BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
UseTof.cxx
Go to the documentation of this file.
1//$Header: /bes/bes/BossCvs/Calibration/CalibSvc/CalibROOTCnv/src/test/UseTof.cxx,v 1.14 2019/09/20 07:01:13 sunss 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/Tof/TofCalibData.h"
10#include "CalibData/Tof/bTofCalibBase.h"
11#include "CalibData/CalibModel.h"
12#include "GaudiKernel/DataSvc.h"
13#include "CalibDataSvc/ICalibRootSvc.h"
14
15using namespace std;
16/// Simple algorithm to test functioning of "the other" TDS
17class UseTof : public Algorithm {
18
19public:
20 UseTof(const std::string& name, ISvcLocator* pSvcLocator);
21
22 StatusCode initialize();
23
24 StatusCode execute();
25
26 StatusCode finalize();
27
28private:
29 IDataProviderSvc* m_pCalibDataSvc;
30 ICalibRootSvc* m_pRootSvc;
31 // Maybe something to say which kind of data to look up?
32
33};
34
35/// Instantiation of a static factory to create instances of this algorithm
36//static const AlgFactory<UseTof> Factory;
37//const IAlgFactory& UseCalibFactory = Factory;
38//const IAlgFactory& UseTofFactory = Factory;
39*/
40#include "UseTof.h"
41#include "TFile.h"
42#include "TTree.h"
43#include "TDirectory.h"
44#include "TObject.h"
45
46UseTof::UseTof( const std::string& name,
47 ISvcLocator* pSvcLocator )
48 : Algorithm ( name, pSvcLocator ), m_pCalibDataSvc(0)
49{
50 // Declare properties here.
51
52}
53
54
55StatusCode UseTof::initialize() {
56 StatusCode sc;
57 MsgStream log(msgSvc(), name());
58 log << MSG::INFO << "Initialize()" << endreq;
59
60 // So far don't have any properties, but in case we do some day..
61// setProperties();
62
63 log<<MSG::INFO << "setProperties()" << endreq;
64
65 sc = service("CalibDataSvc", m_pCalibDataSvc, true);
66
67 if ( !sc.isSuccess() ) {
68 log << MSG::ERROR
69 << "Could not get IDataProviderSvc interface of CalibXmlCnvSvc"
70 << endreq;
71 return sc;
72 } else {
73 log << MSG::DEBUG
74 << "Retrieved IDataProviderSvc interface of CalibXmlCnvSvc"
75 << endreq;
76 }
77
78 sc = service("CalibRootCnvSvc", m_pRootSvc, true);
79 if ( !sc.isSuccess() ) {
80 log << MSG::ERROR
81 << "Could not get ICalibRootSvc interface of CalibRootCnvSvc"
82 << endreq;
83 return sc;
84 }
85 // Get properties from the JobOptionsSvc
86
87 sc = setProperties();
88
89 return StatusCode::SUCCESS;
90
91}
92
93
94StatusCode UseTof::execute( ) {
95
96 MsgStream log(msgSvc(), name());
97
98 // Cheat for now since Windows is having trouble finding definition
99 // of Calibdata::Test_t
100 std::string fullPath = "/Calib/TofCal";
101 log << MSG::INFO<<"execute() fullPath = "<<fullPath<< endreq;
102
103 SmartDataPtr<CalibData::TofCalibData> btof(m_pCalibDataSvc, fullPath);
104
105 TFile *f1 = new TFile("TofCalConst.root","read");
106
107 TTree *btoftree = (TTree*)f1 -> Get("BarTofPar");
108 double fCount[10];
109 double fLeft[5];
110 double fRight[5];
111 btoftree ->SetBranchAddress("FCounter0",&fCount[0]);
112 btoftree ->SetBranchAddress("FCounter1",&fCount[1]);
113 btoftree ->SetBranchAddress("FCounter2",&fCount[2]);
114 btoftree ->SetBranchAddress("FCounter3",&fCount[3]);
115 btoftree ->SetBranchAddress("FCounter4",&fCount[4]);
116 btoftree ->SetBranchAddress("FCounter5",&fCount[5]);
117 btoftree ->SetBranchAddress("FCounter6",&fCount[6]);
118 btoftree ->SetBranchAddress("FCounter7",&fCount[7]);
119 btoftree ->SetBranchAddress("FCounter8",&fCount[8]);
120 btoftree ->SetBranchAddress("FCounter9",&fCount[9]);
121 btoftree->SetBranchAddress("FLeft0",&fLeft[0]);
122 btoftree->SetBranchAddress("FLeft1",&fLeft[1]);
123 btoftree->SetBranchAddress("FLeft2",&fLeft[2]);
124 btoftree->SetBranchAddress("FLeft3",&fLeft[3]);
125 btoftree->SetBranchAddress("FLeft4",&fLeft[4]);
126 btoftree->SetBranchAddress("FRight0",&fRight[0]);
127 btoftree->SetBranchAddress("FRight1",&fRight[1]);
128 btoftree->SetBranchAddress("FRight2",&fRight[2]);
129 btoftree->SetBranchAddress("FRight3",&fRight[3]);
130 btoftree->SetBranchAddress("FRight4",&fRight[4]);
131
132
133
134 for(int i =0;i<176;i++) {
135 btoftree -> GetEntry(i);
136
137 double bAtten0 = btof->getBTofAtten(i,0);
138 double bAtten1 = btof->getBTofAtten(i,1);
139 double bP0 = btof->getBTofPleft(i,0);
140 double bP1 = btof->getBTofPleft(i,1);
141 double bP2 = btof->getBTofPleft(i,2);
142 double bP3 = btof->getBTofPleft(i,3);
143 double bP4 = btof->getBTofPleft(i,4);
144 double bP5 = btof->getBTofPleft(i,5);
145 double bP10 = btof->getBTofPright(i,0);
146
147 // double bQ = btof->getBTofQ(i);
148 double bSpeed0 = btof->getBTofSpeed(i,0);
149 double bSpeed1 = btof->getBTofSpeed(i,1);
150 // double bW1 = btof->getBTofW(i,0);
151 // double bW2 = btof->getBTofW(i,1);
152 // double bW3 = btof->getBTofW(i,2);
153 // double bW4 = btof->getBTofW(i,3);
154 // std::cout<<"=========================================="<<"\n";
155 // std::cout<<"cnt ="<<i<<"\n";
156 double fCount1[10],fLeft1[5],fRight1[5];
157 for(int j=0;j<10;j++){
158 fCount1[j]=btof->getBTofFcounter(i,j);
159 if(fCount1[j]!=fCount[j]) std::cout<<"error error error error"<<std::endl;
160 // std::cout<<"
161 // std::cout<<" fCount["<<j<<"]="<<fCount[j]<<" fCount1["<<j<<"]="<<fCount1[j];
162 }
163 // std::cout<<"\n"<<"=========================================="<<"\n";
164 for(int j=0;j<5;j++){
165 fLeft1[j]=btof->getBTofFleft(i,j);
166 if(fLeft1[j]!=fLeft[j]) std::cout<<"error error error error"<<std::endl;
167 // std::cout<<" fLeft["<<j<<"]="<<fLeft[j];
168 }
169 // std::cout<<"\n"<<"=========================================="<<"\n";
170
171 for(int j=0;j<5;j++){
172 fRight1[j]=btof->getBTofFright(i,j);
173 if( fRight1[j]!= fRight[j]) std::cout<<"error error error error"<<std::endl;
174 // std::cout<<" fRight["<<j<<"]="<<fRight[j];
175 }
176
177
178 /* std::cout<<"Atten0="<<bAtten0<<"Atten1="<<bAtten1<<"Q="<<bQ<<"Speed0="<<bSpeed0<<"Speed1="<<bSpeed1<<"P0="<<bP0<<"P1="<<bP1<<"P2="<<bP2<<"P3="<<bP3<<"P4="<<bP4<<"P10="<<bP10;
179 std::cout<<"\n";
180 std::cout<<"P5="<<bP5<<"Q="<<bQ;
181 std::cout<<"W1="<<bW1<<"W2="<<bW2<<"W3="<<bW3<<"W4="<<bW4;
182 std::cout<<"\n";*/
183 /*
184 std::cout<<"Atten[1]="<<*(bAtten+1)<<"P0[1]="<<*(bP0+1)<<"P1[1]="<<*(bP1+1)<<"P2[1]="<<*(bP2+1)<<"P3[1]="<<*(bP3+1)<<"P4[1]="<<*(bP4+1);
185 std::cout<<"\n";
186 std::cout<<"P5[1]="<<*(bP5+1)<<"S[1]="<<*(bS+1)<<"SS[1]="<<*(bSS+1)<<"Veff[1]="<<*(bVeff+1);
187 */
188 }
189/* for(int i =0;i<96;i++)
190 {
191 double eAtten0 = btof->getETofAtten(i,0);
192 double eAtten1 = btof->getETofAtten(i,1);
193 double eP0 = btof->getETofP(i,0);
194 double eP1 = btof->getETofP(i,1);
195 double eP2 = btof->getETofP(i,2);
196 double eP3 = btof->getETofP(i,3);
197 double eP4 = btof->getETofP(i,4);
198 double eP5 = btof->getETofP(i,5);
199 double eP6 = btof->getETofP(i,6);
200 double eSpeed0 = btof->getETofSpeed(i,0);
201 double eSpeed1 = btof->getETofSpeed(i,1);
202
203 std::cout<<"=========================================="<<"\n";
204 std::cout<<"cnt ="<<i<<"\n";
205
206 std::cout<<"Atten0="<<eAtten0<<"Atten1="<<eAtten1<<"Speed0="<<eSpeed0<<"Speed1="<<eSpeed1<<"P0="<<eP0<<"P1="<<eP1<<"P2="<<eP2<<"P3="<<eP3<<"P4="<<eP4<<"P6="<<eP6;
207 std::cout<<"\n";
208 std::cout<<"P5="<<eP5;
209 std::cout<<"\n";
210 }
211*/
212
213/*double P_b[20];
214 TTree *btofinnertree = (TTree*)f1 -> Get("BarTofParInner");
215 btofinnertree->SetBranchAddress("P0",&P_b[0]);
216 btofinnertree->SetBranchAddress("P1",&P_b[1]);
217 btofinnertree->SetBranchAddress("P2",&P_b[2]);
218 btofinnertree->SetBranchAddress("P3",&P_b[3]);
219 btofinnertree->SetBranchAddress("P4",&P_b[4]);
220 btofinnertree->SetBranchAddress("P5",&P_b[5]);
221 btofinnertree->SetBranchAddress("P6",&P_b[6]);
222 btofinnertree->SetBranchAddress("P7",&P_b[7]);
223 btofinnertree->SetBranchAddress("P8",&P_b[8]);
224 btofinnertree->SetBranchAddress("P9",&P_b[9]);
225 btofinnertree->SetBranchAddress("P10",&P_b[10]);
226 btofinnertree->SetBranchAddress("P11",&P_b[11]);
227 btofinnertree->SetBranchAddress("P12",&P_b[12]);
228 btofinnertree->SetBranchAddress("P13",&P_b[13]);
229 btofinnertree->SetBranchAddress("P14",&P_b[14]);
230 btofinnertree->SetBranchAddress("P15",&P_b[15]);
231 btofinnertree->SetBranchAddress("P16",&P_b[16]);
232 btofinnertree->SetBranchAddress("P17",&P_b[17]);
233 btofinnertree->SetBranchAddress("P18",&P_b[18]);
234 btofinnertree->SetBranchAddress("P19",&P_b[19]);
235
236 for(int i=0;i<88;i++){
237 btofinnertree->GetEntry(i);
238 double P[20];
239 std::cout<<"\n"<<" i================= "<<i<<std::endl;
240 for(int j=0;j<10;j++){
241 // P[j]=btof->getBTofInnerPleft(i,j);
242
243 std::cout<<" P["<<j<<"]"<< P[j];
244 }
245
246 for(int j=0;j<10;j++){
247// P[j+10]=btof->getBTofInnerPright(i,j);
248 std::cout<<" P["<<j+10<<"]"<< P[j+10];
249}
250*/
251/*if(P_b[16]!=P[16]){
252 std::cout<<"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"<<std::endl;
253 std::cout<<"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"<<std::endl;
254 std::cout<<"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"<<std::endl;
255 std::cout<<"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"<<std::endl;
256 std::cout<<"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"<<std::endl;
257std::cout<<"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"<<std::endl;
258 std::cout<<"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"<<std::endl;
259}
260 std::cout<<"\n";
261if(P[16]>0){
262std::cout<<"aaa"<<std::endl;
263}
264std::cout<<"P_b[16]===="<<P_b[16]<<"P_[16]"<<P[16]<<std::endl;
265 }
266 */
267 double sigma[8];
268
269 for(int i=0;i<8;i++){
270 sigma[i]=btof->getBTofSigmaCorr(0,i);
271 std::cout<<" sigma["<<i<<"]="<< sigma[i];
272 }
273 std::cout<<"\n";
274
275 std::cout<<" btof->getRunBegin()"<<btof->getRunBegin(0);
276 std::cout<<"btof->getRunEnd()"<<btof->getRunEnd(0);
277 std::cout<<"btof->getVersion()"<<btof->getVersion(0);
278 std::cout<<"btof->getQCorr()"<<btof->getQCorr(0);
279 std::cout<<"btof->getMisLable()"<<btof->getMisLable(0);
280 std::cout<<"btof->getQElec()"<<btof->getQElec(0);
281 for(int i=0;i<5;i++){
282 std::cout<<"i==="<<i<<std::endl;
283 std::cout<<" btof->getBrEast(int index)"<<btof->getBrEast(0,i);
284 std::cout<<" btof->getBrWest(int index)"<<btof->getBrWest(0,i);
285 std::cout<<" btof->getEndcap(int index)"<<btof->getEndcap(0,i);
286 }
287 //maqm comment because cann't write
288 // m_pRootSvc->writeToRoot("./Tof_test.root", fullPath);
289
290 return StatusCode::SUCCESS;
291}
292/*
293DataSvc::retrieveObject(fullPath,CalibData::CalibTest1);
294*/
295StatusCode UseTof::finalize( ) {
296
297 MsgStream log(msgSvc(), name());
298 log << MSG::INFO
299 << " UseTof FINALIZE!! "
300 << endreq;
301
302 return StatusCode::SUCCESS;
303}
304
305
TTree * sigma
TFile * f1
data GetEntry(0)
StatusCode execute()
Definition: UseTof.cxx:94
UseTof(const std::string &name, ISvcLocator *pSvcLocator)
Definition: UseTof.cxx:46
StatusCode initialize()
Definition: UseTof.cxx:55
StatusCode finalize()
Definition: UseTof.cxx:295