21 if( !calib_barrel_item.empty() ) {
22 std::vector<TofCalib*>::iterator
iter = calib_barrel_item.begin();
23 for( ;
iter != calib_barrel_item.end();
iter++ ) {
24 if( (*
iter) )
delete (*iter);
26 calib_barrel_item.clear();
28 if( !calib_endcap_item.empty() ) {
29 std::vector<TofCalib*>::iterator
iter = calib_endcap_item.begin();
30 for( ;
iter != calib_endcap_item.end();
iter++ ) {
31 if( (*
iter) )
delete (*iter);
33 calib_endcap_item.clear();
35 if( !calib_etf_item.empty() ) {
36 std::vector<TofCalib*>::iterator
iter = calib_etf_item.begin();
37 for( ;
iter != calib_etf_item.end();
iter++ ) {
38 if( (*
iter) )
delete (*iter);
40 calib_etf_item.clear();
42 if( !calibration_barrel_item.empty() ) {
43 std::vector<TofCalibFit*>::iterator
iter = calibration_barrel_item.begin();
44 for( ;
iter != calibration_barrel_item.end();
iter++ ) {
45 if( (*
iter) )
delete (*iter);
47 calibration_barrel_item.clear();
49 if( !calibration_barrel_item2.empty() ) {
50 std::vector<TofCalibFit*>::iterator
iter = calibration_barrel_item2.begin();
51 for( ;
iter != calibration_barrel_item2.end();
iter++ ) {
52 if( (*
iter) )
delete (*iter);
54 calibration_barrel_item2.clear();
56 if( !calibration_endcap_item.empty() ) {
57 std::vector<TofCalibFit*>::iterator
iter = calibration_endcap_item.begin();
58 for( ;
iter != calibration_endcap_item.end();
iter++ ) {
59 if( (*
iter) )
delete (*iter);
61 calibration_endcap_item.clear();
71 calib_barrel_item.push_back(cal_item1);
73 else if( isbarrel==0 ) {
74 calib_endcap_item.push_back(cal_item1);
76 else if( isbarrel==2 ) {
77 calib_etf_item.push_back(cal_item1);
80 cout <<
"Tof::tofcalgsec::TofCalibManaer: addCalib: isbarrel is OUT of range!" << endl;
88 if( cal_item2->
name()==
"calib_barrel_sigma" ) {
89 calibration_barrel_item2.push_back(cal_item2);
92 calibration_barrel_item.push_back(cal_item2);
97 calibration_etf_item.push_back(cal_item2);
105 if( !calib_barrel_item.empty() || !calibration_barrel_item.empty() ) {
106 std::cout <<
"Begin barrel counters calibration..." << std::endl;
107 std::cout << setiosflags(ios::left) << setw(10) <<
"TOF ID" << setw(8) <<
"Entries" << setw(30) <<
"What Calibration" << std::endl;
108 HepVector tcorrelation;
109 for(
unsigned int i=0; i<
NBarrel; i++ ) {
111 if( !calib_barrel_item.empty() ) {
112 std::vector<TofCalib*>::iterator iter1 = calib_barrel_item.begin();
113 for( ; iter1!=calib_barrel_item.end(); iter1++ ) {
115 (*iter1)->calculate( barrelData, i );
118 if( !calibration_barrel_item.empty() ) {
119 std::vector<TofCalibFit*>::iterator iter2 = calibration_barrel_item.begin();
120 for( ; iter2!=calibration_barrel_item.end(); iter2++ ) {
121 (*iter2)->calculate( barrelData, i );
123 if( (*iter2)->name()==
"calib_barrel_common" ) {
124 tcorrelation = (*iter2)->tcorrelation();
131 for(
unsigned int i=0; i<
NBarrel; i++ ) {
133 if( !calibration_barrel_item2.empty() ) {
134 std::vector<TofCalibFit*>::iterator iter2 = calibration_barrel_item2.begin();
135 for( ; iter2!=calibration_barrel_item2.end(); iter2++ ) {
137 if( (*iter2)->name()==
"calib_barrel_sigma" ) {
138 (*iter2)->setTCorrelation( tcorrelation );
141 (*iter2)->calculate( barrelData, i );
147 if( !calib_endcap_item.empty() || !calibration_endcap_item.empty() ) {
148 std::cout <<
"Begin endcap counters calibration..." << std::endl;
149 std::cout << setiosflags(ios::left) << setw(10)<<
"TOF ID" << setw(8) <<
"Entries" << setw(30) <<
"What Calibration" << std::endl;
150 for(
unsigned int i=0; i<
NEndcap; i++ ) {
152 if( !calib_endcap_item.empty() ) {
153 std::vector<TofCalib*>::iterator iter1 = calib_endcap_item.begin();
154 for( ; iter1!=calib_endcap_item.end(); iter1++ ) {
156 (*iter1)->calculate( endcapData, i );
159 if( !calibration_endcap_item.empty() ) {
160 std::vector<TofCalibFit*>::iterator iter2 = calibration_endcap_item.begin();
161 for( ; iter2!=calibration_endcap_item.end(); iter2++ ) {
162 (*iter2)->calculate( endcapData, i );
168 if( !calib_etf_item.empty() || !calibration_etf_item.empty() ) {
169 std::cout <<
"Begin ETF(MRPC) calibration..." << std::endl;
170 std::cout << setiosflags(ios::left) << setw(10) <<
"TOF ID *12 + STRIP" << setw(8) <<
"Entries" << setw(30) <<
"What Calibration" << std::endl;
171 HepVector tcorrelation;
174 if( !calib_etf_item.empty() ) {
175 std::vector<TofCalib*>::iterator iter1 = calib_etf_item.begin();
176 for( ; iter1!=calib_etf_item.end(); iter1++ ) {
178 (*iter1)->calculate( etfData, i );
181 if( !calibration_etf_item.empty() ) {
182 std::vector<TofCalibFit*>::iterator iter2 = calibration_etf_item.begin();
183 for( ; iter2!=calibration_etf_item.end(); iter2++ ) {
184 (*iter2)->calculate( etfData, i );
196 if( !calib_barrel_item.empty() ) {
197 std::vector<TofCalib*>::iterator
iter = calib_barrel_item.begin();
198 for( ;
iter != calib_barrel_item.end();
iter++ ) {
199 string fname = dir + string(
"/") + (*iter)->name() + string(
".txt");
200 (*iter)->fillTxt( fname.c_str() );
204 if( !calib_endcap_item.empty() ) {
205 std::vector<TofCalib*>::iterator
iter = calib_endcap_item.begin();
206 for( ;
iter != calib_endcap_item.end();
iter++ ) {
207 string fname = dir + string(
"/") + (*iter)->name() + string(
".txt");
208 (*iter)->fillTxt( fname.c_str() );
212 if( !calib_etf_item.empty() ) {
213 std::vector<TofCalib*>::iterator
iter = calib_etf_item.begin();
214 for( ;
iter != calib_etf_item.end();
iter++ ) {
215 string fname = dir + string(
"/") + (*iter)->name() + string(
".txt");
216 (*iter)->fillTxt( fname.c_str() );
220 if( !calibration_barrel_item.empty() ) {
221 std::vector<TofCalibFit*>::iterator
iter = calibration_barrel_item.begin();
222 for( ;
iter != calibration_barrel_item.end();
iter++ ) {
223 string fname = dir + string(
"/") + (*iter)->name() + string(
".txt");
224 (*iter)->fillTxt( fname.c_str() );
227 if( !calibration_barrel_item2.empty() ) {
228 std::vector<TofCalibFit*>::iterator
iter = calibration_barrel_item2.begin();
229 for( ;
iter != calibration_barrel_item2.end();
iter++ ) {
230 string fname = dir + string(
"/") + (*iter)->name() + string(
".txt");
231 (*iter)->fillTxt( fname.c_str() );
235 if( !calibration_endcap_item.empty() ) {
236 std::vector<TofCalibFit*>::iterator
iter = calibration_endcap_item.begin();
237 for( ;
iter != calibration_endcap_item.end();
iter++ ) {
238 string fname = dir + string(
"/") + (*iter)->name() + string(
".txt");
239 (*iter)->fillTxt( fname.c_str() );
243 if( !calibration_etf_item.empty() ) {
244 std::vector<TofCalibFit*>::iterator
iter = calibration_etf_item.begin();
245 for( ;
iter != calibration_etf_item.end();
iter++ ) {
246 string fname = dir + string(
"/") + (*iter)->name() + string(
".txt");
247 (*iter)->fillTxt( fname.c_str() );
258 sprintf( filename1,
"%s/barrel%i.root", dir.c_str(),
count );
259 TFile
f1(filename1,
"RECREATE");
260 TTree* ntbarrel =
new TTree(
"btrk",
"barrel data after calibration" );
281 ntbarrel->Branch(
"run", &run,
"run/I" );
282 ntbarrel->Branch(
"event", &event,
"event/I" );
283 ntbarrel->Branch(
"tofid", &tofid,
"tofid/I" );
284 ntbarrel->Branch(
"qleft", &qleft,
"qleft/D" );
285 ntbarrel->Branch(
"qright", &qright,
"qright/D" );
286 ntbarrel->Branch(
"tleft", &tleft,
"tleft/D" );
287 ntbarrel->Branch(
"tright", &tright,
"tright/D" );
288 ntbarrel->Branch(
"zrhit", &zrhit,
"zrhit/D" );
289 ntbarrel->Branch(
"texp", &texp,
"texp/D" );
290 ntbarrel->Branch(
"path", &path,
"path/D" );
291 ntbarrel->Branch(
"phi", &phi,
"phi/D" );
292 ntbarrel->Branch(
"theta", &theta,
"theta/D" );
293 ntbarrel->Branch(
"p", &p,
"p/D" );
294 ntbarrel->Branch(
"t0", &t0,
"t0/D" );
295 ntbarrel->Branch(
"q0", &q0,
"q0/D" );
296 ntbarrel->Branch(
"hitcase",&hitcase,
"hitcase/I");
299 std::cout <<
"begin to write..." << filename1 << std::endl;
300 for(
unsigned int i=0; i<
NBarrel; i++ ) {
301 std::cout <<
"\r\b Writing record ... " << (int((++counter)*100./
NBarrel)) <<
"%";
303 std::vector<Record*>::iterator
iter = barrelData->begin();
304 for( ;
iter!=barrelData->end();
iter++ ) {
305 run = (*iter)->run();
306 event = (*iter)->event();
307 tofid = (*iter)->tofid();
308 qleft = (*iter)->qleft();
309 qright = (*iter)->qright();
310 tleft = (*iter)->tleft();
311 tright = (*iter)->tright();
312 zrhit = (*iter)->zrhit();
313 texp = (*iter)->texp();
314 path = (*iter)->path();
315 phi = (*iter)->phi();
316 theta = (*iter)->theta();
320 hitcase = (*iter)->hitcase();
324 std::cout << std::endl;
330 sprintf( filename2,
"%s/endcap%i.root", dir.c_str(),
count );
331 TFile f2(filename2,
"RECREATE");
332 TTree* ntendcap =
new TTree(
"etrk",
"endcap data after calibration" );
334 ntendcap->Branch(
"run", &run,
"run/I" );
335 ntendcap->Branch(
"event", &event,
"event/I" );
336 ntendcap->Branch(
"tofid", &tofid,
"tofid/I" );
337 ntendcap->Branch(
"qleft", &qleft,
"qleft/D" );
338 ntendcap->Branch(
"qright", &qright,
"qright/D" );
339 ntendcap->Branch(
"tleft", &tleft,
"tleft/D" );
340 ntendcap->Branch(
"tright", &tright,
"tright/D" );
341 ntendcap->Branch(
"zrhit", &zrhit,
"zrhit/D" );
342 ntendcap->Branch(
"texp", &texp,
"texp/D" );
343 ntendcap->Branch(
"path", &path,
"path/D" );
344 ntendcap->Branch(
"phi", &phi,
"phi/D" );
345 ntendcap->Branch(
"theta", &theta,
"theta/D" );
346 ntendcap->Branch(
"p", &p,
"p/D" );
347 ntendcap->Branch(
"t0", &t0,
"t0/D" );
348 ntendcap->Branch(
"q0", &q0,
"q0/D" );
349 ntendcap->Branch(
"hitcase",&hitcase,
"hitcase/I");
352 std::cout <<
"begin to write..." << filename2 << std::endl;
353 for(
unsigned int i=0; i<
NEndcap; i++ ) {
354 std::cout <<
"\r\b Writing record ... " << (int((++counter)*100./
NEndcap)) <<
"%";
356 std::vector<Record*>::iterator
iter = endcapData->begin();
357 for( ;
iter!=endcapData->end();
iter++ ) {
358 run = (*iter)->run();
359 event = (*iter)->event();
360 tofid = (*iter)->tofid();
361 qleft = (*iter)->qleft();
362 qright = (*iter)->qright();
363 tleft = (*iter)->tleft();
364 tright = (*iter)->tright();
365 zrhit = (*iter)->zrhit();
366 texp = (*iter)->texp();
367 path = (*iter)->path();
368 phi = (*iter)->phi();
369 theta = (*iter)->theta();
373 hitcase = (*iter)->hitcase();
377 std::cout << std::endl;
383 sprintf( filename3,
"%s/etf%i.root", dir.c_str(),
count );
384 TFile f3(filename3,
"RECREATE");
385 TTree* ntetf =
new TTree(
"etf",
"en data after calibration" );
387 ntetf->Branch(
"run", &run,
"run/I" );
388 ntetf->Branch(
"event", &event,
"event/I" );
389 ntetf->Branch(
"tofid", &tofid,
"tofid/I" );
390 ntetf->Branch(
"strip", &strip,
"strip/I" );
391 ntetf->Branch(
"qleft", &qleft,
"qleft/D" );
392 ntetf->Branch(
"qright", &qright,
"qright/D" );
393 ntetf->Branch(
"tleft", &tleft,
"tleft/D" );
394 ntetf->Branch(
"tright", &tright,
"tright/D" );
395 ntetf->Branch(
"zrhit", &zrhit,
"zrhit/D" );
396 ntetf->Branch(
"dt", &
dt,
"dt/D" );
397 ntetf->Branch(
"texp", &texp,
"texp/D" );
398 ntetf->Branch(
"path", &path,
"path/D" );
399 ntetf->Branch(
"phi", &phi,
"phi/D" );
400 ntetf->Branch(
"p", &p,
"p/D" );
401 ntetf->Branch(
"t0", &t0,
"t0/D" );
402 ntetf->Branch(
"q0", &q0,
"q0/D" );
403 ntetf->Branch(
"hitcase",&hitcase,
"hitcase/I");
406 std::cout <<
"begin to write..." << filename3 << std::endl;
408 std::cout <<
"\r\b Writing record ... " << (int((++counter)*100./(
NEtf*
NStrip))) <<
"%";
410 std::vector<Record*>::iterator
iter = etfData->begin();
411 for( ;
iter!=etfData->end();
iter++ ) {
412 run = (*iter)->run();
413 event = (*iter)->event();
414 tofid = (*iter)->tofid();
415 strip = (*iter)->strip();
416 qleft = (*iter)->qleft();
417 qright = (*iter)->qright();
418 tleft = (*iter)->tleft();
419 tright = (*iter)->tright();
420 zrhit = (*iter)->zrhit();
422 texp = (*iter)->texp();
423 path = (*iter)->path();
424 phi = (*iter)->phi();
428 hitcase = (*iter)->hitcase();
432 std::cout << std::endl;
437 if( !calibration_barrel_item.empty() ) {
438 std::vector<TofCalibFit*>::iterator
iter = calibration_barrel_item.begin();
439 for( ;
iter != calibration_barrel_item.end();
iter++ ) {
440 string fname = dir + string(
"/") + (*iter)->name() + string(
".root");
441 (*iter)->fillRoot( fname.c_str() );
444 if( !calibration_barrel_item2.empty() ) {
445 std::vector<TofCalibFit*>::iterator
iter = calibration_barrel_item2.begin();
446 for( ;
iter != calibration_barrel_item2.end();
iter++ ) {
447 string fname = dir + string(
"/") + (*iter)->name() + string(
".root");
448 (*iter)->fillRoot( fname.c_str() );
452 if( !calibration_endcap_item.empty() ) {
453 std::vector<TofCalibFit*>::iterator
iter = calibration_endcap_item.begin();
454 for( ;
iter != calibration_endcap_item.end();
iter++ ) {
455 string fname = dir + string(
"/") + (*iter)->name() + string(
".root");
456 (*iter)->fillRoot( fname.c_str() );
460 if( !calibration_etf_item.empty() ) {
461 std::vector<TofCalibFit*>::iterator
iter = calibration_etf_item.begin();
462 for( ;
iter != calibration_etf_item.end();
iter++ ) {
463 string fname = dir + string(
"/") + (*iter)->name() + string(
".root");
464 (*iter)->fillRoot( fname.c_str() );
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)
std::vector< Record * > RecordSet
const unsigned int NStrip
const unsigned int NBarrel
const unsigned int NEndcap
DOUBLE_PRECISION count[3]
const string & name() const
void addCalib(TofCalib *cal_item1, int isbarrel)
static TofCalibManager * getManager()
void fillRoot(string &dir)
void fillTxt(string &dir)
RecordSet * getEtfData(unsigned int i) const
RecordSet * getEndcapData(unsigned int i) const
RecordSet * getBarrelData(unsigned int i) const