283 const char* DigitsTOF700 =
"argon_tof700_digits_files_pro_full.txt")
287#if ROOT_VERSION_CODE < ROOT_VERSION(5, 99, 99)
288 gROOT->LoadMacro(
"$VMCWORKDIR/macro/run/bmnloadlibs.C");
294 if (RunPeriod >= 1 && RunPeriod <= 7) {
295 sprintf(mapping,
"TOF700_map_period_%d.txt", RunPeriod);
297 printf(
"Non-existing run period number %d!", RunPeriod);
308 if (strstr(TracksGemDch,
".root")) {
309 bmnTree->
Add(TracksGemDch);
311 ifstream fin(TracksGemDch);
313 for (
int idx = 0; idx < 1000; idx++) {
317 if (strlen(filename.Data()) == 0)
319 if ((filename.Data())[0] ==
'#')
321 cout <<
" GEM+DCH tracks file #" << idx + 1 <<
" " << filename.
Data() << endl;
322 bmnTree->
Add(filename);
326 printf(
"Non-existing run list file: %s!", TracksGemDch);
335 if (strstr(DigitsTOF700,
".root")) {
336 bmnTreetof700->
Add(DigitsTOF700);
339 ifstream fin(DigitsTOF700);
341 for (
int idx = 0; idx < 1000; idx++) {
345 if (strlen(filename.Data()) == 0)
347 if ((filename.Data())[0] ==
'#')
349 cout <<
" TOF digits file #" << idx + 1 <<
" " << filename.
Data() << endl;
350 bmnTreetof700->
Add(filename);
355 printf(
"Non-existing run list file: %s!", DigitsTOF700);
362 char fnametof700raw[256];
364 strcpy(strstr(fnametof700raw,
"digi.root"),
"raw.root");
381 char name[128], title[128];
384 gStyle->SetOptStat(111111);
390 char fname_calib_root[128];
392 TString dir = getenv(
"VMCWORKDIR");
398 strcpy(fname_calib_root, path.Data());
402 if ((delim = strrchr(fname_calib_root, (
int)
'.')))
404 strcat(fname_calib_root,
"_calibration.root");
406 TFile* fc =
new TFile(fname_calib_root,
"READ",
"Proton mass based calibration of BmnTOF700");
414 printf(
"\n ******************* Time offsets for whole chamber **********************\n");
417 printf(
"%d %f\n", c,
tofcalc[c]);
421 printf(
"\n ******************* Time offsets for one strip **************************\n");
424 printf(
"\n Chamber %d %.1f\n", c,
idchambers[c]);
428 for (
int s = 0; s < smax; s++) {
431 printf(
" strip %d %f\n", s,
tofcals[c][s]);
434 printf(
"\n *************************************************************************\n");
441 char fname_root[128], *delim = 0;
443 if ((delim = strrchr(fname_root, (
int)
'.')))
445 strcat(fname_root,
"_identification_results.root");
446 f =
new TFile(fname_root,
"RECREATE",
"Results of BmnTOF700");
449 TH1F* hntr =
new TH1F(
"hntr",
"Number of all tracks", 200, 0, 200);
450 TH1F* hntr0 =
new TH1F(
"hntr0",
"Number of selected tracks", 200, 0, 200);
451 TH1F* hntr1 =
new TH1F(
"hntr1",
"Number of tracks with FLAG conditions", 200, 0, 200);
452 TH2F* hxytr =
new TH2F(
"hxytr",
"XY tracks", 1500, -150, 150, 1000, -100, 100);
453 TH1F* hptr =
new TH1F(
"hptr",
"Momentum of tracks", 1000, -10, 10);
454 TH1F* hp0 =
new TH1F(
"hp0",
"Momentum of tracks (all)", 1000, -10, 10);
455 TH1F* hltr =
new TH1F(
"hltr",
"Lenght of GEM tracks", 100, 500, 700);
456 TH1F* hltra =
new TH1F(
"hltra",
"Lenght of GEM+DCH tracks", 100, 500, 700);
457 TH2F* hxytrtof =
new TH2F(
"hxytrtof",
"XY tracks with TOF700 hits", 1500, -150, 150, 1000, -100, 100);
458 TH2F* hxyhit =
new TH2F(
"hxyhit",
"XY track hit distance from TOF700 hit", 200, -50, 50, 40, -10, 10);
459 TH2F* hxyhitlr =
new TH2F(
"hxyhitlr",
"XY track hit distance from TOF700 hit (lr cut)", 200, -50, 50, 40, -10, 10);
460 TH1F* hlrdiffs =
new TH1F(
"hlrdiffs",
"LR difference for TOF700 hits with track (small chamber)", 100, -5, +5);
461 TH1F* hlrdiffb =
new TH1F(
"hlrdiffb",
"LR difference for TOF700 hits with track (big chamber)", 100, -5, +5);
462 TH1F* hxdiff =
new TH1F(
"hxdiff",
"X difference for TOF700 hits with track", 100, -50, +50);
463 TH2F* hxxhits =
new TH2F(
"hxxhits",
"X track hit vs TOF700 hit (small chambers)", 200, -100, 100, 200, -100, 100);
464 TH2F* hxxhitb =
new TH2F(
"hxxhitb",
"X track hit vs TOF700 hit (big chambers)", 200, -100, 100, 200, -100, 100);
465 TH2F* hlrxhits =
new TH2F(
"hlrxhits",
"X TOF700 hit vs LR difference (small chamber)", 100, -5, 5, 200, -100, 100);
466 TH2F* hlrxhitb =
new TH2F(
"hlrxhitb",
"X TOF700 hit vs LR difference (big chamber)", 100, -5, 5, 200, -100, 100);
468 TH2F* hlrxtrs =
new TH2F(
"hlrxtrs",
"X TOF700 tr vs LR difference (small chamber)", 100, -5, 5, 200, -100, 100);
469 TH2F* hlrxtrb =
new TH2F(
"hlrxtrb",
"X TOF700 tr vs LR difference (big chamber)", 100, -5, 5, 200, -100, 100);
471 TH1F* hcsignp =
new TH1F(
"hsignp",
"Chambers with right correlation (x vs lr)", 60, 0, 60);
472 TH1F* hcsignm =
new TH1F(
"hsignm",
"Chambers with wrong correlation (x vs lr)", 60, 0, 60);
474 TH1F* htoftr =
new TH1F(
"htoftr",
"TOF of tracks with TOF700 hits", 600, -20, 40);
475 TH1F* htof =
new TH1F(
"htof",
"TOF for hits", 600, -20, 40);
476 TH1F* hntof =
new TH1F(
"hntof",
"Number of hits", 100, 0, 100);
477 TH1F* hnhit =
new TH1F(
"hnhit",
"Number of hits in width limits", 100, 0, 100);
478 TH2F* hxytof =
new TH2F(
"hxytof",
"XY TOF700 hits", 1500, -150, 150, 1000, -100, 100);
479 TH2F* hpbeta =
new TH2F(
"hpbeta",
"Beta vs momentum", 200, 0, 10, 220, 0, 1.1f);
481 TH2F* hpbetac =
new TH2F(
"hpbetac",
"Beta vs momentum, chamber corrections", 200, 0, 10, 220, 0, 1.1f);
483 TH2F* hpbetas =
new TH2F(
"hpbetas",
"Beta vs momentum, strip corrections", 200, 0, 10, 220, 0, 1.1f);
485 TH2F* hpbetacm =
new TH2F(
"hpbetacm",
"Beta vs momentum, Z<0, chamber corrections", 200, 0, 10, 220, 0, 1.1f);
487 TH2F* hpbetasm =
new TH2F(
"hpbetasm",
"Beta vs momentum, Z<0, strip corrections", 200, 0, 10, 220, 0, 1.1f);
489 TH1F* hmass =
new TH1F(
"hmass",
"Mass, p<2", 400, -0.5, 9.5);
490 TH1F* hmassc =
new TH1F(
"hmassc",
"Mass, chamber corrections", 400, -0.5, 9.5);
491 TH1F* hmassc15 =
new TH1F(
"hmassc15",
"Mass, chamber corrections, p<1.5", 400, -0.5, 9.5);
492 TH1F* hmassc20 =
new TH1F(
"hmassc20",
"Mass, chamber corrections, p<2.0", 400, -0.5, 9.5);
493 TH1F* hmasss =
new TH1F(
"hmasss",
"Mass, strip corrections", 400, -0.5, 9.5);
494 TH1F* hmasss15 =
new TH1F(
"hmasss15",
"Mass, strip corrections, p<1.5", 400, -0.5, 9.5);
495 TH1F* hmasss20 =
new TH1F(
"hmasss20",
"Mass, strip corrections, p<2.0", 400, -0.5, 9.5);
496 TH1F* hmasscm =
new TH1F(
"hmasscm",
"Mass, Z<0, chamber corrections", 200, -1, 4);
497 TH1F* hmasssm =
new TH1F(
"hmasssm",
"Mass, Z<0, strip corrections", 200, -1, 4);
499 TH1F* hdtps =
new TH1F(
"hdtps",
"Time resolution, protons, strip corrections", 200, -1., +1.);
501 new TH2F(
"hdtpsvsp",
"Time resolution vs momentum, protons, strip corrections", 240, 0., 6., 200, -1., +1.);
503 TH1F* hdtpc =
new TH1F(
"hdtpc",
"Time resolution, protons, chamber corrections", 200, -1., +1.);
505 new TH2F(
"hdtpcvsp",
"Time resolution vs momentum, protons, chamber corrections", 240, 0., 6., 200, -1., +1.);
507 TH2F* hdtpcvspwlim =
new TH2F(
"hdtpcvspwlim",
"Time resolution vs momentum, protons, chamber corrections, w>3000",
508 240, 0., 6., 200, -1., +1.);
510 TH1F* hdtpcplim =
new TH1F(
"hdtpcplim",
"Time resolution, protons, p>3", 200, -1., +1.);
511 TH1F* hdtpcp1lim =
new TH1F(
"hdtpcp1lim",
"Time resolution, protons, p>4", 200, -1., +1.);
512 TH1F* hdtpcp2lim =
new TH1F(
"hdtpcp2lim",
"Time resolution, protons, p<2", 200, -1., +1.);
513 TH1F* hdtpcp3lim =
new TH1F(
"hdtpcp3lim",
"Time resolution, protons, 2<p<5", 200, -1., +1.);
514 TH1F* hdtpcwlim =
new TH1F(
"hdtpcwlim",
"Time resolution, protons, w>3000", 200, -1., +1.);
515 TH1F* hdtpcwplim =
new TH1F(
"hdtpcwplim",
"Time resolution, protons, p>3, w>3000", 200, -1., +1.);
516 TH1F* hdtpcwp1lim =
new TH1F(
"hdtpcwp1lim",
"Time resolution, protons, p>4, w>3000", 200, -1., +1.);
518 TH2F* hmassvsp =
new TH2F(
"hmassvsp",
"Mass vs momentum", 240, 0., 6., 200, -0.2, 4.8);
520 TH2F* hmasssvsp =
new TH2F(
"hmasssvsp",
"Mass vs momentum, strip correction", 240, 0., 6., 200, -0.2, 4.8);
522 TH2F* hmasscvsp =
new TH2F(
"hmasscvsp",
"Mass vs momentum, chamber corrections", 240, 0., 6., 200, -0.2, 4.8);
524 TH2F* hmasssmvsp =
new TH2F(
"hmasssmvsp",
"Mass vs momentum, Z<0, strip correction", 240, 0., 6., 200, -0.2, 4.8);
527 new TH2F(
"hmasscmvsp",
"Mass vs momentum, Z<0, chamber corrections", 240, 0., 6., 200, -0.2, 4.8);
530 TH1F* htofp =
new TH1F(
"htofp",
"TOF for proton hits, p<2", 600, -20, 40);
531 TH1F* hstr =
new TH1F(
"hstr",
"Strips", 32, 0, 32);
532 TH1F* hcha =
new TH1F(
"hcha",
"Chambers", 60, 0, 60);
533 TH1F* hstrtr =
new TH1F(
"hstrtr",
"Strips with tracks", 32, 0, 32);
534 TH1F* hchatr =
new TH1F(
"hchatr",
"Chambers with tracks", 60, 0, 60);
536 TH2F* hdxy0 =
new TH2F(
"hdxy0",
"DxDy all", 40, -10, +10, 40, -10, +10);
537 TH1F* hdx =
new TH1F(
"hdx",
"dx all", 40, -10, +10);
538 TH1F* hdy =
new TH1F(
"hdy",
"dy all", 40, -10, +10);
539 TH2F* hdxy =
new TH2F(
"hdxy",
"DxDy selected", 40, -10, +10, 40, -10, +10);
540 TH2F* hdxytof =
new TH2F(
"hdxytof",
"DxDy with TOF700 hits", 40, -10, +10, 40, -10, +10);
541 TH2F* hdxyeff =
new TH2F(
"hdxyeff",
"Efficiency vs DxDy", 40, -10, +10, 40, -10, +10);
543 TH1F* hdxeff =
new TH1F(
"hdxeff",
"Efficiency vs Dx", 40, -10, +10);
544 TH1F* hdyeff =
new TH1F(
"hdyeff",
"Efficiency vs Dy", 40, -10, +10);
545 TH2F* hxygoodtr =
new TH2F(
"hxygoodtr",
"XY good tracks", 70, -140, 140, 60, -90, 90);
546 TH2F* hxygoodhit =
new TH2F(
"hxygoodhit",
"XY good tracks with good hits", 70, -140, 140, 60, -90, 90);
547 TH2F* hxyeff =
new TH2F(
"hxyeff",
"Efficiency vs XY good tracks", 70, -140, 140, 60, -90, 90);
549 TH1F* hxeff =
new TH1F(
"hxeff",
"Efficiency vs X good tracks", 70, -140, 140);
550 TH1F* hyeff =
new TH1F(
"hyeff",
"Efficiency vs Y good tracks", 60, -90, 90);
551 TH1F* hdtx =
new TH1F(
"hdtx",
"dtx", 100, -0.25, +0.25);
552 TH1F* hdty =
new TH1F(
"hdty",
"dty", 100, -0.25, +0.25);
553 TH1F* hDdx =
new TH1F(
"hDdx",
"Err dx", 100, 0, 10);
554 TH1F* hDdy =
new TH1F(
"hDdy",
"Err dy", 100, 0, 10);
555 TH1F* hDdtx =
new TH1F(
"hDdtx",
"Err dtx", 100, 0, 0.05);
556 TH1F* hDdty =
new TH1F(
"hDdty",
"Err dty", 100, 0, 0.05);
557 TH1F* hpdx =
new TH1F(
"hpdx",
"Pull dx", 500, -2.5, +2.5);
558 TH1F* hpdy =
new TH1F(
"hpdy",
"Pull dy", 500, -2.5, +2.5);
559 TH1F* hpdtx =
new TH1F(
"hpdtx",
"Pull dtx", 500, -25., +25.);
560 TH1F* hpdty =
new TH1F(
"hpdty",
"Pull dty", 500, -25., +25.);
561 TH1F* hchi2m =
new TH1F(
"hChi2m",
"Chi2 GemDch track", 1000, 0, 100);
562 TH1F* hchi2 =
new TH1F(
"hchi2",
"Chi2 tracks matching", 1000, 0, 100);
573 char nam[64], tit[64];
578 XvsLR =
new TProfile2D(
"xvslr",
"X calibration, chambers",
NUMBER_CHAMBERS, 0,
NUMBER_CHAMBERS, 80, -4, 4, -40.,
582 for (
int i = 0;
i < 10;
i++) {
583 sprintf(nam,
"xvslrvsrun%d",
i);
584 sprintf(tit,
"X calibration, events %d - %d",
i * 30000 + 1, (
i + 1) * 30000);
585 XvsLRvsRun[
i] =
new TProfile2D(nam, tit,
NUMBER_CHAMBERS, 0,
NUMBER_CHAMBERS, 80, -4, 4, -40., +40.,
"e");
588 sprintf(nam,
"xvslrvss%d",
i);
589 sprintf(tit,
"X calibration, strips, chamber %.1f",
idchambers[
i]);
590 XvsLRvsStrip[
i] =
new TProfile2D(nam, tit, 32, 0, 32, 80, -4, 4, -40., +40.,
"e");
591 sprintf(nam,
"xglobvslrvss%d",
i);
592 sprintf(tit,
"X global calibration, strips, chamber %.1f",
idchambers[
i]);
593 XvsLRvsStrip1[
i] =
new TProfile2D(nam, tit, 32, 0, 32, 80, -4, 4, -150., +150.,
"e");
596 sprintf(nam,
"xvslrp%d",
i);
597 sprintf(tit,
"X vs LR plot, chamber %.1f",
idchambers[
i]);
598 XvsLRp[
i] =
new TH2F(nam, tit, 80, -4, 4, 80, -40., +40.);
601 hfitx0 =
new TH1F(
"hfitx0",
"X vs LR constant", 200, -5, +5);
602 hfitx1 =
new TH1F(
"hfitx1",
"X vs LR slope", 200, -20, 20);
603 hfitx0run =
new TH1F(
"hfitx0run",
"X vs LR constant vs run", 20, 0, 20);
604 hfitx1run =
new TH1F(
"hfitx1run",
"X vs LR slope vs run", 20, 0, 20);
605 hfitxs0 =
new TH1F(
"hfitxs0",
"X vs LR constant", 100, -5, +5);
606 hfitxs1 =
new TH1F(
"hfitxs1",
"X vs LR slope", 200, -20, 20);
607 hfitxs0a =
new TH1F(
"hfitxs0a",
"X vs LR constant", 100, -5, +5);
608 hfitxs1a =
new TH1F(
"hfitxs1a",
"X vs LR slope", 200, -20, 20);
609 hfitx1s0 =
new TH1F(
"hfitx1s0",
"X vs LR constant", 600, -150, +150);
610 hfitx1s1 =
new TH1F(
"hfitx1s1",
"X vs LR slope", 200, -20, 20);
611 hfitx1s1a =
new TH1F(
"hfitx1s1a",
"X vs LR slope", 200, -20, 20);
612 hfity =
new TH1F(
"hfity",
"Y shift", 100, -5, +5);
613 hfityc =
new TH1F(
"hfityc",
"Y shift (chambers average)", 100, -5, 5);
616 float cvel = 29.97925f;
617 float ekin = 3.2f, ebeam = ekin +
MP, pbeam =
TMath::Sqrt(ebeam * ebeam +
MP *
MP);
618 float cbeam = pbeam / ebeam;
619 float cpeak = cbeam *
CFACTOR * cvel;
623 TOF2->get_chamber_z(
i, &zc[
i]);
626 Int_t startEvent = 0;
629 printf(
"\nNumber of events in tracks chain is %d (tof700 chain %d)\n", nEvents, nEventstof700);
631 int Ntr = 0, Ntr1 = 0, Ntr1g = 0, Ntr0 = 0;
632 Int_t iEv = 0, iEvtof700 = 0, fCurrent = -1, nevs = 0;
633 UInt_t trackEvId = 0, tof700EvId = 0;
634 UInt_t trackRunId = 0, tof700RunId = 0;
642 TH1D *projtmp = 0, *projtmp1 = 0;
643 for (
Int_t iEv0 = startEvent; iEv0 < startEvent + nEvents; iEv0++) {
644 if (iEv % 10000 == 0) {
645 cout <<
"Event: " << iEv <<
"/" << startEvent + nEvents <<
" ( Run " << trackRunId <<
" EvId " << trackEvId
653 if (mtracks == NULL) {
661 }
while (gemdchtrack0 == NULL);
668 if (eventHeader == NULL)
673 if (tof700RunId == trackRunId && tof700EvId > trackEvId)
675 if (tof700RunId > trackRunId)
678 if (!(tof700EvId == trackEvId && tof700RunId == trackRunId)) {
681 if (eventHeadertof700 == NULL)
685 tof700RunId = eventHeadertof700->GetRunId();
690 if (iEvtof700 >= nEventstof700)
692 if (tof700RunId > trackRunId)
694 if (tof700RunId == trackRunId && tof700EvId > trackEvId)
696 }
while (!(tof700EvId == trackEvId && tof700RunId == trackRunId));
698 if (eventHeadertof700 == NULL)
700 if (!(tof700EvId == trackEvId && tof700RunId == trackRunId)) {
701 cout <<
"Not found EventId " << trackEvId <<
" in tof700 digits file" << endl;
702 cout <<
"Tracks Event: " << iEv <<
", TOF700 Event: " << iEvtof700 << endl;
703 cout <<
"Tracks RunId: " << trackRunId <<
", TOF700 RunId: " << tof700RunId << endl;
704 cout <<
"Tracks EventId: " << trackEvId <<
", TOF700 EventId: " << tof700EvId << endl;
705 if (iEvtof700 >= nEventstof700)
707 if (tof700RunId > trackRunId)
709 if (tof700RunId == trackRunId && tof700EvId > trackEvId)
726 for (
int j = 0; j < 32; j++)
728 for (
int j = 0; j < 32; j++)
730 for (
int j = 0; j < 32; j++)
737 float x = 0., y = 0., z = 0.;
738 float x0 = 0., y0 = 0., z0 = 0.;
739 int hchamb[1000] = {0}, hstrip[1000] = {0};
740 int clchamb[1000] = {0}, clstrip[1000] = {0};
741 Bool_t usedstrip[1000] = {
false};
743 for (
Int_t iDig = 0; iDig < ntof; ++iDig) {
751 Float_t lrdiff = digit->GetDiff();
757 if (
XYPANIN && (
TOF2->get_hit_xp(plane, strip, lrdiff) == 0.))
761 if (width <
wmi[plane] || width >
wma[plane])
764 TOF2->get_hit_xyzp(plane, strip, lrdiff, &x, &y, &z);
766 TOF2->get_hit_xyzng(plane, strip, lrdiff, &x, &y, &z);
770 TOF2->get_hit_xyz(plane, strip, lrdiff, &x, &y, &z);
771 smax1[plane] = strip;
772 if (width > wmax[plane]) {
781 nhits[plane][strip]++;
782 tof[plane][strip] = time;
790 TOF2->get_strip_xyz(plane, strip, &x, &y, &z);
796 numhit[plane][strip] =
nhi;
801 float xyz[3] = {0.}, cxyz[3] = {0.}, xrpc = 0., yrpc = 0., dz = 100., tx = 0., ty = 0., zcha = 0.;
802 float beta = 1.0f, mass = 1.0f, mass2 = 1.0f, tcor = 0., tcorc = 0., tcors = 0., tcorspi = 0., tcorcpi = 0.;
804 int ntr = mtracks->GetEntriesFast();
808 int ntr1 = 0, ntr1g = 0;
809 int iflag = 0, igem = 0, idch = 0;
839 Double_t le = 0., p = 0., ps = 0., pmod = 0., lenr = 0.;
842 double dist = 0., distmin = 1000000000.0f;
857 float massmaxpi = 0.;
858 float massminpi = 0.;
868 double timepeak = 0., betapeak = 0.;
870 for (
Int_t iTr = 0; iTr < ntr; ++iTr) {
872 if (gemdchtrack == NULL)
900 hp0->
Fill(1. / QpGem);
916 Xpv = gemdchtrack->
GetXpv();
917 Ypv = gemdchtrack->
GetYpv();
923 if (primaryVertex->
GetX() < -2 || primaryVertex->
GetX() > 2.5 || primaryVertex->
GetY() < 1
924 || primaryVertex->
GetY() > 4 || primaryVertex->
GetZ() < -1 || primaryVertex->
GetZ() > 2)
928 if ((!goodpv) || nGemHits <
MINGEMNDF || nSiHits <
MINSIHITS || xGem < -140.f || xGem > 240.f
929 || yGem < -40.f || yGem > 200.f || txGem < -0.5f || txGem > 1.0f || tyGem < -0.1f || tyGem > 0.5f
930 || Xpv < -3.5f || Xpv > 4.0f || Ypv < -1.0f || Ypv > 6.0f || QpGem == 0.0f
934 printf(
"Reject: NDF %d xGem %f yGem %f txGem %f tyGem %f Xpv %f Ypv %f QpGem %f\n", nGemHits,
935 xGem, yGem, txGem, tyGem, Xpv, Ypv, QpGem);
939 printf(
"Accept: NDF %d xGem %f yGem %f txGem %f tyGem %f Xpv %f Ypv %f QpGem %f\n", nGemHits, xGem,
940 yGem, txGem, tyGem, Xpv, Ypv, QpGem);
944 dxm = gemdchtrack->
GetDx();
945 dym = gemdchtrack->
GetDy();
946 dtx = gemdchtrack->
GetDtx();
947 dty = gemdchtrack->
GetDty();
948 Ddx = gemdchtrack->
GetDdx();
949 Ddy = gemdchtrack->
GetDdy();
952 Chi2m = gemdchtrack->
GetChi2();
955 hdxy0->
Fill(dxm, dym);
971 xgoodtr = xyz[0] + tx * 100.;
972 ygoodtr = xyz[1] + ty * 100.;
973 hxytr->
Fill(xgoodtr, ygoodtr);
983 chi2 = dxm * dxm / Ddx + dym * dym / Ddy;
987 hdxy->
Fill(dxm, dym);
999 hxygoodtr->
Fill(xgoodtr, ygoodtr);
1000 cxyz[0] = tx /
TMath::Sqrt(1. + tx * tx + ty * ty);
1001 cxyz[1] = ty /
TMath::Sqrt(1. + tx * tx + ty * ty);
1002 cxyz[2] = 1. /
TMath::Sqrt(1. + tx * tx + ty * ty);
1012 int clstart = -1, clwidth = -1, cstr = -1;
1013 float samps = 0., timemin = 1000000000.;
1014 float widthmax = 0.;
1018 for (
int j = 0; j < nstr && nhit[i] > 0; j++) {
1024 timemin =
tof[
i][j];
1028 if (
tof[
i][j] < timemin) {
1029 timemin =
tof[
i][j];
1040 if (j == (nstr - 1)) {
1042 clstrip[ncl0] = cstr;
1043 clwidth = (j + 1 - clstart);
1044 tcl[
i][ncl[
i]] = timemin;
1045 acl[
i][ncl[
i]] = samps;
1046 wcl[
i][ncl[
i]] = clwidth;
1050 timemin = 1000000000.;
1053 }
else if (clstart >= 0) {
1055 clstrip[ncl0] = cstr;
1056 clwidth = (j - clstart);
1057 tcl[
i][ncl[
i]] = timemin;
1058 acl[
i][ncl[
i]] = samps;
1059 wcl[
i][ncl[
i]] = clwidth;
1063 timemin = 1000000000.;
1071 distmin = 1000000000.0f;
1072 for (
int icl = 0; icl < ncl0; icl++) {
1075 int ih = numhit[ic][is];
1078 dz =
zhi[ih] - xyz[2];
1079 xrpc = xyz[0] + dz * tx;
1080 yrpc = xyz[1] + dz * ty;
1089 dx = xrpc -
xhi[ih];
1090 dy = yrpc -
yhi[ih];
1100 if (
dist < distmin) {
1102 himin = numhit[ic][is];
1109 distmin = 1000000000.0f;
1110 for (
int ih = 0; ih < nh; ih++) {
1115 dz =
zhi[ih] - xyz[2];
1116 xrpc = xyz[0] + dz * tx;
1117 yrpc = xyz[1] + dz * ty;
1126 dx = xrpc -
xhi[ih];
1127 dy = yrpc -
yhi[ih];
1137 if (
dist < distmin) {
1149 usedstrip[himin] =
true;
1150 hdxytof->
Fill(dxm, dym);
1151 hxygoodhit->
Fill(xgoodtr, ygoodtr);
1157 dz =
zhi[himin] - xyz[2];
1158 xrpc = xyz[0] + dz * tx;
1159 yrpc = xyz[1] + dz * ty;
1161 hxyhit->
Fill(xrpc -
xhi[himin], yrpc -
yhi[himin]);
1163 hxyhitlr->
Fill(xrpc -
xhi[himin], yrpc -
yhi[himin]);
1165 hxyhitlr->
Fill(xrpc -
xhi[himin], yrpc -
yhi[himin]);
1170 hxdiff->
Fill(
xhi[himin] - xc);
1172 hxxhits->
Fill(
xhi[himin] - xc, xrpc - xc);
1174 hxxhitb->
Fill(
xhi[himin] - xc, xrpc - xc);
1181 hlrxtrs->
Fill(
lrd[himin], xrpc - xc);
1183 hlrxtrb->
Fill(
lrd[himin], xrpc - xc);
1185 if (
lrd[himin] > 0. && (
xhi[himin] - xc) > 0.)
1187 if (
lrd[himin] < 0. && (
xhi[himin] - xc) < 0.)
1189 if (
lrd[himin] > 0. && (
xhi[himin] - xc) < 0.)
1191 if (
lrd[himin] < 0. && (
xhi[himin] - xc) > 0.)
1198 XvsLR->Fill(ic,
lrd[himin], xrpc - xc);
1199 XvsLRp[ic]->Fill(
lrd[himin], xrpc - xc);
1200 YvsY->Fill(ic, is, yrpc - yc);
1201 Int_t numrun = nevs / 30000;
1207 cosa =
sqrt(1. + tx * tx + ty * ty);
1211 hidist =
TMath::Sqrt(xc * xc + yc * yc + (zc - ztarg) * (zc - ztarg));
1217 hxytrtof->
Fill(xrpc, yrpc);
1225 tofr =
tof[ic][is] + lenr / cpeak;
1233 tofr0 =
tof[ic][is];
1236 beta = lenr / tofr / cvel;
1240 mass2 = p * p * (1.f /
beta /
beta - 1.f);
1248 if (p > 0.f && mass2 > massmin1 && mass2 < massmax1 && pmod >
PMIN && pmod <
PMAX) {
1252 tcors = tcor -
tofcals[ic][is];
1253 tcalibrc->
Fill(ic, tcorc);
1254 tcalibrs->
Fill(ic, is, tcors);
1258 if (mass2 > massmin2 && mass2 < massmax2) {
1260 hdtpcvsp->
Fill(p, tcorc);
1262 hdtpsvsp->
Fill(p, tcors);
1264 hdtpcplim->
Fill(tcorc);
1266 hdtpcp1lim->
Fill(tcorc);
1268 hdtpcp2lim->
Fill(tcorc);
1269 if (p >= 2.0f && p < 5.0f)
1270 hdtpcp3lim->
Fill(tcorc);
1272 hdtpcwlim->
Fill(tcorc);
1273 hdtpcvspwlim->
Fill(p, tcorc);
1275 hdtpcwplim->
Fill(tcorc);
1277 hdtpcwp1lim->
Fill(tcorc);
1283 if (p > 0 && massmaxpi > massmin1)
1284 massmaxpi = massmin1;
1287 if (mass2 < massmaxpi && mass2 > massminpi && pmod >
PMIN && pmod <
PMAXPI) {
1289 tcorpi = tofpi - tofr;
1290 tcorcpi = tcorpi -
tofcalc[ic];
1291 tcorspi = tcorpi -
tofcals[ic][is];
1292 tcalibrc->
Fill(ic, tcorcpi);
1293 tcalibrs->
Fill(ic, is, tcorspi);
1296 betapeak = lenr / timepeak / cvel;
1297 tpeak->
Fill(ic, timepeak);
1298 bpeak->
Fill(ic, betapeak);
1300 tofrs = tofr +
tofcals[ic][is];
1301 betac = lenr / tofrc / cvel;
1302 betas = lenr / tofrs / cvel;
1303 masss2 = p * p * (1.f / betas / betas - 1.f);
1305 massc2 = p * p * (1.f / betac / betac - 1.f);
1308 hpbetac->
Fill(p, betac);
1309 hmassc->
Fill(massc2);
1310 hmasscvsp->
Fill(p, massc2);
1311 hpbetas->
Fill(p, betas);
1312 hmasss->
Fill(masss2);
1313 hmasssvsp->
Fill(p, masss2);
1315 hmasss15->
Fill(masss2);
1316 hmassc15->
Fill(massc2);
1319 hmasss20->
Fill(masss2);
1320 hmassc20->
Fill(massc2);
1324 hmasscm->
Fill(massc2);
1327 hmasssm->
Fill(masss2);
1337 if (iEv % 50000 == 0) {
1338 hdxyeff->
Divide(hdxytof, hdxy);
1349 hxyeff->
Divide(hxygoodhit, hxygoodtr);
1362 printf(
"Number of tracks %d, per event %f\n", Ntr, (
float)Ntr / nEvents);
1363 printf(
"GEM+DCH1+DCH2 tracks %d, per event %f (%f%% per track)\n", Ntr1, (
float)Ntr1 / nEvents,
1364 (
float)Ntr1 / Ntr * 100.f);
1365 printf(
"Good GEM+DCH1+DCH2 tracks %d, per event %f (%f%% per track)\n", Ntr0, (
float)Ntr0 / nEvents,
1366 (
float)Ntr0 / Ntr * 100.f);
1367 }
else if (
FLAG > 0) {
1368 printf(
"Number of tracks %d, per event %f\n", Ntr, (
float)Ntr / nEvents);
1369 printf(
"GEM+DCH1 tracks %d, per event %f (%f%% per track)\n", Ntr1, (
float)Ntr1 / nEvents,
1370 (
float)Ntr1 / Ntr * 100.f);
1371 printf(
"Good GEM+DCH1 tracks %d, per event %f (%f%% per track)\n", Ntr0, (
float)Ntr0 / nEvents,
1372 (
float)Ntr0 / Ntr * 100.f);
1374 printf(
"Number of tracks %d, per event %f\n", Ntr, (
float)Ntr / nEvents);
1375 printf(
"GEM+DCH tracks %d, per event %f (%f%% per track)\n", Ntr1, (
float)Ntr1 / nEvents,
1376 Ntr > 0 ? (
float)Ntr1 / Ntr * 100.f : 0.f);
1377 printf(
"Good GEM+DCH tracks %d, per event %f (%f%% per valid track)\n", Ntr1g, (
float)Ntr1g / nEvents,
1378 Ntr1 > 0 ? (
float)Ntr1g / Ntr1 * 100.f : 0.f);
1379 printf(
"Matched GEM+DCH tracks %d, per event %f (%f%% per good track)\n", Ntr0, (
float)Ntr0 / nEvents,
1380 Ntr1g > 0 ? (
float)Ntr0 / Ntr1g * 100.f : 0.f);
1393 char fname_calibr_root[128], *delim = 0;
1395 if ((delim = strrchr(fname_calibr_root, (
int)
'.')))
1397 strcat(fname_calibr_root,
"_calibration.root");
1398 TFile* fc =
new TFile(fname_calibr_root,
"RECREATE",
"Proton mass based calibration of BmnTOF700");
1406 hdxyeff->
Divide(hdxytof, hdxy);
1417 hxyeff->
Divide(hxygoodhit, hxygoodtr);
1430 printf(
"Number of tracks %d, per event %f\n", Ntr, (
float)Ntr / nEvents);
1431 printf(
"GEM+DCH1+DCH2 tracks %d, per event %f (%f%% per track)\n", Ntr1, (
float)Ntr1 / nEvents,
1432 (
float)Ntr1 / Ntr * 100.f);
1433 printf(
"Good GEM+DCH1+DCH2 tracks %d, per event %f (%f%% per track)\n", Ntr0, (
float)Ntr0 / nEvents,
1434 (
float)Ntr0 / Ntr * 100.f);
1435 }
else if (
FLAG > 0) {
1436 printf(
"Number of tracks %d, per event %f\n", Ntr, (
float)Ntr / nEvents);
1437 printf(
"GEM+DCH1 tracks %d, per event %f (%f%% per track)\n", Ntr1, (
float)Ntr1 / nEvents,
1438 (
float)Ntr1 / Ntr * 100.f);
1439 printf(
"Good GEM+DCH1 tracks %d, per event %f (%f%% per track)\n", Ntr0, (
float)Ntr0 / nEvents,
1440 (
float)Ntr0 / Ntr * 100.f);
1442 printf(
"Number of tracks %d, per event %f\n", Ntr, (
float)Ntr / nEvents);
1443 printf(
"GEM+DCH tracks %d, per event %f (%f%% per track)\n", Ntr1, (
float)Ntr1 / nEvents,
1444 Ntr > 0 ? (
float)Ntr1 / Ntr * 100.f : 0.f);
1445 printf(
"Good GEM+DCH tracks %d, per event %f (%f%% per valid track)\n", Ntr1g, (
float)Ntr1g / nEvents,
1446 Ntr1 > 0 ? (
float)Ntr1g / Ntr1 * 100.f : 0.f);
1447 printf(
"Matched GEM+DCH tracks %d, per event %f (%f%% per good track)\n", Ntr0, (
float)Ntr0 / nEvents,
1448 Ntr1g > 0 ? (
float)Ntr0 / Ntr1g * 100.f : 0.f);
1461 char fname_calibr_root[128], *delim = 0;
1463 if ((delim = strrchr(fname_calibr_root, (
int)
'.')))
1465 strcat(fname_calibr_root,
"_calibration.root");
1466 TFile* fc =
new TFile(fname_calibr_root,
"RECREATE",
"Proton mass based calibration of BmnTOF700");
1725 FILE *fdeb = 0, *fcaly = 0, *fcalyc = 0, *fcalxc = 0;
1728 TF1 *li = 0, *lir = 0;
1733 char fname_ycalibr_root[128], *delim = 0;
1736 if ((delim = strrchr(fname_ycalibr_root, (
int)
'.')))
1739 strcat(fname_ycalibr_root,
"_y_calibration_new.txt");
1741 strcat(fname_ycalibr_root,
"_y_calibration.txt");
1742 fcaly = fopen(fname_ycalibr_root,
"w");
1746 if ((delim = strrchr(fname_ycalibr_root, (
int)
'.')))
1749 strcat(fname_ycalibr_root,
"_y_calibration_chamber_new.txt");
1751 strcat(fname_ycalibr_root,
"_y_calibration_chamber.txt");
1752 fcalyc = fopen(fname_ycalibr_root,
"w");
1756 if ((delim = strrchr(fname_ycalibr_root, (
int)
'.')))
1759 strcat(fname_ycalibr_root,
"_x_calibration_chamber_new.txt");
1761 strcat(fname_ycalibr_root,
"_x_calibration_chamber.txt");
1762 fcalxc = fopen(fname_ycalibr_root,
"w");
1765 sprintf(filn,
"XYcalibration_chambers.txt");
1767 sprintf(filn,
"XYcalibration_chambers_new.txt");
1768 fdeb = fopen(filn,
"w");
1770 fcalc =
new TFile(
"FitPicturesChambers_new.root",
"recreate");
1772 fcalc =
new TFile(
"FitPicturesChambers.root",
"recreate");
1784 sprintf(namp,
"Chamber_%d_calibration", ip);
1785 proj[ip] =
XvsLR->ProfileY(namp, ip + 1, ip + 1);
1788 sprintf(namf,
"Chamber_%d_line", ip);
1789 li =
new TF1(namf,
"pol1", lrmin, lrmax);
1790 proj[ip]->
Fit(namf,
"QR");
1791 if (!(proj[ip]->GetFunction(namf))) {
1795 fprintf(fdeb,
"Err: Chamber %d statistic %d\n", ip, ncon);
1804 fprintf(fdeb,
"Fit: Chamber %d statistic %d x0 %f x1 %f\n", ip, ncon, inter[ip], slope[ip]);
1811 fprintf(fdeb,
"Non: Chamber %d statistic %d\n", ip, ncon);
1814 fprintf(fcalxc,
" %3d %7.2f %7.2f\n", ip, inter[ip], slope[ip]);
1816 for (
int ir = 0; (ir < 10) && (ip == 22); ir++) {
1817 sprintf(namp,
"Chamber_%d_calibration_run%d", ip, ir);
1818 projr =
XvsLRvsRun[ir]->ProfileY(namp, ip + 1, ip + 1);
1819 ncon = projr->GetEntries();
1821 sprintf(namf,
"Chamber_%d_line_run%d", ip, ir);
1822 lir =
new TF1(namf,
"pol1", lrmin, lrmax);
1823 projr->Fit(namf,
"QR");
1824 if (projr->GetFunction(namf)) {
1825 Double_t inters = projr->GetFunction(namf)->GetParameter(0);
1826 Double_t slopes = projr->GetFunction(namf)->GetParameter(1);
1827 Double_t einters = projr->GetFunction(namf)->GetParError(0);
1828 Double_t eslopes = projr->GetFunction(namf)->GetParError(1);
1830 hfitx0run->SetBinContent(ir + 1, inters);
1831 hfitx1run->SetBinContent(ir + 1, slopes);
1832 hfitx0run->SetBinError(ir + 1, einters);
1833 hfitx1run->SetBinError(ir + 1, eslopes);
1839 sprintf(namp,
"Chamber_%d_Y_calibration", ip);
1840 proj1[ip] =
YvsY->ProfileY(namp, ip + 1, ip + 1);
1843 sprintf(namf,
"Chamber_%d_Y_line", ip);
1844 li =
new TF1(namf,
"pol0");
1845 proj1[ip]->
Fit(namf,
"Q");
1846 if (!(proj1[ip]->GetFunction(namf))) {
1848 for (
int is = 0; is < nstr; is++) {
1850 fprintf(fcaly,
" %3d %3d %7.2f\n", ip, is, shift[ip][is]);
1853 fprintf(fdeb,
"Err: Chamber %d statistic %d\n", ip, ncon);
1860 fprintf(fdeb,
"Fit: Chamber %d statistic %d shiftY %f\n", ip, ncon,
shiftyc[ip]);
1862 for (
int is = 0; is < nstr; is++) {
1864 hfity->Fill(shift[ip][is]);
1865 fprintf(fcaly,
" %3d %3d %7.2f\n", ip, is, shift[ip][is]);
1866 if (ip == 18 && fdeb) {
1867 fprintf(fdeb,
" Strip %d statistic %d shiftY %f\n", is,
1868 (
int)(proj1[ip]->GetBinEntries(is + 1)), shift[ip][is]);
1873 for (
int is = 0; is < nstr; is++) {
1875 fprintf(fcaly,
" %3d %3d %7.2f\n", ip, is, shift[ip][is]);
1879 fprintf(fdeb,
"Non: Chamber %d statistic %d\n", ip, ncon);
1882 fprintf(fcalyc,
" %3d %7.2f\n", ip,
shiftyc[ip]);