BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnXTCalibrationTOF700.C
Go to the documentation of this file.
1#include <Rtypes.h>
2#include <fstream>
3R__ADD_INCLUDE_PATH($VMCWORKDIR)
4#include "bmndata/BmnEnums.h"
5#include "macro/run/bmnloadlibs.C"
6
7#define OLD_DIGI_FILE false
8#define XYCALIBRATION true
9#define MINSTAT 50
10#define WRITE_NEW_CALIBRATION_FILES 1
11#define WRITE_CALIBRATION_X true
12#define WRITE_CALIBRATION_Y true
13#define WRITE_CALIBRATION_X_CHAMBER true
14#define WRITE_CALIBRATION_Y_CHAMBER true
15
16#define CALRUNNAME 1
17// filenames in geometry directory if CALRUNNAME=0
18#define CALIBFILE "bmn_run9687_digi_calibration.root"
19#define CORRECTIONFILE "bmn_argon_protonbased_time_corrections.root"
20
21#define GEMTYPE 2
22
23// Gleb_SIGEM_v1_*.root - Gem + SILICON треки версия Глеба с damount = dx * dx / (ddxgem + ddxdch) + dy * dy / (ddygem
24// + ddydch);
25#if GEMTYPE == 0
26#define DTXDCH +0.0
27#define DTYDCH +0.0
28#define DXDCH -9.2454
29#define DYDCH +3.7912
30#define DZDCH -0.1655
31#define MINGEMNDF 4
32#define MINSIHITS 2
33#define TRACKFILE "argon_tracks_gleb_chi2_files.txt"
34
35// Gleb_SIGEM_v1_filtered_*.root - Отфильтрованный Gem + SILICON треки версия Глеба с damount = dx * dx / (ddxgem +
36// ddxdch) + dy * dy / (ddygem + ddydch);
37#elif GEMTYPE == 1
38#define DTXDCH +0.0
39#define DTYDCH +0.0
40#define DXDCH -10.2734
41#define DYDCH +3.6434
42#define DZDCH -4.26
43#define MINGEMNDF 4
44#define MINSIHITS 2
45#define TRACKFILE "argon_tracks_gleb_chi2_filter_files.txt"
46
47// Gleb_SIGEM_v2_*.root - Gem + SILICON треки версия Глеба с damount = dx * dx + dy * dy;
48#elif GEMTYPE == 2
49/*
50#define DTXDCH +0.0
51#define DTYDCH +0.0
52#define DXDCH -9.2454
53#define DYDCH +3.7912
54#define DZDCH -0.1655
55#define MINGEMNDF 6
56#define TRACKFILE "argon_tracks_gleb_files.txt"
57*/
58#define DTXDCH +0.0
59#define DTYDCH +0.0
60#define DXDCH -9.1845
61#define DYDCH +3.143
62#define DZDCH -0.1655
63#define MINGEMNDF 4
64#define MINSIHITS 2
65#define TRACKFILE "argon_tracks_lalyo_files_full.txt"
66
67// Merts_SIGEM_v1_*.root - Gem + SILICON треки версия Merts с damount = dx * dx / (ddxgem + ddxdch) + dy * dy / (ddygem
68// + ddydch);
69#elif GEMTYPE == 3
70#define DTXDCH +0.0065589
71#define DTYDCH -0.0004069
72#define DXDCH -8.00097
73#define DYDCH -3.1156
74#define DZDCH -2.32
75#define MINGEMNDF 4
76#define MINSIHITS 2
77#define TRACKFILE "argon_tracks_merts_chi2_files.txt"
78
79// Merts_SIGEM_v2_*.root - Gem + SILICON треки версия Merts с damount = dx * dx + dy * dy;
80#elif GEMTYPE == 4
81#define DTXDCH +0.0065589
82#define DTYDCH -0.0004069
83#define DXDCH -8.00097
84#define DYDCH -3.1156
85#define DZDCH -2.32
86#define MINGEMNDF 4
87#define MINSIHITS 2
88#define TRACKFILE "argon_tracks_merts_files.txt"
89
90#endif
91
92// Old Gleb
93#define DTX0DCH +0.0
94#define DTY0DCH +0.0
95#define DX0DCH -10.3038
96#define DY0DCH +2.55
97#define DZ0DCH +1.94
98
99#define MINTIME true
100
101#define GEMDEBUG false
102
103#define XYPANIN 0
104#define XYPETNEW 1
105
106// #define DXGEMDCHMAX 5.
107// #define DYGEMDCHMAX 3.
108#define DXGEMDCHMAX 2.5
109#define DYGEMDCHMAX 1.5
110
111#define USE_CLUSTERS 1
112
113#define STRIP_CORRECTIONS 1
114#define LIST_STRIP_CORRECTIONS 0
115
116// CALIBRATION - 0 - read corrections from root file *calibration.root, main time peak from TOF700_MC_time_run7.txt
117// 1 - no calibration correction on input, calculation and store corrections in *calibration.root file,
118// mean time peak from beam momentum 2 - no calibration correction on input, calculation and store
119// corrections in *calibration.root file, mean time peak from TOF700_MC_time_run7.txt 3 - no calibration
120// correction on input, calculation and store corrections in *calibration.root file, mean time peak from
121// TOF700_MC_time_run7.txt
122#define CALIBRATION 2
123
124// PRIMARY_VERTEX_CUTS = 0 - don't use additional cuts on primary vertex, 1 - use additional cuts
125#define PRIMARY_VERTEX_CUTS 1
126
127// GEMCUTS = 0 - don't use additional cuts on GEM tracks, 1 - use additional cuts
128#define GEMCUTS 1
129
130// CVERS=0 - use last calibration tables, 1 - use *;1 version
131#define CVERS 1
132
133// CFACTOR - beta factor for main time peak particles
134#define CFACTOR 0.97f
135
136// FLAG -1 - (GEM+DCH1+DCH2), 0 - all, +1 (GEM+DCH1)
137#define FLAG 0
138
139// BETAMAX max velocity for proton selection
140#define BETAMAX 1.00f
141
142// PMIN min momentum for track selection
143#define PMIN 0.5f
144
145// PMAX max momentum for track selection
146#define PMAX 5.0f
147
148// PMAX1 max momentum for proton mass limits for calculate corrections
149#define PMAX1 3.0f
150
151// PMAX2 max momentum for proton mass limits for resolution hists
152#define PMAX2 2.5f
153
154// PRES min momentum for resolution hists
155#define PRES 2.0f
156
157// PRES1 another min momentum for resolution hists
158#define PRES1 3.0f
159
160// PMAXPI max momentum for pion track selection for calculate corrections
161#define PMAXPI 3.0f
162
163// MPIMAX max limit pion mass
164#define MPIMAX 0.2f
165
166// MP proton mass
167#define MP 0.938f
168
169// MP2 proton mass sqare
170#define MP2 (MP * MP)
171
172// pion mass
173#define MPI 0.139
174
175// pion mass square
176#define MPI2 (MPI * MPI)
177
178// scale factor for min mass proton region selection
179#define DMPSCALE1 1.
180
181// scale factor for max mass proton region selection
182#define DMPSCALE2 1.
183
184// scale factor for min mass proton region selection for time hist
185#define DMPSCALET1 1.
186
187// scale factor for max mass proton region selection for time hist
188#define DMPSCALET2 1.5
189
190// scale factor for pion region selection
191#define DMPISCALE 1.
192
193// PSCALE - momentum scale factor
194// #define PSCALE 0.96f
195#define PSCALE 0.99f
196// #define PSCALE 1.00f
197
198#define WRITE_CALIBRATION 1
199
200#define XFACTOR 1.0f
201#define DISTMAX 20.0f
202#define DXMAX 5.0f
203#define DYMAX 3.0f
204#define DXMAXPAN 5.0f
205#define DYMAXPAN 5.0f
206
207#define TOFMAX 39.0f
208
209#define IN_WIDTH_LIMITS 0
210#define WMIN 2900
211#define WMAX 9000
212
213#define NUMBER_CHAMBERS 59
214
217
218int wmi[NUMBER_CHAMBERS] = {2900};
219int wma[NUMBER_CHAMBERS] = {9000};
220
221int nhi = 0;
223int nhits[NUMBER_CHAMBERS][32] = {{0}};
224float tof[NUMBER_CHAMBERS][32] = {{0.}};
225float tofWidths[NUMBER_CHAMBERS][32] = {{0.}};
226double xhi[1000], yhi[1000], zhi[1000];
227double lrd[1000];
228double xhic[1000], yhic[1000], zhic[1000];
229using namespace std;
230using namespace TMath;
231
233
236TFile *fcalc = 0, *fcals = 0;
237
238// X calibration
239
240void FitChambersX();
241void FitStripsX();
261
262float idchambers[59] = {27.1, 28.1, 3.1, 1.1, 29.1, 4.1, 33.1, 30.1, 5.1, 19.3, 31.1, 6.1,
263 2.1, 32.1, 15.2, 16.2, 17.2, 18.2, 19.2, 20.2, 7.1, 115.2, 113.1, 117.1,
264 35.1, 9.1, 37.1, 11.1, 39.1, 13.1, 34.1, 8.1, 36.1, 10.1, 38.1, 12.1,
265 21.2, 23.2, 25.2, 22.2, 24.2, 26.2, 107.2, 108.2, 109.2, 110.2, 111.2, 112.2,
266 114.1, 116.2, 118.1, 14.1, 40.1, 119.2, 120.2, 121.2, 122.2, 123.2, 124.2};
267
271
272Int_t readMCTimeFile(const char* MCTimeFile = "TOF700_MC_argon_qgsm_time_run7.txt");
273
280
281char fnametof700[256];
282
283void BmnXTCalibrationTOF700(const char* TracksGemDch = TRACKFILE,
284 const char* DigitsTOF700 = "argon_tof700_digits_files_pro_full.txt")
285{
286
287 /* Load basic libraries */
288#if ROOT_VERSION_CODE < ROOT_VERSION(5, 99, 99)
289 gROOT->LoadMacro("$VMCWORKDIR/macro/run/bmnloadlibs.C");
290#endif
291 bmnloadlibs(); // load BmnRoot libraries
292
293 int RunPeriod = 7;
294 char mapping[256];
295 if (RunPeriod >= 1 && RunPeriod <= 7) {
296 sprintf(mapping, "TOF700_map_period_%d.txt", RunPeriod);
297 } else {
298 printf("Non-existing run period number %d!", RunPeriod);
299 return;
300 }
301
302#if OLD_DIGI_FILE == true
303 TClonesArray* eventHeadertof700 = NULL;
304#else
305 BmnEventHeader* eventHeadertof700 = NULL;
306#endif
307 TClonesArray *tof700Digits = NULL, *eventHeader = NULL;
308 TClonesArray *tracks = NULL, *mtracks = NULL;
309 CbmVertex* primaryVertex = NULL;
310 TString filename;
311
312 TChain* bmnTree = new TChain("bmndata");
313 if (strstr(TracksGemDch, ".root")) {
314 bmnTree->Add(TracksGemDch);
315 } else {
316 ifstream fin(TracksGemDch);
317 if (fin.is_open()) {
318 for (int idx = 0; idx < 1000; idx++) {
319 if (fin.eof())
320 break;
321 fin >> filename;
322 if (strlen(filename.Data()) == 0)
323 break;
324 if ((filename.Data())[0] == '#')
325 continue;
326 cout << " GEM+DCH tracks file #" << idx + 1 << " " << filename.Data() << endl;
327 bmnTree->Add(filename);
328 }
329 fin.close();
330 } else {
331 printf("Non-existing run list file: %s!", TracksGemDch);
332 return;
333 }
334 }
335 bmnTree->SetBranchAddress("EventHeader", &eventHeader);
336 bmnTree->SetBranchAddress("GemDchTracks", &mtracks);
337 bmnTree->SetBranchAddress("PrimaryVertex", &primaryVertex);
338
339 TChain* bmnTreetof700 = NULL;
340 if (OLD_DIGI_FILE)
341 bmnTreetof700 = new TChain("cbmsim");
342 else
343 bmnTreetof700 = new TChain("bmndata");
344
345 if (strstr(DigitsTOF700, ".root")) {
346 bmnTreetof700->Add(DigitsTOF700); //
347 strcpy(fnametof700, DigitsTOF700);
348 } else {
349 ifstream fin(DigitsTOF700);
350 if (fin.is_open()) {
351 for (int idx = 0; idx < 1000; idx++) {
352 if (fin.eof())
353 break;
354 fin >> filename;
355 if (strlen(filename.Data()) == 0)
356 break;
357 if ((filename.Data())[0] == '#')
358 continue;
359 cout << " TOF digits file #" << idx + 1 << " " << filename.Data() << endl;
360 bmnTreetof700->Add(filename);
361 strcpy(fnametof700, filename.Data());
362 }
363 fin.close();
364 } else {
365 printf("Non-existing run list file: %s!", DigitsTOF700);
366 return;
367 }
368 }
369 if (OLD_DIGI_FILE)
370 bmnTreetof700->SetBranchAddress("EventHeader", &eventHeadertof700);
371 else
372 bmnTreetof700->SetBranchAddress("BmnEventHeader.", &eventHeadertof700);
373 bmnTreetof700->SetBranchAddress("TOF700", &tof700Digits);
374
375 char fnametof700raw[256];
376 strcpy(fnametof700raw, fnametof700);
377 strcpy(strstr(fnametof700raw, "digi.root"), "raw.root");
378 if (XYPANIN)
379 TOF2 = new BmnTof2Raw2DigitNew(mapping, fnametof700raw, 0, 0, "TOF700_geometry_run7_panin.txt");
380 else
381 TOF2 = new BmnTof2Raw2DigitNew(mapping, fnametof700raw, 0, 0, "TOF700_geometry_run7.txt");
382
383 for (int c = 0; c < NUMBER_CHAMBERS; c++) {
384 halfwidthy[c] = 0.5f;
385 if (idchambers[c] < 100.f) {
386 halfwidthx[c] = 8.0f;
387 } else {
388 halfwidthx[c] = 28.0f;
389 }
390 wmi[c] = WMIN;
391 wma[c] = WMAX;
392 }
393
394 char name[128], title[128];
395
396 gStyle->SetOptFit(111);
397 gStyle->SetOptStat(111111);
398
399 if (XYPETNEW && XYCALIBRATION)
400 if (!ReadXYCalibration())
401 return;
403
404 if (CALIBRATION == 0) {
405 char fname_calib_root[128];
406#if CALRUNNAME == 0
407 TString dir = getenv("VMCWORKDIR");
408#ifdef CORRECTIONFILE
409 TString path = dir + "/input/" + CORRECTIONFILE;
410#else
411 TString path = dir + "/input/" + CALIBFILE;
412#endif
413 strcpy(fname_calib_root, path.Data());
414#else
415 char* delim = 0;
416 strcpy(fname_calib_root, gSystem->BaseName(fnametof700));
417 if ((delim = strrchr(fname_calib_root, (int)'.')))
418 *delim = '\0';
419 strcat(fname_calib_root, "_calibration.root");
420#endif
421 TFile* fc = new TFile(fname_calib_root, "READ", "Proton mass based calibration of BmnTOF700");
422 if (CVERS == 0) {
423 itcalibr = (TProfile2D*)fc->Get("tcalibr");
424 itcalibrc = (TProfile*)fc->Get("tcalibrc");
425 } else {
426 itcalibr = (TProfile2D*)fc->Get("tcalibr;1");
427 itcalibrc = (TProfile*)fc->Get("tcalibrc;1");
428 }
429 printf("\n ******************* Time offsets for whole chamber **********************\n");
430 for (int c = 0; c < NUMBER_CHAMBERS; c++) {
431 tofcalc[c] = itcalibrc->GetBinContent(c + 1);
432 printf("%d %f\n", c, tofcalc[c]);
433 }
434 if (STRIP_CORRECTIONS) {
436 printf("\n ******************* Time offsets for one strip **************************\n");
437 for (int c = 0; c < NUMBER_CHAMBERS; c++) {
439 printf("\n Chamber %d %.1f\n", c, idchambers[c]);
440 int smax = 32;
441 if (idchambers[c] >= 100.f)
442 smax = 16;
443 for (int s = 0; s < smax; s++) {
444 tofcals[c][s] = itcalibr->GetBinContent(c + 1, s + 1);
446 printf(" strip %d %f\n", s, tofcals[c][s]);
447 }
449 printf("\n *************************************************************************\n");
450 }
451 }
452 }
453
454 TFile* f = NULL;
455 if (strlen(fnametof700)) {
456 char fname_root[128], *delim = 0;
457 strcpy(fname_root, gSystem->BaseName(fnametof700));
458 if ((delim = strrchr(fname_root, (int)'.')))
459 *delim = '\0';
460 strcat(fname_root, "_calibration_results.root");
461 f = new TFile(fname_root, "RECREATE", "Results of BmnTOF700");
462 }
463
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);
482
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);
485
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);
488
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);
495 hpbeta->SetOption("COLZ");
496 TH2F* hpbetac = new TH2F("hpbetac", "Beta vs momentum, chamber corrections", 200, 0, 10, 220, 0, 1.1f);
497 hpbetac->SetOption("COLZ");
498 TH2F* hpbetas = new TH2F("hpbetas", "Beta vs momentum, strip corrections", 200, 0, 10, 220, 0, 1.1f);
499 hpbetas->SetOption("COLZ");
500 TH2F* hpbetacm = new TH2F("hpbetacm", "Beta vs momentum, Z<0, chamber corrections", 200, 0, 10, 220, 0, 1.1f);
501 hpbetacm->SetOption("COLZ");
502 TH2F* hpbetasm = new TH2F("hpbetasm", "Beta vs momentum, Z<0, strip corrections", 200, 0, 10, 220, 0, 1.1f);
503 hpbetasm->SetOption("COLZ");
504
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);
514
515 TH1F* hdtps = new TH1F("hdtps", "Time resolution, protons, strip corrections", 200, -1., +1.);
516 TH2F* hdtpsvsp =
517 new TH2F("hdtpsvsp", "Time resolution vs momentum, protons, strip corrections", 240, 0., 6., 200, -1., +1.);
518 hdtpsvsp->SetOption("COLZ");
519 TH1F* hdtpc = new TH1F("hdtpc", "Time resolution, protons, chamber corrections", 200, -1., +1.);
520 TH2F* hdtpcvsp =
521 new TH2F("hdtpcvsp", "Time resolution vs momentum, protons, chamber corrections", 240, 0., 6., 200, -1., +1.);
522 hdtpcvsp->SetOption("COLZ");
523 TH2F* hdtpcvspwlim = new TH2F("hdtpcvspwlim", "Time resolution vs momentum, protons, chamber corrections, w>3000",
524 240, 0., 6., 200, -1., +1.);
525 hdtpcvspwlim->SetOption("COLZ");
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.);
533
534 TH2F* hmassvsp = new TH2F("hmassvsp", "Mass vs momentum", 240, 0., 6., 200, -0.2, 4.8);
535 hmassvsp->SetOption("COLZ");
536 TH2F* hmasssvsp = new TH2F("hmasssvsp", "Mass vs momentum, strip correction", 240, 0., 6., 200, -0.2, 4.8);
537 hmasssvsp->SetOption("COLZ");
538 TH2F* hmasscvsp = new TH2F("hmasscvsp", "Mass vs momentum, chamber corrections", 240, 0., 6., 200, -0.2, 4.8);
539 hmasscvsp->SetOption("COLZ");
540 TH2F* hmasssmvsp = new TH2F("hmasssmvsp", "Mass vs momentum, Z<0, strip correction", 240, 0., 6., 200, -0.2, 4.8);
541 hmasssmvsp->SetOption("COLZ");
542 TH2F* hmasscmvsp =
543 new TH2F("hmasscmvsp", "Mass vs momentum, Z<0, chamber corrections", 240, 0., 6., 200, -0.2, 4.8);
544 hmasscmvsp->SetOption("COLZ");
545
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);
551
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);
558 hdxyeff->SetOption("COLZ");
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);
564 hxyeff->SetOption("COLZ");
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);
579
580 TProfile2D* tcalibrs = new TProfile2D("tcalibr", "Time calibration based on proton mass, strips", NUMBER_CHAMBERS,
581 0, NUMBER_CHAMBERS, 32, 0, 32, -1., +1., "e");
582 TProfile* tcalibrc = new TProfile("tcalibrc", "Time calibration based on proton mass, chambers", NUMBER_CHAMBERS, 0,
583 NUMBER_CHAMBERS, -1., +1., "e");
584
585 TProfile* tpeak = new TProfile("tpeak", "Peak time vs chamber", NUMBER_CHAMBERS, 0, NUMBER_CHAMBERS, 0., +30., "e");
586 TProfile* bpeak =
587 new TProfile("bpeak", "Peak velosity vs chamber", NUMBER_CHAMBERS, 0, NUMBER_CHAMBERS, 0., +1.5, "e");
588
589 char nam[64], tit[64];
590
591 // X calibration
592
593 if (XYCALIBRATION) {
594 XvsLR = new TProfile2D("xvslr", "X calibration, chambers", NUMBER_CHAMBERS, 0, NUMBER_CHAMBERS, 80, -4, 4, -40.,
595 +40., "e");
596 YvsY = new TProfile2D("yvsy", "Y calibration, chambers & strips", NUMBER_CHAMBERS, 0, NUMBER_CHAMBERS, 32, 0,
597 32, -4., +4., "e");
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");
602 }
603 for (int i = 0; i < NUMBER_CHAMBERS; i++) {
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");
610 }
611 for (int i = 0; i < NUMBER_CHAMBERS; i++) {
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.);
615 }
616
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);
630 }
631 //
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;
636 float ztarg = -2.2f;
637 float zc[NUMBER_CHAMBERS] = {0.f};
638 for (int i = 0; i < NUMBER_CHAMBERS; i++) {
639 TOF2->get_chamber_z(i, &zc[i]);
640 }
641
642 Int_t startEvent = 0;
643 Int_t nEvents = bmnTree->GetEntries();
644 Int_t nEventstof700 = bmnTreetof700->GetEntries();
645 printf("\nNumber of events in tracks chain is %d (tof700 chain %d)\n", nEvents, nEventstof700);
646
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
655 << " )" << endl;
656 }
657 BmnGemDchTrack* gemdchtrack0 = NULL;
658 do {
659 if (iEv >= nEvents)
660 break;
661 bmnTree->GetEntry(iEv);
662 if (mtracks == NULL) {
663 iEv++;
664 continue;
665 };
666 gemdchtrack0 = (BmnGemDchTrack*)(mtracks->UncheckedAt(0));
667 // gemdchtrack0 = (BmnGemDchTrack*)(mtracks->At(0));
668 // printf("First attempt, iEv = %d, iEv0 = %d\n",iEv,iEv0);
669 iEv++;
670 } while (gemdchtrack0 == NULL);
671 // printf("Point 0, iEv = %d\n",iEv);
672 if (iEv >= nEvents)
673 break;
674 // trackEvId = gemdchtrack0->GetEventId();
675 trackEvId = ((BmnEventHeader*)eventHeader)->GetEventId();
676 // printf("Point 1, iEv = %d, trackEvId = %d\n",iEv,trackEvId);
677 if (eventHeader == NULL)
678 continue;
679 // trackRunId = ((BmnEventHeader*)eventHeader->UncheckedAt(0))->GetRunId();
680 trackRunId = ((BmnEventHeader*)eventHeader)->GetRunId();
681 // printf("Point 2, iEv = %d, trackRunId = %d\n",iEv,trackRunId);
682 if (tof700RunId == trackRunId && tof700EvId > trackEvId)
683 continue;
684 if (tof700RunId > trackRunId)
685 continue;
686 // printf("Point 3, iEv = %d\n",iEv);
687 if (!(tof700EvId == trackEvId && tof700RunId == trackRunId)) {
688 do {
689 bmnTreetof700->GetEntry(iEvtof700);
690 if (eventHeadertof700 == NULL)
691 break;
692#if OLD_DIGI_FILE == true
693 tof700EvId = ((BmnEventHeader*)eventHeadertof700->UncheckedAt(0))->GetEventId();
694 tof700RunId = ((BmnEventHeader*)eventHeadertof700->UncheckedAt(0))->GetRunId();
695#else
696 tof700EvId = eventHeadertof700->GetEventId();
697 tof700RunId = eventHeadertof700->GetRunId();
698#endif
699 // cout << "Tracks Event: " << iEv << ", TOF700 Event: " << iEvtof700 << endl;
700 // cout << "Tracks EventId: " << trackEvId << ", TOF700 EventId: " << tof700EvId << endl;
701 // cout << "Tracks RunId: " << trackRunId << ", TOF700 RunId: " << tof700RunId << endl;
702 iEvtof700++;
703 if (iEvtof700 >= nEventstof700)
704 break;
705 if (tof700RunId > trackRunId)
706 break;
707 if (tof700RunId == trackRunId && tof700EvId > trackEvId)
708 break;
709 } while (!(tof700EvId == trackEvId && tof700RunId == trackRunId));
710 }
711 if (eventHeadertof700 == NULL)
712 continue;
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)
719 break;
720 if (tof700RunId > trackRunId)
721 continue;
722 if (tof700RunId == trackRunId && tof700EvId > trackEvId)
723 continue;
724 break;
725 // continue;
726 }
727 float wmax[NUMBER_CHAMBERS] = {0.};
728 float tmax[NUMBER_CHAMBERS] = {-10000000.};
729 int smax[NUMBER_CHAMBERS] = {-1};
730 int smax1[NUMBER_CHAMBERS] = {-1};
731 int istr[NUMBER_CHAMBERS] = {-1};
732
733 for (int i = 0; i < NUMBER_CHAMBERS; i++) {
734 wmax[i] = 0.;
735 tmax[i] = -1000000.;
736 smax[i] = -1;
737 smax1[i] = -1;
738 nhit[i] = 0;
739 for (int j = 0; j < 32; j++)
740 nhits[i][j] = 0;
741 for (int j = 0; j < 32; j++)
742 tofWidths[i][j] = 0.;
743 for (int j = 0; j < 32; j++)
744 tof[i][j] = 0.;
745 }
746 nhi = 0;
747
748 int ntof = tof700Digits->GetEntriesFast();
749 hntof->Fill(ntof);
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};
755 Int_t numhit[NUMBER_CHAMBERS][32] = {{0}};
756 for (Int_t iDig = 0; iDig < ntof; ++iDig) {
757 BmnTof2Digit* digit = (BmnTof2Digit*)tof700Digits->At(iDig);
758 if (digit == NULL)
759 continue;
760 Short_t plane = digit->GetPlane();
761 Short_t strip = digit->GetStrip();
762 Float_t time = digit->GetTime();
763 Float_t width = digit->GetAmplitude();
764 Float_t lrdiff = digit->GetDiff();
765 // if (iEv % 10 == 0) cout << "plane = " << plane << " strip = " << strip << " time = " << time <<
766 // " width = " << width << endl; if (iEv % 10 == 0) cout << "wmi = " << wmi[plane] << " wma = "
767 // << wma[plane] << endl;
768 if (plane >= NUMBER_CHAMBERS)
769 continue;
770 if (XYPANIN && (TOF2->get_hit_xp(plane, strip, lrdiff) == 0.))
771 continue;
772 // if (lrdiff < -0.5 || lrdiff > 0.5) continue;
773 smax1[plane] = strip;
774 if (width > wmax[plane]) {
775 wmax[plane] = width;
776 tmax[plane] = time;
777 smax[plane] = strip;
778 }
779 if (IN_WIDTH_LIMITS)
780 if (width < wmi[plane] || width > wma[plane])
781 continue;
782 htof->Fill(time);
783 hchamb[nhi] = plane;
784 hstrip[nhi] = strip;
785 nhit[plane]++;
786 nhits[plane][strip]++;
787 tof[plane][strip] = time;
788 tofWidths[plane][strip] = width;
789 istr[plane] = strip;
790 if (XYPANIN)
791 TOF2->get_hit_xyzp(plane, strip, lrdiff, &x, &y, &z);
792 else if (XYPETNEW) {
793 if (XYCALIBRATION) {
794 if (fabs(slopexg[plane][strip]) >= 6.0f) {
795 TOF2->get_strip_xyz(plane, strip, &x0, &y0, &z0);
796 x = slopexg[plane][strip] * lrdiff + interxg[plane][strip];
797 y = y0 + shifty[plane][strip];
798 z = z0;
799 } else {
800 TOF2->get_hit_xyz(plane, strip, +lrdiff, &x, &y, &z);
801 }
802 } else {
803 TOF2->get_hit_xyzng(plane, strip, lrdiff, &x, &y, &z);
804 if (z == 0.)
805 continue;
806 }
807 } else {
808 if (!OLD_DIGI_FILE)
809 TOF2->get_hit_xyz(plane, strip, +lrdiff, &x, &y, &z);
810 else
811 TOF2->get_hit_xyz(plane, strip, -lrdiff, &x, &y, &z);
812 }
813 xhi[nhi] = x;
814 yhi[nhi] = y;
815 zhi[nhi] = z;
816 lrd[nhi] = lrdiff;
817 hxytof->Fill(x, y);
818 TOF2->get_strip_xyz(plane, strip, &x, &y, &z);
819 xhic[nhi] = x;
820 yhic[nhi] = y;
821 zhic[nhi] = z;
822 hstr->Fill(strip);
823 hcha->Fill(plane);
824 numhit[plane][strip] = nhi;
825 nhi++;
826 } // tof700Digits loop
827 hnhit->Fill(nhi);
828
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.;
831 int nh = 0;
832 int ntr = mtracks->GetEntriesFast();
833 hntr->Fill(ntr);
834 Ntr += ntr;
835 int ntr0 = 0;
836 int ntr1 = 0, ntr1g = 0;
837 int iflag = 0, igem = 0, idch = 0;
838 float chi2 = 0.f;
839 BmnGemDchTrack* gemdchtrack = NULL;
840 BmnTrack* track = NULL;
841#if GEMTYPE > 2
842 BmnTrack* gtrack = NULL; // Merts GEM tracks
843#else
844 CbmStsTrack* gtrack = NULL; // Gleb GEM tracks
845#endif
846 Double_t xGem = 0.;
847 Double_t yGem = 0.;
848 Double_t txGem = 0.;
849 Double_t tyGem = 0.;
850 Double_t QpGem = 0.;
851 Double_t QpDch = 0.;
852 Int_t nGemHits = 0;
853 Int_t nSiHits = 0;
854 Double_t Xpv = 0.;
855 Double_t Ypv = 0.;
856 Double_t dxm = 0.;
857 Double_t dym = 0.;
858 Double_t dtx = 0.;
859 Double_t dty = 0.;
860 Double_t Ddx = 0.;
861 Double_t Ddy = 0.;
862 Double_t Ddtx = 0.;
863 Double_t Ddty = 0.;
864 Double_t Chi2m = 0.;
865 Double_t xgoodtr = 0.;
866 Double_t ygoodtr = 0.;
867 Double_t le = 0., p = 0., ps = 0., pmod = 0., lenr = 0.;
868 int himin = -1;
869 double dx, dy, dl;
870 double dist = 0., distmin = 1000000000.0f;
871 Float_t xc, yc, zc;
872 int ic;
873 int is;
874 double cosa = 0.;
875 float hidist = 0.;
876 Double_t tofr0 = 0.f;
877 Double_t tofr = 0.f;
878 Double_t tofp = 0.f;
879 Double_t tofpi = 0.f;
880 float massmin1 = 0.;
881 float massmax1 = 0.;
882 float massmin2 = 0.;
883 float massmax2 = 0.;
884
885 float massmaxpi = 0.;
886 float massminpi = 0.;
887 float tcorpi = 0.;
888 float tofrc = 0.;
889 float tofrs = 0.;
890 float betac = 0.;
891 float betas = 0.;
892 float masss2 = 0.;
893 float masss = 0.;
894 float massc2 = 0.;
895 float massc = 0.;
896 double timepeak = 0., betapeak = 0.;
897
898 for (Int_t iTr = 0; iTr < ntr; ++iTr) {
899 gemdchtrack = (BmnGemDchTrack*)mtracks->At(iTr);
900 if (gemdchtrack == NULL)
901 continue;
902 track = (BmnTrack*)gemdchtrack->GetDchTrack();
903 if (track == NULL)
904 continue;
905 if (track->GetUniqueID() != 100)
906 continue;
907 if (FLAG < 0 && track->GetFlag() >= 0)
908 continue;
909 if (FLAG > 0 && track->GetFlag() < 0)
910 continue;
911#if GEMTYPE > 2
912 gtrack = (BmnTrack*)gemdchtrack->GetGemTrack(); // Merts GEM tracks
913#else
914 gtrack = (CbmStsTrack*)gemdchtrack->GetGemTrack(); // Gleb GEM tracks
915#endif
916 if (gtrack == NULL)
917 continue;
918 // Selection criteria
919 QpGem = gtrack->GetParamLast()->GetQp();
920 QpDch = track->GetParamLast()->GetQp();
921 if (TMath::IsNaN(QpGem)) { /*printf("NaN of INF inv. momentum %f, momentum %f\n",ps,p);*/
922 continue;
923 }
924 if (TMath::IsNaN(QpDch)) { /*printf("NaN of INF inv. momentum %f, momentum %f\n",ps,p);*/
925 continue;
926 }
927 if (QpGem != 0.) {
928 hp0->Fill(1. / QpGem);
929 } else {
930 // hp0->Fill(0.);
931 }
932 // ntr1++;
933 xGem = gtrack->GetParamLast()->GetX();
934 yGem = gtrack->GetParamLast()->GetY();
935 txGem = gtrack->GetParamLast()->GetTx();
936 tyGem = gtrack->GetParamLast()->GetTy();
937#if GEMTYPE > 2
938 nGemHits = gtrack->GetNHits(); // Merts GEM tracks
939#else
940 // nGemHits = gtrack->GetNDF(); // Gleb GEM tracks
941 nGemHits = gemdchtrack->GetGemHits(); // Gleb GEM tracks
942 nSiHits = gemdchtrack->GetSiHits(); // Gleb GEM tracks
943#endif
944 Xpv = gemdchtrack->GetXpv();
945 Ypv = gemdchtrack->GetYpv();
946
947 Bool_t goodpv = true;
949 if (ntr < 2)
950 goodpv = false;
951 if (primaryVertex->GetX() < -2 || primaryVertex->GetX() > 2.5 || primaryVertex->GetY() < 1
952 || primaryVertex->GetY() > 4 || primaryVertex->GetZ() < -1 || primaryVertex->GetZ() > 2)
953 goodpv = false;
954 }
955 if (GEMCUTS)
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
959 || 1.0f / TMath::Abs(QpGem) > 15.0f || 1.0f / TMath::Abs(QpGem) < 0.15f)
960 {
961 if (GEMDEBUG)
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);
964 continue;
965 }
966 if (GEMDEBUG)
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);
969
970 ntr1++;
971 // fill matching parameters
972 dxm = gemdchtrack->GetDx();
973 dym = gemdchtrack->GetDy();
974 dtx = gemdchtrack->GetDtx();
975 dty = gemdchtrack->GetDty();
976 Ddx = gemdchtrack->GetDdx();
977 Ddy = gemdchtrack->GetDdy();
978 Ddtx = gemdchtrack->GetDdtx();
979 Ddty = gemdchtrack->GetDdty();
980 Chi2m = gemdchtrack->GetChi2();
981 hdx->Fill(dxm);
982 hdy->Fill(dym);
983 hdxy0->Fill(dxm, dym);
984 hdtx->Fill(dtx);
985 hdty->Fill(dty);
986 hDdx->Fill(sqrt(Ddx));
987 hDdy->Fill(sqrt(Ddy));
988 hDdtx->Fill(sqrt(Ddtx));
989 hDdty->Fill(sqrt(Ddty));
990 hpdx->Fill(dxm / sqrt(Ddx));
991 hpdy->Fill(dym / sqrt(Ddy));
992 hpdtx->Fill(dtx / sqrt(Ddtx));
993 hpdty->Fill(dty / sqrt(Ddty));
994 xyz[0] = track->GetParamLast()->GetX() + (DX0DCH) - (DXDCH);
995 xyz[1] = track->GetParamLast()->GetY() + (DY0DCH) - (DYDCH);
996 xyz[2] = track->GetParamLast()->GetZ() + (DZ0DCH) - (DZDCH);
997 tx = track->GetParamLast()->GetTx() + (DTX0DCH) - (DTXDCH);
998 ty = track->GetParamLast()->GetTy() + (DTY0DCH) - (DTYDCH);
999 xgoodtr = xyz[0] + tx * 100.;
1000 ygoodtr = xyz[1] + ty * 100.;
1001 hxytr->Fill(xgoodtr, ygoodtr);
1002 // Selection criteria - x and y tracks matching
1003 if (dxm < -DXGEMDCHMAX || dxm > +DXGEMDCHMAX)
1004 continue;
1005 if (dym < -DYGEMDCHMAX || dym > +DYGEMDCHMAX)
1006 continue;
1007 // if (dxm > -DXGEMDCHMAX && dxm < +DXGEMDCHMAX)
1008 // if (dym > -DYGEMDCHMAX && dym < +DYGEMDCHMAX) continue;
1009 hchi2m->Fill(Chi2m);
1010 // if (Chi2m > 30.f) continue;
1011 chi2 = dxm * dxm / Ddx + dym * dym / Ddy;
1012 hchi2->Fill(chi2);
1013 // if (chi2 > 30.f) continue;
1014 ntr1g++;
1015 hdxy->Fill(dxm, dym);
1016 le = gemdchtrack->GetLength() - ztarg;
1017 p = QpGem;
1018 ps = p;
1019 if (p == 0.)
1020 continue;
1021 p = 1. / p;
1022 p *= PSCALE;
1023 hptr->Fill(p); // GeV/c
1024 hltr->Fill(le); // cm
1025 pmod = TMath::Abs(p);
1026 // get xyz and cxyz here
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);
1031
1032 int ncl0 = 0, ncl[NUMBER_CHAMBERS] = {0};
1033 Float_t tcl[NUMBER_CHAMBERS][32] = {{0}};
1034 Int_t acl[NUMBER_CHAMBERS][32] = {{0}};
1035 Int_t wcl[NUMBER_CHAMBERS][32] = {{0}};
1036 if (USE_CLUSTERS) {
1037 for (int i = 0; i < NUMBER_CHAMBERS; i++) {
1038 ncl[i] = 0;
1039 int clstart = -1, clwidth = -1, cstr = -1;
1040 float samps = 0., timemin = 1000000000.;
1041 float widthmax = 0.;
1042 int nstr = 32;
1043 if (idchambers[i] > 100.f)
1044 nstr = 16;
1045 for (int j = 0; j < nstr && nhit[i] > 0; j++) {
1046 if (tofWidths[i][j] > 0.) {
1047 if (clstart < 0) {
1048 clstart = j;
1049 cstr = j;
1050 timemin = tof[i][j];
1051 widthmax = tofWidths[i][j];
1052 } else {
1053 if (MINTIME) {
1054 if (tof[i][j] < timemin) {
1055 timemin = tof[i][j];
1056 cstr = j;
1057 }
1058 } else {
1059 if (tofWidths[i][j] > widthmax) {
1060 widthmax = tofWidths[i][j];
1061 cstr = j;
1062 }
1063 }
1064 }
1065 samps += tofWidths[i][j];
1066 if (j == (nstr - 1)) {
1067 clchamb[ncl0] = i;
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;
1073 ncl0++;
1074 ncl[i]++;
1075 samps = 0.;
1076 timemin = 1000000000.;
1077 widthmax = 0.;
1078 }
1079 } else if (clstart >= 0) {
1080 clchamb[ncl0] = i;
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;
1086 ncl0++;
1087 ncl[i]++;
1088 samps = 0.;
1089 timemin = 1000000000.;
1090 widthmax = 0.;
1091 clstart = -1;
1092 }
1093 }
1094 }
1095 himin = -1;
1096 dist = 0.;
1097 distmin = 1000000000.0f;
1098 for (int icl = 0; icl < ncl0; icl++) {
1099 ic = clchamb[icl];
1100 is = clstrip[icl];
1101 int ih = numhit[ic][is];
1102 if (usedstrip[ih])
1103 continue;
1104 dz = zhi[ih] - xyz[2];
1105 xrpc = xyz[0] + dz * tx;
1106 yrpc = xyz[1] + dz * ty;
1107 if (!XYPANIN) {
1108 if ((xrpc - xhic[ih]) < -(halfwidthx[ic] + DXMAX)
1109 || (xrpc - xhic[ih]) > +(halfwidthx[ic] + DXMAX))
1110 continue;
1111 if ((yrpc - yhic[ih]) < -(halfwidthy[ic] + DYMAX)
1112 || (yrpc - yhic[ih]) > +(halfwidthy[ic] + DYMAX))
1113 continue;
1114 }
1115 dx = xrpc - xhi[ih];
1116 dy = yrpc - yhi[ih];
1117 if (XYPANIN) {
1118 if (TMath::Abs(dx) > DXMAXPAN)
1119 continue;
1120 if (TMath::Abs(dy) > DYMAXPAN)
1121 continue;
1122 dist = TMath::Sqrt(dx * dx + dy * dy);
1123 } else {
1124 dist = TMath::Sqrt(dx * dx / XFACTOR + dy * dy);
1125 }
1126 if (dist < distmin) {
1127 distmin = dist;
1128 himin = numhit[ic][is];
1129 }
1130 }
1131 } else {
1132 nh = nhi;
1133 himin = -1;
1134 dist = 0.;
1135 distmin = 1000000000.0f;
1136 for (int ih = 0; ih < nh; ih++) {
1137 if (usedstrip[ih])
1138 continue;
1139 ic = hchamb[ih];
1140 is = hstrip[ih];
1141 dz = zhi[ih] - xyz[2];
1142 xrpc = xyz[0] + dz * tx;
1143 yrpc = xyz[1] + dz * ty;
1144 if (!XYPANIN) {
1145 if ((xrpc - xhic[ih]) < -(halfwidthx[ic] + DXMAX)
1146 || (xrpc - xhic[ih]) > +(halfwidthx[ic] + DXMAX))
1147 continue;
1148 if ((yrpc - yhic[ih]) < -(halfwidthy[ic] + DYMAX)
1149 || (yrpc - yhic[ih]) > +(halfwidthy[ic] + DYMAX))
1150 continue;
1151 }
1152 dx = xrpc - xhi[ih];
1153 dy = yrpc - yhi[ih];
1154 if (XYPANIN) {
1155 if (TMath::Abs(dx) > DXMAXPAN)
1156 continue;
1157 if (TMath::Abs(dy) > DYMAXPAN)
1158 continue;
1159 dist = TMath::Sqrt(dx * dx + dy * dy);
1160 } else {
1161 dist = TMath::Sqrt(dx * dx / XFACTOR + dy * dy);
1162 }
1163 if (dist < distmin) {
1164 distmin = dist;
1165 himin = ih;
1166 }
1167 }
1168 }
1169 if (himin < 0)
1170 continue;
1171 // Selection criteria on minimal distance track-hit
1172 if (distmin > DISTMAX)
1173 continue;
1174 ntr0++;
1175 usedstrip[himin] = true;
1176 hdxytof->Fill(dxm, dym);
1177 hxygoodhit->Fill(xgoodtr, ygoodtr);
1178 ic = hchamb[himin];
1179 is = hstrip[himin];
1180 xc = xhic[himin];
1181 yc = yhic[himin];
1182 zc = zhic[himin];
1183 dz = zhi[himin] - xyz[2];
1184 xrpc = xyz[0] + dz * tx;
1185 yrpc = xyz[1] + dz * ty;
1186
1187 hxyhit->Fill(xrpc - xhi[himin], yrpc - yhi[himin]);
1188 if (idchambers[ic] < 100.f && fabs(lrd[himin]) < 1.)
1189 hxyhitlr->Fill(xrpc - xhi[himin], yrpc - yhi[himin]);
1190 if (idchambers[ic] > 100.f && fabs(lrd[himin]) < 2.)
1191 hxyhitlr->Fill(xrpc - xhi[himin], yrpc - yhi[himin]);
1192 if (idchambers[ic] < 100.f)
1193 hlrdiffs->Fill(lrd[himin]);
1194 if (idchambers[ic] > 100.f)
1195 hlrdiffb->Fill(lrd[himin]);
1196 hxdiff->Fill(xhi[himin] - xc);
1197 if (idchambers[ic] < 100.f)
1198 hxxhits->Fill(xhi[himin] - xc, xrpc - xc);
1199 if (idchambers[ic] > 100.f)
1200 hxxhitb->Fill(xhi[himin] - xc, xrpc - xc);
1201 if (idchambers[ic] < 100.f)
1202 hlrxhits->Fill(lrd[himin], xhi[himin] - xc);
1203 if (idchambers[ic] > 100.f)
1204 hlrxhitb->Fill(lrd[himin], xhi[himin] - xc);
1205
1206 if (idchambers[ic] < 100.f)
1207 hlrxtrs->Fill(lrd[himin], xrpc - xc);
1208 if (idchambers[ic] > 100.f)
1209 hlrxtrb->Fill(lrd[himin], xrpc - xc);
1210
1211 if (lrd[himin] > 0. && (xhi[himin] - xc) > 0.)
1212 hcsignp->Fill(ic);
1213 if (lrd[himin] < 0. && (xhi[himin] - xc) < 0.)
1214 hcsignp->Fill(ic);
1215 if (lrd[himin] > 0. && (xhi[himin] - xc) < 0.)
1216 hcsignm->Fill(ic);
1217 if (lrd[himin] < 0. && (xhi[himin] - xc) > 0.)
1218 hcsignm->Fill(ic);
1219
1220 // X calibration
1221 if (XYCALIBRATION) {
1222 XvsLRvsStrip[ic]->Fill(is, lrd[himin], xrpc - xc);
1223 XvsLRvsStrip1[ic]->Fill(is, lrd[himin], xrpc);
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;
1228 if (numrun < 10)
1229 XvsLRvsRun[numrun]->Fill(ic, lrd[himin], xrpc - xc);
1230 nevs++;
1231 }
1232 //
1233 cosa = sqrt(1. + tx * tx + ty * ty);
1234 dl = dz * cosa;
1235 lenr = le + dl;
1236 hltra->Fill(lenr);
1237 hidist = TMath::Sqrt(xc * xc + yc * yc + (zc - ztarg) * (zc - ztarg));
1238 // Selection criteria time-of-flight
1239 if (tof[ic][is] > TOFMAX)
1240 continue;
1241 hstrtr->Fill(is);
1242 hchatr->Fill(ic);
1243 hxytrtof->Fill(xrpc, yrpc);
1244
1245 htoftr->Fill(tof[ic][is]);
1246 //
1247 tofr = 0.f;
1248 if (CALIBRATION == 0) {
1249 tofr = tof[ic][is] + tofcalmc[ic];
1250 } else if (CALIBRATION == 1) {
1251 tofr = tof[ic][is] + lenr / cpeak;
1252 } else if (CALIBRATION == 2) {
1253 tofr = tof[ic][is] + tofcalmc[ic];
1254 } else if (CALIBRATION == 3) {
1255 tofr = tof[ic][is] + tofcalmc[ic];
1256 } else {
1257 continue;
1258 }
1259 tofr0 = tof[ic][is];
1260 tofp = 0.f;
1261 tofpi = 0.f;
1262 beta = lenr / tofr / cvel;
1263 // Selection criteria
1264 if (beta <= 0.)
1265 continue;
1266 mass2 = p * p * (1.f / beta / beta - 1.f);
1267 mass = TMath::Sqrt(mass2);
1268 hpbeta->Fill(fabs(p), beta);
1269 hmass->Fill(mass2);
1270 hmassvsp->Fill(fabs(p), mass2);
1271
1272 massmin1 = MP2 - MP2 / (DMPSCALE1 * PMAX1) * (p - 0.5);
1273 massmax1 = MP2 + MP2 / (DMPSCALE2 * PMAX1) * (p - 0.5);
1274 if (p > 0.f && mass2 > massmin1 && mass2 < massmax1 && pmod > PMIN && pmod < PMAX) {
1275 tofp = (lenr / 29.97925f) * TMath::Sqrt(MP2 + p * p) / p;
1276 tcor = tofp - tofr;
1277 tcorc = tcor - tofcalc[ic];
1278 tcors = tcor - tofcals[ic][is];
1279 tcalibrc->Fill(ic, tcorc);
1280 tcalibrs->Fill(ic, is, tcors);
1281 htofp->Fill(tofr0);
1282 massmin2 = MP2 - MP2 / (DMPSCALET1 * PMAX2) * (p - 0.5);
1283 massmax2 = MP2 + MP2 / (DMPSCALET2 * PMAX2) * (p - 0.5);
1284 if (mass2 > massmin2 && mass2 < massmax2) {
1285 hdtpc->Fill(tcorc);
1286 hdtpcvsp->Fill(p, tcorc);
1287 hdtps->Fill(tcors);
1288 hdtpsvsp->Fill(p, tcors);
1289 if (p > PRES)
1290 hdtpcplim->Fill(tcorc);
1291 if (p > PRES1)
1292 hdtpcp1lim->Fill(tcorc);
1293 if (p < 2.0f)
1294 hdtpcp2lim->Fill(tcorc);
1295 if (p >= 2.0f && p < 5.0f)
1296 hdtpcp3lim->Fill(tcorc);
1297 if (tofWidths[ic][is] > WMIN && tofWidths[ic][is] < WMAX) {
1298 hdtpcwlim->Fill(tcorc);
1299 hdtpcvspwlim->Fill(p, tcorc);
1300 if (p > PRES)
1301 hdtpcwplim->Fill(tcorc);
1302 if (p > PRES1)
1303 hdtpcwp1lim->Fill(tcorc);
1304 }
1305 }
1306 }
1307 // massmaxpi = 0.1 + MPIMAX*TMath::Abs(p-0.5)/PMAXPI/DMPISCALE; // Kapishin
1308 massmaxpi = 0.1 + MPIMAX * TMath::Abs(pmod - 0.5) / PMAXPI;
1309 if (p > 0 && massmaxpi > massmin1)
1310 massmaxpi = massmin1;
1311 // massminpi =-0.1 - MPIMAX*TMath::Abs(p-0.5)/PMAXPI/DMPISCALE; // Kapishin
1312 massminpi = -0.1 - MPIMAX * TMath::Abs(pmod - 0.5) / PMAXPI;
1313 if (mass2 < massmaxpi && mass2 > massminpi && pmod > PMIN && pmod < PMAXPI) {
1314 tofpi = (lenr / 29.97925f) * TMath::Sqrt(MPI2 + p * p) / pmod;
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);
1320 }
1321 timepeak = tofcalmc[ic] + tofcalc[ic];
1322 betapeak = lenr / timepeak / cvel;
1323 tpeak->Fill(ic, timepeak);
1324 bpeak->Fill(ic, betapeak);
1325 tofrc = tofr + tofcalc[ic];
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);
1330 masss = TMath::Sqrt(masss2);
1331 massc2 = p * p * (1.f / betac / betac - 1.f);
1332 massc = TMath::Sqrt(massc2);
1333 if (p > 0) {
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);
1340 if (p < 1.5) {
1341 hmasss15->Fill(masss2);
1342 hmassc15->Fill(massc2);
1343 }
1344 if (p < 2.0) {
1345 hmasss20->Fill(masss2);
1346 hmassc20->Fill(massc2);
1347 }
1348 } else {
1349 hpbetacm->Fill(fabs(p), betac);
1350 hmasscm->Fill(massc2);
1351 hmasscmvsp->Fill(fabs(p), massc2);
1352 hpbetasm->Fill(fabs(p), betas);
1353 hmasssm->Fill(masss2);
1354 hmasssmvsp->Fill(fabs(p), masss2);
1355 }
1356 } // tracks loop
1357 hntr1->Fill(ntr1);
1358 Ntr1 += ntr1;
1359 Ntr1g += ntr1g;
1360 hntr0->Fill(ntr0);
1361 Ntr0 += ntr0;
1362 // t_out->Fill();
1363 if (iEv % 50000 == 0) {
1364 hdxyeff->Divide(hdxytof, hdxy);
1365 hdxeff->Divide((projtmp = hdxytof->ProjectionX()), (projtmp1 = hdxy->ProjectionX()));
1366 if (projtmp)
1367 delete projtmp;
1368 if (projtmp1)
1369 delete projtmp1;
1370 hdyeff->Divide((projtmp = hdxytof->ProjectionY()), (projtmp1 = hdxy->ProjectionY()));
1371 if (projtmp)
1372 delete projtmp;
1373 if (projtmp1)
1374 delete projtmp1;
1375 hxyeff->Divide(hxygoodhit, hxygoodtr);
1376 hxeff->Divide((projtmp = hxygoodhit->ProjectionX()), (projtmp1 = hxygoodtr->ProjectionX()));
1377 if (projtmp)
1378 delete projtmp;
1379 if (projtmp1)
1380 delete projtmp1;
1381 hyeff->Divide((projtmp = hxygoodhit->ProjectionY()), (projtmp1 = hxygoodtr->ProjectionY()));
1382 if (projtmp)
1383 delete projtmp;
1384 if (projtmp1)
1385 delete projtmp1;
1386
1387 if (FLAG < 0) {
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);
1399 } else {
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);
1407 }
1408
1409 if (CALIBRATION != 0 && XYCALIBRATION) {
1410 FitChambersX();
1411 FitStripsX();
1412 }
1413
1414 if (f) {
1415 f->Write(NULL, TObject::kOverwrite);
1416 }
1417
1418 if (WRITE_CALIBRATION) {
1419 char fname_calibr_root[128], *delim = 0;
1420 strcpy(fname_calibr_root, gSystem->BaseName(fnametof700));
1421 if ((delim = strrchr(fname_calibr_root, (int)'.')))
1422 *delim = '\0';
1423 strcat(fname_calibr_root, "_calibration.root");
1424 TFile* fc = new TFile(fname_calibr_root, "RECREATE", "Proton mass based calibration of BmnTOF700");
1425 tcalibrs->Write();
1426 tcalibrc->Write();
1427 fc->Close();
1428 }
1429 }
1430 } // event loop
1431
1432 hdxyeff->Divide(hdxytof, hdxy);
1433 hdxeff->Divide((projtmp = hdxytof->ProjectionX()), (projtmp1 = hdxy->ProjectionX()));
1434 if (projtmp)
1435 delete projtmp;
1436 if (projtmp1)
1437 delete projtmp1;
1438 hdyeff->Divide((projtmp = hdxytof->ProjectionY()), (projtmp1 = hdxy->ProjectionY()));
1439 if (projtmp)
1440 delete projtmp;
1441 if (projtmp1)
1442 delete projtmp1;
1443 hxyeff->Divide(hxygoodhit, hxygoodtr);
1444 hxeff->Divide((projtmp = hxygoodhit->ProjectionX()), (projtmp1 = hxygoodtr->ProjectionX()));
1445 if (projtmp)
1446 delete projtmp;
1447 if (projtmp1)
1448 delete projtmp1;
1449 hyeff->Divide((projtmp = hxygoodhit->ProjectionY()), (projtmp1 = hxygoodtr->ProjectionY()));
1450 if (projtmp)
1451 delete projtmp;
1452 if (projtmp1)
1453 delete projtmp1;
1454
1455 if (FLAG < 0) {
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);
1467 } else {
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);
1475 }
1476
1477 if (CALIBRATION != 0 && XYCALIBRATION) {
1478 FitChambersX();
1479 FitStripsX();
1480 }
1481
1482 if (f) {
1483 f->Write(NULL, TObject::kOverwrite);
1484 }
1485
1486 if (WRITE_CALIBRATION) {
1487 char fname_calibr_root[128], *delim = 0;
1488 strcpy(fname_calibr_root, gSystem->BaseName(fnametof700));
1489 if ((delim = strrchr(fname_calibr_root, (int)'.')))
1490 *delim = '\0';
1491 strcat(fname_calibr_root, "_calibration.root");
1492 TFile* fc = new TFile(fname_calibr_root, "RECREATE", "Proton mass based calibration of BmnTOF700");
1493 tcalibrs->Write();
1494 tcalibrc->Write();
1495 fc->Close();
1496 }
1497
1498 return;
1499}
1500
1502{
1503 // example of macro called when a mouse event occurs in a pad.
1504 // Example:
1505 // Root > TFile f("hsimple.root");
1506 // Root > hpxpy.Draw();
1507 // Root > c1.AddExec("exsel","select_hist()");
1508 // When moving the mouse in the canvas, a second canvas shows the
1509 // projection along X of the bin corresponding to the Y position
1510 // of the mouse. The resulting histogram is fitted with a gaussian.
1511 // A "dynamic" line shows the current bin position in Y.
1512 // This more elaborated example can be used as a starting point
1513 // to develop more powerful interactive applications exploiting CINT
1514 // as a development engine.
1515 // Author: Rene Brun
1516
1517 int event = gPad->GetEvent();
1518 if (event != 11)
1519 return;
1520
1521 TObject* select = gPad->GetSelected();
1522 if (!select)
1523 return;
1524 if (!(select->InheritsFrom("TH1")))
1525 return;
1526
1527 // create or set the new canvas c2
1528 TCanvas* csingle = 0;
1529 if ((csingle = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("csingle")))
1530 ;
1531 else
1532 csingle = new TCanvas("csingle");
1533 csingle->cd();
1534
1535 // draw slice corresponding to mouse position
1536 if (!(select->InheritsFrom("TH1F"))) {
1537 TH1F* h = (TH1F*)select;
1538 h->Draw();
1539 } else if (!(select->InheritsFrom("TH2F"))) {
1540 TH2F* h = (TH2F*)select;
1541 h->Draw();
1542 } else if (!(select->InheritsFrom("TProfile"))) {
1543 TProfile* h = (TProfile*)select;
1544 h->Draw();
1545 } else if (!(select->InheritsFrom("TH1D"))) {
1546 TH1D* h = (TH1D*)select;
1547 h->Draw();
1548 } else if (!(select->InheritsFrom("TH2D"))) {
1549 TH2D* h = (TH2D*)select;
1550 h->Draw();
1551 } else if (!(select->InheritsFrom("TProfile2D"))) {
1552 TProfile2D* h = (TProfile2D*)select;
1553 h->Draw();
1554 } else
1555 return;
1556 csingle->Update();
1557}
1558
1559int readMCTimeFile(const char* MCTimeFile)
1560{
1561 // cout << "readMCTimeFile: " << MCTimeFile << endl;
1562 float idchambers[59] = {27.1, 28.1, 3.1, 1.1, 29.1, 4.1, 33.1, 30.1, 5.1, 19.3, 31.1, 6.1,
1563 2.1, 32.1, 15.2, 16.2, 17.2, 18.2, 19.2, 20.2, 7.1, 115.2, 113.1, 117.1,
1564 35.1, 9.1, 37.1, 11.1, 39.1, 13.1, 34.1, 8.1, 36.1, 10.1, 38.1, 12.1,
1565 21.2, 23.2, 25.2, 22.2, 24.2, 26.2, 107.2, 108.2, 109.2, 110.2, 111.2, 112.2,
1566 114.1, 116.2, 118.1, 14.1, 40.1, 119.2, 120.2, 121.2, 122.2, 123.2, 124.2};
1567 bool notused[59] = {true};
1568 int order[59] = {-1};
1569 int c = 0, cmin = -1, c0 = 0;
1570 float idmin = 200.f;
1571 for (c0 = 0; c0 < 59; c0++) {
1572 notused[c0] = true;
1573 order[c0] = -1;
1574 }
1575 for (c0 = 0; c0 < 59; c0++) {
1576 cmin = -1;
1577 idmin = 200.f;
1578 for (c = 0; c < 59; c++) {
1579 if (notused[c] && (idchambers[c] < idmin)) {
1580 idmin = idchambers[c];
1581 cmin = c;
1582 }
1583 }
1584 // printf("c0 %d cmin %d notused %d\n",c0,cmin,(int)notused[cmin]);
1585 if (cmin >= 0) {
1586 notused[cmin] = false;
1587 order[c0] = cmin;
1588 }
1589 }
1590 char fname[128];
1591 FILE* ft = 0;
1592 float time = 0.f, timesigma = 0.f;
1593 if (MCTimeFile == NULL) {
1594 printf("TOF700 MC time-of-flight file name not defined!\n");
1595 return 0;
1596 }
1597 if (strlen(MCTimeFile) == 0) {
1598 printf("TOF700 MC time-of-flight file name not defined!\n");
1599 return 0;
1600 }
1601 TString dir = getenv("VMCWORKDIR");
1602 sprintf(fname, "%s/geometry/%s", dir.Data(), MCTimeFile);
1603 ft = fopen(fname, "r");
1604 if (ft == NULL) {
1605 printf("TOF700 MC time-of-flight file %s open error!\n", fname);
1606 return 0;
1607 }
1608 int cexp = 0, ic = -1;
1609 while (fscanf(ft, "%d %f %f\n", &ic, &time, &timesigma) == 3) {
1610 if (ic > 0 && ic <= 59) {
1611 cexp = order[ic - 1];
1612 tofcalmc[cexp] = time;
1613 if (1)
1614 printf("Chamber %.1f (MC %d, EXP %d) average time-of-flight %f with sigma %f\n", idchambers[cexp], ic,
1615 cexp, time, timesigma);
1616 }
1617 }
1618 fclose(ft);
1619 return 1;
1620}
1621
1623{
1624 FILE *fdeb = 0, *fcalx = 0;
1625 TProfile* proj[NUMBER_CHAMBERS][32] = {{0}};
1626 TProfile* proj1[NUMBER_CHAMBERS][32] = {{0}};
1627 TF1 *li = 0, *li1 = 0;
1628 Int_t ncon = 0;
1629 Char_t namp[128];
1630 Char_t namf[128];
1631 Char_t filn[128];
1632 if (WRITE_CALIBRATION_X) {
1633 char fname_xcalibr_root[128], *delim = 0;
1634 strcpy(fname_xcalibr_root, gSystem->BaseName(fnametof700));
1635 if ((delim = strrchr(fname_xcalibr_root, (int)'.')))
1636 *delim = '\0';
1638 strcat(fname_xcalibr_root, "_x_calibration_new.txt");
1639 else
1640 strcat(fname_xcalibr_root, "_x_calibration.txt");
1641 fcalx = fopen(fname_xcalibr_root, "w");
1642 }
1643 sprintf(filn, "Xcalibration_strips.txt");
1645 sprintf(filn, "Xcalibration_strips_new.txt");
1646 fdeb = fopen(filn, "w");
1648 fcals = new TFile("FitPicturesStrips_new.root", "recreate");
1649 else
1650 fcals = new TFile("FitPicturesStrips.root", "recreate");
1651
1652 Double_t inter[NUMBER_CHAMBERS][32], slope[NUMBER_CHAMBERS][32];
1653 Double_t inter1[NUMBER_CHAMBERS][32], slope1[NUMBER_CHAMBERS][32];
1654 for (int ip = 0; ip < NUMBER_CHAMBERS; ip++) {
1655 int nstr = 32;
1656 Double_t lrmin = -1., lrmax = +1.;
1657 if (idchambers[ip] > 100.f) {
1658 nstr = 16;
1659 lrmin = -2.;
1660 lrmax = +2.;
1661 }
1662 for (int is = 0; is < nstr; is++) {
1663 // Local X
1664 sprintf(namp, "Chamber_%d_strip_%d_calibration", ip, is);
1665 proj[ip][is] = XvsLRvsStrip[ip]->ProfileY(namp, is + 1, is + 1);
1666 ncon = proj[ip][is]->GetEntries();
1667 if (ncon > MINSTAT) {
1668 sprintf(namf, "Chamber_%d_strip_%d_line", ip + 1, is + 1);
1669 li = new TF1(namf, "pol1", lrmin, lrmax);
1670 proj[ip][is]->Fit(namf, "QR");
1671 if (!(proj[ip][is]->GetFunction(namf))) {
1672 inter[ip][is] = 0;
1673 slope[ip][is] = 0;
1674 if (ip == 18 && fdeb) {
1675 fprintf(fdeb, "Err: Chamber %d strip %d statistic %d\n", ip, is, ncon);
1676 }
1677 } else {
1678 inter[ip][is] = proj[ip][is]->GetFunction(namf)->GetParameter(0);
1679 slope[ip][is] = proj[ip][is]->GetFunction(namf)->GetParameter(1);
1680 proj[ip][is]->Write();
1681 hfitxs0->Fill(inter[ip][is]);
1682 hfitxs1->Fill(slope[ip][is]);
1683 if (slope[ip][is] > 0.) {
1684 hfitxs0a->Fill(-inter[ip][is] / slope[ip][is]);
1685 hfitxs1a->Fill(slope[ip][is]);
1686 } else {
1687 hfitxs0a->Fill(+inter[ip][is] / slope[ip][is]);
1688 hfitxs1a->Fill(-slope[ip][is]);
1689 }
1690 if (ip == 18 && fdeb) {
1691 fprintf(fdeb, "Fit: Chamber %d strip %d statistic %d x0 %f x1 %f\n", ip, is, ncon,
1692 inter[ip][is], slope[ip][is]);
1693 }
1694 }
1695 } else {
1696 inter[ip][is] = 0;
1697 slope[ip][is] = 0;
1698 if (ip == 18 && fdeb) {
1699 fprintf(fdeb, "Non: Chamber %d strip %d statistic %d\n", ip, is, ncon);
1700 }
1701 }
1702 fprintf(fcalx, " l %3d %3d %7.2f %7.2f\n", ip, is, inter[ip][is], slope[ip][is]);
1703 // Global X
1704 sprintf(namp, "Chamber_%d_strip_%d_global_calibration", ip, is);
1705 proj1[ip][is] = XvsLRvsStrip1[ip]->ProfileY(namp, is + 1, is + 1);
1706 ncon = proj1[ip][is]->GetEntries();
1707 if (ncon > MINSTAT) {
1708 sprintf(namf, "Chamber_%d_strip_%d_global_line", ip + 1, is + 1);
1709 li1 = new TF1(namf, "pol1", lrmin, lrmax);
1710 proj1[ip][is]->Fit(namf, "QR");
1711 if (!(proj1[ip][is]->GetFunction(namf))) {
1712 inter1[ip][is] = 0;
1713 slope1[ip][is] = 0;
1714 if (ip == 18 && fdeb) {
1715 fprintf(fdeb, "Err1: Chamber %d strip %d statistic %d\n", ip, is, ncon);
1716 }
1717 } else {
1718 inter1[ip][is] = proj1[ip][is]->GetFunction(namf)->GetParameter(0);
1719 slope1[ip][is] = proj1[ip][is]->GetFunction(namf)->GetParameter(1);
1720 proj1[ip][is]->Write();
1721 hfitx1s0->Fill(inter1[ip][is]);
1722 hfitx1s1->Fill(slope1[ip][is]);
1723 if (slope1[ip][is] >= 0.) {
1724 hfitx1s1a->Fill(slope1[ip][is]);
1725 } else {
1726 hfitx1s1a->Fill(-slope1[ip][is]);
1727 }
1728 if (ip == 18 && fdeb) {
1729 fprintf(fdeb, "Fit1: Chamber %d strip %d statistic %d x0 %f x1 %f\n", ip, is, ncon,
1730 inter1[ip][is], slope1[ip][is]);
1731 }
1732 }
1733 } else {
1734 inter1[ip][is] = 0;
1735 slope1[ip][is] = 0;
1736 if (ip == 18 && fdeb) {
1737 fprintf(fdeb, "Non1: Chamber %d strip %d statistic %d\n", ip, is, ncon);
1738 }
1739 }
1740 fprintf(fcalx, " g %3d %3d %7.2f %7.2f\n", ip, is, inter1[ip][is], slope1[ip][is]);
1741 } // loop on strips
1742 } // loop on chambers
1743 fclose(fdeb);
1744 fcals->Close();
1745 if (fcalx)
1746 fclose(fcalx);
1747}
1748
1750{
1751 FILE *fdeb = 0, *fcaly = 0, *fcalyc = 0, *fcalxc = 0;
1752 TProfile *proj[NUMBER_CHAMBERS] = {0}, *projr = 0;
1753 TProfile* proj1[NUMBER_CHAMBERS] = {0};
1754 TF1 *li = 0, *lir = 0;
1755 Int_t ncon = 0;
1756 Char_t namp[128];
1757 Char_t namf[128];
1758 Char_t filn[128];
1759 char fname_ycalibr_root[128], *delim = 0;
1760 if (WRITE_CALIBRATION_Y) {
1761 strcpy(fname_ycalibr_root, gSystem->BaseName(fnametof700));
1762 if ((delim = strrchr(fname_ycalibr_root, (int)'.')))
1763 *delim = '\0';
1765 strcat(fname_ycalibr_root, "_y_calibration_new.txt");
1766 else
1767 strcat(fname_ycalibr_root, "_y_calibration.txt");
1768 fcaly = fopen(fname_ycalibr_root, "w");
1769 }
1771 strcpy(fname_ycalibr_root, gSystem->BaseName(fnametof700));
1772 if ((delim = strrchr(fname_ycalibr_root, (int)'.')))
1773 *delim = '\0';
1775 strcat(fname_ycalibr_root, "_y_calibration_chamber_new.txt");
1776 else
1777 strcat(fname_ycalibr_root, "_y_calibration_chamber.txt");
1778 fcalyc = fopen(fname_ycalibr_root, "w");
1779 }
1781 strcpy(fname_ycalibr_root, gSystem->BaseName(fnametof700));
1782 if ((delim = strrchr(fname_ycalibr_root, (int)'.')))
1783 *delim = '\0';
1785 strcat(fname_ycalibr_root, "_x_calibration_chamber_new.txt");
1786 else
1787 strcat(fname_ycalibr_root, "_x_calibration_chamber.txt");
1788 fcalxc = fopen(fname_ycalibr_root, "w");
1789 }
1790
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");
1797 else
1798 fcalc = new TFile("FitPicturesChambers.root", "recreate");
1799
1802 for (int ip = 0; ip < NUMBER_CHAMBERS; ip++) {
1803 Int_t nstr = 32;
1804 Double_t lrmin = -1., lrmax = +1.;
1805 if (idchambers[ip] > 100.f) {
1806 nstr = 16;
1807 lrmin = -2.;
1808 lrmax = +2.;
1809 }
1810 sprintf(namp, "Chamber_%d_calibration", ip);
1811 proj[ip] = XvsLR->ProfileY(namp, ip + 1, ip + 1);
1812 ncon = proj[ip]->GetEntries();
1813 if (ncon > MINSTAT) {
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))) {
1818 inter[ip] = 0;
1819 slope[ip] = 0;
1820 if (fdeb) {
1821 fprintf(fdeb, "Err: Chamber %d statistic %d\n", ip, ncon);
1822 }
1823 } else {
1824 inter[ip] = proj[ip]->GetFunction(namf)->GetParameter(0);
1825 slope[ip] = proj[ip]->GetFunction(namf)->GetParameter(1);
1826 proj[ip]->Write();
1827 hfitx0->Fill(inter[ip]);
1828 hfitx1->Fill(slope[ip]);
1829 if (fdeb) {
1830 fprintf(fdeb, "Fit: Chamber %d statistic %d x0 %f x1 %f\n", ip, ncon, inter[ip], slope[ip]);
1831 }
1832 }
1833 } else {
1834 inter[ip] = 0;
1835 slope[ip] = 0;
1836 if (fdeb) {
1837 fprintf(fdeb, "Non: Chamber %d statistic %d\n", ip, ncon);
1838 }
1839 }
1840 fprintf(fcalxc, " %3d %7.2f %7.2f\n", ip, inter[ip], slope[ip]);
1841 // X vs Run
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();
1846 if (ncon > MINSTAT) {
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);
1855 // projr->Write();
1856 hfitx0run->SetBinContent(ir + 1, inters);
1857 hfitx1run->SetBinContent(ir + 1, slopes);
1858 hfitx0run->SetBinError(ir + 1, einters);
1859 hfitx1run->SetBinError(ir + 1, eslopes);
1860 }
1861 }
1862 delete projr;
1863 }
1864 // Y calibration
1865 sprintf(namp, "Chamber_%d_Y_calibration", ip);
1866 proj1[ip] = YvsY->ProfileY(namp, ip + 1, ip + 1);
1867 ncon = proj1[ip]->GetEntries();
1868 if (ncon > MINSTAT) {
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))) {
1873 shiftyc[ip] = 0;
1874 for (int is = 0; is < nstr; is++) {
1875 shift[ip][is] = 0.;
1876 fprintf(fcaly, " %3d %3d %7.2f\n", ip, is, shift[ip][is]);
1877 }
1878 if (fdeb) {
1879 fprintf(fdeb, "Err: Chamber %d statistic %d\n", ip, ncon);
1880 }
1881 } else {
1882 shiftyc[ip] = proj1[ip]->GetFunction(namf)->GetParameter(0);
1883 proj1[ip]->Write();
1884 hfityc->Fill(shiftyc[ip]);
1885 if (fdeb) {
1886 fprintf(fdeb, "Fit: Chamber %d statistic %d shiftY %f\n", ip, ncon, shiftyc[ip]);
1887 }
1888 for (int is = 0; is < nstr; is++) {
1889 shift[ip][is] = proj1[ip]->GetBinContent(is + 1);
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]);
1895 }
1896 }
1897 }
1898 } else {
1899 for (int is = 0; is < nstr; is++) {
1900 shift[ip][is] = 0;
1901 fprintf(fcaly, " %3d %3d %7.2f\n", ip, is, shift[ip][is]);
1902 }
1903 shiftyc[ip] = 0;
1904 if (fdeb) {
1905 fprintf(fdeb, "Non: Chamber %d statistic %d\n", ip, ncon);
1906 }
1907 }
1908 fprintf(fcalyc, " %3d %7.2f\n", ip, shiftyc[ip]);
1909 } // loop on chambers
1910 fclose(fdeb);
1911 fcalc->Close();
1912 if (fcaly)
1913 fclose(fcaly);
1914 if (fcalyc)
1915 fclose(fcalyc);
1916 if (fcalxc)
1917 fclose(fcalxc);
1918}
1920{
1921 FILE* fcalx = 0;
1922 FILE *fcaly = 0, *fcalyc = 0, *fcalxc = 0;
1923 char fname_calibr[128], *delim = 0;
1924 strcpy(fname_calibr, gSystem->BaseName(fnametof700));
1925 if ((delim = strrchr(fname_calibr, (int)'.')))
1926 *delim = '\0';
1927 strcat(fname_calibr, "_x_calibration.txt");
1928 fcalx = fopen(fname_calibr, "r");
1929 if (fcalx == NULL) {
1930 printf("File %s open error!\n", fname_calibr);
1931 return 0;
1932 }
1933 strcpy(fname_calibr, gSystem->BaseName(fnametof700));
1934 if ((delim = strrchr(fname_calibr, (int)'.')))
1935 *delim = '\0';
1936 strcat(fname_calibr, "_y_calibration.txt");
1937 fcaly = fopen(fname_calibr, "r");
1938 if (fcaly == NULL) {
1939 printf("File %s open error!\n", fname_calibr);
1940 return 0;
1941 }
1942 strcpy(fname_calibr, gSystem->BaseName(fnametof700));
1943 if ((delim = strrchr(fname_calibr, (int)'.')))
1944 *delim = '\0';
1945 strcat(fname_calibr, "_y_calibration_chamber.txt");
1946 fcalyc = fopen(fname_calibr, "r");
1947 if (fcalyc == NULL) {
1948 printf("File %s open error!\n", fname_calibr);
1949 return 0;
1950 }
1951 strcpy(fname_calibr, gSystem->BaseName(fnametof700));
1952 if ((delim = strrchr(fname_calibr, (int)'.')))
1953 *delim = '\0';
1954 strcat(fname_calibr, "_x_calibration_chamber.txt");
1955 fcalxc = fopen(fname_calibr, "r");
1956 if (fcalxc == NULL) {
1957 printf("File %s open error!\n", fname_calibr);
1958 return 0;
1959 }
1960 //
1961 Int_t nx = 0, ny = 0, nxc = 0, nyc = 0, ip = 0, is = 0;
1962 while (fscanf(fcalx, " l %d %d %lf %lf\n", &ip, &is, &interxl[ip][is], &slopexl[ip][is]) == 4) {
1963 fscanf(fcalx, " g %d %d %lf %lf\n", &ip, &is, &interxg[ip][is], &slopexg[ip][is]);
1964 nx++;
1965 };
1966 while (fscanf(fcalxc, " %d %lf %lf\n", &ip, &interxc[ip], &slopexc[ip]) == 3) {
1967 nxc++;
1968 };
1969 while (fscanf(fcaly, " %d %d %lf\n", &ip, &is, &shifty[ip][is]) == 3) {
1970 ny++;
1971 };
1972 while (fscanf(fcalyc, " %d %lf\n", &ip, &shiftyc[ip]) == 2) {
1973 nyc++;
1974 };
1975 //
1976 printf(" Read TOF700 X calibration parameters - %d strips\n", nx);
1977 printf(" Read TOF700 X calibration parameters - %d chambers\n", nxc);
1978 printf(" Read TOF700 Y calibration parameters - %d strips\n", ny);
1979 printf(" Read TOF700 Y calibration parameters - %d chambers\n", nyc);
1980 if (fcalx)
1981 fclose(fcalx);
1982 if (fcaly)
1983 fclose(fcaly);
1984 if (fcalxc)
1985 fclose(fcalxc);
1986 if (fcalyc)
1987 fclose(fcalyc);
1988 return nx;
1989}
vector< Double_t > dist(vector< Double_t > qp, Double_t mu)
Definition BmnMath.cxx:869
friend F32vec4 fabs(const F32vec4 &a)
Definition P4_F32vec4.h:52
int i
Definition P4_F32vec4.h:22
bool Bool_t
int Int_t
char Char_t
unsigned int UInt_t
float Float_t
short Short_t
double Double_t
#define R__ADD_INCLUDE_PATH(PATH)
#define gROOT
R__EXTERN TStyle * gStyle
R__EXTERN TSystem * gSystem
#define gPad
Double_t GetDdtx() const
Double_t GetDtx() const
Double_t GetYpv() const
Double_t GetChi2() const
Double_t GetDdx() const
Int_t GetSiHits() const
CbmStsTrack * GetGemTrack()
Int_t GetEventId() const
Double_t GetDdty() const
Double_t GetLength() const
Double_t GetXpv() const
Double_t GetDdy() const
Double_t GetDx() const
Double_t GetDty() const
Double_t GetDy() const
Int_t GetGemHits() const
BmnTrack * GetDchTrack()
Short_t GetPlane() const
Short_t GetStrip() const
Float_t GetTime() const
Float_t GetAmplitude() const
Int_t GetNHits() const
Accessors.
Definition BmnTrack.h:49
FairTrackParam * GetParamLast()
Definition BmnTrack.h:65
Int_t GetFlag() const
Definition BmnTrack.h:53
CbmVertex.h.
Definition CbmVertex.h:21
Double_t GetZ() const
Definition CbmVertex.h:60
Double_t GetX() const
Accessors.
Definition CbmVertex.h:58
Double_t GetY() const
Definition CbmVertex.h:59
TVirtualPad * cd(Int_t subpadnumber=0) override
void Update() override
Int_t SetBranchAddress(const char *bname, T **add, TBranch **ptr=nullptr)
virtual Int_t Add(const char *name, Long64_t nentries=TTree::kMaxEntries)
Long64_t GetEntries() const override
Int_t GetEntry(Long64_t entry=0, Int_t getall=0) override
T * Get(const char *namecycle)
virtual Double_t GetParameter(const TString &name) const
void Close(Option_t *option="") override
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
void Draw(Option_t *option="") override
virtual Int_t Fill(const char *name, Double_t w)
virtual Double_t GetEntries() const
virtual TF1 * GetFunction(const char *name) const
virtual Bool_t Divide(const TH1 *h1)
virtual void SetOption(Option_t *option=" ")
TH1D * ProjectionY(const char *name="_py", Int_t firstxbin=0, Int_t lastxbin=-1, Option_t *option="") const
virtual Int_t Fill(const char *namex, const char *namey, Double_t w)
TH1D * ProjectionX(const char *name="_px", Int_t firstybin=0, Int_t lastybin=-1, Option_t *option="") const
Int_t GetEntriesFast() const
TObject * At(Int_t idx) const override
TObject * UncheckedAt(Int_t i) const
virtual UInt_t GetUniqueID() const
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
Int_t Fill(const char *namex, const char *namey, Double_t z) override
Double_t GetBinContent(Int_t bin) const override
Int_t Fill(const char *namex, Double_t y) override
const char * Data() const
double beta(double x, double y)
RVec< PromoteType< T > > sqrt(const RVec< T > &v)
#define IN_WIDTH_LIMITS
int wma[NUMBER_CHAMBERS]
#define NUMBER_CHAMBERS
float idchambers[59]
int wmi[NUMBER_CHAMBERS]
#define WMIN
#define PMAX2
int nhits[NUMBER_CHAMBERS][32]
#define CVERS
float tofWidths[NUMBER_CHAMBERS][32]
#define MPIMAX
#define DMPSCALET2
double yhi[1000]
#define GEMDEBUG
#define XYPANIN
Double_t tofcalc[NUMBER_CHAMBERS]
TProfile * itcalibrc
#define DYMAXPAN
#define DISTMAX
#define PMAX
Float_t halfwidthy[NUMBER_CHAMBERS]
#define CALIBRATION
#define XFACTOR
Float_t halfwidthx[NUMBER_CHAMBERS]
double zhic[1000]
#define MP
#define DXMAXPAN
#define PRES
float tof[NUMBER_CHAMBERS][32]
#define USE_CLUSTERS
double lrd[1000]
#define LIST_STRIP_CORRECTIONS
double xhi[1000]
#define PMIN
#define STRIP_CORRECTIONS
#define DXGEMDCHMAX
#define MPI2
double yhic[1000]
#define WRITE_CALIBRATION
#define DMPSCALE2
Double_t tofcals[NUMBER_CHAMBERS][32]
#define DXMAX
#define GEMCUTS
#define PMAXPI
#define PSCALE
#define WMAX
Double_t tofcalmc[NUMBER_CHAMBERS]
double zhi[1000]
#define PRES1
#define DMPSCALE1
#define MINGEMNDF
#define MINTIME
#define DYMAX
double xhic[1000]
#define CFACTOR
#define MP2
int nhit[NUMBER_CHAMBERS]
#define PMAX1
#define DYGEMDCHMAX
#define TOFMAX
TProfile2D * itcalibr
#define DMPSCALET1
#define DXDCH
#define DTYDCH
#define DY0DCH
#define CALIBFILE
#define DTXDCH
#define DZ0DCH
#define DX0DCH
#define DYDCH
#define CORRECTIONFILE
#define PRIMARY_VERTEX_CUTS
#define MINSIHITS
#define DTX0DCH
#define TRACKFILE
#define DTY0DCH
#define DZDCH
#define XYPETNEW
Double_t slopexc[NUMBER_CHAMBERS]
Double_t slopexg[NUMBER_CHAMBERS][32]
#define WRITE_CALIBRATION_Y_CHAMBER
TFile * fcalc
void FitChambersX()
TH1F * hfitx1s1
TH1F * hfityc
#define WRITE_CALIBRATION_X_CHAMBER
#define WRITE_CALIBRATION_Y
#define WRITE_CALIBRATION_X
TH1F * hfitx0run
int ReadXYCalibration()
TH1F * hfitx1run
Int_t readMCTimeFile(const char *MCTimeFile="TOF700_MC_argon_qgsm_time_run7.txt")
#define XYCALIBRATION
Double_t slopexl[NUMBER_CHAMBERS][32]
TH1F * hfity
TH1F * hfitxs1
TProfile2D * XvsLRvsRun[10]
TProfile2D * YvsY
void FitStripsX()
TH1F * hfitx0
TH1F * hfitx1
Double_t shiftyc[NUMBER_CHAMBERS]
#define WRITE_NEW_CALIBRATION_FILES
TH2F * XvsLRp[NUMBER_CHAMBERS]
TProfile2D * XvsLR
#define MINSTAT
char fnametof700[256]
TH1F * hfitx1s1a
TProfile2D * XvsLRvsStrip1[NUMBER_CHAMBERS]
TH1F * hfitxs0a
void BmnXTCalibrationTOF700(const char *TracksGemDch=TRACKFILE, const char *DigitsTOF700="argon_tof700_digits_files_pro_full.txt")
Double_t interxg[NUMBER_CHAMBERS][32]
void select_hist()
TProfile2D * XvsLRvsStrip[NUMBER_CHAMBERS]
Double_t interxc[NUMBER_CHAMBERS]
TH1F * hfitxs0
Double_t shifty[NUMBER_CHAMBERS][32]
TH1F * hfitxs1a
#define OLD_DIGI_FILE
TH1F * hfitx1s0
#define FLAG
Double_t interxl[NUMBER_CHAMBERS][32]
TFile * fcals
Bool_t IsNaN(Double_t x)
Double_t Sqrt(Double_t x)
Double_t Abs(Double_t d)
Definition json.hpp:4446