255 {
257 char filename1[256];
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" );
261
262 int run;
263 int event;
264 int tofid;
265 int strip;
266 double qleft;
267 double qright;
268 double tleft;
269 double tright;
270 double zrhit;
272 double texp;
273 double path;
274 double phi;
275 double theta;
276 double p;
277 double t0;
278 double q0;
279 int hitcase;
280
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");
297
298 int counter = 0;
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();
317 p = (*iter)->p();
318 t0 = (*iter)->t0();
319 q0 = (*iter)->q0();
320 hitcase = (*iter)->hitcase();
321 ntbarrel->Fill();
322 }
323 }
324 std::cout << std::endl;
325 ntbarrel->Write();
326 delete ntbarrel;
328
329 char filename2[256];
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" );
333
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");
350
351 counter = 0;
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();
370 p = (*iter)->p();
371 t0 = (*iter)->t0();
372 q0 = (*iter)->q0();
373 hitcase = (*iter)->hitcase();
374 ntendcap->Fill();
375 }
376 }
377 std::cout << std::endl;
378 ntendcap->Write();
379 delete ntendcap;
380 f2.Close();
381
382 char filename3[256];
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" );
386
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");
404
405 counter = 0;
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();
425 p = (*iter)->p();
426 t0 = (*iter)->t0();
427 q0 = (*iter)->q0();
428 hitcase = (*iter)->hitcase();
429 ntetf->Fill();
430 }
431 }
432 std::cout << std::endl;
433 ntetf->Write();
434 delete ntetf;
435 f3.Close();
436
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() );
442 }
443 }
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() );
449 }
450 }
451
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() );
457 }
458 }
459
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() );
465 }
466 }
467
468 return;
469}
DOUBLE_PRECISION count[3]
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)