ATLAS Offline Software
Loading...
Searching...
No Matches
TRTCalib_makeplots.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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>
43using namespace std;
44
45bool do_expert = false;
46
47char detlet[3] = {'C', '-', 'A'};
48
49void 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){
60 zmax = std::max(temp,zmax);
61 zmin = std::min(temp,zmin);
62 }
63 }
64 }
65 reshist0->GetZaxis()->SetRangeUser(zmin, zmax);
66}
67
68void 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
76string 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
84class TextPage : public TCanvas
85{
86public:
87 TextPage(const string&);
88};
89
90TextPage::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
101class NHitStack : public THStack
102{
103public:
104 NHitStack(TNtuple *, TLegend *, bool, int, int);
105};
106
107NHitStack::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
144class HitStatistics : public TCanvas
145{
146public:
147 HitStatistics(char *, bool);
148};
149
150HitStatistics::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
279class XYMaps : public TCanvas
280{
281public:
282 XYMaps(char *, string, bool);
283};
284
285XYMaps::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{
561public:
562 T0CalTypeXY(TNtuple *, int, float);
563 void Draw(const string &, bool);
564 TGraph* graph[7]{};
565 TEventList* elist[7]{};
566};
567
568T0CalTypeXY::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
617void 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
661class T0CalibTypeXY : public TCanvas
662{
663public:
664 T0CalibTypeXY(char *, bool);
665};
666
667T0CalibTypeXY::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
740class ChipVariations : public TProfile
741{
742public:
743 ChipVariations(char *, int);
744 void DrawLines(float, float);
745};
746
747ChipVariations::ChipVariations(char *infile, int detector)
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
831void 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
861class BoardVariations : public TGraphErrors
862{
863public:
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
1028class BoardVariationsDiff : public TGraphErrors
1029{
1030public:
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
1039BoardVariationsDiff::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
1136class BoardVariationsOldT0 : public TGraph
1137{
1138public:
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
1292class BoardVariationsRes : public TGraphErrors
1293{
1294public:
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
1456class BoardVariationsTRes1 : public TGraphErrors
1457{
1458public:
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
1631class BoardVariationsTRes : public TGraphErrors
1632{
1633public:
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
1797class DvGraph : public TGraph
1798{
1799public:
1800 DvGraph(char *, string, const string &, int, int, bool);
1801 // TH1F* hist;
1802 TGraph *rtgraph;
1803};
1804
1805DvGraph::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 const bool isdines = false; //hardcoded flag
1871
1872 if (isdines)
1873 {
1874 //coverity[dead_error_begin]
1875 string vrrelation;
1876 if (isinverted)
1877 vrrelation = "x*[2]/sqrt([0]*[0]+x*x)";
1878 else
1879 vrrelation = "sqrt([0]*[0]+x*x)/(x*[2])";
1880
1881 TF1 *vr1 = new TF1("vr-relation", vrrelation.c_str(), 0.0001, 2.0);
1882 vr1->SetParameters(p0, p1, p2);
1883
1884 for (int i = 0; i <= 100; i++)
1885 {
1886 float r = 0.1 + (2.0 - 0.1) * (float)i / 100;
1887 float v1 = vr1->Eval(r, 0, 0, 0);
1888 this->SetPoint(i, r, v1);
1889 // cout << i << " " << r << " " << v1 << endl;
1890 }
1891
1892 vr1->Delete();
1893 }
1894 else
1895 {
1896 cout << " USING POLYNOMIAL R-t RELATION" << endl;
1897
1898 string rtrelation = "[0]+x*([1]+x*([2]+x*[3]))";
1899 string vtrelation;
1900 if (isinverted)
1901 vtrelation = "1/([0]+2*x*[1]+3*x*x*[2])";
1902 else
1903 vtrelation = "[0]+2*x*[1]+3*x*x*[2]";
1904
1905 TF1 *rt1 = new TF1("rt-relation", rtrelation.c_str(), -10000, 10000);
1906 rt1->SetParameters(p0, p1, p2, p3);
1907 TF1 *vt1 = new TF1("vt-relation", vtrelation.c_str(), -10000, 10000);
1908 vt1->SetParameters(p1, p2, p3);
1909
1910 for (int i = 0; i <= 100; i++)
1911 {
1912 float r = 0.1 + (2.0 - 0.1) * (float)i / 100;
1913 float t1 = rt1->GetX(r, -10000, 10000);
1914 float v1 = vt1->Eval(t1, 0, 0, 0);
1915 this->SetPoint(i, r, v1);
1916 // cout << i << " " << r << " " << t1 << " " << v1 << endl;
1917 }
1918
1919 rt1->Delete();
1920 vt1->Delete();
1921 }
1922 }
1923}
1924
1925//================================================================
1926
1927class DGraph : public TGraph
1928{
1929public:
1930 DGraph(char *, string, const string&, int, int, bool);
1931 // TH1F* hist;
1932 TGraph *rtgraph;
1933};
1934
1935DGraph::DGraph(char *infile, string path, const string& folder, int det, int lay, bool isinverted)
1936{
1937
1938 this->SetName(Form("Dv_%i_%i", det, lay));
1939
1940 vector<string> levels;
1941 while (true)
1942 {
1943 if (const auto f = path.find(','); f==std::string::npos ){
1944 break;
1945 } else {
1946 levels.push_back(path.substr(0, f));
1947 path.erase(0, f+1);
1948 }
1949 }
1950 levels.push_back(path.substr(0, path.find(',')));
1951
1952 TFile *file = new TFile(infile);
1953 file->cd();
1954
1955 cout << " In DGraph. Folder: " << folder << " det " << det << " lay " << lay << endl;
1956 for (unsigned int i = 0; i < levels.size(); i++)
1957 cout << " " << levels.at(i);
1958 cout << endl;
1959 cout << " infile:" << string(infile) << endl;
1960
1961 TDirectory *trt = (TDirectory *)file->FindKey("TRT_all")->ReadObj();
1962 if (folder != "")
1963 {
1964 TDirectory *thisDet = (TDirectory *)trt->FindKey(folder.c_str())->ReadObj();
1965 cout << "PLOT FOR " << folder << endl;
1966 if (thisDet->FindKey("rtgraph"))
1967 {
1968 rtgraph = (TGraphErrors *)thisDet->FindKey("rtgraph")->ReadObj();
1969 cout << " folder: " << folder << " found rtgraph " << endl;
1970 }
1971 else
1972 {
1973 rtgraph = nullptr;
1974 cout << " folder: " << folder << " did not find rtgraph " << endl;
1975 }
1976 }
1977 else if (trt->FindKey("rtgraph"))
1978 {
1979 rtgraph = (TGraphErrors *)trt->FindKey("rtgraph")->ReadObj();
1980 cout << " no folder, found rtgraph " << endl;
1981 }
1982 else
1983 {
1984 rtgraph = nullptr;
1985 cout << " no folder, no rtgraph " << endl;
1986 }
1987
1988 if (rtgraph)
1989 {
1990 TF1 *rtfunc = (TF1 *)rtgraph->GetListOfFunctions()->First();
1991
1992 double p0 = rtfunc->GetParameter(0);
1993 double p1 = rtfunc->GetParameter(1);
1994 double p2 = rtfunc->GetParameter(2);
1995 double p3 = rtfunc->GetParameter(3);
1996
1997 cout << " R-t PARAMETERS: " << p0 << " " << p1 << " " << p2 << " " << p3 << endl;
1998
1999 const bool isdines = false; //hardcoded flag
2000
2001 if (isdines)
2002 {
2003 //coverity[dead_error_begin]
2004 string vrrelation;
2005 if (isinverted)
2006 vrrelation = "x*[2]/sqrt([0]*[0]+x*x)";
2007 else
2008 vrrelation = "sqrt([0]*[0]+x*x)/(x*[2])";
2009
2010 TF1 *vr1 = new TF1("vr-relation", vrrelation.c_str(), 0.0001, 2.0);
2011 vr1->SetParameters(p0, p1, p2);
2012
2013 for (int i = 0; i <= 100; i++)
2014 {
2015 float r = 0.1 + (2.0 - 0.1) * (float)i / 100;
2016 float v1 = vr1->Eval(r, 0, 0, 0);
2017 this->SetPoint(i, r, v1);
2018 }
2019
2020 vr1->Delete();
2021 }
2022 else
2023 {
2024 cout << " USING POLYNOMIAL R-t RELATION" << endl;
2025
2026 string rtrelation = "[0]+x*([1]+x*([2]+x*[3]))";
2027 string vtrelation;
2028 if (isinverted)
2029 vtrelation = "1/([0]+2*x*[1]+3*x*x*[2])";
2030 else
2031 vtrelation = "[0]+2*x*[1]+3*x*x*[2]";
2032
2033 TF1 *rt1 = new TF1("rt-relation", rtrelation.c_str(), -10000, 10000);
2034 rt1->SetParameters(p0, p1, p2, p3);
2035 TF1 *vt1 = new TF1("vt-relation", vtrelation.c_str(), -10000, 10000);
2036 vt1->SetParameters(p1, p2, p3);
2037
2038 for (int i = 0; i <= 1000; i++)
2039 {
2040 float t1 = -5 + i * 0.05;
2041 float r1 = rt1->Eval(t1, 0, 0, 0);
2042 this->SetPoint(i, t1, r1);
2043 }
2044
2045 rt1->Delete();
2046 vt1->Delete();
2047 }
2048 }
2049}
2050
2051//================================================================
2052
2053class RtGraphs : public TCanvas
2054{
2055public:
2056 // RtGraphs(char*,int,int);
2057 RtGraphs(char *, const string& , bool);
2058 TH2F *rthist{};
2059 TGraphErrors *rtgraph{};
2060 TGraphErrors *trgraph{};
2062};
2063
2064RtGraphs::RtGraphs(char *infile, const string & folder, bool isAr = false)
2065{
2066
2067 this->SetName(Form("Rt_%s", folder.c_str()));
2068
2069 TFile *file = new TFile(infile);
2070 cout << "in RtGraphs. Infile: " << string(infile) << endl;
2071 file->cd();
2072 TDirectory *trt = nullptr;
2073
2074 map<string, string> titlemap;
2075 if (!isAr)
2076 {
2077
2078 trt = (TDirectory *)file->FindKey("TRT_all")->ReadObj();
2079 titlemap["WholeBarrel_1"] = "whole barrel";
2080 titlemap["Detector_-1"] = "barrel C";
2081 titlemap["Detector_1"] = "barrel A";
2082 titlemap["Detector_-2"] = "end-cap C";
2083 titlemap["Detector_2"] = "end-cap A";
2084 if (trt)
2085 cout << " Xenon. Found TRT_all " << endl;
2086 if (!trt)
2087 cout << " Xenon. Did not find TRT_all " << endl;
2088 }
2089
2090 else
2091 {
2092
2093 trt = (TDirectory *)file->FindKey("TRT_Ar_all")->ReadObj();
2094 titlemap["WholeBarrel_Ar_1"] = "whole Ar barrel";
2095 titlemap["Detector_Ar_-1"] = "barrel Ar C";
2096 titlemap["Detector_Ar_1"] = "barrel Ar A";
2097 titlemap["Detector_Ar_-2"] = "end-cap Ar C";
2098 titlemap["Detector_Ar_2"] = "end-cap Ar A";
2099 if (trt)
2100 cout << " Argon. Found TRT_Ar_all " << endl;
2101 if (!trt)
2102 cout << " Argon. Did not find TRT_Ar_all " << endl;
2103 }
2104
2105 if (trt and (not folder.empty()))
2106 {
2107 cout << " PLOT FOR " << folder << endl;
2108 TDirectory *det = (TDirectory *)trt->FindKey(folder.c_str())->ReadObj();
2109 if (det->FindKey("rt-relation"))
2110 {
2111 cout << " found rt-relation " << endl;
2112 rthist = (TH2F *)det->FindKey("rt-relation")->ReadObj();
2113 this->cd();
2114 rthist->GetXaxis()->SetRangeUser(0, 40);
2115 char name[500];
2116 sprintf(name, "rt (%s)", titlemap[folder].c_str());
2117 rthist->SetTitle(name);
2118 if (det->FindKey("rtgraph"))
2119 {
2120 rtgraph = (TGraphErrors *)det->FindKey("rtgraph")->ReadObj();
2121 cout << " found also rtgraph " << endl;
2122 }
2123 else
2124 {
2125 rtgraph = nullptr;
2126 cout << " did not found rtgraph " << endl;
2127 }
2128 if (det->FindKey("trgraph"))
2129 {
2130 trgraph = (TGraphErrors *)det->FindKey("trgraph")->ReadObj();
2131 cout << " found also trgraph " << endl;
2132 }
2133 else
2134 {
2135 trgraph = nullptr;
2136 cout << " did not found trgraph " << endl;
2137 }
2138 if (det->FindKey("oldrtfunc"))
2139 {
2140 oldrtfunc = (TF1 *)det->FindKey("oldrtfunc")->ReadObj();
2141 cout << " found also oldrtfunc " << endl;
2142 }
2143 else
2144 {
2145 oldrtfunc = nullptr;
2146 cout << " did not find oldrtfunc " << endl;
2147 }
2148 }
2149 else
2150 {
2151 throw string(" NO RT OBJECTS FOUND");
2152 }
2153 }
2154 else if (trt and trt->FindKey("rt-relation"))
2155 {
2156 cout << " No folder. Found rt-relation. PLOT FOR TRT" << endl;
2157 rthist = (TH2F *)trt->FindKey("rt-relation")->ReadObj();
2158 this->cd();
2159 rthist->GetXaxis()->SetRangeUser(0, 40);
2160 rthist->SetTitle("r(t) for whole TRT");
2161 if (trt->FindKey("rtgraph"))
2162 {
2163 rtgraph = (TGraphErrors *)trt->FindKey("rtgraph")->ReadObj();
2164 cout << " found also rtgraph " << endl;
2165 }
2166 else
2167 {
2168 rtgraph = nullptr;
2169 cout << " did not find rtgraph " << endl;
2170 }
2171 if (trt->FindKey("trgraph"))
2172 {
2173 trgraph = (TGraphErrors *)trt->FindKey("trgraph")->ReadObj();
2174 cout << " found also trgraph " << endl;
2175 }
2176 else
2177 {
2178 trgraph = nullptr;
2179 cout << " did not find trgraph " << endl;
2180 }
2181 if (trt->FindKey("oldrtfunc"))
2182 {
2183 oldrtfunc = (TF1 *)trt->FindKey("oldrtfunc")->ReadObj();
2184 cout << " found also oldtrtfunc " << endl;
2185 }
2186 else
2187 {
2188 oldrtfunc = nullptr;
2189 cout << " did not find oldtrtfunc " << endl;
2190 }
2191 }
2192 else
2193 {
2194 cout << " No folder. No rt-relation." << endl;
2195 rthist = nullptr;
2196 rtgraph = nullptr;
2197 oldrtfunc = nullptr;
2198 }
2199
2200 this->cd();
2201 this->Divide(2, 1, 0.01, 0.01);
2202 this->cd(1);
2203
2204 TPad *c1_3 = new TPad("c1_3", "newpad", 0.01, 0.33, 0.99, 0.99);
2205 c1_3->Draw();
2206 c1_3->cd();
2207 c1_3->SetTopMargin(0.1);
2208 c1_3->SetBottomMargin(0.01);
2209 c1_3->SetRightMargin(0.1);
2210 c1_3->SetFillStyle(0);
2211 c1_3->SetGrid();
2212
2213 if (rtgraph)
2214 {
2215 if (folder == "")
2216 {
2217 cout << " found rtgraph for entire TRT " << endl;
2218 rtgraph->SetTitle("r(t) fit (whole TRT)");
2219 }
2220 else
2221 {
2222 cout << " found rtgraph for folder: " << folder << endl;
2223 rtgraph->SetTitle(titlemap[folder].c_str());
2224 }
2225 cout << " set rtgraph X title t-T0/ns and Y title |r|_{track}/mm" << endl;
2226
2227 rtgraph->GetXaxis()->SetTitle("t-T0/ns");
2228 rtgraph->GetYaxis()->SetTitle("|r|_{track}/mm");
2229 // rtgraph->GetYaxis()->SetRangeUser(0,2.7);
2230 rtgraph->GetXaxis()->SetTitleSize(0.06);
2231 rtgraph->GetXaxis()->SetLabelSize(0.06);
2232
2233 // Blue line too wide, extract and plot again:
2234 rtgraph->SetMarkerStyle(20);
2235 rtgraph->SetMarkerSize(0.5);
2236 rtgraph->GetYaxis()->SetRangeUser(-0.05, 2.6);
2237 cout << " Draw rtgraph " << endl;
2238 rtgraph->Draw("ap");
2239 TF1 *newRT;
2240 if (rtgraph->GetFunction("rtfunc"))
2241 newRT = rtgraph->GetFunction("rtfunc");
2242 else
2243 newRT = rtgraph->GetFunction("rtfunc2");
2244 if (newRT)
2245 {
2246 cout << " Draw new fit " << endl;
2247 newRT->SetLineWidth(1);
2248 newRT->Draw("same");
2249 }
2250 if (oldrtfunc)
2251 {
2252 oldrtfunc->SetLineColor(1);
2253 oldrtfunc->SetLineWidth(1);
2254 oldrtfunc->SetLineStyle(2);
2255 cout << " Draw old fit " << endl;
2256 oldrtfunc->Draw("same");
2257 }
2258 // Legend
2259
2260 TLegend *leg = new TLegend(0.7155172, 0.1038136, 0.8965517, 0.2542373, nullptr, "brNDC");
2261 leg->AddEntry(rtgraph, "Data", "p");
2262 leg->AddEntry(newRT, "Fit", "l");
2263 leg->AddEntry(oldrtfunc, "Fit old rt", "l");
2264 leg->SetTextSize(0.03);
2265 leg->Draw();
2266
2267 // Plot the difference between old and new rt:
2268 if (oldrtfunc && newRT)
2269 {
2270 this->cd();
2271 this->cd(1);
2272 TPad *c1_4 = new TPad("c1_4", "newpad", 0.01, 0, 0.99, 0.32);
2273 c1_4->Draw();
2274 c1_4->cd();
2275 c1_4->SetTopMargin(0.01);
2276 c1_4->SetBottomMargin(0.3);
2277 c1_4->SetRightMargin(0.1);
2278 c1_4->SetFillStyle(0);
2279 c1_4->SetGrid();
2280
2281 Double_t Xmax = rtgraph->GetXaxis()->GetXmax();
2282 Double_t Xmin = rtgraph->GetXaxis()->GetXmin();
2283
2284 const Int_t n = 300;
2285 Double_t x[n], y[n], dx;
2286 dx = (Xmax - Xmin) / n;
2287
2288 Double_t Ymax = -10;
2289 Double_t Ymin = 10;
2290
2291 for (Int_t i = 0; i < n; i++)
2292 {
2293 x[i] = Xmin + i * dx;
2294 y[i] = (oldrtfunc->Eval(x[i]) - newRT->Eval(x[i]));
2295 if (y[i] > Ymax)
2296 Ymax = y[i];
2297 if (y[i] < Ymin)
2298 Ymin = y[i];
2299 }
2300
2301 TGraph *gr1 = new TGraph(n, x, y);
2302
2303 gr1->SetTitle("");
2304 gr1->GetXaxis()->SetTitle("t-T0/ns");
2305 gr1->GetXaxis()->SetRangeUser(Xmin, Xmax);
2306 gr1->GetYaxis()->SetTitle("Old r(t) - New r(t) /mm");
2307 gr1->GetYaxis()->SetRangeUser(-0.1, 0.1);
2308 // gr1->GetYaxis()->SetRangeUser(1.1*Ymin,1.1*Ymax);
2309 gr1->GetYaxis()->SetNdivisions(5);
2310 gr1->GetXaxis()->SetTitleSize(0.06);
2311 gr1->GetXaxis()->SetLabelSize(0.06);
2312 gr1->GetYaxis()->SetLabelSize(0.08);
2313 gr1->GetYaxis()->SetTitleOffset(0.8);
2314 gr1->GetYaxis()->SetTitleSize(0.06);
2315 gr1->SetLineStyle(2);
2316
2317 // Also add the difference between the fit and the points of the fit
2318
2319 const Int_t n1 = rtgraph->GetN();
2320 std::vector<Double_t> x1(n1, 0), y1(n1, 0), ex1(n1, 0), ey1(n1, 0);
2321 Double_t X, Y;
2322
2323 for (Int_t i = 0; i < n1; i++)
2324 {
2325 X = 0;
2326 Y = 0;
2327 rtgraph->GetPoint(i, X, Y);
2328 x1.at(i) = X;
2329 y1.at(i) = Y - newRT->Eval(X);
2330 ex1.at(i) = 0;
2331 ey1.at(i) = rtgraph->GetErrorY(i);
2332 if (y1.at(i) > Ymax)
2333 {
2334 Ymax = y1.at(i);
2335 }
2336 if (y1.at(i) < Ymin)
2337 {
2338 Ymin = y1.at(i);
2339 }
2340 }
2341
2342 TGraphErrors *gr2 = new TGraphErrors(n1, &x1.at(0), &y1.at(0), &ex1.at(0), &ey1.at(0));
2343 gr2->SetMarkerColor(2);
2344 gr2->SetMarkerStyle(20);
2345 gr2->SetTitle("");
2346 gr2->GetYaxis()->SetTitle("Old r(t) - New r(t) /mm");
2347
2348 gr2->GetYaxis()->SetRangeUser(-0.2, 0.2);
2349 gr2->GetXaxis()->SetRangeUser(-5, 50);
2350 cout << " Draw difference " << endl;
2351 gr2->Draw("ap");
2352 gr1->Draw("l");
2353
2354 TLine *line0 = new TLine(Xmin, 0, Xmax, 0);
2355 line0->SetLineColor(4);
2356 line0->Draw();
2357 }
2358 }
2359 else
2360 {
2361 cout << " nullptr rtgraph " << endl;
2362 }
2363
2364 this->cd(2);
2365 if (trgraph)
2366 {
2367
2368 if (folder == "")
2369 trgraph->SetTitle("t(r) fit (whole TRT)");
2370 else
2371 {
2372 char name[500];
2373 //don't move 'folder'; it is passed by const ref
2374 sprintf(name, "t(r) fit (%s)", titlemap[string(folder)].c_str());
2375 trgraph->SetTitle(name);
2376 }
2377
2378 trgraph->GetYaxis()->SetTitle("t-T0/ns");
2379 trgraph->GetXaxis()->SetTitle("|r|_{track}/mm");
2380 // trgraph->GetYaxis()->SetRangeUser(0,32);
2381 trgraph->SetMarkerStyle(20);
2382 trgraph->SetMarkerSize(0.5);
2383 cout << " Draw trgraph " << endl;
2384 trgraph->Draw("ap");
2385 }
2386 else
2387 {
2388 cout << " nullptr trgraph " << endl;
2389 }
2390
2391 gStyle->SetOptStat(1);
2392}
2393
2394//=================================================================
2395
2396class XYMapsEC : public TCanvas
2397{
2398public:
2399 XYMapsEC(char *, string, bool);
2400};
2401
2402XYMapsEC::XYMapsEC(char *infile, string variable, bool isAr = false)
2403{
2404
2405 char selectionA[500];
2406 sprintf(selectionA, "%s*(det==2)", variable.c_str());
2407 char selectionC[500];
2408 sprintf(selectionC, "%s*(det==-2)", variable.c_str());
2409 if (variable == "nt0")
2410 variable = "n hits";
2411 TFile *file = new TFile(infile);
2412 // cout << infile << endl;
2413 file->cd();
2414 TNtuple *Chiptuple = nullptr;
2415 TNtuple *Moduletuple = nullptr;
2416
2417 if (!isAr)
2418 {
2419 Chiptuple = (TNtuple *)file->Get("Chiptuple");
2420 Moduletuple = (TNtuple *)file->Get("Moduletuple");
2421 }
2422 else
2423 {
2424 Chiptuple = (TNtuple *)file->Get("Chip_Artuple");
2425 Moduletuple = (TNtuple *)file->Get("Module_Artuple");
2426 }
2427
2428 this->SetName("c1");
2429 this->cd();
2430 this->Divide(2, 2, 0.01, 0.01);
2431 ((TPad *)this->GetPrimitive("c1_1"))->SetFrameFillColor(1);
2432 ((TPad *)this->GetPrimitive("c1_2"))->SetFrameFillColor(1);
2433 ((TPad *)this->GetPrimitive("c1_3"))->SetFrameFillColor(1);
2434 ((TPad *)this->GetPrimitive("c1_4"))->SetFrameFillColor(1);
2435
2436 gStyle->SetPalette(1);
2437
2438 this->cd(1);
2439
2440 Moduletuple->Draw("mod:lay>>reshist10(14,0,14,32,0,32)", selectionA, "colz");
2441 TH2F *reshist10 = (TH2F *)gPad->GetPrimitive("reshist10");
2442 this->Update();
2443 if (reshist10->GetEntries() > 1)
2444 ResizePalette(reshist10);
2445 SetZAxis(reshist10);
2446 char title1[500];
2447 sprintf(title1, "Phi Sector VS Wheel %s (EC side A)", variable.c_str());
2448 if (isAr)
2449 sprintf(title1, "Argon Phi Sector VS Wheel %s (EC side A)", variable.c_str());
2450 reshist10->SetTitle(title1);
2451 reshist10->SetStats(0);
2452 reshist10->GetXaxis()->SetLabelOffset(1000);
2453 reshist10->GetYaxis()->SetLabelOffset(1000);
2454 reshist10->GetXaxis()->SetTitle("Wheel (Z)");
2455 reshist10->GetYaxis()->SetTitle("Phi sector");
2456 if (variable == "ftype")
2457 {
2458 reshist10->GetZaxis()->SetRangeUser(1, 6);
2459 reshist10->GetZaxis()->SetNdivisions(6);
2460 }
2461 else if (variable == "res")
2462 {
2463 reshist10->GetZaxis()->SetRangeUser(0.10, 0.20);
2464 }
2465 else if (variable == "abs(resMean)")
2466 {
2467 reshist10->GetZaxis()->SetRangeUser(0.0, 0.05);
2468 }
2469 else if (variable == "t0")
2470 {
2471 reshist10->GetZaxis()->SetRangeUser(2, 14);
2472 }
2473 else if (variable == "abs(t0-oldt0)")
2474 {
2475 reshist10->GetZaxis()->SetRangeUser(0.0, 0.6);
2476 }
2477 else if (variable == "tres")
2478 {
2479 reshist10->GetZaxis()->SetRangeUser(2.0, 4.5);
2480 }
2481
2482 this->cd(2);
2483
2484 Chiptuple->Draw("mod:chp>>histC(248,84,332,32,0,32)", selectionA, "colz");
2485 TH2F *histC = (TH2F *)gPad->GetPrimitive("histC");
2486 char title3[500];
2487 sprintf(title3, "Chip %s (EC side A)", variable.c_str());
2488 if (isAr)
2489 sprintf(title3, "Argon Chip %s (EC side A)", variable.c_str());
2490 histC->SetTitle(title3);
2491 this->Update();
2492 if (histC->GetEntries() > 1)
2493 ResizePalette(histC);
2494 SetZAxis(histC);
2495 histC->SetStats(0);
2496 histC->GetXaxis()->SetLabelOffset(1000);
2497 histC->GetYaxis()->SetLabelOffset(1000);
2498 histC->GetXaxis()->SetTitle("Chip number");
2499 histC->GetYaxis()->SetTitle("Phi sector");
2500 if (variable == "ftype")
2501 {
2502 histC->GetZaxis()->SetRangeUser(1, 6);
2503 histC->GetZaxis()->SetNdivisions(6);
2504 }
2505 else if (variable == "res")
2506 {
2507 histC->GetZaxis()->SetRangeUser(0.10, 0.20);
2508 }
2509 else if (variable == "abs(resMean)")
2510 {
2511 histC->GetZaxis()->SetRangeUser(0.0, 0.05);
2512 }
2513 else if (variable == "t0")
2514 {
2515 histC->GetZaxis()->SetRangeUser(2, 14);
2516 }
2517 else if (variable == "abs(t0-oldt0)")
2518 {
2519 histC->GetZaxis()->SetRangeUser(0.0, 0.6);
2520 }
2521 else if (variable == "tres")
2522 { // took out paranthesis
2523 histC->GetZaxis()->SetRangeUser(2.0, 4.5);
2524 }
2525
2526 float lowe = 0;
2527 float upe = 32;
2528
2529 TLine *lin11 = new TLine(84, lowe, 84, upe);
2530 lin11->SetLineStyle(2);
2531 lin11->Draw();
2532 TLine *lin12 = new TLine(107, lowe, 107, upe);
2533 lin12->SetLineStyle(2);
2534 lin12->Draw();
2535 TLine *lin13 = new TLine(131, lowe, 131, upe);
2536 lin13->SetLineStyle(2);
2537 lin13->Draw();
2538 TLine *lin14 = new TLine(155, lowe, 155, upe);
2539 lin14->SetLineStyle(2);
2540 lin14->Draw();
2541 TLine *lin15 = new TLine(179, lowe, 179, upe);
2542 lin15->SetLineStyle(2);
2543 lin15->Draw();
2544 TLine *lin16 = new TLine(203, lowe, 203, upe);
2545 lin16->SetLineStyle(2);
2546 lin16->Draw();
2547 TLine *lin17 = new TLine(227, lowe, 227, upe);
2548 lin17->SetLineStyle(2);
2549 lin17->Draw();
2550 TLine *lin18 = new TLine(239, lowe, 239, upe);
2551 lin18->SetLineStyle(2);
2552 lin18->Draw();
2553 this->Update();
2554
2555 this->cd(3);
2556 Moduletuple->Draw("mod:lay>>reshist11(14,0,14,32,0,32)", selectionC, "colz");
2557 TH2F *reshist11 = (TH2F *)gPad->GetPrimitive("reshist11");
2558 this->Update();
2559 if (reshist11->GetEntries() > 1)
2560 ResizePalette(reshist11);
2561 SetZAxis(reshist11);
2562 char title4[500];
2563 sprintf(title4, "Phi Sector VS Wheel %s (EC side C)", variable.c_str());
2564 if (isAr)
2565 sprintf(title4, "Argon Phi Sector VS Wheel %s (EC side C)", variable.c_str());
2566 reshist11->SetTitle(title4);
2567 reshist11->SetMarkerStyle(21);
2568 reshist11->SetStats(0);
2569 reshist11->GetXaxis()->SetLabelOffset(1000);
2570 reshist11->GetYaxis()->SetLabelOffset(1000);
2571 reshist11->GetXaxis()->SetTitle("Layer (Z)");
2572 reshist11->GetYaxis()->SetTitle("Phi sector");
2573 if (variable == "ftype")
2574 {
2575 reshist11->GetZaxis()->SetRangeUser(1, 6);
2576 reshist11->GetZaxis()->SetNdivisions(6);
2577
2578 TLegend *leg = new TLegend(0.99, 0.35, 0.55, 0.01, "T0 fit type");
2579
2580 TH2F *h1 = new TH2F("h1", "h1 title", 40, 0, 4, 30, -3, 3);
2581 h1->SetMarkerColor(54);
2582 h1->SetMarkerStyle(21);
2583
2584 TH2F *h2 = new TH2F("h2", "h2 title", 40, 0, 4, 30, -3, 3);
2585 h2->SetMarkerColor(4);
2586 h2->SetMarkerStyle(21);
2587
2588 TH2F *h3 = new TH2F("h3", "h3 title", 40, 0, 4, 30, -3, 3);
2589 h3->SetMarkerColor(7);
2590 h3->SetMarkerStyle(21);
2591
2592 TH2F *h4 = new TH2F("h4", "h4 title", 40, 0, 4, 30, -3, 3);
2593 h4->SetMarkerColor(81);
2594 h4->SetMarkerStyle(21);
2595
2596 TH2F *h5 = new TH2F("h5", "h5 title", 40, 0, 4, 30, -3, 3);
2597 h5->SetMarkerColor(kYellow);
2598 h5->SetMarkerStyle(21);
2599
2600 TH2F *h6 = new TH2F("h6", "h6 title", 40, 0, 4, 30, -3, 3);
2601 h6->SetMarkerColor(kRed);
2602 h6->SetMarkerStyle(21);
2603
2604 leg->AddEntry(h1, "1: |mean|>5", "P");
2605 leg->AddEntry(h2, "2: normal fit", "P");
2606 leg->AddEntry(h3, "3: used chip ref", "P");
2607 leg->AddEntry(h4, "4: Low stat", "P");
2608 leg->AddEntry(h5, "5: No T0 Cal", "P");
2609 leg->AddEntry(h6, "6: Wrong fit. Mean used", "P");
2610 leg->SetTextSize(0.04);
2611 leg->Draw();
2612 }
2613 else if (variable == "res")
2614 {
2615 reshist11->GetZaxis()->SetRangeUser(0.1, 0.20);
2616 }
2617 else if (variable == "abs(resMean)")
2618 {
2619 reshist11->GetZaxis()->SetRangeUser(0.0, 0.05);
2620 }
2621 else if (variable == "t0")
2622 {
2623 reshist11->GetZaxis()->SetRangeUser(2, 14);
2624 }
2625 else if (variable == "abs(t0-oldt0)")
2626 {
2627 reshist11->GetZaxis()->SetRangeUser(0.0, 0.6);
2628 }
2629 else if (variable == "tres")
2630 {
2631 reshist11->GetZaxis()->SetRangeUser(2.0, 4.5);
2632 }
2633
2634 this->cd(4);
2635 Chiptuple->Draw("mod:chp>>histC1(248,84,332,32,0,32)", selectionC, "colz");
2636 TH2F *histC1 = (TH2F *)gPad->GetPrimitive("histC1");
2637 char title5[500];
2638 sprintf(title5, "Chip %s (EC side C)", variable.c_str());
2639 if (isAr)
2640 sprintf(title5, "Argon Chip %s (EC side C)", variable.c_str());
2641 histC1->SetTitle(title5);
2642 this->Update();
2643 if (histC1->GetEntries() > 1)
2644 ResizePalette(histC1);
2645 SetZAxis(histC1);
2646 histC1->SetStats(0);
2647 histC1->GetXaxis()->SetLabelOffset(1000);
2648 histC1->GetYaxis()->SetLabelOffset(1000);
2649 histC1->GetXaxis()->SetTitle("Chip number");
2650 histC1->GetYaxis()->SetTitle("Phi sector");
2651 if (variable == "ftype")
2652 {
2653 histC1->GetZaxis()->SetRangeUser(1, 6);
2654 histC1->GetZaxis()->SetNdivisions(6);
2655 }
2656 else if (variable == "res")
2657 {
2658 histC1->GetZaxis()->SetRangeUser(0.10, 0.20);
2659 }
2660 else if (variable == "abs(resMean)")
2661 {
2662 histC1->GetZaxis()->SetRangeUser(0.0, 0.05);
2663 }
2664 else if (variable == "t0")
2665 {
2666 histC1->GetZaxis()->SetRangeUser(2, 14);
2667 }
2668 else if (variable == "abs(t0-oldt0)")
2669 {
2670 histC1->GetZaxis()->SetRangeUser(0.0, 0.6);
2671 }
2672 else if (variable == "tres")
2673 { // took out parenthesis
2674 histC1->GetZaxis()->SetRangeUser(2.0, 4.5);
2675 }
2676
2677 TLine *lin1 = new TLine(84, lowe, 84, upe);
2678 lin1->SetLineStyle(2);
2679 lin1->Draw();
2680 TLine *lin2 = new TLine(108, lowe, 108, upe);
2681 lin2->SetLineStyle(2);
2682 lin2->Draw();
2683 TLine *lin3 = new TLine(132, lowe, 132, upe);
2684 lin3->SetLineStyle(2);
2685 lin3->Draw();
2686 TLine *lin4 = new TLine(156, lowe, 156, upe);
2687 lin4->SetLineStyle(2);
2688 lin4->Draw();
2689 TLine *lin5 = new TLine(180, lowe, 180, upe);
2690 lin5->SetLineStyle(2);
2691 lin5->Draw();
2692 TLine *lin6 = new TLine(204, lowe, 204, upe);
2693 lin6->SetLineStyle(2);
2694 lin6->Draw();
2695 TLine *lin7 = new TLine(228, lowe, 228, upe);
2696 lin7->SetLineStyle(2);
2697 lin7->Draw();
2698 TLine *lin8 = new TLine(240, lowe, 239, upe);
2699 lin8->SetLineStyle(2);
2700 lin8->Draw();
2701
2702 this->Update();
2703}
2704
2705//================================================================
2706
2707class RtColor : public TCanvas
2708{
2709public:
2710 RtColor(char *,const string&, bool);
2711 TH2F *hist{};
2712 TGraphErrors *rtgraph{};
2714 TF1 *newRT{};
2715};
2716
2717RtColor::RtColor(char *infile, const string & folder, bool isAr = false)
2718{
2719
2720 map<string, string> titlemap;
2721 titlemap["WholeBarrel_1"] = "whole barrel";
2722 titlemap["Detector_-1"] = "barrel C";
2723 titlemap["Detector_1"] = "barrel A";
2724 titlemap["Detector_-2"] = "end-cap C";
2725 titlemap["Detector_2"] = "end-cap A";
2726
2727 titlemap["WholeBarrel_Ar_1"] = "whole barrel";
2728 titlemap["Detector_Ar_-1"] = "barrel C";
2729 titlemap["Detector_Ar_1"] = "barrel A";
2730 titlemap["Detector_Ar_-2"] = "end-cap C";
2731 titlemap["Detector_Ar-2"] = "end-cap A";
2732
2733 TFile *file = new TFile(infile);
2734 // cout << infile << endl;
2735
2736 TPad *c1_3 = new TPad("c1_3", "newpad", 0.01, 0.33, 0.99, 0.99);
2737 c1_3->Draw();
2738 c1_3->cd();
2739 c1_3->SetTopMargin(0.1);
2740 c1_3->SetBottomMargin(0.01);
2741 c1_3->SetRightMargin(0.1);
2742 c1_3->SetFillStyle(0);
2743 c1_3->SetGrid();
2744
2745 file->cd();
2746
2747 TDirectory *trt = nullptr;
2748 if (!isAr)
2749 trt = (TDirectory *)file->FindKey("TRT_all")->ReadObj();
2750 else
2751 trt = (TDirectory *)file->FindKey("TRT_Ar_all")->ReadObj();
2752
2753 if (folder != "")
2754 {
2755 TDirectory *det = (TDirectory *)trt->FindKey(folder.c_str())->ReadObj();
2756 cout << " RtColor plot for folder" << folder << endl;
2757 if (det->FindKey("rt-relation"))
2758 {
2759 hist = (TH2F *)det->FindKey("rt-relation")->ReadObj();
2760 // this->cd();
2761 if (hist)
2762 {
2763 cout << " found rt-relation " << endl;
2764 hist->GetXaxis()->SetRangeUser(0, 40);
2765 hist->GetYaxis()->SetRangeUser(0, 2.4);
2766 char name[500];
2767 sprintf(name, "r(t) for %s", folder.c_str());
2768 if (isAr)
2769 sprintf(name, "Argon r(t) for %s", folder.c_str());
2770 hist->SetTitle(name);
2771 hist->GetXaxis()->SetRangeUser(0, 50);
2772 hist->Draw("colz");
2773
2774 if (det->FindKey("rtgraph"))
2775 {
2776 cout << " found rtgraph " << endl;
2777 rtgraph = (TGraphErrors *)det->FindKey("rtgraph")->ReadObj();
2778 rtgraph->SetMarkerStyle(20);
2779 rtgraph->SetMarkerColor(1);
2780 rtgraph->SetLineColor(1);
2781 rtgraph->GetYaxis()->SetRangeUser(0, 2.4);
2782 rtgraph->Draw("p");
2783 if (rtgraph->GetFunction("rtfunc"))
2784 newRT = rtgraph->GetFunction("rtfunc");
2785 else
2786 newRT = rtgraph->GetFunction("rtfunc2");
2787 }
2788 if (det->FindKey("oldrtfunc"))
2789 {
2790 cout << " found oldrtfunc " << endl;
2791 oldrtfunc = (TF1 *)det->FindKey("oldrtfunc")->ReadObj();
2792 oldrtfunc->SetRange(0, 50);
2793 oldrtfunc->Draw("same");
2794 }
2795 }
2796 }
2797 else
2798 {
2799 throw string(" NO RT OBJECTS FOUND");
2800 }
2801 }
2802 else if (trt->FindKey("rt-relation"))
2803 {
2804 cout << " RtColor Plot entire TRT" << endl;
2805 hist = (TH2F *)trt->FindKey("rt-relation")->ReadObj();
2806 // this->cd();
2807 hist->GetXaxis()->SetRangeUser(0, 40);
2808 hist->SetTitle("r(t) for whole TRT");
2809 if (isAr)
2810 hist->SetTitle("Argon r(t) for whole TRT");
2811 hist->GetYaxis()->SetRangeUser(0, 2.4);
2812 hist->GetXaxis()->SetRangeUser(0, 50);
2813 hist->Draw("colz");
2814 if (trt->FindKey("rtgraph"))
2815 {
2816 rtgraph = (TGraphErrors *)trt->FindKey("rtgraph")->ReadObj();
2817 rtgraph->SetMarkerStyle(20);
2818 rtgraph->SetLineColor(1);
2819 rtgraph->SetMarkerColor(1);
2820 rtgraph->GetYaxis()->SetRangeUser(0, 2.4);
2821 if (rtgraph->GetFunction("rtfunc"))
2822 newRT = rtgraph->GetFunction("rtfunc");
2823 else
2824 newRT = rtgraph->GetFunction("rtfunc2");
2825 rtgraph->Draw("p");
2826 }
2827 if (trt->FindKey("oldrtfunc"))
2828 {
2829 oldrtfunc = (TF1 *)trt->FindKey("oldrtfunc")->ReadObj();
2830 oldrtfunc->SetRange(0, 50);
2831 oldrtfunc->Draw("same");
2832 }
2833 }
2834 else
2835 hist = nullptr;
2836
2837 // Draw the ratio plots just below:
2838
2839 // Plot the difference between old and new rt:
2840 if (oldrtfunc)
2841 {
2842 this->cd();
2843 this->cd(1);
2844 TPad *c1_4 = new TPad("c1_4", "newpad", 0.01, 0, 0.99, 0.32);
2845 c1_4->Draw();
2846 c1_4->cd();
2847 c1_4->SetTopMargin(0.01);
2848 c1_4->SetBottomMargin(0.3);
2849 c1_4->SetRightMargin(0.1);
2850 c1_4->SetFillStyle(0);
2851 c1_4->SetGrid();
2852
2853 Double_t Xmax = rtgraph->GetXaxis()->GetXmax();
2854 Double_t Xmin = rtgraph->GetXaxis()->GetXmin();
2855
2856 const Int_t n = 300;
2857 Double_t x[n], y[n], dx;
2858 dx = (Xmax - Xmin) / n;
2859
2860 Double_t Ymax = -10;
2861 Double_t Ymin = 10;
2862
2863 newRT->SetRange(-10., 60.);
2864 oldrtfunc->SetRange(-10., 60.);
2865
2866 for (Int_t i = 0; i < n; i++)
2867 {
2868 x[i] = Xmin + i * dx;
2869 y[i] = (oldrtfunc->Eval(x[i]) - newRT->Eval(x[i]));
2870 if (y[i] > Ymax)
2871 Ymax = y[i];
2872 if (y[i] < Ymin)
2873 Ymin = y[i];
2874 }
2875
2876 TGraph *gr1 = new TGraph(n, x, y);
2877
2878 // gStyle->SetOptTitle(0);
2879 gr1->SetTitle("");
2880 gr1->GetXaxis()->SetTitle("t-T0/ns");
2881 gr1->GetXaxis()->SetRangeUser(Xmin, Xmax);
2882 gr1->GetYaxis()->SetTitle("Old r(t) - New r(t) /mm");
2883 gr1->GetYaxis()->SetRangeUser(-0.1, 0.1);
2884 // gr1->GetYaxis()->SetRangeUser(1.1*Ymin,1.1*Ymax);
2885 gr1->GetYaxis()->SetNdivisions(5);
2886 gr1->GetXaxis()->SetTitleSize(0.06);
2887 gr1->GetXaxis()->SetLabelSize(0.06);
2888 gr1->GetYaxis()->SetLabelSize(0.08);
2889 gr1->GetYaxis()->SetTitleOffset(0.8);
2890 gr1->GetYaxis()->SetTitleSize(0.06);
2891 gr1->SetLineStyle(2);
2892
2893 // Also add the difference between the fit and the points of the fit
2894
2895 Int_t n1 = rtgraph->GetN();
2896 std::vector<Double_t> x1(n1,0), y1(n1,0), ex1(n1,0), ey1(n1,0);
2897 Double_t X, Y;
2898
2899 for (Int_t i = 0; i < n1; i++)
2900 {
2901 X = 0;
2902 Y = 0;
2903 rtgraph->GetPoint(i, X, Y);
2904 x1.at(i) = X;
2905 y1.at(i) = Y - newRT->Eval(X);
2906 ex1.at(i) = 0;
2907 ey1.at(i) = rtgraph->GetErrorY(i);
2908 if (y1.at(i) > Ymax)
2909 Ymax = y1.at(i);
2910 if (y1.at(i) < Ymin)
2911 Ymin = y1.at(i);
2912 }
2913 // gr1->Draw("APL");
2914
2915 TGraphErrors *gr2 = new TGraphErrors(n1, &x1.at(0), &y1.at(0), &ex1.at(0), &ey1.at(0));
2916 gr2->SetMarkerColor(kBlack);
2917 gr2->SetMarkerStyle(20);
2918 gr2->SetTitle("");
2919 gr2->GetYaxis()->SetTitle("Old r(t) - New r(t) /mm");
2920
2921 // gr2->GetYaxis()->SetRangeUser(1.1*Ymin,1.1*Ymax);
2922 gr2->GetYaxis()->SetRangeUser(-0.1, 0.1);
2923 gr2->GetXaxis()->SetRangeUser(0, 50);
2924
2925 gr2->Draw("ap");
2926 gr1->Draw("l");
2927
2928 TLine *line0 = new TLine(0, 0, 50, 0);
2929 line0->SetLineColor(4);
2930 line0->Draw();
2931 }
2932}
2933
2934//================================================================
2935
2936class ResidualPlots : public TCanvas
2937{
2938public:
2939 ResidualPlots(TFile *, bool);
2940};
2941
2942ResidualPlots::ResidualPlots(TFile *file, bool isAr = false)
2943{
2944
2945 this->SetName("resplots");
2946
2947 file->cd();
2948
2949 TDirectory *trt = nullptr;
2950 TDirectory *det1 = nullptr;
2951 TDirectory *det2 = nullptr;
2952 TDirectory *det3 = nullptr;
2953 TDirectory *det4 = nullptr;
2954
2955 if (!isAr)
2956 {
2957 cout << " In ResidualPlots Xenon" << endl;
2958 trt = (TDirectory *)file->FindKey("TRT_all")->ReadObj();
2959 if (not trt){
2960 throw std::runtime_error("trt pointer is null");
2961 }
2962 det1 = (TDirectory *)trt->FindKey("Detector_-1")->ReadObj();
2963 det2 = (TDirectory *)trt->FindKey("Detector_1")->ReadObj();
2964 det3 = (TDirectory *)trt->FindKey("Detector_-2")->ReadObj();
2965 det4 = (TDirectory *)trt->FindKey("Detector_2")->ReadObj();
2966 }
2967 else
2968 {
2969 if (not trt){
2970 throw std::runtime_error("trt pointer is null");
2971 }
2972 //hardcoded flag, resulting in (intentional) dead code here
2973 //coverity[dead_error_begin]
2974 cout << " In ResidualPlots Argon" << endl;
2975 if (file->FindKey("TRT_Ar_all"))
2976 trt = (TDirectory *)file->FindKey("TRT_Ar_all")->ReadObj();
2977 if (trt->FindKey("Detector_Ar_-1"))
2978 det1 = (TDirectory *)trt->FindKey("Detector_Ar_-1")->ReadObj();
2979 if (trt->FindKey("Detector_Ar_1"))
2980 det2 = (TDirectory *)trt->FindKey("Detector_Ar_1")->ReadObj();
2981 if (trt->FindKey("Detector_Ar_-2"))
2982 det3 = (TDirectory *)trt->FindKey("Detector_Ar_-2")->ReadObj();
2983 if (trt->FindKey("Detector_Ar_2"))
2984 det4 = (TDirectory *)trt->FindKey("Detector_Ar_2")->ReadObj();
2985 }
2986
2987 TH2F *reshist1 = nullptr;
2988 TH2F *reshist2 = nullptr;
2989 TH2F *reshist3 = nullptr;
2990 TH2F *reshist4 = nullptr;
2991 TH2F *reshist5 = nullptr;
2992 TH2F *treshist1 = nullptr;
2993 TH2F *treshist2 = nullptr;
2994 TH2F *treshist3 = nullptr;
2995 TH2F *treshist4 = nullptr;
2996 TH2F *treshist5 = nullptr;
2997
2998 cout << " Find residual histograms " << endl;
2999
3000 if (trt->FindKey("residual"))
3001 reshist1 = (TH2F *)trt->FindKey("residual")->ReadObj();
3002 if (det1)
3003 {
3004 if (det1->FindKey("residual"))
3005 reshist2 = (TH2F *)det1->FindKey("residual")->ReadObj();
3006 }
3007 if (det2)
3008 {
3009 if (det2->FindKey("residual"))
3010 reshist3 = (TH2F *)det2->FindKey("residual")->ReadObj();
3011 }
3012 if (det3)
3013 {
3014 if (det3->FindKey("residual"))
3015 reshist4 = (TH2F *)det3->FindKey("residual")->ReadObj();
3016 }
3017 if (det4)
3018 {
3019 if (det4->FindKey("residual"))
3020 reshist5 = (TH2F *)det4->FindKey("residual")->ReadObj();
3021 }
3022
3023 cout << " Find time residual histograms" << endl;
3024 if (trt->FindKey("timeresidual"))
3025 treshist1 = (TH2F *)trt->FindKey("timeresidual")->ReadObj();
3026 if (det1)
3027 {
3028 if (det1->FindKey("timeresidual"))
3029 treshist2 = (TH2F *)det1->FindKey("timeresidual")->ReadObj();
3030 }
3031 if (det2)
3032 {
3033 if (det2->FindKey("timeresidual"))
3034 treshist3 = (TH2F *)det2->FindKey("timeresidual")->ReadObj();
3035 }
3036 if (det3)
3037 {
3038 if (det3->FindKey("timeresidual"))
3039 treshist4 = (TH2F *)det3->FindKey("timeresidual")->ReadObj();
3040 }
3041 if (det4)
3042 {
3043 if (det4->FindKey("timeresidual"))
3044 treshist5 = (TH2F *)det4->FindKey("timeresidual")->ReadObj();
3045 }
3046
3047 cout << " Configure residual histograms" << endl;
3048 if (reshist1)
3049 reshist1->SetTitle(Form("residual whole TRT"));
3050 if (reshist2)
3051 reshist2->SetTitle(Form("residual (barrel side C)"));
3052 if (reshist3)
3053 reshist3->SetTitle(Form("residual (barrel side A)"));
3054 if (reshist4)
3055 reshist4->SetTitle(Form("residual (endcap side C)"));
3056 if (reshist5)
3057 reshist5->SetTitle(Form("residual (endcap side A)"));
3058 if (reshist2)
3059 reshist2->SetFillColor(46);
3060 if (reshist3)
3061 reshist3->SetFillColor(46);
3062 if (reshist4)
3063 reshist4->SetFillColor(46);
3064 if (reshist5)
3065 reshist5->SetFillColor(46);
3066
3067 cout << " Configure time residual histograms" << endl;
3068 if (treshist1)
3069 treshist1->SetTitle("time-residual whole TRT");
3070 if (treshist2)
3071 treshist2->SetTitle("time-residual (barrel side C)");
3072 if (treshist3)
3073 treshist3->SetTitle("time-residual (barrel side A)");
3074 if (treshist4)
3075 treshist4->SetTitle("time-residual (endcap side C)");
3076 if (treshist5)
3077 treshist5->SetTitle("time-residual (endcap side A)");
3078 if (treshist2)
3079 treshist2->SetFillColor(38);
3080 if (treshist3)
3081 treshist3->SetFillColor(38);
3082 if (treshist4)
3083 treshist4->SetFillColor(38);
3084 if (treshist5)
3085 treshist5->SetFillColor(38);
3086
3087 if (isAr)
3088 {
3089 //hardcoded flag results in dead code
3090 //coverity[dead_error_begin]
3091 cout << " Configure Argon residual histograms" << endl;
3092 if (reshist1)
3093 reshist1->SetTitle("residual Argon whole TRT");
3094 if (reshist2)
3095 reshist2->SetTitle("residual Argon (barrel side C)");
3096 if (reshist3)
3097 reshist3->SetTitle("residual Argon (barrel side A)");
3098 if (reshist4)
3099 reshist4->SetTitle("residual Argon (endcap side C)");
3100 if (reshist5)
3101 reshist5->SetTitle("residual Argon (endcap side A)");
3102 if (treshist1)
3103 treshist1->SetTitle("time-residual Argon whole TRT");
3104 if (treshist2)
3105 treshist2->SetTitle("time-residual Argon (barrel side C)");
3106 if (treshist3)
3107 treshist3->SetTitle("time-residual Argon (barrel side A)");
3108 if (treshist4)
3109 treshist4->SetTitle("time-residual Argon (endcap side C)");
3110 if (treshist5)
3111 treshist5->SetTitle("time-residual Argon (endcap side A)");
3112 }
3113
3114 TF1 *resfit2 = nullptr;
3115 TF1 *resfit3 = nullptr;
3116 TF1 *resfit4 = nullptr;
3117 TF1 *resfit5 = nullptr;
3118 TF1 *tresfit2 = nullptr;
3119 TF1 *tresfit3 = nullptr;
3120 TF1 *tresfit4 = nullptr;
3121 TF1 *tresfit5 = nullptr;
3122
3123 if (reshist2)
3124 resfit2 = (TF1 *)reshist2->GetListOfFunctions()->First();
3125 if (reshist3)
3126 resfit3 = (TF1 *)reshist3->GetListOfFunctions()->First();
3127 if (reshist4)
3128 resfit4 = (TF1 *)reshist4->GetListOfFunctions()->First();
3129 if (reshist5)
3130 resfit5 = (TF1 *)reshist5->GetListOfFunctions()->First();
3131 if (treshist2)
3132 tresfit2 = (TF1 *)treshist2->GetListOfFunctions()->First();
3133 if (treshist3)
3134 tresfit3 = (TF1 *)treshist3->GetListOfFunctions()->First();
3135 if (treshist4)
3136 tresfit4 = (TF1 *)treshist4->GetListOfFunctions()->First();
3137 if (treshist5)
3138 tresfit5 = (TF1 *)treshist5->GetListOfFunctions()->First();
3139
3140 TText *mintxt = new TText();
3141 mintxt->SetNDC(kTRUE);
3142
3143 this->Divide(4, 2);
3144
3145 this->cd(3);
3146 if (reshist2)
3147 {
3148 cout << " Draw residual barrel C" << endl;
3149 reshist2->Draw();
3150 mintxt->DrawText(0.15, 0.85, Form("Mean: %.3f", resfit2->GetParameter(1)));
3151 mintxt->DrawText(0.15, 0.80, Form("Sigma: %.3f", resfit2->GetParameter(2)));
3152 }
3153 this->cd(2);
3154 // if( !isAr && reshist3){
3155 if (reshist3)
3156 { // changed this (PH)
3157 cout << " Draw residual barrel A" << endl;
3158 reshist3->Draw();
3159 mintxt->DrawText(0.15, 0.85, Form("Mean: %.3f", resfit3->GetParameter(1)));
3160 mintxt->DrawText(0.15, 0.80, Form("Sigma: %.3f", resfit3->GetParameter(2)));
3161 }
3162 this->cd(1);
3163
3164 if (reshist4)
3165 {
3166 cout << " Draw residual endcap C" << endl;
3167 reshist4->Draw();
3168 mintxt->DrawText(0.15, 0.85, Form("Mean: %.3f", resfit4->GetParameter(1)));
3169 mintxt->DrawText(0.15, 0.80, Form("Sigma: %.3f", resfit4->GetParameter(2)));
3170 }
3171 this->cd(4);
3172 if (reshist5)
3173 {
3174 cout << " Draw residual endcap A" << endl;
3175 reshist5->Draw();
3176 mintxt->DrawText(0.15, 0.85, Form("Mean: %.3f", resfit5->GetParameter(1)));
3177 mintxt->DrawText(0.15, 0.80, Form("Sigma: %.3f", resfit5->GetParameter(2)));
3178 }
3179 this->cd(7);
3180
3181 if (treshist2)
3182 {
3183 cout << " Draw time residual barrel C" << endl;
3184 treshist2->Draw();
3185 mintxt->DrawText(0.15, 0.85, Form("Mean: %.3f", tresfit2->GetParameter(1)));
3186 mintxt->DrawText(0.15, 0.80, Form("Sigma: %.3f", tresfit2->GetParameter(2)));
3187 }
3188 this->cd(6);
3189 // if(!isAr && treshist3){ // Changed this (PH)
3190 if (treshist3)
3191 {
3192 cout << " Draw time residual barrel A" << endl;
3193 treshist3->Draw();
3194 mintxt->DrawText(0.15, 0.85, Form("Mean: %.3f", tresfit3->GetParameter(1)));
3195 mintxt->DrawText(0.15, 0.80, Form("Sigma: %.3f", tresfit3->GetParameter(2)));
3196 }
3197 this->cd(5);
3198 if (treshist4)
3199 {
3200 cout << " Draw time residual endcap C" << endl;
3201 treshist4->Draw();
3202 mintxt->DrawText(0.15, 0.85, Form("Mean: %.3f", tresfit4->GetParameter(1)));
3203 mintxt->DrawText(0.15, 0.80, Form("Sigma: %.3f", tresfit4->GetParameter(2)));
3204 }
3205 this->cd(8);
3206 if (treshist5)
3207 {
3208 cout << " Draw time residual endcap A" << endl;
3209 treshist5->Draw();
3210 mintxt->DrawText(0.15, 0.85, Form("Mean: %.3f", tresfit5->GetParameter(1)));
3211 mintxt->DrawText(0.15, 0.80, Form("Sigma: %.3f", tresfit5->GetParameter(2)));
3212 }
3213 gStyle->SetOptStat(0);
3214}
3215
3216//================================================================
3217
3218class TRTPlots : public TCanvas
3219{
3220public:
3221 TRTPlots(TFile *, bool);
3222};
3223
3224TRTPlots::TRTPlots(TFile *file, bool isAr = false)
3225{
3226
3227 this->SetName("resplots");
3228
3229 file->cd();
3230
3231 TDirectory *trt = nullptr;
3232 if (!isAr)
3233 trt = (TDirectory *)file->FindKey("TRT_all")->ReadObj();
3234 else
3235 trt = (TDirectory *)file->FindKey("TRT_Ar_all")->ReadObj();
3236
3237 TH2F *reshist1 = nullptr;
3238 if (trt->FindKey("residual"))
3239 reshist1 = (TH2F *)trt->FindKey("residual")->ReadObj();
3240 else
3241 throw(string("residual histograms for entire TRT not found!"));
3242
3243 TH2F *treshist1 = nullptr;
3244 if (trt->FindKey("timeresidual"))
3245 treshist1 = (TH2F *)trt->FindKey("timeresidual")->ReadObj();
3246 else
3247 throw(string("timeresidual histograms for entire TRT not found!"));
3248
3249 reshist1->SetTitle(Form("residual whole TRT"));
3250 if (isAr)
3251 reshist1->SetTitle(Form("Argon residual whole TRT"));
3252 reshist1->SetFillColor(46);
3253 treshist1->SetTitle(Form("time-residual whole TRT"));
3254 if (isAr)
3255 treshist1->SetTitle(Form("Argon time-residual whole TRT"));
3256 treshist1->SetFillColor(38);
3257
3258 this->Divide(1, 2, 0.01, 0.01);
3259 this->SetLogy();
3260
3261 this->cd(1);
3262 reshist1->Draw();
3263 this->cd(2);
3264 treshist1->Draw();
3265}
3266
3267//================================================================
3268
3269class TBinnedRes : public TCanvas
3270{
3271public:
3272 TBinnedRes(TFile *, vector<TH1D *>);
3273};
3274
3275TBinnedRes::TBinnedRes(TFile* /*file*/, vector<TH1D *> reshists)
3276{
3277
3278 cout << "In TBinnedRes. Input is " << reshists.size() << " histograms to be drawn " << endl;
3279
3280 this->Divide(((int)reshists.size()) / 5, 5);
3281 for (int ihist = 0; ihist < (int)reshists.size(); ihist++)
3282 {
3283 this->cd(ihist + 1);
3284 reshists[ihist]->SetTitle("");
3285 reshists[ihist]->Draw();
3286 reshists[ihist]->GetYaxis()->SetRangeUser(0, 1.1 * reshists[ihist]->GetMaximum());
3287 TLine *zlin = new TLine(0, 0, 0, reshists[ihist]->GetMaximum());
3288 zlin->SetLineStyle(2);
3289 zlin->SetLineColor(4);
3290 zlin->Draw();
3291 }
3292
3293 this->SetGrid();
3294}
3295
3296//================================================================
3297
3298class RtBinning : public TCanvas
3299{
3300public:
3301 RtBinning(TDirectory *, const string&);
3302
3303private:
3304 TH1F *m_hist2{};
3305};
3306
3307RtBinning::RtBinning(TDirectory *file, const string & detector)
3308{
3309
3310 TDirectory *binhist = (TDirectory *)(((TDirectory *)file->Get(detector.c_str()))->Get("binhist"));
3311 if (binhist)
3312 {
3313 int nhists = binhist->GetListOfKeys()->GetEntries();
3314
3315 this->Divide(nhists / 5, 5);
3316 for (int ihist = 0; ihist < nhists; ihist++)
3317 {
3318 this->cd(ihist + 1);
3319 m_hist2 = (TH1F *)(binhist->Get(binhist->GetListOfKeys()->At(ihist)->GetName()));
3320 m_hist2->SetTitle("");
3321 m_hist2->Draw();
3322 }
3323
3324 this->SetGrid();
3325 }
3326}
3327
3328//================================================================
3329
3330class RresTbin : public TCanvas
3331{
3332public:
3333 RresTbin(TFile *, const string &, int);
3334 vector<TH1D *> reshists;
3335 map<double, double> resmap;
3336
3337private:
3338 TGraphErrors m_thegraph;
3339 std::vector<double> m_rdata;
3340 std::vector<double> m_erdata;
3341 std::vector<double> m_tdata;
3342 std::vector<double> m_etdata;
3343};
3344
3345RresTbin::RresTbin(TFile *file, const string & detname, int det)
3346{
3347
3348 TF1 ff("fitfunc", "gaus");
3349 TF1 *ff2 = new TF1("fitfunc2", "pol3");
3350
3351 TDirectory *trt = nullptr;
3352 TDirectory *detdir = nullptr;
3353 TDirectory *binhist = nullptr;
3354 string resname;
3355 bool isAr = false;
3356 if (detname.find("Ar") != string::npos)
3357 isAr = true;
3358 bool allTRT = false;
3359 if (detname == "WholeBarrel_1")
3360 {
3361 resname = "reshists5";
3362 }
3363 else if (detname == "Detector_-1")
3364 {
3365 resname = "reshists2";
3366 }
3367 else if (detname == "Detector_1")
3368 {
3369 resname = "reshists3";
3370 }
3371 else if (detname == "Detector_-2")
3372 {
3373 resname = "reshists1";
3374 }
3375 else if (detname == "Detector_2")
3376 {
3377 resname = "reshists4";
3378 }
3379 else if (!isAr)
3380 {
3381 resname = "reshists";
3382 allTRT = true;
3383 }
3384 else if (detname == "WholeBarrel_Ar_1")
3385 {
3386 resname = "reshists_Ar5";
3387 }
3388 else if (detname == "Detector_Ar_-1")
3389 {
3390 resname = "reshists_Ar2";
3391 }
3392 else if (detname == "Detector_Ar_1")
3393 {
3394 resname = "reshists_Ar3";
3395 }
3396 else if (detname == "Detector_Ar_-2")
3397 {
3398 resname = "reshists_Ar1";
3399 }
3400 else if (detname == "Detector_Ar_2")
3401 {
3402 resname = "reshists_Ar4";
3403 }
3404 else
3405 {
3406 resname = "reshists_Ar";
3407 allTRT = true;
3408 }
3409
3410 if (!isAr)
3411 trt = (TDirectory *)file->FindKey("TRT_all")->ReadObj();
3412 else
3413 trt = (TDirectory *)file->FindKey("TRT_Ar_all")->ReadObj();
3414
3415 if (!isAr)
3416 cout << "In RresTbin Xenon" << endl;
3417 if (isAr)
3418 cout << "In RresTbin Argon" << endl;
3419 if (trt)
3420 {
3421 cout << " found TRT_all directory " << endl;
3422 detdir = (TDirectory *)trt->FindKey(detname.c_str())->ReadObj();
3423 if (detdir)
3424 {
3425 cout << " found binhist directory for detector name " << detname << endl;
3426 if (!allTRT)
3427 {
3428 binhist = (TDirectory *)detdir->FindKey(resname.c_str())->ReadObj();
3429 }
3430 else
3431 {
3432 binhist = (TDirectory *)trt->FindKey(resname.c_str())->ReadObj();
3433 }
3434
3435 if (binhist)
3436 {
3437 cout << " found reshists directory for detector number: " << det << endl;
3438 }
3439 else
3440 {
3441 cout << " did not find reshists directory for detector number " << det << endl;
3442 }
3443 }
3444 else
3445 {
3446 cout << " did not find binhist directory for detector name " << detname << endl;
3447 }
3448 }
3449 else
3450 {
3451 cout << " did not find TRT_all directory " << endl;
3452 }
3453
3454 if (binhist)
3455 {
3456
3457 TVectorD *tbins = (TVectorD *)file->FindKey("tbins")->ReadObj();
3458
3459 if (tbins)
3460 {
3461 const size_t nElements = tbins->GetNoElements();
3462 cout << " found tbins vector with length " << nElements << endl;
3463 m_rdata = std::vector<double>(nElements,0.);
3464 m_erdata = std::vector<double>(nElements,0.);
3465 m_tdata = std::vector<double>(nElements,0.);
3466 m_etdata = std::vector<double>(nElements,0.);
3467 m_thegraph = TGraphErrors(nElements);
3468
3469 int ipoint = 0;
3470 for (int ihist = 0; ihist < tbins->GetNoElements(); ihist++)
3471 {
3472
3473 TH1D *reshist = nullptr;
3474
3475 if (det == 4)
3476 reshist = (TH1D *)binhist->Get(Form("res_tbin%i_bar", ihist));
3477 else if (det == 5)
3478 reshist = (TH1D *)binhist->Get(Form("res_tbin%i_trt", ihist));
3479 else
3480 reshist = (TH1D *)binhist->Get(Form("res_tbin%i_%i", ihist, det));
3481
3482 if (reshist != nullptr)
3483 {
3484 double lolim = -0.1; // reshist->GetBinCenter(reshist->GetMaximumBin()-10);
3485 double hilim = 0.1; // reshist->GetBinCenter(reshist->GetMaximumBin()+10);
3486
3487 if (reshist->Fit(&ff, "Q", "", lolim, hilim) + 1)
3488 {
3489 m_rdata[ipoint] = ff.GetParameter(1);
3490 m_erdata[ipoint] = ff.GetParError(1);
3491 m_tdata[ipoint] = (*tbins)[ihist];
3492
3493 m_etdata[ipoint] = 0;
3494 // printf("%f %f\n",ff.GetParameter(1),ff.GetParError(1));
3495 ipoint++;
3496 }
3497
3498 reshists.push_back(reshist);
3499 }
3500 }
3501 cout << " succesfully fitted " << ipoint << " histograms " << endl;
3502 for (int ip = 0; ip < ipoint; ip++)
3503 {
3504 // cout << rdata[ip] << " ";
3505 resmap[m_tdata[ip]] = m_rdata[ip];
3506 }
3507 // cout << endl;
3508
3509 if (ipoint > 10)
3510 {
3511 m_thegraph = TGraphErrors(ipoint, m_tdata.data(), m_rdata.data(), m_etdata.data(), m_erdata.data());
3512
3513 cout << " draw t-binned residual graph " << endl;
3514 string detstr[8] = {"endcap A", "barrel A", "", "barrel C", "endcap C", "", "whole barrel", "whole TRT"};
3515
3516 m_thegraph.SetMarkerStyle(20);
3517 m_thegraph.SetTitle(Form("t-binned absolute residual (%s)", detstr[det + 2].c_str()));
3518 m_thegraph.Draw("ap");
3519 m_thegraph.GetYaxis()->SetTitle("|r|-|r_{track}| /mm");
3520 m_thegraph.GetYaxis()->SetRangeUser(-0.150, 0.150);
3521 m_thegraph.GetXaxis()->SetRangeUser(0, 50);
3522 m_thegraph.GetXaxis()->SetTitle("t-t0 /ns");
3523
3524 printf("RPOLDIFF %i %e %e %e %e\n", det, ff2->GetParameter(0), ff2->GetParameter(1), ff2->GetParameter(2), ff2->GetParameter(3));
3525
3526 this->SetGrid();
3527 }
3528 }
3529 }
3530}
3531
3532//================================================================
3533
3534class FirstPage : public TCanvas
3535{
3536public:
3537 FirstPage(char *, TFile *);
3538 float runnumber = 0, t0offset = 0;
3539 int iter = 0;
3540
3541private:
3542};
3543
3544FirstPage::FirstPage(char * /*filename*/, TFile *file)
3545{
3546
3547 this->cd();
3548
3549 TNtuple *Tracktuple = (TNtuple *)file->Get("tracktuple");
3550 // we assign here index 0,1,2,3 to detectors -1, -2, 1, 2
3551 TH1F *resAr0 = (TH1F *)file->Get("TRT_Ar_all/Detector_Ar_-1/residual");
3552 TH1F *tresAr0 = (TH1F *)file->Get("TRT_Ar_all/Detector_Ar_-1/timeresidual");
3553 TH1F *resAr1 = (TH1F *)file->Get("TRT_Ar_all/Detector_Ar_-2/residual");
3554 TH1F *tresAr1 = (TH1F *)file->Get("TRT_Ar_all/Detector_Ar_-2/timeresidual");
3555 TH1F *resXe1 = (TH1F *)file->Get("TRT_all/Detector_-2/residual");
3556 TH1F *tresXe1 = (TH1F *)file->Get("TRT_all/Detector_-2/timeresidual");
3557 TH1F *resAr2 = (TH1F *)file->Get("TRT_Ar_all/Detector_Ar_1/residual");
3558 TH1F *tresAr2 = (TH1F *)file->Get("TRT_Ar_all/Detector_Ar_1/timeresidual");
3559 TH1F *resAr3 = (TH1F *)file->Get("TRT_Ar_all/Detector_Ar_2/residual");
3560 TH1F *tresAr3 = (TH1F *)file->Get("TRT_Ar_all/Detector_Ar_2/timeresidual");
3561 TH1F *resXe3 = (TH1F *)file->Get("TRT_all/Detector_2/residual");
3562 TH1F *tresXe3 = (TH1F *)file->Get("TRT_all/Detector_2/timeresidual");
3563
3564 TDatime *dt = new TDatime();
3565
3566 TPaveText *pt = new TPaveText(.1, .2, .9, .9);
3567
3568 if (!Tracktuple)
3569 throw(string("tracktuple not found!"));
3570
3571 cout << " tracktuple found " << endl;
3572 pt->AddText(" ");
3573
3574 // if (string(filename).find("_histograms.root")!=string::npos) iter = atoi(string(filename).substr(string(filename).find("_histograms.root")-2,2).data());
3575 iter = 0;
3576
3577 runnumber = 0;
3578 cout << " writing to header. iteration number " << iter << endl;
3579 pt->AddText(Form("Iteration number: %i", iter));
3580 cout << " writing to header. month " << dt->GetMonth() << endl;
3581 pt->AddText(Form("Time: %02i/%02i/%i %02i:%02i", dt->GetDay(), dt->GetMonth(), dt->GetYear(), dt->GetHour(), dt->GetMinute()));
3582 Tracktuple->SetBranchAddress("run", &runnumber);
3583 Tracktuple->GetEntry(0);
3584 cout << " writing to header. run number " << (int)runnumber << endl;
3585 pt->AddText(Form("Run number: %i", (int)runnumber));
3586 /*
3587 for(int i=1; i<Tracktuple->GetEntries();i++){
3588 float oldrun= runnumber;
3589 Tracktuple->GetEntry(i);
3590 if(oldrun!=runnumber ) pt->AddText(Form("Run number: %i",(int)runnumber));
3591 }
3592 */
3593 cout << " writing to header. number of tracks " << Tracktuple->GetEntries() << endl;
3594 pt->AddText(Form("Total no. tracks: %lli", Tracktuple->GetEntries()));
3595
3596 // Get residuals and time residuals per subdetector
3597 // we assign here index 0,1,2,3 to detectors -1, -2, 1, 2
3598 // the detectors +-1 have only Argon in Run3
3599
3600 float bhitst[4]={0};
3601 float rest[4]{};
3602 float trest[4]{};
3603 float treswt[4]{};
3604
3605 cout << " debug 1 " << endl;
3606 bhitst[0] = resAr0->GetEntries();
3607 bhitst[2] = resAr2->GetEntries();
3608 float nhAr1 = resAr1->GetEntries();
3609 float nhXe1 = resXe1->GetEntries();
3610 cout << " debug 2 " << endl;
3611 bhitst[1] = nhAr1 + nhXe1;
3612 float nhAr3 = 0;
3613 float nhXe3 = 0;
3614 if (resAr3)
3615 nhAr3 = resAr3->GetEntries();
3616 if (resXe3)
3617 nhXe3 = resXe3->GetEntries();
3618 bhitst[3] = nhAr3 + nhXe3;
3619 cout << " debug 3 " << endl;
3620 rest[0] = resAr0->GetFunction("gaus")->GetParameter(2);
3621 rest[2] = resAr2->GetFunction("gaus")->GetParameter(2);
3622 rest[1] = (resAr1->GetFunction("gaus")->GetParameter(2) * nhAr1 + resXe1->GetFunction("gaus")->GetParameter(2) * nhXe1) / bhitst[1];
3623 if (resAr3 and resXe3)
3624 rest[3] = (resAr3->GetFunction("gaus")->GetParameter(2) * nhAr3 + resXe3->GetFunction("gaus")->GetParameter(2) * nhXe3) / bhitst[3];
3625 cout << " debug 4 " << endl;
3626 trest[0] = tresAr0->GetFunction("gaus")->GetParameter(1);
3627 trest[2] = tresAr2->GetFunction("gaus")->GetParameter(1);
3628 trest[1] = (tresAr1->GetFunction("gaus")->GetParameter(1) * nhAr1 + tresXe1->GetFunction("gaus")->GetParameter(1) * nhXe1) / bhitst[1];
3629 if (tresAr3)
3630 trest[3] = (tresAr3->GetFunction("gaus")->GetParameter(1) * nhAr3 + tresXe3->GetFunction("gaus")->GetParameter(1) * nhXe3) / bhitst[3];
3631 cout << " debug 5 " << endl;
3632 treswt[0] = tresAr0->GetFunction("gaus")->GetParameter(2);
3633 treswt[2] = tresAr2->GetFunction("gaus")->GetParameter(2);
3634 treswt[1] = (tresAr1->GetFunction("gaus")->GetParameter(2) * nhAr1 + tresXe1->GetFunction("gaus")->GetParameter(2) * nhXe1) / bhitst[1];
3635 if (tresAr3)
3636 treswt[3] = (tresAr3->GetFunction("gaus")->GetParameter(2) * nhAr3 + tresXe3->GetFunction("gaus")->GetParameter(2) * nhXe3) / bhitst[3];
3637 cout << " debug 6 " << endl;
3638
3639 // Get the precion hits vs tube hits:
3640
3641 TDirectory *errors = nullptr;
3642 TDirectory *errorsAr = nullptr;
3643 bool iserrors = false;
3644 bool iserrorsAr = false;
3645 if (file->FindKey("ErrorsAr"))
3646 {
3647 errorsAr = (TDirectory *)file->FindKey("ErrorsAr")->ReadObj();
3648 if (errorsAr != nullptr)
3649 iserrorsAr = true;
3650 }
3651 if (file->FindKey("Errors"))
3652 {
3653 errors = (TDirectory *)file->FindKey("Errors")->ReadObj();
3654 if (errors != nullptr)
3655 iserrors = true;
3656 }
3657
3658 // double ratiotrt = 0;
3659 double ratioba = 0;
3660 double ratiobc = 0;
3661 double ratioea = 0;
3662 double ratioec = 0;
3663 // TH2F *residual_trt = nullptr;
3664 // TH2F *residual_ba = nullptr;
3665 // TH2F *residual_bc = nullptr;
3666 TH2F *residual_ea = nullptr;
3667 TH2F *residual_ec = nullptr;
3668
3669 // TH2F *residual_trtP = nullptr;
3670 // TH2F *residual_baP = nullptr;
3671 // TH2F *residual_bcP = nullptr;
3672 TH2F *residual_eaP = nullptr;
3673 TH2F *residual_ecP = nullptr;
3674
3675 // TH2F *residualAr_trt = nullptr;
3676 TH2F *residualAr_ba = nullptr;
3677 TH2F *residualAr_bc = nullptr;
3678 TH2F *residualAr_ea = nullptr;
3679 TH2F *residualAr_ec = nullptr;
3680
3681 // TH2F *residualAr_trtP = nullptr;
3682 TH2F *residualAr_baP = nullptr;
3683 TH2F *residualAr_bcP = nullptr;
3684 TH2F *residualAr_eaP = nullptr;
3685 TH2F *residualAr_ecP = nullptr;
3686
3687 if (iserrors && errors->FindKey("tresidual_trt") && errors->FindKey("tresidual_trtP"))
3688 {
3689 // residual_trt = (TH2F *)errors->FindKey("tresidual_trt")->ReadObj();
3690 if (errors->FindKey("tresidual_ea"))
3691 residual_ea = (TH2F *)errors->FindKey("tresidual_ea")->ReadObj();
3692 if (errors->FindKey("tresidual_ec"))
3693 residual_ec = (TH2F *)errors->FindKey("tresidual_ec")->ReadObj();
3694
3695 // residual_trtP = (TH2F *)errors->FindKey("tresidual_trtP")->ReadObj();
3696 if (errors->FindKey("tresidual_eaP"))
3697 residual_eaP = (TH2F *)errors->FindKey("tresidual_eaP")->ReadObj();
3698 if (errors->FindKey("tresidual_ecP"))
3699 residual_ecP = (TH2F *)errors->FindKey("tresidual_ecP")->ReadObj();
3700 }
3701 else
3702 {
3703 cout << " No time residual histograms in endcaps: tresidual_trt and tresidual_trtP " << endl;
3704 }
3705 if (iserrorsAr && errorsAr->FindKey("tresidualAr_trt") && errorsAr->FindKey("tresidualAr_trtP"))
3706 {
3707 // residualAr_trt = (TH2F *)errorsAr->FindKey("tresidualAr_trt")->ReadObj();
3708 if (errorsAr->FindKey("tresidualAr_ba"))
3709 residualAr_ba = (TH2F *)errorsAr->FindKey("tresidualAr_ba")->ReadObj();
3710 if (errorsAr->FindKey("tresidualAr_bc"))
3711 residualAr_bc = (TH2F *)errorsAr->FindKey("tresidualAr_bc")->ReadObj();
3712 if (errorsAr->FindKey("tresidualAr_ea"))
3713 residualAr_ea = (TH2F *)errorsAr->FindKey("tresidualAr_ea")->ReadObj();
3714 if (errorsAr->FindKey("tresidualAr_ec"))
3715 residualAr_ec = (TH2F *)errorsAr->FindKey("tresidualAr_ec")->ReadObj();
3716
3717 // residualAr_trtP = (TH2F *)errorsAr->FindKey("tresidualAr_trtP")->ReadObj();
3718 if (errorsAr->FindKey("tresidualAr_baP"))
3719 residualAr_baP = (TH2F *)errorsAr->FindKey("tresidualAr_baP")->ReadObj();
3720 if (errorsAr->FindKey("tresidualAr_bcP"))
3721 residualAr_bcP = (TH2F *)errorsAr->FindKey("tresidualAr_bcP")->ReadObj();
3722 if (errorsAr->FindKey("tresidualAr_eaP"))
3723 residualAr_eaP = (TH2F *)errorsAr->FindKey("tresidualAr_eaP")->ReadObj();
3724 if (errorsAr->FindKey("tresidualAr_ecP"))
3725 residualAr_ecP = (TH2F *)errorsAr->FindKey("tresidualAr_ecP")->ReadObj();
3726 }
3727 else
3728 {
3729 cout << " No time residual histograms for Argon layers : tresidualAr_trt and tresidualAr_trtP " << endl;
3730 }
3731
3732 // if (residual_trt && residual_trtP && residual_trt->GetEntries() > 0)
3733 // {
3734 // ratiotrt = (residual_trtP->GetEntries() + residualAr_trtP->GetEntries()) / (residual_trt->GetEntries() + residualAr_trt->GetEntries());
3735 // }
3736 if (residualAr_ba && residualAr_baP && residualAr_ba->GetEntries() > 0)
3737 {
3738 ratioba = residualAr_baP->GetEntries() / residualAr_ba->GetEntries();
3739 }
3740 if (residualAr_bc && residualAr_bcP && residualAr_ea && residualAr_bc->GetEntries() > 0)
3741 {
3742 ratiobc = residualAr_bcP->GetEntries() / residualAr_bc->GetEntries();
3743 }
3744 if (residual_ea && residual_eaP && residualAr_ea && residualAr_eaP && residual_ea->GetEntries() > 0)
3745 {
3746 ratioea = (residual_eaP->GetEntries() + residualAr_eaP->GetEntries()) / (residual_ea->GetEntries() + residualAr_ea->GetEntries());
3747 }
3748 if (residual_ecP && residual_ec && residualAr_ecP &&residualAr_ec && residual_ec->GetEntries() > 0)
3749 {
3750 ratioec = (residual_ecP->GetEntries() + residualAr_ecP->GetEntries()) / (residual_ec->GetEntries() + residualAr_ec->GetEntries());
3751 }
3752
3753 pt->AddText("Barrels:");
3754 pt->AddText(Form(" (side C) hits: %i residual: %.4f mm Time res peak: %.3f ns ", (int)bhitst[0], rest[0], trest[0]));
3755 pt->AddText(Form(" (side C) Time res width: %.2f ns Ratio prec hits: %.3f ", treswt[0], ratioba));
3756 pt->AddText(Form(" (side A) hits: %i residual: %.4f mm Time res peak: %.3f ns ", (int)bhitst[2], rest[2], trest[2]));
3757 pt->AddText(Form(" (side A) Time res width: %.2f ns Ratio prec hits: %.3f ", treswt[2], ratiobc));
3758 pt->AddText(" Endcaps:");
3759 pt->AddText(Form(" (side C) hits: %i residual: %.4f mm Time res peak: %.3f ns", (int)bhitst[1], rest[1], trest[1]));
3760 pt->AddText(Form(" (side C) Time res width: %.2f ns Ratio prec hits: %.3f ", treswt[1], ratioea));
3761 pt->AddText(Form(" (side A) hits: %i residual: %.4f mm Time res peak: %.3f ns", (int)bhitst[3], rest[3], trest[3]));
3762 pt->AddText(Form(" (side A) Time res width: %.2f ns Ratio prec hits: %.3f ", treswt[3], ratioec));
3763
3764 pt->SetLabel(Form("TRT calibration iteration summary"));
3765
3766 pt->Draw();
3767}
3768
3769//================================================================
3770
3771class SettingsInfo : public TCanvas
3772{
3773public:
3774 SettingsInfo(char *);
3775 map<string, string> set;
3776
3777private:
3778};
3779
3781{
3782
3783 this->cd();
3784
3785 TPaveText *pt = new TPaveText(.1, .1, 0.9, 0.9);
3786 pt->SetTextAlign(11);
3787 pt->AddText(" ");
3788 pt->AddText(" ");
3789 pt->SetLabel(Form("TRT calibration Main Settings"));
3790
3791 string line;
3792 ifstream myfile(filename);
3793 if (myfile.is_open())
3794 {
3795 while (!myfile.eof())
3796 {
3797 getline(myfile, line);
3798 auto notfirst = [&line](const std::string & sub)->bool{
3799 return line.find(sub)!=0;
3800 };
3801 if (notfirst("#") && notfirst("Clean") && notfirst("Submit") && notfirst("Relink") && notfirst("JobPrefix") && notfirst("Tag") && notfirst("WWW"))
3802 {
3803 int space = line.find_first_of(" ");
3804 if (space != -1)
3805 {
3806 // pt->AddText(line.c_str());
3807 set[trim(line.substr(0, line.find("=") - 1))] = trim(line.substr(line.find("=") + 1, line.size()));
3808 }
3809 }
3810 }
3811 for (const auto & [txt1,txt2]:set)
3812 {
3813 pt->AddText((string(txt1 + " . . . . . . . . . . . . " + txt2)).c_str());
3814 }
3815 myfile.close();
3816 }
3817 else
3818 throw(string("config file not found: ") + string(filename));
3819
3820 pt->Draw();
3821}
3822
3823//================================================================
3824
3825class TrackTupleInfo : public TCanvas
3826{
3827public:
3828 TrackTupleInfo(TFile *);
3829
3830private:
3832};
3833
3835{
3836
3837 m_Tracktuple = (TNtuple *)file->Get("tracktuple");
3838 if (!m_Tracktuple)
3839 throw(string("tracktuple not found!"));
3840
3841 this->SetName("c1");
3842 this->Divide(1, 2, 0.01, 0.01);
3843 ((TPad *)this->GetPrimitive("c1_1"))->SetLogy();
3844 this->cd(1);
3845 TH1F *trackhits = new TH1F("trackhits", "Accepted hits per track", 60, -0.5, 59.5);
3846 TH1F *trackhits1 = new TH1F("trackhits1", "Accepted hits per track BarrelA", 60, -0.5, 59.5);
3847 TH1F *trackhits2 = new TH1F("trackhits2", "Accepted hits per track EndcaoA", 60, -0.5, 59.5);
3848 TH1F *trackhits3 = new TH1F("trackhits3", "Accepted hits per track BarrelC", 60, -0.5, 59.5);
3849 TH1F *trackhits4 = new TH1F("trackhits4", "Accepted hits per track EndcaoC", 60, -0.5, 59.5);
3850
3851 TH1F *eventphase = new TH1F("eventphase", "Event Phase", 80, -18, -1);
3852 TH1F *eventphase1 = new TH1F("eventphase1", "Eventphase1", 80, -18, -1);
3853 TH1F *eventphase2 = new TH1F("eventphase2", "Eventphase2", 80, -18, -1);
3854 TH1F *eventphase3 = new TH1F("eventphase3", "Eventphase3", 80, -18, -1);
3855 TH1F *eventphase4 = new TH1F("eventphase4", "Eventphase4", 80, -18, -1);
3856
3857 m_Tracktuple->Draw("nhits>>trackhits");
3858
3859 m_Tracktuple->Draw("nhits>>trackhits1", "-log(tan(theta/2))>0 && -log(tan(theta/2))< 1 ", "same");
3860 m_Tracktuple->Draw("nhits>>trackhits2", "-log(tan(theta/2))>1", "same");
3861 m_Tracktuple->Draw("nhits>>trackhits3", "-log(tan(theta/2))<0 && -log(tan(theta/2))> -1 ", "same");
3862 m_Tracktuple->Draw("nhits>>trackhits4", "-log(tan(theta/2))<-1 ", "same");
3863 trackhits1->SetLineColor(2);
3864 trackhits2->SetLineColor(3);
3865 trackhits3->SetLineColor(4);
3866 trackhits4->SetLineColor(5);
3867 trackhits1->Draw("same");
3868 trackhits2->Draw("same");
3869 trackhits3->Draw("same");
3870 trackhits4->Draw("same");
3871 TLegend *leg1 = new TLegend(0.7155172, 0.1038136, 0.8965517, 0.2542373, nullptr, "brNDC");
3872 leg1->AddEntry(trackhits, "all tracks", "l");
3873 leg1->AddEntry(trackhits1, "0 < eta < 1", "l");
3874 leg1->AddEntry(trackhits2, "eta > 1", "l");
3875 leg1->AddEntry(trackhits3, "-1 < eta < 0", "l");
3876 leg1->AddEntry(trackhits4, "eta < -1", "l");
3877 leg1->SetTextSize(0.03);
3878 leg1->Draw();
3879
3880 trackhits->SetTitle(Form("Accepted precission hits per track (%lli tracks in total)", m_Tracktuple->GetEntries()));
3881 trackhits->GetXaxis()->SetTitle("accepted precission hits");
3882 trackhits->GetYaxis()->SetTitle("No. tracks");
3883 this->SetName("c1");
3884 this->cd(2);
3885 ((TPad *)this->GetPrimitive("c1_2"))->SetLogy();
3886
3887 m_Tracktuple->Draw("epold>>eventphase");
3888 m_Tracktuple->Draw("epold>>eventphase1", "-log(tan(theta/2))>0 && -log(tan(theta/2))< 1", "same");
3889 m_Tracktuple->Draw("epold>>eventphase2", "-log(tan(theta/2))>1", "same");
3890 m_Tracktuple->Draw("epold>>eventphase3", "-log(tan(theta/2))<0 && -log(tan(theta/2))> -1", "same");
3891 m_Tracktuple->Draw("epold>>eventphase4", "-log(tan(theta/2))<-1", "same");
3892
3893 eventphase1->SetLineColor(2);
3894 eventphase2->SetLineColor(3);
3895 eventphase3->SetLineColor(4);
3896 eventphase4->SetLineColor(5);
3897
3898 eventphase->SetTitle("Eventphase");
3899 eventphase->GetXaxis()->SetTitle("eventphase");
3900 eventphase->GetYaxis()->SetTitle("No. tracks");
3901
3902 TLegend *leg2 = new TLegend(0.7155172, 0.1038136, 0.8965517, 0.2542373, nullptr, "brNDC");
3903 leg2->AddEntry(trackhits1, "0 < eta < 1", "l");
3904 leg2->AddEntry(trackhits2, "eta > 1", "l");
3905 leg2->AddEntry(trackhits3, "-1 < eta < 0", "l");
3906 leg2->AddEntry(trackhits4, "eta < -1", "l");
3907 leg2->SetTextSize(0.03);
3908 leg2->Draw();
3909}
3910
3911//================================================================
3912
3913TGraphErrors *GetMean(TH2F *histo)
3914{
3915
3916 if (!histo)
3917 return nullptr;
3918 int const nxbins = histo->GetNbinsX();
3919 TGraphErrors *Means = new TGraphErrors(nxbins);
3920 float mean = 0;
3921 float rms = 0;
3922 TF1 *ff = new TF1("ff", "gaus");
3923 for (int i = 0; i < nxbins; i++)
3924 {
3925 TH1D *slice = histo->ProjectionY("slice", i + 1, i + 1);
3926 mean = slice->GetMean();
3927 rms = slice->GetRMS();
3928 ff->SetParameter(0, slice->GetEntries());
3929 ff->SetParameter(1, mean);
3930 ff->SetParameter(2, rms);
3931 mean = ff->GetParameter(1);
3932 rms = ff->GetParameter(2);
3933 float x = histo->GetBinCenter(i + 1);
3934 Means->SetPoint(i, x, mean);
3935 Means->SetPointError(i, 0.5 * histo->GetBinWidth(i), ff->GetParError(1));
3936 delete slice;
3937 }
3938 delete ff;
3939 return Means;
3940}
3941
3942TGraphErrors *GetMeanE(TH2F *histo)
3943{
3944
3945 if (!histo)
3946 return nullptr;
3947 int const nxbins = histo->GetNbinsX();
3948 TGraphErrors *Means = new TGraphErrors(nxbins);
3949 float mean = 0;
3950 // float rms = 0;
3951 TF1 *ff = new TF1("ff", "gaus");
3952 for (int i = 0; i < nxbins; i++)
3953 {
3954 TH1D *slice = histo->ProjectionY("slice", i + 1, i + 1);
3955 mean = slice->GetMean();
3956 // rms = slice->GetRMS();
3957 float x = histo->GetBinCenter(i + 1);
3958 Means->SetPoint(i, x, mean);
3959 Means->SetPointError(i, 0.5 * histo->GetBinWidth(i), ff->GetParError(1));
3960 delete slice;
3961 }
3962 delete ff;
3963 return Means;
3964}
3965
3966TGraphErrors *GetPn(TH2F *histo)
3967{
3968
3969 if (!histo)
3970 return nullptr;
3971 int const nxbins = histo->GetNbinsX();
3972 TGraphErrors *Means = new TGraphErrors(nxbins);
3973 float mean = 0;
3974 // float rms = 0;
3975 TF1 *ff = new TF1("ff", "gaus");
3976 for (int i = 0; i < nxbins; i++)
3977 {
3978 TH1D *slice = histo->ProjectionY("slice", i + 1, i + 1);
3979 mean = slice->GetEntries();
3980 float x = histo->GetBinCenter(i + 1);
3981 Means->SetPoint(i, x, mean);
3982 Means->SetPointError(i, 0.5 * histo->GetBinWidth(i), ff->GetParError(1));
3983 delete slice;
3984 }
3985 delete ff;
3986 return Means;
3987}
3988
3989TGraphErrors *GetWidth(TH2F *histo)
3990{
3991 if (!histo)
3992 return nullptr;
3993 int const nxbins = histo->GetNbinsX();
3994 TGraphErrors *Means = new TGraphErrors(nxbins);
3995 float mean = 0;
3996 float rms = 0;
3997 TF1 *ff = new TF1("ff", "gaus");
3998 for (int i = 0; i < nxbins; i++)
3999 {
4000 TH1D *slice = histo->ProjectionY("slice", i + 1, i + 1);
4001 mean = slice->GetMean();
4002 rms = slice->GetRMS();
4003 ff->SetParameter(0, slice->GetEntries());
4004 ff->SetParameter(1, mean);
4005 ff->SetParameter(2, rms);
4006 // int fitresult = slice->Fit("ff", "QR", "", mean - 1.5 * rms, mean + 1.5 * rms);
4007 mean = ff->GetParameter(1);
4008 rms = ff->GetParameter(2);
4009 for (int j = 0; j < 6; j++)
4010 {
4011 // fitresult = slice->Fit("ff", "QR", "", mean - 1.5 * rms, mean + 1.5 * rms);
4012
4013 rms = ff->GetParameter(2);
4014 }
4015 // fitresult = slice->Fit("ff", "QR", "", mean - 1.5 * rms, mean + 1.5 * rms);
4016 float x = histo->GetBinCenter(i + 1);
4017 Means->SetPoint(i, x, rms);
4018 Means->SetPointError(i, 0.5 * histo->GetBinWidth(i), ff->GetParError(2));
4019 delete slice;
4020 }
4021 delete ff;
4022 return Means;
4023}
4024
4025TGraphErrors *GetEntries(TH2F *histo)
4026{
4027 if (!histo)
4028 return nullptr;
4029 int const nxbins = histo->GetNbinsX();
4030 TGraphErrors *Means = new TGraphErrors(nxbins);
4031 float mean = 0;
4032 float rms = 0;
4033 TF1 *ff = new TF1("ff", "gaus");
4034 for (int i = 0; i < nxbins; i++)
4035 {
4036 TH1D *slice = histo->ProjectionY("slice", i + 1, i + 1);
4037 mean = slice->GetEntries();
4038 rms = sqrt(mean);
4039 float x = histo->GetBinCenter(i + 1);
4040 Means->SetPoint(i, x, mean);
4041 Means->SetPointError(i, 0.5 * histo->GetBinWidth(i), rms);
4042 delete slice;
4043 }
4044 delete ff;
4045 return Means;
4046}
4047
4048TGraphErrors *GetPWidth(TH2F *histo)
4049{
4050 if (!histo)
4051 return nullptr;
4052 int const nxbins = histo->GetNbinsX();
4053 TGraphErrors *Means = new TGraphErrors(nxbins);
4054 float mean = 0;
4055 float rms = 0;
4056 TF1 *ff = new TF1("ff", "gaus");
4057 for (int i = 0; i < nxbins; i++)
4058 {
4059 TH1D *slice = histo->ProjectionY("slice", i + 1, i + 1);
4060 mean = slice->GetMean();
4061 rms = slice->GetRMS();
4062 ff->SetParameter(0, slice->GetEntries());
4063 ff->SetParameter(1, mean);
4064 ff->SetParameter(2, rms);
4065 // int fitresult = slice->Fit("ff", "QR", "", -2.5, +2.5);
4066 mean = ff->GetParameter(1);
4067 rms = ff->GetParameter(2);
4068 // fitresult = slice->Fit("ff", "QR", "", -2.5, 2.5);
4069 mean = ff->GetParameter(1);
4070 rms = ff->GetParameter(2);
4071 // fitresult = slice->Fit("ff", "QR", "", -2.5, 2.5);
4072 float x = histo->GetBinCenter(i + 1);
4073 Means->SetPoint(i, x, rms);
4074 Means->SetPointError(i, 0.5 * histo->GetBinWidth(i), ff->GetParError(2));
4075 delete slice;
4076 }
4077 delete ff;
4078 return Means;
4079}
4080
4081class PtDependence : public TCanvas
4082{
4083public:
4084 PtDependence(TFile *);
4085
4086private:
4087 TDirectory *m_errors;
4088};
4089
4091{
4092 m_errors = (TDirectory *)file->FindKey("Errors")->ReadObj();
4093 if (m_errors == nullptr)
4094 throw(string("No errors folder!!!!!!!!!!!!!!!"));
4095 if (m_errors->GetNkeys() > 29)
4096 {
4097 this->Divide(2, 3, 0.01, 0.01);
4098 // Read the histos:
4099 TH2F *residual_trt = (TH2F *)m_errors->FindKey("residual_allhits")->ReadObj();
4100 TH2F *residual_ba = (TH2F *)m_errors->FindKey("residual_ba")->ReadObj();
4101 TH2F *residual_bc = (TH2F *)m_errors->FindKey("residual_bc")->ReadObj();
4102 TH2F *residual_ea = (TH2F *)m_errors->FindKey("residual_ea")->ReadObj();
4103 TH2F *residual_ec = (TH2F *)m_errors->FindKey("residual_ec")->ReadObj();
4104 // TH2F *tresidual_trt = (TH2F *)m_errors->FindKey("tresidual_trt")->ReadObj();
4105 // TH2F *tresidual_ba = (TH2F *)m_errors->FindKey("tresidual_ba")->ReadObj();
4106 // TH2F *tresidual_bc = (TH2F *)m_errors->FindKey("tresidual_bc")->ReadObj();
4107 // TH2F *tresidual_ea = (TH2F *)m_errors->FindKey("tresidual_ea")->ReadObj();
4108 // TH2F *tresidual_ec = (TH2F *)m_errors->FindKey("tresidual_ec")->ReadObj();
4109 TH2F *pull_trtP = (TH2F *)m_errors->FindKey("pull_trtP")->ReadObj();
4110 TH2F *pull_baP = (TH2F *)m_errors->FindKey("pull_baP")->ReadObj();
4111 TH2F *pull_bcP = (TH2F *)m_errors->FindKey("pull_bcP")->ReadObj();
4112 TH2F *pull_eaP = (TH2F *)m_errors->FindKey("pull_eaP")->ReadObj();
4113 TH2F *pull_ecP = (TH2F *)m_errors->FindKey("pull_ecP")->ReadObj();
4114 TH2F *residual_trtP = (TH2F *)m_errors->FindKey("residual_trtP")->ReadObj();
4115 TH2F *residual_baP = (TH2F *)m_errors->FindKey("residual_baP")->ReadObj();
4116 TH2F *residual_bcP = (TH2F *)m_errors->FindKey("residual_bcP")->ReadObj();
4117 TH2F *residual_eaP = (TH2F *)m_errors->FindKey("residual_eaP")->ReadObj();
4118 TH2F *residual_ecP = (TH2F *)m_errors->FindKey("residual_ecP")->ReadObj();
4119 TH2F *tresidual_trtP = (TH2F *)m_errors->FindKey("tresidual_trtP")->ReadObj();
4120 TH2F *tresidual_baP = (TH2F *)m_errors->FindKey("tresidual_baP")->ReadObj();
4121 TH2F *tresidual_bcP = (TH2F *)m_errors->FindKey("tresidual_bcP")->ReadObj();
4122 TH2F *tresidual_eaP = (TH2F *)m_errors->FindKey("tresidual_eaP")->ReadObj();
4123 TH2F *tresidual_ecP = (TH2F *)m_errors->FindKey("tresidual_ecP")->ReadObj();
4124 TH2F *trackerrors_trt = (TH2F *)m_errors->FindKey("trackerrors_trt")->ReadObj();
4125 TH2F *trackerrors_ba = (TH2F *)m_errors->FindKey("trackerrors_ba")->ReadObj();
4126 TH2F *trackerrors_bc = (TH2F *)m_errors->FindKey("trackerrors_bc")->ReadObj();
4127 TH2F *trackerrors_ea = (TH2F *)m_errors->FindKey("trackerrors_ea")->ReadObj();
4128 TH2F *trackerrors_ec = (TH2F *)m_errors->FindKey("trackerrors_ec")->ReadObj();
4129
4130 this->cd(1);
4131 // Time Residual Mean Vs Pt:
4132 TGraphErrors *tresTRT = GetMean(tresidual_trtP);
4133 TGraphErrors *tresBA = GetMean(tresidual_baP);
4134 tresBA->SetLineColor(kRed);
4135 tresBA->SetMarkerColor(kRed);
4136 TGraphErrors *tresBC = GetMean(tresidual_bcP);
4137 tresBC->SetLineColor(kBlue);
4138 tresBC->SetMarkerColor(kBlue);
4139 TGraphErrors *tresEA = GetMean(tresidual_eaP);
4140 tresEA->SetLineColor(kGreen);
4141 tresEA->SetMarkerColor(kGreen);
4142 TGraphErrors *tresEC = GetMean(tresidual_ecP);
4143 tresEC->SetLineColor(kYellow);
4144 tresEC->SetMarkerColor(kYellow);
4145
4146 tresTRT->SetTitle("Time Residual Mean VS PT");
4147 tresTRT->GetXaxis()->SetTitle("Pt (GeV)");
4148 tresTRT->GetYaxis()->SetTitle("ns");
4149 tresTRT->GetYaxis()->SetRangeUser(-0.8, 0.4);
4150 tresTRT->Draw("ALP");
4151 tresBA->Draw("LP");
4152 tresBC->Draw("LP");
4153 tresEA->Draw("LP");
4154 tresEC->Draw("LP");
4155
4156 this->cd(3);
4157 // Time Residual Width Vs Pt
4158
4159 TGraphErrors *tresTRTw = GetWidth(tresidual_trtP);
4160 TGraphErrors *tresBAw = GetWidth(tresidual_baP);
4161 tresBAw->SetLineColor(kRed);
4162 tresBAw->SetMarkerColor(kRed);
4163 TGraphErrors *tresBCw = GetWidth(tresidual_bcP);
4164 tresBCw->SetLineColor(kBlue);
4165 tresBCw->SetMarkerColor(kBlue);
4166 TGraphErrors *tresEAw = GetWidth(tresidual_eaP);
4167 tresEAw->SetLineColor(kGreen);
4168 tresEAw->SetMarkerColor(kGreen);
4169 TGraphErrors *tresECw = GetWidth(tresidual_ecP);
4170 tresECw->SetLineColor(kYellow);
4171 tresECw->SetMarkerColor(kYellow);
4172
4173 tresTRTw->SetTitle("Time Residual Width VS PT");
4174 tresTRTw->GetXaxis()->SetTitle("Pt (GeV)");
4175 tresTRTw->GetYaxis()->SetTitle("ns");
4176 tresTRTw->GetYaxis()->SetRangeUser(2.9, 4.0);
4177 tresTRTw->Draw("ALP");
4178 tresBAw->Draw("LP");
4179 tresBCw->Draw("LP");
4180 tresEAw->Draw("LP");
4181 tresECw->Draw("LP");
4182 this->cd(5);
4183
4184 // Residual Vs Pt:
4185 TGraphErrors *resTRTw = GetWidth(residual_trtP);
4186 TGraphErrors *resBAw = GetWidth(residual_baP);
4187 resBAw->SetLineColor(kRed);
4188 resBAw->SetMarkerColor(kRed);
4189 TGraphErrors *resBCw = GetWidth(residual_bcP);
4190 resBCw->SetLineColor(kBlue);
4191 resBCw->SetMarkerColor(kBlue);
4192 TGraphErrors *resEAw = GetWidth(residual_eaP);
4193 resEAw->SetLineColor(kGreen);
4194 resEAw->SetMarkerColor(kGreen);
4195 TGraphErrors *resECw = GetWidth(residual_ecP);
4196 resECw->SetLineColor(kYellow);
4197 resECw->SetMarkerColor(kYellow);
4198
4199 resTRTw->SetTitle("Residual Width VS PT");
4200 resTRTw->GetXaxis()->SetTitle("Pt (GeV)");
4201 resTRTw->GetYaxis()->SetTitle("mm");
4202 resTRTw->GetYaxis()->SetRangeUser(0.11, 0.18);
4203 resTRTw->Draw("ALP");
4204 resBAw->Draw("LP");
4205 resBCw->Draw("LP");
4206 resEAw->Draw("LP");
4207 resECw->Draw("LP");
4208
4209 this->cd(2);
4210 // Pull Width vs Pt:
4211 TGraphErrors *pullTRTw = GetPWidth(pull_trtP);
4212 TGraphErrors *pullBAw = GetPWidth(pull_baP);
4213 pullBAw->SetLineColor(kRed);
4214 pullBAw->SetMarkerColor(kRed);
4215 TGraphErrors *pullBCw = GetPWidth(pull_bcP);
4216 pullBCw->SetLineColor(kBlue);
4217 pullBCw->SetMarkerColor(kBlue);
4218 TGraphErrors *pullEAw = GetPWidth(pull_eaP);
4219 pullEAw->SetLineColor(kGreen);
4220 pullEAw->SetMarkerColor(kGreen);
4221 TGraphErrors *pullECw = GetPWidth(pull_ecP);
4222 pullECw->SetLineColor(kYellow);
4223 pullECw->SetMarkerColor(kYellow);
4224
4225 pullTRTw->SetTitle("Pull Width VS PT");
4226 pullTRTw->GetXaxis()->SetTitle("Pt (GeV)");
4227 pullTRTw->GetYaxis()->SetTitle(" ");
4228 pullTRTw->GetYaxis()->SetRangeUser(0.7, 1.3);
4229 pullTRTw->Draw("ALP");
4230 pullBAw->Draw("LP");
4231 pullBCw->Draw("LP");
4232 pullEAw->Draw("LP");
4233 pullECw->Draw("LP");
4234
4235 this->cd(4);
4236 // Pull Width vs Pt:
4237 TGraphErrors *trkTRTw = GetMean(trackerrors_trt);
4238 TGraphErrors *trkBAw = GetMean(trackerrors_ba);
4239 trkBAw->SetLineColor(kRed);
4240 trkBAw->SetMarkerColor(kRed);
4241 TGraphErrors *trkBCw = GetMean(trackerrors_bc);
4242 trkBCw->SetLineColor(kBlue);
4243 trkBCw->SetMarkerColor(kBlue);
4244 TGraphErrors *trkEAw = GetMean(trackerrors_ea);
4245 trkEAw->SetLineColor(kGreen);
4246 trkEAw->SetMarkerColor(kGreen);
4247 TGraphErrors *trkECw = GetMean(trackerrors_ec);
4248 trkECw->SetLineColor(kYellow);
4249 trkECw->SetMarkerColor(kYellow);
4250
4251 trkTRTw->SetTitle("Trk error Mean Width VS PT");
4252 trkTRTw->GetXaxis()->SetTitle("Pt (GeV)");
4253 trkTRTw->GetYaxis()->SetTitle("mm");
4254 trkTRTw->GetYaxis()->SetRangeUser(0.0, 0.07);
4255 trkTRTw->Draw("ALP");
4256 trkBAw->Draw("LP");
4257 trkBCw->Draw("LP");
4258 trkEAw->Draw("LP");
4259 trkECw->Draw("LP");
4260
4261 this->cd(6);
4262
4263 // Residual Vs Pt:
4264 TGraphErrors *presTRTw = GetWidth(residual_trt);
4265 TGraphErrors *presBAw = GetWidth(residual_ba);
4266 presBAw->SetLineColor(kRed);
4267 presBAw->SetMarkerColor(kRed);
4268 TGraphErrors *presBCw = GetWidth(residual_bc);
4269 presBCw->SetLineColor(kBlue);
4270 presBCw->SetMarkerColor(kBlue);
4271 TGraphErrors *presEAw = GetWidth(residual_ea);
4272 presEAw->SetLineColor(kGreen);
4273 presEAw->SetMarkerColor(kGreen);
4274 TGraphErrors *presECw = GetWidth(residual_ec);
4275 presECw->SetLineColor(kYellow);
4276 presECw->SetMarkerColor(kYellow);
4277
4278 presTRTw->SetTitle("Residual Width all hits VS PT");
4279 presTRTw->GetXaxis()->SetTitle("Pt (GeV)");
4280 presTRTw->GetYaxis()->SetTitle("mm");
4281 presTRTw->GetYaxis()->SetRangeUser(0.11, 0.18);
4282 presTRTw->Draw("ALP");
4283 presBAw->Draw("LP");
4284 presBCw->Draw("LP");
4285 presEAw->Draw("LP");
4286 presECw->Draw("LP");
4287 }
4288 else
4289 {
4290 cout << " Not enough keys in Errors directory for Pt dependence plots " << endl;
4291 }
4292}
4293
4294class TBDependence : public TCanvas
4295{
4296public:
4297 TBDependence(TFile *);
4298
4299private:
4300 TDirectory *errors;
4301};
4302
4304{
4305 errors = (TDirectory *)file->FindKey("Errors")->ReadObj();
4306 if (!errors)
4307 throw(string("No errors folder!!!!!!!!!!!!!!!"));
4308 if (errors->GetNkeys() > 19)
4309 {
4310 this->Divide(2, 3, 0.01, 0.01);
4311
4312 // Read the histos:
4313
4314 TH2F *pull_vs_tb_trt = (TH2F *)errors->FindKey("pull_vs_tb_trt")->ReadObj();
4315 TH2F *pull_vs_tb_ba = (TH2F *)errors->FindKey("pull_vs_tb_ba")->ReadObj();
4316 TH2F *pull_vs_tb_bc = (TH2F *)errors->FindKey("pull_vs_tb_bc")->ReadObj();
4317 TH2F *pull_vs_tb_ea = (TH2F *)errors->FindKey("pull_vs_tb_ea")->ReadObj();
4318 TH2F *pull_vs_tb_ec = (TH2F *)errors->FindKey("pull_vs_tb_ec")->ReadObj();
4319
4320 TH2F *errors_vs_tb_trt = (TH2F *)errors->FindKey("errors_vs_tb_trt")->ReadObj();
4321 TH2F *errors_vs_tb_ba = (TH2F *)errors->FindKey("errors_vs_tb_ba")->ReadObj();
4322 TH2F *errors_vs_tb_bc = (TH2F *)errors->FindKey("errors_vs_tb_bc")->ReadObj();
4323 TH2F *errors_vs_tb_ea = (TH2F *)errors->FindKey("errors_vs_tb_ea")->ReadObj();
4324 TH2F *errors_vs_tb_ec = (TH2F *)errors->FindKey("errors_vs_tb_ec")->ReadObj();
4325
4326 TH2F *residual_vs_tb_trt = (TH2F *)errors->FindKey("residual_vs_tb_trt")->ReadObj();
4327 TH2F *residual_vs_tb_ba = (TH2F *)errors->FindKey("residual_vs_tb_ba")->ReadObj();
4328 TH2F *residual_vs_tb_bc = (TH2F *)errors->FindKey("residual_vs_tb_bc")->ReadObj();
4329 TH2F *residual_vs_tb_ea = (TH2F *)errors->FindKey("residual_vs_tb_ea")->ReadObj();
4330 TH2F *residual_vs_tb_ec = (TH2F *)errors->FindKey("residual_vs_tb_ec")->ReadObj();
4331
4332 TH2F *trackerrors_vs_tb_trt = (TH2F *)errors->FindKey("trackerrors_vs_tb_trt")->ReadObj();
4333 TH2F *trackerrors_vs_tb_ba = (TH2F *)errors->FindKey("trackerrors_vs_tb_ba")->ReadObj();
4334 TH2F *trackerrors_vs_tb_bc = (TH2F *)errors->FindKey("trackerrors_vs_tb_bc")->ReadObj();
4335 TH2F *trackerrors_vs_tb_ea = (TH2F *)errors->FindKey("trackerrors_vs_tb_ea")->ReadObj();
4336 TH2F *trackerrors_vs_tb_ec = (TH2F *)errors->FindKey("trackerrors_vs_tb_ec")->ReadObj();
4337
4338 this->cd(1);
4339 // Pull widht Vs Pt:
4340 TGraphErrors *tresTRT = GetPWidth(pull_vs_tb_trt);
4341 TGraphErrors *tresBA = GetPWidth(pull_vs_tb_ba);
4342 tresBA->SetLineColor(kRed);
4343 tresBA->SetMarkerColor(kRed);
4344 TGraphErrors *tresBC = GetPWidth(pull_vs_tb_bc);
4345 tresBC->SetLineColor(kBlue);
4346 tresBC->SetMarkerColor(kBlue);
4347 TGraphErrors *tresEA = GetPWidth(pull_vs_tb_ea);
4348 tresEA->SetLineColor(kGreen);
4349 tresEA->SetMarkerColor(kGreen);
4350 TGraphErrors *tresEC = GetPWidth(pull_vs_tb_ec);
4351 tresEC->SetLineColor(kYellow);
4352 tresEC->SetMarkerColor(kYellow);
4353
4354 tresTRT->SetTitle("Pull Width VS Drift Time. Pt>2GeV");
4355 tresTRT->GetXaxis()->SetTitle("Drift Time ");
4356 tresTRT->GetYaxis()->SetTitle(" ");
4357 tresTRT->GetYaxis()->SetRangeUser(0.7, 1.3);
4358 tresTRT->Draw("ALP");
4359 tresBA->Draw("LP");
4360 tresBC->Draw("LP");
4361 tresEA->Draw("LP");
4362 tresEC->Draw("LP");
4363
4364 this->cd(2);
4365 TGraphErrors *errorsTRT = GetMeanE(errors_vs_tb_trt);
4366 TGraphErrors *errorsBA = GetMeanE(errors_vs_tb_ba);
4367 errorsBA->SetLineColor(kRed);
4368 errorsBA->SetMarkerColor(kRed);
4369 TGraphErrors *errorsBC = GetMeanE(errors_vs_tb_bc);
4370 errorsBC->SetLineColor(kBlue);
4371 errorsBC->SetMarkerColor(kBlue);
4372 TGraphErrors *errorsEA = GetMeanE(errors_vs_tb_ea);
4373 errorsEA->SetLineColor(kGreen);
4374 errorsEA->SetMarkerColor(kGreen);
4375 TGraphErrors *errorsEC = GetMeanE(errors_vs_tb_ec);
4376 errorsEC->SetLineColor(kYellow);
4377 errorsEC->SetMarkerColor(kYellow);
4378 errorsTRT->SetTitle("Error VS Drift Time");
4379 errorsTRT->GetXaxis()->SetTitle("Drift Time");
4380 errorsTRT->GetYaxis()->SetTitle("mm");
4381 errorsTRT->GetYaxis()->SetRangeUser(0.05, 0.24);
4382 errorsTRT->Draw("ALP");
4383 errorsBA->Draw("LP");
4384 errorsBC->Draw("LP");
4385 errorsEA->Draw("LP");
4386 errorsEC->Draw("LP");
4387
4388 this->cd(3);
4389 TGraphErrors *ntresBA = GetPn(pull_vs_tb_ba);
4390 ntresBA->SetLineColor(kRed);
4391 ntresBA->SetMarkerColor(kRed);
4392 TGraphErrors *ntresBC = GetPn(pull_vs_tb_bc);
4393 ntresBC->SetLineColor(kBlue);
4394 ntresBC->SetMarkerColor(kBlue);
4395 TGraphErrors *ntresEA = GetPn(pull_vs_tb_ea);
4396 ntresEA->SetLineColor(kGreen);
4397 ntresEA->SetMarkerColor(kGreen);
4398 TGraphErrors *ntresEC = GetPn(pull_vs_tb_ec);
4399 ntresEC->SetLineColor(kYellow);
4400 ntresEC->SetMarkerColor(kYellow);
4401 ntresEA->SetTitle("Number of hits VS Drift Time. Pt>2GeV");
4402 ntresEA->GetXaxis()->SetTitle("Drift Time");
4403 ntresEA->GetYaxis()->SetTitle(" hits ");
4404 ntresEA->Draw("ALP");
4405 ntresEC->Draw("LP");
4406 ntresBA->Draw("LP");
4407 ntresBC->Draw("LP");
4408
4409 this->cd(4);
4410 TGraphErrors *terrorsTRT = GetMean(trackerrors_vs_tb_trt);
4411 TGraphErrors *terrorsBA = GetMean(trackerrors_vs_tb_ba);
4412 terrorsBA->SetLineColor(kRed);
4413 terrorsBA->SetMarkerColor(kRed);
4414 TGraphErrors *terrorsBC = GetMean(trackerrors_vs_tb_bc);
4415 terrorsBC->SetLineColor(kBlue);
4416 terrorsBC->SetMarkerColor(kBlue);
4417 TGraphErrors *terrorsEA = GetMean(trackerrors_vs_tb_ea);
4418 terrorsEA->SetLineColor(kGreen);
4419 terrorsEA->SetMarkerColor(kGreen);
4420 TGraphErrors *terrorsEC = GetMean(trackerrors_vs_tb_ec);
4421 terrorsEC->SetLineColor(kYellow);
4422 terrorsEC->SetMarkerColor(kYellow);
4423 terrorsTRT->SetTitle("Track Error VS Drift Time");
4424 terrorsTRT->GetXaxis()->SetTitle("Drift Time");
4425 terrorsTRT->GetYaxis()->SetTitle("mm");
4426 terrorsTRT->GetYaxis()->SetRangeUser(0.0, 0.07);
4427 terrorsTRT->Draw("ALP");
4428 terrorsBA->Draw("LP");
4429 terrorsBC->Draw("LP");
4430 terrorsEA->Draw("LP");
4431 terrorsEC->Draw("LP");
4432
4433 this->cd(5);
4434 TGraphErrors *residualTRT = GetWidth(residual_vs_tb_trt);
4435 TGraphErrors *residualBA = GetWidth(residual_vs_tb_ba);
4436 residualBA->SetLineColor(kRed);
4437 residualBA->SetMarkerColor(kRed);
4438 TGraphErrors *residualBC = GetWidth(residual_vs_tb_bc);
4439 residualBC->SetLineColor(kBlue);
4440 residualBC->SetMarkerColor(kBlue);
4441 TGraphErrors *residualEA = GetWidth(residual_vs_tb_ea);
4442 residualEA->SetLineColor(kGreen);
4443 residualEA->SetMarkerColor(kGreen);
4444 TGraphErrors *residualEC = GetWidth(residual_vs_tb_ec);
4445 residualEC->SetLineColor(kYellow);
4446 residualEC->SetMarkerColor(kYellow);
4447 residualTRT->SetTitle("Residual VS Drift Time. Pt > 2GeV");
4448 residualTRT->GetXaxis()->SetTitle("Drift Time ");
4449 residualTRT->GetYaxis()->SetTitle("mm");
4450 residualTRT->GetYaxis()->SetRangeUser(0.05, 0.24);
4451 residualTRT->Draw("ALP");
4452 residualBA->Draw("LP");
4453 residualBC->Draw("LP");
4454 residualEA->Draw("LP");
4455 residualEC->Draw("LP");
4456
4457 this->cd(6);
4458
4459 TH2F *residual_trt = (TH2F *)errors->FindKey("tresidual_trt")->ReadObj();
4460 TH2F *residual_ba = (TH2F *)errors->FindKey("tresidual_ba")->ReadObj();
4461 TH2F *residual_bc = (TH2F *)errors->FindKey("tresidual_bc")->ReadObj();
4462 TH2F *residual_ea = (TH2F *)errors->FindKey("tresidual_ea")->ReadObj();
4463 TH2F *residual_ec = (TH2F *)errors->FindKey("tresidual_ec")->ReadObj();
4464
4465 TH2F *residual_trtP = (TH2F *)errors->FindKey("tresidual_trtP")->ReadObj();
4466 TH2F *residual_baP = (TH2F *)errors->FindKey("tresidual_baP")->ReadObj();
4467 TH2F *residual_bcP = (TH2F *)errors->FindKey("tresidual_bcP")->ReadObj();
4468 TH2F *residual_eaP = (TH2F *)errors->FindKey("tresidual_eaP")->ReadObj();
4469 TH2F *residual_ecP = (TH2F *)errors->FindKey("tresidual_ecP")->ReadObj();
4470
4471 TGraphErrors *residualTRT1 = GetEntries(residual_trt);
4472 TGraphErrors *residualBA1 = GetEntries(residual_ba);
4473 residualBA1->SetLineColor(kRed);
4474 residualBA1->SetMarkerColor(kRed);
4475 TGraphErrors *residualBC1 = GetEntries(residual_bc);
4476 residualBC1->SetLineColor(kBlue);
4477 residualBC1->SetMarkerColor(kBlue);
4478 TGraphErrors *residualEA1 = GetEntries(residual_ea);
4479 residualEA1->SetLineColor(kGreen);
4480 residualEA1->SetMarkerColor(kGreen);
4481 TGraphErrors *residualEC1 = GetEntries(residual_ec);
4482 residualEC1->SetLineColor(kYellow);
4483 residualEC1->SetMarkerColor(kYellow);
4484
4485 TGraphErrors *residualTRT2 = GetEntries(residual_trtP);
4486 TGraphErrors *residualBA2 = GetEntries(residual_baP);
4487 residualBA2->SetLineColor(kRed);
4488 residualBA2->SetMarkerColor(kRed);
4489 TGraphErrors *residualBC2 = GetEntries(residual_bcP);
4490 residualBC2->SetLineColor(kBlue);
4491 residualBC2->SetMarkerColor(kBlue);
4492 TGraphErrors *residualEA2 = GetEntries(residual_eaP);
4493 residualEA2->SetLineColor(kGreen);
4494 residualEA2->SetMarkerColor(kGreen);
4495 TGraphErrors *residualEC2 = GetEntries(residual_ecP);
4496 residualEC2->SetLineColor(kYellow);
4497 residualEC2->SetMarkerColor(kYellow);
4498
4499 int nbins = residualTRT1->GetN();
4500
4501 TGraphErrors *ratioTRT = new TGraphErrors(nbins);
4502 TGraphErrors *ratioBA = new TGraphErrors(nbins);
4503 TGraphErrors *ratioBC = new TGraphErrors(nbins);
4504 TGraphErrors *ratioEA = new TGraphErrors(nbins);
4505 TGraphErrors *ratioEC = new TGraphErrors(nbins);
4506
4507 for (int i = 0; i < nbins; i++)
4508 {
4509 double prec = 0;
4510 double all = 0;
4511 double x = 0;
4512 residualTRT1->GetPoint(i, x, all);
4513 residualTRT2->GetPoint(i, x, prec);
4514 cout << i << " " << x << " " << prec << " " << all << endl;
4515 if (all > 0)
4516 {
4517 ratioTRT->SetPoint(i, x, prec / all);
4518 }
4519 else
4520 {
4521 ratioTRT->SetPoint(i, x, 0);
4522 }
4523 residualBA1->GetPoint(i, x, all);
4524 residualBA2->GetPoint(i, x, prec);
4525 cout << i << " " << x << " " << prec << " " << all << endl;
4526 if (all > 0)
4527 {
4528 ratioBA->SetPoint(i, x, prec / all);
4529 }
4530 else
4531 {
4532 ratioBA->SetPoint(i, x, 0);
4533 }
4534
4535 residualBC1->GetPoint(i, x, all);
4536 residualBC2->GetPoint(i, x, prec);
4537 cout << i << " " << x << " " << prec << " " << all << endl;
4538 if (all > 0)
4539 {
4540 ratioBC->SetPoint(i, x, prec / all);
4541 }
4542 else
4543 {
4544 ratioBC->SetPoint(i, x, 0);
4545 }
4546
4547 residualEA1->GetPoint(i, x, all);
4548 residualEA2->GetPoint(i, x, prec);
4549 cout << i << " " << x << " " << prec << " " << all << endl;
4550 if (all > 0)
4551 {
4552 ratioEA->SetPoint(i, x, prec / all);
4553 }
4554 else
4555 {
4556 ratioEA->SetPoint(i, x, 0);
4557 }
4558
4559 residualEC1->GetPoint(i, x, all);
4560 residualEC2->GetPoint(i, x, prec);
4561 cout << i << " " << x << " " << prec << " " << all << endl;
4562 if (all > 0)
4563 {
4564 ratioEC->SetPoint(i, x, prec / all);
4565 }
4566 else
4567 {
4568 ratioEC->SetPoint(i, x, 0);
4569 }
4570 cout << endl;
4571 }
4572
4573 ratioTRT->SetTitle("Ratio Precision Hits Vs Pt. Pt > 2GeV");
4574 ratioTRT->GetXaxis()->SetTitle("Precission Hits/Total Hits ");
4575 ratioTRT->GetYaxis()->SetTitle("pt");
4576 ratioTRT->GetYaxis()->SetRangeUser(0.05, 0.24);
4577 ratioTRT->GetYaxis()->SetRangeUser(0.3, 1);
4578
4579 ratioBA->SetLineColor(kRed);
4580 ratioBC->SetLineColor(kBlue);
4581 ratioEA->SetLineColor(kGreen);
4582 ratioEC->SetLineColor(kYellow);
4583
4584 ratioTRT->Draw("alp");
4585 ratioBA->Draw("lp");
4586 ratioBC->Draw("lp");
4587 ratioEA->Draw("lp");
4588 ratioEC->Draw("lp");
4589 }
4590 else
4591 {
4592 cout << " Not enough keys in Errors directory for tb dependence plots " << endl;
4593 }
4594}
4595
4596class ToTDependence : public TCanvas
4597{
4598public:
4599 ToTDependence(TFile *, bool, bool, bool isAr);
4600
4601private:
4602 TDirectory *m_errors;
4603};
4604
4605ToTDependence::ToTDependence(TFile *file, bool isba = true, bool isht = false, bool isAr = false)
4606{
4607 m_errors = nullptr;
4608 cout << "READING CORRECTIONS: " << endl;
4609
4610 if (!isAr)
4611 m_errors = (TDirectory *)file->FindKey("Correction")->ReadObj();
4612 else
4613 m_errors = (TDirectory *)file->FindKey("CorrectionAr")->ReadObj();
4614
4615 this->Divide(2, 3, 0.01, 0.01);
4616
4617 // Read the histos:
4618
4619 TH2F *tres_vs_ToT_ba = nullptr;
4620 TH2F *tres_vs_ToT_bc = nullptr;
4621 // Residual:
4622 TH2F *res_vs_ToT_ba = nullptr;
4623 TH2F *res_vs_ToT_bc = nullptr;
4624
4625 if (!isAr)
4626 {
4627 if (!isht)
4628 {
4629 if (isba)
4630 {
4631 if (m_errors->FindKey("tres_vs_ToT_ba"))
4632 tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tres_vs_ToT_ba")->ReadObj();
4633 if (m_errors->FindKey("res_vs_ToT_ba"))
4634 res_vs_ToT_ba = (TH2F *)m_errors->FindKey("res_vs_ToT_ba")->ReadObj();
4635 if (m_errors->FindKey("tres_vs_ToT_bc"))
4636 tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tres_vs_ToT_bc")->ReadObj();
4637 if (m_errors->FindKey("res_vs_ToT_bc"))
4638 res_vs_ToT_bc = (TH2F *)m_errors->FindKey("res_vs_ToT_bc")->ReadObj();
4639 }
4640 else
4641 {
4642 if (m_errors->FindKey("tres_vs_ToT_ea"))
4643 tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tres_vs_ToT_ea")->ReadObj();
4644 if (m_errors->FindKey("res_vs_ToT_ea"))
4645 res_vs_ToT_ba = (TH2F *)m_errors->FindKey("res_vs_ToT_ea")->ReadObj();
4646 if (m_errors->FindKey("tres_vs_ToT_ec"))
4647 tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tres_vs_ToT_ec")->ReadObj();
4648 if (m_errors->FindKey("res_vs_ToT_ec"))
4649 res_vs_ToT_bc = (TH2F *)m_errors->FindKey("res_vs_ToT_ec")->ReadObj();
4650 }
4651 }
4652 else
4653 {
4654 if (isba)
4655 {
4656 if (m_errors->FindKey("tres_vs_HT_ba"))
4657 tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tres_vs_HT_ba")->ReadObj();
4658 if (m_errors->FindKey("res_vs_HT_ba"))
4659 res_vs_ToT_ba = (TH2F *)m_errors->FindKey("res_vs_HT_ba")->ReadObj();
4660 if (m_errors->FindKey("tres_vs_HT_bc"))
4661 tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tres_vs_HT_bc")->ReadObj();
4662 if (m_errors->FindKey("res_vs_HT_bc"))
4663 res_vs_ToT_bc = (TH2F *)m_errors->FindKey("res_vs_HT_bc")->ReadObj();
4664 }
4665 else
4666 {
4667 if (m_errors->FindKey("tres_vs_HT_ea"))
4668 tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tres_vs_HT_ea")->ReadObj();
4669 if (m_errors->FindKey("res_vs_HT_ea"))
4670 res_vs_ToT_ba = (TH2F *)m_errors->FindKey("res_vs_HT_ea")->ReadObj();
4671 if (m_errors->FindKey("tres_vs_HT_ec"))
4672 tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tres_vs_HT_ec")->ReadObj();
4673 if (m_errors->FindKey("res_vs_HT_ec"))
4674 res_vs_ToT_bc = (TH2F *)m_errors->FindKey("res_vs_HT_ec")->ReadObj();
4675 }
4676 }
4677 }
4678 else
4679 {
4680 if (!isht)
4681 {
4682 if (isba)
4683 {
4684 if (m_errors->FindKey("tresAr_vs_ToT_ba"))
4685 tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tresAr_vs_ToT_ba")->ReadObj();
4686 if (m_errors->FindKey("resAr_vs_ToT_ba"))
4687 res_vs_ToT_ba = (TH2F *)m_errors->FindKey("resAr_vs_ToT_ba")->ReadObj();
4688 if (m_errors->FindKey("tresAr_vs_ToT_bc"))
4689 tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tresAr_vs_ToT_bc")->ReadObj();
4690 if (m_errors->FindKey("resAr_vs_ToT_bc"))
4691 res_vs_ToT_bc = (TH2F *)m_errors->FindKey("resAr_vs_ToT_bc")->ReadObj();
4692 }
4693 else
4694 {
4695 if (m_errors->FindKey("tresAr_vs_ToT_ea"))
4696 tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tresAr_vs_ToT_ea")->ReadObj();
4697 if (m_errors->FindKey("resAr_vs_ToT_ea"))
4698 res_vs_ToT_ba = (TH2F *)m_errors->FindKey("resAr_vs_ToT_ea")->ReadObj();
4699 if (m_errors->FindKey("tresAr_vs_ToT_ec"))
4700 tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tresAr_vs_ToT_ec")->ReadObj();
4701 if (m_errors->FindKey("resAr_vs_ToT_ec"))
4702 res_vs_ToT_bc = (TH2F *)m_errors->FindKey("resAr_vs_ToT_ec")->ReadObj();
4703 }
4704 }
4705 else
4706 {
4707 if (isba)
4708 {
4709 if (m_errors->FindKey("tresAr_vs_HT_ba"))
4710 tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tresAr_vs_HT_ba")->ReadObj();
4711 if (m_errors->FindKey("resAr_vs_HT_ba"))
4712 res_vs_ToT_ba = (TH2F *)m_errors->FindKey("resAr_vs_HT_ba")->ReadObj();
4713 if (m_errors->FindKey("tresAr_vs_HT_bc"))
4714 tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tresAr_vs_HT_bc")->ReadObj();
4715 if (m_errors->FindKey("resAr_vs_HT_bc"))
4716 res_vs_ToT_bc = (TH2F *)m_errors->FindKey("resAr_vs_HT_bc")->ReadObj();
4717 }
4718 else
4719 {
4720 if (m_errors->FindKey("tresAr_vs_HT_ea"))
4721 tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tresAr_vs_HT_ea")->ReadObj();
4722 if (m_errors->FindKey("resAr_vs_HT_ea"))
4723 res_vs_ToT_ba = (TH2F *)m_errors->FindKey("resAr_vs_HT_ea")->ReadObj();
4724 if (m_errors->FindKey("tresAr_vs_HT_ec"))
4725 tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tresAr_vs_HT_ec")->ReadObj();
4726 if (m_errors->FindKey("resAr_vs_HT_ec"))
4727 res_vs_ToT_bc = (TH2F *)m_errors->FindKey("resAr_vs_HT_ec")->ReadObj();
4728 }
4729 }
4730 }
4731
4732 this->cd(1);
4733 // Time Residual Mean Vs Pt:
4734 TGraphErrors *tresBA = GetMean(tres_vs_ToT_ba);
4735 tresBA->SetLineColor(kRed);
4736 tresBA->SetMarkerColor(kRed);
4737 if (not tres_vs_ToT_ba){
4738 throw std::runtime_error("tres_vs_ToT_ba pointer is null");
4739 }
4740 if (isba)
4741 tres_vs_ToT_ba->SetTitle("Barrel A Time Residual Mean VS ToT");
4742 else
4743 tres_vs_ToT_ba->SetTitle("Endcap A Time Residual Mean VS ToT");
4744 tres_vs_ToT_ba->GetXaxis()->SetTitle("ToT (bin)");
4745 tres_vs_ToT_ba->GetYaxis()->SetTitle("Time Residual (ns)");
4746
4747 if (isht){
4748 if (isba){
4749 tres_vs_ToT_ba->SetTitle("Barrel A Time Residual Mean VS HT");
4750 }else{
4751 tres_vs_ToT_ba->SetTitle("Endcap A Time Residual Mean VS HT");}
4752 tres_vs_ToT_ba->GetXaxis()->SetTitle("HT (bin)");
4753 }
4754
4755 tres_vs_ToT_ba->Draw("colz");
4756 tresBA->Draw("same");
4757
4758 this->cd(3);
4759 TGraphErrors *tresBC = GetMean(tres_vs_ToT_bc);
4760 tresBC->SetLineColor(kBlue);
4761 tresBC->SetMarkerColor(kBlue);
4762 if (isba){
4763 if (not tres_vs_ToT_bc){
4764 throw std::runtime_error(" tres_vs_ToT_bc is null");
4765 }
4766 tres_vs_ToT_bc->SetTitle("Barrel C Time Residual Mean VS ToT");
4767 }else{
4768 tres_vs_ToT_bc->SetTitle("Endcap C Time Residual Mean VS ToT");}
4769 tres_vs_ToT_bc->GetXaxis()->SetTitle("ToT (bin)");
4770 tres_vs_ToT_bc->GetYaxis()->SetTitle("Time Residual (ns)");
4771 if (isht){
4772 if (isba){
4773 tres_vs_ToT_bc->SetTitle("Barrel C Time Residual Mean VS HT");
4774 }else{
4775 tres_vs_ToT_bc->SetTitle("Endcap C Time Residual Mean VS HT");
4776 }
4777 tres_vs_ToT_bc->GetXaxis()->SetTitle("HT (bin)");
4778 }
4779
4780 tres_vs_ToT_bc->Draw("colz");
4781 tresBC->Draw("same");
4782
4783 this->cd(5);
4784 tresBA->SetTitle("Barrel Time Residual Mean vs ToT");
4785 if (!isba)
4786 tresBA->SetTitle("Endcap Time Residual Mean vs ToT");
4787 tresBA->GetXaxis()->SetTitle("ToT (bin)");
4788
4789 if (isht)
4790 {
4791 tresBA->SetTitle("Barrel Time Residual Mean vs HT");
4792 if (!isba)
4793 tresBA->SetTitle("Endcap Time Residual Mean vs HT");
4794 tresBA->GetXaxis()->SetTitle("HT");
4795 }
4796 tresBA->GetXaxis()->SetRangeUser(-0.5, 23.5);
4797 tresBA->GetYaxis()->SetRangeUser(-10, 10);
4798 if (isht)
4799 {
4800 tresBA->GetXaxis()->SetRangeUser(-0.5, 1.5);
4801 tresBA->GetYaxis()->SetRangeUser(-3, 3);
4802 }
4803 tresBA->Draw("alp");
4804 tresBC->Draw("same");
4805
4806 this->cd(2);
4807 TGraphErrors *resBA1 = GetMean(res_vs_ToT_ba);
4808 resBA1->SetLineColor(kRed);
4809 resBA1->SetMarkerColor(kRed);
4810 if (not res_vs_ToT_ba){
4811 throw std::runtime_error("res_vs_ToT_ba is null ptr");
4812 }
4813 if (isba)
4814 res_vs_ToT_ba->SetTitle("Barrel A Residual Mean VS ToT");
4815 else
4816 res_vs_ToT_ba->SetTitle("Endcap A Residual Mean VS ToT");
4817 res_vs_ToT_ba->GetXaxis()->SetTitle("ToT (bin)");
4818 res_vs_ToT_ba->GetYaxis()->SetTitle("Residual (mm)");
4819 if (isht)
4820 {
4821 if (isba)
4822 res_vs_ToT_ba->SetTitle("Barrel A Residual Mean VS HT");
4823 else
4824 res_vs_ToT_ba->SetTitle("Endcap A Residual Mean VS HT");
4825 res_vs_ToT_ba->GetXaxis()->SetTitle("HT (bin)");
4826 }
4827 res_vs_ToT_ba->Draw("colz");
4828 resBA1->Draw("same");
4829
4830 this->cd(4);
4831 TGraphErrors *resBC1 = GetMean(res_vs_ToT_bc);
4832 resBC1->SetLineColor(kBlue);
4833 resBC1->SetMarkerColor(kBlue);
4834 if (isba)
4835 res_vs_ToT_bc->SetTitle("Barrel C Residual Mean VS ToT");
4836 else
4837 res_vs_ToT_bc->SetTitle("Endcap C Residual Mean VS ToT");
4838 res_vs_ToT_bc->GetXaxis()->SetTitle("ToT (bin)");
4839 res_vs_ToT_bc->GetYaxis()->SetTitle("Residual (mm)");
4840 if (isht)
4841 {
4842 if (isba)
4843 res_vs_ToT_bc->SetTitle("Barrel C Residual Mean VS HT");
4844 else
4845 res_vs_ToT_bc->SetTitle("Endcap C Residual Mean VS HT");
4846 res_vs_ToT_bc->GetXaxis()->SetTitle("HT (bin)");
4847 }
4848 res_vs_ToT_bc->Draw("colz");
4849 resBC1->Draw("same");
4850
4851 this->cd(6);
4852
4853 TGraphErrors *resBA = GetWidth(res_vs_ToT_ba);
4854 resBA->SetLineColor(kRed);
4855 resBA->SetMarkerColor(kRed);
4856 TGraphErrors *resBC = GetWidth(res_vs_ToT_bc);
4857 resBC->SetLineColor(kBlue);
4858 resBC->SetMarkerColor(kBlue);
4859 resBA->SetTitle("Barrel Time Residual Width vs ToT");
4860 if (!isba)
4861 resBA->SetTitle("Endcap Time Residual Width vs ToT");
4862 resBA->GetXaxis()->SetTitle("ToT (bin)");
4863
4864 if (isht)
4865 {
4866 resBA->SetTitle("Barrel Residual Width vs HT");
4867 if (!isba)
4868 resBA->SetTitle("Endcap Residual Width vs HT");
4869 resBA->GetXaxis()->SetTitle("HT");
4870 }
4871 resBA->GetXaxis()->SetRangeUser(-0.5, 23.5);
4872 resBA->GetYaxis()->SetRangeUser(0.08, 0.2);
4873 if (isht)
4874 {
4875 resBA->GetXaxis()->SetRangeUser(-0.5, 1.5);
4876 resBA->GetYaxis()->SetRangeUser(0.08, 0.2);
4877 }
4878 resBA->Draw("alp");
4879 resBC->Draw("same");
4880}
4881
4882class SinDependence : public TCanvas
4883{
4884public:
4885 SinDependence(TFile *, bool, bool, bool);
4886
4887private:
4888 TDirectory *m_errors;
4889};
4890
4891SinDependence::SinDependence(TFile *file, bool isba = true, bool isht = false, bool isAr = false)
4892{
4893 m_errors = nullptr;
4894
4895 if (!isAr)
4896 m_errors = (TDirectory *)file->FindKey("Correction")->ReadObj();
4897 else
4898 m_errors = (TDirectory *)file->FindKey("CorrectionAr")->ReadObj();
4899 if (!m_errors)
4900 throw(string("No errors folder!!!!!!!!!!!!!!!"));
4901
4902 this->Divide(2, 3, 0.01, 0.01);
4903
4904 // Read the histos:
4905
4906 TH2F *tres_vs_ToT_ba = nullptr;
4907 TH2F *tres_vs_ToT_bc = nullptr;
4908 // Residual:
4909 TH2F *res_vs_ToT_ba = nullptr;
4910 TH2F *res_vs_ToT_bc = nullptr;
4911
4912 if (!isAr)
4913 {
4914 if (!isht)
4915 {
4916 if (isba)
4917 { // sin
4918 tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tres_vs_SinOverP_bc")->ReadObj();
4919 res_vs_ToT_ba = (TH2F *)m_errors->FindKey("res_vs_SinOverP_ba")->ReadObj();
4920 tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tres_vs_SinOverP_bc")->ReadObj();
4921 res_vs_ToT_bc = (TH2F *)m_errors->FindKey("res_vs_SinOverP_bc")->ReadObj();
4922 }
4923 else
4924 {
4925 tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tres_vs_SinOverP_ea")->ReadObj();
4926 res_vs_ToT_ba = (TH2F *)m_errors->FindKey("res_vs_SinOverP_ea")->ReadObj();
4927 tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tres_vs_SinOverP_ec")->ReadObj();
4928 res_vs_ToT_bc = (TH2F *)m_errors->FindKey("res_vs_SinOverP_ec")->ReadObj();
4929 }
4930 }
4931 else
4932 {
4933 if (isba)
4934 { // cos
4935 tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tres_vs_CosOverP_bc")->ReadObj();
4936 res_vs_ToT_ba = (TH2F *)m_errors->FindKey("res_vs_CosOverP_ba")->ReadObj();
4937 tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tres_vs_CosOverP_bc")->ReadObj();
4938 res_vs_ToT_bc = (TH2F *)m_errors->FindKey("res_vs_CosOverP_bc")->ReadObj();
4939 }
4940 else
4941 {
4942 tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tres_vs_CosOverP_ea")->ReadObj();
4943 res_vs_ToT_ba = (TH2F *)m_errors->FindKey("res_vs_CosOverP_ea")->ReadObj();
4944 tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tres_vs_CosOverP_ec")->ReadObj();
4945 res_vs_ToT_bc = (TH2F *)m_errors->FindKey("res_vs_CosOverP_ec")->ReadObj();
4946 }
4947 }
4948 }
4949 else
4950 {
4951 if (!isht)
4952 {
4953 if (isba)
4954 { // sin
4955 tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tresAr_vs_SinOverP_bc")->ReadObj();
4956 res_vs_ToT_ba = (TH2F *)m_errors->FindKey("resAr_vs_SinOverP_ba")->ReadObj();
4957 tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tresAr_vs_SinOverP_bc")->ReadObj();
4958 res_vs_ToT_bc = (TH2F *)m_errors->FindKey("resAr_vs_SinOverP_bc")->ReadObj();
4959 }
4960 else
4961 {
4962 tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tresAr_vs_SinOverP_ea")->ReadObj();
4963 res_vs_ToT_ba = (TH2F *)m_errors->FindKey("resAr_vs_SinOverP_ea")->ReadObj();
4964 tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tresAr_vs_SinOverP_ec")->ReadObj();
4965 res_vs_ToT_bc = (TH2F *)m_errors->FindKey("resAr_vs_SinOverP_ec")->ReadObj();
4966 }
4967 }
4968 else
4969 {
4970 if (isba)
4971 { // cos
4972 tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tresAr_vs_CosOverP_bc")->ReadObj();
4973 res_vs_ToT_ba = (TH2F *)m_errors->FindKey("resAr_vs_CosOverP_ba")->ReadObj();
4974 tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tresAr_vs_CosOverP_bc")->ReadObj();
4975 res_vs_ToT_bc = (TH2F *)m_errors->FindKey("resAr_vs_CosOverP_bc")->ReadObj();
4976 }
4977 else
4978 {
4979 tres_vs_ToT_ba = (TH2F *)m_errors->FindKey("tresAr_vs_CosOverP_ea")->ReadObj();
4980 res_vs_ToT_ba = (TH2F *)m_errors->FindKey("resAr_vs_CosOverP_ea")->ReadObj();
4981 tres_vs_ToT_bc = (TH2F *)m_errors->FindKey("tresAr_vs_CosOverP_ec")->ReadObj();
4982 res_vs_ToT_bc = (TH2F *)m_errors->FindKey("resAr_vs_CosOverP_ec")->ReadObj();
4983 }
4984 }
4985 }
4986
4987 this->cd(1);
4988 // Time Residual Mean Vs Pt:
4989 TGraphErrors *tresBA = GetMean(tres_vs_ToT_ba);
4990 tresBA->SetLineColor(kRed);
4991 tresBA->SetMarkerColor(kRed);
4992 if (isba)
4993 tres_vs_ToT_ba->SetTitle("Barrel A Time Residual Mean VS sin(Theta)/p");
4994 else
4995 tres_vs_ToT_ba->SetTitle("Endcap A Time Residual Mean VS sin(Theta)/p");
4996 tres_vs_ToT_ba->GetXaxis()->SetTitle("sin(Theta)/p");
4997 tres_vs_ToT_ba->GetYaxis()->SetTitle("Time Residual (ns)");
4998
4999 if (isht)
5000 {
5001 if (isba)
5002 tres_vs_ToT_ba->SetTitle("Barrel A Time Residual Mean VS cos(Theta)/p");
5003 else
5004 tres_vs_ToT_ba->SetTitle("Endcap A Time Residual Mean VS cos(Theta)/p");
5005 tres_vs_ToT_ba->GetXaxis()->SetTitle("cos(Theta)/p");
5006 }
5007
5008 tres_vs_ToT_ba->Draw("colz");
5009 tresBA->Draw("same");
5010
5011 this->cd(3);
5012 TGraphErrors *tresBC = GetMean(tres_vs_ToT_bc);
5013 tresBC->SetLineColor(kBlue);
5014 tresBC->SetMarkerColor(kBlue);
5015 if (isba)
5016 tres_vs_ToT_bc->SetTitle("Barrel C Time Residual Mean VS sin(Theta)/p");
5017 else
5018 tres_vs_ToT_bc->SetTitle("Endcap C Time Residual Mean VS sin(Theta)/p");
5019 tres_vs_ToT_bc->GetXaxis()->SetTitle("sin(Theta)/p");
5020 tres_vs_ToT_bc->GetYaxis()->SetTitle("Time Residual (ns)");
5021 if (isht)
5022 {
5023 if (isba)
5024 tres_vs_ToT_bc->SetTitle("Barrel C Time Residual Mean VS cos(Theta)/p");
5025 else
5026 tres_vs_ToT_bc->SetTitle("Endcap C Time Residual Mean VS cos(Theta)/p");
5027 tres_vs_ToT_bc->GetXaxis()->SetTitle("cos(Theta)/p");
5028 }
5029 tres_vs_ToT_bc->Draw("colz");
5030 tresBC->Draw("same");
5031
5032 this->cd(5);
5033 tresBA->SetTitle("Barrel Time Residual Mean vs Sin(theta) / p");
5034 if (!isba)
5035 tresBA->SetTitle("Endcap Time Residual Mean vs Sin(theta) / p");
5036
5037 if (isht)
5038 {
5039 tresBA->SetTitle("Barrel Time Residual Mean vs Cos(theta) / p");
5040 if (!isba)
5041 tresBA->SetTitle("Endcap Time Residual Mean vs Cos(theta) / p");
5042 }
5043
5044 tresBA->GetXaxis()->SetRangeUser(0, 1);
5045 tresBA->GetYaxis()->SetRangeUser(-1, 1.5);
5046 tresBA->Draw("alp");
5047 tresBC->Draw("same");
5048
5049 this->cd(2);
5050 TGraphErrors *resBA1 = GetMean(res_vs_ToT_ba);
5051 resBA1->SetLineColor(kRed);
5052 resBA1->SetMarkerColor(kRed);
5053 if (isba)
5054 res_vs_ToT_ba->SetTitle("Barrel A Residual Mean VS sin(Theta)/p");
5055 else
5056 res_vs_ToT_ba->SetTitle("Endcap A Residual Mean VS sin(Theta)/p");
5057 res_vs_ToT_ba->GetXaxis()->SetTitle("sin(Theta)/p");
5058 res_vs_ToT_ba->GetYaxis()->SetTitle("Residual (mm)");
5059 if (isht)
5060 {
5061 if (isba)
5062 res_vs_ToT_ba->SetTitle("Barrel A Residual Mean VS cos(Theta)/p");
5063 else
5064 res_vs_ToT_ba->SetTitle("Endcap A Residual Mean VS cos(Theta)/p");
5065 res_vs_ToT_ba->GetXaxis()->SetTitle("cos(Theta)/p");
5066 }
5067 res_vs_ToT_ba->Draw("colz");
5068 resBA1->Draw("same");
5069
5070 this->cd(4);
5071 TGraphErrors *resBC1 = GetMean(res_vs_ToT_bc);
5072 resBC1->SetLineColor(kBlue);
5073 resBC1->SetMarkerColor(kBlue);
5074 if (isba)
5075 res_vs_ToT_bc->SetTitle("Barrel C Residual Mean VS sin(Theta)/p");
5076 else
5077 res_vs_ToT_bc->SetTitle("Endcap C Residual Mean VS sin(Theta)/p");
5078 res_vs_ToT_bc->GetXaxis()->SetTitle("sin(Theta)/p");
5079 res_vs_ToT_bc->GetYaxis()->SetTitle("Residual (mm)");
5080 if (isht)
5081 {
5082 if (isba)
5083 res_vs_ToT_bc->SetTitle("Barrel C Residual Mean VS cos(Theta)/p");
5084 else
5085 res_vs_ToT_bc->SetTitle("Endcap C Residual Mean VS cos(Theta)/p");
5086 res_vs_ToT_bc->GetXaxis()->SetTitle("cos(Theta)/p");
5087 }
5088 res_vs_ToT_bc->Draw("colz");
5089 resBC1->Draw("same");
5090
5091 this->cd(6);
5092
5093 TGraphErrors *resBA = GetWidth(res_vs_ToT_ba);
5094 resBA->SetLineColor(kRed);
5095 resBA->SetMarkerColor(kRed);
5096 TGraphErrors *resBC = GetWidth(res_vs_ToT_bc);
5097 resBC->SetLineColor(kBlue);
5098 resBC->SetMarkerColor(kBlue);
5099 resBA->SetTitle("Barrel Residual Width vs Sin(theta) / p");
5100 if (!isba)
5101 resBA->SetTitle("Endcap Residual Widht vs Sin(theta) / p");
5102
5103 if (isht)
5104 {
5105 resBA->SetTitle("Barrel Residual Width vs Cos(theta) / p");
5106 if (!isba)
5107 resBA->SetTitle("Endcap Residual Widht vs Cos(theta) / p");
5108 }
5109
5110 resBA->GetXaxis()->SetRangeUser(0, 1);
5111 resBA->GetYaxis()->SetRangeUser(0.08, 0.20);
5112 resBA->Draw("alp");
5113 resBC->Draw("same");
5114}
5115
5116//================================================================
5117//================================================================
5118
5119int itersum (int argc, char *argv[])
5120{
5121
5122 string inputfile = string(argv[2]);
5123 TFile *datafile = new TFile(argv[2]);
5124 if (datafile->IsZombie())
5125 {
5126 cout << "ERROR! INPUT FILE DOES NOT EXIST!" << endl;
5127 exit(-1);
5128 }
5129
5130 bool isAr = false;
5131 if (datafile->FindKey("TRT_Ar_all"))
5132 {
5133 isAr = true;
5134 cout << " This run contains straws with Argon" << endl;
5135 }
5136 if (!datafile->FindKey("Chip_Artuple"))
5137 {
5138 isAr = false;
5139 cout << " This run contains does not have Argon ntuples" << endl;
5140 }
5141
5142 // Here we have to do the fix, because the trees are duplicated
5143
5144 TFile *refdatafile;
5145 bool useref = false;
5146 if (argc > 4)
5147 {
5148 useref = true;
5149 refdatafile = new TFile(argv[4]);
5150 if (refdatafile->IsZombie())
5151 {
5152 cout << "INPUT REFERENCE FILE DOES NOT EXIST! RUNNING WITHOUT IT!" << endl;
5153 useref = false;
5154 }
5155 else
5156 cout << "INPUT REFERENCE FILE OK!" << endl;
5157 }
5158
5159 // First page on Shifter report, general information
5160 cout << "MAKING FirstPage" << endl;
5161 FirstPage *firstpage = nullptr;
5162 try
5163 {
5164 firstpage = new FirstPage(argv[2], datafile);
5165 }
5166 catch (string e)
5167 {
5168 cout << e << endl;
5169 }
5170
5171 // Add a page with the settings:
5172 cout << "MAKING Settings" << endl;
5173 SettingsInfo *settings = nullptr;
5174 // if (argv[3]) try { settings = new SettingsInfo(argv[3]); } catch (string e) { cout << e << endl; }
5175
5176 // Tracktuple info
5177 cout << "MAKING TracktupleInfo" << endl;
5178 TrackTupleInfo *tracktupleinfo = nullptr;
5179 try
5180 {
5181 tracktupleinfo = new TrackTupleInfo(datafile);
5182 }
5183 catch (string e)
5184 {
5185 cout << e << endl;
5186 }
5187
5188 // Hit statistics
5189 HitStatistics *hitstat = nullptr;
5190 cout << "MAKING HitStatistics" << endl;
5191 hitstat = new HitStatistics(argv[2]);
5192
5193 HitStatistics *hitstatAr = nullptr;
5194 if (isAr)
5195 {
5196 cout << "MAKING Ar HitStatistics" << endl;
5197 hitstatAr = new HitStatistics(argv[2], true);
5198 }
5199
5200 // TRT Global Results:
5201 cout << "MAKING TRTPlots" << endl;
5202 // SERGI - What is the purpose of the lines commented below? (TRTPlots *TRTresplots and *TRTresplotsAr are not used at anywhere)
5203 // TRTPlots *TRTresplots = nullptr;
5204 // try
5205 // {
5206 // TRTresplots = new TRTPlots(datafile);
5207 // }
5208 // catch (string e)
5209 // {
5210 // cout << e << endl;
5211 // }
5212 // TRTPlots *TRTresplotsAr = nullptr;
5213 if (isAr)
5214 // try
5215 // {
5216 // TRTresplotsAr = new TRTPlots(datafile, true);
5217 // }
5218 // catch (string e)
5219 // {
5220 // cout << e << endl;
5221 // }
5222
5223 // Residual and time residual (TRT and both barrels)
5224 cout << "MAKING ResidualPlots" << endl;
5225 ResidualPlots *resplots = nullptr;
5226 try
5227 {
5228 resplots = new ResidualPlots(datafile);
5229 }
5230 catch (string e)
5231 {
5232 cout << e << endl;
5233 }
5234 ResidualPlots *resplotsAr = nullptr;
5235 if (isAr)
5236 try
5237 {
5238 resplotsAr = new ResidualPlots(datafile, true);
5239 }
5240 catch (string e)
5241 {
5242 cout << e << endl;
5243 }
5244
5245 // Do t0 calibration type:
5246 cout << "MAKING T0CalibTypeXY" << endl;
5247 T0CalibTypeXY *hitstatxy = new T0CalibTypeXY(argv[2]);
5248 T0CalibTypeXY *hitstatxyAr = nullptr;
5249 if (isAr)
5250 hitstatxyAr = new T0CalibTypeXY(argv[2], true);
5251
5252 // Do hits plots:
5253 cout << "MAKING XYMaps(nt0)" << endl;
5254 XYMaps *nhits = new XYMaps(argv[2], "nt0");
5255 XYMaps *nhitsAr = nullptr;
5256 if (isAr)
5257 nhitsAr = new XYMaps(argv[2], "nt0", true);
5258 // Do res plot:
5259 cout << "MAKING XYMaps(res)" << endl;
5260 XYMaps *resxy0 = new XYMaps(argv[2], "res");
5261 XYMaps *resxy0Ar = nullptr;
5262 if (isAr)
5263 resxy0Ar = new XYMaps(argv[2], "res", true);
5264 // Do residual center plot:
5265 cout << "MAKING XYMaps(resmean)" << endl;
5266 XYMaps *resxy = new XYMaps(argv[2], "abs(resMean)");
5267 XYMaps *resxyAr = nullptr;
5268 if (isAr)
5269 resxyAr = new XYMaps(argv[2], "abs(resMean)", true);
5270 // Do t0s plots:
5271 cout << "MAKING XYMaps(t0)" << endl;
5272 XYMaps *xymap = new XYMaps(argv[2], "t0");
5273 XYMaps *xymapAr = nullptr;
5274 if (isAr)
5275 xymapAr = new XYMaps(argv[2], "t0", true);
5276 // Do Oldt0plots:
5277 cout << "MAKING XYMaps(oldt0)" << endl;
5278 XYMaps *oldt0 = new XYMaps(argv[2], "oldt0");
5279 XYMaps *oldt0Ar = nullptr;
5280 if (isAr)
5281 oldt0Ar = new XYMaps(argv[2], "oldt0", true);
5282 // Do t0 diff:
5283 cout << "MAKING XYMaps(t0-oldt0)" << endl;
5284 XYMaps *oldt01 = new XYMaps(argv[2], "abs(t0-oldt0)");
5285 XYMaps *oldt01Ar = nullptr;
5286 if (isAr)
5287 oldt01Ar = new XYMaps(argv[2], "abs(t0-oldt0)", true); // changed from t0-old-t0
5288 // Do t0 diff mean:
5289 cout << "MAKING XYMaps(tresMean)" << endl;
5290 XYMaps *oldt0111 = new XYMaps(argv[2], "abs(tresMean)");
5291 XYMaps *oldt0111Ar = nullptr;
5292 if (isAr)
5293 oldt0111Ar = new XYMaps(argv[2], "abs(tresMean)", true);
5294 // Do t0 width:
5295 cout << "MAKING XYMaps(tres)" << endl;
5296 XYMaps *oldt011 = new XYMaps(argv[2], "(tres)");
5297 XYMaps *oldt011Ar = nullptr;
5298 if (isAr)
5299 oldt011Ar = new XYMaps(argv[2], "(tres)", true);
5300
5301 // Add the plot for Chip T0 (board offset) variations
5302 ChipVariations *chipgraphA = nullptr;
5303 ChipVariations *chipgraphC = nullptr;
5304 if (datafile->FindKey("TRT_all"))
5305 {
5306 cout << "MAKING ChipVariations" << endl;
5307 chipgraphA = new ChipVariations(argv[2], 1);
5308 chipgraphC = new ChipVariations(argv[2], -1);
5309 }
5310
5311 // Add the plot for Board T0 variations
5312 BoardVariationsOldT0 *refboardgraphA = nullptr;
5313 BoardVariationsOldT0 *refboardgraphC = nullptr;
5314 BoardVariationsDiff *boarddiffgraphA = nullptr;
5315 BoardVariationsDiff *boarddiffgraphC = nullptr;
5316 if (useref)
5317 {
5318 cout << "MAKING BoardVariationsOldT0" << endl;
5319 refboardgraphA = new BoardVariationsOldT0(argv[4], 1);
5320 refboardgraphC = new BoardVariationsOldT0(argv[4], -1);
5321 refboardgraphA->SetLineColor(2);
5322 refboardgraphC->SetLineColor(2);
5323 cout << "MAKING BoardVariationsDiff" << endl;
5324 boarddiffgraphA = new BoardVariationsDiff(argv[2], argv[4], 1);
5325 boarddiffgraphC = new BoardVariationsDiff(argv[2], argv[4], -1);
5326 }
5327 // Add the plot for Board T0 variations
5328 cout << "MAKING BoardVariations" << endl;
5329 BoardVariations *boardgraphA = new BoardVariations(argv[2], 1);
5330 BoardVariations *boardgraphC = new BoardVariations(argv[2], -1);
5331 // Add the plot for the residual
5332 cout << "MAKING BoardVariationsRes" << endl;
5333 BoardVariationsRes *boardgraphA1 = new BoardVariationsRes(argv[2], 1);
5334 BoardVariationsRes *boardgraphC1 = new BoardVariationsRes(argv[2], -1);
5335 // Add the plot for the Time residual
5336 cout << "MAKING BoardVariationsTRes" << endl;
5337 BoardVariationsTRes *boardgraphA2 = new BoardVariationsTRes(argv[2], 1);
5338 BoardVariationsTRes *boardgraphC2 = new BoardVariationsTRes(argv[2], -1);
5339 // Add the plot for the sigma Time residual
5340 cout << "MAKING BoardVariationsTRes1" << endl;
5341 BoardVariationsTRes1 *boardgraphA3 = new BoardVariationsTRes1(argv[2], 1);
5342 BoardVariationsTRes1 *boardgraphC3 = new BoardVariationsTRes1(argv[2], -1);
5343
5344 // RtGraphs* rtrelation11=nullptr;
5345 RtGraphs *rtrelation_bar = nullptr;
5346 RtGraphs *rtrelation21 = nullptr;
5347 RtGraphs *rtrelation31 = nullptr;
5348 RtGraphs *rtrelation41 = nullptr;
5349 RtGraphs *rtrelation51 = nullptr;
5350 RtBinning *rtbinning_bar = nullptr;
5351 RtBinning *rtbinning1 = nullptr;
5352 RtBinning *rtbinning2 = nullptr;
5353 RtBinning *rtbinning3 = nullptr;
5354 RtBinning *rtbinning4 = nullptr;
5355 if (datafile->FindKey("TRT_all"))
5356 {
5357 cout << "MAKING RtGraphs" << endl;
5358 TDirectory *trt = (TDirectory *)datafile->FindKey("TRT_all")->ReadObj();
5359
5360 if (trt->FindKey("WholeBarrel_1"))
5361 {
5362 try
5363 {
5364 rtrelation_bar = new RtGraphs(argv[2], "WholeBarrel_1");
5365 }
5366 catch (string e)
5367 {
5368 cout << e << endl;
5369 }
5370 }
5371 if (trt->FindKey("Detector_-1"))
5372 {
5373 try
5374 {
5375 rtrelation21 = new RtGraphs(argv[2], "Detector_-1");
5376 }
5377 catch (string e)
5378 {
5379 cout << e << endl;
5380 }
5381 }
5382 if (trt->FindKey("Detector_1"))
5383 {
5384 try
5385 {
5386 rtrelation31 = new RtGraphs(argv[2], "Detector_1");
5387 }
5388 catch (string e)
5389 {
5390 cout << e << endl;
5391 }
5392 }
5393 if (trt->FindKey("Detector_-2"))
5394 {
5395 try
5396 {
5397 rtrelation41 = new RtGraphs(argv[2], "Detector_-2");
5398 }
5399 catch (string e)
5400 {
5401 cout << e << endl;
5402 }
5403 }
5404 if (trt->FindKey("Detector_2"))
5405 {
5406 try
5407 {
5408 rtrelation51 = new RtGraphs(argv[2], "Detector_2");
5409 }
5410 catch (string e)
5411 {
5412 cout << e << endl;
5413 }
5414 }
5415 // r plots for each t-bin
5416 cout << "MAKING Rt binning" << endl;
5417
5418 // No Xenon for Barrel in Run3
5419 // rtbinning_bar=new RtBinning(trt,"WholeBarrel_1");
5420 // cout << "MAKING Rt binning for Detector_-1" << endl;
5421 // rtbinning1=new RtBinning(trt,"Detector_-1");
5422 // cout << "MAKING Rt binning for Detector_1" << endl;
5423 // rtbinning2=new RtBinning(trt,"Detector_1");
5424 cout << "MAKING Rt binning for Detector_-2" << endl;
5425 rtbinning3 = new RtBinning(trt, "Detector_-2");
5426 cout << "MAKING Rt binning for Detector_2" << endl;
5427 rtbinning4 = new RtBinning(trt, "Detector_2");
5428 }
5429
5430 // Binned residual plots
5431 RresTbin *binres_bar = nullptr;
5432 RresTbin *binres1 = nullptr;
5433 RresTbin *binres2 = nullptr;
5434 RresTbin *binres3 = nullptr;
5435 RresTbin *binres4 = nullptr;
5436 TBinnedRes *tbinnedres_bar = nullptr;
5437 TBinnedRes *tbinnedres1 = nullptr;
5438 TBinnedRes *tbinnedres2 = nullptr;
5439 TBinnedRes *tbinnedres3 = nullptr;
5440 TBinnedRes *tbinnedres4 = nullptr;
5441
5442 cout << "MAKING Binned Residual" << endl;
5443 // No Xenon hists for Barrel in Run3
5444 // binres_bar=new RresTbin(datafile,"WholeBarrel_1",4);
5445 // tbinnedres_bar=new TBinnedRes(datafile,binres_bar->reshists);
5446 // cout << "MAKING Binned Residual for Detector_-1" << endl;
5447 // binres1=new RresTbin(datafile,"Detector_-1",-1);
5448 // tbinnedres1=new TBinnedRes(datafile,binres1->reshists);
5449 // cout << "MAKING Binned Residual for Detector_1" << endl;
5450 // binres2=new RresTbin(datafile,"Detector_1",1);
5451 // tbinnedres2=new TBinnedRes(datafile,binres2->reshists);
5452 cout << "MAKING Binned Residual for Detector_-2" << endl;
5453 binres3 = new RresTbin(datafile, "Detector_-2", -2);
5454 tbinnedres3 = new TBinnedRes(datafile, binres3->reshists);
5455 cout << "MAKING Binned Residual for Detector_2" << endl;
5456 binres4 = new RresTbin(datafile, "Detector_2", 2);
5457 tbinnedres4 = new TBinnedRes(datafile, binres4->reshists);
5458
5459 RtColor *rtcol = nullptr;
5460 RtColor *rtcol1 = nullptr;
5461 RtColor *rtcol2 = nullptr;
5462 RtColor *rtcol3 = nullptr;
5463 RtColor *rtcol4 = nullptr;
5464 RtColor *rtcol5 = nullptr;
5465 // Rt relation, default plot
5466 cout << "MAKING RtColor" << endl;
5467
5468 if (datafile->FindKey("TRT_all"))
5469 {
5470 cout << " found TRT_all " << endl;
5471
5472 // no Xenon RtColor plot for entire TRT
5473 // rtcol= new RtColor(argv[2],"");
5474
5475 TDirectory *trt = (TDirectory *)datafile->FindKey("TRT_all")->ReadObj();
5476
5477 // No Xenon Rt plots for barrel in Run3
5478 /*
5479 if (trt->FindKey("WholeBarrel_1")){
5480 cout << " MAKING RtColor WholeBarrel" << endl;
5481 try {rtcol1= new RtColor(argv[2],"WholeBarrel_1");}
5482 catch (string e){cout << e << endl;}
5483 }
5484
5485
5486 if (trt->FindKey("Detector_-1")){
5487 cout << " MAKING RtColor Detector_-1" << endl;
5488 try {rtcol2= new RtColor(argv[2],"Detector_-1");}
5489 catch (string e){cout << e << endl;}
5490 }
5491
5492 if (trt->FindKey("Detector_1")){
5493 cout << " MAKING RtColor Detector_1" << endl;
5494 try {rtcol3= new RtColor(argv[2],"Detector_1");}
5495 catch (string e){cout << e << endl;}
5496 }
5497 */
5498
5499 if (trt->FindKey("Detector_-2"))
5500 {
5501 cout << " MAKING RtColor Detector_-2" << endl;
5502 try
5503 {
5504 rtcol4 = new RtColor(argv[2], "Detector_-2");
5505 }
5506 catch (string e)
5507 {
5508 cout << e << endl;
5509 }
5510 }
5511
5512 if (trt->FindKey("Detector_2"))
5513 {
5514 cout << " MAKING RtColor Detector_2" << endl;
5515 try
5516 {
5517 rtcol5 = new RtColor(argv[2], "Detector_2");
5518 }
5519 catch (string e)
5520 {
5521 cout << e << endl;
5522 }
5523 }
5524 }
5525 // ARGON!!
5526 // SERGI - Is this actually used for something????
5527 // RtGraphs *rtArrelation_bar = nullptr;
5528 // RtGraphs *rtArrelation21 = nullptr;
5529 // RtGraphs *rtArrelation31 = nullptr;
5530 // RtGraphs *rtArrelation41 = nullptr;
5531 // RtGraphs *rtArrelation51 = nullptr;
5532 // RtBinning *rtArbinning_bar = nullptr;
5533 // RtBinning *rtArbinning1 = nullptr;
5534 // RtBinning *rtArbinning2 = nullptr;
5535 // RtBinning *rtArbinning3 = nullptr;
5536 // RtBinning *rtArbinning4 = nullptr;
5537 // if (datafile->FindKey("TRT_Ar_all"))
5538 // {
5539 // cout << "MAKING AR RtGraphs" << endl;
5540 // TDirectory *trtAr = (TDirectory *)datafile->FindKey("TRT_Ar_all")->ReadObj();
5541
5542 // if (trtAr->FindKey("Detector_Ar_-1/binhist"))
5543 // {
5544 // cout << " Found Detector_Ar_-1/binhist" << endl;
5545 // rtArbinning1 = new RtBinning(trtAr, "Detector_Ar_-1");
5546 // try
5547 // {
5548 // rtArrelation21 = new RtGraphs(argv[2], "Detector_Ar_-1", true);
5549 // }
5550 // catch (string e)
5551 // {
5552 // cout << e << endl;
5553 // }
5554 // }
5555
5556 // if (trtAr->FindKey("Detector_Ar_1/binhist"))
5557 // {
5558 // cout << " Found Detector_Ar_1/binhist" << endl;
5559 // rtArbinning2 = new RtBinning(trtAr, "Detector_Ar_1");
5560 // try
5561 // {
5562 // rtArrelation31 = new RtGraphs(argv[2], "Detector_Ar_1", true);
5563 // }
5564 // catch (string e)
5565 // {
5566 // cout << e << endl;
5567 // }
5568 // }
5569
5570 // if (trtAr->FindKey("Detector_Ar_-2/binhist"))
5571 // {
5572 // cout << " Found Detector_Ar_-2/binhist" << endl;
5573 // rtArbinning3 = new RtBinning(trtAr, "Detector_Ar_-2");
5574 // try
5575 // {
5576 // rtArrelation41 = new RtGraphs(argv[2], "Detector_Ar_-2", true);
5577 // }
5578 // catch (string e)
5579 // {
5580 // cout << e << endl;
5581 // }
5582 // }
5583 // if (trtAr->FindKey("Detector_Ar_2/binhist"))
5584 // {
5585
5586 // TDirectory *test = (TDirectory *)(((TDirectory *)trtAr->Get("Detector_Ar_2")));
5587 // if (test->FindKey("binhist"))
5588 // {
5589 // cout << " Found Detector_Ar_2/binhist" << endl;
5590 // rtArbinning4 = new RtBinning(trtAr, "Detector_Ar_2");
5591 // try
5592 // {
5593 // rtArrelation51 = new RtGraphs(argv[2], "Detector_Ar_2", true);
5594 // }
5595 // catch (string e)
5596 // {
5597 // cout << e << endl;
5598 // }
5599 // }
5600 // }
5601 // // r plots for each t-bin
5602 // cout << " MAKING AR Rt binning" << endl;
5603 // }
5604
5605 // Binned residual plots
5606 // RresTbin *binresAr_bar_bar = nullptr;
5607 // RresTbin *binresAr_bar1 = nullptr;
5608 // RresTbin *binresAr_bar2 = nullptr;
5609 // RresTbin *binresAr_bar3 = nullptr;
5610 // RresTbin *binresAr_bar4 = nullptr;
5611 // TBinnedRes *tbinnedArres_bar = nullptr;
5612 // TBinnedRes *tbinnedArres1 = nullptr;
5613 // TBinnedRes *tbinnedArres2 = nullptr;
5614 // TBinnedRes *tbinnedArres3 = nullptr;
5615 // TBinnedRes *tbinnedArres4 = nullptr;
5616
5617 cout << "MAKING RT Binned Residual for Ar" << endl;
5618
5619 TDirectory *trtAr = (TDirectory *)datafile->FindKey("TRT_Ar_all")->ReadObj();
5620 // if (trtAr->FindKey("WholeBarrel_Ar_1")) binresAr_bar_bar = new RresTbin(datafile,"WholeBarrel_Ar_1",4);
5621 // if (trtAr->FindKey("Detector_Ar_-1"))
5622 // binresAr_bar1 = new RresTbin(datafile, "Detector_Ar_-1", -1);
5623 // if (trtAr->FindKey("Detector_Ar_1"))
5624 // binresAr_bar2 = new RresTbin(datafile, "Detector_Ar_1", 1);
5625 // if (trtAr->FindKey("Detector_Ar_-2"))
5626 // binresAr_bar3 = new RresTbin(datafile, "Detector_Ar_-2", -2);
5627 // if (trtAr->FindKey("Detector_Ar_2"))
5628 // binresAr_bar4 = new RresTbin(datafile, "Detector_Ar_2", 2);
5629
5630 cout << "MAKING RT Binned Abs Residual for Ar" << endl;
5631
5632 // tbinnedArres_bar = new TBinnedRes(datafile,binresAr_bar_bar->reshists);
5633 // tbinnedArres1 = new TBinnedRes(datafile, binresAr_bar1->reshists);
5634 // tbinnedArres2 = new TBinnedRes(datafile, binresAr_bar2->reshists);
5635 // tbinnedArres3 = new TBinnedRes(datafile, binresAr_bar3->reshists);
5636 // tbinnedArres4 = new TBinnedRes(datafile, binresAr_bar4->reshists);
5637
5638 // RtColor *rtArcol = nullptr;
5639 // RtColor *rtArcol1 = nullptr;
5640 RtColor *rtArcol2 = nullptr;
5641 RtColor *rtArcol3 = nullptr;
5642 RtColor *rtArcol4 = nullptr;
5643 RtColor *rtArcol5 = nullptr;
5644 // Rt relation, default plot
5645 // if (datafile->FindKey("TRT_Ar_all/rt-relation"))
5646 // {
5647 // cout << "MAKING AR RtColor all TRT" << endl;
5648 // try
5649 // {
5650 // rtArcol = new RtColor(argv[2], "", true);
5651 // }
5652 // catch (string e)
5653 // {
5654 // cout << e << endl;
5655 // }
5656 // }
5657
5658 if (trtAr->FindKey("Detector_Ar_-1"))
5659 {
5660 cout << " MAKING AR RtColor det -1" << endl;
5661 try
5662 {
5663 rtArcol2 = new RtColor(argv[2], "Detector_Ar_-1", true);
5664 }
5665 catch (string e)
5666 {
5667 cout << e << endl;
5668 }
5669 }
5670 if (trtAr->FindKey("Detector_Ar_1"))
5671 {
5672 cout << " MAKING AR RtColor det 1" << endl;
5673 try
5674 {
5675 rtArcol3 = new RtColor(argv[2], "Detector_Ar_1", true);
5676 }
5677 catch (string e)
5678 {
5679 cout << e << endl;
5680 }
5681 }
5682 if (trtAr->FindKey("Detector_Ar_-2"))
5683 {
5684 cout << " MAKING AR RtColor det -2" << endl;
5685 try
5686 {
5687 rtArcol4 = new RtColor(argv[2], "Detector_Ar_-2", true);
5688 }
5689 catch (string e)
5690 {
5691 cout << e << endl;
5692 }
5693 }
5694 if (trtAr->FindKey("Detector_Ar_2"))
5695 {
5696 cout << " MAKING AR RtColor det 2" << endl;
5697 try
5698 {
5699 rtArcol5 = new RtColor(argv[2], "Detector_Ar_2", true);
5700 }
5701 catch (string e)
5702 {
5703 cout << e << endl;
5704 }
5705 }
5706 // Add the plot for Board T0 variations
5707 BoardVariationsOldT0 *refboardECgraphA = nullptr;
5708 BoardVariationsOldT0 *refboardECgraphC = nullptr;
5709 BoardVariationsDiff *boarddiffECgraphA = nullptr;
5710 BoardVariationsDiff *boarddiffECgraphC = nullptr;
5711 if (useref)
5712 {
5713 cout << "MAKING BoardVariationsOldT0 for Ar" << endl;
5714 refboardECgraphA = new BoardVariationsOldT0(argv[4], 2);
5715 refboardECgraphC = new BoardVariationsOldT0(argv[4], -2);
5716 cout << "MAKING BoardVariationsDiff Ar" << endl;
5717 boarddiffECgraphA = new BoardVariationsDiff(argv[2], argv[4], 2);
5718 boarddiffECgraphC = new BoardVariationsDiff(argv[2], argv[4], -2);
5719 boarddiffECgraphA->SetLineColor(2);
5720 boarddiffECgraphC->SetLineColor(2);
5721 }
5722 // Add the plot for Board T0 variations
5723 cout << "MAKING BoardVariations Ar" << endl;
5724 BoardVariations *boardECgraphA = new BoardVariations(argv[2], 2);
5725 BoardVariations *boardECgraphC = new BoardVariations(argv[2], -2);
5726 // Add the plot for the residual
5727 cout << "MAKING BoardVariationsRes Ar" << endl;
5728 BoardVariationsRes *boardECgraphA1 = new BoardVariationsRes(argv[2], 2);
5729 BoardVariationsRes *boardECgraphC1 = new BoardVariationsRes(argv[2], -2);
5730 // Add the plot for the Time residual
5731 cout << "MAKING BoardVariationsTRes Ar" << endl;
5732 BoardVariationsTRes *boardECgraphA2 = new BoardVariationsTRes(argv[2], 2);
5733 BoardVariationsTRes *boardECgraphC2 = new BoardVariationsTRes(argv[2], -2);
5734 // Add the plot for the sigma Time residual
5735 cout << "MAKING BoardVariationsTRes1" << endl;
5736 BoardVariationsTRes1 *boardECgraphA3 = new BoardVariationsTRes1(argv[2], 2);
5737 BoardVariationsTRes1 *boardECgraphC3 = new BoardVariationsTRes1(argv[2], -2);
5738
5739 cout << " Start printing itersum.ps" << endl;
5740
5741 TCanvas *textpage;
5742
5743 TCanvas *c1 = new TCanvas();
5744 c1->Print("itersum.ps[");
5745 c1->cd();
5746
5747 if (firstpage)
5748 firstpage->Print("itersum.ps");
5749 c1->Clear();
5750 if (settings)
5751 settings->Print("itersum.ps");
5752 c1->Clear();
5753 if (tracktupleinfo)
5754 tracktupleinfo->Print("itersum.ps");
5755 c1->Clear();
5756 if (hitstat)
5757 hitstat->Print("itersum.ps");
5758 c1->Clear();
5759 if (hitstatAr)
5760 hitstatAr->Print("itersum.ps");
5761 c1->Clear();
5762
5763 gStyle->SetOptStat(0);
5764 if (resplots)
5765 resplots->Print("itersum.ps");
5766 c1->Clear();
5767 if (resplotsAr)
5768 resplotsAr->Print("itersum.ps");
5769 c1->Clear();
5770
5771 textpage = new TextPage(" BARREL PLOTS ");
5772 textpage->Print("itersum.ps");
5773 c1->Clear();
5774
5775 hitstatxy->Print("itersum.ps");
5776 c1->Clear();
5777 if (isAr)
5778 hitstatxyAr->Print("itersum.ps");
5779 c1->Clear();
5780 nhits->Print("itersum.ps");
5781 c1->Clear();
5782 if (isAr)
5783 nhitsAr->Print("itersum.ps");
5784 c1->Clear();
5785 resxy0->Print("itersum.ps");
5786 c1->Clear();
5787 if (isAr)
5788 resxy0Ar->Print("itersum.ps");
5789 c1->Clear();
5790 resxy->Print("itersum.ps");
5791 c1->Clear();
5792 if (isAr)
5793 resxyAr->Print("itersum.ps");
5794 c1->Clear();
5795 xymap->Print("itersum.ps");
5796 c1->Clear();
5797 if (isAr)
5798 xymapAr->Print("itersum.ps");
5799 c1->Clear();
5800 if (do_expert)
5801 {
5802 oldt0->Print("itersum.ps");
5803 c1->Clear();
5804 if (isAr)
5805 oldt0Ar->Print("itersum.ps");
5806 c1->Clear();
5807 }
5808 oldt01->Print("itersum.ps");
5809 c1->Clear();
5810 if (isAr)
5811 oldt01Ar->Print("itersum.ps");
5812 c1->Clear();
5813 if (do_expert)
5814 {
5815 oldt0111->Print("itersum.ps");
5816 c1->Clear();
5817 if (isAr)
5818 oldt0111Ar->Print("itersum.ps");
5819 c1->Clear();
5820 }
5821 oldt011->Print("itersum.ps");
5822 c1->Clear();
5823 if (isAr)
5824 oldt011Ar->Print("itersum.ps");
5825 c1->Clear();
5826
5827 // textpage = new TextPage(" T0 PLOTS "); textpage->Print("itersum.ps"); c1->Clear();
5828
5829 double lowe = -3.5, upe = 3.5;
5830 if (do_expert)
5831 if (chipgraphA && chipgraphC)
5832 {
5833 chipgraphA->GetYaxis()->SetRangeUser(lowe, upe);
5834 chipgraphC->GetYaxis()->SetRangeUser(lowe, upe);
5835 c1->cd();
5836 c1->Divide(1, 2, 0.01, 0.01);
5837 c1->cd(1);
5838 chipgraphA->Draw();
5839 chipgraphA->DrawLines(lowe, upe);
5840 c1->cd(2);
5841 chipgraphC->Draw();
5842 chipgraphC->DrawLines(lowe, upe);
5843 c1->Print("itersum.ps");
5844 c1->Clear();
5845 }
5846
5847 c1->cd();
5848 c1->Divide(1, 2, 0.01, 0.01);
5849 c1->cd(1);
5850 boardgraphA->Draw("apl");
5851 boardgraphA->DrawLines();
5852 if (refboardgraphA)
5853 refboardgraphA->Draw("pl");
5854 TLegend *leg = new TLegend(0.8, 0.8, 0.98, 0.95);
5855 leg->AddEntry(boardgraphA, "data", "l");
5856 if (refboardgraphA)
5857 leg->AddEntry(refboardgraphA, "ref (input to 1st it)", "l");
5858 leg->SetTextSize(0.03);
5859 leg->Draw();
5860 c1->cd(2);
5861 boardgraphC->Draw("apl");
5862 boardgraphC->DrawLines();
5863 if (refboardgraphC)
5864 refboardgraphC->Draw("pl");
5865 c1->Print("itersum.ps");
5866 c1->Clear();
5867
5868 // Add the plot for Board T0 variations differenses
5869 if (useref)
5870 {
5871 c1->cd();
5872 c1->Divide(1, 2, 0.01, 0.01);
5873 c1->cd(1);
5874 boarddiffgraphA->Draw("ap");
5875 boarddiffgraphA->DrawLines();
5876
5877 c1->cd(2);
5878 boarddiffgraphC->Draw("ap");
5879 boarddiffgraphC->DrawLines();
5880 if (do_expert)
5881 c1->Print("itersum.ps");
5882 c1->Clear();
5883 }
5884
5885 c1->cd();
5886 c1->Divide(1, 2, 0.01, 0.01);
5887 c1->cd(1);
5888 boardgraphA1->Draw("apl");
5889 boardgraphA1->DrawLines();
5890 c1->cd(2);
5891 boardgraphC1->Draw("apl");
5892 boardgraphC1->DrawLines();
5893 c1->Print("itersum.ps");
5894 c1->Clear();
5895
5896 c1->cd();
5897 c1->Divide(1, 2, 0.01, 0.01);
5898 c1->cd(1);
5899 boardgraphA2->Draw("apl");
5900 boardgraphA2->DrawLines();
5901 c1->cd(2);
5902 boardgraphC2->Draw("apl");
5903 boardgraphC2->DrawLines();
5904 c1->Print("itersum.ps");
5905 c1->Clear();
5906
5907 c1->cd();
5908 c1->Divide(1, 2, 0.01, 0.01);
5909 c1->cd(1);
5910 boardgraphA3->Draw("apl");
5911 boardgraphA3->DrawLines();
5912 c1->cd(2);
5913 boardgraphC3->Draw("apl");
5914 boardgraphC3->DrawLines();
5915 c1->Print("itersum.ps");
5916 c1->Clear();
5917
5918 // ################################################################ ADD PLOTS FOR ENDCAPS:
5919
5920 c1->Clear();
5921 textpage = new TextPage("ENDCAP PLOTS");
5922 textpage->Print("itersum.ps");
5923 c1->Clear();
5924
5925 cout << "MAKING PLOTS FOR ENDCAPS" << endl;
5926
5927 // Do hits fit type:
5928 XYMapsEC *ntypeEC = new XYMapsEC(argv[2], "ftype");
5929 ntypeEC->Print("itersum.ps");
5930 XYMapsEC *ntypeECAr = nullptr;
5931 if (isAr)
5932 {
5933 ntypeECAr = new XYMapsEC(argv[2], "ftype", true);
5934 ntypeECAr->Print("itersum.ps");
5935 }
5936
5937 // Do hits plots:
5938 XYMapsEC *nhitsEC = new XYMapsEC(argv[2], "nt0");
5939 nhitsEC->Print("itersum.ps");
5940 XYMapsEC *nhitsECAr = nullptr;
5941 if (isAr)
5942 {
5943 nhitsECAr = new XYMapsEC(argv[2], "nt0", true);
5944 nhitsECAr->Print("itersum.ps");
5945 }
5946 // Do res plot:
5947 XYMapsEC *resxy0EC = new XYMapsEC(argv[2], "res");
5948 resxy0EC->Print("itersum.ps");
5949 XYMapsEC *resxy0ECAr = nullptr;
5950 if (isAr)
5951 {
5952 resxy0ECAr = new XYMapsEC(argv[2], "res", true);
5953 resxy0ECAr->Print("itersum.ps");
5954 }
5955
5956 XYMapsEC *resxyM0EC = new XYMapsEC(argv[2], "abs(resMean)");
5957 resxyM0EC->Print("itersum.ps");
5958 XYMapsEC *resxyM0ECAr = nullptr;
5959 if (isAr)
5960 {
5961 resxyM0ECAr = new XYMapsEC(argv[2], "abs(resMean)", true);
5962 resxyM0ECAr->Print("itersum.ps");
5963 }
5964
5965 // Do t0s plots:
5966 XYMapsEC *xymapEC = new XYMapsEC(argv[2], "t0");
5967 xymapEC->Print("itersum.ps");
5968 XYMapsEC *xymapECAr = nullptr;
5969 if (isAr)
5970 {
5971 xymapECAr = new XYMapsEC(argv[2], "t0", true);
5972 xymapECAr->Print("itersum.ps");
5973 }
5974
5975 // Do Oldt0plots
5976 XYMapsEC *oldt0EC = nullptr;
5977 if (do_expert)
5978 oldt0EC = new XYMapsEC(argv[2], "oldt0");
5979 if (do_expert)
5980 oldt0EC->Print("itersum.ps");
5981 XYMapsEC *oldt0ECAr = nullptr;
5982 if (do_expert)
5983 {
5984 if (isAr)
5985 {
5986 oldt0ECAr = new XYMapsEC(argv[2], "oldt0", true);
5987 oldt0ECAr->Print("itersum.ps");
5988 }
5989 }
5990
5991 // Do t0 diff:
5992 XYMapsEC *oldt01EC = new XYMapsEC(argv[2], "abs(t0-oldt0)");
5993 oldt01EC->Print("itersum.ps");
5994 XYMapsEC *oldt01ECAr = nullptr;
5995 if (isAr)
5996 {
5997 oldt01ECAr = new XYMapsEC(argv[2], "abs(t0-oldt0)", true);
5998 oldt01ECAr->Print("itersum.ps");
5999 }
6000
6001 // Do t0 widht:
6002
6003 XYMapsEC *oldt0111EC = nullptr;
6004 if (do_expert)
6005 oldt0111EC = new XYMapsEC(argv[2], "abs(tresMean)");
6006 if (do_expert)
6007 oldt0111EC->Print("itersum.ps");
6008 XYMapsEC *oldt0111ECAr = nullptr;
6009 if (do_expert)
6010 {
6011 if (isAr)
6012 {
6013 oldt0111ECAr = new XYMapsEC(argv[2], "abs(tresMean)", true);
6014 oldt0111ECAr->Print("itersum.ps");
6015 }
6016 }
6017 // Do t0 widht:
6018 XYMapsEC *oldt011EC = new XYMapsEC(argv[2], "tres");
6019 oldt011EC->Print("itersum.ps");
6020 XYMapsEC *oldt011ECAr = nullptr;
6021 if (isAr)
6022 {
6023 oldt011ECAr = new XYMapsEC(argv[2], "tres", true);
6024 oldt011ECAr->Print("itersum.ps");
6025 }
6026
6027 // Do board variations for Ar
6028 c1->cd();
6029 c1->Divide(1, 2, 0.01, 0.01);
6030 c1->cd(1);
6031 boardECgraphA->Draw("apl");
6032 boardECgraphA->DrawLines();
6033 if (refboardECgraphA)
6034 refboardECgraphA->Draw("pl");
6035 TLegend *legAr = new TLegend(0.8, 0.8, 0.98, 0.95);
6036 legAr->AddEntry(boardECgraphA, "data", "l");
6037 if (refboardECgraphA)
6038 leg->AddEntry(refboardECgraphA, "ref (input to 1st it)", "l");
6039 legAr->SetTextSize(0.03);
6040 legAr->Draw();
6041 c1->cd(2);
6042 boardECgraphC->Draw("apl");
6043 boardECgraphC->DrawLines();
6044 if (refboardECgraphC)
6045 refboardECgraphC->Draw("pl");
6046 c1->Print("itersum.ps");
6047 c1->Clear();
6048
6049 // Add the plot for Board T0 variations differenses
6050 if (useref)
6051 {
6052 c1->cd();
6053 c1->Divide(1, 2, 0.01, 0.01);
6054 c1->cd(1);
6055 boarddiffECgraphA->Draw("ap");
6056 boarddiffECgraphA->DrawLines();
6057 c1->cd(2);
6058 boarddiffECgraphC->Draw("ap");
6059 boarddiffECgraphC->DrawLines();
6060 if (do_expert)
6061 c1->Print("itersum.ps");
6062 c1->Clear();
6063 }
6064
6065 c1->cd();
6066 c1->Divide(1, 2, 0.01, 0.01);
6067 c1->cd(1);
6068 boardECgraphA1->Draw("apl");
6069 boardECgraphA1->DrawLines();
6070 c1->cd(2);
6071 boardECgraphC1->Draw("apl");
6072 boardECgraphC1->DrawLines();
6073 c1->Print("itersum.ps");
6074 c1->Clear();
6075
6076 c1->cd();
6077 c1->Divide(1, 2, 0.01, 0.01);
6078 c1->cd(1);
6079 boardECgraphA2->Draw("apl");
6080 boardECgraphA2->DrawLines();
6081 c1->cd(2);
6082 boardECgraphC2->Draw("apl");
6083 boardECgraphC2->DrawLines();
6084 c1->Print("itersum.ps");
6085 c1->Clear();
6086
6087 c1->cd();
6088 c1->Divide(1, 2, 0.01, 0.01);
6089 c1->cd(1);
6090 boardECgraphA3->Draw("apl");
6091 boardECgraphA3->DrawLines();
6092 c1->cd(2);
6093 boardECgraphC3->Draw("apl");
6094 boardECgraphC3->DrawLines();
6095 c1->Print("itersum.ps");
6096 c1->Clear();
6097
6098 // ################################### RT PLOTS: ########################################################
6099
6100 textpage = new TextPage(" RT PLOTS ");
6101 textpage->Print("itersum.ps");
6102 c1->Clear();
6103
6104 gStyle->SetOptStat(1);
6105 gStyle->SetOptFit(0);
6106 if (do_expert)
6107 if (rtrelation_bar)
6108 rtrelation_bar->Print("itersum.ps");
6109 c1->Clear();
6110 if (do_expert)
6111 if (rtbinning_bar)
6112 rtbinning_bar->Print("itersum.ps");
6113 c1->Clear();
6114 if (do_expert)
6115 if (rtrelation21)
6116 rtrelation21->Print("itersum.ps");
6117 c1->Clear();
6118 if (do_expert)
6119 if (rtbinning1)
6120 rtbinning1->Print("itersum.ps");
6121 c1->Clear();
6122 if (do_expert)
6123 if (rtrelation31)
6124 rtrelation31->Print("itersum.ps");
6125 c1->Clear();
6126 if (do_expert)
6127 if (rtbinning2)
6128 rtbinning2->Print("itersum.ps");
6129 c1->Clear();
6130 if (do_expert)
6131 if (rtrelation41)
6132 rtrelation41->Print("itersum.ps");
6133 c1->Clear();
6134 if (do_expert)
6135 if (rtbinning3)
6136 rtbinning3->Print("itersum.ps");
6137 c1->Clear();
6138 if (do_expert)
6139 if (rtrelation51)
6140 rtrelation51->Print("itersum.ps");
6141 c1->Clear();
6142 if (do_expert)
6143 if (rtbinning4)
6144 rtbinning4->Print("itersum.ps");
6145 c1->Clear();
6146
6147 if (do_expert)
6148 if (binres_bar)
6149 binres_bar->Print("itersum.ps");
6150 c1->Clear();
6151 if (do_expert)
6152 if (tbinnedres_bar)
6153 tbinnedres_bar->Print("itersum.ps");
6154 c1->Clear();
6155 if (do_expert)
6156 if (binres1)
6157 binres1->Print("itersum.ps");
6158 c1->Clear();
6159 if (do_expert)
6160 if (tbinnedres1)
6161 tbinnedres1->Print("itersum.ps");
6162 c1->Clear();
6163 if (do_expert)
6164 if (binres2)
6165 binres2->Print("itersum.ps");
6166 c1->Clear();
6167 if (do_expert)
6168 if (tbinnedres2)
6169 tbinnedres2->Print("itersum.ps");
6170 c1->Clear();
6171 if (do_expert)
6172 binres3->Print("itersum.ps");
6173 c1->Clear();
6174 if (do_expert)
6175 if (tbinnedres3)
6176 tbinnedres3->Print("itersum.ps");
6177 c1->Clear();
6178 if (do_expert)
6179 binres4->Print("itersum.ps");
6180 c1->Clear();
6181 if (do_expert)
6182 if (tbinnedres4)
6183 tbinnedres4->Print("itersum.ps");
6184 c1->Clear();
6185
6186 gStyle->SetOptStat(0);
6187 if (do_expert)
6188 if (rtcol)
6189 rtcol->Print("itersum.ps");
6190 c1->Clear();
6191 if (do_expert)
6192 if (rtcol1)
6193 rtcol1->Print("itersum.ps");
6194 c1->Clear();
6195 if (rtcol2)
6196 rtcol2->Print("itersum.ps");
6197 c1->Clear();
6198 if (isAr && rtArcol2)
6199 rtArcol2->Print("itersum.ps");
6200 c1->Clear();
6201 if (rtcol3)
6202 rtcol3->Print("itersum.ps");
6203 c1->Clear();
6204 if (isAr && rtArcol3)
6205 rtArcol3->Print("itersum.ps");
6206 c1->Clear();
6207 if (rtcol4)
6208 rtcol4->Print("itersum.ps");
6209 c1->Clear();
6210 if (isAr && rtArcol4)
6211 rtArcol4->Print("itersum.ps");
6212 c1->Clear();
6213 if (rtcol5)
6214 rtcol5->Print("itersum.ps");
6215 c1->Clear();
6216 if (isAr && rtArcol5)
6217 rtArcol5->Print("itersum.ps");
6218 c1->Clear();
6219
6220 // Plot all RTs together....
6221
6222 DGraph *dgraph0 = nullptr; // trt
6223 DGraph *dgraph1 = nullptr; // -1
6224 DGraph *dgraph2 = nullptr; // 1
6225 DGraph *dgraph3 = nullptr; // -2
6226 DGraph *dgraph4 = nullptr; // 2
6227 DGraph *dgraph5 = nullptr; // whole barrel
6228 bool isinverted = false;
6229 if (datafile->FindKey("TRT_all"))
6230 {
6231 TDirectory *trt = (TDirectory *)datafile->FindKey("TRT_all")->ReadObj();
6232 cout << "MAKING DGraphs" << endl;
6233 c1->cd();
6234 c1->SetGrid();
6235 dgraph0 = new DGraph(argv[2], "-2,-1", "", -2, -1, isinverted);
6236 if (trt->FindKey("WholeBarrel_1"))
6237 {
6238 dgraph5 = new DGraph(argv[2], "-2,-1", "WholeBarrel_1", -1, -1, isinverted);
6239 }
6240 else
6241 {
6242 cout << " did not find WholeBarrel_1" << endl;
6243 if (trt->FindKey("Detector_1"))
6244 dgraph1 = new DGraph(argv[2], "-2,-1", "Detector_1", 1, -1, isinverted);
6245 if (trt->FindKey("Detector_-1"))
6246 dgraph2 = new DGraph(argv[2], "-2,-1", "Detector_-1", 1, -1, isinverted);
6247 }
6248 if (trt->FindKey("Detector_2"))
6249 dgraph3 = new DGraph(argv[2], "-2,-1", "Detector_2", 1, -1, isinverted);
6250 if (trt->FindKey("Detector_-2"))
6251 dgraph4 = new DGraph(argv[2], "-2,-1", "Detector_-2", 1, -1, isinverted);
6252
6253
6254 TLegend *leg = new TLegend(0.8, 0.8, 0.98, 0.95);
6255 if (dgraph0 != nullptr)
6256 {
6257 dgraph0->GetXaxis()->SetRangeUser(-5, 45);
6258 cout << " found TRT_all" << endl;
6259 dgraph0->SetLineWidth(3);
6260 dgraph0->SetLineColor(1);
6261 dgraph0->SetTitle("r(t)");
6262
6263 dgraph0->GetXaxis()->SetTitle("t/ns");
6264
6265 dgraph0->GetYaxis()->SetTitle("R / (mm)");
6266
6267 if (dgraph0->rtgraph)
6268 dgraph0->Draw("apl");
6269 if (dgraph0->rtgraph)
6270 leg->AddEntry(dgraph0, "Whole TRT", "l");
6271 }
6272 if (dgraph1 != nullptr)
6273 {
6274 cout << " found Detector_1" << endl;
6275 dgraph1->SetLineWidth(3);
6276 dgraph1->SetLineColor(3);
6277 if (dgraph1->rtgraph)
6278 dgraph1->Draw("pl");
6279 if (dgraph1->rtgraph)
6280 leg->AddEntry(dgraph1, "Barrel C Side", "l");
6281 }
6282
6283 if (dgraph2 != nullptr)
6284 {
6285 cout << " found Detector_-1" << endl;
6286 dgraph2->SetLineWidth(3);
6287 dgraph2->SetLineColor(2);
6288 if (dgraph2->rtgraph)
6289 dgraph2->Draw("pl");
6290 if (dgraph2->rtgraph)
6291 leg->AddEntry(dgraph2, "Barrel A Side", "l");
6292 }
6293
6294 if (dgraph3 != nullptr)
6295 {
6296 dgraph3->SetLineWidth(3);
6297 cout << " found Detector_2" << endl;
6298 dgraph3->SetLineColor(6);
6299 if (dgraph3->rtgraph)
6300 dgraph3->Draw("pl");
6301 if (dgraph3->rtgraph)
6302 leg->AddEntry(dgraph3, "Endcap C side", "l");
6303 }
6304
6305 if (dgraph4 != nullptr)
6306 {
6307 cout << " found Detector_-2" << endl;
6308 dgraph4->SetLineWidth(3);
6309 dgraph4->SetLineColor(7);
6310 if (dgraph4->rtgraph)
6311 dgraph4->Draw("pl");
6312 if (dgraph4->rtgraph)
6313 leg->AddEntry(dgraph4, "Endcap A side", "l");
6314 }
6315 if (dgraph5 != nullptr)
6316 {
6317 cout << " found WholeBarrel_1" << endl;
6318 dgraph5->SetLineWidth(3);
6319 dgraph5->SetLineColor(8);
6320 if (dgraph5->rtgraph)
6321 dgraph5->Draw("pl");
6322 if (dgraph5->rtgraph)
6323 leg->AddEntry(dgraph5, "Whole Barrel", "l");
6324 }
6325
6326 leg->SetTextSize(0.03);
6327 leg->Draw();
6328 c1->Print("itersum.ps");
6329 c1->Clear();
6330 }
6331
6332 // Plot drift velocity:
6333 DvGraph *dvgraph0 = nullptr; // trt
6334 DvGraph *dvgraph1 = nullptr; // -1
6335 DvGraph *dvgraph2 = nullptr; // 1
6336 DvGraph *dvgraph3 = nullptr; // -2
6337 DvGraph *dvgraph4 = nullptr; // 2
6338 DvGraph *dvgraph5 = nullptr; // whole barrel
6339 if (do_expert)
6340 {
6341 // bool isinverted=false;
6342 if (datafile->FindKey("TRT_all"))
6343 {
6344 cout << " do_expert: found TRT_all" << endl;
6345 TDirectory *trt = (TDirectory *)datafile->FindKey("TRT_all")->ReadObj();
6346 cout << "MAKING DvGraphs" << endl;
6347 c1->cd();
6348 c1->SetGrid();
6349 dvgraph0 = new DvGraph(argv[2], "-2,-1", "", -2, -1, isinverted);
6350 if (trt->FindKey("WholeBarrel_1"))
6351 dvgraph5 = new DvGraph(argv[2], "-2,-1", "WholeBarrel_1", -1, -1, isinverted);
6352 else
6353 {
6354 if (trt->FindKey("Detector_1"))
6355 dvgraph1 = new DvGraph(argv[2], "-2,-1", "Detector_1", 1, -1, isinverted);
6356 if (trt->FindKey("Detector_-1"))
6357 dvgraph2 = new DvGraph(argv[2], "-2,-1", "Detector_-1", 1, -1, isinverted);
6358 }
6359 if (trt->FindKey("Detector_2"))
6360 dvgraph3 = new DvGraph(argv[2], "-2,-1", "Detector_2", 1, -1, isinverted);
6361 if (trt->FindKey("Detector_-2"))
6362 dvgraph4 = new DvGraph(argv[2], "-2,-1", "Detector_-2", 1, -1, isinverted);
6363
6364
6365 TLegend *leg = new TLegend(0.8, 0.8, 0.98, 0.95);
6366 if (dvgraph0 != nullptr)
6367 {
6368 dvgraph0->GetXaxis()->SetRangeUser(0, 2);
6369 cout << " do_expert: found -2-1" << endl;
6370 dvgraph0->SetLineWidth(3);
6371 dvgraph0->SetLineColor(1);
6372 if (isinverted)
6373 dvgraph0->SetTitle("dt/dr");
6374 else
6375 dvgraph0->SetTitle("dr/dt");
6376 dvgraph0->GetXaxis()->SetTitle("r/mm");
6377 if (isinverted)
6378 dvgraph0->GetYaxis()->SetTitle("dt/dr / (ns/mm)");
6379 else
6380 dvgraph0->GetYaxis()->SetTitle("dr/dt / (mm/ns)");
6381 if (dvgraph0->rtgraph)
6382 dvgraph0->Draw("apl");
6383 if (dvgraph0->rtgraph)
6384 leg->AddEntry(dvgraph0, "Whole TRT", "l");
6385 }
6386 if (dvgraph1 != nullptr)
6387 {
6388 cout << " do_expert: found Detector_1" << endl;
6389 dvgraph1->SetLineWidth(3);
6390 dvgraph1->SetLineColor(3);
6391 if (dvgraph1->rtgraph)
6392 dvgraph1->Draw("pl");
6393 if (dvgraph1->rtgraph)
6394 leg->AddEntry(dvgraph1, "Barrel C Side", "l");
6395 }
6396
6397 if (dvgraph2 != nullptr)
6398 {
6399 dvgraph2->SetLineWidth(3);
6400 dvgraph2->SetLineColor(2);
6401 if (dvgraph2->rtgraph)
6402 dvgraph2->Draw("pl");
6403 if (dvgraph2->rtgraph)
6404 leg->AddEntry(dvgraph2, "Barrel A Side", "l");
6405 }
6406
6407 if (dvgraph3 != nullptr)
6408 {
6409 dvgraph3->SetLineWidth(3);
6410 dvgraph3->SetLineColor(6);
6411 if (dvgraph3->rtgraph)
6412 dvgraph3->Draw("pl");
6413 if (dvgraph3->rtgraph)
6414 leg->AddEntry(dvgraph3, "Endcap C side", "l");
6415 }
6416
6417 if (dvgraph4 != nullptr)
6418 {
6419 dvgraph4->SetLineWidth(3);
6420 dvgraph4->SetLineColor(7);
6421 if (dvgraph4->rtgraph)
6422 dvgraph4->Draw("pl");
6423 if (dvgraph4->rtgraph)
6424 leg->AddEntry(dvgraph4, "Endcap A side", "l");
6425 }
6426 if (dvgraph5 != nullptr)
6427 {
6428 dvgraph5->SetLineWidth(3);
6429 dvgraph5->SetLineColor(8);
6430 if (dvgraph5->rtgraph)
6431 dvgraph5->Draw("pl");
6432 if (dvgraph5->rtgraph)
6433 leg->AddEntry(dvgraph5, "Whole Barrel", "l");
6434 }
6435
6436 leg->SetTextSize(0.03);
6437 leg->Draw();
6438 c1->Print("itersum.ps");
6439 c1->Clear();
6440 }
6441 }
6442
6443 // ################################### ADD PLOTS FOR TRACKING #######################################33
6444 c1->Clear();
6445 textpage = new TextPage("Track plots: Only for Experts!!!");
6446 textpage->Print("itersum.ps");
6447 c1->Clear();
6448
6449 bool istracktuple = false;
6450 TNtuple *Tracktuple = nullptr;
6451 if (datafile->FindKey("tracktuple"))
6452 {
6453 Tracktuple = (TNtuple *)datafile->Get("tracktuple");
6454 istracktuple = true;
6455 }
6456
6457 cout << "MAKING TRACK PLOTS" << endl;
6458 c1->Clear();
6459 if (istracktuple)
6460 {
6461 // first Residuals:
6462 if (Tracktuple->GetListOfBranches()->FindObject("trackres"))
6463 {
6464 c1->cd();
6465 c1->Divide(2, 1, 0.01, 0.01);
6466 c1->cd(1);
6467 Tracktuple->Draw("trackres>>histRes(100,0,1.5)");
6468 TH1F *histRes = (TH1F *)gPad->GetPrimitive("histRes");
6469 histRes->SetTitle("Residual on track");
6470 histRes->GetXaxis()->SetTitle("Residual (mm)");
6471 histRes->Draw();
6472
6473 c1->cd(2);
6474 Tracktuple->Draw("trackres:t-ttrack-t0>>histRes2d(100,-12,12,100,0,1)", "", "colz");
6475 TH2F *histRes2d = (TH2F *)gPad->GetPrimitive("histRes2d");
6476 histRes2d->SetTitle("Track time residual VS track residual");
6477 histRes2d->GetXaxis()->SetTitle("Time residual (ns)");
6478 histRes2d->GetYaxis()->SetTitle("Track Residual (mm)");
6479 histRes2d->Draw("colz");
6480 TProfile *res2d = histRes2d->ProfileX();
6481 res2d->Draw("same");
6482
6483 c1->Print("itersum.ps");
6484 c1->Clear();
6485 }
6486
6487 // first pt:
6488 if (Tracktuple->GetListOfBranches()->FindObject("pt"))
6489 {
6490 c1->cd();
6491 c1->Divide(2, 1, 0.01, 0.01);
6492 c1->cd(1);
6493 Tracktuple->Draw("pt/1000>>histPt(100,0,20)");
6494 TH1F *histPt = (TH1F *)gPad->GetPrimitive("histPt");
6495 histPt->SetTitle("Transverse momentum on track");
6496 histPt->GetXaxis()->SetTitle("Pt (GeV)");
6497 histPt->Draw();
6498
6499 c1->cd(2);
6500 Tracktuple->Draw("trackres:pt/1000>>histPt2d(100,0,20,100,0,1.5)", "", "colz");
6501 TH2F *histPt2d = (TH2F *)gPad->GetPrimitive("histPt2d");
6502 histPt2d->SetTitle("Transverse momentum on track VS track residual");
6503 histPt2d->GetXaxis()->SetTitle("Pt (GeV)");
6504 histPt2d->GetYaxis()->SetTitle("Track Residual (mm)");
6505 histPt2d->Draw("COLZ");
6506 TProfile *pt2d = histPt2d->ProfileX();
6507 pt2d->Draw("same");
6508 c1->Print("itersum.ps");
6509 c1->Clear();
6510 }
6511 // first theta:
6512 if (Tracktuple->GetListOfBranches()->FindObject("theta"))
6513 {
6514 c1->cd();
6515 c1->Divide(2, 1, 0.01, 0.01);
6516 c1->cd(1);
6517 Tracktuple->Draw("theta>>histTheta(100,0,4)");
6518 TH1F *histTheta = (TH1F *)gPad->GetPrimitive("histTheta");
6519 histTheta->SetTitle("Theta distribution on track");
6520 histTheta->GetXaxis()->SetTitle("Theta (rad)");
6521 histTheta->Draw();
6522
6523 c1->cd(2);
6524 Tracktuple->Draw("trackres:theta>>histTheta2d(100,0,4,100,0,1.5)", "", "colz");
6525 TH2F *histTheta2d = (TH2F *)gPad->GetPrimitive("histTheta2d");
6526 histTheta2d->SetTitle("Theta distrib. on track VS track residual");
6527 histTheta2d->GetXaxis()->SetTitle("Theta (rad)");
6528 histTheta2d->GetYaxis()->SetTitle("Track Residual (mm)");
6529 histTheta2d->Draw("COLZ");
6530 TProfile *theta2d = histTheta2d->ProfileX();
6531 theta2d->Draw("same");
6532 c1->Print("itersum.ps");
6533 c1->Clear();
6534 }
6535 // first phi:
6536 if (Tracktuple->GetListOfBranches()->FindObject("phi"))
6537 {
6538 c1->cd();
6539 c1->Divide(2, 1, 0.01, 0.01);
6540 c1->cd(1);
6541 Tracktuple->Draw("phi>>histPhi(100,-3.5,0)");
6542 TH1F *histPhi = (TH1F *)gPad->GetPrimitive("histPhi");
6543 histPhi->SetTitle("Phi distribution on track");
6544 histPhi->GetXaxis()->SetTitle("Phi (rad)");
6545 histPhi->Draw();
6546
6547 c1->cd(2);
6548 Tracktuple->Draw("trackres:phi>>histPhi2d(100,-3.5,0,100,0,1.5)", "", "colz");
6549 TH2F *histPhi2d = (TH2F *)gPad->GetPrimitive("histPhi2d");
6550 histPhi2d->SetTitle("Phi distrib. on track VS track residual");
6551 histPhi2d->GetXaxis()->SetTitle("Phi (rad)");
6552 histPhi2d->GetYaxis()->SetTitle("Track Residual (mm)");
6553 histPhi2d->Draw("COLZ");
6554 TProfile *phi2d = histPhi2d->ProfileX();
6555 phi2d->Draw("same");
6556 c1->Print("itersum.ps");
6557 c1->Clear();
6558 }
6559 // first d0:
6560 if (Tracktuple->GetListOfBranches()->FindObject("d0"))
6561 {
6562 c1->cd();
6563 c1->Divide(2, 1, 0.01, 0.01);
6564 c1->cd(1);
6565 Tracktuple->Draw("d0>>histD0(100,-5,5)");
6566 TH1F *histD0 = (TH1F *)gPad->GetPrimitive("histD0");
6567 histD0->SetTitle("D0 distribution on track");
6568 histD0->GetXaxis()->SetTitle("D0 (mm)");
6569 histD0->Draw();
6570
6571 c1->cd(2);
6572 Tracktuple->Draw("trackres:d0>>histD02d(100,-5,5,100,0,1.5)", "", "colz");
6573 TH2F *histD02d = (TH2F *)gPad->GetPrimitive("histD02d");
6574 histD02d->SetTitle("D0 distrib. on track VS track residual");
6575 histD02d->GetXaxis()->SetTitle("D0 (rad)");
6576 histD02d->GetYaxis()->SetTitle("Track Residual (mm)");
6577 histD02d->Draw("COLZ");
6578 TProfile *d02d = histD02d->ProfileX();
6579 d02d->Draw("same");
6580 c1->Print("itersum.ps");
6581 c1->Clear();
6582 }
6583 }
6584
6585 // ################################### ADD PLOTS FOR Pulls and Errors #######################################33
6586
6587 // Skip all this for now (PH)
6588 cout << " Skipping plots for Pulls and Errors " << endl;
6589
6590 // SERGI - Another block not used :). Firewalls below previously commented... useless block of code
6591 // bool iserrors = false;
6592 // TDirectory *errors = nullptr;
6593 // if (datafile->FindKey("Errors"))
6594 // {
6595 // errors = (TDirectory *)datafile->FindKey("Errors")->ReadObj();
6596 // if (errors != nullptr)
6597 // iserrors = true;
6598 // }
6599
6600 c1->Clear();
6601 /*
6602 textpage = new TextPage(" Error Plots and Pt dependence. Only for Experts!!!");
6603 textpage->Print("itersum.ps");
6604 c1->Clear();
6605
6606 cout << "Making Error/Pt plots:" << endl;
6607 c1->Clear();
6608 if (iserrors){
6609 //first Residuals:
6610 cout << "Start with Pt plots:" << endl;
6611 errors->cd();
6612
6613 PtDependence* ptstuff = new PtDependence(datafile);
6614 ptstuff->Print("itersum.ps");
6615
6616 TBDependence* tbstuff = new TBDependence(datafile);
6617 tbstuff->Print("itersum.ps");
6618
6619
6620
6621 }
6622
6623
6624 */
6625
6626 // ################################### ADD PLOTS FOR ToT and HT #######################################33
6627
6628 // Skip all this for now (PH)
6629 cout << " Skipping plots for ToT and HT " << endl;
6630
6631 // SERGI - Firewalls below previously commented... useless block of code
6632 // bool iscorrections = false;
6633 // TDirectory *corrections = nullptr;
6634 // if (datafile->FindKey("Correction"))
6635 // {
6636 // corrections = (TDirectory *)datafile->FindKey("Correction")->ReadObj();
6637 // if (corrections != nullptr)
6638 // iscorrections = true;
6639 // }
6640
6641 c1->Clear();
6642 textpage = new TextPage(" ToT Corrections and HT corrections: ");
6643 textpage->Print("itersum.pdf");
6644 c1->Clear();
6645
6646 cout << "Making ToT / HT Plots" << endl;
6647 c1->Clear();
6648 /*
6649 if (iscorrections){
6650 //first Residuals:
6651 cout << "Start with ToT plots:" << endl;
6652 corrections->cd();
6653
6654 ToTDependence* totstuff = new ToTDependence(datafile, true); // Barrels:
6655 totstuff->Print("itersum.ps");
6656
6657 ToTDependence* totstuff2 = new ToTDependence(datafile, false); // Barrels:
6658 totstuff2->Print("itersum.ps");
6659
6660 cout << "Start with HT plots:" << endl;
6661
6662 ToTDependence* htstuff = new ToTDependence(datafile, true, true ); // Barrels:
6663 htstuff->Print("itersum.ps");
6664
6665 ToTDependence* htstuff2 = new ToTDependence(datafile, false, true); // Barrels:
6666 htstuff2->Print("itersum.ps");
6667
6668 cout << "Start with sin(theta) / p plots:" << endl;
6669
6670 SinDependence* sinstuff = new SinDependence(datafile, true); // Barrels:
6671 sinstuff->Print("itersum.ps");
6672
6673 SinDependence* sinstuff2 = new SinDependence(datafile, false); // Barrels:
6674 sinstuff2->Print("itersum.ps");
6675
6676 cout << "Start with cos(theta) / p plots:" << endl;
6677
6678 SinDependence* cosstuff = new SinDependence(datafile, true, true); // Barrels:
6679 cosstuff->Print("itersum.ps");
6680
6681 SinDependence* cosstuff2 = new SinDependence(datafile, false, true); // Barrels:
6682 cosstuff2->Print("itersum.ps");
6683
6684
6685 }
6686
6687
6688 */
6689
6690 // ################################### ADD PLOTS FOR ToT and HT ARGON #######################################33
6691
6692 // bool iscorrectionsAr = false;
6693 // TDirectory *correctionsAr = nullptr;
6694 // if (datafile->FindKey("CorrectionAr"))
6695 // {
6696 // correctionsAr = (TDirectory *)datafile->FindKey("CorrectionAr")->ReadObj();
6697 // if (correctionsAr != nullptr)
6698 // iscorrectionsAr = true;
6699 // }
6700
6701 /*
6702 if (iscorrectionsAr){
6703 c1->Clear();
6704 textpage = new TextPage(" ToT Corrections and HT corrections: ARGON");
6705 textpage->Print("itersum.ps");
6706 c1->Clear();
6707
6708 cout << "Making ToT / HT Plots ARGON" << endl;
6709 c1->Clear();
6710 //first Residuals:
6711 cout << "Start with ToT plots:" << endl;
6712 corrections->cd();
6713
6714 ToTDependence* totstuff = new ToTDependence(datafile, true, false, true); // Barrels:
6715 totstuff->Print("itersum.ps");
6716
6717 ToTDependence* totstuff2 = new ToTDependence(datafile, false, false, true); // Barrels:
6718 totstuff2->Print("itersum.ps");
6719
6720 cout << "Start with HT plots:" << endl;
6721
6722 ToTDependence* htstuff = new ToTDependence(datafile, true, true, true ); // Barrels:
6723 htstuff->Print("itersum.ps");
6724
6725 ToTDependence* htstuff2 = new ToTDependence(datafile, false, true, true); // Barrels:
6726 htstuff2->Print("itersum.ps");
6727
6728 cout << "Start with sin(theta) / p plots:" << endl;
6729
6730 SinDependence* sinstuff = new SinDependence(datafile, true, false, true); // Barrels:
6731 sinstuff->Print("itersum.ps");
6732
6733 // SinDependence* sinstuff2 = new SinDependence(datafile, false, false, true); // Barrels:
6734 // sinstuff2->Print("itersum.ps");
6735
6736 cout << "Start with cos(theta) / p plots:" << endl;
6737
6738 // SinDependence* cosstuff = new SinDependence(datafile, true, true, true); // Barrels:
6739 // cosstuff->Print("itersum.ps");
6740
6741 SinDependence* cosstuff2 = new SinDependence(datafile, false, true, true); // Barrels:
6742 cosstuff2->Print("itersum.ps");
6743
6744
6745 }
6746
6747 c1->Print("itersum.ps]");
6748 */
6749
6750 datafile->Close();
6751 if (useref)
6752 refdatafile->Close();
6753
6754 // cout << "RDIFF -1 ";
6755 // for (map<double,double>::iterator rtpoint = rtrelation21->rtmap.begin(); rtpoint != rtrelation21->rtmap.end(); rtpoint++){
6756 // cout << binres1->resmap[rtpoint->second] << " ";
6757 // }
6758 // cout << endl;
6759 // cout << "RDIFF 1 ";
6760 // for (map<double,double>::iterator rtpoint = rtrelation31->rtmap.begin(); rtpoint != rtrelation31->rtmap.end(); rtpoint++){
6761 // cout << binres2->resmap[rtpoint->second] << " ";
6762 // }
6763 // cout << endl;
6764
6765 // cout << "RDIFF -2 ";
6766 // for (map<double,double>::iterator rtpoint = rtrelation41->rtmap.begin(); rtpoint != rtrelation41->rtmap.end(); rtpoint++){
6767 // cout << binres3->resmap[rtpoint->second] << " ";
6768 // }
6769 // cout << endl;
6770
6771 // cout << "RDIFF 2 ";
6772 // for (map<double,double>::iterator rtpoint = rtrelation51->rtmap.begin(); rtpoint != rtrelation51->rtmap.end(); rtpoint++){
6773 // cout << binres4->resmap[rtpoint->second] << " ";
6774 // }
6775 // cout << endl;
6776
6777 // add some extra info to each page
6778 if (settings && firstpage)
6779 {
6780 string fixfloat, fieldonoff;
6781 if (settings->set["UsePol0"].find("True") != string::npos)
6782 fixfloat = " - floating";
6783 else
6784 fixfloat = " - fixed";
6785 if (settings->set["RtRelation"].find("binned") != string::npos)
6786 fixfloat = "";
6787 if (settings->set["Solenoid"].find("True") != string::npos)
6788 fieldonoff = "ON";
6789 else
6790 fieldonoff = "OFF";
6791
6792 string pmarking =
6793 string("/Helvetica-Bold findfont 36 scalefont setfont 40 2190 moveto (Run:) show ") +
6794 string(Form("/Helvetica findfont 36 scalefont setfont 240 2190 moveto (%i) show ", (int)firstpage->runnumber)) +
6795
6796 string("/Helvetica-Bold findfont 36 scalefont setfont 40 2150 moveto (Iteration:) show ") +
6797 string(Form("/Helvetica findfont 36 scalefont setfont 240 2150 moveto (%02i) show ", firstpage->iter)) +
6798
6799 string("/Helvetica-Bold findfont 36 scalefont setfont 40 2110 moveto (Rt relation:) show ") +
6800 string(Form("/Helvetica findfont 36 scalefont setfont 240 2110 moveto (%s%s) show ", settings->set["RtRelation"].data(), fixfloat.data())) +
6801
6802 string("/Helvetica-Bold findfont 36 scalefont setfont 540 2190 moveto (Rt binning:) show ") +
6803 string(Form("/Helvetica findfont 36 scalefont setfont 740 2190 moveto (%s) show ", settings->set["RtBinning"].data())) +
6804
6805 string("/Helvetica-Bold findfont 36 scalefont setfont 540 2150 moveto (Rt level:) show ") +
6806
6807 string("/Helvetica-Bold findfont 36 scalefont setfont 540 2110 moveto (T0 level:) show ") +
6808
6809 string("/Helvetica-Bold findfont 36 scalefont setfont 1040 2190 moveto (Solenoid:) show ") +
6810 string(Form("/Helvetica findfont 36 scalefont setfont 1260 2190 moveto (%s) show ", fieldonoff.data())) +
6811
6812 string("/Helvetica-Bold findfont 36 scalefont setfont 1040 2150 moveto (SW release:) show ") +
6813 string(Form("/Helvetica findfont 36 scalefont setfont 1260 2150 moveto (%s) show ", settings->set["ReleaseRec"].data())) +
6814
6815 string("/Helvetica-Bold findfont 36 scalefont setfont 1040 2110 moveto (T0 Offset:) show ") +
6816 string(Form("/Helvetica findfont 36 scalefont setfont 1260 2110 moveto (%s) show ", settings->set["T0Offset"].data())) +
6817
6818 string("/Helvetica-Bold findfont 30 scalefont setfont 40 2060 moveto (Data:) show ") +
6819 string(Form("/Helvetica findfont 30 scalefont setfont 240 2060 moveto (%s) show ", settings->set["Inputdir"].data())) +
6820
6821 string("/Helvetica-Bold findfont 30 scalefont setfont 40 2020 moveto (Start const:) show ") +
6822 string(Form("/Helvetica findfont 30 scalefont setfont 240 2020 moveto (%s) show ", settings->set["StartConst"].data()));
6823 system((string("sed -i 's?showpage?" + pmarking + "showpage?g' itersum.ps")).data());
6824 }
6825
6826 // Add some graphs in a new direcrory "analysis"
6827 datafile = new TFile(argv[2], "UPDATE");
6828 datafile->cd();
6829 if (datafile->FindKey("analysis"))
6830 datafile->rmdir("analysis");
6831 TDirectory *adir = datafile->mkdir("analysis", "analysis");
6832 adir->cd();
6833 if (chipgraphA)
6834 chipgraphA->Write();
6835 if (chipgraphC)
6836 chipgraphC->Write();
6837 boardgraphA->Write();
6838 boardgraphC->Write();
6839 if (refboardgraphA)
6840 refboardgraphA->Write();
6841 if (refboardgraphC)
6842 refboardgraphC->Write();
6843 if (dvgraph0)
6844 dvgraph0->Write();
6845 if (dvgraph1)
6846 dvgraph1->Write();
6847 if (dvgraph2)
6848 dvgraph2->Write();
6849 datafile->Write();
6850 datafile->Close();
6851
6852 return 0;
6853}
6854
6855int tt_remove(int /*argc*/, char *argv[])
6856{
6857
6858 TFile *itersumfile = new TFile(argv[2], "UPDATE");
6859 if (itersumfile->FindKey("tracktuple"))
6860 {
6861 itersumfile->Delete("tracktuple;*");
6862 }
6863 if (itersumfile->FindKey("binhist"))
6864 {
6865 itersumfile->rmdir("binhist");
6866 }
6867 if (itersumfile->FindKey("analysis"))
6868 {
6869 itersumfile->rmdir("analysis");
6870 }
6871
6872 itersumfile->Write();
6873 itersumfile->Close();
6874
6875 return 0;
6876}
6877
6878int main (int argc, char *argv[])
6879{
6880
6881 gErrorIgnoreLevel = kFatal; // Explicitly remove all messages
6882
6883 if ((string(argv[1])).find("itersum") != std::string::npos)
6884 {
6885 cout << "GENERATING ITERATION SUMMARY PLOTS" << endl;
6886 itersum(argc, argv);
6887 }
6888
6889 if ((string(argv[1])).find("restore") != std::string::npos)
6890 {
6891 cout << "REMOVING THE TRACKTUPLE, BINHIST AND ANALYSE DIRECTORY" << endl;
6892 tt_remove(argc, argv);
6893 }
6894
6895 return 0;
6896}
float reshist[100]
the 1D residual histogram (100 bins)
Definition Calibrator.h:157
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static Double_t t0
int tt_remove(int, char *argv[])
void SetZAxis(TH2F *reshist0)
char detlet[3]
TGraphErrors * GetWidth(TH2F *histo)
TGraphErrors * GetMean(TH2F *histo)
void ResizePalette(TH2 *hist)
int itersum(int argc, char *argv[])
TGraphErrors * GetEntries(TH2F *histo)
TGraphErrors * GetPn(TH2F *histo)
TGraphErrors * GetMeanE(TH2F *histo)
string trim(string s)
bool do_expert
TGraphErrors * GetPWidth(TH2F *histo)
#define y
#define x
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41
Define macros for attributes used to control the static checker.
#define ATLAS_NO_CHECK_FILE_THREAD_SAFETY
BoardVariationsDiff(char *, char *, int)
BoardVariations(char *, int)
void DrawLines(float, float)
ChipVariations(char *, int)
DGraph(char *, string, const string &, int, int, bool)
DvGraph(char *, string, const string &, int, int, bool)
FirstPage(char *, TFile *)
HitStatistics(char *, bool)
NHitStack(TNtuple *, TLegend *, bool, int, int)
ResidualPlots(TFile *, bool)
std::vector< double > m_etdata
std::vector< double > m_tdata
TGraphErrors m_thegraph
RresTbin(TFile *, const string &, int)
std::vector< double > m_erdata
vector< TH1D * > reshists
map< double, double > resmap
std::vector< double > m_rdata
RtBinning(TDirectory *, const string &)
TGraphErrors * rtgraph
RtColor(char *, const string &, bool)
RtGraphs(char *, const string &, bool)
TGraphErrors * rtgraph
TGraphErrors * trgraph
map< string, string > set
SinDependence(TFile *, bool, bool, bool)
T0CalTypeXY(TNtuple *, int, float)
TEventList * elist[7]
void Draw(const string &, bool)
T0CalibTypeXY(char *, bool)
TBinnedRes(TFile *, vector< TH1D * >)
TRTPlots(TFile *, bool)
TextPage(const string &)
ToTDependence(TFile *, bool, bool, bool isAr)
XYMapsEC(char *, string, bool)
XYMaps(char *, string, bool)
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="")
int r
Definition globals.cxx:22
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138
int main()
Definition hello.cxx:18
double hmax(TH1 *&h)
Definition listroot.cxx:115
STL namespace.
TFile * file