284 const char* DigitsTOF700 =
"argon_tof700_digits_files_pro_full.txt")
288#if ROOT_VERSION_CODE < ROOT_VERSION(5, 99, 99)
289 gROOT->LoadMacro(
"$VMCWORKDIR/macro/run/bmnloadlibs.C");
295 if (RunPeriod >= 1 && RunPeriod <= 7) {
296 sprintf(mapping,
"TOF700_map_period_%d.txt", RunPeriod);
298 printf(
"Non-existing run period number %d!", RunPeriod);
302#if OLD_DIGI_FILE == true
313 if (strstr(TracksGemDch,
".root")) {
314 bmnTree->
Add(TracksGemDch);
316 ifstream fin(TracksGemDch);
318 for (
int idx = 0; idx < 1000; idx++) {
322 if (strlen(filename.Data()) == 0)
324 if ((filename.Data())[0] ==
'#')
326 cout <<
" GEM+DCH tracks file #" << idx + 1 <<
" " << filename.
Data() << endl;
327 bmnTree->
Add(filename);
331 printf(
"Non-existing run list file: %s!", TracksGemDch);
339 TChain* bmnTreetof700 = NULL;
341 bmnTreetof700 =
new TChain(
"cbmsim");
343 bmnTreetof700 =
new TChain(
"bmndata");
345 if (strstr(DigitsTOF700,
".root")) {
346 bmnTreetof700->
Add(DigitsTOF700);
349 ifstream fin(DigitsTOF700);
351 for (
int idx = 0; idx < 1000; idx++) {
355 if (strlen(filename.Data()) == 0)
357 if ((filename.Data())[0] ==
'#')
359 cout <<
" TOF digits file #" << idx + 1 <<
" " << filename.
Data() << endl;
360 bmnTreetof700->
Add(filename);
365 printf(
"Non-existing run list file: %s!", DigitsTOF700);
375 char fnametof700raw[256];
377 strcpy(strstr(fnametof700raw,
"digi.root"),
"raw.root");
394 char name[128], title[128];
397 gStyle->SetOptStat(111111);
405 char fname_calib_root[128];
407 TString dir = getenv(
"VMCWORKDIR");
413 strcpy(fname_calib_root, path.Data());
417 if ((delim = strrchr(fname_calib_root, (
int)
'.')))
419 strcat(fname_calib_root,
"_calibration.root");
421 TFile* fc =
new TFile(fname_calib_root,
"READ",
"Proton mass based calibration of BmnTOF700");
429 printf(
"\n ******************* Time offsets for whole chamber **********************\n");
432 printf(
"%d %f\n", c,
tofcalc[c]);
436 printf(
"\n ******************* Time offsets for one strip **************************\n");
439 printf(
"\n Chamber %d %.1f\n", c,
idchambers[c]);
443 for (
int s = 0; s < smax; s++) {
446 printf(
" strip %d %f\n", s,
tofcals[c][s]);
449 printf(
"\n *************************************************************************\n");
456 char fname_root[128], *delim = 0;
458 if ((delim = strrchr(fname_root, (
int)
'.')))
460 strcat(fname_root,
"_calibration_results.root");
461 f =
new TFile(fname_root,
"RECREATE",
"Results of BmnTOF700");
464 TH1F* hntr =
new TH1F(
"hntr",
"Number of all tracks", 200, 0, 200);
465 TH1F* hntr0 =
new TH1F(
"hntr0",
"Number of selected tracks", 200, 0, 200);
466 TH1F* hntr1 =
new TH1F(
"hntr1",
"Number of tracks with FLAG conditions", 200, 0, 200);
467 TH2F* hxytr =
new TH2F(
"hxytr",
"XY tracks", 1500, -150, 150, 1000, -100, 100);
468 TH1F* hptr =
new TH1F(
"hptr",
"Momentum of tracks", 1000, -10, 10);
469 TH1F* hp0 =
new TH1F(
"hp0",
"Momentum of tracks (all)", 1000, -10, 10);
470 TH1F* hltr =
new TH1F(
"hltr",
"Lenght of GEM tracks", 100, 500, 700);
471 TH1F* hltra =
new TH1F(
"hltra",
"Lenght of GEM+DCH tracks", 100, 500, 700);
472 TH2F* hxytrtof =
new TH2F(
"hxytrtof",
"XY tracks with TOF700 hits", 1500, -150, 150, 1000, -100, 100);
473 TH2F* hxyhit =
new TH2F(
"hxyhit",
"XY track hit distance from TOF700 hit", 200, -50, 50, 40, -10, 10);
474 TH2F* hxyhitlr =
new TH2F(
"hxyhitlr",
"XY track hit distance from TOF700 hit (lr cut)", 200, -50, 50, 40, -10, 10);
475 TH1F* hlrdiffs =
new TH1F(
"hlrdiffs",
"LR difference for TOF700 hits with track (small chamber)", 100, -5, +5);
476 TH1F* hlrdiffb =
new TH1F(
"hlrdiffb",
"LR difference for TOF700 hits with track (big chamber)", 100, -5, +5);
477 TH1F* hxdiff =
new TH1F(
"hxdiff",
"X difference for TOF700 hits with track", 100, -50, +50);
478 TH2F* hxxhits =
new TH2F(
"hxxhits",
"X track hit vs TOF700 hit (small chambers)", 200, -100, 100, 200, -100, 100);
479 TH2F* hxxhitb =
new TH2F(
"hxxhitb",
"X track hit vs TOF700 hit (big chambers)", 200, -100, 100, 200, -100, 100);
480 TH2F* hlrxhits =
new TH2F(
"hlrxhits",
"X TOF700 hit vs LR difference (small chamber)", 100, -5, 5, 200, -100, 100);
481 TH2F* hlrxhitb =
new TH2F(
"hlrxhitb",
"X TOF700 hit vs LR difference (big chamber)", 100, -5, 5, 200, -100, 100);
483 TH2F* hlrxtrs =
new TH2F(
"hlrxtrs",
"X TOF700 tr vs LR difference (small chamber)", 100, -5, 5, 200, -100, 100);
484 TH2F* hlrxtrb =
new TH2F(
"hlrxtrb",
"X TOF700 tr vs LR difference (big chamber)", 100, -5, 5, 200, -100, 100);
486 TH1F* hcsignp =
new TH1F(
"hsignp",
"Chambers with right correlation (x vs lr)", 60, 0, 60);
487 TH1F* hcsignm =
new TH1F(
"hsignm",
"Chambers with wrong correlation (x vs lr)", 60, 0, 60);
489 TH1F* htoftr =
new TH1F(
"htoftr",
"TOF of tracks with TOF700 hits", 600, -20, 40);
490 TH1F* htof =
new TH1F(
"htof",
"TOF for hits", 600, -20, 40);
491 TH1F* hntof =
new TH1F(
"hntof",
"Number of hits", 100, 0, 100);
492 TH1F* hnhit =
new TH1F(
"hnhit",
"Number of hits in width limits", 100, 0, 100);
493 TH2F* hxytof =
new TH2F(
"hxytof",
"XY TOF700 hits", 1500, -150, 150, 1000, -100, 100);
494 TH2F* hpbeta =
new TH2F(
"hpbeta",
"Beta vs momentum", 200, 0, 10, 220, 0, 1.1f);
496 TH2F* hpbetac =
new TH2F(
"hpbetac",
"Beta vs momentum, chamber corrections", 200, 0, 10, 220, 0, 1.1f);
498 TH2F* hpbetas =
new TH2F(
"hpbetas",
"Beta vs momentum, strip corrections", 200, 0, 10, 220, 0, 1.1f);
500 TH2F* hpbetacm =
new TH2F(
"hpbetacm",
"Beta vs momentum, Z<0, chamber corrections", 200, 0, 10, 220, 0, 1.1f);
502 TH2F* hpbetasm =
new TH2F(
"hpbetasm",
"Beta vs momentum, Z<0, strip corrections", 200, 0, 10, 220, 0, 1.1f);
505 TH1F* hmass =
new TH1F(
"hmass",
"Mass, p<2", 400, -0.5, 9.5);
506 TH1F* hmassc =
new TH1F(
"hmassc",
"Mass, chamber corrections", 400, -0.5, 9.5);
507 TH1F* hmassc15 =
new TH1F(
"hmassc15",
"Mass, chamber corrections, p<1.5", 400, -0.5, 9.5);
508 TH1F* hmassc20 =
new TH1F(
"hmassc20",
"Mass, chamber corrections, p<2.0", 400, -0.5, 9.5);
509 TH1F* hmasss =
new TH1F(
"hmasss",
"Mass, strip corrections", 400, -0.5, 9.5);
510 TH1F* hmasss15 =
new TH1F(
"hmasss15",
"Mass, strip corrections, p<1.5", 400, -0.5, 9.5);
511 TH1F* hmasss20 =
new TH1F(
"hmasss20",
"Mass, strip corrections, p<2.0", 400, -0.5, 9.5);
512 TH1F* hmasscm =
new TH1F(
"hmasscm",
"Mass, Z<0, chamber corrections", 200, -1, 4);
513 TH1F* hmasssm =
new TH1F(
"hmasssm",
"Mass, Z<0, strip corrections", 200, -1, 4);
515 TH1F* hdtps =
new TH1F(
"hdtps",
"Time resolution, protons, strip corrections", 200, -1., +1.);
517 new TH2F(
"hdtpsvsp",
"Time resolution vs momentum, protons, strip corrections", 240, 0., 6., 200, -1., +1.);
519 TH1F* hdtpc =
new TH1F(
"hdtpc",
"Time resolution, protons, chamber corrections", 200, -1., +1.);
521 new TH2F(
"hdtpcvsp",
"Time resolution vs momentum, protons, chamber corrections", 240, 0., 6., 200, -1., +1.);
523 TH2F* hdtpcvspwlim =
new TH2F(
"hdtpcvspwlim",
"Time resolution vs momentum, protons, chamber corrections, w>3000",
524 240, 0., 6., 200, -1., +1.);
526 TH1F* hdtpcplim =
new TH1F(
"hdtpcplim",
"Time resolution, protons, p>3", 200, -1., +1.);
527 TH1F* hdtpcp1lim =
new TH1F(
"hdtpcp1lim",
"Time resolution, protons, p>4", 200, -1., +1.);
528 TH1F* hdtpcp2lim =
new TH1F(
"hdtpcp2lim",
"Time resolution, protons, p<2", 200, -1., +1.);
529 TH1F* hdtpcp3lim =
new TH1F(
"hdtpcp3lim",
"Time resolution, protons, 2<p<5", 200, -1., +1.);
530 TH1F* hdtpcwlim =
new TH1F(
"hdtpcwlim",
"Time resolution, protons, w>3000", 200, -1., +1.);
531 TH1F* hdtpcwplim =
new TH1F(
"hdtpcwplim",
"Time resolution, protons, p>3, w>3000", 200, -1., +1.);
532 TH1F* hdtpcwp1lim =
new TH1F(
"hdtpcwp1lim",
"Time resolution, protons, p>4, w>3000", 200, -1., +1.);
534 TH2F* hmassvsp =
new TH2F(
"hmassvsp",
"Mass vs momentum", 240, 0., 6., 200, -0.2, 4.8);
536 TH2F* hmasssvsp =
new TH2F(
"hmasssvsp",
"Mass vs momentum, strip correction", 240, 0., 6., 200, -0.2, 4.8);
538 TH2F* hmasscvsp =
new TH2F(
"hmasscvsp",
"Mass vs momentum, chamber corrections", 240, 0., 6., 200, -0.2, 4.8);
540 TH2F* hmasssmvsp =
new TH2F(
"hmasssmvsp",
"Mass vs momentum, Z<0, strip correction", 240, 0., 6., 200, -0.2, 4.8);
543 new TH2F(
"hmasscmvsp",
"Mass vs momentum, Z<0, chamber corrections", 240, 0., 6., 200, -0.2, 4.8);
546 TH1F* htofp =
new TH1F(
"htofp",
"TOF for proton hits, p<2", 600, -20, 40);
547 TH1F* hstr =
new TH1F(
"hstr",
"Strips", 32, 0, 32);
548 TH1F* hcha =
new TH1F(
"hcha",
"Chambers", 60, 0, 60);
549 TH1F* hstrtr =
new TH1F(
"hstrtr",
"Strips with tracks", 32, 0, 32);
550 TH1F* hchatr =
new TH1F(
"hchatr",
"Chambers with tracks", 60, 0, 60);
552 TH2F* hdxy0 =
new TH2F(
"hdxy0",
"DxDy all", 40, -10, +10, 40, -10, +10);
553 TH1F* hdx =
new TH1F(
"hdx",
"dx all", 40, -10, +10);
554 TH1F* hdy =
new TH1F(
"hdy",
"dy all", 40, -10, +10);
555 TH2F* hdxy =
new TH2F(
"hdxy",
"DxDy selected", 40, -10, +10, 40, -10, +10);
556 TH2F* hdxytof =
new TH2F(
"hdxytof",
"DxDy with TOF700 hits", 40, -10, +10, 40, -10, +10);
557 TH2F* hdxyeff =
new TH2F(
"hdxyeff",
"Efficiency vs DxDy", 40, -10, +10, 40, -10, +10);
559 TH1F* hdxeff =
new TH1F(
"hdxeff",
"Efficiency vs Dx", 40, -10, +10);
560 TH1F* hdyeff =
new TH1F(
"hdyeff",
"Efficiency vs Dy", 40, -10, +10);
561 TH2F* hxygoodtr =
new TH2F(
"hxygoodtr",
"XY good tracks", 70, -140, 140, 60, -90, 90);
562 TH2F* hxygoodhit =
new TH2F(
"hxygoodhit",
"XY good tracks with good hits", 70, -140, 140, 60, -90, 90);
563 TH2F* hxyeff =
new TH2F(
"hxyeff",
"Efficiency vs XY good tracks", 70, -140, 140, 60, -90, 90);
565 TH1F* hxeff =
new TH1F(
"hxeff",
"Efficiency vs X good tracks", 70, -140, 140);
566 TH1F* hyeff =
new TH1F(
"hyeff",
"Efficiency vs Y good tracks", 60, -90, 90);
567 TH1F* hdtx =
new TH1F(
"hdtx",
"dtx", 100, -0.25, +0.25);
568 TH1F* hdty =
new TH1F(
"hdty",
"dty", 100, -0.25, +0.25);
569 TH1F* hDdx =
new TH1F(
"hDdx",
"Err dx", 100, 0, 10);
570 TH1F* hDdy =
new TH1F(
"hDdy",
"Err dy", 100, 0, 10);
571 TH1F* hDdtx =
new TH1F(
"hDdtx",
"Err dtx", 100, 0, 0.05);
572 TH1F* hDdty =
new TH1F(
"hDdty",
"Err dty", 100, 0, 0.05);
573 TH1F* hpdx =
new TH1F(
"hpdx",
"Pull dx", 500, -2.5, +2.5);
574 TH1F* hpdy =
new TH1F(
"hpdy",
"Pull dy", 500, -2.5, +2.5);
575 TH1F* hpdtx =
new TH1F(
"hpdtx",
"Pull dtx", 500, -25., +25.);
576 TH1F* hpdty =
new TH1F(
"hpdty",
"Pull dty", 500, -25., +25.);
577 TH1F* hchi2m =
new TH1F(
"hChi2m",
"Chi2 GemDch track", 1000, 0, 100);
578 TH1F* hchi2 =
new TH1F(
"hchi2",
"Chi2 tracks matching", 1000, 0, 100);
589 char nam[64], tit[64];
594 XvsLR =
new TProfile2D(
"xvslr",
"X calibration, chambers",
NUMBER_CHAMBERS, 0,
NUMBER_CHAMBERS, 80, -4, 4, -40.,
598 for (
int i = 0;
i < 10;
i++) {
599 sprintf(nam,
"xvslrvsrun%d",
i);
600 sprintf(tit,
"X calibration, events %d - %d",
i * 30000 + 1, (
i + 1) * 30000);
601 XvsLRvsRun[
i] =
new TProfile2D(nam, tit,
NUMBER_CHAMBERS, 0,
NUMBER_CHAMBERS, 80, -4, 4, -40., +40.,
"e");
604 sprintf(nam,
"xvslrvss%d",
i);
605 sprintf(tit,
"X calibration, strips, chamber %.1f",
idchambers[
i]);
606 XvsLRvsStrip[
i] =
new TProfile2D(nam, tit, 32, 0, 32, 80, -4, 4, -40., +40.,
"e");
607 sprintf(nam,
"xglobvslrvss%d",
i);
608 sprintf(tit,
"X global calibration, strips, chamber %.1f",
idchambers[
i]);
609 XvsLRvsStrip1[
i] =
new TProfile2D(nam, tit, 32, 0, 32, 80, -4, 4, -150., +150.,
"e");
612 sprintf(nam,
"xvslrp%d",
i);
613 sprintf(tit,
"X vs LR plot, chamber %.1f",
idchambers[
i]);
614 XvsLRp[
i] =
new TH2F(nam, tit, 80, -4, 4, 80, -40., +40.);
617 hfitx0 =
new TH1F(
"hfitx0",
"X vs LR constant", 200, -5, +5);
618 hfitx1 =
new TH1F(
"hfitx1",
"X vs LR slope", 200, -20, 20);
619 hfitx0run =
new TH1F(
"hfitx0run",
"X vs LR constant vs run", 20, 0, 20);
620 hfitx1run =
new TH1F(
"hfitx1run",
"X vs LR slope vs run", 20, 0, 20);
621 hfitxs0 =
new TH1F(
"hfitxs0",
"X vs LR constant", 100, -5, +5);
622 hfitxs1 =
new TH1F(
"hfitxs1",
"X vs LR slope", 200, -20, 20);
623 hfitxs0a =
new TH1F(
"hfitxs0a",
"X vs LR constant", 100, -5, +5);
624 hfitxs1a =
new TH1F(
"hfitxs1a",
"X vs LR slope", 200, -20, 20);
625 hfitx1s0 =
new TH1F(
"hfitx1s0",
"X vs LR constant", 600, -150, +150);
626 hfitx1s1 =
new TH1F(
"hfitx1s1",
"X vs LR slope", 200, -20, 20);
627 hfitx1s1a =
new TH1F(
"hfitx1s1a",
"X vs LR slope", 200, -20, 20);
628 hfity =
new TH1F(
"hfity",
"Y shift", 100, -5, +5);
629 hfityc =
new TH1F(
"hfityc",
"Y shift (chambers average)", 100, -5, 5);
632 float cvel = 29.97925f;
633 float ekin = 3.2f, ebeam = ekin +
MP, pbeam =
TMath::Sqrt(ebeam * ebeam +
MP *
MP);
634 float cbeam = pbeam / ebeam;
635 float cpeak = cbeam *
CFACTOR * cvel;
639 TOF2->get_chamber_z(
i, &zc[
i]);
642 Int_t startEvent = 0;
645 printf(
"\nNumber of events in tracks chain is %d (tof700 chain %d)\n", nEvents, nEventstof700);
647 int Ntr = 0, Ntr1 = 0, Ntr1g = 0, Ntr0 = 0;
648 Int_t iEv = 0, iEvtof700 = 0, fCurrent = -1, nevs = 0;
649 UInt_t trackEvId = 0, tof700EvId = 0;
650 UInt_t trackRunId = 0, tof700RunId = 0;
651 TH1D *projtmp = 0, *projtmp1 = 0;
652 for (
Int_t iEv0 = startEvent; iEv0 < startEvent + nEvents; iEv0++) {
653 if (iEv % 10000 == 0) {
654 cout <<
"Event: " << iEv <<
"/" << startEvent + nEvents <<
" ( Run " << trackRunId <<
" EvId " << trackEvId
662 if (mtracks == NULL) {
670 }
while (gemdchtrack0 == NULL);
677 if (eventHeader == NULL)
682 if (tof700RunId == trackRunId && tof700EvId > trackEvId)
684 if (tof700RunId > trackRunId)
687 if (!(tof700EvId == trackEvId && tof700RunId == trackRunId)) {
690 if (eventHeadertof700 == NULL)
692#if OLD_DIGI_FILE == true
696 tof700EvId = eventHeadertof700->GetEventId();
697 tof700RunId = eventHeadertof700->GetRunId();
703 if (iEvtof700 >= nEventstof700)
705 if (tof700RunId > trackRunId)
707 if (tof700RunId == trackRunId && tof700EvId > trackEvId)
709 }
while (!(tof700EvId == trackEvId && tof700RunId == trackRunId));
711 if (eventHeadertof700 == NULL)
713 if (!(tof700EvId == trackEvId && tof700RunId == trackRunId)) {
714 cout <<
"Not found EventId " << trackEvId <<
" in tof700 digits file" << endl;
715 cout <<
"Tracks Event: " << iEv <<
", TOF700 Event: " << iEvtof700 << endl;
716 cout <<
"Tracks RunId: " << trackRunId <<
", TOF700 RunId: " << tof700RunId << endl;
717 cout <<
"Tracks EventId: " << trackEvId <<
", TOF700 EventId: " << tof700EvId << endl;
718 if (iEvtof700 >= nEventstof700)
720 if (tof700RunId > trackRunId)
722 if (tof700RunId == trackRunId && tof700EvId > trackEvId)
739 for (
int j = 0; j < 32; j++)
741 for (
int j = 0; j < 32; j++)
743 for (
int j = 0; j < 32; j++)
750 float x = 0., y = 0., z = 0.;
751 float x0 = 0., y0 = 0., z0 = 0.;
752 int hchamb[1000] = {0}, hstrip[1000] = {0};
753 int clchamb[1000] = {0}, clstrip[1000] = {0};
754 Bool_t usedstrip[1000] = {
false};
756 for (
Int_t iDig = 0; iDig < ntof; ++iDig) {
764 Float_t lrdiff = digit->GetDiff();
770 if (
XYPANIN && (
TOF2->get_hit_xp(plane, strip, lrdiff) == 0.))
773 smax1[plane] = strip;
774 if (width > wmax[plane]) {
780 if (width <
wmi[plane] || width >
wma[plane])
786 nhits[plane][strip]++;
787 tof[plane][strip] = time;
791 TOF2->get_hit_xyzp(plane, strip, lrdiff, &x, &y, &z);
795 TOF2->get_strip_xyz(plane, strip, &x0, &y0, &z0);
797 y = y0 +
shifty[plane][strip];
800 TOF2->get_hit_xyz(plane, strip, +lrdiff, &x, &y, &z);
803 TOF2->get_hit_xyzng(plane, strip, lrdiff, &x, &y, &z);
809 TOF2->get_hit_xyz(plane, strip, +lrdiff, &x, &y, &z);
811 TOF2->get_hit_xyz(plane, strip, -lrdiff, &x, &y, &z);
818 TOF2->get_strip_xyz(plane, strip, &x, &y, &z);
824 numhit[plane][strip] =
nhi;
829 float xyz[3] = {0.}, cxyz[3] = {0.}, xrpc = 0., yrpc = 0., dz = 100., tx = 0., ty = 0., zcha = 0.;
830 float beta = 1.0f, mass = 1.0f, mass2 = 1.0f, tcor = 0., tcorc = 0., tcors = 0., tcorspi = 0., tcorcpi = 0.;
832 int ntr = mtracks->GetEntriesFast();
836 int ntr1 = 0, ntr1g = 0;
837 int iflag = 0, igem = 0, idch = 0;
867 Double_t le = 0., p = 0., ps = 0., pmod = 0., lenr = 0.;
870 double dist = 0., distmin = 1000000000.0f;
885 float massmaxpi = 0.;
886 float massminpi = 0.;
896 double timepeak = 0., betapeak = 0.;
898 for (
Int_t iTr = 0; iTr < ntr; ++iTr) {
900 if (gemdchtrack == NULL)
928 hp0->
Fill(1. / QpGem);
944 Xpv = gemdchtrack->
GetXpv();
945 Ypv = gemdchtrack->
GetYpv();
951 if (primaryVertex->
GetX() < -2 || primaryVertex->
GetX() > 2.5 || primaryVertex->
GetY() < 1
952 || primaryVertex->
GetY() > 4 || primaryVertex->
GetZ() < -1 || primaryVertex->
GetZ() > 2)
956 if ((!goodpv) || nGemHits <
MINGEMNDF || nSiHits <
MINSIHITS || xGem < -140.f || xGem > 240.f
957 || yGem < -40.f || yGem > 200.f || txGem < -0.5f || txGem > 1.0f || tyGem < -0.1f || tyGem > 0.5f
958 || Xpv < -3.5f || Xpv > 4.0f || Ypv < -1.0f || Ypv > 6.0f || QpGem == 0.0f
962 printf(
"Reject: NDF %d xGem %f yGem %f txGem %f tyGem %f Xpv %f Ypv %f QpGem %f\n", nGemHits,
963 xGem, yGem, txGem, tyGem, Xpv, Ypv, QpGem);
967 printf(
"Accept: NDF %d xGem %f yGem %f txGem %f tyGem %f Xpv %f Ypv %f QpGem %f\n", nGemHits, xGem,
968 yGem, txGem, tyGem, Xpv, Ypv, QpGem);
972 dxm = gemdchtrack->
GetDx();
973 dym = gemdchtrack->
GetDy();
974 dtx = gemdchtrack->
GetDtx();
975 dty = gemdchtrack->
GetDty();
976 Ddx = gemdchtrack->
GetDdx();
977 Ddy = gemdchtrack->
GetDdy();
980 Chi2m = gemdchtrack->
GetChi2();
983 hdxy0->
Fill(dxm, dym);
999 xgoodtr = xyz[0] + tx * 100.;
1000 ygoodtr = xyz[1] + ty * 100.;
1001 hxytr->
Fill(xgoodtr, ygoodtr);
1009 hchi2m->
Fill(Chi2m);
1011 chi2 = dxm * dxm / Ddx + dym * dym / Ddy;
1015 hdxy->
Fill(dxm, dym);
1027 hxygoodtr->
Fill(xgoodtr, ygoodtr);
1028 cxyz[0] = tx /
TMath::Sqrt(1. + tx * tx + ty * ty);
1029 cxyz[1] = ty /
TMath::Sqrt(1. + tx * tx + ty * ty);
1030 cxyz[2] = 1. /
TMath::Sqrt(1. + tx * tx + ty * ty);
1039 int clstart = -1, clwidth = -1, cstr = -1;
1040 float samps = 0., timemin = 1000000000.;
1041 float widthmax = 0.;
1045 for (
int j = 0; j < nstr && nhit[i] > 0; j++) {
1050 timemin =
tof[
i][j];
1054 if (
tof[
i][j] < timemin) {
1055 timemin =
tof[
i][j];
1066 if (j == (nstr - 1)) {
1068 clstrip[ncl0] = cstr;
1069 clwidth = (j + 1 - clstart);
1070 tcl[
i][ncl[
i]] = timemin;
1071 acl[
i][ncl[
i]] = samps;
1072 wcl[
i][ncl[
i]] = clwidth;
1076 timemin = 1000000000.;
1079 }
else if (clstart >= 0) {
1081 clstrip[ncl0] = cstr;
1082 clwidth = (j - clstart);
1083 tcl[
i][ncl[
i]] = timemin;
1084 acl[
i][ncl[
i]] = samps;
1085 wcl[
i][ncl[
i]] = clwidth;
1089 timemin = 1000000000.;
1097 distmin = 1000000000.0f;
1098 for (
int icl = 0; icl < ncl0; icl++) {
1101 int ih = numhit[ic][is];
1104 dz =
zhi[ih] - xyz[2];
1105 xrpc = xyz[0] + dz * tx;
1106 yrpc = xyz[1] + dz * ty;
1115 dx = xrpc -
xhi[ih];
1116 dy = yrpc -
yhi[ih];
1126 if (
dist < distmin) {
1128 himin = numhit[ic][is];
1135 distmin = 1000000000.0f;
1136 for (
int ih = 0; ih < nh; ih++) {
1141 dz =
zhi[ih] - xyz[2];
1142 xrpc = xyz[0] + dz * tx;
1143 yrpc = xyz[1] + dz * ty;
1152 dx = xrpc -
xhi[ih];
1153 dy = yrpc -
yhi[ih];
1163 if (
dist < distmin) {
1175 usedstrip[himin] =
true;
1176 hdxytof->
Fill(dxm, dym);
1177 hxygoodhit->
Fill(xgoodtr, ygoodtr);
1183 dz =
zhi[himin] - xyz[2];
1184 xrpc = xyz[0] + dz * tx;
1185 yrpc = xyz[1] + dz * ty;
1187 hxyhit->
Fill(xrpc -
xhi[himin], yrpc -
yhi[himin]);
1189 hxyhitlr->
Fill(xrpc -
xhi[himin], yrpc -
yhi[himin]);
1191 hxyhitlr->
Fill(xrpc -
xhi[himin], yrpc -
yhi[himin]);
1196 hxdiff->
Fill(
xhi[himin] - xc);
1198 hxxhits->
Fill(
xhi[himin] - xc, xrpc - xc);
1200 hxxhitb->
Fill(
xhi[himin] - xc, xrpc - xc);
1207 hlrxtrs->
Fill(
lrd[himin], xrpc - xc);
1209 hlrxtrb->
Fill(
lrd[himin], xrpc - xc);
1211 if (
lrd[himin] > 0. && (
xhi[himin] - xc) > 0.)
1213 if (
lrd[himin] < 0. && (
xhi[himin] - xc) < 0.)
1215 if (
lrd[himin] > 0. && (
xhi[himin] - xc) < 0.)
1217 if (
lrd[himin] < 0. && (
xhi[himin] - xc) > 0.)
1224 XvsLR->Fill(ic,
lrd[himin], xrpc - xc);
1225 XvsLRp[ic]->Fill(
lrd[himin], xrpc - xc);
1226 YvsY->Fill(ic, is, yrpc - yc);
1227 Int_t numrun = nevs / 30000;
1233 cosa =
sqrt(1. + tx * tx + ty * ty);
1237 hidist =
TMath::Sqrt(xc * xc + yc * yc + (zc - ztarg) * (zc - ztarg));
1243 hxytrtof->
Fill(xrpc, yrpc);
1251 tofr =
tof[ic][is] + lenr / cpeak;
1259 tofr0 =
tof[ic][is];
1262 beta = lenr / tofr / cvel;
1266 mass2 = p * p * (1.f /
beta /
beta - 1.f);
1274 if (p > 0.f && mass2 > massmin1 && mass2 < massmax1 && pmod >
PMIN && pmod <
PMAX) {
1278 tcors = tcor -
tofcals[ic][is];
1279 tcalibrc->
Fill(ic, tcorc);
1280 tcalibrs->
Fill(ic, is, tcors);
1284 if (mass2 > massmin2 && mass2 < massmax2) {
1286 hdtpcvsp->
Fill(p, tcorc);
1288 hdtpsvsp->
Fill(p, tcors);
1290 hdtpcplim->
Fill(tcorc);
1292 hdtpcp1lim->
Fill(tcorc);
1294 hdtpcp2lim->
Fill(tcorc);
1295 if (p >= 2.0f && p < 5.0f)
1296 hdtpcp3lim->
Fill(tcorc);
1298 hdtpcwlim->
Fill(tcorc);
1299 hdtpcvspwlim->
Fill(p, tcorc);
1301 hdtpcwplim->
Fill(tcorc);
1303 hdtpcwp1lim->
Fill(tcorc);
1309 if (p > 0 && massmaxpi > massmin1)
1310 massmaxpi = massmin1;
1313 if (mass2 < massmaxpi && mass2 > massminpi && pmod >
PMIN && pmod <
PMAXPI) {
1315 tcorpi = tofpi - tofr;
1316 tcorcpi = tcorpi -
tofcalc[ic];
1317 tcorspi = tcorpi -
tofcals[ic][is];
1318 tcalibrc->
Fill(ic, tcorcpi);
1319 tcalibrs->
Fill(ic, is, tcorspi);
1322 betapeak = lenr / timepeak / cvel;
1323 tpeak->
Fill(ic, timepeak);
1324 bpeak->
Fill(ic, betapeak);
1326 tofrs = tofr +
tofcals[ic][is];
1327 betac = lenr / tofrc / cvel;
1328 betas = lenr / tofrs / cvel;
1329 masss2 = p * p * (1.f / betas / betas - 1.f);
1331 massc2 = p * p * (1.f / betac / betac - 1.f);
1334 hpbetac->
Fill(p, betac);
1335 hmassc->
Fill(massc2);
1336 hmasscvsp->
Fill(p, massc2);
1337 hpbetas->
Fill(p, betas);
1338 hmasss->
Fill(masss2);
1339 hmasssvsp->
Fill(p, masss2);
1341 hmasss15->
Fill(masss2);
1342 hmassc15->
Fill(massc2);
1345 hmasss20->
Fill(masss2);
1346 hmassc20->
Fill(massc2);
1350 hmasscm->
Fill(massc2);
1353 hmasssm->
Fill(masss2);
1363 if (iEv % 50000 == 0) {
1364 hdxyeff->
Divide(hdxytof, hdxy);
1375 hxyeff->
Divide(hxygoodhit, hxygoodtr);
1388 printf(
"Number of tracks %d, per event %f\n", Ntr, (
float)Ntr / nEvents);
1389 printf(
"GEM+DCH1+DCH2 tracks %d, per event %f (%f%% per track)\n", Ntr1, (
float)Ntr1 / nEvents,
1390 (
float)Ntr1 / Ntr * 100.f);
1391 printf(
"Good GEM+DCH1+DCH2 tracks %d, per event %f (%f%% per track)\n", Ntr0, (
float)Ntr0 / nEvents,
1392 (
float)Ntr0 / Ntr * 100.f);
1393 }
else if (
FLAG > 0) {
1394 printf(
"Number of tracks %d, per event %f\n", Ntr, (
float)Ntr / nEvents);
1395 printf(
"GEM+DCH1 tracks %d, per event %f (%f%% per track)\n", Ntr1, (
float)Ntr1 / nEvents,
1396 (
float)Ntr1 / Ntr * 100.f);
1397 printf(
"Good GEM+DCH1 tracks %d, per event %f (%f%% per track)\n", Ntr0, (
float)Ntr0 / nEvents,
1398 (
float)Ntr0 / Ntr * 100.f);
1400 printf(
"Number of tracks %d, per event %f\n", Ntr, (
float)Ntr / nEvents);
1401 printf(
"GEM+DCH tracks %d, per event %f (%f%% per track)\n", Ntr1, (
float)Ntr1 / nEvents,
1402 Ntr > 0 ? (
float)Ntr1 / Ntr * 100.f : 0.f);
1403 printf(
"Good GEM+DCH tracks %d, per event %f (%f%% per valid track)\n", Ntr1g, (
float)Ntr1g / nEvents,
1404 Ntr1 > 0 ? (
float)Ntr1g / Ntr1 * 100.f : 0.f);
1405 printf(
"Matched GEM+DCH tracks %d, per event %f (%f%% per good track)\n", Ntr0, (
float)Ntr0 / nEvents,
1406 Ntr1g > 0 ? (
float)Ntr0 / Ntr1g * 100.f : 0.f);
1419 char fname_calibr_root[128], *delim = 0;
1421 if ((delim = strrchr(fname_calibr_root, (
int)
'.')))
1423 strcat(fname_calibr_root,
"_calibration.root");
1424 TFile* fc =
new TFile(fname_calibr_root,
"RECREATE",
"Proton mass based calibration of BmnTOF700");
1432 hdxyeff->
Divide(hdxytof, hdxy);
1443 hxyeff->
Divide(hxygoodhit, hxygoodtr);
1456 printf(
"Number of tracks %d, per event %f\n", Ntr, (
float)Ntr / nEvents);
1457 printf(
"GEM+DCH1+DCH2 tracks %d, per event %f (%f%% per track)\n", Ntr1, (
float)Ntr1 / nEvents,
1458 (
float)Ntr1 / Ntr * 100.f);
1459 printf(
"Good GEM+DCH1+DCH2 tracks %d, per event %f (%f%% per track)\n", Ntr0, (
float)Ntr0 / nEvents,
1460 (
float)Ntr0 / Ntr * 100.f);
1461 }
else if (
FLAG > 0) {
1462 printf(
"Number of tracks %d, per event %f\n", Ntr, (
float)Ntr / nEvents);
1463 printf(
"GEM+DCH1 tracks %d, per event %f (%f%% per track)\n", Ntr1, (
float)Ntr1 / nEvents,
1464 (
float)Ntr1 / Ntr * 100.f);
1465 printf(
"Good GEM+DCH1 tracks %d, per event %f (%f%% per track)\n", Ntr0, (
float)Ntr0 / nEvents,
1466 (
float)Ntr0 / Ntr * 100.f);
1468 printf(
"Number of tracks %d, per event %f\n", Ntr, (
float)Ntr / nEvents);
1469 printf(
"GEM+DCH tracks %d, per event %f (%f%% per track)\n", Ntr1, (
float)Ntr1 / nEvents,
1470 Ntr > 0 ? (
float)Ntr1 / Ntr * 100.f : 0.f);
1471 printf(
"Good GEM+DCH tracks %d, per event %f (%f%% per valid track)\n", Ntr1g, (
float)Ntr1g / nEvents,
1472 Ntr1 > 0 ? (
float)Ntr1g / Ntr1 * 100.f : 0.f);
1473 printf(
"Matched GEM+DCH tracks %d, per event %f (%f%% per good track)\n", Ntr0, (
float)Ntr0 / nEvents,
1474 Ntr1g > 0 ? (
float)Ntr0 / Ntr1g * 100.f : 0.f);
1487 char fname_calibr_root[128], *delim = 0;
1489 if ((delim = strrchr(fname_calibr_root, (
int)
'.')))
1491 strcat(fname_calibr_root,
"_calibration.root");
1492 TFile* fc =
new TFile(fname_calibr_root,
"RECREATE",
"Proton mass based calibration of BmnTOF700");
1751 FILE *fdeb = 0, *fcaly = 0, *fcalyc = 0, *fcalxc = 0;
1754 TF1 *li = 0, *lir = 0;
1759 char fname_ycalibr_root[128], *delim = 0;
1762 if ((delim = strrchr(fname_ycalibr_root, (
int)
'.')))
1765 strcat(fname_ycalibr_root,
"_y_calibration_new.txt");
1767 strcat(fname_ycalibr_root,
"_y_calibration.txt");
1768 fcaly = fopen(fname_ycalibr_root,
"w");
1772 if ((delim = strrchr(fname_ycalibr_root, (
int)
'.')))
1775 strcat(fname_ycalibr_root,
"_y_calibration_chamber_new.txt");
1777 strcat(fname_ycalibr_root,
"_y_calibration_chamber.txt");
1778 fcalyc = fopen(fname_ycalibr_root,
"w");
1782 if ((delim = strrchr(fname_ycalibr_root, (
int)
'.')))
1785 strcat(fname_ycalibr_root,
"_x_calibration_chamber_new.txt");
1787 strcat(fname_ycalibr_root,
"_x_calibration_chamber.txt");
1788 fcalxc = fopen(fname_ycalibr_root,
"w");
1791 sprintf(filn,
"XYcalibration_chambers.txt");
1793 sprintf(filn,
"XYcalibration_chambers_new.txt");
1794 fdeb = fopen(filn,
"w");
1796 fcalc =
new TFile(
"FitPicturesChambers_new.root",
"recreate");
1798 fcalc =
new TFile(
"FitPicturesChambers.root",
"recreate");
1810 sprintf(namp,
"Chamber_%d_calibration", ip);
1811 proj[ip] =
XvsLR->ProfileY(namp, ip + 1, ip + 1);
1814 sprintf(namf,
"Chamber_%d_line", ip);
1815 li =
new TF1(namf,
"pol1", lrmin, lrmax);
1816 proj[ip]->
Fit(namf,
"QR");
1817 if (!(proj[ip]->GetFunction(namf))) {
1821 fprintf(fdeb,
"Err: Chamber %d statistic %d\n", ip, ncon);
1830 fprintf(fdeb,
"Fit: Chamber %d statistic %d x0 %f x1 %f\n", ip, ncon, inter[ip], slope[ip]);
1837 fprintf(fdeb,
"Non: Chamber %d statistic %d\n", ip, ncon);
1840 fprintf(fcalxc,
" %3d %7.2f %7.2f\n", ip, inter[ip], slope[ip]);
1842 for (
int ir = 0; (ir < 10) && (ip == 22); ir++) {
1843 sprintf(namp,
"Chamber_%d_calibration_run%d", ip, ir);
1844 projr =
XvsLRvsRun[ir]->ProfileY(namp, ip + 1, ip + 1);
1845 ncon = projr->GetEntries();
1847 sprintf(namf,
"Chamber_%d_line_run%d", ip, ir);
1848 lir =
new TF1(namf,
"pol1", lrmin, lrmax);
1849 projr->Fit(namf,
"QR");
1850 if (projr->GetFunction(namf)) {
1851 Double_t inters = projr->GetFunction(namf)->GetParameter(0);
1852 Double_t slopes = projr->GetFunction(namf)->GetParameter(1);
1853 Double_t einters = projr->GetFunction(namf)->GetParError(0);
1854 Double_t eslopes = projr->GetFunction(namf)->GetParError(1);
1856 hfitx0run->SetBinContent(ir + 1, inters);
1857 hfitx1run->SetBinContent(ir + 1, slopes);
1858 hfitx0run->SetBinError(ir + 1, einters);
1859 hfitx1run->SetBinError(ir + 1, eslopes);
1865 sprintf(namp,
"Chamber_%d_Y_calibration", ip);
1866 proj1[ip] =
YvsY->ProfileY(namp, ip + 1, ip + 1);
1869 sprintf(namf,
"Chamber_%d_Y_line", ip);
1870 li =
new TF1(namf,
"pol0");
1871 proj1[ip]->
Fit(namf,
"Q");
1872 if (!(proj1[ip]->GetFunction(namf))) {
1874 for (
int is = 0; is < nstr; is++) {
1876 fprintf(fcaly,
" %3d %3d %7.2f\n", ip, is, shift[ip][is]);
1879 fprintf(fdeb,
"Err: Chamber %d statistic %d\n", ip, ncon);
1886 fprintf(fdeb,
"Fit: Chamber %d statistic %d shiftY %f\n", ip, ncon,
shiftyc[ip]);
1888 for (
int is = 0; is < nstr; is++) {
1890 hfity->Fill(shift[ip][is]);
1891 fprintf(fcaly,
" %3d %3d %7.2f\n", ip, is, shift[ip][is]);
1892 if (ip == 18 && fdeb) {
1893 fprintf(fdeb,
" Strip %d statistic %d shiftY %f\n", is,
1894 (
int)(proj1[ip]->GetBinEntries(is + 1)), shift[ip][is]);
1899 for (
int is = 0; is < nstr; is++) {
1901 fprintf(fcaly,
" %3d %3d %7.2f\n", ip, is, shift[ip][is]);
1905 fprintf(fdeb,
"Non: Chamber %d statistic %d\n", ip, ncon);
1908 fprintf(fcalyc,
" %3d %7.2f\n", ip,
shiftyc[ip]);