ATLAS Offline Software
TRTCalib_makeplots.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 #include <fstream>
9 #include <sstream>
10 #include <iomanip>
11 #include <stdlib.h>
12 #include <stdio.h>
13 #include <math.h>
14 #include <iostream>
15 #include <exception>
16 #include <TNtuple.h>
17 #include <TFile.h>
18 #include <TKey.h>
19 #include <TH1F.h>
20 #include <TH2F.h>
21 #include <TGraphErrors.h>
22 #include <TF1.h>
23 #include <TStyle.h> //TStyle not found by the Makefile
24 #include <TCanvas.h>
25 #include <THStack.h>
26 #include <TLine.h>
27 #include <TLegend.h>
28 #include <TLegendEntry.h>
29 #include <THStack.h>
30 #include <TEventList.h>
31 #include <TPad.h>
32 #include <TPaveText.h>
33 #include <TPaveStats.h>
34 #include <TPaletteAxis.h>
35 #include <TProfile.h>
36 #include <TROOT.h>
37 #include <TError.h>
38 #include <TVectorD.h>
39 #include <map>
40 #include <string>
41 #include <vector>
42 #include <stdexcept>
43 using namespace std;
44 
45 bool do_expert = false;
46 
47 char detlet[3] = {'C', '-', 'A'};
48 
49 void SetZAxis(TH2F *reshist0)
50 {
51  double zmin = 100000000;
52  double zmax = -100000000;
53  double temp = 0;
54  for (int ix = 0; ix < reshist0->GetNbinsX(); ix++)
55  {
56  for (int iy = 0; iy < reshist0->GetNbinsY(); iy++)
57  {
58  temp = reshist0->GetBinContent(ix, iy);
59  if (temp !=0){
62  }
63  }
64  }
65  reshist0->GetZaxis()->SetRangeUser(zmin, zmax);
66 }
67 
68 void ResizePalette(TH2 *hist)
69 {
70  TPaletteAxis *palette = (TPaletteAxis *)hist->GetListOfFunctions()->FindObject("palette");
71  palette->SetX2NDC(0.92);
72  palette->Paint();
73  palette->SetLabelSize(0.03);
74 }
75 
76 string trim(string s)
77 {
78  const char * whitespace = " \n\r\t";
79  s.erase(s.find_last_not_of(whitespace)+1);//rtrim
80  s.erase(0,s.find_first_not_of(whitespace));//ltrim
81  return s;
82 }
83 
84 class TextPage : public TCanvas
85 {
86 public:
87  TextPage(const string&);
88 };
89 
90 TextPage::TextPage(const string & text)
91 {
92  this->cd();
93  TPaveText *pt = new TPaveText(.1, .1, 0.9, 0.9);
94  pt->SetTextAlign(22);
95  pt->AddText(text.data());
96  pt->Draw();
97 }
98 
99 //================================================================
100 
101 class NHitStack : public THStack
102 {
103 public:
104  NHitStack(TNtuple *, TLegend *, bool, int, int);
105 };
106 
107 NHitStack::NHitStack(TNtuple *tuple, TLegend *leg, bool doleg, int mint0, int minrt)
108 {
109 
110  int min = (int)tuple->GetMinimum("nt0");
111  int max = (int)tuple->GetMaximum("nt0");
112  float bsize = ceil(((float)(max - min) / 50));
113  int hmax = min + (int)(50 * bsize);
114  // cout << min << " " << max << " " << bsize << " " << hmax << endl;
115  TH1F *hits1 = new TH1F(Form("%s_hits1", tuple->GetName()), "test1", 50, min, hmax);
116  TH1F *hits2 = new TH1F(Form("%s_hits2", tuple->GetName()), "test2", 50, min, hmax);
117  TH1F *hits3 = new TH1F(Form("%s_hits3", tuple->GetName()), "test3", 50, min, hmax);
118  // TH1F* hits2 = new TH1F("hits2","test2",50,min,hmax);
119  // TH1F* hits3 = new TH1F("hits3","test3",50,min,hmax);
120  tuple->Draw(Form("nt0>>%s_hits1", tuple->GetName()), Form("nt0<=%i", mint0));
121  tuple->Draw(Form("nt0>>%s_hits2", tuple->GetName()), Form("nt0>%i && nt0<=%i", mint0, minrt));
122  tuple->Draw(Form("nt0>>%s_hits3", tuple->GetName()), Form("nt0>%i", minrt));
123  hits1->SetFillColor(46);
124  hits2->SetFillColor(8);
125  hits3->SetFillColor(38);
126 
127  // gStyle->SetOptStat("e");
128 
129  this->Add(hits1);
130  this->Add(hits2);
131  this->Add(hits3);
132 
133  if (doleg)
134  {
135  leg->AddEntry(hits1, "no calibration");
136  leg->AddEntry(hits2, "enough for T0 calib");
137  leg->AddEntry(hits3, "enough for T0+RT calib");
138  leg->SetTextSize(0.04);
139  }
140 }
141 
142 //================================================================
143 
144 class HitStatistics : public TCanvas
145 {
146 public:
147  HitStatistics(char *, bool);
148 };
149 
150 HitStatistics::HitStatistics(char *infile, bool isAr = false)
151 {
152 
153  TFile *file = new TFile(infile);
154  cout << " In HitStatistics infile: " << infile << endl;
155  file->cd();
156  TNtuple *Strawtuple = nullptr;
157  TNtuple *Chiptuple = nullptr;
158  TNtuple *Boardtuple = nullptr;
159  TNtuple *Moduletuple = nullptr;
160  TNtuple *Layertuple = nullptr;
161  TNtuple *Detectortuple = nullptr;
162  TNtuple *conftup = nullptr;
163 
164  if (!isAr)
165  {
166  Strawtuple = (TNtuple *)file->Get("Strawtuple");
167  Chiptuple = (TNtuple *)file->Get("Chiptuple");
168  Boardtuple = (TNtuple *)file->Get("Boardtuple");
169  Moduletuple = (TNtuple *)file->Get("Moduletuple");
170  Layertuple = (TNtuple *)file->Get("Layertuple");
171  Detectortuple = (TNtuple *)file->Get("Detectortuple");
172  conftup = (TNtuple *)file->Get("configs");
173  }
174  else
175  {
176  Strawtuple = (TNtuple *)file->Get("Straw_Artuple");
177  Chiptuple = (TNtuple *)file->Get("Chip_Artuple");
178  Boardtuple = (TNtuple *)file->Get("Board_Artuple");
179  Moduletuple = (TNtuple *)file->Get("Module_Artuple");
180  Layertuple = (TNtuple *)file->Get("Layer_Artuple");
181  Detectortuple = (TNtuple *)file->Get("Detector_Artuple");
182  conftup = (TNtuple *)file->Get("configs");
183  }
184 
185  float mint0 = 500, minrt = 10000;
186  if (conftup)
187  {
188  conftup->SetBranchAddress("mint0", &mint0);
189  conftup->SetBranchAddress("minrt", &minrt);
190  conftup->GetEntry(0);
191  }
192 
193  this->SetName("c1");
194  this->cd();
195  this->Divide(3, 2, 0.01, 0.01);
196 
197  ((TPad *)this->GetPrimitive("c1_1"))->SetFrameFillColor(0);
198  ((TPad *)this->GetPrimitive("c1_2"))->SetFrameFillColor(0);
199  ((TPad *)this->GetPrimitive("c1_3"))->SetFrameFillColor(0);
200  ((TPad *)this->GetPrimitive("c1_4"))->SetFrameFillColor(0);
201  ((TPad *)this->GetPrimitive("c1_5"))->SetFrameFillColor(0);
202  ((TPad *)this->GetPrimitive("c1_6"))->SetFrameFillColor(0);
203 
204  ((TPad *)this->GetPrimitive("c1_1"))->SetLogy();
205  ((TPad *)this->GetPrimitive("c1_2"))->SetLogy();
206  ((TPad *)this->GetPrimitive("c1_3"))->SetLogy();
207  ((TPad *)this->GetPrimitive("c1_4"))->SetLogy();
208  ((TPad *)this->GetPrimitive("c1_5"))->SetLogy();
209  ((TPad *)this->GetPrimitive("c1_6"))->SetLogy();
210 
211  TLegend *leg = new TLegend(0.95, 0.6, 0.35, 0.35);
212 
213  this->cd(1);
214  this->SetLogx();
215  NHitStack *hsStraw = new NHitStack(Strawtuple, leg, false, (int)mint0, (int)minrt);
216  hsStraw->SetTitle("Hit Statistics (Straw)");
217  if (isAr)
218  hsStraw->SetTitle("Hit Statistics (Argon Straw)");
219  hsStraw->Draw();
220  hsStraw->GetHistogram()->GetXaxis()->SetTitle("No. Hits");
221  hsStraw->GetHistogram()->GetYaxis()->SetTitle("No. Straws");
222  hsStraw->GetHistogram()->GetXaxis()->SetNdivisions(-4);
223  this->cd(2);
224  this->SetLogx();
225  NHitStack *hsChip = new NHitStack(Chiptuple, leg, false, (int)mint0, (int)minrt);
226  hsChip->SetTitle("Hit Statistics (Chip)");
227  if (isAr)
228  hsChip->SetTitle("Hit Statistics (Argon chip)");
229  hsChip->Draw();
230  hsChip->GetHistogram()->GetXaxis()->SetTitle("No. Hits");
231  hsChip->GetHistogram()->GetYaxis()->SetTitle("No. Chips");
232  hsChip->GetHistogram()->GetXaxis()->SetNdivisions(-4);
233  this->cd(3);
234  this->SetLogx();
235  NHitStack *hsBoard = new NHitStack(Boardtuple, leg, false, (int)mint0, (int)minrt);
236  hsBoard->SetTitle("Hit Statistics (Board)");
237  if (isAr)
238  hsBoard->SetTitle("Hit Statistics (Argon Board)");
239  hsBoard->Draw();
240  hsBoard->GetHistogram()->GetXaxis()->SetTitle("No. Hits");
241  hsBoard->GetHistogram()->GetYaxis()->SetTitle("No. Boards");
242  hsBoard->GetHistogram()->GetXaxis()->SetNdivisions(-4);
243  this->cd(4);
244  this->SetLogx();
245  NHitStack *hsModule = new NHitStack(Moduletuple, leg, false, (int)mint0, (int)minrt);
246  hsModule->SetTitle("Hit Statistics (Phi Sector)");
247  if (isAr)
248  hsModule->SetTitle("Hit Statistics (Argon Phi Sector)");
249  hsModule->Draw();
250  hsModule->GetHistogram()->GetXaxis()->SetTitle("No. Hits");
251  hsModule->GetHistogram()->GetYaxis()->SetTitle("No. Phi Sectors");
252  hsModule->GetHistogram()->GetXaxis()->SetNdivisions(-4);
253  this->cd(5);
254  this->SetLogx();
255  NHitStack *hsLayer = new NHitStack(Layertuple, leg, false, (int)mint0, (int)minrt);
256  hsLayer->SetTitle("Hit Statistics (Layer/wheel)");
257  if (isAr)
258  hsLayer->SetTitle("Hit Statistics (Argon Layer/wheel)");
259  hsLayer->Draw();
260  hsLayer->GetHistogram()->GetXaxis()->SetTitle("No. Hits");
261  hsLayer->GetHistogram()->GetYaxis()->SetTitle("No. Layers/wheel");
262  hsLayer->GetHistogram()->GetXaxis()->SetNdivisions(-4);
263  this->cd(6);
264  this->SetLogx();
265  NHitStack *hsDetector = new NHitStack(Detectortuple, leg, true, (int)mint0, (int)minrt);
266  hsDetector->SetTitle("Hit Statistics (Detector)");
267  if (isAr)
268  hsDetector->SetTitle("Argon Hit Statistics (Detector)");
269  hsDetector->Draw();
270  hsDetector->GetHistogram()->GetXaxis()->SetTitle("No. Hits");
271  hsDetector->GetHistogram()->GetYaxis()->SetTitle("No. Detectors");
272  hsDetector->GetHistogram()->GetXaxis()->SetNdivisions(-4);
273 
274  leg->Draw();
275 }
276 
277 //================================================================
278 
279 class XYMaps : public TCanvas
280 {
281 public:
282  XYMaps(char *, string, bool);
283 };
284 
285 XYMaps::XYMaps(char *infile, string variable, bool isAr = false)
286 {
287 
288  char selectionA[500];
289  sprintf(selectionA, "%s*(det==1)", variable.c_str());
290  char selectionC[500];
291  sprintf(selectionC, "%s*(det==-1)", variable.c_str());
292  if (variable == "nt0")
293  variable = "Nhits";
294  TFile *file = new TFile(infile);
295  cout << "In XYMaps infile: " << infile << " variable " << variable << endl;
296  file->cd();
297  TNtuple *Chiptuple = nullptr;
298  TNtuple *Boardtuple = nullptr;
299  TNtuple *Moduletuple = nullptr;
300 
301  if (!isAr)
302  {
303  Chiptuple = (TNtuple *)file->Get("Chiptuple");
304  Boardtuple = (TNtuple *)file->Get("Boardtuple");
305  Moduletuple = (TNtuple *)file->Get("Moduletuple");
306  }
307  else
308  {
309  Chiptuple = (TNtuple *)file->Get("Chip_Artuple");
310  Boardtuple = (TNtuple *)file->Get("Board_Artuple");
311  Moduletuple = (TNtuple *)file->Get("Module_Artuple");
312  }
313 
314  this->SetName("c1");
315  this->cd();
316  this->Divide(3, 2, 0.01, 0.01);
317  ((TPad *)this->GetPrimitive("c1_1"))->SetFrameFillColor(1);
318  ((TPad *)this->GetPrimitive("c1_2"))->SetFrameFillColor(1);
319  ((TPad *)this->GetPrimitive("c1_3"))->SetFrameFillColor(1);
320  ((TPad *)this->GetPrimitive("c1_4"))->SetFrameFillColor(1);
321  ((TPad *)this->GetPrimitive("c1_5"))->SetFrameFillColor(1);
322  ((TPad *)this->GetPrimitive("c1_6"))->SetFrameFillColor(1);
323 
324  gStyle->SetPalette(1);
325 
326  this->cd(1);
327  Moduletuple->Draw("y:x>>reshist10(40,-1200,1200,40,-1200,1200)", selectionA, "colz");
328  TH2F *reshist10 = (TH2F *)gPad->GetPrimitive("reshist10");
329  if (!reshist10)
330  throw string("Variable not found!");
331  if (variable == "res")
332  {
333  reshist10->GetZaxis()->SetRangeUser(0.12, 0.19);
334  }
335  else if (variable == "abs(resMean)")
336  {
337  reshist10->GetZaxis()->SetRangeUser(0.0, 0.01);
338  }
339  else if (variable == "t0")
340  {
341  reshist10->GetZaxis()->SetRangeUser(1.0, 7.0);
342  }
343  else if (variable == "abs(t0-oldt0)")
344  {
345  reshist10->GetZaxis()->SetRangeUser(0, .4);
346  }
347  else if (variable == "(tres)")
348  {
349  reshist10->GetZaxis()->SetRangeUser(2.0, 4.0);
350  }
351  this->Update();
352  if (reshist10->GetEntries() > 1)
353  ResizePalette(reshist10);
354  // SetZAxis(reshist10);
355  char title1[500];
356  sprintf(title1, "Module %s (barrel side A)", variable.c_str());
357  if (isAr)
358  sprintf(title1, "Argon Module %s (barrel side A)", variable.c_str());
359  reshist10->SetTitle(title1);
360  reshist10->SetStats(0);
361  reshist10->GetXaxis()->SetLabelOffset(1000);
362  reshist10->GetYaxis()->SetLabelOffset(1000);
363 
364  this->cd(2);
365  Boardtuple->Draw("y:x>>reshist0(100,-1200,1200,100,-1200,1200)", selectionA, "colz");
366  TH2F *reshist0 = (TH2F *)gPad->GetPrimitive("reshist0");
367  if (!reshist0)
368  throw string("Variable not found!");
369 
370  if (variable == "res")
371  {
372  reshist0->GetZaxis()->SetRangeUser(0.12, 0.19);
373  }
374  else if (variable == "abs(resMean)")
375  {
376  reshist0->GetZaxis()->SetRangeUser(0.0, 0.01);
377  }
378  else if (variable == "t0")
379  {
380  reshist0->GetZaxis()->SetRangeUser(1.0, 7.0);
381  }
382  else if (variable == "abs(t0-oldt0)")
383  {
384  reshist0->GetZaxis()->SetRangeUser(0, .4);
385  }
386  else if (variable == "(tres)")
387  {
388  reshist0->GetZaxis()->SetRangeUser(2.0, 4.0);
389  }
390  this->Update();
391  if (reshist0->GetEntries() > 1)
392  ResizePalette(reshist0);
393  // SetZAxis(reshist0);
394  char title2[500];
395  sprintf(title2, "Board %s (barrel side A)", variable.c_str());
396  if (isAr)
397  sprintf(title2, "Argon Board %s (barrel side A)", variable.c_str());
398  reshist0->SetTitle(title2);
399  reshist0->SetStats(0);
400  reshist0->GetXaxis()->SetLabelOffset(1000);
401  reshist0->GetYaxis()->SetLabelOffset(1000);
402 
403  this->cd(3);
404  Chiptuple->Draw("y:x>>t0hist0(300,-1200,1200,300,-1200,1200)", selectionA, "colz");
405  TH2F *t0hist0 = (TH2F *)gPad->GetPrimitive("t0hist0");
406  if (!t0hist0)
407  throw string("Variable not found!");
408  char title3[500];
409  sprintf(title3, "Chip %s (barrel side A)", variable.c_str());
410  if (isAr)
411  sprintf(title3, "Argon Chip %s (barrel side A)", variable.c_str());
412  t0hist0->SetTitle(title3);
413 
414  if (variable == "res")
415  {
416  t0hist0->GetZaxis()->SetRangeUser(0.12, 0.19);
417  }
418  else if (variable == "abs(resMean)")
419  {
420  t0hist0->GetZaxis()->SetRangeUser(0.0, 0.01);
421  }
422  else if (variable == "t0")
423  {
424  t0hist0->GetZaxis()->SetRangeUser(1.0, 7.0);
425  }
426  else if (variable == "abs(t0-oldt0)")
427  {
428  t0hist0->GetZaxis()->SetRangeUser(0, .4);
429  }
430  else if (variable == "(tres)")
431  {
432  t0hist0->GetZaxis()->SetRangeUser(2.0, 4.0);
433  }
434  this->Update();
435  if (t0hist0->GetEntries() > 1)
436  ResizePalette(t0hist0);
437  // SetZAxis(t0hist0);
438  t0hist0->SetStats(0);
439  t0hist0->GetXaxis()->SetLabelOffset(1000);
440  t0hist0->GetYaxis()->SetLabelOffset(1000);
441 
442  this->cd(4);
443  Moduletuple->Draw("y:x>>reshist11(40,-1200,1200,40,-1200,1200)", selectionC, "colz");
444  TH2F *reshist11 = (TH2F *)gPad->GetPrimitive("reshist11");
445  if (!reshist11)
446  throw string("Variable not found!");
447  if (variable == "res")
448  {
449  reshist11->GetZaxis()->SetRangeUser(0.12, 0.19);
450  }
451  else if (variable == "abs(resMean)")
452  {
453  reshist11->GetZaxis()->SetRangeUser(0.0, 0.01);
454  }
455  else if (variable == "t0")
456  {
457  reshist11->GetZaxis()->SetRangeUser(1.0, 7.0);
458  }
459  else if (variable == "abs(t0-oldt0)")
460  {
461  reshist11->GetZaxis()->SetRangeUser(0, .4);
462  }
463  else if (variable == "(tres)")
464  {
465  reshist11->GetZaxis()->SetRangeUser(2.0, 4.0);
466  }
467  this->Update();
468  if (reshist11->GetEntries() > 1)
469  ResizePalette(reshist11);
470  // SetZAxis(reshist11);
471  char title4[500];
472  sprintf(title4, "Module %s (barrel side C)", variable.c_str());
473  if (isAr)
474  sprintf(title4, "Argon Module %s (barrel side C)", variable.c_str());
475  reshist11->SetTitle(title4);
476  reshist11->SetStats(0);
477  reshist11->GetXaxis()->SetLabelOffset(1000);
478  reshist11->GetYaxis()->SetLabelOffset(1000);
479 
480  this->cd(5);
481  Boardtuple->Draw("y:x>>reshist1(100,-1200,1200,100,-1200,1200)", selectionC, "colz");
482  TH2F *reshist1 = (TH2F *)gPad->GetPrimitive("reshist1");
483  if (!reshist1)
484  throw string("Variable not found!");
485  if (variable == "res")
486  {
487  reshist1->GetZaxis()->SetRangeUser(0.12, 0.19);
488  }
489  else if (variable == "abs(resMean)")
490  {
491  reshist1->GetZaxis()->SetRangeUser(0.0, 0.01);
492  }
493  else if (variable == "t0")
494  {
495  reshist1->GetZaxis()->SetRangeUser(1.0, 7.0);
496  }
497  else if (variable == "abs(t0-oldt0)")
498  {
499  reshist1->GetZaxis()->SetRangeUser(0, .4);
500  }
501  else if (variable == "(tres)")
502  {
503  reshist1->GetZaxis()->SetRangeUser(2.0, 4.0);
504  }
505  this->Update();
506  if (reshist1->GetEntries() > 1)
507  ResizePalette(reshist1);
508 
509  char title5[500];
510  sprintf(title5, "Board %s (barrel side C)", variable.c_str());
511  if (isAr)
512  sprintf(title5, "Argon Board %s (barrel side C)", variable.c_str());
513  reshist1->SetTitle(title5);
514  reshist1->SetStats(0);
515  reshist1->GetXaxis()->SetLabelOffset(1000);
516  reshist1->GetYaxis()->SetLabelOffset(1000);
517 
518  this->cd(6);
519  Chiptuple->Draw("y:x>>t0hist1(300,-1200,1200,300,-1200,1200)", selectionC, "colz");
520  TH2F *t0hist1 = (TH2F *)gPad->GetPrimitive("t0hist1");
521  if (!t0hist1)
522  throw string("Variable not found!");
523  if (variable == "res")
524  {
525  t0hist1->GetZaxis()->SetRangeUser(0.12, 0.19);
526  }
527  else if (variable == "abs(resMean)")
528  {
529  t0hist1->GetZaxis()->SetRangeUser(0.0, 0.01);
530  }
531  else if (variable == "t0")
532  {
533  t0hist1->GetZaxis()->SetRangeUser(1.0, 7.0);
534  }
535  else if (variable == "abs(t0-oldt0)")
536  {
537  t0hist1->GetZaxis()->SetRangeUser(0, .4);
538  }
539  else if (variable == "(tres)")
540  {
541  t0hist1->GetZaxis()->SetRangeUser(2.0, 4.0);
542  }
543  this->Update();
544  if (t0hist1->GetEntries() > 1)
545  ResizePalette(t0hist1);
546 
547  char title6[500];
548  sprintf(title6, "Chip %s (barrel side C)", variable.c_str());
549  if (isAr)
550  sprintf(title6, "Argon Chip %s (barrel side C)", variable.c_str());
551  t0hist1->SetTitle(title6);
552  t0hist1->SetStats(0);
553  t0hist1->GetXaxis()->SetLabelOffset(1000);
554  t0hist1->GetYaxis()->SetLabelOffset(1000);
555 }
556 
557 //================================================================
558 
560 {
561 public:
562  T0CalTypeXY(TNtuple *, int, float);
563  void Draw(const string &, bool);
564  TGraph* graph[7]{};
565  TEventList* elist[7]{};
566 };
567 
568 T0CalTypeXY::T0CalTypeXY(TNtuple *Levtuple, int detector, float markersize)
569 {
570 
571  float x{}, y{}, nt0{}, chp{}, brd{}, lay{}, mod{}, det{};
572  int color[7] = {0, 46, 38, 8, 16, 1, 2};
573 
574  Levtuple->SetBranchAddress("x", &x);
575  Levtuple->SetBranchAddress("y", &y);
576  Levtuple->SetBranchAddress("nt0", &nt0);
577  Levtuple->SetBranchAddress("chp", &chp);
578  Levtuple->SetBranchAddress("brd", &brd);
579  Levtuple->SetBranchAddress("lay", &lay);
580  Levtuple->SetBranchAddress("mod", &mod);
581  Levtuple->SetBranchAddress("det", &det);
582 
583  Levtuple->Draw(">>tmplist0", Form("nt0*(det==%i)", detector));
584  Levtuple->Draw(">>tmplist1", Form("nt0*(ftype==1 && det==%i)", detector));
585  Levtuple->Draw(">>tmplist2", Form("nt0*(ftype==2 && det==%i)", detector));
586  Levtuple->Draw(">>tmplist3", Form("nt0*(ftype==3 && det==%i)", detector));
587  Levtuple->Draw(">>tmplist4", Form("nt0*(ftype==4 && det==%i)", detector));
588  Levtuple->Draw(">>tmplist5", Form("nt0*(ftype==5 && det==%i)", detector));
589  Levtuple->Draw(">>tmplist6", Form("nt0*(ftype==6 && det==%i)", detector));
590  elist[0] = (TEventList *)gDirectory->Get("tmplist0");
591  elist[1] = (TEventList *)gDirectory->Get("tmplist1");
592  elist[2] = (TEventList *)gDirectory->Get("tmplist2");
593  elist[3] = (TEventList *)gDirectory->Get("tmplist3");
594  elist[4] = (TEventList *)gDirectory->Get("tmplist4");
595  elist[5] = (TEventList *)gDirectory->Get("tmplist5");
596  elist[6] = (TEventList *)gDirectory->Get("tmplist6");
597 
598  for (int igr = 0; igr <= 6; igr++)
599  {
600  graph[igr] = new TGraph();
601  graph[igr]->SetMarkerStyle(20);
602  graph[igr]->SetMarkerSize(markersize);
603  graph[igr]->SetMarkerColor(color[igr]);
604  int ipnt = 0;
605  for (int ib = 0; ib < elist[igr]->GetN(); ib++)
606  {
607  ipnt++;
608  Levtuple->GetEntry(elist[igr]->GetEntry(ib));
609 
610  graph[igr]->SetPoint(ipnt, x, y);
611  }
612  graph[igr]->RemovePoint(0);
613  }
614  graph[0]->SetMarkerSize(0.1);
615 }
616 
617 void T0CalTypeXY::Draw(const string & title, bool plotleg)
618 {
619  graph[0]->GetHistogram()->GetXaxis()->SetLabelOffset(1000);
620  graph[0]->GetHistogram()->GetYaxis()->SetLabelOffset(1000);
621  if (graph[0]->GetN() > 0)
622  graph[0]->Draw("ap");
623  if (graph[1]->GetN() > 0)
624  graph[1]->Draw("p");
625  if (graph[2]->GetN() > 0)
626  graph[2]->Draw("p");
627  if (graph[3]->GetN() > 0)
628  graph[3]->Draw("p");
629  if (graph[4]->GetN() > 0)
630  graph[4]->Draw("p");
631  if (graph[5]->GetN() > 0)
632  graph[5]->Draw("p");
633  if (graph[6]->GetN() > 0)
634  graph[6]->Draw("p");
635  cout << "In Draw title: " << title << endl;
636  cout << " Events in graph[0]: " << graph[0]->GetN() << endl;
637  cout << " Events in graph[1]: " << graph[1]->GetN() << endl;
638  cout << " Events in graph[2]: " << graph[2]->GetN() << endl;
639  cout << " Events in graph[3]: " << graph[3]->GetN() << endl;
640  cout << " Events in graph[4]: " << graph[4]->GetN() << endl;
641  graph[0]->Clear();
642  graph[0]->SetTitle(title.c_str());
643 
644  if (plotleg)
645  {
646  TLegend *leg = new TLegend(0.99, 0.35, 0.55, 0.01);
647  leg->AddEntry(graph[2], "normal fit");
648  leg->AddEntry(graph[3], "used chip ref");
649  leg->AddEntry(graph[4], "Low stat,T0");
650  leg->AddEntry(graph[1], "|mean|>5");
651  leg->AddEntry(graph[5], "No T0 Cal");
652  leg->AddEntry(graph[6], "Wrong fit, RMS and Mean used");
653  leg->SetTextSize(0.04);
654 
655  leg->Draw();
656  }
657 }
658 
659 //================================================================
660 
661 class T0CalibTypeXY : public TCanvas
662 {
663 public:
664  T0CalibTypeXY(char *, bool);
665 };
666 
667 T0CalibTypeXY::T0CalibTypeXY(char *infile, bool isAr = false)
668 {
669 
670  TFile *file = new TFile(infile);
671  cout << "In T0CalibTypeXY infile: " << infile << endl;
672  file->cd();
673  TNtuple *Chiptuple = nullptr;
674  TNtuple *Boardtuple = nullptr;
675  TNtuple *Moduletuple = nullptr;
676 
677  if (!isAr)
678  {
679  Chiptuple = (TNtuple *)file->Get("Chiptuple");
680  Boardtuple = (TNtuple *)file->Get("Boardtuple");
681  Moduletuple = (TNtuple *)file->Get("Moduletuple");
682  }
683  else
684  {
685  Chiptuple = (TNtuple *)file->Get("Chip_Artuple");
686  Boardtuple = (TNtuple *)file->Get("Board_Artuple");
687  Moduletuple = (TNtuple *)file->Get("Module_Artuple");
688  }
689 
690  T0CalTypeXY hxy1 = T0CalTypeXY(Chiptuple, -1, 0.2);
691  T0CalTypeXY hxy2 = T0CalTypeXY(Boardtuple, -1, 0.5);
692  T0CalTypeXY hxy3 = T0CalTypeXY(Moduletuple, -1, 0.8);
693  T0CalTypeXY hxy4 = T0CalTypeXY(Chiptuple, 1, 0.2);
694  T0CalTypeXY hxy5 = T0CalTypeXY(Boardtuple, 1, 0.5);
695  T0CalTypeXY hxy6 = T0CalTypeXY(Moduletuple, 1, 0.8);
696 
697  this->SetName("c1");
698  this->cd();
699  this->Divide(3, 2, 0.01, 0.01);
700  ((TPad *)this->GetPrimitive("c1_1"))->SetFrameFillColor(1);
701  ((TPad *)this->GetPrimitive("c1_2"))->SetFrameFillColor(1);
702  ((TPad *)this->GetPrimitive("c1_3"))->SetFrameFillColor(1);
703  ((TPad *)this->GetPrimitive("c1_4"))->SetFrameFillColor(1);
704  ((TPad *)this->GetPrimitive("c1_5"))->SetFrameFillColor(1);
705  ((TPad *)this->GetPrimitive("c1_6"))->SetFrameFillColor(1);
706  if (!isAr)
707  {
708  this->cd(6);
709  hxy1.Draw("T0 calib type (Chip, side C)", false);
710  this->cd(5);
711  hxy2.Draw("T0 calib type (Board, side C)", false);
712  this->cd(4);
713  hxy3.Draw("T0 calib type (Module, side C)", false);
714  this->cd(3);
715  hxy4.Draw("T0 calib type (Chip, side A)", false);
716  this->cd(2);
717  hxy5.Draw("T0 calib type (Board, side A)", false);
718  this->cd(1);
719  hxy6.Draw("T0 calib type (Module, side A)", true);
720  }
721  else
722  {
723  this->cd(6);
724  hxy1.Draw("Argon T0 calib type (Chip, side C)", false);
725  this->cd(5);
726  hxy2.Draw("Argon T0 calib type (Board, side C)", false);
727  this->cd(4);
728  hxy3.Draw("Argon T0 calib type (Module, side C)", false);
729  this->cd(3);
730  hxy4.Draw("Argon T0 calib type (Chip, side A)", false);
731  this->cd(2);
732  hxy5.Draw("Argon T0 calib type (Board, side A)", false);
733  this->cd(1);
734  hxy6.Draw("Argon T0 calib type (Module, side A)", true);
735  }
736 }
737 
738 //================================================================
739 
740 class ChipVariations : public TProfile
741 {
742 public:
743  ChipVariations(char *, int);
744  void DrawLines(float, float);
745 };
746 
748 {
749 
750  ofstream txtfile(Form("finedelays_%i.txt", detector), ios::out);
751 
752  float t0o, chip, dt0, rt0;
753  int nchip[9] = {10, 11, 15, 9, 9, 11, 12, 13, 14};
754 
755  this->SetBins(104, 0.5, 104.5);
756  this->SetName(Form("ChipT0Var_%i", detector));
757 
758  TFile *file = new TFile(infile);
759  cout << "In ChipVariations infile: " << infile << " detector " << detector << endl;
760  file->cd();
761  TNtuple *Chiptuple = (TNtuple *)file->Get("Chiptuple");
762 
763  Chiptuple->SetBranchAddress("rt0", &rt0);
764  Chiptuple->SetBranchAddress("t0offset", &t0o);
765  Chiptuple->SetBranchAddress("chp", &chip);
766  Chiptuple->SetBranchAddress("dt0", &dt0);
767 
768  int ic = 0;
769  for (int ibrd = 0; ibrd < 9; ibrd++)
770  {
771 
772  Chiptuple->Draw(">>tmplist", Form("brd==%i && t0offset!=0 && ftype>1 && det==%i", ibrd, detector));
773  TEventList *elist = (TEventList *)gDirectory->Get("tmplist");
774 
775  int mchip = 0;
776  for (int ib = 0; ib < elist->GetN(); ib++)
777  {
778  ic++;
779  Chiptuple->GetEntry(elist->GetEntry(ib));
780  if (ibrd < 2)
781  mchip = (int)chip;
782  if (ibrd >= 2 && ibrd < 5)
783  mchip = (int)chip + 21;
784  if (ibrd >= 5)
785  mchip = (int)chip + 21 + 33;
786  this->Fill(mchip, t0o);
787  }
788  }
789 
790  ic = 0;
791  for (int ibrd = 0; ibrd < 9; ibrd++)
792  {
793  for (int ichp = 0; ichp < nchip[ibrd]; ichp++)
794  {
795  int mchip = 0;
796  if (ibrd == 0)
797  mchip = ichp + 1;
798  if (ibrd == 1)
799  mchip = ichp + nchip[ibrd - 1] + 1;
800  if (ibrd == 2)
801  mchip = ichp + 1;
802  if (ibrd == 3)
803  mchip = ichp + nchip[ibrd - 1] + 1;
804  if (ibrd == 4)
805  mchip = ichp + nchip[ibrd - 1] + nchip[ibrd - 2] + 1;
806  if (ibrd == 5)
807  mchip = ichp + 1;
808  if (ibrd == 6)
809  mchip = ichp + nchip[ibrd - 1] + 1;
810  if (ibrd == 7)
811  mchip = ichp + nchip[ibrd - 1] + nchip[ibrd - 2] + 1;
812  if (ibrd == 8)
813  mchip = ichp + nchip[ibrd - 1] + nchip[ibrd - 2] + nchip[ibrd - 3] + 1;
814  txtfile << ibrd << " " << mchip << " " << detector << " " << ic << " " << this->GetBinContent(ic + 1) << endl;
815  ic++;
816  }
817  }
818 
819  // chg->RemovePoint(0);
820  this->SetTitle(Form("Chip T0 offset (phi-mod average, %c-side)", detlet[detector + 1]));
821  this->SetStats(kFALSE);
822  this->SetLineColor(2);
823  this->GetYaxis()->SetTitle("T0_{board}-T0_{chip} / ns");
824  this->GetXaxis()->SetTitle("chip #");
825 
826  txtfile.close();
827  file->Close();
828  delete file;
829 }
830 
831 void ChipVariations::DrawLines(float lowe, float upe)
832 {
833  TLine *lin1 = new TLine(10.5, lowe, 10.5, upe);
834  lin1->SetLineStyle(2);
835  lin1->Draw();
836  TLine *lin2 = new TLine(21.5, lowe, 21.5, upe);
837  lin2->SetLineStyle(2);
838  lin2->Draw();
839  TLine *lin3 = new TLine(36.5, lowe, 36.5, upe);
840  lin3->SetLineStyle(2);
841  lin3->Draw();
842  TLine *lin4 = new TLine(45.5, lowe, 45.5, upe);
843  lin4->SetLineStyle(2);
844  lin4->Draw();
845  TLine *lin5 = new TLine(54.5, lowe, 54.5, upe);
846  lin5->SetLineStyle(2);
847  lin5->Draw();
848  TLine *lin6 = new TLine(65.5, lowe, 65.5, upe);
849  lin6->SetLineStyle(2);
850  lin6->Draw();
851  TLine *lin7 = new TLine(77.5, lowe, 77.5, upe);
852  lin7->SetLineStyle(2);
853  lin7->Draw();
854  TLine *lin8 = new TLine(90.5, lowe, 90.5, upe);
855  lin8->SetLineStyle(2);
856  lin8->Draw();
857 }
858 
859 //================================================================
860 
861 class BoardVariations : public TGraphErrors
862 {
863 public:
864  BoardVariations(char *, int);
865  void DrawLines();
866  int GetNpoints() { return this->fNpoints; }
867  double *GetX() { return this->fX; }
868  double *GetY() { return this->fY; }
869  float maxx, maxy, minx, miny;
870 };
871 
873 {
874 
875  cout << "In BoardVariations infile: " << infile << " detector " << det << endl;
876 
877  // ofstream txtfile(Form("BoardVar_%i.txt",det),ios::out);
878 
879  float t0, dt0, bindex;
880 
881  minx = 0;
882  maxx = 289;
883  miny = 100;
884  maxy = -25;
885  if (abs(det) == 2)
886  maxx = 449;
887 
888  this->SetName(Form("BoardT0Var_%i", det));
889 
890  unique_ptr<TFile> file(new TFile(infile));
891 
892  file->cd();
893  TNtuple *Boardtuple = (TNtuple *)file->Get("Board_Artuple");
894  TNtuple *BoardtupleXe = (TNtuple *)file->Get("Boardtuple");
895  Boardtuple->SetBranchAddress("t0", &t0);
896  Boardtuple->SetBranchAddress("dt0", &dt0);
897  if (abs(det) == 2)
898  {
899  BoardtupleXe->SetBranchAddress("t0", &t0);
900  BoardtupleXe->SetBranchAddress("dt0", &dt0);
901  }
902 
903  int ipnt = 0;
904  if (abs(det) == 1)
905  {
906  for (int imod = 0; imod < 32; imod++)
907  {
908  for (int ibrd = 0; ibrd < 9; ibrd++)
909  {
910 
911  bindex = 9 * imod + ibrd;
912 
913  Boardtuple->Draw(">>tmplist", Form("brd==%i && det==%i && mod==%i", ibrd, det, imod));
914  TEventList *elist = (TEventList *)gDirectory->Get("tmplist");
915  for (int ib = 0; ib < elist->GetN(); ib++)
916  {
917  ipnt++;
918  Boardtuple->GetEntry(elist->GetEntry(ib));
919 
920  if (t0 < miny)
921  miny = t0;
922  if (t0 > maxy)
923  maxy = t0;
924  this->SetPoint(ipnt, bindex + 1, t0);
925  this->SetPointError(ipnt, 0, dt0);
926 
927  // txtfile << det << " " << bindex << " " << t0 << endl;
928  // txtfile << det << " " << bindex << " t0 " << t0 << " ibrd "<<ibrd<<" det "<<det<<" imod "<<imod<<endl;
929  }
930  }
931  }
932  }
933  else if (abs(det) == 2)
934  {
935  for (int imod = 0; imod < 32; imod++)
936  {
937  for (int ilay = 0; ilay < 14; ilay++)
938  {
939 
940  bindex = 14 * imod + ilay;
941 
942  Boardtuple->Draw(">>tmplist1", Form("lay==%i && det==%i && mod==%i", ilay, det, imod));
943  TEventList *elist = (TEventList *)gDirectory->Get("tmplist1");
944  for (int ib = 0; ib < elist->GetN(); ib++)
945  {
946  ipnt++;
947  Boardtuple->GetEntry(elist->GetEntry(ib));
948  this->SetPoint(ipnt, bindex + 1, t0);
949  this->SetPointError(ipnt, 0, dt0);
950  if (t0 < miny)
951  miny = t0;
952  if (t0 > maxy)
953  maxy = t0;
954  // txtfile << det << " " << bindex << " " << t0 << endl;
955  }
956 
957  BoardtupleXe->Draw(">>tmplistXe", Form("lay==%i && det==%i && mod==%i", ilay, det, imod));
958  elist = (TEventList *)gDirectory->Get("tmplistXe");
959  for (int ib = 0; ib < elist->GetN(); ib++)
960  {
961  ipnt++;
962  BoardtupleXe->GetEntry(elist->GetEntry(ib));
963  this->SetPoint(ipnt, bindex + 1, t0);
964  this->SetPointError(ipnt, 0, dt0);
965  if (t0 < miny)
966  miny = t0;
967  if (t0 > maxy)
968  maxy = t0;
969  // txtfile << det << " " << bindex << " " << t0 << endl;
970  }
971  }
972  }
973  }
974 
975  this->fMaximum = maxy;
976  this->fMinimum = miny;
977  if (det == 1)
978  {
979  this->SetTitle("Barrel Board T0s A side");
980  }
981  else if (det == -1)
982  {
983  this->SetTitle("Barrel Board T0s C side");
984  }
985  else if (det == 2)
986  {
987  this->SetTitle("Endcap Board T0s A side");
988  }
989  else if (det == -2)
990  {
991  this->SetTitle("Endcap Board T0s C side");
992  }
993 
994  this->SetLineColor(4);
995  this->RemovePoint(0);
996 
997  file->Close();
998  // txtfile.close();
999  cout << " found " << ipnt << " board t0s " << endl;
1000  // this->Print();
1001 }
1002 
1004 {
1005 
1006  this->GetYaxis()->SetTitle("T0_{board} / ns");
1007  this->GetXaxis()->SetTitle("board #");
1008  this->GetYaxis()->SetRangeUser(-0.1 + miny, 0.1 + maxy);
1009  // Increased range from 7-14 to 0-20 (PH Sept 2022))
1010  this->GetYaxis()->SetRangeUser(0.0, 20.0);
1011  miny = 0.0;
1012  maxy = 20.0;
1013  this->GetXaxis()->SetRangeUser(minx, maxx);
1014  this->Draw("AL");
1015  int nb = 9;
1016  if (maxx > 14)
1017  nb = 14;
1018  for (int imod = 1; imod <= (floor(int(maxx) / nb)); imod++)
1019  {
1020  TLine *lin = new TLine((float)imod * nb + 0.5, miny, (float)imod * nb + 0.5, maxy);
1021  lin->SetLineStyle(2);
1022  lin->Draw();
1023  }
1024 }
1025 
1026 //================================================================
1027 
1028 class BoardVariationsDiff : public TGraphErrors
1029 {
1030 public:
1031  BoardVariationsDiff(char *, char *, int);
1032  void DrawLines();
1033  int GetNpoints() { return this->fNpoints; }
1034  double *GetX() { return this->fX; }
1035  double *GetY() { return this->fY; }
1036  float maxx, maxy, minx, miny;
1037 };
1038 
1039 BoardVariationsDiff::BoardVariationsDiff(char *infile_data, char *infile_ref, int det)
1040 {
1041 
1042  cout << "In BoardVariationsDiff infile_data: " << string(infile_data) << " infile_ref: " << string(infile_ref) << " detector " << det << endl;
1043 
1044  // ofstream txtfile(Form("BoardVarDiff_%i.txt",det),ios::out);
1045 
1046  float t0, dt0, oldt0, bindex;
1047 
1048  minx = 0;
1049  maxx = 289;
1050  miny = 1000;
1051  maxy = -1000;
1052  if (abs(det) == 2)
1053  maxx = 449;
1054 
1055  this->SetName(Form("BoardT0VarDiff_%i", det));
1056 
1057  unique_ptr<TFile> filedata(new TFile(infile_data));
1058  unique_ptr<TFile> fileref(new TFile(infile_ref));
1059 
1060  filedata->cd();
1061  TNtuple *Boardtuple_data = (TNtuple *)filedata->Get("Board_Artuple");
1062  fileref->cd();
1063  TNtuple *Boardtuple_ref = (TNtuple *)fileref->Get("Board_Artuple");
1064 
1065  Boardtuple_data->SetBranchAddress("t0", &t0);
1066  Boardtuple_data->SetBranchAddress("dt0", &dt0);
1067  Boardtuple_ref->SetBranchAddress("oldt0", &oldt0);
1068 
1069  int ipnt = 0;
1070  for (int imod = 0; imod < 32; imod++)
1071  {
1072  for (int ibrd = 0; ibrd < 9; ibrd++)
1073  {
1074 
1075  bindex = 9 * imod + ibrd;
1076 
1077  Boardtuple_data->Draw(">>tmplist", Form("brd==%i && det==%i && mod==%i", ibrd, det, imod));
1078  TEventList *elist = (TEventList *)gDirectory->Get("tmplist");
1079  for (int ib = 0; ib < elist->GetN(); ib++)
1080  {
1081  ipnt++;
1082  Boardtuple_data->GetEntry(elist->GetEntry(ib));
1083  Boardtuple_ref->GetEntry(elist->GetEntry(ib));
1084  if ((t0 - oldt0) < miny)
1085  miny = t0 - oldt0;
1086  if ((t0 - oldt0) > maxy)
1087  maxy = t0 - oldt0;
1088  this->SetPoint(ipnt, bindex + 1, t0 - oldt0);
1089  this->SetPointError(ipnt, 0, dt0);
1090  // txtfile << det << " " << bindex << " " << t0-oldt0 << endl;
1091  }
1092  }
1093  }
1094 
1095  // Increased margin from 0.1 to 0.2 (PH Sept 2022)
1096  this->fMaximum = maxy + 0.2;
1097  this->fMinimum = miny - 0.2;
1098  if ((det + 1)>=3){
1099  throw std::runtime_error("detlet[det + 1] is out of bounds");
1100  }
1101  this->SetTitle(Form("Board T0 - ref (%c-side)", detlet[det + 1]));
1102  this->SetLineColor(4);
1103  this->RemovePoint(0);
1104 
1105  filedata->Close();
1106 
1107  cout << " found " << ipnt << " board t0s " << endl;
1108  // this->Print();
1109 }
1110 
1112 {
1113 
1114  this->GetYaxis()->SetTitle("T0_{board}-ref / ns");
1115  this->GetXaxis()->SetTitle("board #");
1116  // Increased margin from 0.1 to 0.2 (PH Sept 2022)
1117  this->GetYaxis()->SetRangeUser(-0.2 + miny, 0.2 + maxy);
1118  this->GetXaxis()->SetRangeUser(minx, maxx);
1119  this->Draw("AP");
1120  int nb = 9;
1121  if (maxx > 300)
1122  nb = 14;
1123  TLine *lin = new TLine(minx, 0, maxx, 0);
1124  lin->SetLineColor(2);
1125  lin->Draw();
1126  for (int imod = 1; imod <= (floor(int(maxx) / nb)); imod++)
1127  {
1128  TLine *lin = new TLine((float)imod * nb + 0.5, this->fMinimum, (float)imod * nb + 0.5, this->fMaximum);
1129  lin->SetLineStyle(2);
1130  lin->Draw();
1131  }
1132 }
1133 
1134 //================================================================
1135 
1136 class BoardVariationsOldT0 : public TGraph
1137 {
1138 public:
1139  BoardVariationsOldT0(char *, int);
1140  void DrawLines();
1141  int GetNpoints() { return this->fNpoints; }
1142  double *GetX() { return this->fX; }
1143  double *GetY() { return this->fY; }
1144  float maxx, maxy, minx, miny;
1145 };
1146 
1148 {
1149 
1150  cout << "In BoardVariationsOldT0 infile: " << string(infile) << " detector " << det << endl;
1151 
1152  // ofstream txtfile(Form("BoardOldT0Var_%i.txt",det),ios::out);
1153 
1154  float oldt0, bindex;
1155 
1156  minx = 0;
1157  maxx = 289;
1158  miny = 100;
1159  maxy = -25;
1160  if (abs(det) == 2)
1161  maxx = 449;
1162 
1163  this->SetName(Form("BoardOldT0Var_%i", det));
1164 
1165  unique_ptr<TFile> file(new TFile(infile));
1166 
1167  file->cd();
1168  TNtuple *Boardtuple = (TNtuple *)file->Get("Board_Artuple");
1169  TNtuple *BoardtupleXe = (TNtuple *)file->Get("Boardtuple");
1170 
1171  Boardtuple->SetBranchAddress("oldt0", &oldt0);
1172  if (abs(det) == 2)
1173  BoardtupleXe->SetBranchAddress("oldt0", &oldt0);
1174 
1175  int ipnt = 0;
1176  if (abs(det) == 1)
1177  {
1178 
1179  for (int imod = 0; imod < 32; imod++)
1180  {
1181  for (int ibrd = 0; ibrd < 9; ibrd++)
1182  {
1183 
1184  bindex = 9 * imod + ibrd;
1185 
1186  Boardtuple->Draw(">>tmplist", Form("brd==%i && det==%i && mod==%i", ibrd, det, imod));
1187  TEventList *elist = (TEventList *)gDirectory->Get("tmplist");
1188  for (int ib = 0; ib < elist->GetN(); ib++)
1189  {
1190  ipnt++;
1191  Boardtuple->GetEntry(elist->GetEntry(ib));
1192  if (oldt0 < miny)
1193  miny = oldt0;
1194  if (oldt0 > maxy)
1195  maxy = oldt0;
1196  this->SetPoint(ipnt, bindex + 1, oldt0);
1197  // txtfile << det << " " << bindex << " " << oldt0 << endl;
1198  }
1199  }
1200  }
1201  }
1202  else if (abs(det) == 2)
1203  {
1204  for (int imod = 0; imod < 32; imod++)
1205  {
1206  for (int ilay = 0; ilay < 14; ilay++)
1207  {
1208 
1209  bindex = 14 * imod + ilay;
1210 
1211  Boardtuple->Draw(">>tmplist1", Form("lay==%i && det==%i && mod==%i", ilay, det, imod));
1212  TEventList *elist = (TEventList *)gDirectory->Get("tmplist1");
1213  for (int ib = 0; ib < elist->GetN(); ib++)
1214  {
1215  ipnt++;
1216  Boardtuple->GetEntry(elist->GetEntry(ib));
1217  this->SetPoint(ipnt, bindex + 1, oldt0);
1218  if (oldt0 < miny)
1219  miny = oldt0;
1220  if (oldt0 > maxy)
1221  maxy = oldt0;
1222  // txtfile << det << " " << bindex << " " << t0 << endl;
1223  }
1224 
1225  BoardtupleXe->Draw(">>tmplistXe", Form("lay==%i && det==%i && mod==%i", ilay, det, imod));
1226  elist = (TEventList *)gDirectory->Get("tmplistXe");
1227  for (int ib = 0; ib < elist->GetN(); ib++)
1228  {
1229  ipnt++;
1230  BoardtupleXe->GetEntry(elist->GetEntry(ib));
1231  this->SetPoint(ipnt, bindex + 1, oldt0);
1232  if (oldt0 < miny)
1233  miny = oldt0;
1234  if (oldt0 > maxy)
1235  maxy = oldt0;
1236  // txtfile << det << " " << bindex << " " << t0 << endl;
1237  }
1238  }
1239  }
1240  }
1241 
1242  this->fMaximum = maxy;
1243  this->fMinimum = miny;
1244 
1245  if (abs(det) == 1)
1246  {
1247  this->SetTitle(Form("Barrel Board T0s (%c-side)", detlet[det + 1]));
1248  }
1249  else
1250  {
1251  if ((det + 1)>=3){
1252  throw std::runtime_error("detlet[det + 1] is out of bounds");
1253  }
1254  this->SetTitle(Form("Endcap Board T0s (%c-side)", detlet[det + 1]));
1255  }
1256  this->SetLineColor(4);
1257  this->RemovePoint(0);
1258 
1259  this->GetYaxis()->SetRangeUser(9, 10.7);
1260 
1261  file->Close();
1262  // txtfile.close();
1263  cout << " found " << ipnt << " board t0s " << endl;
1264  // this->Print();
1265 }
1266 
1268 {
1269 
1270  this->GetYaxis()->SetTitle("T0_{board} / ns");
1271  this->GetXaxis()->SetTitle("board #");
1272  // Increased range from 9-10.6 to 5-15 (PH Sept 2022)
1273  miny = 5.0;
1274  maxy = 15.0;
1275  this->GetYaxis()->SetRangeUser(miny, maxy);
1276  this->GetXaxis()->SetRangeUser(minx, maxx);
1277  this->Draw("AL");
1278  int nb = 9;
1279  if (maxx > 300)
1280  nb = 14;
1281  for (int imod = 1; imod <= (floor(int(maxx) / nb)); imod++)
1282  {
1283  TLine *lin = new TLine((float)imod * nb + 0.5, miny, (float)imod * nb + 0.5, maxy);
1284  lin->SetLineStyle(2);
1285  lin->Draw();
1286  }
1287 }
1288 
1289 //================================================================
1290 // Board distributions for time residual
1291 
1292 class BoardVariationsRes : public TGraphErrors
1293 {
1294 public:
1295  BoardVariationsRes(char *, int);
1296  void DrawLines();
1297  int GetNpoints() { return this->fNpoints; }
1298  double *GetX() { return this->fX; }
1299  double *GetY() { return this->fY; }
1300  float maxx, maxy, minx, miny;
1301 };
1302 
1304 {
1305 
1306  // ofstream txtfile(Form("BoardVarRes_%i.txt",det),ios::out);
1307 
1308  float t0{}, dt0{}, bindex{};
1309 
1310  minx = 0;
1311  maxx = 289;
1312  miny = 100;
1313  maxy = -100;
1314  if (abs(det) == 2)
1315  maxx = 449;
1316 
1317  this->SetName(Form("BoardResVar_%i", det));
1318 
1319  unique_ptr<TFile> file(new TFile(infile));
1320  cout << "In BoardVariationsRes infile: " << string(infile) << " detector " << det << endl;
1321 
1322  file->cd();
1323 
1324  TNtuple *BoardtupleRes = (TNtuple *)file->Get("Board_Artuple");
1325  TNtuple *BoardtupleXe = (TNtuple *)file->Get("Boardtuple");
1326 
1327  BoardtupleRes->SetBranchAddress("res", &t0);
1328  BoardtupleRes->SetBranchAddress("dres", &dt0);
1329  if (abs(det) == 2)
1330  {
1331  BoardtupleXe->SetBranchAddress("res", &t0);
1332  BoardtupleXe->SetBranchAddress("dres", &dt0);
1333  }
1334 
1335  int ipnt = 0;
1336  if (abs(det) == 1)
1337  {
1338  for (int imod = 0; imod < 32; imod++)
1339  {
1340  for (int ibrd = 0; ibrd < 9; ibrd++)
1341  {
1342 
1343  bindex = 9 * imod + ibrd;
1344 
1345  BoardtupleRes->Draw(">>tmplist", Form("brd==%i && det==%i && mod==%i", ibrd, det, imod));
1346  TEventList *elist = (TEventList *)gDirectory->Get("tmplist");
1347  for (int ib = 0; ib < elist->GetN(); ib++)
1348  {
1349  ipnt++;
1350  BoardtupleRes->GetEntry(elist->GetEntry(ib));
1351  // cout << bindex+1 << " " << t0 << " " << dt0 << endl;
1352  if (t0 < miny)
1353  miny = t0;
1354  if (t0 > maxy)
1355  maxy = t0;
1356  this->SetPoint(ipnt, bindex + 1, t0);
1357  this->SetPointError(ipnt, 0, dt0);
1358  // txtfile << det << " " << bindex << " " << t0 << endl;
1359  }
1360  }
1361  }
1362  }
1363  else if (abs(det) == 2)
1364  {
1365  for (int imod = 0; imod < 32; imod++)
1366  {
1367  for (int ilay = 0; ilay < 14; ilay++)
1368  {
1369 
1370  bindex = 14 * imod + ilay;
1371 
1372  BoardtupleRes->Draw(">>tmplist1", Form("lay==%i && det==%i && mod==%i", ilay, det, imod));
1373  TEventList *elist = (TEventList *)gDirectory->Get("tmplist1");
1374  for (int ib = 0; ib < elist->GetN(); ib++)
1375  {
1376  ipnt++;
1377  BoardtupleRes->GetEntry(elist->GetEntry(ib));
1378  this->SetPoint(ipnt, bindex + 1, t0);
1379  this->SetPointError(ipnt, 0, dt0);
1380  if (t0 < miny)
1381  miny = t0;
1382  if (t0 > maxy)
1383  maxy = t0;
1384  // txtfile << det << " " << bindex << " " << t0 << endl;
1385  }
1386 
1387  BoardtupleXe->Draw(">>tmplistXe", Form("lay==%i && det==%i && mod==%i", ilay, det, imod));
1388  elist = (TEventList *)gDirectory->Get("tmplistXe");
1389  for (int ib = 0; ib < elist->GetN(); ib++)
1390  {
1391  ipnt++;
1392  BoardtupleXe->GetEntry(elist->GetEntry(ib));
1393  this->SetPoint(ipnt, bindex + 1, t0);
1394  this->SetPointError(ipnt, 0, dt0);
1395  if (t0 < miny)
1396  miny = t0;
1397  if (t0 > maxy)
1398  maxy = t0;
1399  // txtfile << det << " " << bindex << " " << t0 << endl;
1400  }
1401  }
1402  }
1403  }
1404 
1405  if (det == 1)
1406  {
1407  this->SetTitle("Barrel Board Residuals A side");
1408  }
1409  else if (det == -1)
1410  {
1411  this->SetTitle("Barrel Board Residuals C side");
1412  }
1413  else if (det == 2)
1414  {
1415  this->SetTitle("Endcap Board Residuals A side");
1416  }
1417  else if (det == -2)
1418  {
1419  this->SetTitle("Endcap Board Residuals C side");
1420  }
1421  this->SetLineColor(4);
1422  this->RemovePoint(0);
1423  this->fMaximum = 0.200;
1424  this->fMinimum = 0.100;
1425 
1426  file->Close();
1427  // txtfile.close();
1428  cout << " found " << ipnt << " board t0s " << endl;
1429  // this->Print();
1430 }
1431 
1433 {
1434 
1435  this->GetYaxis()->SetTitle("Residual{board} / um");
1436  this->GetXaxis()->SetTitle("board #");
1437  miny = 0.100;
1438  maxy = 0.200;
1439  this->GetYaxis()->SetRangeUser(miny, maxy);
1440  this->GetXaxis()->SetRangeUser(minx, maxx);
1441  this->Draw("AL");
1442  int nb = 9;
1443  if (maxx > 300)
1444  nb = 14;
1445  for (int imod = 1; imod <= (floor(int(maxx) / nb)); imod++)
1446  {
1447  TLine *lin = new TLine((float)imod * nb + 0.5, miny, (float)imod * nb + 0.5, maxy);
1448  lin->SetLineStyle(2);
1449  lin->Draw();
1450  }
1451 }
1452 
1453 //================================================================
1454 // DO board distributions for Sigma time residual
1455 
1456 class BoardVariationsTRes1 : public TGraphErrors
1457 {
1458 public:
1459  BoardVariationsTRes1(char *, int);
1460  void DrawLines();
1461  int GetNpoints() { return this->fNpoints; }
1462  double *GetX() { return this->fX; }
1463  double *GetY() { return this->fY; }
1464  float maxx, maxy, minx, miny;
1465 };
1466 
1468 {
1469 
1470  // ofstream txtfile(Form("BoardVarTRes1_%i.txt",det),ios::out);
1471 
1472  cout << "In BoardVariationsTRes1 infile: " << string(infile) << " detector " << det << endl;
1473 
1474  float t0{}, oldt0{}, dt0{}, bindex{}, t0offset{};
1475 
1476  minx = 0;
1477  maxx = 289;
1478  miny = 100;
1479  maxy = -100;
1480  if (abs(det) == 2)
1481  maxx = 449;
1482 
1483  this->SetName(Form("BoardT0Var_%i", det));
1484 
1485  unique_ptr<TFile> file(new TFile(infile));
1486 
1487  file->cd();
1488  TNtuple *BoardtupleTRes = (TNtuple *)file->Get("Board_Artuple");
1489  TNtuple *BoardtupleXe = (TNtuple *)file->Get("Boardtuple");
1490 
1491  BoardtupleTRes->SetBranchAddress("t0", &t0);
1492  BoardtupleTRes->SetBranchAddress("oldt0", &oldt0);
1493  BoardtupleTRes->SetBranchAddress("dt0", &dt0);
1494  BoardtupleTRes->SetBranchAddress("t0offset", &t0offset);
1495  if (abs(det) == 2)
1496  {
1497  BoardtupleXe->SetBranchAddress("t0", &t0);
1498  BoardtupleXe->SetBranchAddress("oldt0", &oldt0);
1499  BoardtupleXe->SetBranchAddress("dt0", &dt0);
1500  BoardtupleXe->SetBranchAddress("t0offset", &t0offset);
1501  }
1502 
1503  int ipnt = 0;
1504  if (abs(det) == 1)
1505  {
1506  for (int imod = 0; imod < 32; imod++)
1507  {
1508  for (int ibrd = 0; ibrd < 9; ibrd++)
1509  {
1510 
1511  bindex = 9 * imod + ibrd;
1512 
1513  BoardtupleTRes->Draw(">>tmplist", Form("brd==%i && det==%i && mod==%i", ibrd, det, imod));
1514  TEventList *elist = (TEventList *)gDirectory->Get("tmplist");
1515  for (int ib = 0; ib < elist->GetN(); ib++)
1516  {
1517  ipnt++;
1518  BoardtupleTRes->GetEntry(elist->GetEntry(ib));
1519  if ((t0 - oldt0) < miny)
1520  miny = t0 - oldt0;
1521  if ((t0 - oldt0) > maxy)
1522  maxy = t0 - oldt0;
1523  this->SetPoint(ipnt, bindex + 1, t0 - oldt0);
1524  this->SetPointError(ipnt, 0, dt0);
1525  // txtfile << det << " " << bindex << " " << t0-oldt0 << endl;
1526  }
1527  }
1528  }
1529  }
1530  else if (abs(det) == 2)
1531  {
1532  for (int imod = 0; imod < 32; imod++)
1533  {
1534  for (int ilay = 0; ilay < 14; ilay++)
1535  {
1536 
1537  bindex = 14 * imod + ilay;
1538 
1539  BoardtupleTRes->Draw(">>tmplist1", Form("lay==%i && det==%i && mod==%i", ilay, det, imod));
1540  TEventList *elist = (TEventList *)gDirectory->Get("tmplist1");
1541  for (int ib = 0; ib < elist->GetN(); ib++)
1542  {
1543  ipnt++;
1544  BoardtupleTRes->GetEntry(elist->GetEntry(ib));
1545  if ((t0 - oldt0) < miny)
1546  miny = t0 - oldt0;
1547  if ((t0 - oldt0) > maxy)
1548  maxy = t0 - oldt0;
1549  this->SetPoint(ipnt, bindex + 1, t0 - oldt0);
1550  this->SetPointError(ipnt, 0, dt0);
1551  // txtfile << det << " " << bindex << " " << t0-oldt0 << endl;
1552  }
1553 
1554  BoardtupleXe->Draw(">>tmplistXe", Form("lay==%i && det==%i && mod==%i", ilay, det, imod));
1555  elist = (TEventList *)gDirectory->Get("tmplistXe");
1556  for (int ib = 0; ib < elist->GetN(); ib++)
1557  {
1558  ipnt++;
1559  BoardtupleXe->GetEntry(elist->GetEntry(ib));
1560  if ((t0 - oldt0) < miny)
1561  miny = t0 - oldt0;
1562  if ((t0 - oldt0) > maxy)
1563  maxy = t0 - oldt0;
1564  this->SetPoint(ipnt, bindex + 1, t0 - oldt0);
1565  this->SetPointError(ipnt, 0, dt0);
1566  // txtfile << det << " " << bindex << " " << t0-oldt0 << endl;
1567  }
1568  }
1569  }
1570  }
1571 
1572  if (det == 1)
1573  {
1574  this->SetTitle("Barrel Board T0 Difference (A side)");
1575  }
1576  else if (det == -1)
1577  {
1578  this->SetTitle("Barrel Board T0 Difference (C side)");
1579  }
1580  else if (det == 2)
1581  {
1582  this->SetTitle("Endcap Board T0 Difference (A side)");
1583  }
1584  else if (det == -2)
1585  {
1586  this->SetTitle("Endcap Board T0 Difference (C side)");
1587  }
1588  this->SetLineColor(4);
1589  this->RemovePoint(0);
1590  this->GetYaxis()->SetRangeUser(9, 10.7);
1591 
1592  file->Close();
1593  // txtfile.close();
1594  cout << " found " << ipnt << " board t0s " << endl;
1595  // this->Print();
1596 }
1597 
1599 {
1600 
1601  this->GetYaxis()->SetTitle("Board T0 Difference / ns");
1602  this->GetXaxis()->SetTitle("board #");
1603  // Increased range from -0.5 - 0.5 to -1 - 1 (PH)
1604  miny = -1.5;
1605  maxy = 1.5;
1606  this->GetYaxis()->SetRangeUser(miny, maxy);
1607  this->GetXaxis()->SetRangeUser(minx, maxx);
1608  this->Draw("AL");
1609  TLine *lin = new TLine(minx, 0, maxx, 0);
1610  lin->Draw();
1611  TLine *lin1 = new TLine(minx, 0.3, maxx, 0.3);
1612  lin1->SetLineStyle(2);
1613  lin1->Draw();
1614  TLine *lin2 = new TLine(minx, -0.3, maxx, -0.3);
1615  lin2->SetLineStyle(2);
1616  lin2->Draw();
1617  // int nb=9;
1618  // if(maxx>300) nb=14;
1619  for (int imod = 1; imod <= (floor(int(maxx) / 9)); imod++)
1620  { // need to change the upper limit for both board and
1621  // barrel T0 differences
1622  TLine *lin = new TLine((float)imod * 9 + 0.5, miny, (float)imod * 9 + 0.5, maxy);
1623  lin->SetLineStyle(2);
1624  lin->Draw();
1625  }
1626 }
1627 
1628 //================================================================
1629 // DO board distributions for Sigma time residual
1630 
1631 class BoardVariationsTRes : public TGraphErrors
1632 {
1633 public:
1634  BoardVariationsTRes(char *, int);
1635  void DrawLines();
1636  int GetNpoints() { return this->fNpoints; }
1637  double *GetX() { return this->fX; }
1638  double *GetY() { return this->fY; }
1639  float maxx, maxy, minx, miny;
1640 };
1641 
1643 {
1644 
1645  // ofstream txtfile(Form("BoardVarTRes_%i.txt",det),ios::out);
1646 
1647  float t0, dt0, bindex;
1648 
1649  minx = 0;
1650  maxx = 289;
1651  miny = 100;
1652  maxy = -100;
1653  if (abs(det) == 2)
1654  maxx = 449;
1655 
1656  this->SetName(Form("BoardT0Var_%i", det));
1657 
1658  unique_ptr<TFile> file(new TFile(infile));
1659 
1660  cout << "In BoardVariationsTRes infile: " << string(infile) << " detector " << det << endl;
1661  file->cd();
1662  TNtuple *BoardtupleTRes = (TNtuple *)file->Get("Board_Artuple");
1663  TNtuple *BoardtupleXe = (TNtuple *)file->Get("Boardtuple");
1664 
1665  BoardtupleTRes->SetBranchAddress("tres", &t0);
1666  BoardtupleTRes->SetBranchAddress("dres", &dt0);
1667  if (abs(det) == 2)
1668  {
1669  BoardtupleXe->SetBranchAddress("tres", &t0);
1670  BoardtupleXe->SetBranchAddress("dres", &dt0);
1671  }
1672 
1673  int ipnt = 0;
1674  if (abs(det) == 1)
1675  {
1676  for (int imod = 0; imod < 32; imod++)
1677  {
1678  for (int ibrd = 0; ibrd < 9; ibrd++)
1679  {
1680 
1681  bindex = 9 * imod + ibrd;
1682 
1683  BoardtupleTRes->Draw(">>tmplist", Form("brd==%i && det==%i && mod==%i", ibrd, det, imod));
1684  TEventList *elist = (TEventList *)gDirectory->Get("tmplist");
1685  for (int ib = 0; ib < elist->GetN(); ib++)
1686  {
1687  ipnt++;
1688  BoardtupleTRes->GetEntry(elist->GetEntry(ib));
1689  this->SetPoint(ipnt, bindex + 1, t0);
1690  this->SetPointError(ipnt, 0, dt0);
1691  if (t0 < miny)
1692  miny = t0;
1693  if (t0 > maxy)
1694  maxy = t0;
1695  // txtfile << det << " " << bindex << " " << t0 << endl;
1696  }
1697  }
1698  }
1699  }
1700  else if (abs(det) == 2)
1701  {
1702  for (int imod = 0; imod < 32; imod++)
1703  {
1704  for (int ilay = 0; ilay < 14; ilay++)
1705  {
1706 
1707  bindex = 14 * imod + ilay;
1708 
1709  BoardtupleTRes->Draw(">>tmplist1", Form("lay==%i && det==%i && mod==%i", ilay, det, imod));
1710  TEventList *elist = (TEventList *)gDirectory->Get("tmplist1");
1711  for (int ib = 0; ib < elist->GetN(); ib++)
1712  {
1713  ipnt++;
1714  BoardtupleTRes->GetEntry(elist->GetEntry(ib));
1715  this->SetPoint(ipnt, bindex + 1, t0);
1716  this->SetPointError(ipnt, 0, dt0);
1717  if (t0 < miny)
1718  miny = t0;
1719  if (t0 > maxy)
1720  maxy = t0;
1721  // txtfile << det << " " << bindex << " " << t0 << endl;
1722  }
1723 
1724  BoardtupleXe->Draw(">>tmplistXe", Form("lay==%i && det==%i && mod==%i", ilay, det, imod));
1725  elist = (TEventList *)gDirectory->Get("tmplistXe");
1726  for (int ib = 0; ib < elist->GetN(); ib++)
1727  {
1728  ipnt++;
1729  BoardtupleXe->GetEntry(elist->GetEntry(ib));
1730  this->SetPoint(ipnt, bindex + 1, t0);
1731  this->SetPointError(ipnt, 0, dt0);
1732  if (t0 < miny)
1733  miny = t0;
1734  if (t0 > maxy)
1735  maxy = t0;
1736  // txtfile << det << " " << bindex << " " << t0 << endl;
1737  }
1738  }
1739  }
1740  }
1741 
1742  this->fMaximum = maxy;
1743  this->fMinimum = miny;
1744  if (abs(det) == 1)
1745  {
1746  // title set here, not sure why it doesnt work
1747  this->SetTitle(Form("Barrel Board Sigma Time Residuals (%c-side)", detlet[det + 1]));
1748  }
1749  else
1750  {
1751  if (det+1 >=3){
1752  throw std::out_of_range("Out-of-bounds access to the detlet array");
1753  }
1754  this->SetTitle(Form("Endcap Board Sigma Time Residuals (%c-side)", detlet[det + 1]));
1755  }
1756  this->SetLineColor(4);
1757  this->RemovePoint(0);
1758 
1759  file->Close();
1760  // txtfile.close();
1761  cout << " found " << ipnt << " board t0s " << endl;
1762  // this->Print();
1763 }
1764 
1766 {
1767 
1768  this->GetYaxis()->SetTitle("Board Sigma Time Residuals/ ns");
1769  this->GetXaxis()->SetTitle("board #");
1770  // Increased range from 3.0-3.7 to 1-5 (PH)
1771  miny = 1.0;
1772  maxy = 5.0;
1773  this->GetYaxis()->SetRangeUser(miny, maxy);
1774  this->GetXaxis()->SetRangeUser(minx, maxx);
1775  this->Draw("ALP");
1776  TLine *lin = new TLine(minx, 0, maxx, 0);
1777  lin->Draw();
1778  TLine *lin1 = new TLine(minx, 0.3, maxx, 0.3);
1779  lin1->SetLineStyle(2);
1780  lin1->Draw();
1781  TLine *lin2 = new TLine(minx, -0.3, maxx, -0.3);
1782  lin2->SetLineStyle(2);
1783  lin2->Draw();
1784  int nb = 9;
1785  if (maxx > 300)
1786  nb = 14;
1787  for (int imod = 1; imod <= (floor(int(maxx) / nb)); imod++)
1788  {
1789  TLine *lin = new TLine((float)imod * nb + 0.5, miny, (float)imod * nb + 0.5, maxy);
1790  lin->SetLineStyle(2);
1791  lin->Draw();
1792  }
1793 }
1794 
1795 //================================================================
1796 
1797 class DvGraph : public TGraph
1798 {
1799 public:
1800  DvGraph(char *, string, const string &, int, int, bool);
1801  // TH1F* hist;
1802  TGraph *rtgraph;
1803 };
1804 
1805 DvGraph::DvGraph(char *infile, string path, const string & folder, int det, int lay, bool isinverted)
1806 {
1807 
1808  this->SetName(Form("Dv_%i_%i", det, lay));
1809 
1810  vector<string> levels;
1811 
1812  while (true)
1813  {
1814  if (const auto f = path.find(','); f==std::string::npos ){
1815  break;
1816  } else {
1817  levels.push_back(path.substr(0, f));
1818  path.erase(f+1,std::string::npos);
1819  }
1820  }
1821  levels.push_back(path.substr(0, path.find(",")));
1822  cout << " In DvGraph folder: " << folder << " det " << det << " lay " << lay << endl;
1823  for (unsigned int i = 0; i < levels.size(); i++)
1824  cout << " " << levels.at(i);
1825  cout << endl;
1826 
1827  TFile *file = new TFile(infile);
1828  cout << infile << endl;
1829  file->cd();
1830 
1831  TDirectory *trt = (TDirectory *)file->FindKey("TRT_all")->ReadObj();
1832  if (folder != "")
1833  {
1834  TDirectory *thisdet = (TDirectory *)trt->FindKey(folder.c_str())->ReadObj();
1835  cout << "PLOT FOR " << folder << endl;
1836  if (thisdet->FindKey("rtgraph"))
1837  {
1838  rtgraph = (TGraphErrors *)thisdet->FindKey("rtgraph")->ReadObj();
1839  cout << "found rtgraph " << folder << endl;
1840  }
1841  else
1842  {
1843  rtgraph = nullptr;
1844  cout << "did not find rtgraph " << folder << endl;
1845  }
1846  }
1847  else if (trt->FindKey("rtgraph"))
1848  {
1849  rtgraph = (TGraphErrors *)trt->FindKey("rtgraph")->ReadObj();
1850  cout << "no folder, but found rtgraph " << folder << endl;
1851  }
1852  else
1853  {
1854  rtgraph = nullptr;
1855  cout << "no folder, no rtgraph " << folder << endl;
1856  }
1857 
1858  if (rtgraph)
1859  {
1860 
1861  TF1 *rtfunc = (TF1 *)rtgraph->GetListOfFunctions()->First();
1862 
1863  double p0 = rtfunc->GetParameter(0);
1864  double p1 = rtfunc->GetParameter(1);
1865  double p2 = rtfunc->GetParameter(2);
1866  double p3 = rtfunc->GetParameter(3);
1867 
1868  cout << " R-t PARAMETERS: " << p0 << " " << p1 << " " << p2 << " " << p3 << endl;
1869 
1870  bool isdines = false;
1871 
1872  if (isdines)
1873  {
1874  string vrrelation;
1875  if (isinverted)
1876  vrrelation = "x*[2]/sqrt([0]*[0]+x*x)";
1877  else
1878  vrrelation = "sqrt([0]*[0]+x*x)/(x*[2])";
1879 
1880  TF1 *vr1 = new TF1("vr-relation", vrrelation.c_str(), 0.0001, 2.0);
1881  vr1->SetParameters(p0, p1, p2);
1882 
1883  for (int i = 0; i <= 100; i++)
1884  {
1885  float r = 0.1 + (2.0 - 0.1) * (float)i / 100;
1886  float v1 = vr1->Eval(r, 0, 0, 0);
1887  this->SetPoint(i, r, v1);
1888  // cout << i << " " << r << " " << v1 << endl;
1889  }
1890 
1891  vr1->Delete();
1892  }
1893  else
1894  {
1895  cout << " USING POLYNOMIAL R-t RELATION" << endl;
1896 
1897  string rtrelation = "[0]+x*([1]+x*([2]+x*[3]))";
1898  string vtrelation;
1899  if (isinverted)
1900  vtrelation = "1/([0]+2*x*[1]+3*x*x*[2])";
1901  else
1902  vtrelation = "[0]+2*x*[1]+3*x*x*[2]";
1903 
1904  TF1 *rt1 = new TF1("rt-relation", rtrelation.c_str(), -10000, 10000);
1905  rt1->SetParameters(p0, p1, p2, p3);
1906  TF1 *vt1 = new TF1("vt-relation", vtrelation.c_str(), -10000, 10000);
1907  vt1->SetParameters(p1, p2, p3);
1908 
1909  for (int i = 0; i <= 100; i++)
1910  {
1911  float r = 0.1 + (2.0 - 0.1) * (float)i / 100;
1912  float t1 = rt1->GetX(r, -10000, 10000);
1913  float v1 = vt1->Eval(t1, 0, 0, 0);
1914  this->SetPoint(i, r, v1);
1915  // cout << i << " " << r << " " << t1 << " " << v1 << endl;
1916  }
1917 
1918  rt1->Delete();
1919  vt1->Delete();
1920  }
1921  }
1922 }
1923 
1924 //================================================================
1925 
1926 class DGraph : public TGraph
1927 {
1928 public:
1929  DGraph(char *, string, string, int, int, bool);
1930  // TH1F* hist;
1931  TGraph *rtgraph;
1932 };
1933 
1934 DGraph::DGraph(char *infile, string path, string folder, int det, int lay, bool isinverted)
1935 {
1936 
1937  this->SetName(Form("Dv_%i_%i", det, lay));
1938 
1939  vector<string> levels;
1940  while (true)
1941  {
1942  if (const auto f = path.find(','); f==std::string::npos ){
1943  break;
1944  } else {
1945  levels.push_back(path.substr(0, f));
1946  path.erase(0, f+1);
1947  }
1948  }
1949  levels.push_back(path.substr(0, path.find(',')));
1950 
1951  TFile *file = new TFile(infile);
1952  file->cd();
1953 
1954  cout << " In DGraph. Folder: " << folder << " det " << det << " lay " << lay << endl;
1955  for (unsigned int i = 0; i < levels.size(); i++)
1956  cout << " " << levels.at(i);
1957  cout << endl;
1958  cout << " infile:" << string(infile) << endl;
1959 
1960  TDirectory *trt = (TDirectory *)file->FindKey("TRT_all")->ReadObj();
1961  if (folder != "")
1962  {
1963  TDirectory *thisDet = (TDirectory *)trt->FindKey(folder.c_str())->ReadObj();
1964  cout << "PLOT FOR " << folder << endl;
1965  if (thisDet->FindKey("rtgraph"))
1966  {
1967  rtgraph = (TGraphErrors *)thisDet->FindKey("rtgraph")->ReadObj();
1968  cout << " folder: " << folder << " found rtgraph " << endl;
1969  }
1970  else
1971  {
1972  rtgraph = nullptr;
1973  cout << " folder: " << folder << " did not find rtgraph " << endl;
1974  }
1975  }
1976  else if (trt->FindKey("rtgraph"))
1977  {
1978  rtgraph = (TGraphErrors *)trt->FindKey("rtgraph")->ReadObj();
1979  cout << " no folder, found rtgraph " << endl;
1980  }
1981  else
1982  {
1983  rtgraph = nullptr;
1984  cout << " no folder, no rtgraph " << endl;
1985  }
1986 
1987  if (rtgraph)
1988  {
1989  TF1 *rtfunc = (TF1 *)rtgraph->GetListOfFunctions()->First();
1990 
1991  double p0 = rtfunc->GetParameter(0);
1992  double p1 = rtfunc->GetParameter(1);
1993  double p2 = rtfunc->GetParameter(2);
1994  double p3 = rtfunc->GetParameter(3);
1995 
1996  cout << " R-t PARAMETERS: " << p0 << " " << p1 << " " << p2 << " " << p3 << endl;
1997 
1998  bool isdines = false;
1999 
2000  if (isdines)
2001  {
2002 
2003  string vrrelation;
2004  if (isinverted)
2005  vrrelation = "x*[2]/sqrt([0]*[0]+x*x)";
2006  else
2007  vrrelation = "sqrt([0]*[0]+x*x)/(x*[2])";
2008 
2009  TF1 *vr1 = new TF1("vr-relation", vrrelation.c_str(), 0.0001, 2.0);
2010  vr1->SetParameters(p0, p1, p2);
2011 
2012  for (int i = 0; i <= 100; i++)
2013  {
2014  float r = 0.1 + (2.0 - 0.1) * (float)i / 100;
2015  float v1 = vr1->Eval(r, 0, 0, 0);
2016  this->SetPoint(i, r, v1);
2017  }
2018 
2019  vr1->Delete();
2020  }
2021  else
2022  {
2023  cout << " USING POLYNOMIAL R-t RELATION" << endl;
2024 
2025  string rtrelation = "[0]+x*([1]+x*([2]+x*[3]))";
2026  string vtrelation;
2027  if (isinverted)
2028  vtrelation = "1/([0]+2*x*[1]+3*x*x*[2])";
2029  else
2030  vtrelation = "[0]+2*x*[1]+3*x*x*[2]";
2031 
2032  TF1 *rt1 = new TF1("rt-relation", rtrelation.c_str(), -10000, 10000);
2033  rt1->SetParameters(p0, p1, p2, p3);
2034  TF1 *vt1 = new TF1("vt-relation", vtrelation.c_str(), -10000, 10000);
2035  vt1->SetParameters(p1, p2, p3);
2036 
2037  for (int i = 0; i <= 1000; i++)
2038  {
2039  float t1 = -5 + i * 0.05;
2040  float r1 = rt1->Eval(t1, 0, 0, 0);
2041  this->SetPoint(i, t1, r1);
2042  }
2043 
2044  rt1->Delete();
2045  vt1->Delete();
2046  }
2047  }
2048 }
2049 
2050 //================================================================
2051 
2052 class RtGraphs : public TCanvas
2053 {
2054 public:
2055  // RtGraphs(char*,int,int);
2056  RtGraphs(char *, const string& , bool);
2057  TH2F *rthist{};
2058  TGraphErrors *rtgraph{};
2059  TGraphErrors *trgraph{};
2060  TF1 *oldrtfunc{};
2061 };
2062 
2063 RtGraphs::RtGraphs(char *infile, const string & folder, bool isAr = false)
2064 {
2065 
2066  this->SetName(Form("Rt_%s", folder.c_str()));
2067 
2068  TFile *file = new TFile(infile);
2069  cout << "in RtGraphs. Infile: " << string(infile) << endl;
2070  file->cd();
2071  TDirectory *trt = nullptr;
2072 
2073  map<string, string> titlemap;
2074  if (!isAr)
2075  {
2076 
2077  trt = (TDirectory *)file->FindKey("TRT_all")->ReadObj();
2078  titlemap["WholeBarrel_1"] = "whole barrel";
2079  titlemap["Detector_-1"] = "barrel C";
2080  titlemap["Detector_1"] = "barrel A";
2081  titlemap["Detector_-2"] = "end-cap C";
2082  titlemap["Detector_2"] = "end-cap A";
2083  if (trt)
2084  cout << " Xenon. Found TRT_all " << endl;
2085  if (!trt)
2086  cout << " Xenon. Did not find TRT_all " << endl;
2087  }
2088 
2089  else
2090  {
2091 
2092  trt = (TDirectory *)file->FindKey("TRT_Ar_all")->ReadObj();
2093  titlemap["WholeBarrel_Ar_1"] = "whole Ar barrel";
2094  titlemap["Detector_Ar_-1"] = "barrel Ar C";
2095  titlemap["Detector_Ar_1"] = "barrel Ar A";
2096  titlemap["Detector_Ar_-2"] = "end-cap Ar C";
2097  titlemap["Detector_Ar_2"] = "end-cap Ar A";
2098  if (trt)
2099  cout << " Argon. Found TRT_Ar_all " << endl;
2100  if (!trt)
2101  cout << " Argon. Did not find TRT_Ar_all " << endl;
2102  }
2103 
2104  if (trt and (not folder.empty()))
2105  {
2106  cout << " PLOT FOR " << folder << endl;
2107  TDirectory *det = (TDirectory *)trt->FindKey(folder.c_str())->ReadObj();
2108  if (det->FindKey("rt-relation"))
2109  {
2110  cout << " found rt-relation " << endl;
2111  rthist = (TH2F *)det->FindKey("rt-relation")->ReadObj();
2112  this->cd();
2113  rthist->GetXaxis()->SetRangeUser(0, 40);
2114  char name[500];
2115  sprintf(name, "rt (%s)", titlemap[folder].c_str());
2116  rthist->SetTitle(name);
2117  if (det->FindKey("rtgraph"))
2118  {
2119  rtgraph = (TGraphErrors *)det->FindKey("rtgraph")->ReadObj();
2120  cout << " found also rtgraph " << endl;
2121  }
2122  else
2123  {
2124  rtgraph = nullptr;
2125  cout << " did not found rtgraph " << endl;
2126  }
2127  if (det->FindKey("trgraph"))
2128  {
2129  trgraph = (TGraphErrors *)det->FindKey("trgraph")->ReadObj();
2130  cout << " found also trgraph " << endl;
2131  }
2132  else
2133  {
2134  trgraph = nullptr;
2135  cout << " did not found trgraph " << endl;
2136  }
2137  if (det->FindKey("oldrtfunc"))
2138  {
2139  oldrtfunc = (TF1 *)det->FindKey("oldrtfunc")->ReadObj();
2140  cout << " found also oldrtfunc " << endl;
2141  }
2142  else
2143  {
2144  oldrtfunc = nullptr;
2145  cout << " did not find oldrtfunc " << endl;
2146  }
2147  }
2148  else
2149  {
2150  throw string(" NO RT OBJECTS FOUND");
2151  }
2152  }
2153  else if (trt and trt->FindKey("rt-relation"))
2154  {
2155  cout << " No folder. Found rt-relation. PLOT FOR TRT" << endl;
2156  rthist = (TH2F *)trt->FindKey("rt-relation")->ReadObj();
2157  this->cd();
2158  rthist->GetXaxis()->SetRangeUser(0, 40);
2159  rthist->SetTitle("r(t) for whole TRT");
2160  if (trt->FindKey("rtgraph"))
2161  {
2162  rtgraph = (TGraphErrors *)trt->FindKey("rtgraph")->ReadObj();
2163  cout << " found also rtgraph " << endl;
2164  }
2165  else
2166  {
2167  rtgraph = nullptr;
2168  cout << " did not find rtgraph " << endl;
2169  }
2170  if (trt->FindKey("trgraph"))
2171  {
2172  trgraph = (TGraphErrors *)trt->FindKey("trgraph")->ReadObj();
2173  cout << " found also trgraph " << endl;
2174  }
2175  else
2176  {
2177  trgraph = nullptr;
2178  cout << " did not find trgraph " << endl;
2179  }
2180  if (trt->FindKey("oldrtfunc"))
2181  {
2182  oldrtfunc = (TF1 *)trt->FindKey("oldrtfunc")->ReadObj();
2183  cout << " found also oldtrtfunc " << endl;
2184  }
2185  else
2186  {
2187  oldrtfunc = nullptr;
2188  cout << " did not find oldtrtfunc " << endl;
2189  }
2190  }
2191  else
2192  {
2193  cout << " No folder. No rt-relation." << endl;
2194  rthist = nullptr;
2195  rtgraph = nullptr;
2196  oldrtfunc = nullptr;
2197  }
2198 
2199  this->cd();
2200  this->Divide(2, 1, 0.01, 0.01);
2201  this->cd(1);
2202 
2203  TPad *c1_3 = new TPad("c1_3", "newpad", 0.01, 0.33, 0.99, 0.99);
2204  c1_3->Draw();
2205  c1_3->cd();
2206  c1_3->SetTopMargin(0.1);
2207  c1_3->SetBottomMargin(0.01);
2208  c1_3->SetRightMargin(0.1);
2209  c1_3->SetFillStyle(0);
2210  c1_3->SetGrid();
2211 
2212  if (rtgraph)
2213  {
2214  if (folder == "")
2215  {
2216  cout << " found rtgraph for entire TRT " << endl;
2217  rtgraph->SetTitle("r(t) fit (whole TRT)");
2218  }
2219  else
2220  {
2221  cout << " found rtgraph for folder: " << folder << endl;
2222  rtgraph->SetTitle(titlemap[folder].c_str());
2223  }
2224  cout << " set rtgraph X title t-T0/ns and Y title |r|_{track}/mm" << endl;
2225 
2226  rtgraph->GetXaxis()->SetTitle("t-T0/ns");
2227  rtgraph->GetYaxis()->SetTitle("|r|_{track}/mm");
2228  // rtgraph->GetYaxis()->SetRangeUser(0,2.7);
2229  rtgraph->GetXaxis()->SetTitleSize(0.06);
2230  rtgraph->GetXaxis()->SetLabelSize(0.06);
2231 
2232  // Blue line too wide, extract and plot again:
2233  rtgraph->SetMarkerStyle(20);
2234  rtgraph->SetMarkerSize(0.5);
2235  rtgraph->GetYaxis()->SetRangeUser(-0.05, 2.6);
2236  cout << " Draw rtgraph " << endl;
2237  rtgraph->Draw("ap");
2238  TF1 *newRT;
2239  if (rtgraph->GetFunction("rtfunc"))
2240  newRT = rtgraph->GetFunction("rtfunc");
2241  else
2242  newRT = rtgraph->GetFunction("rtfunc2");
2243  if (newRT)
2244  {
2245  cout << " Draw new fit " << endl;
2246  newRT->SetLineWidth(1);
2247  newRT->Draw("same");
2248  }
2249  if (oldrtfunc)
2250  {
2251  oldrtfunc->SetLineColor(1);
2252  oldrtfunc->SetLineWidth(1);
2253  oldrtfunc->SetLineStyle(2);
2254  cout << " Draw old fit " << endl;
2255  oldrtfunc->Draw("same");
2256  }
2257  // Legend
2258 
2259  TLegend *leg = new TLegend(0.7155172, 0.1038136, 0.8965517, 0.2542373, nullptr, "brNDC");
2260  leg->AddEntry(rtgraph, "Data", "p");
2261  leg->AddEntry(newRT, "Fit", "l");
2262  leg->AddEntry(oldrtfunc, "Fit old rt", "l");
2263  leg->SetTextSize(0.03);
2264  leg->Draw();
2265 
2266  // Plot the difference between old and new rt:
2267  if (oldrtfunc && newRT)
2268  {
2269  this->cd();
2270  this->cd(1);
2271  TPad *c1_4 = new TPad("c1_4", "newpad", 0.01, 0, 0.99, 0.32);
2272  c1_4->Draw();
2273  c1_4->cd();
2274  c1_4->SetTopMargin(0.01);
2275  c1_4->SetBottomMargin(0.3);
2276  c1_4->SetRightMargin(0.1);
2277  c1_4->SetFillStyle(0);
2278  c1_4->SetGrid();
2279 
2280  Double_t Xmax = rtgraph->GetXaxis()->GetXmax();
2281  Double_t Xmin = rtgraph->GetXaxis()->GetXmin();
2282 
2283  const Int_t n = 300;
2284  Double_t x[n], y[n], dx;
2285  dx = (Xmax - Xmin) / n;
2286 
2287  Double_t Ymax = -10;
2288  Double_t Ymin = 10;
2289 
2290  for (Int_t i = 0; i < n; i++)
2291  {
2292  x[i] = Xmin + i * dx;
2293  y[i] = (oldrtfunc->Eval(x[i]) - newRT->Eval(x[i]));
2294  if (y[i] > Ymax)
2295  Ymax = y[i];
2296  if (y[i] < Ymin)
2297  Ymin = y[i];
2298  }
2299 
2300  TGraph *gr1 = new TGraph(n, x, y);
2301 
2302  gr1->SetTitle("");
2303  gr1->GetXaxis()->SetTitle("t-T0/ns");
2304  gr1->GetXaxis()->SetRangeUser(Xmin, Xmax);
2305  gr1->GetYaxis()->SetTitle("Old r(t) - New r(t) /mm");
2306  gr1->GetYaxis()->SetRangeUser(-0.1, 0.1);
2307  // gr1->GetYaxis()->SetRangeUser(1.1*Ymin,1.1*Ymax);
2308  gr1->GetYaxis()->SetNdivisions(5);
2309  gr1->GetXaxis()->SetTitleSize(0.06);
2310  gr1->GetXaxis()->SetLabelSize(0.06);
2311  gr1->GetYaxis()->SetLabelSize(0.08);
2312  gr1->GetYaxis()->SetTitleOffset(0.8);
2313  gr1->GetYaxis()->SetTitleSize(0.06);
2314  gr1->SetLineStyle(2);
2315 
2316  // Also add the difference between the fit and the points of the fit
2317 
2318  const Int_t n1 = rtgraph->GetN();
2319  std::vector<Double_t> x1(n1, 0), y1(n1, 0), ex1(n1, 0), ey1(n1, 0);
2320  Double_t X, Y;
2321 
2322  for (Int_t i = 0; i < n1; i++)
2323  {
2324  X = 0;
2325  Y = 0;
2326  rtgraph->GetPoint(i, X, Y);
2327  x1.at(i) = X;
2328  y1.at(i) = Y - newRT->Eval(X);
2329  ex1.at(i) = 0;
2330  ey1.at(i) = rtgraph->GetErrorY(i);
2331  if (y1.at(i) > Ymax)
2332  {
2333  Ymax = y1.at(i);
2334  }
2335  if (y1.at(i) < Ymin)
2336  {
2337  Ymin = y1.at(i);
2338  }
2339  }
2340 
2341  TGraphErrors *gr2 = new TGraphErrors(n1, &x1.at(0), &y1.at(0), &ex1.at(0), &ey1.at(0));
2342  gr2->SetMarkerColor(2);
2343  gr2->SetMarkerStyle(20);
2344  gr2->SetTitle("");
2345  gr2->GetYaxis()->SetTitle("Old r(t) - New r(t) /mm");
2346 
2347  gr2->GetYaxis()->SetRangeUser(-0.2, 0.2);
2348  gr2->GetXaxis()->SetRangeUser(-5, 50);
2349  cout << " Draw difference " << endl;
2350  gr2->Draw("ap");
2351  gr1->Draw("l");
2352 
2353  TLine *line0 = new TLine(Xmin, 0, Xmax, 0);
2354  line0->SetLineColor(4);
2355  line0->Draw();
2356  }
2357  }
2358  else
2359  {
2360  cout << " nullptr rtgraph " << endl;
2361  }
2362 
2363  this->cd(2);
2364  if (trgraph)
2365  {
2366 
2367  if (folder == "")
2368  trgraph->SetTitle("t(r) fit (whole TRT)");
2369  else
2370  {
2371  char name[500];
2372  sprintf(name, "t(r) fit (%s)", titlemap[string(std::move(folder))].c_str());
2373  trgraph->SetTitle(name);
2374  }
2375 
2376  trgraph->GetYaxis()->SetTitle("t-T0/ns");
2377  trgraph->GetXaxis()->SetTitle("|r|_{track}/mm");
2378  // trgraph->GetYaxis()->SetRangeUser(0,32);
2379  trgraph->SetMarkerStyle(20);
2380  trgraph->SetMarkerSize(0.5);
2381  cout << " Draw trgraph " << endl;
2382  trgraph->Draw("ap");
2383  }
2384  else
2385  {
2386  cout << " nullptr trgraph " << endl;
2387  }
2388 
2389  gStyle->SetOptStat(1);
2390 }
2391 
2392 //=================================================================
2393 
2394 class XYMapsEC : public TCanvas
2395 {
2396 public:
2397  XYMapsEC(char *, string, bool);
2398 };
2399 
2400 XYMapsEC::XYMapsEC(char *infile, string variable, bool isAr = false)
2401 {
2402 
2403  char selectionA[500];
2404  sprintf(selectionA, "%s*(det==2)", variable.c_str());
2405  char selectionC[500];
2406  sprintf(selectionC, "%s*(det==-2)", variable.c_str());
2407  if (variable == "nt0")
2408  variable = "n hits";
2409  TFile *file = new TFile(infile);
2410  // cout << infile << endl;
2411  file->cd();
2412  TNtuple *Chiptuple = nullptr;
2413  TNtuple *Moduletuple = nullptr;
2414 
2415  if (!isAr)
2416  {
2417  Chiptuple = (TNtuple *)file->Get("Chiptuple");
2418  Moduletuple = (TNtuple *)file->Get("Moduletuple");
2419  }
2420  else
2421  {
2422  Chiptuple = (TNtuple *)file->Get("Chip_Artuple");
2423  Moduletuple = (TNtuple *)file->Get("Module_Artuple");
2424  }
2425 
2426  this->SetName("c1");
2427  this->cd();
2428  this->Divide(2, 2, 0.01, 0.01);
2429  ((TPad *)this->GetPrimitive("c1_1"))->SetFrameFillColor(1);
2430  ((TPad *)this->GetPrimitive("c1_2"))->SetFrameFillColor(1);
2431  ((TPad *)this->GetPrimitive("c1_3"))->SetFrameFillColor(1);
2432  ((TPad *)this->GetPrimitive("c1_4"))->SetFrameFillColor(1);
2433 
2434  gStyle->SetPalette(1);
2435 
2436  this->cd(1);
2437 
2438  Moduletuple->Draw("mod:lay>>reshist10(14,0,14,32,0,32)", selectionA, "colz");
2439  TH2F *reshist10 = (TH2F *)gPad->GetPrimitive("reshist10");
2440  this->Update();
2441  if (reshist10->GetEntries() > 1)
2442  ResizePalette(reshist10);
2443  SetZAxis(reshist10);
2444  char title1[500];
2445  sprintf(title1, "Phi Sector VS Wheel %s (EC side A)", variable.c_str());
2446  if (isAr)
2447  sprintf(title1, "Argon Phi Sector VS Wheel %s (EC side A)", variable.c_str());
2448  reshist10->SetTitle(title1);
2449  reshist10->SetStats(0);
2450  reshist10->GetXaxis()->SetLabelOffset(1000);
2451  reshist10->GetYaxis()->SetLabelOffset(1000);
2452  reshist10->GetXaxis()->SetTitle("Wheel (Z)");
2453  reshist10->GetYaxis()->SetTitle("Phi sector");
2454  if (variable == "ftype")
2455  {
2456  reshist10->GetZaxis()->SetRangeUser(1, 6);
2457  reshist10->GetZaxis()->SetNdivisions(6);
2458  }
2459  else if (variable == "res")
2460  {
2461  reshist10->GetZaxis()->SetRangeUser(0.10, 0.20);
2462  }
2463  else if (variable == "abs(resMean)")
2464  {
2465  reshist10->GetZaxis()->SetRangeUser(0.0, 0.05);
2466  }
2467  else if (variable == "t0")
2468  {
2469  reshist10->GetZaxis()->SetRangeUser(2, 14);
2470  }
2471  else if (variable == "abs(t0-oldt0)")
2472  {
2473  reshist10->GetZaxis()->SetRangeUser(0.0, 0.6);
2474  }
2475  else if (variable == "tres")
2476  {
2477  reshist10->GetZaxis()->SetRangeUser(2.0, 4.5);
2478  }
2479 
2480  this->cd(2);
2481 
2482  Chiptuple->Draw("mod:chp>>histC(248,84,332,32,0,32)", selectionA, "colz");
2483  TH2F *histC = (TH2F *)gPad->GetPrimitive("histC");
2484  char title3[500];
2485  sprintf(title3, "Chip %s (EC side A)", variable.c_str());
2486  if (isAr)
2487  sprintf(title3, "Argon Chip %s (EC side A)", variable.c_str());
2488  histC->SetTitle(title3);
2489  this->Update();
2490  if (histC->GetEntries() > 1)
2491  ResizePalette(histC);
2492  SetZAxis(histC);
2493  histC->SetStats(0);
2494  histC->GetXaxis()->SetLabelOffset(1000);
2495  histC->GetYaxis()->SetLabelOffset(1000);
2496  histC->GetXaxis()->SetTitle("Chip number");
2497  histC->GetYaxis()->SetTitle("Phi sector");
2498  if (variable == "ftype")
2499  {
2500  histC->GetZaxis()->SetRangeUser(1, 6);
2501  histC->GetZaxis()->SetNdivisions(6);
2502  }
2503  else if (variable == "res")
2504  {
2505  histC->GetZaxis()->SetRangeUser(0.10, 0.20);
2506  }
2507  else if (variable == "abs(resMean)")
2508  {
2509  histC->GetZaxis()->SetRangeUser(0.0, 0.05);
2510  }
2511  else if (variable == "t0")
2512  {
2513  histC->GetZaxis()->SetRangeUser(2, 14);
2514  }
2515  else if (variable == "abs(t0-oldt0)")
2516  {
2517  histC->GetZaxis()->SetRangeUser(0.0, 0.6);
2518  }
2519  else if (variable == "tres")
2520  { // took out paranthesis
2521  histC->GetZaxis()->SetRangeUser(2.0, 4.5);
2522  }
2523 
2524  float lowe = 0;
2525  float upe = 32;
2526 
2527  TLine *lin11 = new TLine(84, lowe, 84, upe);
2528  lin11->SetLineStyle(2);
2529  lin11->Draw();
2530  TLine *lin12 = new TLine(107, lowe, 107, upe);
2531  lin12->SetLineStyle(2);
2532  lin12->Draw();
2533  TLine *lin13 = new TLine(131, lowe, 131, upe);
2534  lin13->SetLineStyle(2);
2535  lin13->Draw();
2536  TLine *lin14 = new TLine(155, lowe, 155, upe);
2537  lin14->SetLineStyle(2);
2538  lin14->Draw();
2539  TLine *lin15 = new TLine(179, lowe, 179, upe);
2540  lin15->SetLineStyle(2);
2541  lin15->Draw();
2542  TLine *lin16 = new TLine(203, lowe, 203, upe);
2543  lin16->SetLineStyle(2);
2544  lin16->Draw();
2545  TLine *lin17 = new TLine(227, lowe, 227, upe);
2546  lin17->SetLineStyle(2);
2547  lin17->Draw();
2548  TLine *lin18 = new TLine(239, lowe, 239, upe);
2549  lin18->SetLineStyle(2);
2550  lin18->Draw();
2551  this->Update();
2552 
2553  this->cd(3);
2554  Moduletuple->Draw("mod:lay>>reshist11(14,0,14,32,0,32)", selectionC, "colz");
2555  TH2F *reshist11 = (TH2F *)gPad->GetPrimitive("reshist11");
2556  this->Update();
2557  if (reshist11->GetEntries() > 1)
2558  ResizePalette(reshist11);
2559  SetZAxis(reshist11);
2560  char title4[500];
2561  sprintf(title4, "Phi Sector VS Wheel %s (EC side C)", variable.c_str());
2562  if (isAr)
2563  sprintf(title4, "Argon Phi Sector VS Wheel %s (EC side C)", variable.c_str());
2564  reshist11->SetTitle(title4);
2565  reshist11->SetMarkerStyle(21);
2566  reshist11->SetStats(0);
2567  reshist11->GetXaxis()->SetLabelOffset(1000);
2568  reshist11->GetYaxis()->SetLabelOffset(1000);
2569  reshist11->GetXaxis()->SetTitle("Layer (Z)");
2570  reshist11->GetYaxis()->SetTitle("Phi sector");
2571  if (variable == "ftype")
2572  {
2573  reshist11->GetZaxis()->SetRangeUser(1, 6);
2574  reshist11->GetZaxis()->SetNdivisions(6);
2575 
2576  TLegend *leg = new TLegend(0.99, 0.35, 0.55, 0.01, "T0 fit type");
2577 
2578  TH2F *h1 = new TH2F("h1", "h1 title", 40, 0, 4, 30, -3, 3);
2579  h1->SetMarkerColor(54);
2580  h1->SetMarkerStyle(21);
2581 
2582  TH2F *h2 = new TH2F("h2", "h2 title", 40, 0, 4, 30, -3, 3);
2583  h2->SetMarkerColor(4);
2584  h2->SetMarkerStyle(21);
2585 
2586  TH2F *h3 = new TH2F("h3", "h3 title", 40, 0, 4, 30, -3, 3);
2587  h3->SetMarkerColor(7);
2588  h3->SetMarkerStyle(21);
2589 
2590  TH2F *h4 = new TH2F("h4", "h4 title", 40, 0, 4, 30, -3, 3);
2591  h4->SetMarkerColor(81);
2592  h4->SetMarkerStyle(21);
2593 
2594  TH2F *h5 = new TH2F("h5", "h5 title", 40, 0, 4, 30, -3, 3);
2595  h5->SetMarkerColor(kYellow);
2596  h5->SetMarkerStyle(21);
2597 
2598  TH2F *h6 = new TH2F("h6", "h6 title", 40, 0, 4, 30, -3, 3);
2599  h6->SetMarkerColor(kRed);
2600  h6->SetMarkerStyle(21);
2601 
2602  leg->AddEntry(h1, "1: |mean|>5", "P");
2603  leg->AddEntry(h2, "2: normal fit", "P");
2604  leg->AddEntry(h3, "3: used chip ref", "P");
2605  leg->AddEntry(h4, "4: Low stat", "P");
2606  leg->AddEntry(h5, "5: No T0 Cal", "P");
2607  leg->AddEntry(h6, "6: Wrong fit. Mean used", "P");
2608  leg->SetTextSize(0.04);
2609  leg->Draw();
2610  }
2611  else if (variable == "res")
2612  {
2613  reshist11->GetZaxis()->SetRangeUser(0.1, 0.20);
2614  }
2615  else if (variable == "abs(resMean)")
2616  {
2617  reshist11->GetZaxis()->SetRangeUser(0.0, 0.05);
2618  }
2619  else if (variable == "t0")
2620  {
2621  reshist11->GetZaxis()->SetRangeUser(2, 14);
2622  }
2623  else if (variable == "abs(t0-oldt0)")
2624  {
2625  reshist11->GetZaxis()->SetRangeUser(0.0, 0.6);
2626  }
2627  else if (variable == "tres")
2628  {
2629  reshist11->GetZaxis()->SetRangeUser(2.0, 4.5);
2630  }
2631 
2632  this->cd(4);
2633  Chiptuple->Draw("mod:chp>>histC1(248,84,332,32,0,32)", selectionC, "colz");
2634  TH2F *histC1 = (TH2F *)gPad->GetPrimitive("histC1");
2635  char title5[500];
2636  sprintf(title5, "Chip %s (EC side C)", variable.c_str());
2637  if (isAr)
2638  sprintf(title5, "Argon Chip %s (EC side C)", variable.c_str());
2639  histC1->SetTitle(title5);
2640  this->Update();
2641  if (histC1->GetEntries() > 1)
2642  ResizePalette(histC1);
2643  SetZAxis(histC1);
2644  histC1->SetStats(0);
2645  histC1->GetXaxis()->SetLabelOffset(1000);
2646  histC1->GetYaxis()->SetLabelOffset(1000);
2647  histC1->GetXaxis()->SetTitle("Chip number");
2648  histC1->GetYaxis()->SetTitle("Phi sector");
2649  if (variable == "ftype")
2650  {
2651  histC1->GetZaxis()->SetRangeUser(1, 6);
2652  histC1->GetZaxis()->SetNdivisions(6);
2653  }
2654  else if (variable == "res")
2655  {
2656  histC1->GetZaxis()->SetRangeUser(0.10, 0.20);
2657  }
2658  else if (variable == "abs(resMean)")
2659  {
2660  histC1->GetZaxis()->SetRangeUser(0.0, 0.05);
2661  }
2662  else if (variable == "t0")
2663  {
2664  histC1->GetZaxis()->SetRangeUser(2, 14);
2665  }
2666  else if (variable == "abs(t0-oldt0)")
2667  {
2668  histC1->GetZaxis()->SetRangeUser(0.0, 0.6);
2669  }
2670  else if (variable == "tres")
2671  { // took out parenthesis
2672  histC1->GetZaxis()->SetRangeUser(2.0, 4.5);
2673  }
2674 
2675  TLine *lin1 = new TLine(84, lowe, 84, upe);
2676  lin1->SetLineStyle(2);
2677  lin1->Draw();
2678  TLine *lin2 = new TLine(108, lowe, 108, upe);
2679  lin2->SetLineStyle(2);
2680  lin2->Draw();
2681  TLine *lin3 = new TLine(132, lowe, 132, upe);
2682  lin3->SetLineStyle(2);
2683  lin3->Draw();
2684  TLine *lin4 = new TLine(156, lowe, 156, upe);
2685  lin4->SetLineStyle(2);
2686  lin4->Draw();
2687  TLine *lin5 = new TLine(180, lowe, 180, upe);
2688  lin5->SetLineStyle(2);
2689  lin5->Draw();
2690  TLine *lin6 = new TLine(204, lowe, 204, upe);
2691  lin6->SetLineStyle(2);
2692  lin6->Draw();
2693  TLine *lin7 = new TLine(228, lowe, 228, upe);
2694  lin7->SetLineStyle(2);
2695  lin7->Draw();
2696  TLine *lin8 = new TLine(240, lowe, 239, upe);
2697  lin8->SetLineStyle(2);
2698  lin8->Draw();
2699 
2700  this->Update();
2701 }
2702 
2703 //================================================================
2704 
2705 class RtColor : public TCanvas
2706 {
2707 public:
2708  RtColor(char *,const string&, bool);
2710  TGraphErrors *rtgraph{};
2711  TF1 *oldrtfunc{};
2712  TF1 *newRT{};
2713 };
2714 
2715 RtColor::RtColor(char *infile, const string & folder, bool isAr = false)
2716 {
2717 
2718  map<string, string> titlemap;
2719  titlemap["WholeBarrel_1"] = "whole barrel";
2720  titlemap["Detector_-1"] = "barrel C";
2721  titlemap["Detector_1"] = "barrel A";
2722  titlemap["Detector_-2"] = "end-cap C";
2723  titlemap["Detector_2"] = "end-cap A";
2724 
2725  titlemap["WholeBarrel_Ar_1"] = "whole barrel";
2726  titlemap["Detector_Ar_-1"] = "barrel C";
2727  titlemap["Detector_Ar_1"] = "barrel A";
2728  titlemap["Detector_Ar_-2"] = "end-cap C";
2729  titlemap["Detector_Ar-2"] = "end-cap A";
2730 
2731  TFile *file = new TFile(infile);
2732  // cout << infile << endl;
2733 
2734  TPad *c1_3 = new TPad("c1_3", "newpad", 0.01, 0.33, 0.99, 0.99);
2735  c1_3->Draw();
2736  c1_3->cd();
2737  c1_3->SetTopMargin(0.1);
2738  c1_3->SetBottomMargin(0.01);
2739  c1_3->SetRightMargin(0.1);
2740  c1_3->SetFillStyle(0);
2741  c1_3->SetGrid();
2742 
2743  file->cd();
2744 
2745  TDirectory *trt = nullptr;
2746  if (!isAr)
2747  trt = (TDirectory *)file->FindKey("TRT_all")->ReadObj();
2748  else
2749  trt = (TDirectory *)file->FindKey("TRT_Ar_all")->ReadObj();
2750 
2751  if (folder != "")
2752  {
2753  TDirectory *det = (TDirectory *)trt->FindKey(folder.c_str())->ReadObj();
2754  cout << " RtColor plot for folder" << folder << endl;
2755  if (det->FindKey("rt-relation"))
2756  {
2757  hist = (TH2F *)det->FindKey("rt-relation")->ReadObj();
2758  // this->cd();
2759  if (hist)
2760  {
2761  cout << " found rt-relation " << endl;
2762  hist->GetXaxis()->SetRangeUser(0, 40);
2763  hist->GetYaxis()->SetRangeUser(0, 2.4);
2764  char name[500];
2765  sprintf(name, "r(t) for %s", folder.c_str());
2766  if (isAr)
2767  sprintf(name, "Argon r(t) for %s", folder.c_str());
2768  hist->SetTitle(name);
2769  hist->GetXaxis()->SetRangeUser(0, 50);
2770  hist->Draw("colz");
2771 
2772  if (det->FindKey("rtgraph"))
2773  {
2774  cout << " found rtgraph " << endl;
2775  rtgraph = (TGraphErrors *)det->FindKey("rtgraph")->ReadObj();
2776  rtgraph->SetMarkerStyle(20);
2777  rtgraph->SetMarkerColor(1);
2778  rtgraph->SetLineColor(1);
2779  rtgraph->GetYaxis()->SetRangeUser(0, 2.4);
2780  rtgraph->Draw("p");
2781  if (rtgraph->GetFunction("rtfunc"))
2782  newRT = rtgraph->GetFunction("rtfunc");
2783  else
2784  newRT = rtgraph->GetFunction("rtfunc2");
2785  }
2786  if (det->FindKey("oldrtfunc"))
2787  {
2788  cout << " found oldrtfunc " << endl;
2789  oldrtfunc = (TF1 *)det->FindKey("oldrtfunc")->ReadObj();
2790  oldrtfunc->SetRange(0, 50);
2791  oldrtfunc->Draw("same");
2792  }
2793  }
2794  }
2795  else
2796  {
2797  throw string(" NO RT OBJECTS FOUND");
2798  }
2799  }
2800  else if (trt->FindKey("rt-relation"))
2801  {
2802  cout << " RtColor Plot entire TRT" << endl;
2803  hist = (TH2F *)trt->FindKey("rt-relation")->ReadObj();
2804  // this->cd();
2805  hist->GetXaxis()->SetRangeUser(0, 40);
2806  hist->SetTitle("r(t) for whole TRT");
2807  if (isAr)
2808  hist->SetTitle("Argon r(t) for whole TRT");
2809  hist->GetYaxis()->SetRangeUser(0, 2.4);
2810  hist->GetXaxis()->SetRangeUser(0, 50);
2811  hist->Draw("colz");
2812  if (trt->FindKey("rtgraph"))
2813  {
2814  rtgraph = (TGraphErrors *)trt->FindKey("rtgraph")->ReadObj();
2815  rtgraph->SetMarkerStyle(20);
2816  rtgraph->SetLineColor(1);
2817  rtgraph->SetMarkerColor(1);
2818  rtgraph->GetYaxis()->SetRangeUser(0, 2.4);
2819  if (rtgraph->GetFunction("rtfunc"))
2820  newRT = rtgraph->GetFunction("rtfunc");
2821  else
2822  newRT = rtgraph->GetFunction("rtfunc2");
2823  rtgraph->Draw("p");
2824  }
2825  if (trt->FindKey("oldrtfunc"))
2826  {
2827  oldrtfunc = (TF1 *)trt->FindKey("oldrtfunc")->ReadObj();
2828  oldrtfunc->SetRange(0, 50);
2829  oldrtfunc->Draw("same");
2830  }
2831  }
2832  else
2833  hist = nullptr;
2834 
2835  // Draw the ratio plots just below:
2836 
2837  // Plot the difference between old and new rt:
2838  if (oldrtfunc)
2839  {
2840  this->cd();
2841  this->cd(1);
2842  TPad *c1_4 = new TPad("c1_4", "newpad", 0.01, 0, 0.99, 0.32);
2843  c1_4->Draw();
2844  c1_4->cd();
2845  c1_4->SetTopMargin(0.01);
2846  c1_4->SetBottomMargin(0.3);
2847  c1_4->SetRightMargin(0.1);
2848  c1_4->SetFillStyle(0);
2849  c1_4->SetGrid();
2850 
2851  Double_t Xmax = rtgraph->GetXaxis()->GetXmax();
2852  Double_t Xmin = rtgraph->GetXaxis()->GetXmin();
2853 
2854  const Int_t n = 300;
2855  Double_t x[n], y[n], dx;
2856  dx = (Xmax - Xmin) / n;
2857 
2858  Double_t Ymax = -10;
2859  Double_t Ymin = 10;
2860 
2861  newRT->SetRange(-10., 60.);
2862  oldrtfunc->SetRange(-10., 60.);
2863 
2864  for (Int_t i = 0; i < n; i++)
2865  {
2866  x[i] = Xmin + i * dx;
2867  y[i] = (oldrtfunc->Eval(x[i]) - newRT->Eval(x[i]));
2868  if (y[i] > Ymax)
2869  Ymax = y[i];
2870  if (y[i] < Ymin)
2871  Ymin = y[i];
2872  }
2873 
2874  TGraph *gr1 = new TGraph(n, x, y);
2875 
2876  // gStyle->SetOptTitle(0);
2877  gr1->SetTitle("");
2878  gr1->GetXaxis()->SetTitle("t-T0/ns");
2879  gr1->GetXaxis()->SetRangeUser(Xmin, Xmax);
2880  gr1->GetYaxis()->SetTitle("Old r(t) - New r(t) /mm");
2881  gr1->GetYaxis()->SetRangeUser(-0.1, 0.1);
2882  // gr1->GetYaxis()->SetRangeUser(1.1*Ymin,1.1*Ymax);
2883  gr1->GetYaxis()->SetNdivisions(5);
2884  gr1->GetXaxis()->SetTitleSize(0.06);
2885  gr1->GetXaxis()->SetLabelSize(0.06);
2886  gr1->GetYaxis()->SetLabelSize(0.08);
2887  gr1->GetYaxis()->SetTitleOffset(0.8);
2888  gr1->GetYaxis()->SetTitleSize(0.06);
2889  gr1->SetLineStyle(2);
2890 
2891  // Also add the difference between the fit and the points of the fit
2892 
2893  Int_t n1 = rtgraph->GetN();
2894  std::vector<Double_t> x1(n1,0), y1(n1,0), ex1(n1,0), ey1(n1,0);
2895  Double_t X, Y;
2896 
2897  for (Int_t i = 0; i < n1; i++)
2898  {
2899  X = 0;
2900  Y = 0;
2901  rtgraph->GetPoint(i, X, Y);
2902  x1.at(i) = X;
2903  y1.at(i) = Y - newRT->Eval(X);
2904  ex1.at(i) = 0;
2905  ey1.at(i) = rtgraph->GetErrorY(i);
2906  if (y1.at(i) > Ymax)
2907  Ymax = y1.at(i);
2908  if (y1.at(i) < Ymin)
2909  Ymin = y1.at(i);
2910  }
2911  // gr1->Draw("APL");
2912 
2913  TGraphErrors *gr2 = new TGraphErrors(n1, &x1.at(0), &y1.at(0), &ex1.at(0), &ey1.at(0));
2914  gr2->SetMarkerColor(kBlack);
2915  gr2->SetMarkerStyle(20);
2916  gr2->SetTitle("");
2917  gr2->GetYaxis()->SetTitle("Old r(t) - New r(t) /mm");
2918 
2919  // gr2->GetYaxis()->SetRangeUser(1.1*Ymin,1.1*Ymax);
2920  gr2->GetYaxis()->SetRangeUser(-0.1, 0.1);
2921  gr2->GetXaxis()->SetRangeUser(0, 50);
2922 
2923  gr2->Draw("ap");
2924  gr1->Draw("l");
2925 
2926  TLine *line0 = new TLine(0, 0, 50, 0);
2927  line0->SetLineColor(4);
2928  line0->Draw();
2929  }
2930 }
2931 
2932 //================================================================
2933 
2934 class ResidualPlots : public TCanvas
2935 {
2936 public:
2937  ResidualPlots(TFile *, bool);
2938 };
2939 
2940 ResidualPlots::ResidualPlots(TFile *file, bool isAr = false)
2941 {
2942 
2943  this->SetName("resplots");
2944 
2945  file->cd();
2946 
2947  TDirectory *trt = nullptr;
2948  TDirectory *det1 = nullptr;
2949  TDirectory *det2 = nullptr;
2950  TDirectory *det3 = nullptr;
2951  TDirectory *det4 = nullptr;
2952 
2953  if (!isAr)
2954  {
2955  cout << " In ResidualPlots Xenon" << endl;
2956  trt = (TDirectory *)file->FindKey("TRT_all")->ReadObj();
2957  if (not trt){
2958  throw std::runtime_error("trt pointer is null");
2959  }
2960  det1 = (TDirectory *)trt->FindKey("Detector_-1")->ReadObj();
2961  det2 = (TDirectory *)trt->FindKey("Detector_1")->ReadObj();
2962  det3 = (TDirectory *)trt->FindKey("Detector_-2")->ReadObj();
2963  det4 = (TDirectory *)trt->FindKey("Detector_2")->ReadObj();
2964  }
2965  else
2966  {
2967  if (not trt){
2968  throw std::runtime_error("trt pointer is null");
2969  }
2970  cout << " In ResidualPlots Argon" << endl;
2971  if (file->FindKey("TRT_Ar_all"))
2972  trt = (TDirectory *)file->FindKey("TRT_Ar_all")->ReadObj();
2973  if (trt->FindKey("Detector_Ar_-1"))
2974  det1 = (TDirectory *)trt->FindKey("Detector_Ar_-1")->ReadObj();
2975  if (trt->FindKey("Detector_Ar_1"))
2976  det2 = (TDirectory *)trt->FindKey("Detector_Ar_1")->ReadObj();
2977  if (trt->FindKey("Detector_Ar_-2"))
2978  det3 = (TDirectory *)trt->FindKey("Detector_Ar_-2")->ReadObj();
2979  if (trt->FindKey("Detector_Ar_2"))
2980  det4 = (TDirectory *)trt->FindKey("Detector_Ar_2")->ReadObj();
2981  }
2982 
2983  TH2F *reshist1 = nullptr;
2984  TH2F *reshist2 = nullptr;
2985  TH2F *reshist3 = nullptr;
2986  TH2F *reshist4 = nullptr;
2987  TH2F *reshist5 = nullptr;
2988  TH2F *treshist1 = nullptr;
2989  TH2F *treshist2 = nullptr;
2990  TH2F *treshist3 = nullptr;
2991  TH2F *treshist4 = nullptr;
2992  TH2F *treshist5 = nullptr;
2993 
2994  cout << " Find residual histograms " << endl;
2995 
2996  if (trt->FindKey("residual"))
2997  reshist1 = (TH2F *)trt->FindKey("residual")->ReadObj();
2998  if (det1)
2999  {
3000  if (det1->FindKey("residual"))
3001  reshist2 = (TH2F *)det1->FindKey("residual")->ReadObj();
3002  }
3003  if (det2)
3004  {
3005  if (det2->FindKey("residual"))
3006  reshist3 = (TH2F *)det2->FindKey("residual")->ReadObj();
3007  }
3008  if (det3)
3009  {
3010  if (det3->FindKey("residual"))
3011  reshist4 = (TH2F *)det3->FindKey("residual")->ReadObj();
3012  }
3013  if (det4)
3014  {
3015  if (det4->FindKey("residual"))
3016  reshist5 = (TH2F *)det4->FindKey("residual")->ReadObj();
3017  }
3018 
3019  cout << " Find time residual histograms" << endl;
3020  if (trt->FindKey("timeresidual"))
3021  treshist1 = (TH2F *)trt->FindKey("timeresidual")->ReadObj();
3022  if (det1)
3023  {
3024  if (det1->FindKey("timeresidual"))
3025  treshist2 = (TH2F *)det1->FindKey("timeresidual")->ReadObj();
3026  }
3027  if (det2)
3028  {
3029  if (det2->FindKey("timeresidual"))
3030  treshist3 = (TH2F *)det2->FindKey("timeresidual")->ReadObj();
3031  }
3032  if (det3)
3033  {
3034  if (det3->FindKey("timeresidual"))
3035  treshist4 = (TH2F *)det3->FindKey("timeresidual")->ReadObj();
3036  }
3037  if (det4)
3038  {
3039  if (det4->FindKey("timeresidual"))
3040  treshist5 = (TH2F *)det4->FindKey("timeresidual")->ReadObj();
3041  }
3042 
3043  cout << " Configure residual histograms" << endl;
3044  if (reshist1)
3045  reshist1->SetTitle(Form("residual whole TRT"));
3046  if (reshist2)
3047  reshist2->SetTitle(Form("residual (barrel side C)"));
3048  if (reshist3)
3049  reshist3->SetTitle(Form("residual (barrel side A)"));
3050  if (reshist4)
3051  reshist4->SetTitle(Form("residual (endcap side C)"));
3052  if (reshist5)
3053  reshist5->SetTitle(Form("residual (endcap side A)"));
3054  if (reshist2)
3055  reshist2->SetFillColor(46);
3056  if (reshist3)
3057  reshist3->SetFillColor(46);
3058  if (reshist4)
3059  reshist4->SetFillColor(46);
3060  if (reshist5)
3061  reshist5->SetFillColor(46);
3062 
3063  cout << " Configure time residual histograms" << endl;
3064  if (treshist1)
3065  treshist1->SetTitle("time-residual whole TRT");
3066  if (treshist2)
3067  treshist2->SetTitle("time-residual (barrel side C)");
3068  if (treshist3)
3069  treshist3->SetTitle("time-residual (barrel side A)");
3070  if (treshist4)
3071  treshist4->SetTitle("time-residual (endcap side C)");
3072  if (treshist5)
3073  treshist5->SetTitle("time-residual (endcap side A)");
3074  if (treshist2)
3075  treshist2->SetFillColor(38);
3076  if (treshist3)
3077  treshist3->SetFillColor(38);
3078  if (treshist4)
3079  treshist4->SetFillColor(38);
3080  if (treshist5)
3081  treshist5->SetFillColor(38);
3082 
3083  if (isAr)
3084  {
3085  cout << " Configure Argon residual histograms" << endl;
3086  if (reshist1)
3087  reshist1->SetTitle("residual Argon whole TRT");
3088  if (reshist2)
3089  reshist2->SetTitle("residual Argon (barrel side C)");
3090  if (reshist3)
3091  reshist3->SetTitle("residual Argon (barrel side A)");
3092  if (reshist4)
3093  reshist4->SetTitle("residual Argon (endcap side C)");
3094  if (reshist5)
3095  reshist5->SetTitle("residual Argon (endcap side A)");
3096  if (treshist1)
3097  treshist1->SetTitle("time-residual Argon whole TRT");
3098  if (treshist2)
3099  treshist2->SetTitle("time-residual Argon (barrel side C)");
3100  if (treshist3)
3101  treshist3->SetTitle("time-residual Argon (barrel side A)");
3102  if (treshist4)
3103  treshist4->SetTitle("time-residual Argon (endcap side C)");
3104  if (treshist5)
3105  treshist5->SetTitle("time-residual Argon (endcap side A)");
3106  }
3107 
3108  TF1 *resfit2 = nullptr;
3109  TF1 *resfit3 = nullptr;
3110  TF1 *resfit4 = nullptr;
3111  TF1 *resfit5 = nullptr;
3112  TF1 *tresfit2 = nullptr;
3113  TF1 *tresfit3 = nullptr;
3114  TF1 *tresfit4 = nullptr;
3115  TF1 *tresfit5 = nullptr;
3116 
3117  if (reshist2)
3118  resfit2 = (TF1 *)reshist2->GetListOfFunctions()->First();
3119  if (reshist3)
3120  resfit3 = (TF1 *)reshist3->GetListOfFunctions()->First();
3121  if (reshist4)
3122  resfit4 = (TF1 *)reshist4->GetListOfFunctions()->First();
3123  if (reshist5)
3124  resfit5 = (TF1 *)reshist5->GetListOfFunctions()->First();
3125  if (treshist2)
3126  tresfit2 = (TF1 *)treshist2->GetListOfFunctions()->First();
3127  if (treshist3)
3128  tresfit3 = (TF1 *)treshist3->GetListOfFunctions()->First();
3129  if (treshist4)
3130  tresfit4 = (TF1 *)treshist4->GetListOfFunctions()->First();
3131  if (treshist5)
3132  tresfit5 = (TF1 *)treshist5->GetListOfFunctions()->First();
3133 
3134  TText *mintxt = new TText();
3135  mintxt->SetNDC(kTRUE);
3136 
3137  this->Divide(4, 2);
3138 
3139  this->cd(3);
3140  if (reshist2)
3141  {
3142  cout << " Draw residual barrel C" << endl;
3143  reshist2->Draw();
3144  mintxt->DrawText(0.15, 0.85, Form("Mean: %.3f", resfit2->GetParameter(1)));
3145  mintxt->DrawText(0.15, 0.80, Form("Sigma: %.3f", resfit2->GetParameter(2)));
3146  }
3147  this->cd(2);
3148  // if( !isAr && reshist3){
3149  if (reshist3)
3150  { // changed this (PH)
3151  cout << " Draw residual barrel A" << endl;
3152  reshist3->Draw();
3153  mintxt->DrawText(0.15, 0.85, Form("Mean: %.3f", resfit3->GetParameter(1)));
3154  mintxt->DrawText(0.15, 0.80, Form("Sigma: %.3f", resfit3->GetParameter(2)));
3155  }
3156  this->cd(1);
3157 
3158  if (reshist4)
3159  {
3160  cout << " Draw residual endcap C" << endl;
3161  reshist4->Draw();
3162  mintxt->DrawText(0.15, 0.85, Form("Mean: %.3f", resfit4->GetParameter(1)));
3163  mintxt->DrawText(0.15, 0.80, Form("Sigma: %.3f", resfit4->GetParameter(2)));
3164  }
3165  this->cd(4);
3166  if (reshist5)
3167  {
3168  cout << " Draw residual endcap A" << endl;
3169  reshist5->Draw();
3170  mintxt->DrawText(0.15, 0.85, Form("Mean: %.3f", resfit5->GetParameter(1)));
3171  mintxt->DrawText(0.15, 0.80, Form("Sigma: %.3f", resfit5->GetParameter(2)));
3172  }
3173  this->cd(7);
3174 
3175  if (treshist2)
3176  {
3177  cout << " Draw time residual barrel C" << endl;
3178  treshist2->Draw();
3179  mintxt->DrawText(0.15, 0.85, Form("Mean: %.3f", tresfit2->GetParameter(1)));
3180  mintxt->DrawText(0.15, 0.80, Form("Sigma: %.3f", tresfit2->GetParameter(2)));
3181  }
3182  this->cd(6);
3183  // if(!isAr && treshist3){ // Changed this (PH)
3184  if (treshist3)
3185  {
3186  cout << " Draw time residual barrel A" << endl;
3187  treshist3->Draw();
3188  mintxt->DrawText(0.15, 0.85, Form("Mean: %.3f", tresfit3->GetParameter(1)));
3189  mintxt->DrawText(0.15, 0.80, Form("Sigma: %.3f", tresfit3->GetParameter(2)));
3190  }
3191  this->cd(5);
3192  if (treshist4)
3193  {
3194  cout << " Draw time residual endcap C" << endl;
3195  treshist4->Draw();
3196  mintxt->DrawText(0.15, 0.85, Form("Mean: %.3f", tresfit4->GetParameter(1)));
3197  mintxt->DrawText(0.15, 0.80, Form("Sigma: %.3f", tresfit4->GetParameter(2)));
3198  }
3199  this->cd(8);
3200  if (treshist5)
3201  {
3202  cout << " Draw time residual endcap A" << endl;
3203  treshist5->Draw();
3204  mintxt->DrawText(0.15, 0.85, Form("Mean: %.3f", tresfit5->GetParameter(1)));
3205  mintxt->DrawText(0.15, 0.80, Form("Sigma: %.3f", tresfit5->GetParameter(2)));
3206  }
3207  gStyle->SetOptStat(0);
3208 }
3209 
3210 //================================================================
3211 
3212 class TRTPlots : public TCanvas
3213 {
3214 public:
3215  TRTPlots(TFile *, bool);
3216 };
3217 
3218 TRTPlots::TRTPlots(TFile *file, bool isAr = false)
3219 {
3220 
3221  this->SetName("resplots");
3222 
3223  file->cd();
3224 
3225  TDirectory *trt = nullptr;
3226  if (!isAr)
3227  trt = (TDirectory *)file->FindKey("TRT_all")->ReadObj();
3228  else
3229  trt = (TDirectory *)file->FindKey("TRT_Ar_all")->ReadObj();
3230 
3231  TH2F *reshist1 = nullptr;
3232  if (trt->FindKey("residual"))
3233  reshist1 = (TH2F *)trt->FindKey("residual")->ReadObj();
3234  else
3235  throw(string("residual histograms for entire TRT not found!"));
3236 
3237  TH2F *treshist1 = nullptr;
3238  if (trt->FindKey("timeresidual"))
3239  treshist1 = (TH2F *)trt->FindKey("timeresidual")->ReadObj();
3240  else
3241  throw(string("timeresidual histograms for entire TRT not found!"));
3242 
3243  reshist1->SetTitle(Form("residual whole TRT"));
3244  if (isAr)
3245  reshist1->SetTitle(Form("Argon residual whole TRT"));
3246  reshist1->SetFillColor(46);
3247  treshist1->SetTitle(Form("time-residual whole TRT"));
3248  if (isAr)
3249  treshist1->SetTitle(Form("Argon time-residual whole TRT"));
3250  treshist1->SetFillColor(38);
3251 
3252  this->Divide(1, 2, 0.01, 0.01);
3253  this->SetLogy();
3254 
3255  this->cd(1);
3256  reshist1->Draw();
3257  this->cd(2);
3258  treshist1->Draw();
3259 }
3260 
3261 //================================================================
3262 
3263 class TBinnedRes : public TCanvas
3264 {
3265 public:
3266  TBinnedRes(TFile *, vector<TH1D *>);
3267 };
3268 
3269 TBinnedRes::TBinnedRes(TFile* /*file*/, vector<TH1D *> reshists)
3270 {
3271 
3272  cout << "In TBinnedRes. Input is " << reshists.size() << " histograms to be drawn " << endl;
3273 
3274  this->Divide(((int)reshists.size()) / 5, 5);
3275  for (int ihist = 0; ihist < (int)reshists.size(); ihist++)
3276  {
3277  this->cd(ihist + 1);
3278  reshists[ihist]->SetTitle("");
3279  reshists[ihist]->Draw();
3280  reshists[ihist]->GetYaxis()->SetRangeUser(0, 1.1 * reshists[ihist]->GetMaximum());
3281  TLine *zlin = new TLine(0, 0, 0, reshists[ihist]->GetMaximum());
3282  zlin->SetLineStyle(2);
3283  zlin->SetLineColor(4);
3284  zlin->Draw();
3285  }
3286 
3287  this->SetGrid();
3288 }
3289 
3290 //================================================================
3291 
3292 class RtBinning : public TCanvas
3293 {
3294 public:
3295  RtBinning(TDirectory *, const string&);
3296 
3297 private:
3298  TH1F *m_hist2{};
3299 };
3300 
3301 RtBinning::RtBinning(TDirectory *file, const string & detector)
3302 {
3303 
3304  TDirectory *binhist = (TDirectory *)(((TDirectory *)file->Get(detector.c_str()))->Get("binhist"));
3305  if (binhist)
3306  {
3307  int nhists = binhist->GetListOfKeys()->GetEntries();
3308 
3309  this->Divide(nhists / 5, 5);
3310  for (int ihist = 0; ihist < nhists; ihist++)
3311  {
3312  this->cd(ihist + 1);
3313  m_hist2 = (TH1F *)(binhist->Get(binhist->GetListOfKeys()->At(ihist)->GetName()));
3314  m_hist2->SetTitle("");
3315  m_hist2->Draw();
3316  }
3317 
3318  this->SetGrid();
3319  }
3320 }
3321 
3322 //================================================================
3323 
3324 class RresTbin : public TCanvas
3325 {
3326 public:
3327  RresTbin(TFile *, const string &, int);
3328  vector<TH1D *> reshists;
3329  map<double, double> resmap;
3330 
3331 private:
3332  TGraphErrors m_thegraph;
3333  std::vector<double> m_rdata;
3334  std::vector<double> m_erdata;
3335  std::vector<double> m_tdata;
3336  std::vector<double> m_etdata;
3337 };
3338 
3339 RresTbin::RresTbin(TFile *file, const string & detname, int det)
3340 {
3341 
3342  TF1 ff("fitfunc", "gaus");
3343  TF1 *ff2 = new TF1("fitfunc2", "pol3");
3344 
3345  TDirectory *trt = nullptr;
3346  TDirectory *detdir = nullptr;
3347  TDirectory *binhist = nullptr;
3348  string resname;
3349  bool isAr = false;
3350  if (detname.find("Ar") != string::npos)
3351  isAr = true;
3352  bool allTRT = false;
3353  if (detname == "WholeBarrel_1")
3354  {
3355  resname = "reshists5";
3356  }
3357  else if (detname == "Detector_-1")
3358  {
3359  resname = "reshists2";
3360  }
3361  else if (detname == "Detector_1")
3362  {
3363  resname = "reshists3";
3364  }
3365  else if (detname == "Detector_-2")
3366  {
3367  resname = "reshists1";
3368  }
3369  else if (detname == "Detector_2")
3370  {
3371  resname = "reshists4";
3372  }
3373  else if (!isAr)
3374  {
3375  resname = "reshists";
3376  allTRT = true;
3377  }
3378  else if (detname == "WholeBarrel_Ar_1")
3379  {
3380  resname = "reshists_Ar5";
3381  }
3382  else if (detname == "Detector_Ar_-1")
3383  {
3384  resname = "reshists_Ar2";
3385  }
3386  else if (detname == "Detector_Ar_1")
3387  {
3388  resname = "reshists_Ar3";
3389  }
3390  else if (detname == "Detector_Ar_-2")
3391  {
3392  resname = "reshists_Ar1";
3393  }
3394  else if (detname == "Detector_Ar_2")
3395  {
3396  resname = "reshists_Ar4";
3397  }
3398  else
3399  {
3400  resname = "reshists_Ar";
3401  allTRT = true;
3402  }
3403 
3404  if (!isAr)
3405  trt = (TDirectory *)file->FindKey("TRT_all")->ReadObj();
3406  else
3407  trt = (TDirectory *)file->FindKey("TRT_Ar_all")->ReadObj();
3408 
3409  if (!isAr)
3410  cout << "In RresTbin Xenon" << endl;
3411  if (isAr)
3412  cout << "In RresTbin Argon" << endl;
3413  if (trt)
3414  {
3415  cout << " found TRT_all directory " << endl;
3416  detdir = (TDirectory *)trt->FindKey(detname.c_str())->ReadObj();
3417  if (detdir)
3418  {
3419  cout << " found binhist directory for detector name " << detname << endl;
3420  if (!allTRT)
3421  {
3422  binhist = (TDirectory *)detdir->FindKey(resname.c_str())->ReadObj();
3423  }
3424  else
3425  {
3426  binhist = (TDirectory *)trt->FindKey(resname.c_str())->ReadObj();
3427  }
3428 
3429  if (binhist)
3430  {
3431  cout << " found reshists directory for detector number: " << det << endl;
3432  }
3433  else
3434  {
3435  cout << " did not find reshists directory for detector number " << det << endl;
3436  }
3437  }
3438  else
3439  {
3440  cout << " did not find binhist directory for detector name " << detname << endl;
3441  }
3442  }
3443  else
3444  {
3445  cout << " did not find TRT_all directory " << endl;
3446  }
3447 
3448  if (binhist)
3449  {
3450 
3451  TVectorD *tbins = (TVectorD *)file->FindKey("tbins")->ReadObj();
3452 
3453  if (tbins)
3454  {
3455  const size_t nElements = tbins->GetNoElements();
3456  cout << " found tbins vector with length " << nElements << endl;
3457  m_rdata = std::vector<double>(nElements,0.);
3458  m_erdata = std::vector<double>(nElements,0.);
3459  m_tdata = std::vector<double>(nElements,0.);
3460  m_etdata = std::vector<double>(nElements,0.);
3461  m_thegraph = TGraphErrors(nElements);
3462 
3463  int ipoint = 0;
3464  for (int ihist = 0; ihist < tbins->GetNoElements(); ihist++)
3465  {
3466 
3467  TH1D *reshist = nullptr;
3468 
3469  if (det == 4)
3470  reshist = (TH1D *)binhist->Get(Form("res_tbin%i_bar", ihist));
3471  else if (det == 5)
3472  reshist = (TH1D *)binhist->Get(Form("res_tbin%i_trt", ihist));
3473  else
3474  reshist = (TH1D *)binhist->Get(Form("res_tbin%i_%i", ihist, det));
3475 
3476  if (reshist != nullptr)
3477  {
3478  double lolim = -0.1; // reshist->GetBinCenter(reshist->GetMaximumBin()-10);
3479  double hilim = 0.1; // reshist->GetBinCenter(reshist->GetMaximumBin()+10);
3480 
3481  if (reshist->Fit(&ff, "Q", "", lolim, hilim) + 1)
3482  {
3483  m_rdata[ipoint] = ff.GetParameter(1);
3484  m_erdata[ipoint] = ff.GetParError(1);
3485  m_tdata[ipoint] = (*tbins)[ihist];
3486 
3487  m_etdata[ipoint] = 0;
3488  // printf("%f %f\n",ff.GetParameter(1),ff.GetParError(1));
3489  ipoint++;
3490  }
3491 
3492  reshists.push_back(reshist);
3493  }
3494  }
3495  cout << " succesfully fitted " << ipoint << " histograms " << endl;
3496  for (int ip = 0; ip < ipoint; ip++)
3497  {
3498  // cout << rdata[ip] << " ";
3499  resmap[m_tdata[ip]] = m_rdata[ip];
3500  }
3501  // cout << endl;
3502 
3503  if (ipoint > 10)
3504  {
3505  m_thegraph = TGraphErrors(ipoint, m_tdata.data(), m_rdata.data(), m_etdata.data(), m_erdata.data());
3506 
3507  cout << " draw t-binned residual graph " << endl;
3508  string detstr[8] = {"endcap A", "barrel A", "", "barrel C", "endcap C", "", "whole barrel", "whole TRT"};
3509 
3510  m_thegraph.SetMarkerStyle(20);
3511  m_thegraph.SetTitle(Form("t-binned absolute residual (%s)", detstr[det + 2].c_str()));
3512  m_thegraph.Draw("ap");
3513  m_thegraph.GetYaxis()->SetTitle("|r|-|r_{track}| /mm");
3514  m_thegraph.GetYaxis()->SetRangeUser(-0.150, 0.150);
3515  m_thegraph.GetXaxis()->SetRangeUser(0, 50);
3516  m_thegraph.GetXaxis()->SetTitle("t-t0 /ns");
3517 
3518  printf("RPOLDIFF %i %e %e %e %e\n", det, ff2->GetParameter(0), ff2->GetParameter(1), ff2->GetParameter(2), ff2->GetParameter(3));
3519 
3520  this->SetGrid();
3521  }
3522  }
3523  }
3524 }
3525 
3526 //================================================================
3527 
3528 class FirstPage : public TCanvas
3529 {
3530 public:
3531  FirstPage(char *, TFile *);
3532  float runnumber = 0, t0offset = 0;
3533  int iter = 0;
3534 
3535 private:
3536 };
3537 
3538 FirstPage::FirstPage(char * /*filename*/, TFile *file)
3539 {
3540 
3541  this->cd();
3542 
3543  TNtuple *Tracktuple = (TNtuple *)file->Get("tracktuple");
3544  // we assign here index 0,1,2,3 to detectors -1, -2, 1, 2
3545  TH1F *resAr0 = (TH1F *)file->Get("TRT_Ar_all/Detector_Ar_-1/residual");
3546  TH1F *tresAr0 = (TH1F *)file->Get("TRT_Ar_all/Detector_Ar_-1/timeresidual");
3547  TH1F *resAr1 = (TH1F *)file->Get("TRT_Ar_all/Detector_Ar_-2/residual");
3548  TH1F *tresAr1 = (TH1F *)file->Get("TRT_Ar_all/Detector_Ar_-2/timeresidual");
3549  TH1F *resXe1 = (TH1F *)file->Get("TRT_all/Detector_-2/residual");
3550  TH1F *tresXe1 = (TH1F *)file->Get("TRT_all/Detector_-2/timeresidual");
3551  TH1F *resAr2 = (TH1F *)file->Get("TRT_Ar_all/Detector_Ar_1/residual");
3552  TH1F *tresAr2 = (TH1F *)file->Get("TRT_Ar_all/Detector_Ar_1/timeresidual");
3553  TH1F *resAr3 = (TH1F *)file->Get("TRT_Ar_all/Detector_Ar_2/residual");
3554  TH1F *tresAr3 = (TH1F *)file->Get("TRT_Ar_all/Detector_Ar_2/timeresidual");
3555  TH1F *resXe3 = (TH1F *)file->Get("TRT_all/Detector_2/residual");
3556  TH1F *tresXe3 = (TH1F *)file->Get("TRT_all/Detector_2/timeresidual");
3557 
3558  TDatime *dt = new TDatime();
3559 
3560  TPaveText *pt = new TPaveText(.1, .2, .9, .9);
3561 
3562  if (!Tracktuple)
3563  throw(string("tracktuple not found!"));
3564 
3565  cout << " tracktuple found " << endl;
3566  pt->AddText(" ");
3567 
3568  // if (string(filename).find("_histograms.root")!=string::npos) iter = atoi(string(filename).substr(string(filename).find("_histograms.root")-2,2).data());
3569  iter = 0;
3570 
3571  runnumber = 0;
3572  cout << " writing to header. iteration number " << iter << endl;
3573  pt->AddText(Form("Iteration number: %i", iter));
3574  cout << " writing to header. month " << dt->GetMonth() << endl;
3575  pt->AddText(Form("Time: %02i/%02i/%i %02i:%02i", dt->GetDay(), dt->GetMonth(), dt->GetYear(), dt->GetHour(), dt->GetMinute()));
3576  Tracktuple->SetBranchAddress("run", &runnumber);
3577  Tracktuple->GetEntry(0);
3578  cout << " writing to header. run number " << (int)runnumber << endl;
3579  pt->AddText(Form("Run number: %i", (int)runnumber));
3580  /*
3581  for(int i=1; i<Tracktuple->GetEntries();i++){
3582  float oldrun= runnumber;
3583  Tracktuple->GetEntry(i);
3584  if(oldrun!=runnumber ) pt->AddText(Form("Run number: %i",(int)runnumber));
3585  }
3586  */
3587  cout << " writing to header. number of tracks " << Tracktuple->GetEntries() << endl;
3588  pt->AddText(Form("Total no. tracks: %lli", Tracktuple->GetEntries()));
3589 
3590  // Get residuals and time residuals per subdetector
3591  // we assign here index 0,1,2,3 to detectors -1, -2, 1, 2
3592  // the detectors +-1 have only Argon in Run3
3593 
3594  float bhitst[4]={0};
3595  float rest[4]{};
3596  float trest[4]{};
3597  float treswt[4]{};
3598 
3599  cout << " debug 1 " << endl;
3600  bhitst[0] = resAr0->GetEntries();
3601  bhitst[2] = resAr2->GetEntries();
3602  float nhAr1 = resAr1->GetEntries();
3603  float nhXe1 = resXe1->GetEntries();
3604  cout << " debug 2 " << endl;
3605  bhitst[1] = nhAr1 + nhXe1;
3606  float nhAr3 = 0;
3607  float nhXe3 = 0;
3608  if (resAr3)
3609  nhAr3 = resAr3->GetEntries();
3610  if (resXe3)
3611  nhXe3 = resXe3->GetEntries();
3612  bhitst[3] = nhAr3 + nhXe3;
3613  cout << " debug 3 " << endl;
3614  rest[0] = resAr0->GetFunction("gaus")->GetParameter(2);
3615  rest[2] = resAr2->GetFunction("gaus")->GetParameter(2);
3616  rest[1] = (resAr1->GetFunction("gaus")->GetParameter(2) * nhAr1 + resXe1->GetFunction("gaus")->GetParameter(2) * nhXe1) / bhitst[1];
3617  if (resAr3 and resXe3)
3618  rest[3] = (resAr3->GetFunction("gaus")->GetParameter(2) * nhAr3 + resXe3->GetFunction("gaus")->GetParameter(2) * nhXe3) / bhitst[3];
3619  cout << " debug 4 " << endl;
3620  trest[0] = tresAr0->GetFunction("gaus")->GetParameter(1);
3621  trest[2] = tresAr2->GetFunction("gaus")->GetParameter(1);
3622  trest[1] = (tresAr1->GetFunction("gaus")->GetParameter(1) * nhAr1 + tresXe1->GetFunction("gaus")->GetParameter(1) * nhXe1) / bhitst[1];
3623  if (tresAr3)
3624  trest[3] = (tresAr3->GetFunction("gaus")->GetParameter(1) * nhAr3 + tresXe3->GetFunction("gaus")->GetParameter(1) * nhXe3) / bhitst[3];
3625  cout << " debug 5 " << endl;
3626  treswt[0] = tresAr0->GetFunction("gaus")->GetParameter(2);
3627  treswt[2] = tresAr2->GetFunction("gaus")->GetParameter(2);
3628  treswt[1] = (tresAr1->GetFunction("gaus")->GetParameter(2) * nhAr1 + tresXe1->GetFunction("gaus")->GetParameter(2) * nhXe1) / bhitst[1];
3629  if (tresAr3)
3630  treswt[3] = (tresAr3->GetFunction("gaus")->GetParameter(2) * nhAr3 + tresXe3->GetFunction("gaus")->GetParameter(2) * nhXe3) / bhitst[3];
3631  cout << " debug 6 " << endl;
3632 
3633  // Get the precion hits vs tube hits:
3634 
3635  TDirectory *errors = nullptr;
3636  TDirectory *errorsAr = nullptr;
3637  bool iserrors = false;
3638  bool iserrorsAr = false;
3639  if (file->FindKey("ErrorsAr"))
3640  {
3641  errorsAr = (TDirectory *)file->FindKey("ErrorsAr")->ReadObj();
3642  if (errorsAr != nullptr)
3643  iserrorsAr = true;
3644  }
3645  if (file->FindKey("Errors"))
3646  {
3647  errors = (TDirectory *)file->FindKey("Errors")->ReadObj();
3648  if (errors != nullptr)
3649  iserrors = true;
3650  }
3651 
3652  // double ratiotrt = 0;
3653  double ratioba = 0;
3654  double ratiobc = 0;
3655  double ratioea = 0;
3656  double ratioec = 0;
3657  // TH2F *residual_trt = nullptr;
3658  // TH2F *residual_ba = nullptr;
3659  // TH2F *residual_bc = nullptr;
3660  TH2F *residual_ea = nullptr;
3661  TH2F *residual_ec = nullptr;
3662 
3663  // TH2F *residual_trtP = nullptr;
3664  // TH2F *residual_baP = nullptr;
3665  // TH2F *residual_bcP = nullptr;
3666  TH2F *residual_eaP = nullptr;
3667  TH2F *residual_ecP = nullptr;
3668 
3669  // TH2F *residualAr_trt = nullptr;
3670  TH2F *residualAr_ba = nullptr;
3671  TH2F *residualAr_bc = nullptr;
3672  TH2F *residualAr_ea = nullptr;
3673  TH2F *residualAr_ec = nullptr;
3674 
3675  // TH2F *residualAr_trtP = nullptr;
3676  TH2F *residualAr_baP = nullptr;
3677  TH2F *residualAr_bcP = nullptr;
3678  TH2F *residualAr_eaP = nullptr;
3679  TH2F *residualAr_ecP = nullptr;
3680 
3681  if (iserrors && errors->FindKey("tresidual_trt") && errors->FindKey("tresidual_trtP"))
3682  {
3683  // residual_trt = (TH2F *)errors->FindKey("tresidual_trt")->ReadObj();
3684  if (errors->FindKey("tresidual_ea"))
3685  residual_ea = (TH2F *)errors->FindKey("tresidual_ea")->ReadObj();
3686  if (errors->FindKey("tresidual_ec"))
3687  residual_ec = (TH2F *)errors->FindKey("tresidual_ec")->ReadObj();
3688 
3689  // residual_trtP = (TH2F *)errors->FindKey("tresidual_trtP")->ReadObj();
3690  if (errors->FindKey("tresidual_eaP"))
3691  residual_eaP = (TH2F *)errors->FindKey("tresidual_eaP")->ReadObj();
3692  if (errors->FindKey("tresidual_ecP"))
3693  residual_ecP = (TH2F *)errors->FindKey("tresidual_ecP")->ReadObj();
3694  }
3695  else
3696  {
3697  cout << " No time residual histograms in endcaps: tresidual_trt and tresidual_trtP " << endl;
3698  }
3699  if (iserrorsAr && errorsAr->FindKey("tresidualAr_trt") && errorsAr->FindKey("tresidualAr_trtP"))
3700  {
3701  // residualAr_trt = (TH2F *)errorsAr->FindKey("tresidualAr_trt")->ReadObj();
3702  if (errorsAr->FindKey("tresidualAr_ba"))
3703  residualAr_ba = (TH2F *)errorsAr->FindKey("tresidualAr_ba")->ReadObj();
3704  if (errorsAr->FindKey("tresidualAr_bc"))
3705  residualAr_bc = (TH2F *)errorsAr->FindKey("tresidualAr_bc")->ReadObj();
3706  if (errorsAr->FindKey("tresidualAr_ea"))
3707  residualAr_ea = (TH2F *)errorsAr->FindKey("tresidualAr_ea")->ReadObj();
3708  if (errorsAr->FindKey("tresidualAr_ec"))
3709  residualAr_ec = (TH2F *)errorsAr->FindKey("tresidualAr_ec")->ReadObj();
3710 
3711  // residualAr_trtP = (TH2F *)errorsAr->FindKey("tresidualAr_trtP")->ReadObj();
3712  if (errorsAr->FindKey("tresidualAr_baP"))
3713  residualAr_baP = (TH2F *)errorsAr->FindKey("tresidualAr_baP")->ReadObj();
3714  if (errorsAr->FindKey("tresidualAr_bcP"))
3715  residualAr_bcP = (TH2F *)errorsAr->FindKey("tresidualAr_bcP")->ReadObj();
3716  if (errorsAr->FindKey("tresidualAr_eaP"))
3717  residualAr_eaP = (TH2F *)errorsAr->FindKey("tresidualAr_eaP")->ReadObj();
3718  if (errorsAr->FindKey("tresidualAr_ecP"))
3719  residualAr_ecP = (TH2F *)errorsAr->FindKey("tresidualAr_ecP")->ReadObj();
3720  }
3721  else
3722  {
3723  cout << " No time residual histograms for Argon layers : tresidualAr_trt and tresidualAr_trtP " << endl;
3724  }
3725 
3726  // if (residual_trt && residual_trtP && residual_trt->GetEntries() > 0)
3727  // {
3728  // ratiotrt = (residual_trtP->GetEntries() + residualAr_trtP->GetEntries()) / (residual_trt->GetEntries() + residualAr_trt->GetEntries());
3729  // }
3730  if (residualAr_ba && residualAr_baP && residualAr_ba->GetEntries() > 0)
3731  {
3732  ratioba = residualAr_baP->GetEntries() / residualAr_ba->GetEntries();
3733  }
3734  if (residualAr_bc && residualAr_bcP && residualAr_ea && residualAr_bc->GetEntries() > 0)
3735  {
3736  ratiobc = residualAr_bcP->GetEntries() / residualAr_bc->GetEntries();
3737  }
3738  if (residual_ea && residual_eaP && residualAr_ea && residualAr_eaP && residual_ea->GetEntries() > 0)
3739  {
3740  ratioea = (residual_eaP->GetEntries() + residualAr_eaP->GetEntries()) / (residual_ea->GetEntries() + residualAr_ea->GetEntries());
3741  }
3742  if (residual_ec && residualAr_ecP &&residualAr_ec && residual_ec->GetEntries() > 0)
3743  {
3744  ratioec = (residual_ecP->GetEntries() + residualAr_ecP->GetEntries()) / (residual_ec->GetEntries() + residualAr_ec->GetEntries());
3745  }
3746 
3747  pt->AddText("Barrels:");
3748  pt->AddText(Form(" (side C) hits: %i residual: %.4f mm Time res peak: %.3f ns ", (int)bhitst[0], rest[0], trest[0]));
3749  pt->AddText(Form(" (side C) Time res width: %.2f ns Ratio prec hits: %.3f ", treswt[0], ratioba));
3750  pt->AddText(Form(" (side A) hits: %i residual: %.4f mm Time res peak: %.3f ns ", (int)bhitst[2], rest[2], trest[2]));
3751  pt->AddText(Form(" (side A) Time res width: %.2f ns Ratio prec hits: %.3f ", treswt[2], ratiobc));
3752  pt->AddText(" Endcaps:");
3753  pt->AddText(Form(" (side C) hits: %i residual: %.4f mm Time res peak: %.3f ns", (int)bhitst[1], rest[1], trest[1]));
3754  pt->AddText(Form(" (side C) Time res width: %.2f ns Ratio prec hits: %.3f ", treswt[1], ratioea));
3755  pt->AddText(Form(" (side A) hits: %i residual: %.4f mm Time res peak: %.3f ns", (int)bhitst[3], rest[3], trest[3]));
3756  pt->AddText(Form(" (side A) Time res width: %.2f ns Ratio prec hits: %.3f ", treswt[3], ratioec));
3757 
3758  pt->SetLabel(Form("TRT calibration iteration summary"));
3759 
3760  pt->Draw();
3761 }
3762 
3763 //================================================================
3764 
3765 class SettingsInfo : public TCanvas
3766 {
3767 public:
3768  SettingsInfo(char *);
3769  map<string, string> set;
3770 
3771 private:
3772 };
3773 
3775 {
3776 
3777  this->cd();
3778 
3779  TPaveText *pt = new TPaveText(.1, .1, 0.9, 0.9);
3780  pt->SetTextAlign(11);
3781  pt->AddText(" ");
3782  pt->AddText(" ");
3783  pt->SetLabel(Form("TRT calibration Main Settings"));
3784 
3785  string line;
3786  ifstream myfile(filename);
3787  if (myfile.is_open())
3788  {
3789  while (!myfile.eof())
3790  {
3791  getline(myfile, line);
3792  auto notfirst = [&line](const std::string & sub)->bool{
3793  return line.find(sub)!=0;
3794  };
3795  if (notfirst("#") && notfirst("Clean") && notfirst("Submit") && notfirst("Relink") && notfirst("JobPrefix") && notfirst("Tag") && notfirst("WWW"))
3796  {
3797  int space = line.find_first_of(" ");
3798  if (space != -1)
3799  {
3800  // pt->AddText(line.c_str());
3801  set[trim(line.substr(0, line.find("=") - 1))] = trim(line.substr(line.find("=") + 1, line.size()));
3802  }
3803  }
3804  }
3805  for (const auto & [txt1,txt2]:set)
3806  {
3807  pt->AddText((string(txt1 + " . . . . . . . . . . . . " + txt2)).c_str());
3808  }
3809  myfile.close();
3810  }
3811  else
3812  throw(string("config file not found: ") + string(filename));
3813 
3814  pt->Draw();
3815 }
3816 
3817 //================================================================
3818 
3819 class TrackTupleInfo : public TCanvas
3820 {
3821 public:
3822  TrackTupleInfo(TFile *);
3823 
3824 private:
3825  TNtuple *m_Tracktuple;
3826 };
3827 
3829 {
3830 
3831  m_Tracktuple = (TNtuple *)file->Get("tracktuple");
3832  if (!m_Tracktuple)
3833  throw(string("tracktuple not found!"));
3834 
3835  this->SetName("c1");
3836  this->Divide(1, 2, 0.01, 0.01);
3837  ((TPad *)this->GetPrimitive("c1_1"))->SetLogy();
3838  this->cd(1);
3839  TH1F *trackhits = new TH1F("trackhits", "Accepted hits per track", 60, -0.5, 59.5);
3840  TH1F *trackhits1 = new TH1F("trackhits1", "Accepted hits per track BarrelA", 60, -0.5, 59.5);
3841  TH1F *trackhits2 = new TH1F("trackhits2", "Accepted hits per track EndcaoA", 60, -0.5, 59.5);
3842  TH1F *trackhits3 = new TH1F("trackhits3", "Accepted hits per track BarrelC", 60, -0.5, 59.5);
3843  TH1F *trackhits4 = new TH1F("trackhits4", "Accepted hits per track EndcaoC", 60, -0.5, 59.5);
3844 
3845  TH1F *eventphase = new TH1F("eventphase", "Event Phase", 80, -18, -1);
3846  TH1F *eventphase1 = new TH1F("eventphase1", "Eventphase1", 80, -18, -1);
3847  TH1F *eventphase2 = new TH1F("eventphase2", "Eventphase2", 80, -18, -1);
3848  TH1F *eventphase3 = new TH1F("eventphase3", "Eventphase3", 80, -18, -1);
3849  TH1F *eventphase4 = new TH1F("eventphase4", "Eventphase4", 80, -18, -1);
3850 
3851  m_Tracktuple->Draw("nhits>>trackhits");
3852 
3853  m_Tracktuple->Draw("nhits>>trackhits1", "-log(tan(theta/2))>0 && -log(tan(theta/2))< 1 ", "same");
3854  m_Tracktuple->Draw("nhits>>trackhits2", "-log(tan(theta/2))>1", "same");
3855  m_Tracktuple->Draw("nhits>>trackhits3", "-log(tan(theta/2))<0 && -log(tan(theta/2))> -1 ", "same");
3856  m_Tracktuple->Draw("nhits>>trackhits4", "-log(tan(theta/2))<-1 ", "same");
3857  trackhits1->SetLineColor(2);
3858  trackhits2->SetLineColor(3);
3859  trackhits3->SetLineColor(4);
3860  trackhits4->SetLineColor(5);
3861  trackhits1->Draw("same");
3862  trackhits2->Draw("same");
3863  trackhits3->Draw("same");
3864  trackhits4->Draw("same");
3865  TLegend *leg1 = new TLegend(0.7155172, 0.1038136, 0.8965517, 0.2542373, nullptr, "brNDC");
3866  leg1->AddEntry(trackhits, "all tracks", "l");
3867  leg1->AddEntry(trackhits1, "0 < eta < 1", "l");
3868  leg1->AddEntry(trackhits2, "eta > 1", "l");
3869  leg1->AddEntry(trackhits3, "-1 < eta < 0", "l");
3870  leg1->AddEntry(trackhits4, "eta < -1", "l");
3871  leg1->SetTextSize(0.03);
3872  leg1->Draw();
3873 
3874  trackhits->SetTitle(Form("Accepted precission hits per track (%lli tracks in total)", m_Tracktuple->GetEntries()));
3875  trackhits->GetXaxis()->SetTitle("accepted precission hits");
3876  trackhits->GetYaxis()->SetTitle("No. tracks");
3877  this->SetName("c1");
3878  this->cd(2);
3879  ((TPad *)this->GetPrimitive("c1_2"))->SetLogy();
3880 
3881  m_Tracktuple->Draw("epold>>eventphase");
3882  m_Tracktuple->Draw("epold>>eventphase1", "-log(tan(theta/2))>0 && -log(tan(theta/2))< 1", "same");
3883  m_Tracktuple->Draw("epold>>eventphase2", "-log(tan(theta/2))>1", "same");
3884  m_Tracktuple->Draw("epold>>eventphase3", "-log(tan(theta/2))<0 && -log(tan(theta/2))> -1", "same");
3885  m_Tracktuple->Draw("epold>>eventphase4", "-log(tan(theta/2))<-1", "same");
3886 
3887  eventphase1->SetLineColor(2);
3888  eventphase2->SetLineColor(3);
3889  eventphase3->SetLineColor(4);
3890  eventphase4->SetLineColor(5);
3891 
3892  eventphase->SetTitle("Eventphase");
3893  eventphase->GetXaxis()->SetTitle("eventphase");
3894  eventphase->GetYaxis()->SetTitle("No. tracks");
3895 
3896  TLegend *leg2 = new TLegend(0.7155172, 0.1038136, 0.8965517, 0.2542373, nullptr, "brNDC");
3897  leg2->AddEntry(trackhits1, "0 < eta < 1", "l");
3898  leg2->AddEntry(trackhits2, "eta > 1", "l");
3899  leg2->AddEntry(trackhits3, "-1 < eta < 0", "l");
3900  leg2->AddEntry(trackhits4, "eta < -1", "l");
3901  leg2->SetTextSize(0.03);
3902  leg2->Draw();
3903 }
3904 
3905 //================================================================
3906 
3907 TGraphErrors *GetMean(TH2F *histo)
3908 {
3909 
3910  if (!histo)
3911  return nullptr;
3912  int const nxbins = histo->GetNbinsX();
3913  TGraphErrors *Means = new TGraphErrors(nxbins);
3914  float mean = 0;
3915  float rms = 0;
3916  TF1 *ff = new TF1("ff", "gaus");
3917  for (int i = 0; i < nxbins; i++)
3918  {
3919  TH1D *slice = histo->ProjectionY("slice", i + 1, i + 1);
3920  mean = slice->GetMean();
3921  rms = slice->GetRMS();
3922  ff->SetParameter(0, slice->GetEntries());
3923  ff->SetParameter(1, mean);
3924  ff->SetParameter(2, rms);
3925  mean = ff->GetParameter(1);
3926  rms = ff->GetParameter(2);
3927  float x = histo->GetBinCenter(i + 1);
3928  Means->SetPoint(i, x, mean);
3929  Means->SetPointError(i, 0.5 * histo->GetBinWidth(i), ff->GetParError(1));
3930  delete slice;
3931  }
3932  delete ff;
3933  return Means;
3934 }
3935 
3936 TGraphErrors *GetMeanE(TH2F *histo)
3937 {
3938 
3939  if (!histo)
3940  return nullptr;
3941  int const nxbins = histo->GetNbinsX();
3942  TGraphErrors *Means = new TGraphErrors(nxbins);
3943  float mean = 0;
3944  // float rms = 0;
3945  TF1 *ff = new TF1("ff", "gaus");
3946  for (int i = 0; i < nxbins; i++)
3947  {
3948  TH1D *slice = histo->ProjectionY("slice", i + 1, i + 1);
3949  mean = slice->GetMean();
3950  // rms = slice->GetRMS();
3951  float x = histo->GetBinCenter(i + 1);
3952  Means->SetPoint(i, x, mean);
3953  Means->SetPointError(i, 0.5 * histo->GetBinWidth(i), ff->GetParError(1));
3954  delete slice;
3955  }
3956  delete ff;
3957  return Means;
3958 }
3959 
3960 TGraphErrors *GetPn(TH2F *histo)
3961 {
3962 
3963  if (!histo)
3964  return nullptr;
3965  int const nxbins = histo->GetNbinsX();
3966  TGraphErrors *Means = new TGraphErrors(nxbins);
3967  float mean = 0;
3968  // float rms = 0;
3969  TF1 *ff = new TF1("ff", "gaus");
3970  for (int i = 0; i < nxbins; i++)
3971  {
3972  TH1D *slice = histo->ProjectionY("slice", i + 1, i + 1);
3973  mean = slice->GetEntries();
3974  float x = histo->GetBinCenter(i + 1);
3975  Means->SetPoint(i, x, mean);
3976  Means->SetPointError(i, 0.5 * histo->GetBinWidth(i), ff->GetParError(1));
3977  delete slice;
3978  }
3979  delete ff;
3980  return Means;
3981 }
3982 
3983 TGraphErrors *GetWidth(TH2F *histo)
3984 {
3985  if (!histo)
3986  return nullptr;
3987  int const nxbins = histo->GetNbinsX();
3988  TGraphErrors *Means = new TGraphErrors(nxbins);
3989  float mean = 0;
3990  float rms = 0;
3991  TF1 *ff = new TF1("ff", "gaus");
3992  for (int i = 0; i < nxbins; i++)
3993  {
3994  TH1D *slice = histo->ProjectionY("slice", i + 1, i + 1);
3995  mean = slice->GetMean();
3996  rms = slice->GetRMS();
3997  ff->SetParameter(0, slice->GetEntries());
3998  ff->SetParameter(1, mean);
3999  ff->SetParameter(2, rms);
4000  // int fitresult = slice->Fit("ff", "QR", "", mean - 1.5 * rms, mean + 1.5 * rms);
4001  mean = ff->GetParameter(1);
4002  rms = ff->GetParameter(2);
4003  for (int j = 0; j < 6; j++)
4004  {
4005  // fitresult = slice->Fit("ff", "QR", "", mean - 1.5 * rms, mean + 1.5 * rms);
4006  mean = ff->GetParameter(1);
4007  rms = ff->GetParameter(2);
4008  }
4009  // fitresult = slice->Fit("ff", "QR", "", mean - 1.5 * rms, mean + 1.5 * rms);
4010  float x = histo->GetBinCenter(i + 1);
4011  Means->SetPoint(i, x, rms);
4012  Means->SetPointError(i, 0.5 * histo->GetBinWidth(i), ff->GetParError(2));
4013  delete slice;
4014  }
4015  delete ff;
4016  return Means;
4017 }
4018 
4019 TGraphErrors *GetEntries(TH2F *histo)
4020 {
4021  if (!histo)
4022  return nullptr;
4023  int const nxbins = histo->GetNbinsX();
4024  TGraphErrors *Means = new TGraphErrors(nxbins);
4025  float mean = 0;
4026  float rms = 0;
4027  TF1 *ff = new TF1("ff", "gaus");
4028  for (int i = 0; i < nxbins; i++)
4029  {
4030  TH1D *slice = histo->ProjectionY("slice", i + 1, i + 1);
4031  mean = slice->GetEntries();
4032  rms = sqrt(mean);
4033  float x = histo->GetBinCenter(i + 1);
4034  Means->SetPoint(i, x, mean);
4035  Means->SetPointError(i, 0.5 * histo->GetBinWidth(i), rms);
4036  delete slice;
4037  }
4038  delete ff;
4039  return Means;
4040 }
4041 
4042 TGraphErrors *GetPWidth(TH2F *histo)
4043 {
4044  if (!histo)
4045  return nullptr;
4046  int const nxbins = histo->GetNbinsX();
4047  TGraphErrors *Means = new TGraphErrors(nxbins);
4048  float mean = 0;
4049  float rms = 0;
4050  TF1 *ff = new TF1("ff", "gaus");
4051  for (int i = 0; i < nxbins; i++)
4052  {
4053  TH1D *slice = histo->ProjectionY("slice", i + 1, i + 1);
4054  mean = slice->GetMean();
4055  rms = slice->GetRMS();
4056  ff->SetParameter(0, slice->GetEntries());
4057  ff->SetParameter(1, mean);
4058  ff->SetParameter(2, rms);
4059  // int fitresult = slice->Fit("ff", "QR", "", -2.5, +2.5);
4060  mean = ff->GetParameter(1);
4061  rms = ff->GetParameter(2);
4062  // fitresult = slice->Fit("ff", "QR", "", -2.5, 2.5);
4063  mean = ff->GetParameter(1);
4064  rms = ff->GetParameter(2);
4065  // fitresult = slice->Fit("ff", "QR", "", -2.5, 2.5);
4066  float x = histo->GetBinCenter(i + 1);
4067  Means->SetPoint(i, x, rms);
4068  Means->SetPointError(i, 0.5 * histo->GetBinWidth(i), ff->GetParError(2));
4069  delete slice;
4070  }
4071  delete ff;
4072  return Means;
4073 }
4074 
4075 class PtDependence : public TCanvas
4076 {
4077 public:
4078  PtDependence(TFile *);
4079 
4080 private:
4081  TDirectory *m_errors;
4082 };
4083 
4085 {
4086  m_errors = (TDirectory *)file->FindKey("Errors")->ReadObj();
4087  if (m_errors == nullptr)
4088  throw(string("No errors folder!!!!!!!!!!!!!!!"));
4089  if (m_errors->GetNkeys() > 29)
4090  {
4091  this->Divide(2, 3, 0.01, 0.01);
4092  // Read the histos:
4093  TH2F *residual_trt = (TH2F *)m_errors->FindKey("residual_allhits")->ReadObj();
4094  TH2F *residual_ba = (TH2F *)m_errors->FindKey("residual_ba")->ReadObj();
4095  TH2F *residual_bc = (TH2F *)m_errors->FindKey("residual_bc")->ReadObj();
4096  TH2F *residual_ea = (TH2F *)m_errors->FindKey("residual_ea")->ReadObj();
4097  TH2F *residual_ec = (TH2F *)m_errors->FindKey("residual_ec")->ReadObj();
4098  // TH2F *tresidual_trt = (TH2F *)m_errors->FindKey("tresidual_trt")->ReadObj();
4099  // TH2F *tresidual_ba = (TH2F *)m_errors->FindKey("tresidual_ba")->ReadObj();
4100  // TH2F *tresidual_bc = (TH2F *)m_errors->FindKey("tresidual_bc")->ReadObj();
4101  // TH2F *tresidual_ea = (TH2F *)m_errors->FindKey("tresidual_ea")->ReadObj();
4102  // TH2F *tresidual_ec = (TH2F *)m_errors->FindKey("tresidual_ec")->ReadObj();
4103  TH2F *pull_trtP = (TH2F *)m_errors->FindKey("pull_trtP")->ReadObj();
4104  TH2F *pull_baP = (TH2F *)m_errors->FindKey("pull_baP")->ReadObj();
4105  TH2F *pull_bcP = (TH2F *)m_errors->FindKey("pull_bcP")->ReadObj();
4106  TH2F *pull_eaP = (TH2F *)m_errors->FindKey("pull_eaP")->ReadObj();
4107  TH2F *pull_ecP = (TH2F *)m_errors->FindKey("pull_ecP")->ReadObj();
4108  TH2F *residual_trtP = (TH2F *)m_errors->FindKey("residual_trtP")->ReadObj();
4109  TH2F *residual_baP = (TH2F *)m_errors->FindKey("residual_baP")->ReadObj();
4110  TH2F *residual_bcP = (TH2F *)m_errors->FindKey("residual_bcP")->ReadObj();
4111  TH2F *residual_eaP = (TH2F *)m_errors->FindKey("residual_eaP")->ReadObj();
4112  TH2F *residual_ecP = (TH2F *)m_errors->FindKey("residual_ecP")->ReadObj();
4113  TH2F *tresidual_trtP = (TH2F *)m_errors->FindKey("tresidual_trtP")->ReadObj();
4114  TH2F *tresidual_baP = (TH2F *)m_errors->FindKey("tresidual_baP")->ReadObj();
4115  TH2F *tresidual_bcP = (TH2F *)m_errors->FindKey("tresidual_bcP")->ReadObj();
4116  TH2F *tresidual_eaP = (TH2F *)m_errors->FindKey("tresidual_eaP")->ReadObj();
4117  TH2F *tresidual_ecP = (TH2F *)m_errors->FindKey("tresidual_ecP")->ReadObj();
4118  TH2F *trackerrors_trt = (TH2F *)m_errors->FindKey("trackerrors_trt")->ReadObj();
4119  TH2F *trackerrors_ba = (TH2F *)m_errors->FindKey("trackerrors_ba")->ReadObj();
4120  TH2F *trackerrors_bc = (TH2F *)m_errors->FindKey("trackerrors_bc")->ReadObj();
4121  TH2F *trackerrors_ea = (TH2F *)m_errors->FindKey("trackerrors_ea")->ReadObj();
4122  TH2F *trackerrors_ec = (TH2F *)m_errors->FindKey("trackerrors_ec")->ReadObj();
4123 
4124  this->cd(1);
4125  // Time Residual Mean Vs Pt:
4126  TGraphErrors *tresTRT = GetMean(tresidual_trtP);
4127  TGraphErrors *tresBA = GetMean(tresidual_baP);
4128  tresBA->SetLineColor(kRed);
4129  tresBA->SetMarkerColor(kRed);
4130  TGraphErrors *tresBC = GetMean(tresidual_bcP);
4131  tresBC->SetLineColor(kBlue);
4132  tresBC->SetMarkerColor(kBlue);
4133  TGraphErrors *tresEA = GetMean(tresidual_eaP);
4134  tresEA->SetLineColor(kGreen);
4135  tresEA->SetMarkerColor(kGreen);
4136  TGraphErrors *tresEC = GetMean(tresidual_ecP);
4137  tresEC->SetLineColor(kYellow);
4138  tresEC->SetMarkerColor(kYellow);
4139 
4140  tresTRT->SetTitle("Time Residual Mean VS PT");
4141  tresTRT->GetXaxis()->SetTitle("Pt (GeV)");
4142  tresTRT->GetYaxis()->SetTitle("ns");
4143  tresTRT->GetYaxis()->SetRangeUser(-0.8, 0.4);
4144  tresTRT->Draw("ALP");
4145  tresBA->Draw("LP");
4146  tresBC->Draw("LP");
4147  tresEA->Draw("LP");
4148  tresEC->Draw("LP");
4149 
4150  this->cd(3);
4151  // Time Residual Width Vs Pt
4152 
4153  TGraphErrors *tresTRTw = GetWidth(tresidual_trtP);
4154  TGraphErrors *tresBAw = GetWidth(tresidual_baP);
4155  tresBAw->SetLineColor(kRed);
4156  tresBAw->SetMarkerColor(kRed);
4157  TGraphErrors *tresBCw = GetWidth(tresidual_bcP);
4158  tresBCw->SetLineColor(kBlue);
4159  tresBCw->SetMarkerColor(kBlue);
4160  TGraphErrors *tresEAw = GetWidth(tresidual_eaP);
4161  tresEAw->SetLineColor(kGreen);
4162  tresEAw->SetMarkerColor(kGreen);
4163  TGraphErrors *tresECw = GetWidth(tresidual_ecP);
4164  tresECw->SetLineColor(kYellow);
4165  tresECw->SetMarkerColor(kYellow);
4166 
4167  tresTRTw->SetTitle("Time Residual Width VS PT");
4168  tresTRTw->GetXaxis()->SetTitle("Pt (GeV)");
4169  tresTRTw->GetYaxis()->SetTitle("ns");
4170  tresTRTw->GetYaxis()->SetRangeUser(2.9, 4.0);
4171  tresTRTw->Draw("ALP");
4172  tresBAw->Draw("LP");
4173  tresBCw->Draw("LP");
4174  tresEAw->Draw("LP");
4175  tresECw->Draw("LP");
4176  this->cd(5);
4177 
4178  // Residual Vs Pt:
4179  TGraphErrors *resTRTw = GetWidth(residual_trtP);
4180  TGraphErrors *resBAw = GetWidth(residual_baP);
4181  resBAw->SetLineColor(kRed);
4182  resBAw->SetMarkerColor(kRed);
4183  TGraphErrors *resBCw = GetWidth(residual_bcP);
4184  resBCw->SetLineColor(kBlue);
4185  resBCw->SetMarkerColor(kBlue);
4186  TGraphErrors *resEAw = GetWidth(residual_eaP);
4187  resEAw->SetLineColor(kGreen);
4188  resEAw->SetMarkerColor(kGreen);
4189  TGraphErrors *resECw = GetWidth(residual_ecP);
4190  resECw->SetLineColor(kYellow);
4191  resECw->SetMarkerColor(kYellow);
4192 
4193  resTRTw->SetTitle("Residual Width VS PT");
4194  resTRTw->GetXaxis()->SetTitle("Pt (GeV)");
4195  resTRTw->GetYaxis()->SetTitle("mm");
4196  resTRTw->GetYaxis()->SetRangeUser(0.11, 0.18);
4197  resTRTw->Draw("ALP");
4198  resBAw->Draw("LP");
4199  resBCw->Draw("LP");
4200  resEAw->Draw("LP");
4201  resECw->Draw("LP");
4202 
4203  this->cd(2);
4204  // Pull Width vs Pt:
4205  TGraphErrors *pullTRTw = GetPWidth(pull_trtP);
4206  TGraphErrors *pullBAw = GetPWidth(pull_baP);
4207  pullBAw->SetLineColor(kRed);
4208  pullBAw->SetMarkerColor(kRed);
4209  TGraphErrors *pullBCw = GetPWidth(pull_bcP);
4210  pullBCw->SetLineColor(kBlue);
4211  pullBCw->SetMarkerColor(kBlue);
4212  TGraphErrors *pullEAw = GetPWidth(pull_eaP);
4213  pullEAw->SetLineColor(kGreen);
4214  pullEAw->SetMarkerColor(kGreen);
4215  TGraphErrors *pullECw = GetPWidth(pull_ecP);
4216  pullECw->SetLineColor(kYellow);
4217  pullECw->SetMarkerColor(kYellow);
4218 
4219  pullTRTw->SetTitle("Pull Width VS PT");
4220  pullTRTw->GetXaxis()->SetTitle("Pt (GeV)");
4221  pullTRTw->GetYaxis()->SetTitle(" ");
4222  pullTRTw->GetYaxis()->SetRangeUser(0.7, 1.3);
4223  pullTRTw->Draw("ALP");
4224  pullBAw->Draw("LP");
4225  pullBCw->Draw("LP");
4226  pullEAw->Draw("LP");
4227  pullECw->Draw("LP");
4228 
4229  this->cd(4);
4230  // Pull Width vs Pt:
4231  TGraphErrors *trkTRTw = GetMean(trackerrors_trt);
4232  TGraphErrors *trkBAw = GetMean(trackerrors_ba);
4233  trkBAw->SetLineColor(kRed);
4234  trkBAw->SetMarkerColor(kRed);
4235  TGraphErrors *trkBCw = GetMean(trackerrors_bc);
4236  trkBCw->SetLineColor(kBlue);
4237  trkBCw->SetMarkerColor(kBlue);
4238  TGraphErrors *trkEAw = GetMean(trackerrors_ea);
4239  trkEAw->SetLineColor(kGreen);
4240  trkEAw->SetMarkerColor(kGreen);
4241  TGraphErrors *trkECw = GetMean(trackerrors_ec);
4242  trkECw->SetLineColor(kYellow);
4243  trkECw->SetMarkerColor(kYellow);
4244 
4245  trkTRTw->SetTitle("Trk error Mean Width VS PT");
4246  trkTRTw->GetXaxis()->SetTitle("Pt (GeV)");
4247  trkTRTw->GetYaxis()->SetTitle("mm");
4248  trkTRTw->GetYaxis()->SetRangeUser(0.0, 0.07);
4249  trkTRTw->Draw("ALP");
4250  trkBAw->Draw("LP");
4251  trkBCw->Draw("LP");
4252  trkEAw->Draw("LP");
4253  trkECw->Draw("LP");
4254 
4255  this->cd(6);
4256 
4257  // Residual Vs Pt:
4258  TGraphErrors *presTRTw = GetWidth(residual_trt);
4259  TGraphErrors *presBAw = GetWidth(residual_ba);
4260  presBAw->SetLineColor(kRed);
4261  presBAw->SetMarkerColor(kRed);
4262  TGraphErrors *presBCw = GetWidth(residual_bc);
4263  presBCw->SetLineColor(kBlue);
4264  presBCw->SetMarkerColor(kBlue);
4265  TGraphErrors *presEAw = GetWidth(residual_ea);
4266  presEAw->SetLineColor(kGreen);
4267  presEAw->SetMarkerColor(kGreen);
4268  TGraphErrors *presECw = GetWidth(residual_ec);
4269  presECw->SetLineColor(kYellow);
4270  presECw->SetMarkerColor(kYellow);
4271 
4272  presTRTw->SetTitle("Residual Width all hits VS PT");
4273  presTRTw->GetXaxis()->SetTitle("Pt (GeV)");
4274  presTRTw->GetYaxis()->SetTitle("mm");
4275  presTRTw->GetYaxis()->SetRangeUser(0.11, 0.18);
4276  presTRTw->Draw("ALP");
4277  presBAw->Draw("LP");
4278  presBCw->Draw("LP");
4279  presEAw->Draw("LP");
4280  presECw->Draw("LP");
4281  }
4282  else
4283  {
4284  cout << " Not enough keys in Errors directory for Pt dependence plots " << endl;
4285  }
4286 }
4287 
4288 class TBDependence : public TCanvas
4289 {
4290 public:
4291  TBDependence(TFile *);
4292 
4293 private:
4294  TDirectory *errors;
4295 };
4296 
4298 {
4299  errors = (TDirectory *)file->FindKey("Errors")->ReadObj();
4300  if (!errors)
4301  throw(string("No errors folder!!!!!!!!!!!!!!!"));
4302  if (errors->GetNkeys() > 19)
4303  {
4304  this->Divide(2, 3, 0.01, 0.01);
4305 
4306  // Read the histos:
4307 
4308  TH2F *pull_vs_tb_trt = (TH2F *)errors->FindKey("pull_vs_tb_trt")->ReadObj();
4309  TH2F *pull_vs_tb_ba = (TH2F *)errors->FindKey("pull_vs_tb_ba")->ReadObj();
4310  TH2F *pull_vs_tb_bc = (TH2F *)errors->FindKey("pull_vs_tb_bc")->ReadObj();
4311  TH2F *pull_vs_tb_ea = (TH2F *)errors->FindKey("pull_vs_tb_ea")->ReadObj();
4312  TH2F *pull_vs_tb_ec = (TH2F *)errors->FindKey("pull_vs_tb_ec")->ReadObj();
4313 
4314  TH2F *errors_vs_tb_trt = (TH2F *)errors->FindKey("errors_vs_tb_trt")->ReadObj();
4315  TH2F *errors_vs_tb_ba = (TH2F *)errors->FindKey("errors_vs_tb_ba")->ReadObj();
4316  TH2F *errors_vs_tb_bc = (TH2F *)errors->FindKey("errors_vs_tb_bc")->ReadObj();
4317  TH2F *errors_vs_tb_ea = (TH2F *)errors->FindKey("errors_vs_tb_ea")->ReadObj();
4318  TH2F *errors_vs_tb_ec = (TH2F *)errors->FindKey("errors_vs_tb_ec")->ReadObj();
4319 
4320  TH2F *residual_vs_tb_trt = (TH2F *)errors->FindKey("residual_vs_tb_trt")->ReadObj();
4321  TH2F *residual_vs_tb_ba = (TH2F *)errors->FindKey("residual_vs_tb_ba")->ReadObj();
4322  TH2F *residual_vs_tb_bc = (TH2F *)errors->FindKey("residual_vs_tb_bc")->ReadObj();
4323  TH2F *residual_vs_tb_ea = (TH2F *)errors->FindKey("residual_vs_tb_ea")->ReadObj();
4324  TH2F *residual_vs_tb_ec = (TH2F *)errors->FindKey("residual_vs_tb_ec")->ReadObj();
4325 
4326  TH2F *trackerrors_vs_tb_trt = (TH2F *)errors->FindKey("trackerrors_vs_tb_trt")->ReadObj();
4327  TH2F *trackerrors_vs_tb_ba = (TH2F *)errors->FindKey("trackerrors_vs_tb_ba")->ReadObj();
4328  TH2F *trackerrors_vs_tb_bc = (TH2F *)errors->FindKey("trackerrors_vs_tb_bc")->ReadObj();
4329  TH2F *trackerrors_vs_tb_ea = (TH2F *)errors->FindKey("trackerrors_vs_tb_ea")->ReadObj();
4330  TH2F *trackerrors_vs_tb_ec = (TH2F *)errors->FindKey("trackerrors_vs_tb_ec")->ReadObj();
4331 
4332  this->cd(1);
4333  // Pull widht Vs Pt:
4334  TGraphErrors *tresTRT = GetPWidth(pull_vs_tb_trt);
4335  TGraphErrors *tresBA = GetPWidth(pull_vs_tb_ba);
4336  tresBA->SetLineColor(kRed);
4337  tresBA->SetMarkerColor(kRed);
4338  TGraphErrors *tresBC = GetPWidth(pull_vs_tb_bc);
4339  tresBC->SetLineColor(kBlue);
4340  tresBC->SetMarkerColor(kBlue);
4341  TGraphErrors *tresEA = GetPWidth(pull_vs_tb_ea);
4342  tresEA->SetLineColor(kGreen);
4343  tresEA->SetMarkerColor(kGreen);
4344  TGraphErrors *tresEC = GetPWidth(pull_vs_tb_ec);
4345  tresEC->SetLineColor(kYellow);
4346  tresEC->SetMarkerColor(kYellow);
4347 
4348  tresTRT->SetTitle("Pull Width VS Drift Time. Pt>2GeV");
4349  tresTRT->GetXaxis()->SetTitle("Drift Time ");
4350  tresTRT->GetYaxis()->SetTitle(" ");
4351  tresTRT->GetYaxis()->SetRangeUser(0.7, 1.3);
4352  tresTRT->Draw("ALP");
4353  tresBA->Draw("LP");
4354  tresBC->Draw("LP");
4355  tresEA->Draw("LP");
4356  tresEC->Draw("LP");
4357 
4358  this->cd(2);
4359  TGraphErrors *errorsTRT = GetMeanE(errors_vs_tb_trt);
4360  TGraphErrors *errorsBA = GetMeanE(errors_vs_tb_ba);
4361  errorsBA->SetLineColor(kRed);
4362  errorsBA->SetMarkerColor(kRed);
4363  TGraphErrors *errorsBC = GetMeanE(errors_vs_tb_bc);
4364  errorsBC->SetLineColor(kBlue);
4365  errorsBC->SetMarkerColor(kBlue);
4366  TGraphErrors *errorsEA = GetMeanE(errors_vs_tb_ea);
4367  errorsEA->SetLineColor(kGreen);
4368  errorsEA->SetMarkerColor(kGreen);
4369  TGraphErrors *errorsEC = GetMeanE(errors_vs_tb_ec);
4370  errorsEC->SetLineColor(kYellow);
4371  errorsEC->SetMarkerColor(kYellow);
4372  errorsTRT->SetTitle("Error VS Drift Time");
4373  errorsTRT->GetXaxis()->SetTitle("Drift Time");
4374  errorsTRT->GetYaxis()->SetTitle("mm");
4375  errorsTRT->GetYaxis()->SetRangeUser(0.05, 0.24);
4376  errorsTRT->Draw("ALP");
4377  errorsBA->Draw("LP");
4378  errorsBC->Draw("LP");
4379  errorsEA->Draw("LP");
4380  errorsEC->Draw("LP");
4381 
4382  this->cd(3);
4383  TGraphErrors *ntresBA = GetPn(pull_vs_tb_ba);
4384  ntresBA->SetLineColor(kRed);
4385  ntresBA->SetMarkerColor(kRed);
4386  TGraphErrors *ntresBC = GetPn(pull_vs_tb_bc);
4387  ntresBC->SetLineColor(kBlue);
4388  ntresBC->SetMarkerColor(kBlue);
4389  TGraphErrors *ntresEA = GetPn(pull_vs_tb_ea);
4390  ntresEA->SetLineColor(kGreen);
4391  ntresEA->SetMarkerColor(kGreen);
4392  TGraphErrors *ntresEC = GetPn(pull_vs_tb_ec);
4393  ntresEC->SetLineColor(kYellow);
4394  ntresEC->SetMarkerColor(kYellow);
4395  ntresEA->SetTitle("Number of hits VS Drift Time. Pt>2GeV");
4396  ntresEA->GetXaxis()->SetTitle("Drift Time");
4397  ntresEA->GetYaxis()->SetTitle(" hits ");
4398  ntresEA->Draw("ALP");
4399  ntresEC->Draw("LP");
4400  ntresBA->Draw("LP");
4401  ntresBC->Draw("LP");
4402 
4403  this->cd(4);
4404  TGraphErrors *terrorsTRT = GetMean(trackerrors_vs_tb_trt);
4405  TGraphErrors *terrorsBA = GetMean(trackerrors_vs_tb_ba);
4406  terrorsBA->SetLineColor(kRed);
4407  terrorsBA->SetMarkerColor(kRed);
4408  TGraphErrors *terrorsBC = GetMean(trackerrors_vs_tb_bc);
4409  terrorsBC->SetLineColor(kBlue);
4410  terrorsBC->SetMarkerColor(kBlue);
4411  TGraphErrors *terrorsEA = GetMean(trackerrors_vs_tb_ea);
4412  terrorsEA->SetLineColor(kGreen);
4413  terrorsEA->SetMarkerColor(kGreen);
4414  TGraphErrors *terrorsEC = GetMean(trackerrors_vs_tb_ec);
4415  terrorsEC->SetLineColor(kYellow);
4416  terrorsEC->SetMarkerColor(kYellow);
4417  terrorsTRT->SetTitle("Track Error VS Drift Time");
4418  terrorsTRT->GetXaxis()->SetTitle("Drift Time");
4419  terrorsTRT->GetYaxis()->SetTitle("mm");
4420  terrorsTRT->GetYaxis()->SetRangeUser(0.0, 0.07);
4421  terrorsTRT->Draw("ALP");
4422  terrorsBA->Draw("LP");
4423  terrorsBC->Draw("LP");
4424  terrorsEA->Draw("LP");
4425  terrorsEC->Draw("LP");
4426 
4427  this->cd(5);
4428  TGraphErrors *residualTRT = GetWidth(residual_vs_tb_trt);
4429  TGraphErrors *residualBA = GetWidth(residual_vs_tb_ba);
4430  residualBA->SetLineColor(kRed);
4431  residualBA->SetMarkerColor(kRed);
4432  TGraphErrors *residualBC = GetWidth(residual_vs_tb_bc);
4433  residualBC->SetLineColor(kBlue);
4434  residualBC->SetMarkerColor(kBlue);
4435  TGraphErrors *residualEA = GetWidth(residual_vs_tb_ea);
4436  residualEA->SetLineColor(kGreen);
4437  residualEA->SetMarkerColor(kGreen);
4438  TGraphErrors *residualEC = GetWidth(residual_vs_tb_ec);
4439  residualEC->SetLineColor(kYellow);
4440  residualEC->SetMarkerColor(kYellow);
4441  residualTRT->SetTitle("Residual VS Drift Time. Pt > 2GeV");
4442  residualTRT->GetXaxis()->SetTitle("Drift Time ");
4443  residualTRT->GetYaxis()->SetTitle("mm");
4444  residualTRT->GetYaxis()->SetRangeUser(0.05, 0.24);
4445  residualTRT->Draw("ALP");
4446  residualBA->Draw("LP");
4447  residualBC->Draw("LP");
4448  residualEA->Draw("LP");
4449  residualEC->Draw("LP");
4450 
4451  this->cd(6);
4452 
4453  TH2F *residual_trt = (TH2F *)errors->FindKey("tresidual_trt")->ReadObj();
4454  TH2F *residual_ba = (TH2F *)errors->FindKey("tresidual_ba")->ReadObj();
4455  TH2F *residual_bc = (TH2F *)errors->FindKey("tresidual_bc")->ReadObj();
4456  TH2F *residual_ea = (TH2F *)errors->FindKey("tresidual_ea")->ReadObj();
4457  TH2F *residual_ec = (TH2F *)errors->FindKey("tresidual_ec")->ReadObj();
4458 
4459  TH2F *residual_trtP = (TH2F *)errors->FindKey("tresidual_trtP")->ReadObj();
4460  TH2F *residual_baP = (TH2F *)errors->FindKey("tresidual_baP")->ReadObj();
4461  TH2F *residual_bcP = (TH2F *)errors->FindKey("tresidual_bcP")->ReadObj();
4462  TH2F *residual_eaP = (TH2F *)errors->FindKey("tresidual_eaP")->ReadObj();
4463  TH2F *residual_ecP = (TH2F *)errors->FindKey("tresidual_ecP")->ReadObj();
4464 
4465  TGraphErrors *residualTRT1 = GetEntries(residual_trt);
4466  TGraphErrors *residualBA1 = GetEntries(residual_ba);
4467  residualBA1->SetLineColor(kRed);
4468  residualBA1->SetMarkerColor(kRed);
4469  TGraphErrors *residualBC1 = GetEntries(residual_bc);
4470  residualBC1->SetLineColor(kBlue);
4471  residualBC1->SetMarkerColor(kBlue);
4472  TGraphErrors *residualEA1 = GetEntries(residual_ea);
4473  residualEA1->SetLineColor(kGreen);
4474  residualEA1->SetMarkerColor(kGreen);
4475  TGraphErrors *residualEC1 = GetEntries(residual_ec);
4476  residualEC1->SetLineColor(kYellow);
4477  residualEC1->SetMarkerColor(kYellow);
4478 
4479  TGraphErrors *residualTRT2 = GetEntries(residual_trtP);
4480  TGraphErrors *residualBA2 = GetEntries(residual_baP);
4481  residualBA2->SetLineColor(kRed);
4482  residualBA2->SetMarkerColor(kRed);
4483  TGraphErrors *residualBC2 = GetEntries(residual_bcP);
4484  residualBC2->SetLineColor(kBlue);
4485  residualBC2->SetMarkerColor(kBlue);
4486  TGraphErrors *residualEA2 = GetEntries(residual_eaP);
4487  residualEA2->SetLineColor(kGreen);
4488  residualEA2->SetMarkerColor(kGreen);
4489  TGraphErrors *residualEC2 = GetEntries(residual_ecP);
4490  residualEC2->SetLineColor(kYellow);
4491  residualEC2->SetMarkerColor(kYellow);
4492 
4493  int nbins = residualTRT1->GetN();
4494 
4495  TGraphErrors *ratioTRT = new TGraphErrors(nbins);
4496  TGraphErrors *ratioBA = new TGraphErrors(nbins);
4497  TGraphErrors *ratioBC = new TGraphErrors(nbins);
4498  TGraphErrors *ratioEA = new TGraphErrors(nbins);
4499  TGraphErrors *ratioEC = new TGraphErrors(nbins);
4500 
4501  for (int i = 0; i < nbins; i++)
4502  {
4503  double prec = 0;
4504  double all = 0;
4505  double x = 0;
4506  residualTRT1->GetPoint(i, x, all);
4507  residualTRT2->GetPoint(i, x, prec);
4508  cout << i << " " << x << " " << prec << " " << all << endl;
4509  if (all > 0)
4510  {
4511  ratioTRT->SetPoint(i, x, prec / all);
4512  }
4513  else
4514  {
4515  ratioTRT->SetPoint(i, x, 0);
4516  }
4517  residualBA1->GetPoint(i, x, all);
4518  residualBA2->GetPoint(i, x, prec);
4519  cout << i << " " << x << " " << prec << " " << all << endl;
4520  if (all > 0)
4521  {
4522  ratioBA->SetPoint(i, x, prec / all);
4523  }
4524  else
4525  {
4526  ratioBA->SetPoint(i, x, 0);
4527  }
4528 
4529  residualBC1->GetPoint(i, x, all);
4530  residualBC2->GetPoint(i, x, prec);
4531  cout << i << " " << x << " " << prec << " " << all << endl;
4532  if (all > 0)
4533  {
4534  ratioBC->SetPoint(i, x, prec / all);
4535  }
4536  else
4537  {
4538  ratioBC->SetPoint(i, x, 0);
4539  }
4540 
4541  residualEA1->GetPoint(i, x, all);
4542  residualEA2->GetPoint(i, x, prec);
4543  cout << i << " " << x << " " << prec << " " << all << endl;
4544  if (all > 0)
4545  {
4546  ratioEA->SetPoint(i, x, prec / all);
4547  }
4548  else
4549  {
4550  ratioEA->SetPoint(i, x, 0);
4551  }
4552 
4553  residualEC1->GetPoint(i, x, all);
4554  residualEC2->GetPoint(i, x, prec);
4555  cout << i << " " << x << " " << prec << " " << all << endl;
4556  if (all > 0)
4557  {
4558  ratioEC->SetPoint(i, x, prec / all);
4559  }
4560  else
4561  {
4562  ratioEC->SetPoint(i, x, 0);
4563  }
4564  cout << endl;
4565  }
4566 
4567  ratioTRT->SetTitle("Ratio Precision Hits Vs Pt. Pt > 2GeV");
4568  ratioTRT->GetXaxis()->SetTitle("Precission Hits/Total Hits ");
4569  ratioTRT->GetYaxis()->SetTitle("pt");
4570  ratioTRT->GetYaxis()->SetRangeUser(0.05, 0.24);
4571  ratioTRT->GetYaxis()->SetRangeUser(0.3, 1);
4572 
4573  ratioBA->SetLineColor(kRed);
4574  ratioBC->SetLineColor(kBlue);
4575  ratioEA->SetLineColor(kGreen);
4576  ratioEC->SetLineColor(kYellow);
4577 
4578  ratioTRT->Draw("alp");
4579  ratioBA->Draw("lp");
4580  ratioBC->Draw("lp");
4581  ratioEA->Draw("lp");
4582  ratioEC->Draw("lp");
4583  }
4584  else
4585  {
4586  cout << " Not enough keys in Errors directory for tb dependence plots " << endl;
4587  }
4588 }
4589 
4590 class ToTDependence : public TCanvas
4591 {
4592 public:
4593  ToTDependence(TFile *, bool, bool, bool isAr);
4594 
4595 private:
4596  TDirectory *m_errors;
4597 };
4598 
4599 ToTDependence::ToTDependence(TFile *file, bool isba = true, bool isht = false, bool isAr = false)
4600 {
4601  m_errors = nullptr;
4602  cout << "READING CORRECTIONS: " << endl;
4603 
4604  if (!isAr)
4605  m_errors = (TDirectory *)file->FindKey("Correction")->ReadObj();
4606  else
4607  m_errors = (TDirectory *)file->FindKey("CorrectionAr")->ReadObj();
4608 
4609  this->Divide(2, 3, 0.01, 0.01);
4610 
4611  // Read the histos:
4612 
4613  TH2F *tres_vs_ToT_ba = nullptr;
4614  TH2F *tres_vs_ToT_bc = nullptr;
4615  // Residual:
4616  TH2F *res_vs_ToT_ba = nullptr;
4617  TH2F *res_vs_ToT_bc = nullptr;
4618 
4619  if (!isAr)
4620  {
4621  if (!isht)
4622  {
4623  if (isba)
4624  {
4625  if (m_errors->FindKey("tres_vs_ToT_ba"))
4626  tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tres_vs_ToT_ba")->ReadObj();
4627  if (m_errors->FindKey("res_vs_ToT_ba"))
4628  res_vs_ToT_ba = (TH2F *)m_errors->FindKey("res_vs_ToT_ba")->ReadObj();
4629  if (m_errors->FindKey("tres_vs_ToT_bc"))
4630  tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tres_vs_ToT_bc")->ReadObj();
4631  if (m_errors->FindKey("res_vs_ToT_bc"))
4632  res_vs_ToT_bc = (TH2F *)m_errors->FindKey("res_vs_ToT_bc")->ReadObj();
4633  }
4634  else
4635  {
4636  if (m_errors->FindKey("tres_vs_ToT_ea"))
4637  tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tres_vs_ToT_ea")->ReadObj();
4638  if (m_errors->FindKey("res_vs_ToT_ea"))
4639  res_vs_ToT_ba = (TH2F *)m_errors->FindKey("res_vs_ToT_ea")->ReadObj();
4640  if (m_errors->FindKey("tres_vs_ToT_ec"))
4641  tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tres_vs_ToT_ec")->ReadObj();
4642  if (m_errors->FindKey("res_vs_ToT_ec"))
4643  res_vs_ToT_bc = (TH2F *)m_errors->FindKey("res_vs_ToT_ec")->ReadObj();
4644  }
4645  }
4646  else
4647  {
4648  if (isba)
4649  {
4650  if (m_errors->FindKey("tres_vs_HT_ba"))
4651  tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tres_vs_HT_ba")->ReadObj();
4652  if (m_errors->FindKey("res_vs_HT_ba"))
4653  res_vs_ToT_ba = (TH2F *)m_errors->FindKey("res_vs_HT_ba")->ReadObj();
4654  if (m_errors->FindKey("tres_vs_HT_bc"))
4655  tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tres_vs_HT_bc")->ReadObj();
4656  if (m_errors->FindKey("res_vs_HT_bc"))
4657  res_vs_ToT_bc = (TH2F *)m_errors->FindKey("res_vs_HT_bc")->ReadObj();
4658  }
4659  else
4660  {
4661  if (m_errors->FindKey("tres_vs_HT_ea"))
4662  tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tres_vs_HT_ea")->ReadObj();
4663  if (m_errors->FindKey("res_vs_HT_ea"))
4664  res_vs_ToT_ba = (TH2F *)m_errors->FindKey("res_vs_HT_ea")->ReadObj();
4665  if (m_errors->FindKey("tres_vs_HT_ec"))
4666  tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tres_vs_HT_ec")->ReadObj();
4667  if (m_errors->FindKey("res_vs_HT_ec"))
4668  res_vs_ToT_bc = (TH2F *)m_errors->FindKey("res_vs_HT_ec")->ReadObj();
4669  }
4670  }
4671  }
4672  else
4673  {
4674  if (!isht)
4675  {
4676  if (isba)
4677  {
4678  if (m_errors->FindKey("tresAr_vs_ToT_ba"))
4679  tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tresAr_vs_ToT_ba")->ReadObj();
4680  if (m_errors->FindKey("resAr_vs_ToT_ba"))
4681  res_vs_ToT_ba = (TH2F *)m_errors->FindKey("resAr_vs_ToT_ba")->ReadObj();
4682  if (m_errors->FindKey("tresAr_vs_ToT_bc"))
4683  tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tresAr_vs_ToT_bc")->ReadObj();
4684  if (m_errors->FindKey("resAr_vs_ToT_bc"))
4685  res_vs_ToT_bc = (TH2F *)m_errors->FindKey("resAr_vs_ToT_bc")->ReadObj();
4686  }
4687  else
4688  {
4689  if (m_errors->FindKey("tresAr_vs_ToT_ea"))
4690  tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tresAr_vs_ToT_ea")->ReadObj();
4691  if (m_errors->FindKey("resAr_vs_ToT_ea"))
4692  res_vs_ToT_ba = (TH2F *)m_errors->FindKey("resAr_vs_ToT_ea")->ReadObj();
4693  if (m_errors->FindKey("tresAr_vs_ToT_ec"))
4694  tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tresAr_vs_ToT_ec")->ReadObj();
4695  if (m_errors->FindKey("resAr_vs_ToT_ec"))
4696  res_vs_ToT_bc = (TH2F *)m_errors->FindKey("resAr_vs_ToT_ec")->ReadObj();
4697  }
4698  }
4699  else
4700  {
4701  if (isba)
4702  {
4703  if (m_errors->FindKey("tresAr_vs_HT_ba"))
4704  tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tresAr_vs_HT_ba")->ReadObj();
4705  if (m_errors->FindKey("resAr_vs_HT_ba"))
4706  res_vs_ToT_ba = (TH2F *)m_errors->FindKey("resAr_vs_HT_ba")->ReadObj();
4707  if (m_errors->FindKey("tresAr_vs_HT_bc"))
4708  tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tresAr_vs_HT_bc")->ReadObj();
4709  if (m_errors->FindKey("resAr_vs_HT_bc"))
4710  res_vs_ToT_bc = (TH2F *)m_errors->FindKey("resAr_vs_HT_bc")->ReadObj();
4711  }
4712  else
4713  {
4714  if (m_errors->FindKey("tresAr_vs_HT_ea"))
4715  tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tresAr_vs_HT_ea")->ReadObj();
4716  if (m_errors->FindKey("resAr_vs_HT_ea"))
4717  res_vs_ToT_ba = (TH2F *)m_errors->FindKey("resAr_vs_HT_ea")->ReadObj();
4718  if (m_errors->FindKey("tresAr_vs_HT_ec"))
4719  tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tresAr_vs_HT_ec")->ReadObj();
4720  if (m_errors->FindKey("resAr_vs_HT_ec"))
4721  res_vs_ToT_bc = (TH2F *)m_errors->FindKey("resAr_vs_HT_ec")->ReadObj();
4722  }
4723  }
4724  }
4725 
4726  this->cd(1);
4727  // Time Residual Mean Vs Pt:
4728  TGraphErrors *tresBA = GetMean(tres_vs_ToT_ba);
4729  tresBA->SetLineColor(kRed);
4730  tresBA->SetMarkerColor(kRed);
4731  if (not tres_vs_ToT_ba){
4732  throw std::runtime_error("tres_vs_ToT_ba pointer is null");
4733  }
4734  if (isba)
4735  tres_vs_ToT_ba->SetTitle("Barrel A Time Residual Mean VS ToT");
4736  else
4737  tres_vs_ToT_ba->SetTitle("Endcap A Time Residual Mean VS ToT");
4738  tres_vs_ToT_ba->GetXaxis()->SetTitle("ToT (bin)");
4739  tres_vs_ToT_ba->GetYaxis()->SetTitle("Time Residual (ns)");
4740 
4741  if (isht){
4742  if (isba){
4743  tres_vs_ToT_ba->SetTitle("Barrel A Time Residual Mean VS HT");
4744  }else{
4745  tres_vs_ToT_ba->SetTitle("Endcap A Time Residual Mean VS HT");}
4746  tres_vs_ToT_ba->GetXaxis()->SetTitle("HT (bin)");
4747  }
4748 
4749  tres_vs_ToT_ba->Draw("colz");
4750  tresBA->Draw("same");
4751 
4752  this->cd(3);
4753  TGraphErrors *tresBC = GetMean(tres_vs_ToT_bc);
4754  tresBC->SetLineColor(kBlue);
4755  tresBC->SetMarkerColor(kBlue);
4756  if (isba){
4757  if (not tres_vs_ToT_bc){
4758  throw std::runtime_error(" tres_vs_ToT_bc is null");
4759  }
4760  tres_vs_ToT_bc->SetTitle("Barrel C Time Residual Mean VS ToT");
4761  }else{
4762  tres_vs_ToT_bc->SetTitle("Endcap C Time Residual Mean VS ToT");}
4763  tres_vs_ToT_bc->GetXaxis()->SetTitle("ToT (bin)");
4764  tres_vs_ToT_bc->GetYaxis()->SetTitle("Time Residual (ns)");
4765  if (isht){
4766  if (isba){
4767  tres_vs_ToT_bc->SetTitle("Barrel C Time Residual Mean VS HT");
4768  }else{
4769  tres_vs_ToT_bc->SetTitle("Endcap C Time Residual Mean VS HT");
4770  }
4771  tres_vs_ToT_bc->GetXaxis()->SetTitle("HT (bin)");
4772  }
4773 
4774  tres_vs_ToT_bc->Draw("colz");
4775  tresBC->Draw("same");
4776 
4777  this->cd(5);
4778  tresBA->SetTitle("Barrel Time Residual Mean vs ToT");
4779  if (!isba)
4780  tresBA->SetTitle("Endcap Time Residual Mean vs ToT");
4781  tresBA->GetXaxis()->SetTitle("ToT (bin)");
4782 
4783  if (isht)
4784  {
4785  tresBA->SetTitle("Barrel Time Residual Mean vs HT");
4786  if (!isba)
4787  tresBA->SetTitle("Endcap Time Residual Mean vs HT");
4788  tresBA->GetXaxis()->SetTitle("HT");
4789  }
4790  tresBA->GetXaxis()->SetRangeUser(-0.5, 23.5);
4791  tresBA->GetYaxis()->SetRangeUser(-10, 10);
4792  if (isht)
4793  {
4794  tresBA->GetXaxis()->SetRangeUser(-0.5, 1.5);
4795  tresBA->GetYaxis()->SetRangeUser(-3, 3);
4796  }
4797  tresBA->Draw("alp");
4798  tresBC->Draw("same");
4799 
4800  this->cd(2);
4801  TGraphErrors *resBA1 = GetMean(res_vs_ToT_ba);
4802  resBA1->SetLineColor(kRed);
4803  resBA1->SetMarkerColor(kRed);
4804  if (not res_vs_ToT_ba){
4805  throw std::runtime_error("res_vs_ToT_ba is null ptr");
4806  }
4807  if (isba)
4808  res_vs_ToT_ba->SetTitle("Barrel A Residual Mean VS ToT");
4809  else
4810  res_vs_ToT_ba->SetTitle("Endcap A Residual Mean VS ToT");
4811  res_vs_ToT_ba->GetXaxis()->SetTitle("ToT (bin)");
4812  res_vs_ToT_ba->GetYaxis()->SetTitle("Residual (mm)");
4813  if (isht)
4814  {
4815  if (isba)
4816  res_vs_ToT_ba->SetTitle("Barrel A Residual Mean VS HT");
4817  else
4818  res_vs_ToT_ba->SetTitle("Endcap A Residual Mean VS HT");
4819  res_vs_ToT_ba->GetXaxis()->SetTitle("HT (bin)");
4820  }
4821  res_vs_ToT_ba->Draw("colz");
4822  resBA1->Draw("same");
4823 
4824  this->cd(4);
4825  TGraphErrors *resBC1 = GetMean(res_vs_ToT_bc);
4826  resBC1->SetLineColor(kBlue);
4827  resBC1->SetMarkerColor(kBlue);
4828  if (isba)
4829  res_vs_ToT_bc->SetTitle("Barrel C Residual Mean VS ToT");
4830  else
4831  res_vs_ToT_bc->SetTitle("Endcap C Residual Mean VS ToT");
4832  res_vs_ToT_bc->GetXaxis()->SetTitle("ToT (bin)");
4833  res_vs_ToT_bc->GetYaxis()->SetTitle("Residual (mm)");
4834  if (isht)
4835  {
4836  if (isba)
4837  res_vs_ToT_bc->SetTitle("Barrel C Residual Mean VS HT");
4838  else
4839  res_vs_ToT_bc->SetTitle("Endcap C Residual Mean VS HT");
4840  res_vs_ToT_bc->GetXaxis()->SetTitle("HT (bin)");
4841  }
4842  res_vs_ToT_bc->Draw("colz");
4843  resBC1->Draw("same");
4844 
4845  this->cd(6);
4846 
4847  TGraphErrors *resBA = GetWidth(res_vs_ToT_ba);
4848  resBA->SetLineColor(kRed);
4849  resBA->SetMarkerColor(kRed);
4850  TGraphErrors *resBC = GetWidth(res_vs_ToT_bc);
4851  resBC->SetLineColor(kBlue);
4852  resBC->SetMarkerColor(kBlue);
4853  resBA->SetTitle("Barrel Time Residual Width vs ToT");
4854  if (!isba)
4855  resBA->SetTitle("Endcap Time Residual Width vs ToT");
4856  resBA->GetXaxis()->SetTitle("ToT (bin)");
4857 
4858  if (isht)
4859  {
4860  resBA->SetTitle("Barrel Residual Width vs HT");
4861  if (!isba)
4862  resBA->SetTitle("Endcap Residual Width vs HT");
4863  resBA->GetXaxis()->SetTitle("HT");
4864  }
4865  resBA->GetXaxis()->SetRangeUser(-0.5, 23.5);
4866  resBA->GetYaxis()->SetRangeUser(0.08, 0.2);
4867  if (isht)
4868  {
4869  resBA->GetXaxis()->SetRangeUser(-0.5, 1.5);
4870  resBA->GetYaxis()->SetRangeUser(0.08, 0.2);
4871  }
4872  resBA->Draw("alp");
4873  resBC->Draw("same");
4874 }
4875 
4876 class SinDependence : public TCanvas
4877 {
4878 public:
4879  SinDependence(TFile *, bool, bool, bool);
4880 
4881 private:
4882  TDirectory *m_errors;
4883 };
4884 
4885 SinDependence::SinDependence(TFile *file, bool isba = true, bool isht = false, bool isAr = false)
4886 {
4887  m_errors = nullptr;
4888 
4889  if (!isAr)
4890  m_errors = (TDirectory *)file->FindKey("Correction")->ReadObj();
4891  else
4892  m_errors = (TDirectory *)file->FindKey("CorrectionAr")->ReadObj();
4893  if (!m_errors)
4894  throw(string("No errors folder!!!!!!!!!!!!!!!"));
4895 
4896  this->Divide(2, 3, 0.01, 0.01);
4897 
4898  // Read the histos:
4899 
4900  TH2F *tres_vs_ToT_ba = nullptr;
4901  TH2F *tres_vs_ToT_bc = nullptr;
4902  // Residual:
4903  TH2F *res_vs_ToT_ba = nullptr;
4904  TH2F *res_vs_ToT_bc = nullptr;
4905 
4906  if (!isAr)
4907  {
4908  if (!isht)
4909  {
4910  if (isba)
4911  { // sin
4912  tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tres_vs_SinOverP_bc")->ReadObj();
4913  res_vs_ToT_ba = (TH2F *)m_errors->FindKey("res_vs_SinOverP_ba")->ReadObj();
4914  tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tres_vs_SinOverP_bc")->ReadObj();
4915  res_vs_ToT_bc = (TH2F *)m_errors->FindKey("res_vs_SinOverP_bc")->ReadObj();
4916  }
4917  else
4918  {
4919  tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tres_vs_SinOverP_ea")->ReadObj();
4920  res_vs_ToT_ba = (TH2F *)m_errors->FindKey("res_vs_SinOverP_ea")->ReadObj();
4921  tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tres_vs_SinOverP_ec")->ReadObj();
4922  res_vs_ToT_bc = (TH2F *)m_errors->FindKey("res_vs_SinOverP_ec")->ReadObj();
4923  }
4924  }
4925  else
4926  {
4927  if (isba)
4928  { // cos
4929  tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tres_vs_CosOverP_bc")->ReadObj();
4930  res_vs_ToT_ba = (TH2F *)m_errors->FindKey("res_vs_CosOverP_ba")->ReadObj();
4931  tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tres_vs_CosOverP_bc")->ReadObj();
4932  res_vs_ToT_bc = (TH2F *)m_errors->FindKey("res_vs_CosOverP_bc")->ReadObj();
4933  }
4934  else
4935  {
4936  tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tres_vs_CosOverP_ea")->ReadObj();
4937  res_vs_ToT_ba = (TH2F *)m_errors->FindKey("res_vs_CosOverP_ea")->ReadObj();
4938  tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tres_vs_CosOverP_ec")->ReadObj();
4939  res_vs_ToT_bc = (TH2F *)m_errors->FindKey("res_vs_CosOverP_ec")->ReadObj();
4940  }
4941  }
4942  }
4943  else
4944  {
4945  if (!isht)
4946  {
4947  if (isba)
4948  { // sin
4949  tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tresAr_vs_SinOverP_bc")->ReadObj();
4950  res_vs_ToT_ba = (TH2F *)m_errors->FindKey("resAr_vs_SinOverP_ba")->ReadObj();
4951  tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tresAr_vs_SinOverP_bc")->ReadObj();
4952  res_vs_ToT_bc = (TH2F *)m_errors->FindKey("resAr_vs_SinOverP_bc")->ReadObj();
4953  }
4954  else
4955  {
4956  tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tresAr_vs_SinOverP_ea")->ReadObj();
4957  res_vs_ToT_ba = (TH2F *)m_errors->FindKey("resAr_vs_SinOverP_ea")->ReadObj();
4958  tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tresAr_vs_SinOverP_ec")->ReadObj();
4959  res_vs_ToT_bc = (TH2F *)m_errors->FindKey("resAr_vs_SinOverP_ec")->ReadObj();
4960  }
4961  }
4962  else
4963  {
4964  if (isba)
4965  { // cos
4966  tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tresAr_vs_CosOverP_bc")->ReadObj();
4967  res_vs_ToT_ba = (TH2F *)m_errors->FindKey("resAr_vs_CosOverP_ba")->ReadObj();
4968  tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tresAr_vs_CosOverP_bc")->ReadObj();
4969  res_vs_ToT_bc = (TH2F *)m_errors->FindKey("resAr_vs_CosOverP_bc")->ReadObj();
4970  }
4971  else
4972  {
4973  tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tresAr_vs_CosOverP_ea")->ReadObj();
4974  res_vs_ToT_ba = (TH2F *)m_errors->FindKey("resAr_vs_CosOverP_ea")->ReadObj();
4975  tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tresAr_vs_CosOverP_ec")->ReadObj();
4976  res_vs_ToT_bc = (TH2F *)m_errors->FindKey("resAr_vs_CosOverP_ec")->ReadObj();
4977  }
4978  }
4979  }
4980 
4981  this->cd(1);
4982  // Time Residual Mean Vs Pt:
4983  TGraphErrors *tresBA = GetMean(tres_vs_ToT_ba);
4984  tresBA->SetLineColor(kRed);
4985  tresBA->SetMarkerColor(kRed);
4986  if (isba)
4987  tres_vs_ToT_ba->SetTitle("Barrel A Time Residual Mean VS sin(Theta)/p");
4988  else
4989  tres_vs_ToT_ba->SetTitle("Endcap A Time Residual Mean VS sin(Theta)/p");
4990  tres_vs_ToT_ba->GetXaxis()->SetTitle("sin(Theta)/p");
4991  tres_vs_ToT_ba->GetYaxis()->SetTitle("Time Residual (ns)");
4992 
4993  if (isht)
4994  {
4995  if (isba)
4996  tres_vs_ToT_ba->SetTitle("Barrel A Time Residual Mean VS cos(Theta)/p");
4997  else
4998  tres_vs_ToT_ba->SetTitle("Endcap A Time Residual Mean VS cos(Theta)/p");
4999  tres_vs_ToT_ba->GetXaxis()->SetTitle("cos(Theta)/p");
5000  }
5001 
5002  tres_vs_ToT_ba->Draw("colz");
5003  tresBA->Draw("same");
5004 
5005  this->cd(3);
5006  TGraphErrors *tresBC = GetMean(tres_vs_ToT_bc);
5007  tresBC->SetLineColor(kBlue);
5008  tresBC->SetMarkerColor(kBlue);
5009  if (isba)
5010  tres_vs_ToT_bc->SetTitle("Barrel C Time Residual Mean VS sin(Theta)/p");
5011  else
5012  tres_vs_ToT_bc->SetTitle("Endcap C Time Residual Mean VS sin(Theta)/p");
5013  tres_vs_ToT_bc->GetXaxis()->SetTitle("sin(Theta)/p");
5014  tres_vs_ToT_bc->GetYaxis()->SetTitle("Time Residual (ns)");
5015  if (isht)
5016  {
5017  if (isba)
5018  tres_vs_ToT_bc->SetTitle("Barrel C Time Residual Mean VS cos(Theta)/p");
5019  else
5020  tres_vs_ToT_bc->SetTitle("Endcap C Time Residual Mean VS cos(Theta)/p");
5021  tres_vs_ToT_bc->GetXaxis()->SetTitle("cos(Theta)/p");
5022  }
5023  tres_vs_ToT_bc->Draw("colz");
5024  tresBC->Draw("same");
5025 
5026  this->cd(5);
5027  tresBA->SetTitle("Barrel Time Residual Mean vs Sin(theta) / p");
5028  if (!isba)
5029  tresBA->SetTitle("Endcap Time Residual Mean vs Sin(theta) / p");
5030 
5031  if (isht)
5032  {
5033  tresBA->SetTitle("Barrel Time Residual Mean vs Cos(theta) / p");
5034  if (!isba)
5035  tresBA->SetTitle("Endcap Time Residual Mean vs Cos(theta) / p");
5036  }
5037 
5038  tresBA->GetXaxis()->SetRangeUser(0, 1);
5039  tresBA->GetYaxis()->SetRangeUser(-1, 1.5);
5040  tresBA->Draw("alp");
5041  tresBC->Draw("same");
5042 
5043  this->cd(2);
5044  TGraphErrors *resBA1 = GetMean(res_vs_ToT_ba);
5045  resBA1->SetLineColor(kRed);
5046  resBA1->SetMarkerColor(kRed);
5047  if (isba)
5048  res_vs_ToT_ba->SetTitle("Barrel A Residual Mean VS sin(Theta)/p");
5049  else
5050  res_vs_ToT_ba->SetTitle("Endcap A Residual Mean VS sin(Theta)/p");
5051  res_vs_ToT_ba->GetXaxis()->SetTitle("sin(Theta)/p");
5052  res_vs_ToT_ba->GetYaxis()->SetTitle("Residual (mm)");
5053  if (isht)
5054  {
5055  if (isba)
5056  res_vs_ToT_ba->SetTitle("Barrel A Residual Mean VS cos(Theta)/p");
5057  else
5058  res_vs_ToT_ba->SetTitle("Endcap A Residual Mean VS cos(Theta)/p");
5059  res_vs_ToT_ba->GetXaxis()->SetTitle("cos(Theta)/p");
5060  }
5061  res_vs_ToT_ba->Draw("colz");
5062  resBA1->Draw("same");
5063 
5064  this->cd(4);
5065  TGraphErrors *resBC1 = GetMean(res_vs_ToT_bc);
5066  resBC1->SetLineColor(kBlue);
5067  resBC1->SetMarkerColor(kBlue);
5068  if (isba)
5069  res_vs_ToT_bc->SetTitle("Barrel C Residual Mean VS sin(Theta)/p");
5070  else
5071  res_vs_ToT_bc->SetTitle("Endcap C Residual Mean VS sin(Theta)/p");
5072  res_vs_ToT_bc->GetXaxis()->SetTitle("sin(Theta)/p");
5073  res_vs_ToT_bc->GetYaxis()->SetTitle("Residual (mm)");
5074  if (isht)
5075  {
5076  if (isba)
5077  res_vs_ToT_bc->SetTitle("Barrel C Residual Mean VS cos(Theta)/p");
5078  else
5079  res_vs_ToT_bc->SetTitle("Endcap C Residual Mean VS cos(Theta)/p");
5080  res_vs_ToT_bc->GetXaxis()->SetTitle("cos(Theta)/p");
5081  }
5082  res_vs_ToT_bc->Draw("colz");
5083  resBC1->Draw("same");
5084 
5085  this->cd(6);
5086 
5087  TGraphErrors *resBA = GetWidth(res_vs_ToT_ba);
5088  resBA->SetLineColor(kRed);
5089  resBA->SetMarkerColor(kRed);
5090  TGraphErrors *resBC = GetWidth(res_vs_ToT_bc);
5091  resBC->SetLineColor(kBlue);
5092  resBC->SetMarkerColor(kBlue);
5093  resBA->SetTitle("Barrel Residual Width vs Sin(theta) / p");
5094  if (!isba)
5095  resBA->SetTitle("Endcap Residual Widht vs Sin(theta) / p");
5096 
5097  if (isht)
5098  {
5099  resBA->SetTitle("Barrel Residual Width vs Cos(theta) / p");
5100  if (!isba)
5101  resBA->SetTitle("Endcap Residual Widht vs Cos(theta) / p");
5102  }
5103 
5104  resBA->GetXaxis()->SetRangeUser(0, 1);
5105  resBA->GetYaxis()->SetRangeUser(0.08, 0.20);
5106  resBA->Draw("alp");
5107  resBC->Draw("same");
5108 }
5109 
5110 //================================================================
5111 //================================================================
5112 
5113 int itersum (int argc, char *argv[])
5114 {
5115 
5116  string inputfile = string(argv[2]);
5117  TFile *datafile = new TFile(argv[2]);
5118  if (datafile->IsZombie())
5119  {
5120  cout << "ERROR! INPUT FILE DOES NOT EXIST!" << endl;
5121  exit(-1);
5122  }
5123 
5124  bool isAr = false;
5125  if (datafile->FindKey("TRT_Ar_all"))
5126  {
5127  isAr = true;
5128  cout << " This run contains straws with Argon" << endl;
5129  }
5130  if (!datafile->FindKey("Chip_Artuple"))
5131  {
5132  isAr = false;
5133  cout << " This run contains does not have Argon ntuples" << endl;
5134  }
5135 
5136  // Here we have to do the fix, because the trees are duplicated
5137 
5138  TFile *refdatafile;
5139  bool useref = false;
5140  if (argc > 4)
5141  {
5142  useref = true;
5143  refdatafile = new TFile(argv[4]);
5144  if (refdatafile->IsZombie())
5145  {
5146  cout << "INPUT REFERENCE FILE DOES NOT EXIST! RUNNING WITHOUT IT!" << endl;
5147  useref = false;
5148  }
5149  else
5150  cout << "INPUT REFERENCE FILE OK!" << endl;
5151  }
5152 
5153  // First page on Shifter report, general information
5154  cout << "MAKING FirstPage" << endl;
5155  FirstPage *firstpage = nullptr;
5156  try
5157  {
5158  firstpage = new FirstPage(argv[2], datafile);
5159  }
5160  catch (string e)
5161  {
5162  cout << e << endl;
5163  }
5164 
5165  // Add a page with the settings:
5166  cout << "MAKING Settings" << endl;
5167  SettingsInfo *settings = nullptr;
5168  // if (argv[3]) try { settings = new SettingsInfo(argv[3]); } catch (string e) { cout << e << endl; }
5169 
5170  // Tracktuple info
5171  cout << "MAKING TracktupleInfo" << endl;
5172  TrackTupleInfo *tracktupleinfo = nullptr;
5173  try
5174  {
5175  tracktupleinfo = new TrackTupleInfo(datafile);
5176  }
5177  catch (string e)
5178  {
5179  cout << e << endl;
5180  }
5181 
5182  // Hit statistics
5183  HitStatistics *hitstat = nullptr;
5184  cout << "MAKING HitStatistics" << endl;
5185  hitstat = new HitStatistics(argv[2]);
5186 
5187  HitStatistics *hitstatAr = nullptr;
5188  if (isAr)
5189  {
5190  cout << "MAKING Ar HitStatistics" << endl;
5191  hitstatAr = new HitStatistics(argv[2], true);
5192  }
5193 
5194  // TRT Global Results:
5195  cout << "MAKING TRTPlots" << endl;
5196  // SERGI - What is the purpose of the lines commented below? (TRTPlots *TRTresplots and *TRTresplotsAr are not used at anywhere)
5197  // TRTPlots *TRTresplots = nullptr;
5198  // try
5199  // {
5200  // TRTresplots = new TRTPlots(datafile);
5201  // }
5202  // catch (string e)
5203  // {
5204  // cout << e << endl;
5205  // }
5206  // TRTPlots *TRTresplotsAr = nullptr;
5207  if (isAr)
5208  // try
5209  // {
5210  // TRTresplotsAr = new TRTPlots(datafile, true);
5211  // }
5212  // catch (string e)
5213  // {
5214  // cout << e << endl;
5215  // }
5216 
5217  // Residual and time residual (TRT and both barrels)
5218  cout << "MAKING ResidualPlots" << endl;
5219  ResidualPlots *resplots = nullptr;
5220  try
5221  {
5222  resplots = new ResidualPlots(datafile);
5223  }
5224  catch (string e)
5225  {
5226  cout << e << endl;
5227  }
5228  ResidualPlots *resplotsAr = nullptr;
5229  if (isAr)
5230  try
5231  {
5232  resplotsAr = new ResidualPlots(datafile, true);
5233  }
5234  catch (string e)
5235  {
5236  cout << e << endl;
5237  }
5238 
5239  // Do t0 calibration type:
5240  cout << "MAKING T0CalibTypeXY" << endl;
5241  T0CalibTypeXY *hitstatxy = new T0CalibTypeXY(argv[2]);
5242  T0CalibTypeXY *hitstatxyAr = nullptr;
5243  if (isAr)
5244  hitstatxyAr = new T0CalibTypeXY(argv[2], true);
5245 
5246  // Do hits plots:
5247  cout << "MAKING XYMaps(nt0)" << endl;
5248  XYMaps *nhits = new XYMaps(argv[2], "nt0");
5249  XYMaps *nhitsAr = nullptr;
5250  if (isAr)
5251  nhitsAr = new XYMaps(argv[2], "nt0", true);
5252  // Do res plot:
5253  cout << "MAKING XYMaps(res)" << endl;
5254  XYMaps *resxy0 = new XYMaps(argv[2], "res");
5255  XYMaps *resxy0Ar = nullptr;
5256  if (isAr)
5257  resxy0Ar = new XYMaps(argv[2], "res", true);
5258  // Do residual center plot:
5259  cout << "MAKING XYMaps(resmean)" << endl;
5260  XYMaps *resxy = new XYMaps(argv[2], "abs(resMean)");
5261  XYMaps *resxyAr = nullptr;
5262  if (isAr)
5263  resxyAr = new XYMaps(argv[2], "abs(resMean)", true);
5264  // Do t0s plots:
5265  cout << "MAKING XYMaps(t0)" << endl;
5266  XYMaps *xymap = new XYMaps(argv[2], "t0");
5267  XYMaps *xymapAr = nullptr;
5268  if (isAr)
5269  xymapAr = new XYMaps(argv[2], "t0", true);
5270  // Do Oldt0plots:
5271  cout << "MAKING XYMaps(oldt0)" << endl;
5272  XYMaps *oldt0 = new XYMaps(argv[2], "oldt0");
5273  XYMaps *oldt0Ar = nullptr;
5274  if (isAr)
5275  oldt0Ar = new XYMaps(argv[2], "oldt0", true);
5276  // Do t0 diff:
5277  cout << "MAKING XYMaps(t0-oldt0)" << endl;
5278  XYMaps *oldt01 = new XYMaps(argv[2], "abs(t0-oldt0)");
5279  XYMaps *oldt01Ar = nullptr;
5280  if (isAr)
5281  oldt01Ar = new XYMaps(argv[2], "abs(t0-oldt0)", true); // changed from t0-old-t0
5282  // Do t0 diff mean:
5283  cout << "MAKING XYMaps(tresMean)" << endl;
5284  XYMaps *oldt0111 = new XYMaps(argv[2], "abs(tresMean)");
5285  XYMaps *oldt0111Ar = nullptr;
5286  if (isAr)
5287  oldt0111Ar = new XYMaps(argv[2], "abs(tresMean)", true);
5288  // Do t0 width:
5289  cout << "MAKING XYMaps(tres)" << endl;
5290  XYMaps *oldt011 = new XYMaps(argv[2], "(tres)");
5291  XYMaps *oldt011Ar = nullptr;
5292  if (isAr)
5293  oldt011Ar = new XYMaps(argv[2], "(tres)", true);
5294 
5295  // Add the plot for Chip T0 (board offset) variations
5296  ChipVariations *chipgraphA = nullptr;
5297  ChipVariations *chipgraphC = nullptr;
5298  if (datafile->FindKey("TRT_all"))
5299  {
5300  cout << "MAKING ChipVariations" << endl;
5301  chipgraphA = new ChipVariations(argv[2], 1);
5302  chipgraphC = new ChipVariations(argv[2], -1);
5303  }
5304 
5305  // Add the plot for Board T0 variations
5306  BoardVariationsOldT0 *refboardgraphA = nullptr;
5307  BoardVariationsOldT0 *refboardgraphC = nullptr;
5308  BoardVariationsDiff *boarddiffgraphA = nullptr;
5309  BoardVariationsDiff *boarddiffgraphC = nullptr;
5310  if (useref)
5311  {
5312  cout << "MAKING BoardVariationsOldT0" << endl;
5313  refboardgraphA = new BoardVariationsOldT0(argv[4], 1);
5314  refboardgraphC = new BoardVariationsOldT0(argv[4], -1);
5315  refboardgraphA->SetLineColor(2);
5316  refboardgraphC->SetLineColor(2);
5317  cout << "MAKING BoardVariationsDiff" << endl;
5318  boarddiffgraphA = new BoardVariationsDiff(argv[2], argv[4], 1);
5319  boarddiffgraphC = new BoardVariationsDiff(argv[2], argv[4], -1);
5320  }
5321  // Add the plot for Board T0 variations
5322  cout << "MAKING BoardVariations" << endl;
5323  BoardVariations *boardgraphA = new BoardVariations(argv[2], 1);
5324  BoardVariations *boardgraphC = new BoardVariations(argv[2], -1);
5325  // Add the plot for the residual
5326  cout << "MAKING BoardVariationsRes" << endl;
5327  BoardVariationsRes *boardgraphA1 = new BoardVariationsRes(argv[2], 1);
5328  BoardVariationsRes *boardgraphC1 = new BoardVariationsRes(argv[2], -1);
5329  // Add the plot for the Time residual
5330  cout << "MAKING BoardVariationsTRes" << endl;
5331  BoardVariationsTRes *boardgraphA2 = new BoardVariationsTRes(argv[2], 1);
5332  BoardVariationsTRes *boardgraphC2 = new BoardVariationsTRes(argv[2], -1);
5333  // Add the plot for the sigma Time residual
5334  cout << "MAKING BoardVariationsTRes1" << endl;
5335  BoardVariationsTRes1 *boardgraphA3 = new BoardVariationsTRes1(argv[2], 1);
5336  BoardVariationsTRes1 *boardgraphC3 = new BoardVariationsTRes1(argv[2], -1);
5337 
5338  // RtGraphs* rtrelation11=nullptr;
5339  RtGraphs *rtrelation_bar = nullptr;
5340  RtGraphs *rtrelation21 = nullptr;
5341  RtGraphs *rtrelation31 = nullptr;
5342  RtGraphs *rtrelation41 = nullptr;
5343  RtGraphs *rtrelation51 = nullptr;
5344  RtBinning *rtbinning_bar = nullptr;
5345  RtBinning *rtbinning1 = nullptr;
5346  RtBinning *rtbinning2 = nullptr;
5347  RtBinning *rtbinning3 = nullptr;
5348  RtBinning *rtbinning4 = nullptr;
5349  if (datafile->FindKey("TRT_all"))
5350  {
5351  cout << "MAKING RtGraphs" << endl;
5352  TDirectory *trt = (TDirectory *)datafile->FindKey("TRT_all")->ReadObj();
5353 
5354  if (trt->FindKey("WholeBarrel_1"))
5355  {
5356  try
5357  {
5358  rtrelation_bar = new RtGraphs(argv[2], "WholeBarrel_1");
5359  }
5360  catch (string e)
5361  {
5362  cout << e << endl;
5363  }
5364  }
5365  if (trt->FindKey("Detector_-1"))
5366  {
5367  try
5368  {
5369  rtrelation21 = new RtGraphs(argv[2], "Detector_-1");
5370  }
5371  catch (string e)
5372  {
5373  cout << e << endl;
5374  }
5375  }
5376  if (trt->FindKey("Detector_1"))
5377  {
5378  try
5379  {
5380  rtrelation31 = new RtGraphs(argv[2], "Detector_1");
5381  }
5382  catch (string e)
5383  {
5384  cout << e << endl;
5385  }
5386  }
5387  if (trt->FindKey("Detector_-2"))
5388  {
5389  try
5390  {
5391  rtrelation41 = new RtGraphs(argv[2], "Detector_-2");
5392  }
5393  catch (string e)
5394  {
5395  cout << e << endl;
5396  }
5397  }
5398  if (trt->FindKey("Detector_2"))
5399  {
5400  try
5401  {
5402  rtrelation51 = new RtGraphs(argv[2], "Detector_2");
5403  }
5404  catch (string e)
5405  {
5406  cout << e << endl;
5407  }
5408  }
5409  // r plots for each t-bin
5410  cout << "MAKING Rt binning" << endl;
5411 
5412  // No Xenon for Barrel in Run3
5413  // rtbinning_bar=new RtBinning(trt,"WholeBarrel_1");
5414  // cout << "MAKING Rt binning for Detector_-1" << endl;
5415  // rtbinning1=new RtBinning(trt,"Detector_-1");
5416  // cout << "MAKING Rt binning for Detector_1" << endl;
5417  // rtbinning2=new RtBinning(trt,"Detector_1");
5418  cout << "MAKING Rt binning for Detector_-2" << endl;
5419  rtbinning3 = new RtBinning(trt, "Detector_-2");
5420  cout << "MAKING Rt binning for Detector_2" << endl;
5421  rtbinning4 = new RtBinning(trt, "Detector_2");
5422  }
5423 
5424  // Binned residual plots
5425  RresTbin *binres_bar = nullptr;
5426  RresTbin *binres1 = nullptr;
5427  RresTbin *binres2 = nullptr;
5428  RresTbin *binres3 = nullptr;
5429  RresTbin *binres4 = nullptr;
5430  TBinnedRes *tbinnedres_bar = nullptr;
5431  TBinnedRes *tbinnedres1 = nullptr;
5432  TBinnedRes *tbinnedres2 = nullptr;
5433  TBinnedRes *tbinnedres3 = nullptr;
5434  TBinnedRes *tbinnedres4 = nullptr;
5435 
5436  cout << "MAKING Binned Residual" << endl;
5437  // No Xenon hists for Barrel in Run3
5438  // binres_bar=new RresTbin(datafile,"WholeBarrel_1",4);
5439  // tbinnedres_bar=new TBinnedRes(datafile,binres_bar->reshists);
5440  // cout << "MAKING Binned Residual for Detector_-1" << endl;
5441  // binres1=new RresTbin(datafile,"Detector_-1",-1);
5442  // tbinnedres1=new TBinnedRes(datafile,binres1->reshists);
5443  // cout << "MAKING Binned Residual for Detector_1" << endl;
5444  // binres2=new RresTbin(datafile,"Detector_1",1);
5445  // tbinnedres2=new TBinnedRes(datafile,binres2->reshists);
5446  cout << "MAKING Binned Residual for Detector_-2" << endl;
5447  binres3 = new RresTbin(datafile, "Detector_-2", -2);
5448  tbinnedres3 = new TBinnedRes(datafile, binres3->reshists);
5449  cout << "MAKING Binned Residual for Detector_2" << endl;
5450  binres4 = new RresTbin(datafile, "Detector_2", 2);
5451  tbinnedres4 = new TBinnedRes(datafile, binres4->reshists);
5452 
5453  RtColor *rtcol = nullptr;
5454  RtColor *rtcol1 = nullptr;
5455  RtColor *rtcol2 = nullptr;
5456  RtColor *rtcol3 = nullptr;
5457  RtColor *rtcol4 = nullptr;
5458  RtColor *rtcol5 = nullptr;
5459  // Rt relation, default plot
5460  cout << "MAKING RtColor" << endl;
5461 
5462  if (datafile->FindKey("TRT_all"))
5463  {
5464  cout << " found TRT_all " << endl;
5465 
5466  // no Xenon RtColor plot for entire TRT
5467  // rtcol= new RtColor(argv[2],"");
5468 
5469  TDirectory *trt = (TDirectory *)datafile->FindKey("TRT_all")->ReadObj();
5470 
5471  // No Xenon Rt plots for barrel in Run3
5472  /*
5473  if (trt->FindKey("WholeBarrel_1")){
5474  cout << " MAKING RtColor WholeBarrel" << endl;
5475  try {rtcol1= new RtColor(argv[2],"WholeBarrel_1");}
5476  catch (string e){cout << e << endl;}
5477  }
5478 
5479 
5480  if (trt->FindKey("Detector_-1")){
5481  cout << " MAKING RtColor Detector_-1" << endl;
5482  try {rtcol2= new RtColor(argv[2],"Detector_-1");}
5483  catch (string e){cout << e << endl;}
5484  }
5485 
5486  if (trt->FindKey("Detector_1")){
5487  cout << " MAKING RtColor Detector_1" << endl;
5488  try {rtcol3= new RtColor(argv[2],"Detector_1");}
5489  catch (string e){cout << e << endl;}
5490  }
5491  */
5492 
5493  if (trt->FindKey("Detector_-2"))
5494  {
5495  cout << " MAKING RtColor Detector_-2" << endl;
5496  try
5497  {
5498  rtcol4 = new RtColor(argv[2], "Detector_-2");
5499  }
5500  catch (string e)
5501  {
5502  cout << e << endl;
5503  }
5504  }
5505 
5506  if (trt->FindKey("Detector_2"))
5507  {
5508  cout << " MAKING RtColor Detector_2" << endl;
5509  try
5510  {
5511  rtcol5 = new RtColor(argv[2], "Detector_2");
5512  }
5513  catch (string e)
5514  {
5515  cout << e << endl;
5516  }
5517  }
5518  }
5519  // ARGON!!
5520  // SERGI - Is this actually used for something????
5521  // RtGraphs *rtArrelation_bar = nullptr;
5522  // RtGraphs *rtArrelation21 = nullptr;
5523  // RtGraphs *rtArrelation31 = nullptr;
5524  // RtGraphs *rtArrelation41 = nullptr;
5525  // RtGraphs *rtArrelation51 = nullptr;
5526  // RtBinning *rtArbinning_bar = nullptr;
5527  // RtBinning *rtArbinning1 = nullptr;
5528  // RtBinning *rtArbinning2 = nullptr;
5529  // RtBinning *rtArbinning3 = nullptr;
5530  // RtBinning *rtArbinning4 = nullptr;
5531  // if (datafile->FindKey("TRT_Ar_all"))
5532  // {
5533  // cout << "MAKING AR RtGraphs" << endl;
5534  // TDirectory *trtAr = (TDirectory *)datafile->FindKey("TRT_Ar_all")->ReadObj();
5535 
5536  // if (trtAr->FindKey("Detector_Ar_-1/binhist"))
5537  // {
5538  // cout << " Found Detector_Ar_-1/binhist" << endl;
5539  // rtArbinning1 = new RtBinning(trtAr, "Detector_Ar_-1");
5540  // try
5541  // {
5542  // rtArrelation21 = new RtGraphs(argv[2], "Detector_Ar_-1", true);
5543  // }
5544  // catch (string e)
5545  // {
5546  // cout << e << endl;
5547  // }
5548  // }
5549 
5550  // if (trtAr->FindKey("Detector_Ar_1/binhist"))
5551  // {
5552  // cout << " Found Detector_Ar_1/binhist" << endl;
5553  // rtArbinning2 = new RtBinning(trtAr, "Detector_Ar_1");
5554  // try
5555  // {
5556  // rtArrelation31 = new RtGraphs(argv[2], "Detector_Ar_1", true);
5557  // }
5558  // catch (string e)
5559  // {
5560  // cout << e << endl;
5561  // }
5562  // }
5563 
5564  // if (trtAr->FindKey("Detector_Ar_-2/binhist"))
5565  // {
5566  // cout << " Found Detector_Ar_-2/binhist" << endl;
5567  // rtArbinning3 = new RtBinning(trtAr, "Detector_Ar_-2");
5568  // try
5569  // {
5570  // rtArrelation41 = new RtGraphs(argv[2], "Detector_Ar_-2", true);
5571  // }
5572  // catch (string e)
5573  // {
5574  // cout << e << endl;
5575  // }
5576  // }
5577  // if (trtAr->FindKey("Detector_Ar_2/binhist"))
5578  // {
5579 
5580  // TDirectory *test = (TDirectory *)(((TDirectory *)trtAr->Get("Detector_Ar_2")));
5581  // if (test->FindKey("binhist"))
5582  // {
5583  // cout << " Found Detector_Ar_2/binhist" << endl;
5584  // rtArbinning4 = new RtBinning(trtAr, "Detector_Ar_2");
5585  // try
5586  // {
5587  // rtArrelation51 = new RtGraphs(argv[2], "Detector_Ar_2", true);
5588  // }
5589  // catch (string e)
5590  // {
5591  // cout << e << endl;
5592  // }
5593  // }
5594  // }
5595  // // r plots for each t-bin
5596  // cout << " MAKING AR Rt binning" << endl;
5597  // }
5598 
5599  // Binned residual plots
5600  // RresTbin *binresAr_bar_bar = nullptr;
5601  // RresTbin *binresAr_bar1 = nullptr;
5602  // RresTbin *binresAr_bar2 = nullptr;
5603  // RresTbin *binresAr_bar3 = nullptr;
5604  // RresTbin *binresAr_bar4 = nullptr;
5605  // TBinnedRes *tbinnedArres_bar = nullptr;
5606  // TBinnedRes *tbinnedArres1 = nullptr;
5607  // TBinnedRes *tbinnedArres2 = nullptr;
5608  // TBinnedRes *tbinnedArres3 = nullptr;
5609  // TBinnedRes *tbinnedArres4 = nullptr;
5610 
5611  cout << "MAKING RT Binned Residual for Ar" << endl;
5612 
5613  TDirectory *trtAr = (TDirectory *)datafile->FindKey("TRT_Ar_all")->ReadObj();
5614  // if (trtAr->FindKey("WholeBarrel_Ar_1")) binresAr_bar_bar = new RresTbin(datafile,"WholeBarrel_Ar_1",4);
5615  // if (trtAr->FindKey("Detector_Ar_-1"))
5616  // binresAr_bar1 = new RresTbin(datafile, "Detector_Ar_-1", -1);
5617  // if (trtAr->FindKey("Detector_Ar_1"))
5618  // binresAr_bar2 = new RresTbin(datafile, "Detector_Ar_1", 1);
5619  // if (trtAr->FindKey("Detector_Ar_-2"))
5620  // binresAr_bar3 = new RresTbin(datafile, "Detector_Ar_-2", -2);
5621  // if (trtAr->FindKey("Detector_Ar_2"))
5622  // binresAr_bar4 = new RresTbin(datafile, "Detector_Ar_2", 2);
5623 
5624  cout << "MAKING RT Binned Abs Residual for Ar" << endl;
5625 
5626  // tbinnedArres_bar = new TBinnedRes(datafile,binresAr_bar_bar->reshists);
5627  // tbinnedArres1 = new TBinnedRes(datafile, binresAr_bar1->reshists);
5628  // tbinnedArres2 = new TBinnedRes(datafile, binresAr_bar2->reshists);
5629  // tbinnedArres3 = new TBinnedRes(datafile, binresAr_bar3->reshists);
5630  // tbinnedArres4 = new TBinnedRes(datafile, binresAr_bar4->reshists);
5631 
5632  // RtColor *rtArcol = nullptr;
5633  // RtColor *rtArcol1 = nullptr;
5634  RtColor *rtArcol2 = nullptr;
5635  RtColor *rtArcol3 = nullptr;
5636  RtColor *rtArcol4 = nullptr;
5637  RtColor *rtArcol5 = nullptr;
5638  // Rt relation, default plot
5639  // if (datafile->FindKey("TRT_Ar_all/rt-relation"))
5640  // {
5641  // cout << "MAKING AR RtColor all TRT" << endl;
5642  // try
5643  // {
5644  // rtArcol = new RtColor(argv[2], "", true);
5645  // }
5646  // catch (string e)
5647  // {
5648  // cout << e << endl;
5649  // }
5650  // }
5651 
5652  if (trtAr->FindKey("Detector_Ar_-1"))
5653  {
5654  cout << " MAKING AR RtColor det -1" << endl;
5655  try
5656  {
5657  rtArcol2 = new RtColor(argv[2], "Detector_Ar_-1", true);
5658  }
5659  catch (string e)
5660  {
5661  cout << e << endl;
5662  }
5663  }
5664  if (trtAr->FindKey("Detector_Ar_1"))
5665  {
5666  cout << " MAKING AR RtColor det 1" << endl;
5667  try
5668  {
5669  rtArcol3 = new RtColor(argv[2], "Detector_Ar_1", true);
5670  }
5671  catch (string e)
5672  {
5673  cout << e << endl;
5674  }
5675  }
5676  if (trtAr->FindKey("Detector_Ar_-2"))
5677  {
5678  cout << " MAKING AR RtColor det -2" << endl;
5679  try
5680  {
5681  rtArcol4 = new RtColor(argv[2], "Detector_Ar_-2", true);
5682  }
5683  catch (string e)
5684  {
5685  cout << e << endl;
5686  }
5687  }
5688  if (trtAr->FindKey("Detector_Ar_2"))
5689  {
5690  cout << " MAKING AR RtColor det 2" << endl;
5691  try
5692  {
5693  rtArcol5 = new RtColor(argv[2], "Detector_Ar_2", true);
5694  }
5695  catch (string e)
5696  {
5697  cout << e << endl;
5698  }
5699  }
5700  // Add the plot for Board T0 variations
5701  BoardVariationsOldT0 *refboardECgraphA = nullptr;
5702  BoardVariationsOldT0 *refboardECgraphC = nullptr;
5703  BoardVariationsDiff *boarddiffECgraphA = nullptr;
5704  BoardVariationsDiff *boarddiffECgraphC = nullptr;
5705  if (useref)
5706  {
5707  cout << "MAKING BoardVariationsOldT0 for Ar" << endl;
5708  refboardECgraphA = new BoardVariationsOldT0(argv[4], 2);
5709  refboardECgraphC = new BoardVariationsOldT0(argv[4], -2);
5710  cout << "MAKING BoardVariationsDiff Ar" << endl;
5711  boarddiffECgraphA = new BoardVariationsDiff(argv[2], argv[4], 2);
5712  boarddiffECgraphC = new BoardVariationsDiff(argv[2], argv[4], -2);
5713  boarddiffECgraphA->SetLineColor(2);
5714  boarddiffECgraphC->SetLineColor(2);
5715  }
5716  // Add the plot for Board T0 variations
5717  cout << "MAKING BoardVariations Ar" << endl;
5718  BoardVariations *boardECgraphA = new BoardVariations(argv[2], 2);
5719  BoardVariations *boardECgraphC = new BoardVariations(argv[2], -2);
5720  // Add the plot for the residual
5721  cout << "MAKING BoardVariationsRes Ar" << endl;
5722  BoardVariationsRes *boardECgraphA1 = new BoardVariationsRes(argv[2], 2);
5723  BoardVariationsRes *boardECgraphC1 = new BoardVariationsRes(argv[2], -2);
5724  // Add the plot for the Time residual
5725  cout << "MAKING BoardVariationsTRes Ar" << endl;
5726  BoardVariationsTRes *boardECgraphA2 = new BoardVariationsTRes(argv[2], 2);
5727  BoardVariationsTRes *boardECgraphC2 = new BoardVariationsTRes(argv[2], -2);
5728  // Add the plot for the sigma Time residual
5729  cout << "MAKING BoardVariationsTRes1" << endl;
5730  BoardVariationsTRes1 *boardECgraphA3 = new BoardVariationsTRes1(argv[2], 2);
5731  BoardVariationsTRes1 *boardECgraphC3 = new BoardVariationsTRes1(argv[2], -2);
5732 
5733  cout << " Start printing itersum.ps" << endl;
5734 
5735  TCanvas *textpage;
5736 
5737  TCanvas *c1 = new TCanvas();
5738  c1->Print("itersum.ps[");
5739  c1->cd();
5740 
5741  if (firstpage)
5742  firstpage->Print("itersum.ps");
5743  c1->Clear();
5744  if (settings)
5745  settings->Print("itersum.ps");
5746  c1->Clear();
5747  if (tracktupleinfo)
5748  tracktupleinfo->Print("itersum.ps");
5749  c1->Clear();
5750  if (hitstat)
5751  hitstat->Print("itersum.ps");
5752  c1->Clear();
5753  if (hitstatAr)
5754  hitstatAr->Print("itersum.ps");
5755  c1->Clear();
5756 
5757  gStyle->SetOptStat(0);
5758  if (resplots)
5759  resplots->Print("itersum.ps");
5760  c1->Clear();
5761  if (resplotsAr)
5762  resplotsAr->Print("itersum.ps");
5763  c1->Clear();
5764 
5765  textpage = new TextPage(" BARREL PLOTS ");
5766  textpage->Print("itersum.ps");
5767  c1->Clear();
5768 
5769  hitstatxy->Print("itersum.ps");
5770  c1->Clear();
5771  if (isAr)
5772  hitstatxyAr->Print("itersum.ps");
5773  c1->Clear();
5774  nhits->Print("itersum.ps");
5775  c1->Clear();
5776  if (isAr)
5777  nhitsAr->Print("itersum.ps");
5778  c1->Clear();
5779  resxy0->Print("itersum.ps");
5780  c1->Clear();
5781  if (isAr)
5782  resxy0Ar->Print("itersum.ps");
5783  c1->Clear();
5784  resxy->Print("itersum.ps");
5785  c1->Clear();
5786  if (isAr)
5787  resxyAr->Print("itersum.ps");
5788  c1->Clear();
5789  xymap->Print("itersum.ps");
5790  c1->Clear();
5791  if (isAr)
5792  xymapAr->Print("itersum.ps");
5793  c1->Clear();
5794  if (do_expert)
5795  {
5796  oldt0->Print("itersum.ps");
5797  c1->Clear();
5798  if (isAr)
5799  oldt0Ar->Print("itersum.ps");
5800  c1->Clear();
5801  }
5802  oldt01->Print("itersum.ps");
5803  c1->Clear();
5804  if (isAr)
5805  oldt01Ar->Print("itersum.ps");
5806  c1->Clear();
5807  if (do_expert)
5808  {
5809  oldt0111->Print("itersum.ps");
5810  c1->Clear();
5811  if (isAr)
5812  oldt0111Ar->Print("itersum.ps");
5813  c1->Clear();
5814  }
5815  oldt011->Print("itersum.ps");
5816  c1->Clear();
5817  if (isAr)
5818  oldt011Ar->Print("itersum.ps");
5819  c1->Clear();
5820 
5821  // textpage = new TextPage(" T0 PLOTS "); textpage->Print("itersum.ps"); c1->Clear();
5822 
5823  double lowe = -3.5, upe = 3.5;
5824  if (do_expert)
5825  if (chipgraphA && chipgraphC)
5826  {
5827  chipgraphA->GetYaxis()->SetRangeUser(lowe, upe);
5828  chipgraphC->GetYaxis()->SetRangeUser(lowe, upe);
5829  c1->cd();
5830  c1->Divide(1, 2, 0.01, 0.01);
5831  c1->cd(1);
5832  chipgraphA->Draw();
5833  chipgraphA->DrawLines(lowe, upe);
5834  c1->cd(2);
5835  chipgraphC->Draw();
5836  chipgraphC->DrawLines(lowe, upe);
5837  c1->Print("itersum.ps");
5838  c1->Clear();
5839  }
5840 
5841  c1->cd();
5842  c1->Divide(1, 2, 0.01, 0.01);
5843  c1->cd(1);
5844  boardgraphA->Draw("apl");
5845  boardgraphA->DrawLines();
5846  if (refboardgraphA)
5847  refboardgraphA->Draw("pl");
5848  TLegend *leg = new TLegend(0.8, 0.8, 0.98, 0.95);
5849  leg->AddEntry(boardgraphA, "data", "l");
5850  if (refboardgraphA)
5851  leg->AddEntry(refboardgraphA, "ref (input to 1st it)", "l");
5852  leg->SetTextSize(0.03);
5853  leg->Draw();
5854  c1->cd(2);
5855  boardgraphC->Draw("apl");
5856  boardgraphC->DrawLines();
5857  if (refboardgraphC)
5858  refboardgraphC->Draw("pl");
5859  c1->Print("itersum.ps");
5860  c1->Clear();
5861 
5862  // Add the plot for Board T0 variations differenses
5863  if (useref)
5864  {
5865  c1->cd();
5866  c1->Divide(1, 2, 0.01, 0.01);
5867  c1->cd(1);
5868  boarddiffgraphA->Draw("ap");
5869  boarddiffgraphA->DrawLines();
5870 
5871  c1->cd(2);
5872  boarddiffgraphC->Draw("ap");
5873  boarddiffgraphC->DrawLines();
5874  if (do_expert)
5875  c1->Print("itersum.ps");
5876  c1->Clear();
5877  }
5878 
5879  c1->cd();
5880  c1->Divide(1, 2, 0.01, 0.01);
5881  c1->cd(1);
5882  boardgraphA1->Draw("apl");
5883  boardgraphA1->DrawLines();
5884  c1->cd(2);
5885  boardgraphC1->Draw("apl");
5886  boardgraphC1->DrawLines();
5887  c1->Print("itersum.ps");
5888  c1->Clear();
5889 
5890  c1->cd();
5891  c1->Divide(1, 2, 0.01, 0.01);
5892  c1->cd(1);
5893  boardgraphA2->Draw("apl");
5894  boardgraphA2->DrawLines();
5895  c1->cd(2);
5896  boardgraphC2->Draw("apl");
5897  boardgraphC2->DrawLines();
5898  c1->Print("itersum.ps");
5899  c1->Clear();
5900 
5901  c1->cd();
5902  c1->Divide(1, 2, 0.01, 0.01);
5903  c1->cd(1);
5904  boardgraphA3->Draw("apl");
5905  boardgraphA3->DrawLines();
5906  c1->cd(2);
5907  boardgraphC3->Draw("apl");
5908  boardgraphC3->DrawLines();
5909  c1->Print("itersum.ps");
5910  c1->Clear();
5911 
5912  // ################################################################ ADD PLOTS FOR ENDCAPS:
5913 
5914  c1->Clear();
5915  textpage = new TextPage("ENDCAP PLOTS");
5916  textpage->Print("itersum.ps");
5917  c1->Clear();
5918 
5919  cout << "MAKING PLOTS FOR ENDCAPS" << endl;
5920 
5921  // Do hits fit type:
5922  XYMapsEC *ntypeEC = new XYMapsEC(argv[2], "ftype");
5923  ntypeEC->Print("itersum.ps");
5924  XYMapsEC *ntypeECAr = nullptr;
5925  if (isAr)
5926  {
5927  ntypeECAr = new XYMapsEC(argv[2], "ftype", true);
5928  ntypeECAr->Print("itersum.ps");
5929  }
5930 
5931  // Do hits plots:
5932  XYMapsEC *nhitsEC = new XYMapsEC(argv[2], "nt0");
5933  nhitsEC->Print("itersum.ps");
5934  XYMapsEC *nhitsECAr = nullptr;
5935  if (isAr)
5936  {
5937  nhitsECAr = new XYMapsEC(argv[2], "nt0", true);
5938  nhitsECAr->Print("itersum.ps");
5939  }
5940  // Do res plot:
5941  XYMapsEC *resxy0EC = new XYMapsEC(argv[2], "res");
5942  resxy0EC->Print("itersum.ps");
5943  XYMapsEC *resxy0ECAr = nullptr;
5944  if (isAr)
5945  {
5946  resxy0ECAr = new XYMapsEC(argv[2], "res", true);
5947  resxy0ECAr->Print("itersum.ps");
5948  }
5949 
5950  XYMapsEC *resxyM0EC = new XYMapsEC(argv[2], "abs(resMean)");
5951  resxyM0EC->Print("itersum.ps");
5952  XYMapsEC *resxyM0ECAr = nullptr;
5953  if (isAr)
5954  {
5955  resxyM0ECAr = new XYMapsEC(argv[2], "abs(resMean)", true);
5956  resxyM0ECAr->Print("itersum.ps");
5957  }
5958 
5959  // Do t0s plots:
5960  XYMapsEC *xymapEC = new XYMapsEC(argv[2], "t0");
5961  xymapEC->Print("itersum.ps");
5962  XYMapsEC *xymapECAr = nullptr;
5963  if (isAr)
5964  {
5965  xymapECAr = new XYMapsEC(argv[2], "t0", true);
5966  xymapECAr->Print("itersum.ps");
5967  }
5968 
5969  // Do Oldt0plots
5970  XYMapsEC *oldt0EC = nullptr;
5971  if (do_expert)
5972  oldt0EC = new XYMapsEC(argv[2], "oldt0");
5973  if (do_expert)
5974  oldt0EC->Print("itersum.ps");
5975  XYMapsEC *oldt0ECAr = nullptr;
5976  if (do_expert)
5977  {
5978  if (isAr)
5979  {
5980  oldt0ECAr = new XYMapsEC(argv[2], "oldt0", true);
5981  oldt0ECAr->Print("itersum.ps");
5982  }
5983  }
5984 
5985  // Do t0 diff:
5986  XYMapsEC *oldt01EC = new XYMapsEC(argv[2], "abs(t0-oldt0)");
5987  oldt01EC->Print("itersum.ps");
5988  XYMapsEC *oldt01ECAr = nullptr;
5989  if (isAr)
5990  {
5991  oldt01ECAr = new XYMapsEC(argv[2], "abs(t0-oldt0)", true);
5992  oldt01ECAr->Print("itersum.ps");
5993  }
5994 
5995  // Do t0 widht:
5996 
5997  XYMapsEC *oldt0111EC = nullptr;
5998  if (do_expert)
5999  oldt0111EC = new XYMapsEC(argv[2], "abs(tresMean)");
6000  if (do_expert)
6001  oldt0111EC->Print("itersum.ps");
6002  XYMapsEC *oldt0111ECAr = nullptr;
6003  if (do_expert)
6004  {
6005  if (isAr)
6006  {
6007  oldt0111ECAr = new XYMapsEC(argv[2], "abs(tresMean)", true);
6008  oldt0111ECAr->Print("itersum.ps");
6009  }
6010  }
6011  // Do t0 widht:
6012  XYMapsEC *oldt011EC = new XYMapsEC(argv[2], "tres");
6013  oldt011EC->Print("itersum.ps");
6014  XYMapsEC *oldt011ECAr = nullptr;
6015  if (isAr)
6016  {
6017  oldt011ECAr = new XYMapsEC(argv[2], "tres", true);
6018  oldt011ECAr->Print("itersum.ps");
6019  }
6020 
6021  // Do board variations for Ar
6022  c1->cd();
6023  c1->Divide(1, 2, 0.01, 0.01);
6024  c1->cd(1);
6025  boardECgraphA->Draw("apl");
6026  boardECgraphA->DrawLines();
6027  if (refboardECgraphA)
6028  refboardECgraphA->Draw("pl");
6029  TLegend *legAr = new TLegend(0.8, 0.8, 0.98, 0.95);
6030  legAr->AddEntry(boardECgraphA, "data", "l");
6031  if (refboardECgraphA)
6032  leg->AddEntry(refboardECgraphA, "ref (input to 1st it)", "l");
6033  legAr->SetTextSize(0.03);
6034  legAr->Draw();
6035  c1->cd(2);
6036  boardECgraphC->Draw("apl");
6037  boardECgraphC->DrawLines();
6038  if (refboardECgraphC)
6039  refboardECgraphC->Draw("pl");
6040  c1->Print("itersum.ps");
6041  c1->Clear();
6042 
6043  // Add the plot for Board T0 variations differenses
6044  if (useref)
6045  {
6046  c1->cd();
6047  c1->Divide(1, 2, 0.01, 0.01);
6048  c1->cd(1);
6049  boarddiffECgraphA->Draw("ap");
6050  boarddiffECgraphA->DrawLines();
6051  c1->cd(2);
6052  boarddiffECgraphC->Draw("ap");
6053  boarddiffECgraphC->DrawLines();
6054  if (do_expert)
6055  c1->Print("itersum.ps");
6056  c1->Clear();
6057  }
6058 
6059  c1->cd();
6060  c1->Divide(1, 2, 0.01, 0.01);
6061  c1->cd(1);
6062  boardECgraphA1->Draw("apl");
6063  boardECgraphA1->DrawLines();
6064  c1->cd(2);
6065  boardECgraphC1->Draw("apl");
6066  boardECgraphC1->DrawLines();
6067  c1->Print("itersum.ps");
6068  c1->Clear();
6069 
6070  c1->cd();
6071  c1->Divide(1, 2, 0.01, 0.01);
6072  c1->cd(1);
6073  boardECgraphA2->Draw("apl");
6074  boardECgraphA2->DrawLines();
6075  c1->cd(2);
6076  boardECgraphC2->Draw("apl");
6077  boardECgraphC2->DrawLines();
6078  c1->Print("itersum.ps");
6079  c1->Clear();
6080 
6081  c1->cd();
6082  c1->Divide(1, 2, 0.01, 0.01);
6083  c1->cd(1);
6084  boardECgraphA3->Draw("apl");
6085  boardECgraphA3->DrawLines();
6086  c1->cd(2);
6087  boardECgraphC3->Draw("apl");
6088  boardECgraphC3->DrawLines();
6089  c1->Print("itersum.ps");
6090  c1->Clear();
6091 
6092  // ################################### RT PLOTS: ########################################################
6093 
6094  textpage = new TextPage(" RT PLOTS ");
6095  textpage->Print("itersum.ps");
6096  c1->Clear();
6097 
6098  gStyle->SetOptStat(1);
6099  gStyle->SetOptFit(0);
6100  if (do_expert)
6101  if (rtrelation_bar)
6102  rtrelation_bar->Print("itersum.ps");
6103  c1->Clear();
6104  if (do_expert)
6105  if (rtbinning_bar)
6106  rtbinning_bar->Print("itersum.ps");
6107  c1->Clear();
6108  if (do_expert)
6109  if (rtrelation21)
6110  rtrelation21->Print("itersum.ps");
6111  c1->Clear();
6112  if (do_expert)
6113  if (rtbinning1)
6114  rtbinning1->Print("itersum.ps");
6115  c1->Clear();
6116  if (do_expert)
6117  if (rtrelation31)
6118  rtrelation31->Print("itersum.ps");
6119  c1->Clear();
6120  if (do_expert)
6121  if (rtbinning2)
6122  rtbinning2->Print("itersum.ps");
6123  c1->Clear();
6124  if (do_expert)
6125  if (rtrelation41)
6126  rtrelation41->Print("itersum.ps");
6127  c1->Clear();
6128  if (do_expert)
6129  if (rtbinning3)
6130  rtbinning3->Print("itersum.ps");
6131  c1->Clear();
6132  if (do_expert)
6133  if (rtrelation51)
6134  rtrelation51->Print("itersum.ps");
6135  c1->Clear();
6136  if (do_expert)
6137  if (rtbinning4)
6138  rtbinning4->Print("itersum.ps");
6139  c1->Clear();
6140 
6141  if (do_expert)
6142  if (binres_bar)
6143  binres_bar->Print("itersum.ps");
6144  c1->Clear();
6145  if (do_expert)
6146  if (tbinnedres_bar)
6147  tbinnedres_bar->Print("itersum.ps");
6148  c1->Clear();
6149  if (do_expert)
6150  if (binres1)
6151  binres1->Print("itersum.ps");
6152  c1->Clear();
6153  if (do_expert)
6154  if (tbinnedres1)
6155  tbinnedres1->Print("itersum.ps");
6156  c1->Clear();
6157  if (do_expert)
6158  if (binres2)
6159  binres2->Print("itersum.ps");
6160  c1->Clear();
6161  if (do_expert)
6162  if (tbinnedres2)
6163  tbinnedres2->Print("itersum.ps");
6164  c1->Clear();
6165  if (do_expert)
6166  binres3->Print("itersum.ps");
6167  c1->Clear();
6168  if (do_expert)
6169  if (tbinnedres3)
6170  tbinnedres3->Print("itersum.ps");
6171  c1->Clear();
6172  if (do_expert)
6173  binres4->Print("itersum.ps");
6174  c1->Clear();
6175  if (do_expert)
6176  if (tbinnedres4)
6177  tbinnedres4->Print("itersum.ps");
6178  c1->Clear();
6179 
6180  gStyle->SetOptStat(0);
6181  if (do_expert)
6182  if (rtcol)
6183  rtcol->Print("itersum.ps");
6184  c1->Clear();
6185  if (do_expert)
6186  if (rtcol1)
6187  rtcol1->Print("itersum.ps");
6188  c1->Clear();
6189  if (rtcol2)
6190  rtcol2->Print("itersum.ps");
6191  c1->Clear();
6192  if (isAr && rtArcol2)
6193  rtArcol2->Print("itersum.ps");
6194  c1->Clear();
6195  if (rtcol3)
6196  rtcol3->Print("itersum.ps");
6197  c1->Clear();
6198  if (isAr && rtArcol3)
6199  rtArcol3->Print("itersum.ps");
6200  c1->Clear();
6201  if (rtcol4)
6202  rtcol4->Print("itersum.ps");
6203  c1->Clear();
6204  if (isAr && rtArcol4)
6205  rtArcol4->Print("itersum.ps");
6206  c1->Clear();
6207  if (rtcol5)
6208  rtcol5->Print("itersum.ps");
6209  c1->Clear();
6210  if (isAr && rtArcol5)
6211  rtArcol5->Print("itersum.ps");
6212  c1->Clear();
6213 
6214  // Plot all RTs together....
6215 
6216  DGraph *dgraph0 = nullptr; // trt
6217  DGraph *dgraph1 = nullptr; // -1
6218  DGraph *dgraph2 = nullptr; // 1
6219  DGraph *dgraph3 = nullptr; // -2
6220  DGraph *dgraph4 = nullptr; // 2
6221  DGraph *dgraph5 = nullptr; // whole barrel
6222  bool isinverted = false;
6223  if (datafile->FindKey("TRT_all"))
6224  {
6225  TDirectory *trt = (TDirectory *)datafile->FindKey("TRT_all")->ReadObj();
6226  cout << "MAKING DGraphs" << endl;
6227  c1->cd();
6228  c1->SetGrid();
6229  dgraph0 = new DGraph(argv[2], "-2,-1", "", -2, -1, isinverted);
6230  if (trt->FindKey("WholeBarrel_1"))
6231  {
6232  dgraph5 = new DGraph(argv[2], "-2,-1", "WholeBarrel_1", -1, -1, isinverted);
6233  }
6234  else
6235  {
6236  cout << " did not find WholeBarrel_1" << endl;
6237  if (trt->FindKey("Detector_1"))
6238  dgraph1 = new DGraph(argv[2], "-2,-1", "Detector_1", 1, -1, isinverted);
6239  if (trt->FindKey("Detector_-1"))
6240  dgraph2 = new DGraph(argv[2], "-2,-1", "Detector_-1", 1, -1, isinverted);
6241  }
6242  if (trt->FindKey("Detector_2"))
6243  dgraph3 = new DGraph(argv[2], "-2,-1", "Detector_2", 1, -1, isinverted);
6244  if (trt->FindKey("Detector_-2"))
6245  dgraph4 = new DGraph(argv[2], "-2,-1", "Detector_-2", 1, -1, isinverted);
6246 
6247 
6248  TLegend *leg = new TLegend(0.8, 0.8, 0.98, 0.95);
6249  if (dgraph0 != nullptr)
6250  {
6251  dgraph0->GetXaxis()->SetRangeUser(-5, 45);
6252  cout << " found TRT_all" << endl;
6253  dgraph0->SetLineWidth(3);
6254  dgraph0->SetLineColor(1);
6255  dgraph0->SetTitle("r(t)");
6256 
6257  dgraph0->GetXaxis()->SetTitle("t/ns");
6258 
6259  dgraph0->GetYaxis()->SetTitle("R / (mm)");
6260 
6261  if (dgraph0->rtgraph)
6262  dgraph0->Draw("apl");
6263  if (dgraph0->rtgraph)
6264  leg->AddEntry(dgraph0, "Whole TRT", "l");
6265  }
6266  if (dgraph1 != nullptr)
6267  {
6268  cout << " found Detector_1" << endl;
6269  dgraph1->SetLineWidth(3);
6270  dgraph1->SetLineColor(3);
6271  if (dgraph1->rtgraph)
6272  dgraph1->Draw("pl");
6273  if (dgraph1->rtgraph)
6274  leg->AddEntry(dgraph1, "Barrel C Side", "l");
6275  }
6276 
6277  if (dgraph2 != nullptr)
6278  {
6279  cout << " found Detector_-1" << endl;
6280  dgraph2->SetLineWidth(3);
6281  dgraph2->SetLineColor(2);
6282  if (dgraph2->rtgraph)
6283  dgraph2->Draw("pl");
6284  if (dgraph2->rtgraph)
6285  leg->AddEntry(dgraph2, "Barrel A Side", "l");
6286  }
6287 
6288  if (dgraph3 != nullptr)
6289  {
6290  dgraph3->SetLineWidth(3);
6291  cout << " found Detector_2" << endl;
6292  dgraph3->SetLineColor(6);
6293  if (dgraph3->rtgraph)
6294  dgraph3->Draw("pl");
6295  if (dgraph3->rtgraph)
6296  leg->AddEntry(dgraph3, "Endcap C side", "l");
6297  }
6298 
6299  if (dgraph4 != nullptr)
6300  {
6301  cout << " found Detector_-2" << endl;
6302  dgraph4->SetLineWidth(3);
6303  dgraph4->SetLineColor(7);
6304  if (dgraph4->rtgraph)
6305  dgraph4->Draw("pl");
6306  if (dgraph4->rtgraph)
6307  leg->AddEntry(dgraph4, "Endcap A side", "l");
6308  }
6309  if (dgraph5 != nullptr)
6310  {
6311  cout << " found WholeBarrel_1" << endl;
6312  dgraph5->SetLineWidth(3);
6313  dgraph5->SetLineColor(8);
6314  if (dgraph5->rtgraph)
6315  dgraph5->Draw("pl");
6316  if (dgraph5->rtgraph)
6317  leg->AddEntry(dgraph5, "Whole Barrel", "l");
6318  }
6319 
6320  leg->SetTextSize(0.03);
6321  leg->Draw();
6322  c1->Print("itersum.ps");
6323  c1->Clear();
6324  }
6325 
6326  // Plot drift velocity:
6327  DvGraph *dvgraph0 = nullptr; // trt
6328  DvGraph *dvgraph1 = nullptr; // -1
6329  DvGraph *dvgraph2 = nullptr; // 1
6330  DvGraph *dvgraph3 = nullptr; // -2
6331  DvGraph *dvgraph4 = nullptr; // 2
6332  DvGraph *dvgraph5 = nullptr; // whole barrel
6333  if (do_expert)
6334  {
6335  // bool isinverted=false;
6336  if (datafile->FindKey("TRT_all"))
6337  {
6338  cout << " do_expert: found TRT_all" << endl;
6339  TDirectory *trt = (TDirectory *)datafile->FindKey("TRT_all")->ReadObj();
6340  cout << "MAKING DvGraphs" << endl;
6341  c1->cd();
6342  c1->SetGrid();
6343  dvgraph0 = new DvGraph(argv[2], "-2,-1", "", -2, -1, isinverted);
6344  if (trt->FindKey("WholeBarrel_1"))
6345  dvgraph5 = new DvGraph(argv[2], "-2,-1", "WholeBarrel_1", -1, -1, isinverted);
6346  else
6347  {
6348  if (trt->FindKey("Detector_1"))
6349  dvgraph1 = new DvGraph(argv[2], "-2,-1", "Detector_1", 1, -1, isinverted);
6350  if (trt->FindKey("Detector_-1"))
6351  dvgraph2 = new DvGraph(argv[2], "-2,-1", "Detector_-1", 1, -1, isinverted);
6352  }
6353  if (trt->FindKey("Detector_2"))
6354  dvgraph3 = new DvGraph(argv[2], "-2,-1", "Detector_2", 1, -1, isinverted);
6355  if (trt->FindKey("Detector_-2"))
6356  dvgraph4 = new DvGraph(argv[2], "-2,-1", "Detector_-2", 1, -1, isinverted);
6357 
6358 
6359  TLegend *leg = new TLegend(0.8, 0.8, 0.98, 0.95);
6360  if (dvgraph0 != nullptr)
6361  {
6362  dvgraph0->GetXaxis()->SetRangeUser(0, 2);
6363  cout << " do_expert: found -2-1" << endl;
6364  dvgraph0->SetLineWidth(3);
6365  dvgraph0->SetLineColor(1);
6366  if (isinverted)
6367  dvgraph0->SetTitle("dt/dr");
6368  else
6369  dvgraph0->SetTitle("dr/dt");
6370  dvgraph0->GetXaxis()->SetTitle("r/mm");
6371  if (isinverted)
6372  dvgraph0->GetYaxis()->SetTitle("dt/dr / (ns/mm)");
6373  else
6374  dvgraph0->GetYaxis()->SetTitle("dr/dt / (mm/ns)");
6375  if (dvgraph0->rtgraph)
6376  dvgraph0->Draw("apl");
6377  if (dvgraph0->rtgraph)
6378  leg->AddEntry(dvgraph0, "Whole TRT", "l");
6379  }
6380  if (dvgraph1 != nullptr)
6381  {
6382  cout << " do_expert: found Detector_1" << endl;
6383  dvgraph1->SetLineWidth(3);
6384  dvgraph1->SetLineColor(3);
6385  if (dvgraph1->rtgraph)
6386  dvgraph1->Draw("pl");
6387  if (dvgraph1->rtgraph)
6388  leg->AddEntry(dvgraph1, "Barrel C Side", "l");
6389  }
6390 
6391  if (dvgraph2 != nullptr)
6392  {
6393  dvgraph2->SetLineWidth(3);
6394  dvgraph2->SetLineColor(2);
6395  if (dvgraph2->rtgraph)
6396  dvgraph2->Draw("pl");
6397  if (dvgraph2->rtgraph)
6398  leg->AddEntry(dvgraph2, "Barrel A Side", "l");
6399  }
6400 
6401  if (dvgraph3 != nullptr)
6402  {
6403  dvgraph3->SetLineWidth(3);
6404  dvgraph3->SetLineColor(6);
6405  if (dvgraph3->rtgraph)
6406  dvgraph3->Draw("pl");
6407  if (dvgraph3->rtgraph)
6408  leg->AddEntry(dvgraph3, "Endcap C side", "l");
6409  }
6410 
6411  if (dvgraph4 != nullptr)
6412  {
6413  dvgraph4->SetLineWidth(3);
6414  dvgraph4->SetLineColor(7);
6415  if (dvgraph4->rtgraph)
6416  dvgraph4->Draw("pl");
6417  if (dvgraph4->rtgraph)
6418  leg->AddEntry(dvgraph4, "Endcap A side", "l");
6419  }
6420  if (dvgraph5 != nullptr)
6421  {
6422  dvgraph5->SetLineWidth(3);
6423  dvgraph5->SetLineColor(8);
6424  if (dvgraph5->rtgraph)
6425  dvgraph5->Draw("pl");
6426  if (dvgraph5->rtgraph)
6427  leg->AddEntry(dvgraph5, "Whole Barrel", "l");
6428  }
6429 
6430  leg->SetTextSize(0.03);
6431  leg->Draw();
6432  c1->Print("itersum.ps");
6433  c1->Clear();
6434  }
6435  }
6436 
6437  // ################################### ADD PLOTS FOR TRACKING #######################################33
6438  c1->Clear();
6439  textpage = new TextPage("Track plots: Only for Experts!!!");
6440  textpage->Print("itersum.ps");
6441  c1->Clear();
6442 
6443  bool istracktuple = false;
6444  TNtuple *Tracktuple = nullptr;
6445  if (datafile->FindKey("tracktuple"))
6446  {
6447  Tracktuple = (TNtuple *)datafile->Get("tracktuple");
6448  istracktuple = true;
6449  }
6450 
6451  cout << "MAKING TRACK PLOTS" << endl;
6452  c1->Clear();
6453  if (istracktuple)
6454  {
6455  // first Residuals:
6456  if (Tracktuple->GetListOfBranches()->FindObject("trackres"))
6457  {
6458  c1->cd();
6459  c1->Divide(2, 1, 0.01, 0.01);
6460  c1->cd(1);
6461  Tracktuple->Draw("trackres>>histRes(100,0,1.5)");
6462  TH1F *histRes = (TH1F *)gPad->GetPrimitive("histRes");
6463  histRes->SetTitle("Residual on track");
6464  histRes->GetXaxis()->SetTitle("Residual (mm)");
6465  histRes->Draw();
6466 
6467  c1->cd(2);
6468  Tracktuple->Draw("trackres:t-ttrack-t0>>histRes2d(100,-12,12,100,0,1)", "", "colz");
6469  TH2F *histRes2d = (TH2F *)gPad->GetPrimitive("histRes2d");
6470  histRes2d->SetTitle("Track time residual VS track residual");
6471  histRes2d->GetXaxis()->SetTitle("Time residual (ns)");
6472  histRes2d->GetYaxis()->SetTitle("Track Residual (mm)");
6473  histRes2d->Draw("colz");
6474  TProfile *res2d = histRes2d->ProfileX();
6475  res2d->Draw("same");
6476 
6477  c1->Print("itersum.ps");
6478  c1->Clear();
6479  }
6480 
6481  // first pt:
6482  if (Tracktuple->GetListOfBranches()->FindObject("pt"))
6483  {
6484  c1->cd();
6485  c1->Divide(2, 1, 0.01, 0.01);
6486  c1->cd(1);
6487  Tracktuple->Draw("pt/1000>>histPt(100,0,20)");
6488  TH1F *histPt = (TH1F *)gPad->GetPrimitive("histPt");
6489  histPt->SetTitle("Transverse momentum on track");
6490  histPt->GetXaxis()->SetTitle("Pt (GeV)");
6491  histPt->Draw();
6492 
6493  c1->cd(2);
6494  Tracktuple->Draw("trackres:pt/1000>>histPt2d(100,0,20,100,0,1.5)", "", "colz");
6495  TH2F *histPt2d = (TH2F *)gPad->GetPrimitive("histPt2d");
6496  histPt2d->SetTitle("Transverse momentum on track VS track residual");
6497  histPt2d->GetXaxis()->SetTitle("Pt (GeV)");
6498  histPt2d->GetYaxis()->SetTitle("Track Residual (mm)");
6499  histPt2d->Draw("COLZ");
6500  TProfile *pt2d = histPt2d->ProfileX();
6501  pt2d->Draw("same");
6502  c1->Print("itersum.ps");
6503  c1->Clear();
6504  }
6505  // first theta:
6506  if (Tracktuple->GetListOfBranches()->FindObject("theta"))
6507  {
6508  c1->cd();
6509  c1->Divide(2, 1, 0.01, 0.01);
6510  c1->cd(1);
6511  Tracktuple->Draw("theta>>histTheta(100,0,4)");
6512  TH1F *histTheta = (TH1F *)gPad->GetPrimitive("histTheta");
6513  histTheta->SetTitle("Theta distribution on track");
6514  histTheta->GetXaxis()->SetTitle("Theta (rad)");
6515  histTheta->Draw();
6516 
6517  c1->cd(2);
6518  Tracktuple->Draw("trackres:theta>>histTheta2d(100,0,4,100,0,1.5)", "", "colz");
6519  TH2F *histTheta2d = (TH2F *)gPad->GetPrimitive("histTheta2d");
6520  histTheta2d->SetTitle("Theta distrib. on track VS track residual");
6521  histTheta2d->GetXaxis()->SetTitle("Theta (rad)");
6522  histTheta2d->GetYaxis()->SetTitle("Track Residual (mm)");
6523  histTheta2d->Draw("COLZ");
6524  TProfile *theta2d = histTheta2d->ProfileX();
6525  theta2d->Draw("same");
6526  c1->Print("itersum.ps");
6527  c1->Clear();
6528  }
6529  // first phi:
6530  if (Tracktuple->GetListOfBranches()->FindObject("phi"))
6531  {
6532  c1->cd();
6533  c1->Divide(2, 1, 0.01, 0.01);
6534  c1->cd(1);
6535  Tracktuple->Draw("phi>>histPhi(100,-3.5,0)");
6536  TH1F *histPhi = (TH1F *)gPad->GetPrimitive("histPhi");
6537  histPhi->SetTitle("Phi distribution on track");
6538  histPhi->GetXaxis()->SetTitle("Phi (rad)");
6539  histPhi->Draw();
6540 
6541  c1->cd(2);
6542  Tracktuple->Draw("trackres:phi>>histPhi2d(100,-3.5,0,100,0,1.5)", "", "colz");
6543  TH2F *histPhi2d = (TH2F *)gPad->GetPrimitive("histPhi2d");
6544  histPhi2d->SetTitle("Phi distrib. on track VS track residual");
6545  histPhi2d->GetXaxis()->SetTitle("Phi (rad)");
6546  histPhi2d->GetYaxis()->SetTitle("Track Residual (mm)");
6547  histPhi2d->Draw("COLZ");
6548  TProfile *phi2d = histPhi2d->ProfileX();
6549  phi2d->Draw("same");
6550  c1->Print("itersum.ps");
6551  c1->Clear();
6552  }
6553  // first d0:
6554  if (Tracktuple->GetListOfBranches()->FindObject("d0"))
6555  {
6556  c1->cd();
6557  c1->Divide(2, 1, 0.01, 0.01);
6558  c1->cd(1);
6559  Tracktuple->Draw("d0>>histD0(100,-5,5)");
6560  TH1F *histD0 = (TH1F *)gPad->GetPrimitive("histD0");
6561  histD0->SetTitle("D0 distribution on track");
6562  histD0->GetXaxis()->SetTitle("D0 (mm)");
6563  histD0->Draw();
6564 
6565  c1->cd(2);
6566  Tracktuple->Draw("trackres:d0>>histD02d(100,-5,5,100,0,1.5)", "", "colz");
6567  TH2F *histD02d = (TH2F *)gPad->GetPrimitive("histD02d");
6568  histD02d->SetTitle("D0 distrib. on track VS track residual");
6569  histD02d->GetXaxis()->SetTitle("D0 (rad)");
6570  histD02d->GetYaxis()->SetTitle("Track Residual (mm)");
6571  histD02d->Draw("COLZ");
6572  TProfile *d02d = histD02d->ProfileX();
6573  d02d->Draw("same");
6574  c1->Print("itersum.ps");
6575  c1->Clear();
6576  }
6577  }
6578 
6579  // ################################### ADD PLOTS FOR Pulls and Errors #######################################33
6580 
6581  // Skip all this for now (PH)
6582  cout << " Skipping plots for Pulls and Errors " << endl;
6583 
6584  // SERGI - Another block not used :). Firewalls below previously commented... useless block of code
6585  // bool iserrors = false;
6586  // TDirectory *errors = nullptr;
6587  // if (datafile->FindKey("Errors"))
6588  // {
6589  // errors = (TDirectory *)datafile->FindKey("Errors")->ReadObj();
6590  // if (errors != nullptr)
6591  // iserrors = true;
6592  // }
6593 
6594  c1->Clear();
6595  /*
6596  textpage = new TextPage(" Error Plots and Pt dependence. Only for Experts!!!");
6597  textpage->Print("itersum.ps");
6598  c1->Clear();
6599 
6600  cout << "Making Error/Pt plots:" << endl;
6601  c1->Clear();
6602  if (iserrors){
6603  //first Residuals:
6604  cout << "Start with Pt plots:" << endl;
6605  errors->cd();
6606 
6607  PtDependence* ptstuff = new PtDependence(datafile);
6608  ptstuff->Print("itersum.ps");
6609 
6610  TBDependence* tbstuff = new TBDependence(datafile);
6611  tbstuff->Print("itersum.ps");
6612 
6613 
6614 
6615  }
6616 
6617 
6618  */
6619 
6620  // ################################### ADD PLOTS FOR ToT and HT #######################################33
6621 
6622  // Skip all this for now (PH)
6623  cout << " Skipping plots for ToT and HT " << endl;
6624 
6625  // SERGI - Firewalls below previously commented... useless block of code
6626  // bool iscorrections = false;
6627  // TDirectory *corrections = nullptr;
6628  // if (datafile->FindKey("Correction"))
6629  // {
6630  // corrections = (TDirectory *)datafile->FindKey("Correction")->ReadObj();
6631  // if (corrections != nullptr)
6632  // iscorrections = true;
6633  // }
6634 
6635  c1->Clear();
6636  textpage = new TextPage(" ToT Corrections and HT corrections: ");
6637  textpage->Print("itersum.pdf");
6638  c1->Clear();
6639 
6640  cout << "Making ToT / HT Plots" << endl;
6641  c1->Clear();
6642  /*
6643  if (iscorrections){
6644  //first Residuals:
6645  cout << "Start with ToT plots:" << endl;
6646  corrections->cd();
6647 
6648  ToTDependence* totstuff = new ToTDependence(datafile, true); // Barrels:
6649  totstuff->Print("itersum.ps");
6650 
6651  ToTDependence* totstuff2 = new ToTDependence(datafile, false); // Barrels:
6652  totstuff2->Print("itersum.ps");
6653 
6654  cout << "Start with HT plots:" << endl;
6655 
6656  ToTDependence* htstuff = new ToTDependence(datafile, true, true ); // Barrels:
6657  htstuff->Print("itersum.ps");
6658 
6659  ToTDependence* htstuff2 = new ToTDependence(datafile, false, true); // Barrels:
6660  htstuff2->Print("itersum.ps");
6661 
6662  cout << "Start with sin(theta) / p plots:" << endl;
6663 
6664  SinDependence* sinstuff = new SinDependence(datafile, true); // Barrels:
6665  sinstuff->Print("itersum.ps");
6666 
6667  SinDependence* sinstuff2 = new SinDependence(datafile, false); // Barrels:
6668  sinstuff2->Print("itersum.ps");
6669 
6670  cout << "Start with cos(theta) / p plots:" << endl;
6671 
6672  SinDependence* cosstuff = new SinDependence(datafile, true, true); // Barrels:
6673  cosstuff->Print("itersum.ps");
6674 
6675  SinDependence* cosstuff2 = new SinDependence(datafile, false, true); // Barrels:
6676  cosstuff2->Print("itersum.ps");
6677 
6678 
6679  }
6680 
6681 
6682  */
6683 
6684  // ################################### ADD PLOTS FOR ToT and HT ARGON #######################################33
6685 
6686  // bool iscorrectionsAr = false;
6687  // TDirectory *correctionsAr = nullptr;
6688  // if (datafile->FindKey("CorrectionAr"))
6689  // {
6690  // correctionsAr = (TDirectory *)datafile->FindKey("CorrectionAr")->ReadObj();
6691  // if (correctionsAr != nullptr)
6692  // iscorrectionsAr = true;
6693  // }
6694 
6695  /*
6696  if (iscorrectionsAr){
6697  c1->Clear();
6698  textpage = new TextPage(" ToT Corrections and HT corrections: ARGON");
6699  textpage->Print("itersum.ps");
6700  c1->Clear();
6701 
6702  cout << "Making ToT / HT Plots ARGON" << endl;
6703  c1->Clear();
6704  //first Residuals:
6705  cout << "Start with ToT plots:" << endl;
6706  corrections->cd();
6707 
6708  ToTDependence* totstuff = new ToTDependence(datafile, true, false, true); // Barrels:
6709  totstuff->Print("itersum.ps");
6710 
6711  ToTDependence* totstuff2 = new ToTDependence(datafile, false, false, true); // Barrels:
6712  totstuff2->Print("itersum.ps");
6713 
6714  cout << "Start with HT plots:" << endl;
6715 
6716  ToTDependence* htstuff = new ToTDependence(datafile, true, true, true ); // Barrels:
6717  htstuff->Print("itersum.ps");
6718 
6719  ToTDependence* htstuff2 = new ToTDependence(datafile, false, true, true); // Barrels:
6720  htstuff2->Print("itersum.ps");
6721 
6722  cout << "Start with sin(theta) / p plots:" << endl;
6723 
6724  SinDependence* sinstuff = new SinDependence(datafile, true, false, true); // Barrels:
6725  sinstuff->Print("itersum.ps");
6726 
6727  // SinDependence* sinstuff2 = new SinDependence(datafile, false, false, true); // Barrels:
6728  // sinstuff2->Print("itersum.ps");
6729 
6730  cout << "Start with cos(theta) / p plots:" << endl;
6731 
6732  // SinDependence* cosstuff = new SinDependence(datafile, true, true, true); // Barrels:
6733  // cosstuff->Print("itersum.ps");
6734 
6735  SinDependence* cosstuff2 = new SinDependence(datafile, false, true, true); // Barrels:
6736  cosstuff2->Print("itersum.ps");
6737 
6738 
6739  }
6740 
6741  c1->Print("itersum.ps]");
6742  */
6743 
6744  datafile->Close();
6745  if (useref)
6746  refdatafile->Close();
6747 
6748  // cout << "RDIFF -1 ";
6749  // for (map<double,double>::iterator rtpoint = rtrelation21->rtmap.begin(); rtpoint != rtrelation21->rtmap.end(); rtpoint++){
6750  // cout << binres1->resmap[rtpoint->second] << " ";
6751  // }
6752  // cout << endl;
6753  // cout << "RDIFF 1 ";
6754  // for (map<double,double>::iterator rtpoint = rtrelation31->rtmap.begin(); rtpoint != rtrelation31->rtmap.end(); rtpoint++){
6755  // cout << binres2->resmap[rtpoint->second] << " ";
6756  // }
6757  // cout << endl;
6758 
6759  // cout << "RDIFF -2 ";
6760  // for (map<double,double>::iterator rtpoint = rtrelation41->rtmap.begin(); rtpoint != rtrelation41->rtmap.end(); rtpoint++){
6761  // cout << binres3->resmap[rtpoint->second] << " ";
6762  // }
6763  // cout << endl;
6764 
6765  // cout << "RDIFF 2 ";
6766  // for (map<double,double>::iterator rtpoint = rtrelation51->rtmap.begin(); rtpoint != rtrelation51->rtmap.end(); rtpoint++){
6767  // cout << binres4->resmap[rtpoint->second] << " ";
6768  // }
6769  // cout << endl;
6770 
6771  // add some extra info to each page
6772  if (settings && firstpage)
6773  {
6774  string fixfloat, fieldonoff;
6775  if (settings->set["UsePol0"].find("True") != string::npos)
6776  fixfloat = " - floating";
6777  else
6778  fixfloat = " - fixed";
6779  if (settings->set["RtRelation"].find("binned") != string::npos)
6780  fixfloat = "";
6781  if (settings->set["Solenoid"].find("True") != string::npos)
6782  fieldonoff = "ON";
6783  else
6784  fieldonoff = "OFF";
6785 
6786  string pmarking =
6787  string("/Helvetica-Bold findfont 36 scalefont setfont 40 2190 moveto (Run:) show ") +
6788  string(Form("/Helvetica findfont 36 scalefont setfont 240 2190 moveto (%i) show ", (int)firstpage->runnumber)) +
6789 
6790  string("/Helvetica-Bold findfont 36 scalefont setfont 40 2150 moveto (Iteration:) show ") +
6791  string(Form("/Helvetica findfont 36 scalefont setfont 240 2150 moveto (%02i) show ", firstpage->iter)) +
6792 
6793  string("/Helvetica-Bold findfont 36 scalefont setfont 40 2110 moveto (Rt relation:) show ") +
6794  string(Form("/Helvetica findfont 36 scalefont setfont 240 2110 moveto (%s%s) show ", settings->set["RtRelation"].data(), fixfloat.data())) +
6795 
6796  string("/Helvetica-Bold findfont 36 scalefont setfont 540 2190 moveto (Rt binning:) show ") +
6797  string(Form("/Helvetica findfont 36 scalefont setfont 740 2190 moveto (%s) show ", settings->set["RtBinning"].data())) +
6798 
6799  string("/Helvetica-Bold findfont 36 scalefont setfont 540 2150 moveto (Rt level:) show ") +
6800 
6801  string("/Helvetica-Bold findfont 36 scalefont setfont 540 2110 moveto (T0 level:) show ") +
6802 
6803  string("/Helvetica-Bold findfont 36 scalefont setfont 1040 2190 moveto (Solenoid:) show ") +
6804  string(Form("/Helvetica findfont 36 scalefont setfont 1260 2190 moveto (%s) show ", fieldonoff.data())) +
6805 
6806  string("/Helvetica-Bold findfont 36 scalefont setfont 1040 2150 moveto (SW release:) show ") +
6807  string(Form("/Helvetica findfont 36 scalefont setfont 1260 2150 moveto (%s) show ", settings->set["ReleaseRec"].data())) +
6808 
6809  string("/Helvetica-Bold findfont 36 scalefont setfont 1040 2110 moveto (T0 Offset:) show ") +
6810  string(Form("/Helvetica findfont 36 scalefont setfont 1260 2110 moveto (%s) show ", settings->set["T0Offset"].data())) +
6811 
6812  string("/Helvetica-Bold findfont 30 scalefont setfont 40 2060 moveto (Data:) show ") +
6813  string(Form("/Helvetica findfont 30 scalefont setfont 240 2060 moveto (%s) show ", settings->set["Inputdir"].data())) +
6814 
6815  string("/Helvetica-Bold findfont 30 scalefont setfont 40 2020 moveto (Start const:) show ") +
6816  string(Form("/Helvetica findfont 30 scalefont setfont 240 2020 moveto (%s) show ", settings->set["StartConst"].data()));
6817  system((string("sed -i 's?showpage?" + pmarking + "showpage?g' itersum.ps")).data());
6818  }
6819 
6820  // Add some graphs in a new direcrory "analysis"
6821  datafile = new TFile(argv[2], "UPDATE");
6822  datafile->cd();
6823  if (datafile->FindKey("analysis"))
6824  datafile->rmdir("analysis");
6825  TDirectory *adir = datafile->mkdir("analysis", "analysis");
6826  adir->cd();
6827  if (chipgraphA)
6828  chipgraphA->Write();
6829  if (chipgraphC)
6830  chipgraphC->Write();
6831  boardgraphA->Write();
6832  boardgraphC->Write();
6833  if (refboardgraphA)
6834  refboardgraphA->Write();
6835  if (refboardgraphC)
6836  refboardgraphC->Write();
6837  if (dvgraph0)
6838  dvgraph0->Write();
6839  if (dvgraph1)
6840  dvgraph1->Write();
6841  if (dvgraph2)
6842  dvgraph2->Write();
6843  datafile->Write();
6844  datafile->Close();
6845 
6846  return 0;
6847 }
6848 
6849 int tt_remove(int /*argc*/, char *argv[])
6850 {
6851 
6852  TFile *itersumfile = new TFile(argv[2], "UPDATE");
6853  if (itersumfile->FindKey("tracktuple"))
6854  {
6855  itersumfile->Delete("tracktuple;*");
6856  }
6857  if (itersumfile->FindKey("binhist"))
6858  {
6859  itersumfile->rmdir("binhist");
6860  }
6861  if (itersumfile->FindKey("analysis"))
6862  {
6863  itersumfile->rmdir("analysis");
6864  }
6865 
6866  itersumfile->Write();
6867  itersumfile->Close();
6868 
6869  return 0;
6870 }
6871 
6872 int main (int argc, char *argv[])
6873 {
6874 
6875  gErrorIgnoreLevel = kFatal; // Explicitly remove all messages
6876 
6877  if ((string(argv[1])).find("itersum") != std::string::npos)
6878  {
6879  cout << "GENERATING ITERATION SUMMARY PLOTS" << endl;
6880  itersum(argc, argv);
6881  }
6882 
6883  if ((string(argv[1])).find("restore") != std::string::npos)
6884  {
6885  cout << "REMOVING THE TRACKTUPLE, BINHIST AND ANALYSE DIRECTORY" << endl;
6886  tt_remove(argc, argv);
6887  }
6888 
6889  return 0;
6890 }
plotBeamSpotCompare.ex1
ex1
Definition: plotBeamSpotCompare.py:217
BoardVariationsDiff::GetX
double * GetX()
Definition: TRTCalib_makeplots.cxx:1034
plotBeamSpotCompare.gr1
gr1
Definition: plotBeamSpotCompare.py:391
RresTbin::m_etdata
std::vector< double > m_etdata
Definition: TRTCalib_makeplots.cxx:3336
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
PtDependence::m_errors
TDirectory * m_errors
Definition: TRTCalib_makeplots.cxx:4081
beamspotman.r
def r
Definition: beamspotman.py:676
GetPn
TGraphErrors * GetPn(TH2F *histo)
Definition: TRTCalib_makeplots.cxx:3960
temp
Definition: JetEventDict.h:21
XYMaps
Definition: TRTCalib_makeplots.cxx:280
extractSporadic.nhists
nhists
Definition: extractSporadic.py:111
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
RresTbin::m_thegraph
TGraphErrors m_thegraph
Definition: TRTCalib_makeplots.cxx:3332
SinDependence::m_errors
TDirectory * m_errors
Definition: TRTCalib_makeplots.cxx:4882
checkFileSG.line
line
Definition: checkFileSG.py:75
color
Definition: jFexInputByteStreamTool.cxx:25
BoardVariationsRes::GetNpoints
int GetNpoints()
Definition: TRTCalib_makeplots.cxx:1297
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
mean
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
Definition: dependence.cxx:254
BoardVariationsTRes1::BoardVariationsTRes1
BoardVariationsTRes1(char *, int)
Definition: TRTCalib_makeplots.cxx:1467
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:128
max
#define max(a, b)
Definition: cfImp.cxx:41
ResidualPlots
Definition: TRTCalib_makeplots.cxx:2935
run.infile
string infile
Definition: run.py:13
trim
string trim(string s)
Definition: TRTCalib_makeplots.cxx:76
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
BoardVariationsOldT0::DrawLines
void DrawLines()
Definition: TRTCalib_makeplots.cxx:1267
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
RresTbin::m_erdata
std::vector< double > m_erdata
Definition: TRTCalib_makeplots.cxx:3334
FirstPage::iter
int iter
Definition: TRTCalib_makeplots.cxx:3533
RresTbin
Definition: TRTCalib_makeplots.cxx:3325
VertexShift::Xmin
const float Xmin
Definition: VertexShift.h:25
TRTCalib_Extractor.det
det
Definition: TRTCalib_Extractor.py:36
BoardVariationsTRes
Definition: TRTCalib_makeplots.cxx:1632
T0CalTypeXY::Draw
void Draw(const string &, bool)
Definition: TRTCalib_makeplots.cxx:617
PixelAthClusterMonAlgCfg.zmin
zmin
Definition: PixelAthClusterMonAlgCfg.py:169
ToTDependence
Definition: TRTCalib_makeplots.cxx:4591
TRTCalib_cfilter.detector
detector
Definition: TRTCalib_cfilter.py:241
BoardVariationsTRes::GetX
double * GetX()
Definition: TRTCalib_makeplots.cxx:1637
RresTbin::resmap
map< double, double > resmap
Definition: TRTCalib_makeplots.cxx:3329
TRTPlots::TRTPlots
TRTPlots(TFile *, bool)
Definition: TRTCalib_makeplots.cxx:3218
DGraph::rtgraph
TGraph * rtgraph
Definition: TRTCalib_makeplots.cxx:1931
RresTbin::reshists
vector< TH1D * > reshists
Definition: TRTCalib_makeplots.cxx:3328
plotmaker.hist
hist
Definition: plotmaker.py:148
CalibDbCompareT0.dt0
dt0
Definition: CalibDbCompareT0.py:76
BoardVariationsDiff::GetY
double * GetY()
Definition: TRTCalib_makeplots.cxx:1035
extractSporadic.c1
c1
Definition: extractSporadic.py:134
BoardVariationsTRes::BoardVariationsTRes
BoardVariationsTRes(char *, int)
Definition: TRTCalib_makeplots.cxx:1642
XYMaps::XYMaps
XYMaps(char *, string, bool)
Definition: TRTCalib_makeplots.cxx:285
FirstPage::runnumber
float runnumber
Definition: TRTCalib_makeplots.cxx:3532
ALFA_EventTPCnv_Dict::t0
std::vector< ALFA_RawData_p1 > t0
Definition: ALFA_EventTPCnvDict.h:42
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
Cut::all
@ all
Definition: SUSYToolsAlg.cxx:67
test_pyathena.pt
pt
Definition: test_pyathena.py:11
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
PlotCalibFromCool.ib
ib
Definition: PlotCalibFromCool.py:419
DvGraph::rtgraph
TGraph * rtgraph
Definition: TRTCalib_makeplots.cxx:1802
GetMean
TGraphErrors * GetMean(TH2F *histo)
Definition: TRTCalib_makeplots.cxx:3907
GetMeanE
TGraphErrors * GetMeanE(TH2F *histo)
Definition: TRTCalib_makeplots.cxx:3936
GetWidth
TGraphErrors * GetWidth(TH2F *histo)
Definition: TRTCalib_makeplots.cxx:3983
TRTPlots
Definition: TRTCalib_makeplots.cxx:3213
GetEntries
TGraphErrors * GetEntries(TH2F *histo)
Definition: TRTCalib_makeplots.cxx:4019
TBinnedRes
Definition: TRTCalib_makeplots.cxx:3264
read_hist_ntuple.h1
h1
Definition: read_hist_ntuple.py:21
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
x
#define x
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
BoardVariations::GetY
double * GetY()
Definition: TRTCalib_makeplots.cxx:868
ChipVariations::ChipVariations
ChipVariations(char *, int)
Definition: TRTCalib_makeplots.cxx:747
makeTRTBarrelCans.y1
tuple y1
Definition: makeTRTBarrelCans.py:15
DGraph::DGraph
DGraph(char *, string, string, int, int, bool)
Definition: TRTCalib_makeplots.cxx:1934
BoardVariationsDiff::BoardVariationsDiff
BoardVariationsDiff(char *, char *, int)
Definition: TRTCalib_makeplots.cxx:1039
Monitored::X
@ X
Definition: HistogramFillerUtils.h:24
SinDependence::SinDependence
SinDependence(TFile *, bool, bool, bool)
Definition: TRTCalib_makeplots.cxx:4885
HitStatistics::HitStatistics
HitStatistics(char *, bool)
Definition: TRTCalib_makeplots.cxx:150
BoardVariationsTRes1::GetX
double * GetX()
Definition: TRTCalib_makeplots.cxx:1462
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
BoardVariationsRes::DrawLines
void DrawLines()
Definition: TRTCalib_makeplots.cxx:1432
BoardVariationsRes::miny
float miny
Definition: TRTCalib_makeplots.cxx:1300
BoardVariationsOldT0::GetNpoints
int GetNpoints()
Definition: TRTCalib_makeplots.cxx:1141
BoardVariations::miny
float miny
Definition: TRTCalib_makeplots.cxx:869
maskDeadModules.mod
mod
Definition: maskDeadModules.py:36
ToTDependence::m_errors
TDirectory * m_errors
Definition: TRTCalib_makeplots.cxx:4596
RtColor
Definition: TRTCalib_makeplots.cxx:2706
ResizePalette
void ResizePalette(TH2 *hist)
Definition: TRTCalib_makeplots.cxx:68
perfmonmt-refit.slice
slice
Definition: perfmonmt-refit.py:52
BoardVariationsRes::BoardVariationsRes
BoardVariationsRes(char *, int)
Definition: TRTCalib_makeplots.cxx:1303
ParseInputs.gDirectory
gDirectory
Definition: Final2012/ParseInputs.py:133
lumiFormat.i
int i
Definition: lumiFormat.py:85
TBDependence::errors
TDirectory * errors
Definition: TRTCalib_makeplots.cxx:4294
D3PDSizeSummary.ff
ff
Definition: D3PDSizeSummary.py:305
python.TrigEgammaMonitorHelper.TProfile
def TProfile(*args, **kwargs)
Definition: TrigEgammaMonitorHelper.py:81
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
beamspotman.n
n
Definition: beamspotman.py:731
BoardVariationsDiff::GetNpoints
int GetNpoints()
Definition: TRTCalib_makeplots.cxx:1033
CaloNoise_fillDB.dt
dt
Definition: CaloNoise_fillDB.py:58
PtDependence::PtDependence
PtDependence(TFile *)
Definition: TRTCalib_makeplots.cxx:4084
covarianceTool.title
title
Definition: covarianceTool.py:542
RtGraphs
Definition: TRTCalib_makeplots.cxx:2053
TextPage
Definition: TRTCalib_makeplots.cxx:85
BoardVariationsTRes::DrawLines
void DrawLines()
Definition: TRTCalib_makeplots.cxx:1765
file
TFile * file
Definition: tile_monitor.h:29
BoardVariationsTRes1::GetNpoints
int GetNpoints()
Definition: TRTCalib_makeplots.cxx:1461
PixelAthClusterMonAlgCfg.zmax
zmax
Definition: PixelAthClusterMonAlgCfg.py:169
XYMapsEC::XYMapsEC
XYMapsEC(char *, string, bool)
Definition: TRTCalib_makeplots.cxx:2400
TrackTupleInfo::m_Tracktuple
TNtuple * m_Tracktuple
Definition: TRTCalib_makeplots.cxx:3825
FirstPage
Definition: TRTCalib_makeplots.cxx:3529
find_tgc_unfilled_channelids.ip
ip
Definition: find_tgc_unfilled_channelids.py:3
compute_lumi.leg
leg
Definition: compute_lumi.py:95
python.selection.variable
variable
Definition: selection.py:33
hist_file_dump.f
f
Definition: hist_file_dump.py:135
HitStatistics
Definition: TRTCalib_makeplots.cxx:145
ChipVariations
Definition: TRTCalib_makeplots.cxx:741
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
Definition: TRTCalib_makeplots.cxx:6
BoardVariationsOldT0::miny
float miny
Definition: TRTCalib_makeplots.cxx:1144
BoardVariationsOldT0::GetY
double * GetY()
Definition: TRTCalib_makeplots.cxx:1143
RtBinning::RtBinning
RtBinning(TDirectory *, const string &)
Definition: TRTCalib_makeplots.cxx:3301
calibdata.exit
exit
Definition: calibdata.py:236
NHitStack::NHitStack
NHitStack(TNtuple *, TLegend *, bool, int, int)
Definition: TRTCalib_makeplots.cxx:107
DeMoScan.runnumber
runnumber
Definition: DeMoScan.py:266
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
min
#define min(a, b)
Definition: cfImp.cxx:40
BoardVariationsTRes1::GetY
double * GetY()
Definition: TRTCalib_makeplots.cxx:1463
grepfile.ic
int ic
Definition: grepfile.py:33
mergePhysValFiles.errors
list errors
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:43
main
int main(int argc, char *argv[])
Definition: TRTCalib_makeplots.cxx:6872
GetPWidth
TGraphErrors * GetPWidth(TH2F *histo)
Definition: TRTCalib_makeplots.cxx:4042
do_expert
bool do_expert
Definition: TRTCalib_makeplots.cxx:45
Monitored::Y
@ Y
Definition: HistogramFillerUtils.h:24
pdg_comparison.markersize
markersize
Definition: pdg_comparison.py:375
T0CalibTypeXY
Definition: TRTCalib_makeplots.cxx:662
SettingsInfo
Definition: TRTCalib_makeplots.cxx:3766
BoardVariationsTRes::GetY
double * GetY()
Definition: TRTCalib_makeplots.cxx:1638
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
SinDependence
Definition: TRTCalib_makeplots.cxx:4877
DvGraph
Definition: TRTCalib_makeplots.cxx:1798
tt_remove
int tt_remove(int, char *argv[])
Definition: TRTCalib_makeplots.cxx:6849
BoardVariations::GetNpoints
int GetNpoints()
Definition: TRTCalib_makeplots.cxx:866
BoardVariationsRes::GetY
double * GetY()
Definition: TRTCalib_makeplots.cxx:1299
TBDependence
Definition: TRTCalib_makeplots.cxx:4289
RresTbin::m_tdata
std::vector< double > m_tdata
Definition: TRTCalib_makeplots.cxx:3335
T0CalTypeXY
Definition: TRTCalib_makeplots.cxx:560
ToTDependence::ToTDependence
ToTDependence(TFile *, bool, bool, bool isAr)
Definition: TRTCalib_makeplots.cxx:4599
gErrorIgnoreLevel
int gErrorIgnoreLevel
BoardVariations::GetX
double * GetX()
Definition: TRTCalib_makeplots.cxx:867
BoardVariationsRes::GetX
double * GetX()
Definition: TRTCalib_makeplots.cxx:1298
TextPage::TextPage
TextPage(const string &)
Definition: TRTCalib_makeplots.cxx:90
RresTbin::RresTbin
RresTbin(TFile *, const string &, int)
Definition: TRTCalib_makeplots.cxx:3339
Rtt_histogram.n1
n1
Definition: Rtt_histogram.py:21
PtDependence
Definition: TRTCalib_makeplots.cxx:4076
BoardVariationsTRes1
Definition: TRTCalib_makeplots.cxx:1457
TBDependence::TBDependence
TBDependence(TFile *)
Definition: TRTCalib_makeplots.cxx:4297
dqt_zlumi_display_z_rate.gr2
gr2
Definition: dqt_zlumi_display_z_rate.py:81
TrackTupleInfo
Definition: TRTCalib_makeplots.cxx:3820
y
#define y
TBinnedRes::TBinnedRes
TBinnedRes(TFile *, vector< TH1D * >)
Definition: TRTCalib_makeplots.cxx:3269
BoardVariationsDiff
Definition: TRTCalib_makeplots.cxx:1029
BoardVariationsTRes1::miny
float miny
Definition: TRTCalib_makeplots.cxx:1464
BoardVariations::BoardVariations
BoardVariations(char *, int)
Definition: TRTCalib_makeplots.cxx:872
DGraph
Definition: TRTCalib_makeplots.cxx:1927
BoardVariationsDiff::miny
float miny
Definition: TRTCalib_makeplots.cxx:1036
FullCPAlgorithmsTest_CA.inputfile
dictionary inputfile
Definition: FullCPAlgorithmsTest_CA.py:59
makeTRTBarrelCans.dx
tuple dx
Definition: makeTRTBarrelCans.py:20
itersum
int itersum(int argc, char *argv[])
Definition: TRTCalib_makeplots.cxx:5113
SettingsInfo::set
map< string, string > set
Definition: TRTCalib_makeplots.cxx:3769
beamspotnt.rms
rms
Definition: bin/beamspotnt.py:1266
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
hmax
double hmax(TH1 *&h)
Definition: listroot.cxx:115
CaloCondBlobAlgs_fillNoiseFromASCII.folder
folder
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:56
calibdata.cd
cd
Definition: calibdata.py:51
makeTransCanvas.text
text
Definition: makeTransCanvas.py:11
TrackTupleInfo::TrackTupleInfo
TrackTupleInfo(TFile *)
Definition: TRTCalib_makeplots.cxx:3828
T0CalTypeXY::T0CalTypeXY
T0CalTypeXY(TNtuple *, int, float)
Definition: TRTCalib_makeplots.cxx:568
BoardVariations::DrawLines
void DrawLines()
Definition: TRTCalib_makeplots.cxx:1003
jobOptions.prec
prec
Definition: jobOptions.Superchic_UPC_yyMuMu.py:20
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
RtGraphs::RtGraphs
RtGraphs(char *, const string &, bool)
Definition: TRTCalib_makeplots.cxx:2063
NHitStack
Definition: TRTCalib_makeplots.cxx:102
BoardVariationsTRes::miny
float miny
Definition: TRTCalib_makeplots.cxx:1639
ChipVariations::DrawLines
void DrawLines(float, float)
Definition: TRTCalib_makeplots.cxx:831
TRTCalib_cfilter.p3
p3
Definition: TRTCalib_cfilter.py:132
RtColor::RtColor
RtColor(char *, const string &, bool)
Definition: TRTCalib_makeplots.cxx:2715
hotSpotInTAG.nb
nb
Definition: hotSpotInTAG.py:164
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415
checker_macros.h
Define macros for attributes used to control the static checker.
BoardVariations
Definition: TRTCalib_makeplots.cxx:862
RresTbin::m_rdata
std::vector< double > m_rdata
Definition: TRTCalib_makeplots.cxx:3333
BoardVariationsRes
Definition: TRTCalib_makeplots.cxx:1293
BoardVariationsOldT0::GetX
double * GetX()
Definition: TRTCalib_makeplots.cxx:1142
BoardVariationsTRes::GetNpoints
int GetNpoints()
Definition: TRTCalib_makeplots.cxx:1636
RtBinning
Definition: TRTCalib_makeplots.cxx:3293
readCCLHist.float
float
Definition: readCCLHist.py:83
SettingsInfo::SettingsInfo
SettingsInfo(char *)
Definition: TRTCalib_makeplots.cxx:3774
BoardVariationsDiff::DrawLines
void DrawLines()
Definition: TRTCalib_makeplots.cxx:1111
SetZAxis
void SetZAxis(TH2F *reshist0)
Definition: TRTCalib_makeplots.cxx:49
DvGraph::DvGraph
DvGraph(char *, string, const string &, int, int, bool)
Definition: TRTCalib_makeplots.cxx:1805
detlet
char detlet[3]
Definition: TRTCalib_makeplots.cxx:47
TRTCalib_cfilter.p0
p0
Definition: TRTCalib_cfilter.py:129
BoardVariationsTRes1::DrawLines
void DrawLines()
Definition: TRTCalib_makeplots.cxx:1598
BoardVariationsOldT0
Definition: TRTCalib_makeplots.cxx:1137
FirstPage::FirstPage
FirstPage(char *, TFile *)
Definition: TRTCalib_makeplots.cxx:3538
ResidualPlots::ResidualPlots
ResidualPlots(TFile *, bool)
Definition: TRTCalib_makeplots.cxx:2940
BoardVariationsOldT0::BoardVariationsOldT0
BoardVariationsOldT0(char *, int)
Definition: TRTCalib_makeplots.cxx:1147
XYMapsEC
Definition: TRTCalib_makeplots.cxx:2395
T0CalibTypeXY::T0CalibTypeXY
T0CalibTypeXY(char *, bool)
Definition: TRTCalib_makeplots.cxx:667