BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
RootTofCalibDataCnv.cxx
Go to the documentation of this file.
1// $Header: /bes/bes/BossCvs/Calibration/CalibSvc/CalibROOTCnv/src/cnv/RootTofCalibDataCnv.cxx,v 1.20 2019/09/20 07:01:13 sunss Exp $
2#include "GaudiKernel/MsgStream.h"
4#include "CalibData/Tof/TofCalibData.h"
5#include "CalibData/Tof/bTofCalibBase.h"
6#include "CalibData/Tof/eTofCalibBase.h"
7#include "CalibData/Tof/etfCalibBase.h"
8#include "CalibData/Tof/etfBunchCalibBase.h"
9#include "CalibDataSvc/IInstrumentName.h"
10
11#include "TFile.h"
12#include "TTree.h"
13#include "TDirectory.h"
14#include "TObject.h"
15
16#include "GaudiKernel/CnvFactory.h"
17#include "GaudiKernel/IOpaqueAddress.h"
18#include "GaudiKernel/DataObject.h"
19#include "GaudiKernel/IAddressCreator.h"
20#include "GaudiKernel/IDataProviderSvc.h"
21#include "GaudiKernel/IConversionSvc.h"
22#include "GaudiKernel/GenericAddress.h"
23
24#include "CalibDataSvc/ICalibRootSvc.h" //maybe
25#include "CalibDataSvc/ICalibMetaCnvSvc.h"
26
27// Temporary. Hope to find a better way to do this
28#include "CalibData/CalibModel.h"
29using namespace CalibData;
30
31const unsigned int nBarAtten = 8;
32const unsigned int nBarSpeed = 2;
33const unsigned int nBarPar = 10;
34const unsigned int nBarParOff = 20;
35const unsigned int nBarSigma = 5;
36const unsigned int nBarSigCnt = 10;
37
38const unsigned int nBarSigCor = 8;
39const unsigned int nBarOffset = 2;
40
41const unsigned int nEndAtten = 5;
42const unsigned int nEndSpeed = 4;
43const unsigned int nEndPar = 8;
44const unsigned int nEndSigma = 5;
45
46const unsigned int nEtfSpeed = 4;
47const unsigned int nEtfPar = 20;
48const unsigned int nEtfBunch = 4;
49
50
53 }
54
55
56const CLID& RootTofCalibDataCnv::objType() const {
57 return CLID_Calib_TofCal;
58}
59
61 return CLID_Calib_TofCal;
62}
63
64StatusCode RootTofCalibDataCnv::i_createObj(const std::string& fname,
65 DataObject*& refpObject) {
66
67 MsgStream log(msgSvc(), "RootTofCalibDataCnv");
68 log<<MSG::DEBUG<<"SetProperty"<<endreq;
69
70 // open the file
71 StatusCode sc = openRead(fname);
72 if(!sc)
73 { log<<MSG::ERROR<<"unable to open files"<<endreq;
74 }
75
82
83 std::vector<CalibData::bTofCalibBase> tmpbTof;
84 std::vector<CalibData::eTofCalibBase> tmpeTof;
85 std::vector<CalibData::etfCalibBase> tmpetf;
86 std::vector<CalibData::etfBunchCalibBase> tmpetfBunch;
87 std::vector<CalibData::bTofCommonCalibBase> tmpbTofCommon;
88 std::vector<CalibData::tofCalibInfoBase> tofinfoCol;
89 // Read in the object
90 int cnt;
91 // read btoftree ------------------------------------------------------------
92
93 double cnvBarAtten[nBarAtten];
94 double cnvBarSpeed[nBarSpeed];
95 double cnvBarPar1[nBarPar];
96 double cnvBarPar2[nBarPar];
97 double cnvBarParOff1_bunch0[nBarParOff];
98 double cnvBarParOff2_bunch0[nBarParOff];
99 double cnvBarParOff1_bunch1[nBarParOff];
100 double cnvBarParOff2_bunch1[nBarParOff];
101 double cnvBarParOff1_bunch2[nBarParOff];
102 double cnvBarParOff2_bunch2[nBarParOff];
103 double cnvBarParOff1_bunch3[nBarParOff];
104 double cnvBarParOff2_bunch3[nBarParOff];
105 double cnvFLeft[nBarSigma];
106 double cnvFRight[nBarSigma];
107 double cnvFCount[nBarSigCnt];
108
109 TTree *btoftree = (TTree*)m_inFile -> Get("BarTofPar");
110
111 char brname[10];
112 for( unsigned int i=0; i<nBarAtten; i++ ) {
113 sprintf( brname, "Atten%i", i );
114 btoftree -> SetBranchAddress( brname, &cnvBarAtten[i] );
115 }
116 for( unsigned int i=0; i<nBarSpeed; i++ ) {
117 sprintf( brname, "Speed%i", i );
118 btoftree -> SetBranchAddress( brname, &cnvBarSpeed[i] );
119 }
120 for( unsigned int i=0; i<nBarPar; i++ ) {
121 sprintf( brname, "P%i", i );
122 btoftree -> SetBranchAddress( brname, &cnvBarPar1[i] );
123 }
124 for( unsigned int i=0; i<nBarPar; i++ ) {
125 sprintf( brname, "P%i", i+nBarPar );
126 btoftree -> SetBranchAddress( brname, &cnvBarPar2[i] );
127 }
128 for( unsigned int i=0; i<nBarParOff; i++ ) {
129 sprintf( brname, "Bunch0_Poff%i", i );
130 btoftree -> SetBranchAddress( brname, &cnvBarParOff1_bunch0[i] );
131 }
132 for( unsigned int i=0; i<nBarParOff; i++ ) {
133 sprintf( brname, "Bunch0_Poff%i", i+nBarParOff );
134 btoftree -> SetBranchAddress( brname, &cnvBarParOff2_bunch0[i] );
135 }
136 for( unsigned int i=0; i<nBarParOff; i++ ) {
137 sprintf( brname, "Bunch1_Poff%i", i );
138 btoftree -> SetBranchAddress( brname, &cnvBarParOff1_bunch1[i] );
139 }
140 for( unsigned int i=0; i<nBarParOff; i++ ) {
141 sprintf( brname, "Bunch1_Poff%i", i+nBarParOff );
142 btoftree -> SetBranchAddress( brname, &cnvBarParOff2_bunch1[i] );
143 }
144 for( unsigned int i=0; i<nBarParOff; i++ ) {
145 sprintf( brname, "Bunch2_Poff%i", i );
146 btoftree -> SetBranchAddress( brname, &cnvBarParOff1_bunch2[i] );
147 }
148 for( unsigned int i=0; i<nBarParOff; i++ ) {
149 sprintf( brname, "Bunch2_Poff%i", i+nBarParOff );
150 btoftree -> SetBranchAddress( brname, &cnvBarParOff2_bunch2[i] );
151 }
152 for( unsigned int i=0; i<nBarParOff; i++ ) {
153 sprintf( brname, "Bunch3_Poff%i", i );
154 btoftree -> SetBranchAddress( brname, &cnvBarParOff1_bunch3[i] );
155 }
156 for( unsigned int i=0; i<nBarParOff; i++ ) {
157 sprintf( brname, "Bunch3_Poff%i", i+nBarParOff );
158 btoftree -> SetBranchAddress( brname, &cnvBarParOff2_bunch3[i] );
159 }
160 for( unsigned int i=0; i<nBarSigma; i++ ) {
161 sprintf( brname, "FLeft%i", i );
162 btoftree -> SetBranchAddress( brname, &cnvFLeft[i] );
163 }
164 for( unsigned int i=0; i<nBarSigma; i++ ) {
165 sprintf( brname, "FRight%i", i );
166 btoftree -> SetBranchAddress( brname, &cnvFRight[i] );
167 }
168 for( unsigned int i=0; i<nBarSigCnt; i++ ) {
169 sprintf( brname, "FCounter%i", i );
170 btoftree -> SetBranchAddress( brname, &cnvFCount[i] );
171 }
172
173 for(cnt=0; cnt<btoftree->GetEntries(); cnt++){
174 btoftree -> GetEntry(cnt);
175 bTof.setAtten( cnvBarAtten );
176 bTof.setSpeed( cnvBarSpeed );
177 bTof.setP1( cnvBarPar1 );
178 bTof.setP2( cnvBarPar2 );
179 bTof.setPoff1_bunch0( cnvBarParOff1_bunch0 );
180 bTof.setPoff2_bunch0( cnvBarParOff2_bunch0 );
181 bTof.setPoff1_bunch1( cnvBarParOff1_bunch1 );
182 bTof.setPoff2_bunch1( cnvBarParOff2_bunch1 );
183 bTof.setPoff1_bunch2( cnvBarParOff1_bunch2 );
184 bTof.setPoff2_bunch2( cnvBarParOff2_bunch2 );
185 bTof.setPoff1_bunch3( cnvBarParOff1_bunch3 );
186 bTof.setPoff2_bunch3( cnvBarParOff2_bunch3 );
187 bTof.setFPleft( cnvFLeft );
188 bTof.setFPright( cnvFRight );
189 bTof.setFPcounter( cnvFCount );
190 tmpbTof.push_back(bTof);
191 }
192
193 //read etoftree
194 double cnvEndAtten[nEndAtten];
195 double cnvEndSpeed[nEndSpeed];
196 double cnvEndPar[nEndPar];
197 double cnvEndFPar[nEndSigma];
198
199 TTree *etoftree = (TTree*)m_inFile -> Get("EndTofPar");
200
201 char ecname[10];
202 for( unsigned int i=0; i<nEndAtten; i++ ) {
203 sprintf( ecname, "Atten%i", i );
204 etoftree -> SetBranchAddress( ecname, &cnvEndAtten[i] );
205 }
206 for( unsigned int i=0; i<nEndSpeed; i++ ) {
207 sprintf( ecname, "Speed%i", i );
208 etoftree -> SetBranchAddress( ecname, &cnvEndSpeed[i] );
209 }
210 for( unsigned int i=0; i<nEndPar; i++ ) {
211 sprintf( ecname, "P%i", i );
212 etoftree -> SetBranchAddress( ecname, &cnvEndPar[i] );
213 }
214 for( unsigned int i=0; i<nEndSigma; i++ ) {
215 sprintf( ecname, "FCounter%i", i );
216 etoftree -> SetBranchAddress( ecname, &cnvEndFPar[i] );
217 }
218
219 for(cnt=0; cnt<etoftree->GetEntries(); cnt++){
220 etoftree -> GetEntry(cnt);
221 eTof.setAtten( cnvEndAtten );
222 eTof.setSpeed( cnvEndSpeed );
223 eTof.setP( cnvEndPar );
224 eTof.setFP( cnvEndFPar );
225 tmpeTof.push_back(eTof);
226 }
227
228 //read etftree
229 double cnvEtfSpeed[nEtfSpeed];
230 double cnvEtfPar[nEtfPar];
231 double cnvEtfPar1[nEtfPar];
232 double cnvEtfPar2[nEtfPar];
233
234 if( NULL!=m_inFile->Get("EtfTofPar") ) {
235 TTree *etftree = (TTree*)m_inFile -> Get("EtfTofPar");
236
237 char etfname[10];
238 for( unsigned int i=0; i<nEtfSpeed; i++ ) {
239 sprintf( etfname, "Speed%i", i );
240 etftree -> SetBranchAddress( etfname, &cnvEtfSpeed[i] );
241 }
242 for( unsigned int i=0; i<nEtfPar; i++ ) {
243 sprintf( etfname, "P%i", i );
244 etftree -> SetBranchAddress( etfname, &cnvEtfPar[i] );
245 }
246 for( unsigned int i=0; i<nEtfPar; i++ ) {
247 sprintf( etfname, "P%i", i+nEtfPar );
248 etftree -> SetBranchAddress( etfname, &cnvEtfPar1[i] );
249 }
250 for( unsigned int i=0; i<nEtfPar; i++ ) {
251 sprintf( etfname, "P%i", i+2*nEtfPar );
252 etftree -> SetBranchAddress( etfname, &cnvEtfPar2[i] );
253 }
254
255 for(cnt=0; cnt<etftree->GetEntries(); cnt++){
256 etftree -> GetEntry(cnt);
257 etf.setSpeed( cnvEtfSpeed );
258 etf.setP( cnvEtfPar );
259 etf.setP1( cnvEtfPar1 );
260 etf.setP2( cnvEtfPar2 );
261 tmpetf.push_back(etf);
262 }
263 }
264
265 //read etfbunchtree
266 double cnvEtfBunchP[nEtfBunch];
267
268 if( NULL!=m_inFile->Get("EtfTofBunch") ) {
269 TTree *etfbunchtree = (TTree*)m_inFile -> Get("EtfTofBunch");
270
271 char etfbunchname[10];
272 for( unsigned int i=0; i<nEtfBunch; i++ ) {
273 sprintf( etfbunchname, "pbunch%i", i );
274 etfbunchtree -> SetBranchAddress( etfbunchname, &cnvEtfBunchP[i] );
275 }
276
277 int entries= etfbunchtree->GetEntries();
278 for(cnt=0;cnt<entries;cnt++){
279 etfbunchtree -> GetEntry(cnt);
280 etfBunch.setPBunch( cnvEtfBunchP );
281 tmpetfBunch.push_back( etfBunch );
282 }
283 }
284
285 //read bTofCommonCalibBase
286 double cnvBarSigCor[nBarSigCor];
287 double cnvBarOffset[nBarOffset];
288 TTree *btofcommontree = (TTree*)m_inFile -> Get("BarTofParCommon");
289 for( unsigned int i=0; i<nBarSigCor; i++ ) {
290 sprintf( brname, "sigmaCorr%i", i );
291 btofcommontree-> SetBranchAddress( brname, &cnvBarSigCor[i] );
292 }
293 for( unsigned int i=0; i<nBarOffset; i++ ) {
294 sprintf( brname, "t0offset%i", i );
295 btofcommontree-> SetBranchAddress( brname, &cnvBarOffset[i]);
296 }
297
298 int entries = btofcommontree->GetEntries();
299 for(cnt=0;cnt<entries;cnt++){
300 btofcommontree->GetEntry(cnt);
301 bTofCommon.setSigmaCorr( cnvBarSigCor );
302 bTofCommon.setOffset( cnvBarOffset );
303 tmpbTofCommon.push_back(bTofCommon);
304 }
305
306 int m_run1, m_run2, m_version;
307 int m_qCorr, m_qElec, m_misLable;
308 int m_tofidEast[5], m_tofidWest[5], m_tofidEndcap[5];
309 int m_runFrom, m_runTo, m_eventFrom, m_eventTo;
310
311 TTree *CalibInfo = (TTree*)m_inFile -> Get("CalibInfo");
312 CalibInfo->SetBranchAddress("Run1", &m_run1 );
313 CalibInfo->SetBranchAddress("Run2", &m_run2 );
314 CalibInfo->SetBranchAddress("Version", &m_version );
315 CalibInfo->SetBranchAddress("ebrId0", &m_tofidEast[0] );
316 CalibInfo->SetBranchAddress("ebrId1", &m_tofidEast[1] );
317 CalibInfo->SetBranchAddress("ebrId2", &m_tofidEast[2] );
318 CalibInfo->SetBranchAddress("ebrId3", &m_tofidEast[3] );
319 CalibInfo->SetBranchAddress("ebrId4", &m_tofidEast[4] );
320 CalibInfo->SetBranchAddress("ecId0", &m_tofidEndcap[0] );
321 CalibInfo->SetBranchAddress("ecId1", &m_tofidEndcap[1] );
322 CalibInfo->SetBranchAddress("ecId2", &m_tofidEndcap[2] );
323 CalibInfo->SetBranchAddress("ecId3", &m_tofidEndcap[3] );
324 CalibInfo->SetBranchAddress("ecId4", &m_tofidEndcap[4] );
325 CalibInfo->SetBranchAddress("wbrId0", &m_tofidWest[0] );
326 CalibInfo->SetBranchAddress("wbrId1", &m_tofidWest[1] );
327 CalibInfo->SetBranchAddress("wbrId2", &m_tofidWest[2] );
328 CalibInfo->SetBranchAddress("wbrId3", &m_tofidWest[3] );
329 CalibInfo->SetBranchAddress("wbrId4", &m_tofidWest[4] );
330 CalibInfo->SetBranchAddress("misLable",&m_misLable );
331 CalibInfo->SetBranchAddress("qCorr", &m_qCorr );
332 CalibInfo->SetBranchAddress("qElec", &m_qElec );
333 if( CalibInfo->GetBranchStatus("runFrom") ){
334 CalibInfo->SetBranchAddress("runFrom", &m_runFrom );
335 CalibInfo->SetBranchAddress("runTo", &m_runTo );
336 CalibInfo->SetBranchAddress("eventFrom", &m_eventFrom );
337 CalibInfo->SetBranchAddress("eventTo", &m_eventTo );
338 }
339 else {
340 m_runFrom = -1;
341 m_runTo = -1;
342 m_eventFrom = -1;
343 m_eventTo = -1;
344 }
345
346 entries= CalibInfo->GetEntries();
347 for(cnt=0;cnt<entries;cnt++){
348 CalibInfo->GetEntry(cnt);
349 tofinfo.setRunBegin(m_run1);
350 tofinfo.setRunEnd(m_run2);
351 tofinfo.setVersion(m_version);
352 tofinfo.setQCorr(m_qCorr);
353 tofinfo.setQElec(m_qElec);
354 tofinfo.setMisLable(m_misLable);
355 tofinfo.setBrEast(m_tofidEast);
356 tofinfo.setBrWest(m_tofidWest);
357 tofinfo.setEndcap(m_tofidEndcap);
358 tofinfo.setRunFrom(m_runFrom);
359 tofinfo.setRunTo(m_runTo);
360 tofinfo.setEventFrom(m_eventFrom);
361 tofinfo.setEventTo(m_eventTo);
362 tofinfoCol.push_back(tofinfo);
363 }
364
365 CalibData::TofCalibData *tmpObject = new CalibData::TofCalibData(&tmpbTof,&tmpbTofCommon,&tmpeTof,&tmpetf,&tmpetfBunch,&tofinfoCol);
366
367 refpObject=tmpObject;
368
369 return StatusCode::SUCCESS;
370}
371
372StatusCode RootTofCalibDataCnv::createRoot(const std::string& fname,
373 CalibData::CalibBase1* pTDSObj) {
374 MsgStream log(msgSvc(), "RootTofCalibDataCnv");
375
376 // Open the file, create the branch
377 StatusCode sc = openWrite(fname);
378 if(!sc)
379 { log<<MSG::ERROR<<"unable to open files"<<endreq;
380 }
381 // write the Data in the TCDS to RootFile
382 int j;
383 CalibData::TofCalibData* btof = dynamic_cast<CalibData::TofCalibData*>(pTDSObj);
384
385 // write btoftree----------------------------------------------------------------
386 double cnvBarAtten[nBarAtten];
387 double cnvBarSpeed[nBarSpeed];
388 double cnvBarPar1[nBarPar];
389 double cnvBarPar2[nBarPar];
390 double cnvBarParOff1_bunch0[nBarParOff];
391 double cnvBarParOff2_bunch0[nBarParOff];
392 double cnvBarParOff1_bunch1[nBarParOff];
393 double cnvBarParOff2_bunch1[nBarParOff];
394 double cnvBarParOff1_bunch2[nBarParOff];
395 double cnvBarParOff2_bunch2[nBarParOff];
396 double cnvBarParOff1_bunch3[nBarParOff];
397 double cnvBarParOff2_bunch3[nBarParOff];
398 double cnvFLeft[nBarSigma];
399 double cnvFRight[nBarSigma];
400 double cnvFCount[nBarSigCnt];
401
402 char brname[8], ibrname[8];
403 TTree *btoftree = new TTree("BarTofPar", "BarTofPar");
404 for( unsigned int i=0; i<nBarAtten; i++ ) {
405 sprintf( brname, "Atten%i", i );
406 sprintf( ibrname, "Atten%i/D", i );
407 btoftree -> Branch( brname, &cnvBarAtten[i], ibrname );
408 }
409 for( unsigned int i=0; i<nBarSpeed; i++ ) {
410 sprintf( brname, "Speed%i", i );
411 sprintf( ibrname, "Speed%i/D", i );
412 btoftree -> Branch( brname, &cnvBarSpeed[i], ibrname );
413 }
414 for( unsigned int i=0; i<nBarPar; i++ ) {
415 sprintf( brname, "P%i", i );
416 sprintf( ibrname, "P%i/D", i );
417 btoftree -> Branch( brname, &cnvBarPar1[i], ibrname );
418 }
419 for( unsigned int i=0; i<nBarPar; i++ ) {
420 sprintf( brname, "P%i", i+nBarPar );
421 sprintf( ibrname, "P%i/D", i+nBarPar );
422 btoftree -> Branch( brname, &cnvBarPar2[i], ibrname );
423 }
424 for( unsigned int i=0; i<nBarParOff; i++ ) {
425 sprintf( brname, "Bunch0_Poff%i", i );
426 sprintf( ibrname, "Bunch0_Poff%i/D", i );
427 btoftree -> Branch( brname, &cnvBarParOff1_bunch0[i], ibrname );
428 }
429 for( unsigned int i=0; i<nBarParOff; i++ ) {
430 sprintf( brname, "Bunch0_Poff%i", i+nBarParOff );
431 sprintf( ibrname, "Bunch0_Poff%i/D", i+nBarParOff );
432 btoftree -> Branch( brname, &cnvBarParOff2_bunch0[i], ibrname );
433 }
434 for( unsigned int i=0; i<nBarParOff; i++ ) {
435 sprintf( brname, "Bunch1_Poff%i", i );
436 sprintf( ibrname, "Bunch1_Poff%i/D", i );
437 btoftree -> Branch( brname, &cnvBarParOff1_bunch1[i], ibrname );
438 }
439 for( unsigned int i=0; i<nBarParOff; i++ ) {
440 sprintf( brname, "Bunch1_Poff%i", i+nBarParOff );
441 sprintf( ibrname, "Bunch1_Poff%i/D", i+nBarParOff );
442 btoftree -> Branch( brname, &cnvBarParOff2_bunch1[i], ibrname );
443 }
444 for( unsigned int i=0; i<nBarParOff; i++ ) {
445 sprintf( brname, "Bunch2_Poff%i", i );
446 sprintf( ibrname, "Bunch2_Poff%i/D", i );
447 btoftree -> Branch( brname, &cnvBarParOff1_bunch2[i], ibrname );
448 }
449 for( unsigned int i=0; i<nBarParOff; i++ ) {
450 sprintf( brname, "Bunch2_Poff%i", i+nBarParOff );
451 sprintf( ibrname, "Bunch2_Poff%i/D", i+nBarParOff );
452 btoftree -> Branch( brname, &cnvBarParOff2_bunch2[i], ibrname );
453 }
454 for( unsigned int i=0; i<nBarParOff; i++ ) {
455 sprintf( brname, "Bunch3_Poff%i", i );
456 sprintf( ibrname, "Bunch3_Poff%i/D", i );
457 btoftree -> Branch( brname, &cnvBarParOff1_bunch3[i], ibrname );
458 }
459 for( unsigned int i=0; i<nBarParOff; i++ ) {
460 sprintf( brname, "Bunch3_Poff%i", i+nBarParOff );
461 sprintf( ibrname, "Bunch3_Poff%i/D", i+nBarParOff );
462 btoftree -> Branch( brname, &cnvBarParOff2_bunch3[i], ibrname );
463 }
464 for( unsigned int i=0; i<nBarSigma; i++ ) {
465 sprintf( brname, "FLeft%i", i );
466 sprintf( ibrname, "FLeft%i/D", i );
467 btoftree -> Branch( brname, &cnvFLeft[i], ibrname );
468 }
469 for( unsigned int i=0; i<nBarSigma; i++ ) {
470 sprintf( brname, "FRight%i", i );
471 sprintf( ibrname, "FRight%i/D", i );
472 btoftree -> Branch( brname, &cnvFRight[i], ibrname );
473 }
474 for( unsigned int i=0; i<nBarSigCnt; i++ ) {
475 sprintf( brname, "FCounter%i", i );
476 sprintf( ibrname, "FCounter%i/D", i );
477 btoftree -> Branch( brname, &cnvFCount[i], ibrname );
478 }
479
480 for( int i=0; i<176; i++ ) {
481 for(j=0;j<static_cast<int>(nBarAtten);j++) {
482 cnvBarAtten[j] = btof->getBTofAtten(i,j);
483 }
484 for(j=0;j<static_cast<int>(nBarSpeed);j++) {
485 cnvBarSpeed[j] = btof->getBTofSpeed(i,j);
486 }
487 for(j=0;j<static_cast<int>(nBarPar);j++){
488 cnvBarPar1[j] = btof->getBTofPleft(i,j);
489 cnvBarPar2[j] = btof->getBTofPright(i,j);
490 }
491 for(j=0;j<static_cast<int>(nBarParOff);j++){
492 cnvBarParOff1_bunch0[j] = btof->getBTofPoffleft_bunch0(i,j);
493 cnvBarParOff2_bunch0[j] = btof->getBTofPoffright_bunch0(i,j);
494 }
495 for(j=0;j<static_cast<int>(nBarParOff);j++){
496 cnvBarParOff1_bunch1[j] = btof->getBTofPoffleft_bunch1(i,j);
497 cnvBarParOff2_bunch1[j] = btof->getBTofPoffright_bunch1(i,j);
498 }
499 for(j=0;j<static_cast<int>(nBarParOff);j++){
500 cnvBarParOff1_bunch2[j] = btof->getBTofPoffleft_bunch2(i,j);
501 cnvBarParOff2_bunch2[j] = btof->getBTofPoffright_bunch2(i,j);
502 }
503 for(j=0;j<static_cast<int>(nBarParOff);j++){
504 cnvBarParOff1_bunch3[j] = btof->getBTofPoffleft_bunch3(i,j);
505 cnvBarParOff2_bunch3[j] = btof->getBTofPoffright_bunch3(i,j);
506 }
507 for(j=0;j<static_cast<int>(nBarSigma);j++){
508 cnvFLeft[j] = btof->getBTofFleft(i,j);
509 cnvFRight[j] = btof->getBTofFright(i,j);
510 }
511 for(j=0;j<static_cast<int>(nBarSigCnt);j++){
512 cnvFCount[j] = btof->getBTofFcounter(i,j);
513 }
514 btoftree -> Fill();
515 }
516
517 //write etoftree----------------------------------------------------------------
518 double cnvEndAtten[nEndAtten];
519 double cnvEndSpeed[nEndSpeed];
520 double cnvEndPar[nEndPar];
521 double cnvEndFPar[nEndSigma];
522
523 char ecname[8], iecname[8];
524 TTree *etoftree = new TTree("EndTofPar", "EndTofPar");
525 for( unsigned int i=0; i<nEndAtten; i++ ) {
526 sprintf( ecname, "Atten%i", i );
527 sprintf( iecname, "Atten%i/D", i );
528 etoftree -> Branch( ecname, &cnvEndAtten[i], iecname );
529 }
530 for( unsigned int i=0; i<nEndSpeed; i++ ) {
531 sprintf( ecname, "Speed%i", i );
532 sprintf( iecname, "Speed%i/D", i );
533 etoftree -> Branch( ecname, &cnvEndSpeed[i], iecname );
534 }
535 for( unsigned int i=0; i<nEndPar; i++ ) {
536 sprintf( ecname, "P%i", i );
537 sprintf( iecname, "P%i/D", i );
538 etoftree -> Branch( ecname, &cnvEndPar[i], iecname );
539 }
540 for( unsigned int i=0; i<nEndSigma; i++ ) {
541 sprintf( ecname, "FCounter%i", i );
542 sprintf( iecname, "FCounter%i/D", i );
543 etoftree -> Branch( ecname, &cnvEndFPar[i], iecname );
544 }
545
546 for(int i=0; i<96; i++){
547 for(j=0;j<static_cast<int>(nEndAtten);j++) {
548 cnvEndAtten[j] = btof->getETofAtten(i,j);
549 }
550 for(j=0;j<static_cast<int>(nEndSpeed);j++) {
551 cnvEndSpeed[j] = btof->getETofSpeed(i,j);
552 }
553 for(j=0;j<static_cast<int>(nEndPar);j++){
554 cnvEndPar[j] = btof->getETofP(i,j);
555 }
556 for(j=0;j<static_cast<int>(nEndSigma);j++){
557 cnvEndFPar[j] = btof->getETofFP(i,j);
558 }
559 etoftree -> Fill();
560 }
561
562 //write etftree----------------------------------------------------------------
563 double cnvEtfSpeed[nEtfSpeed];
564 double cnvEtfPar[nEtfPar];
565 double cnvEtfPar1[nEtfPar];
566 double cnvEtfPar2[nEtfPar];
567
568 char etfname[8], ietfname[8];
569 TTree *etftree = new TTree("EtfTofPar", "EtfTofPar");
570 for( unsigned int i=0; i<nEtfSpeed; i++ ) {
571 sprintf( etfname, "Speed%i", i );
572 sprintf( ietfname, "Speed%i/D", i );
573 etftree -> Branch( etfname, &cnvEtfSpeed[i], ietfname );
574 }
575 for( unsigned int i=0; i<nEtfPar; i++ ) {
576 sprintf( etfname, "P%i", i );
577 sprintf( ietfname, "P%i/D", i );
578 etftree -> Branch( etfname, &cnvEtfPar[i], ietfname );
579 }
580 for( unsigned int i=0; i<nEtfPar; i++ ) {
581 sprintf( etfname, "P%i", i+nEtfPar );
582 sprintf( ietfname, "P%i/D", i+nEtfPar );
583 etftree -> Branch( etfname, &cnvEtfPar1[i], ietfname );
584 }
585 for( unsigned int i=0; i<nEtfPar; i++ ) {
586 sprintf( etfname, "P%i", i+2*nEtfPar );
587 sprintf( ietfname, "P%i/D", i+2*nEtfPar );
588 etftree -> Branch( etfname, &cnvEtfPar2[i], ietfname );
589 }
590
591 for( int i=0; i<72; i++ ) {
592 for( int k=0; k<12; k++ ) {
593 for(j=0;j<static_cast<int>(nEtfSpeed);j++) {
594 cnvEtfSpeed[j] = btof->getEtfSpeed(i,k,j);
595 }
596 for(j=0;j<static_cast<int>(nEtfPar);j++){
597 cnvEtfPar[j] = btof->getEtfPcombine(i,k,j);
598 cnvEtfPar1[j] = btof->getEtfPleft(i,k,j);
599 cnvEtfPar2[j] = btof->getEtfPright(i,k,j);
600 }
601 etftree -> Fill();
602 }
603 }
604
605 //write etftree----------------------------------------------------------------
606 double cnvEtfBunchP[nEtfBunch];
607
608 char etfbunchname[8], ietfbunchname[8];
609 TTree *etfbunchtree = new TTree("EtfTofBunch", "EtfTofBunch");
610 for( unsigned int i=0; i<nEtfBunch; i++ ) {
611 sprintf( etfbunchname, "pbunch%i", i );
612 sprintf( ietfbunchname, "pbunch%i/D", i );
613 etfbunchtree -> Branch( etfbunchname, &cnvEtfBunchP[i], ietfbunchname );
614 }
615
616 for(j=0;j<static_cast<int>(nEtfBunch);j++) {
617 cnvEtfBunchP[j] = btof->getEtfPBunch(0,j);
618 }
619 etfbunchtree -> Fill();
620
621
622 // write all the trees
623 btoftree -> Write();
624 etoftree -> Write();
625 etftree -> Write();
626 etfbunchtree -> Write();
627 delete btoftree;
628 delete etoftree;
629 delete etftree;
630 delete etfbunchtree;
631 closeWrite();
632 log<<MSG::INFO<<"successfully create RootFile"<<endreq;
633
634 return sc;
635}
curve Branch("CurveSize",&CurveSize,"CurveSize/I")
curve Fill()
curve Write()
data GetEntry(0)
data SetBranchAddress("time",&time)
const unsigned int nBarOffset
const unsigned int nBarParOff
const unsigned int nEndPar
const unsigned int nEtfPar
const unsigned int nBarPar
const unsigned int nBarSigma
const unsigned int nEndSigma
const unsigned int nBarSigCor
const unsigned int nEndSpeed
const unsigned int nBarOffset
const unsigned int nBarParOff
const unsigned int nEtfSpeed
const unsigned int nEtfBunch
const unsigned int nEndPar
const unsigned int nEtfPar
const unsigned int nBarSpeed
const unsigned int nEndAtten
const unsigned int nBarAtten
const unsigned int nBarSigCnt
const unsigned int nBarPar
double getETofFP(int index, int pardex)
double getBTofPoffleft_bunch1(int index, int pardex)
double getBTofPoffleft_bunch3(int index, int pardex)
double getBTofSpeed(int index, int pardex)
double getETofP(int index, int pardex)
double getBTofPoffright_bunch3(int index, int pardex)
double getEtfPBunch(int cnx, int pardex)
double getBTofPoffright_bunch2(int index, int pardex)
double getBTofFleft(int index, int pardex)
double getBTofPoffright_bunch0(int index, int pardex)
double getBTofPoffright_bunch1(int index, int pardex)
double getEtfSpeed(int index, int strip, int pardex)
double getBTofFright(int index, int pardex)
double getBTofFcounter(int index, int pardex)
double getBTofPoffleft_bunch2(int index, int pardex)
double getEtfPleft(int index, int strip, int pardex)
double getEtfPcombine(int index, int strip, int pardex)
double getETofAtten(int index, int pardex)
double getBTofAtten(int index, int pardex)
double getBTofPoffleft_bunch0(int index, int pardex)
double getEtfPright(int index, int strip, int pardex)
double getBTofPleft(int index, int pardex)
double getETofSpeed(int index, int pardex)
double getBTofPright(int index, int pardex)
void setP2(const double *TofP2)
void setPoff1_bunch3(const double *TofPoff1_bunch3)
void setFPleft(const double *FP1)
void setPoff2_bunch1(const double *TofPoff2_bunch1)
void setSpeed(const double *Speed)
void setAtten(const double *Atten)
void setPoff1_bunch0(const double *TofPoff1_bunch0)
void setPoff2_bunch2(const double *TofPoff2_bunch2)
void setPoff1_bunch1(const double *TofPoff1_bunch1)
void setFPcounter(const double *FP3)
void setPoff1_bunch2(const double *TofPoff1_bunch2)
void setPoff2_bunch3(const double *TofPoff2_bunch3)
void setFPright(const double *FP2)
void setPoff2_bunch0(const double *TofPoff2_bunch0)
void setP1(const double *TofP1)
void setSigmaCorr(const double *sigmaCorr)
void setOffset(const double *offset)
void setAtten(const double *Atten)
void setP(const double *TofP)
void setFP(const double *FP)
void setSpeed(const double *Speed)
void setPBunch(const double *etfBunchP)
void setSpeed(const double *Speed)
Definition: etfCalibBase.cxx:6
void setP(const double *etfP)
void setP1(const double *etfP1)
void setP2(const double *etfP2)
void setBrWest(const int *tofidWest)
void setBrEast(const int *tofidEast)
void setEndcap(const int *tofidEndcap)
StatusCode openRead(const std::string &fname)
StatusCode closeWrite()
virtual StatusCode openWrite(const std::string &fname)
static const CLID & classID()
virtual StatusCode createRoot(const std::string &fname, CalibData::CalibBase1 *pTDSObj)
const CLID & objType() const
RootTofCalibDataCnv(ISvcLocator *svc)
virtual StatusCode i_createObj(const std::string &fname, DataObject *&refpObject)
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)