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