BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
UseDedx.cxx
Go to the documentation of this file.
1//$Header: /bes/bes/BossCvs/Calibration/CalibSvc/CalibROOTCnv/src/test/UseDedx.cxx,v 1.7
2//2010/03/05 02:17:54 huangb Exp $
3/*#include <stdio.h>
4#include "CalibData/CalibModel.h"
5#include "CalibData/Dedx/DedxCalibData.h"
6#include "CalibDataSvc/ICalibRootSvc.h"
7#include "GaudiKernel/AlgFactory.h"
8#include "GaudiKernel/Algorithm.h"
9#include "GaudiKernel/DataSvc.h"
10#include "GaudiKernel/IDataProviderSvc.h"
11#include "GaudiKernel/MsgStream.h"
12#include "GaudiKernel/Service.h"
13#include "GaudiKernel/SmartDataPtr.h"
14using namespace std;
15/// Simple algorithm to test functioning of "the other" TDS
16class UseDedx : public Algorithm {
17
18public:
19 UseDedx(const std::string& name, ISvcLocator* pSvcLocator);
20
21 StatusCode initialize();
22
23 StatusCode execute();
24
25 StatusCode finalize();
26
27private:
28 IDataProviderSvc* m_pCalibDataSvc;
29 ICalibRootSvc* m_pRootSvc;
30 // Maybe something to say which kind of data to look up?
31
32};
33
34/// Instantiation of a static factory to create instances of this algorithm
35//static const AlgFactory<UseDedx> Factory;
36//const IAlgFactory& UseCalibFactory = Factory;
37//const IAlgFactory& UseDedxFactory = Factory;
38*/
39#include "UseDedx.h"
40UseDedx::UseDedx( const std::string& name, ISvcLocator* pSvcLocator )
41 : Algorithm( name, pSvcLocator ), m_pCalibDataSvc( 0 ) {
42 // Declare properties here.
43}
44
45StatusCode UseDedx::initialize() {
46 StatusCode sc;
47 MsgStream log( msgSvc(), name() );
48 log << MSG::INFO << "Initialize()" << endmsg;
49
50 // So far don't have any properties, but in case we do some day..
51 // setProperties();
52
53 log << MSG::INFO << "setProperties()" << endmsg;
54
55 sc = service( "CalibDataSvc", m_pCalibDataSvc, true );
56
57 if ( !sc.isSuccess() )
58 {
59 log << MSG::ERROR << "Could not get IDataProviderSvc interface of CalibXmlCnvSvc"
60 << endmsg;
61 return sc;
62 }
63 else
64 { log << MSG::DEBUG << "Retrieved IDataProviderSvc interface of CalibXmlCnvSvc" << endmsg; }
65
66 sc = service( "CalibRootCnvSvc", m_pRootSvc, true );
67 if ( !sc.isSuccess() )
68 {
69 log << MSG::ERROR << "Could not get ICalibRootSvc interface of CalibRootCnvSvc" << endmsg;
70 return sc;
71 }
72
73 // Get properties from the JobOptionsSvc
74
75 sc = setProperties();
76
77 return StatusCode::SUCCESS;
78}
79
80StatusCode UseDedx::execute() {
81
82 MsgStream log( msgSvc(), name() );
83
84 std::string fullPath = "/Calib/DedxCal";
85
86 log << MSG::INFO << "execute() fullPath = " << fullPath << endmsg;
87
88 SmartDataPtr<CalibData::DedxCalibData> test( m_pCalibDataSvc, fullPath );
89 int i;
90 int j;
91 double ddg;
92 double ggs;
93 double wireg;
94 double gain;
95 double zdep;
96 double resol;
97 double layerg;
98 double m_id_doca;
99 double m_iner_chi;
100 double m_iner_gain;
101 double m_iner_hits;
102 double m_ip_eangle;
103 double m_out_chi;
104 double m_out_gain;
105 double m_out_hits;
106
107 for ( i = 0; i < 4; i++ )
108 {
109 for ( j = 0; j < 43; j++ )
110 {
111 ddg = test->getddg( i, j );
112 ggs = test->getggs( i, j );
113 zdep = test->getzdep( i, j );
114 // std::cout<<"ddg["<<i<<"]["<<j<<"]="<<ddg;
115 // std::cout<<" ggs["<<i<<"]["<<j<<"]="<<ggs;
116 // std::cout<<" zdep["<<i<<"]["<<j<<"]="<<zdep;
117 // std::cout<<"\n";
118 }
119 }
120
121 for ( int i = 0; i < 1600; i++ )
122 {
123 m_id_doca = test->get_id_doca( i );
124 m_iner_chi = test->get_iner_chi( i );
125 m_iner_gain = test->get_iner_gain( i );
126 m_iner_hits = test->get_iner_hits( i );
127 m_ip_eangle = test->get_ip_eangle( i );
128 m_out_chi = test->get_out_chi( i );
129 m_out_gain = test->get_out_gain( i );
130 m_out_hits = test->get_out_hits( i );
131 std::cout << "m_id_doca: " << m_id_doca << " m_iner_chi: " << m_iner_chi
132 << " m_iner_gain: " << m_iner_gain << " m_iner_hits:" << m_iner_hits
133 << " m_ip_eangle:" << m_ip_eangle << " m_out_chi=" << m_out_chi
134 << " m_out_gain:" << m_out_gain << " m_out_hits=" << m_out_hits << std::endl;
135 }
136 gain = test->getgain();
137 // std::cout<<"gain="<<gain<<"\n";
138 double m_costheta;
139 for ( int i = 0; i < 80; i++ )
140 {
141 m_costheta = test->get_costheta( i );
142 std::cout << " m_costheta=" << m_costheta;
143 if ( i % 5 == 0 ) std::cout << "\n" << std::endl;
144 }
145 double t0, dedx;
146 for ( int i = 0; i < 35; i++ )
147 {
148 t0 = test->get_t0( i );
149 dedx = test->get_dedx( i );
150 std::cout << "t0 =" << t0 << " dedx=" << dedx;
151 if ( i % 5 == 0 ) std::cout << "\n" << std::endl;
152 }
153
154 resol = test->getresol();
155 // std::cout<<"resol="<<resol<<"\n";
156
157 for ( i = 0; i < 43; i++ )
158 {
159 layerg = test->getlayerg( i );
160 // std::cout<<"layerg["<<i<<"]="<<layerg;
161 }
162
163 for ( i = 0; i < 60; i++ )
164 {
165 wireg = test->getwireg( i );
166 // std::cout<<"wireg["<<i<<"]="<<wireg<<"\n";
167 }
168
169 for ( i = 0; i < 20; i++ ) { std::cout << "hadron " << i << " = " << test->get_hadron( i ); }
170
171 // for pah is error
172 // m_pRootSvc->writeToRoot("/home/huangb/2.root", fullPath);
173 return StatusCode::SUCCESS;
174}
175
176StatusCode UseDedx::finalize() {
177
178 MsgStream log( msgSvc(), name() );
179 log << MSG::INFO << " UseDedx FINALIZE!! " << endmsg;
180
181 return StatusCode::SUCCESS;
182}
std::string test
IMessageSvc * msgSvc()
UseDedx(const std::string &name, ISvcLocator *pSvcLocator)
Definition UseDedx.cxx:40
StatusCode initialize()
Definition UseDedx.cxx:45
StatusCode finalize()
Definition UseDedx.cxx:176
StatusCode execute()
Definition UseDedx.cxx:80