Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VertexingQA.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file VertexingQA.C
1 #include "../CommonTools.h"
2 #include <sPhenixStyle.C>
3 
4 
6 {
8  TFile *qa_file_new = TFile::Open(newfile.c_str());
9  TFile *qa_file_ref = TFile::Open(reffile.c_str());
10 
11  TFile *outfilef = new TFile(outfile.c_str(), "recreate");
12 
13 
14  {
15  const char *hist_name_prefix = "QAG4SimulationTracking";
16  TString prefix = TString("h_") + hist_name_prefix + TString("_");
17 
18 
19  // obtain normalization
20  double Nevent_new = 1;
21  double Nevent_ref = 1;
22 
23  TH2 *h_new = (TH2 *) qa_file_new->GetObjectChecked(
24  prefix + TString("DCArPhi_pT"), "TH2");
25  assert(h_new);
26 
27  // h_new->Rebin(1, 2);
28  //h_new->Sumw2();
29  // h_new->Scale(1. / Nevent_new);
30 
31  TH2 *h_ref = NULL;
32  if (qa_file_ref)
33  {
34  h_ref = (TH2 *) qa_file_ref->GetObjectChecked(
35  prefix + TString("DCArPhi_pT"), "TH2");
36  assert(h_ref);
37 
38  // h_ref->Rebin(1, 2);
39  //h_ref->Sumw2();
40  h_ref->Scale(Nevent_new / Nevent_ref);
41  }
42 
43  TCanvas *c1 = new TCanvas(TString("QA_Draw_Tracking_DCArPhi") + TString("_") + hist_name_prefix,
44  TString("QA_Draw_Tracking_DCArPhi") + TString("_") + hist_name_prefix,
45  1800, 1000);
46  c1->Divide(4, 2);
47  int idx = 1;
48  TPad *p;
49 
50  vector<pair<double, double>> gpt_ranges{
51  {0, 0.5},
52  {0.5, 1},
53  {1, 1.5},
54  {1.5, 2},
55  {2, 4},
56  {4, 16},
57  {16, 40}};
58 
59  TF1 *f1 = nullptr;
60  TF1 *fit = nullptr;
61  Double_t sigma = 0;
62  Double_t sigma_unc = 0;
63  char resstr[500];
64  TLatex *res = nullptr;
65  for (auto pt_range : gpt_ranges)
66  {
67  //cout << __PRETTY_FUNCTION__ << " process " << pt_range.first << " - " << pt_range.second << " GeV/c";
68 
69  p = (TPad *) c1->cd(idx++);
70  c1->Update();
71  p->SetLogy();
72 
73  const double epsilon = 1e-6;
74  const int bin_start = h_new->GetXaxis()->FindBin(pt_range.first + epsilon);
75  const int bin_end = h_new->GetXaxis()->FindBin(pt_range.second - epsilon);
76 
77  TH1 *h_proj_new = h_new->ProjectionY(
78  TString::Format(
79  "%s_New_ProjX_%d_%d",
80  h_new->GetName(), bin_start, bin_end),
81  bin_start, bin_end);
82  if (pt_range.first < 2.0)
83  {
84  h_proj_new->GetXaxis()->SetRangeUser(-.05,.05);
85  h_proj_new->Rebin(5);
86  }
87  else
88  {
89  h_proj_new->GetXaxis()->SetRangeUser(-.01,.01);
90  }
91  h_proj_new->SetTitle(TString(hist_name_prefix) + TString::Format(
92  ": %.1f - %.1f GeV/c", pt_range.first, pt_range.second));
93  h_proj_new->GetXaxis()->SetTitle(TString::Format(
94  "DCA (r #phi) [cm]"));
95  h_proj_new->GetXaxis()->SetNdivisions(5,5);
96  f1 = new TF1("f1","gaus",-.01,.01);
97  h_proj_new->Fit(f1,"qm");
98  sigma = f1->GetParameter(2);
99  sigma_unc = f1->GetParError(2);
100 
101  TH1 *h_proj_ref = nullptr;
102  if (h_ref)
103  {
104  h_proj_ref =
105  h_ref->ProjectionY(
106  TString::Format(
107  "%s_Ref_ProjX_%d_%d",
108  h_new->GetName(), bin_start, bin_end),
109  bin_start, bin_end);
110  if (pt_range.first < 2.0)
111  {
112  //h_proj_ref->GetXaxis()->SetRangeUser(-.05,.05);
113  h_proj_ref->Rebin(5);
114  }
115  }
116 
117  DrawReference(h_proj_new, h_proj_ref);
118 
119  sprintf(resstr,"#sigma = %.5f #pm %.5f cm", sigma, sigma_unc);
120  res = new TLatex(0.325,0.825,resstr);
121  res->SetNDC();
122  res->SetTextSize(0.05);
123  res->SetTextAlign(13);
124  res->Draw();
125  }
126  p = (TPad *) c1->cd(idx++);
127  c1->Update();
128  TPaveText *pt = new TPaveText(.05,.1,.95,.8);
129  pt->AddText("No cuts");
130  pt->Draw();
131 
132  //SaveCanvas(c1, TString(qa_file_name_new) + TString("_") + TString(c1->GetName()), true);
133 
134 
135 
136  c1->Draw();
137  outfilef->cd();
138  c1->Write();
139 }
140 {
141  const char *hist_name_prefix = "QAG4SimulationTracking";
142  TString prefix = TString("h_") + hist_name_prefix + TString("_");
143 
144 
145  // obtain normalization
146  double Nevent_new = 1;
147  double Nevent_ref = 1;
148 
149  TH2 *h_new2 = (TH2 *) qa_file_new->GetObjectChecked(
150  prefix + TString("DCArPhi_pT_cuts"), "TH2");
151  assert(h_new2);
152 
153  // h_new->Rebin(1, 2);
154  //h_new2->Sumw2();
155  // h_new->Scale(1. / Nevent_new);
156 
157  TH2 *h_ref2 = NULL;
158  if (qa_file_ref)
159  {
160  h_ref2 = (TH2 *) qa_file_ref->GetObjectChecked(
161  prefix + TString("DCArPhi_pT_cuts"), "TH2");
162  assert(h_ref2);
163 
164  // h_ref->Rebin(1, 2);
165  //h_ref2->Sumw2();
166  h_ref2->Scale(Nevent_new / Nevent_ref);
167  }
168 
169  TCanvas *c2 = new TCanvas(TString("QA_Draw_Tracking_DCArPhi2") + TString("_") + hist_name_prefix,
170  TString("QA_Draw_Tracking_DCArPhi2") + TString("_") + hist_name_prefix,
171  1800, 1000);
172  c2->Divide(4, 2);
173  int idx2 = 1;
174  TPad *p2;
175 
176  vector<pair<double, double>> gpt_ranges2{
177  {0, 0.5},
178  {0.5, 1},
179  {1, 1.5},
180  {1.5, 2},
181  {2, 4},
182  {4, 16},
183  {16, 40}};
184  TF1 *f2 = nullptr;
185  TF1 *fit2 = nullptr;
186  Double_t sigma2 = 0;
187  Double_t sigma_unc2 = 0;
188  char resstr2[500];
189  TLatex *res2 = nullptr;
190  for (auto pt_range : gpt_ranges2)
191  {
192  //cout << __PRETTY_FUNCTION__ << " process " << pt_range.first << " - " << pt_range.second << " GeV/c";
193 
194  p2 = (TPad *) c2->cd(idx2++);
195  c2->Update();
196  p2->SetLogy();
197 
198  const double epsilon = 1e-6;
199  const int bin_start = h_new2->GetXaxis()->FindBin(pt_range.first + epsilon);
200  const int bin_end = h_new2->GetXaxis()->FindBin(pt_range.second - epsilon);
201 
202  TH1 *h_proj_new2 = h_new2->ProjectionY(
203  TString::Format(
204  "%s_New_ProjX_%d_%d",
205  h_new2->GetName(), bin_start, bin_end),
206  bin_start, bin_end);
207  if (pt_range.first < 2.0)
208  {
209  h_proj_new2->GetXaxis()->SetRangeUser(-.05,.05);
210  h_proj_new2->Rebin(5);
211  }
212  else
213  {
214  h_proj_new2->GetXaxis()->SetRangeUser(-.01,.01);
215  }
216  h_proj_new2->SetTitle(TString(hist_name_prefix) + TString::Format(
217  ": %.1f - %.1f GeV/c", pt_range.first, pt_range.second));
218  h_proj_new2->GetXaxis()->SetTitle(TString::Format(
219  "DCA (r #phi) [cm]"));
220  h_proj_new2->GetXaxis()->SetNdivisions(5,5);
221  f2 = new TF1("f2","gaus",-.01,.01);
222  h_proj_new2->Fit(f2 , "mq");
223  fit2 = h_proj_new2->GetFunction("f2");
224  sigma2 = fit2->GetParameter(2);
225  sigma_unc2 = fit2->GetParError(2);
226 
227  TH1 *h_proj_ref2 = nullptr;
228  if (h_ref2)
229  {
230  h_proj_ref2 =
231  h_ref2->ProjectionY(
232  TString::Format(
233  "%s_Ref_ProjX_%d_%d",
234  h_new2->GetName(), bin_start, bin_end),
235  bin_start, bin_end);
236  if (pt_range.first < 2.0)
237  {
238  //h_proj_ref->GetXaxis()->SetRangeUser(-.05,.05);
239  h_proj_ref2->Rebin(5);
240  }
241  }
242  DrawReference(h_proj_new2, h_proj_ref2);
243 
244  sprintf(resstr2,"#sigma = %.5f #pm %.5f cm", sigma2, sigma_unc2);
245  res2 = new TLatex(0.325,0.825,resstr2);
246  res2->SetNDC();
247  res2->SetTextSize(0.05);
248  res2->SetTextAlign(13);
249  res2->Draw();
250  }
251 
252 
253  p2 = (TPad *) c2->cd(idx2++);
254  c2->Update();
255  TPaveText *pt2 = new TPaveText(.05,.1,.95,.8);
256  pt2->AddText("Cuts: MVTX hits>=2, INTT hits>=1,");
257  pt2->AddText("TPC hits>=20");
258  pt2->Draw();
259 
260  //SaveCanvas(c2, TString(qa_file_name_new) + TString("_") + TString(c2->GetName()), true);
261 
262  c2->Draw();
263  outfilef->cd();
264  c2->Write();
265  }
266 
267 {
268  const char *hist_name_prefix = "QAG4SimulationTracking";
269  TString prefix = TString("h_") + hist_name_prefix + TString("_");
270 
271 
272  // obtain normalization
273  double Nevent_new = 1;
274  double Nevent_ref = 1;
275 
276  if (qa_file_new)
277  {
278  TH1 *h_norm = (TH1 *) qa_file_new->GetObjectChecked(
279  prefix + TString("Normalization"), "TH1");
280  assert(h_norm);
281 
282  Nevent_new = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Truth Track"));
283  }
284  if (qa_file_ref)
285  {
286  TH1 *h_norm = (TH1 *) qa_file_ref->GetObjectChecked(
287  prefix + TString("Normalization"), "TH1");
288  assert(h_norm);
289 
290  Nevent_ref = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Truth Track"));
291  }
292 
293  TH2 *h_new = (TH2 *) qa_file_new->GetObjectChecked(
294  prefix + TString("DCAZ_pT"), "TH2");
295  assert(h_new);
296 
297  // h_new->Rebin(1, 2);
298  //h_new->Sumw2();
299  // h_new->Scale(1. / Nevent_new);
300 
301  TH2 *h_ref = NULL;
302  if (qa_file_ref)
303  {
304  h_ref = (TH2 *) qa_file_ref->GetObjectChecked(
305  prefix + TString("DCAZ_pT"), "TH2");
306  assert(h_ref);
307 
308  // h_ref->Rebin(1, 2);
309  // h_ref->Sumw2();
310  h_ref->Scale(Nevent_new / Nevent_ref);
311  }
312 
313  TCanvas *c1 = new TCanvas(TString("QA_Draw_Tracking_DCAZ") + TString("_") + hist_name_prefix,
314  TString("QA_Draw_Tracking_DCAZ") + TString("_") + hist_name_prefix,
315  1800, 1000);
316  c1->Divide(4, 2);
317  int idx = 1;
318  TPad *p;
319 
320  vector<pair<double, double>> gpt_ranges{
321  {0, 0.5},
322  {0.5, 1},
323  {1, 1.5},
324  {1.5, 2},
325  {2, 4},
326  {4, 16},
327  {16, 40}};
328  TF1 *f1 = nullptr;
329  TF1 *fit = nullptr;
330  Double_t sigma = 0;
331  Double_t sigma_unc = 0;
332  char resstr[500];
333  TLatex *res = nullptr;
334  for (auto pt_range : gpt_ranges)
335  {
336  //cout << __PRETTY_FUNCTION__ << " process " << pt_range.first << " - " << pt_range.second << " GeV/c";
337 
338  p = (TPad *) c1->cd(idx++);
339  c1->Update();
340  p->SetLogy();
341 
342  const double epsilon = 1e-6;
343  const int bin_start = h_new->GetXaxis()->FindBin(pt_range.first + epsilon);
344  const int bin_end = h_new->GetXaxis()->FindBin(pt_range.second - epsilon);
345 
346  TH1 *h_proj_new = h_new->ProjectionY(
347  TString::Format(
348  "%s_New_ProjX_%d_%d",
349  h_new->GetName(), bin_start, bin_end),
350  bin_start, bin_end);
351  if (pt_range.first < 2.0)
352  {
353  h_proj_new->GetXaxis()->SetRangeUser(-.05, .05);
354  h_proj_new->Rebin(5);
355  }
356  else
357  {
358  h_proj_new->GetXaxis()->SetRangeUser(-.01, .01);
359  }
360  h_proj_new->SetTitle(TString(hist_name_prefix) + TString::Format(
361  ": %.1f - %.1f GeV/c", pt_range.first, pt_range.second));
362  h_proj_new->GetXaxis()->SetTitle(TString::Format(
363  "DCA (Z) [cm]"));
364  h_proj_new->GetXaxis()->SetNdivisions(5, 5);
365 
366  f1 = new TF1("f1", "gaus", -.01, .01);
367  h_proj_new->Fit(f1,"mq");
368  sigma = f1->GetParameter(2);
369  sigma_unc = f1->GetParError(2);
370 
371  TH1 *h_proj_ref = nullptr;
372  if (h_ref)
373  {
374  h_proj_ref =
375  h_ref->ProjectionY(
376  TString::Format(
377  "%s_Ref_ProjX_%d_%d",
378  h_new->GetName(), bin_start, bin_end),
379  bin_start, bin_end);
380  if (pt_range.first < 2.0)
381  {
382  //h_proj_ref->GetXaxis()->SetRangeUser(-.05,.05);
383  h_proj_ref->Rebin(5);
384  }
385  }
386  DrawReference(h_proj_new, h_proj_ref);
387  sprintf(resstr, "#sigma = %.5f #pm %.5f cm", sigma, sigma_unc);
388  res = new TLatex(0.325, 0.825, resstr);
389  res->SetNDC();
390  res->SetTextSize(0.05);
391  res->SetTextAlign(13);
392  res->Draw();
393  }
394  p = (TPad *) c1->cd(idx++);
395  c1->Update();
396  TPaveText *pt = new TPaveText(.05, .1, .95, .8);
397  pt->AddText("No cuts");
398  pt->Draw();
399 
400 // SaveCanvas(c1, TString(qa_file_name_new) + TString("_") + TString(c1->GetName()), true);
401 
402  c1->Draw();
403  outfilef->cd();
404  c1->Write();
405  }
406 
407 {
408 
409  const char *hist_name_prefix = "QAG4SimulationTracking";
410  TString prefix = TString("h_") + hist_name_prefix + TString("_");
411 
412 
413  // obtain normalization
414  double Nevent_new = 1;
415  double Nevent_ref = 1;
416 
417  // cuts plots
418  TH2 *h_new2 = (TH2 *) qa_file_new->GetObjectChecked(
419  prefix + TString("DCAZ_pT_cuts"), "TH2");
420  assert(h_new2);
421 
422  // h_new->Rebin(1, 2);
423  //h_new2->Sumw2();
424  // h_new->Scale(1. / Nevent_new);
425 
426  TH2 *h_ref2 = NULL;
427  if (qa_file_ref)
428  {
429  h_ref2 = (TH2 *) qa_file_ref->GetObjectChecked(
430  prefix + TString("DCAZ_pT_cuts"), "TH2");
431  assert(h_ref2);
432 
433  // h_ref->Rebin(1, 2);
434  //h_ref2->Sumw2();
435  h_ref2->Scale(Nevent_new / Nevent_ref);
436  }
437 
438  TCanvas *c2 = new TCanvas(TString("QA_Draw_Tracking_DCAZ2") + TString("_") + hist_name_prefix,
439  TString("QA_Draw_Tracking_DCAZ2") + TString("_") + hist_name_prefix,
440  1800, 1000);
441  c2->Divide(4, 2);
442  int idx2 = 1;
443  TPad *p2;
444 
445  vector<pair<double, double>> gpt_ranges2{
446  {0, 0.5},
447  {0.5, 1},
448  {1, 1.5},
449  {1.5, 2},
450  {2, 4},
451  {4, 16},
452  {16, 40}};
453  TF1 *f2 = nullptr;
454  TF1 *fit2 = nullptr;
455  Double_t sigma2 = 0;
456  Double_t sigma_unc2 = 0;
457  char resstr2[500];
458  TLatex *res2 = nullptr;
459  for (auto pt_range : gpt_ranges2)
460  {
461  //cout << __PRETTY_FUNCTION__ << " process " << pt_range.first << " - " << pt_range.second << " GeV/c";
462 
463  p2 = (TPad *) c2->cd(idx2++);
464  c2->Update();
465  p2->SetLogy();
466 
467  const double epsilon = 1e-6;
468  const int bin_start = h_new2->GetXaxis()->FindBin(pt_range.first + epsilon);
469  const int bin_end = h_new2->GetXaxis()->FindBin(pt_range.second - epsilon);
470 
471  TH1 *h_proj_new2 = h_new2->ProjectionY(
472  TString::Format(
473  "%s_New_ProjX_%d_%d",
474  h_new2->GetName(), bin_start, bin_end),
475  bin_start, bin_end);
476  if (pt_range.first < 2.0)
477  {
478  h_proj_new2->GetXaxis()->SetRangeUser(-.05, .05);
479  h_proj_new2->Rebin(5);
480  }
481  else
482  {
483  h_proj_new2->GetXaxis()->SetRangeUser(-.01, .01);
484  }
485  h_proj_new2->SetTitle(TString(hist_name_prefix) + TString::Format(
486  ": %.1f - %.1f GeV/c", pt_range.first, pt_range.second));
487  h_proj_new2->GetXaxis()->SetTitle(TString::Format(
488  "DCA (Z) [cm]"));
489  h_proj_new2->GetXaxis()->SetNdivisions(5, 5);
490 
491  f2 = new TF1("f2", "gaus", -.01, .01);
492  h_proj_new2->Fit(f2,"mq");
493  fit2 = h_proj_new2->GetFunction("f2");
494  sigma2 = fit2->GetParameter(2);
495  sigma_unc2 = fit2->GetParError(2);
496 
497  TH1 *h_proj_ref2 = nullptr;
498  if (h_ref2)
499  {
500  h_proj_ref2 =
501  h_ref2->ProjectionY(
502  TString::Format(
503  "%s_Ref_ProjX_%d_%d",
504  h_new2->GetName(), bin_start, bin_end),
505  bin_start, bin_end);
506  if (pt_range.first < 2.0)
507  {
508  //h_proj_ref->GetXaxis()->SetRangeUser(-.05,.05);
509  h_proj_ref2->Rebin(5);
510  }
511  }
512  DrawReference(h_proj_new2, h_proj_ref2);
513  sprintf(resstr2, "#sigma = %.5f #pm %.5f cm", sigma2, sigma_unc2);
514  res2 = new TLatex(0.325, 0.825, resstr2);
515  res2->SetNDC();
516  res2->SetTextSize(0.05);
517  res2->SetTextAlign(13);
518  res2->Draw();
519  }
520  p2 = (TPad *) c2->cd(idx2++);
521  c2->Update();
522  TPaveText *pt2 = new TPaveText(.05, .1, .95, .8);
523  pt2->AddText("Cuts: MVTX hits>=2, INTT hits>=1,");
524  pt2->AddText("TPC hits>=20");
525  pt2->Draw();
526 
527 // SaveCanvas(c2, TString(qa_file_name_new) + TString("_") + TString(c2->GetName()), true);
528  c2->Draw();
529  outfilef->cd();
530  c2->Write();
531  }
532 
533 {
534  const char *hist_name_prefix = "QAG4SimulationTracking";
535  TString prefix = TString("h_") + hist_name_prefix + TString("_");
536 
537 
538  // obtain normalization
539  double Nevent_new = 1;
540  double Nevent_ref = 1;
541 
542  if (qa_file_new)
543  {
544 
545  TH1 *h_norm = (TH1 *) qa_file_new->GetObjectChecked(
546  prefix + TString("Normalization"), "TH1");
547  assert(h_norm);
548 
549  Nevent_new = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Event"));
550  }
551  if (qa_file_ref)
552  {
553  TH1 *h_norm = (TH1 *) qa_file_ref->GetObjectChecked(
554  prefix + TString("Normalization"), "TH1");
555  assert(h_norm);
556 
557  Nevent_ref = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Event"));
558  }
559 
560  TCanvas *c1 = new TCanvas(TString("QA_Draw_Tracking_DCA_Resolution") + TString("_") + hist_name_prefix,
561  TString("QA_Draw_Tracking_DCA_Resolution") + TString("_") + hist_name_prefix,
562  1800, 1000);
563  c1->Divide(2, 1);
564  int idx = 1;
565  TPad *p;
566 
567  {
568  p = (TPad *) c1->cd(idx++);
569  c1->Update();
570  p->SetLogx();
571  TH1 *frame = p->DrawFrame(0.1, -0.01, 50, 0.01,
572  ";Truth p_{T} [GeV/c];<DCA (r #phi)> #pm #sigma(DCA (r #phi)) [cm]");
573  gPad->SetLeftMargin(.2);
574  frame->GetYaxis()->SetTitleOffset(2);
575  TLine *l = new TLine(0.1, 0, 50, 0);
576  l->SetLineColor(kGray);
577  l->Draw();
578 
579  TH2 *h_QAG4SimulationTracking_DCArPhi = (TH2 *) qa_file_new->GetObjectChecked(
580  prefix + "DCArPhi_pT_cuts", "TH2");
581  assert(h_QAG4SimulationTracking_DCArPhi);
582 
583  h_QAG4SimulationTracking_DCArPhi->Rebin2D(20, 1);
584 
585  // h_QAG4SimulationTracking_DCArPhi->Draw("colz");
586  TGraphErrors *ge_QAG4SimulationTracking_DCArPhi = FitProfile(h_QAG4SimulationTracking_DCArPhi);
587  ge_QAG4SimulationTracking_DCArPhi->Draw("pe");
588 
589  TGraphErrors *h_ratio_ref = NULL;
590  if (qa_file_ref)
591  {
592  TH2 *h_QAG4SimulationTracking_DCArPhi = (TH2 *) qa_file_ref->GetObjectChecked(
593  prefix + "DCArPhi_pT_cuts", "TH2");
594  assert(h_QAG4SimulationTracking_DCArPhi);
595 
596  h_QAG4SimulationTracking_DCArPhi->Rebin2D(20, 1);
597 
598  h_ratio_ref = FitProfile(h_QAG4SimulationTracking_DCArPhi);
599  ge_QAG4SimulationTracking_DCArPhi->Draw("pe");
600  }
601 
602  ge_QAG4SimulationTracking_DCArPhi->SetTitle("DCA (r #phi, #geq 2MVTX, #geq 1INTT, #geq 20TPC) [cm]");
603  DrawReference(ge_QAG4SimulationTracking_DCArPhi, h_ratio_ref, true);
604  }
605 
606  {
607  p = (TPad *) c1->cd(idx++);
608  c1->Update();
609  p->SetLogx();
610  TH1 *frame = p->DrawFrame(0.1, -0.01, 50, 0.01,
611  "DCA (Z) [cm];Truth p_{T} [GeV/c];<DCA (Z)> #pm #sigma(DCA (Z)) [cm]");
612  // gPad->SetLeftMargin(.2);
613  gPad->SetTopMargin(-1);
614  frame->GetYaxis()->SetTitleOffset(1.7);
615  //TLine *l = new TLine(0.1, 0, 50, 0);
616  //l->SetLineColor(kGray);
617  //l->Draw();
618  HorizontalLine(gPad, 1)->Draw();
619 
620  TH2 *h_QAG4SimulationTracking_DCAZ = (TH2 *) qa_file_new->GetObjectChecked(
621  prefix + "DCAZ_pT_cuts", "TH2");
622  assert(h_QAG4SimulationTracking_DCAZ);
623 
624  h_QAG4SimulationTracking_DCAZ->Rebin2D(40, 1);
625 
626  TGraphErrors *ge_QAG4SimulationTracking_DCAZ = FitProfile(h_QAG4SimulationTracking_DCAZ);
627  ge_QAG4SimulationTracking_DCAZ->Draw("pe");
628  ge_QAG4SimulationTracking_DCAZ->SetTitle("DCA (Z) [cm]");
629 
630  TGraphErrors *h_ratio_ref = NULL;
631  if (qa_file_ref)
632  {
633  TH2 *h_QAG4SimulationTracking_DCAZ = (TH2 *) qa_file_ref->GetObjectChecked(
634  prefix + "DCAZ_pT_cuts", "TH2");
635  assert(h_QAG4SimulationTracking_DCAZ);
636 
637  h_QAG4SimulationTracking_DCAZ->Rebin2D(40, 1);
638 
639  h_ratio_ref = FitProfile(h_QAG4SimulationTracking_DCAZ);
640  ge_QAG4SimulationTracking_DCAZ->Draw("pe");
641  }
642 
643  DrawReference(ge_QAG4SimulationTracking_DCAZ, h_ratio_ref, true);
644  }
645 
646  //SaveCanvas(c1, TString(qa_file_name_new) + TString("_") + TString(c1->GetName()), true);
647  c1->Draw();
648  outfilef->cd();
649  c1->Write();
650  }
651 
652  {
653  const char *hist_name_prefix = "QAG4SimulationTracking";
654  TString prefix = TString("h_") + hist_name_prefix + TString("_");
655 
656  // obtain normalization
657  double Nevent_new = 1;
658  double Nevent_ref = 1;
659 
660  if (qa_file_new)
661  {
662  TH1 *h_norm = (TH1 *) qa_file_new->GetObjectChecked(
663  prefix + TString("Normalization"), "TH1");
664  assert(h_norm);
665 
666  Nevent_new = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Truth Track"));
667  }
668  if (qa_file_ref)
669  {
670  TH1 *h_norm = (TH1 *) qa_file_ref->GetObjectChecked(
671  prefix + TString("Normalization"), "TH1");
672  assert(h_norm);
673 
674  Nevent_ref = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Truth Track"));
675  }
676 
677 
678 
679  TH2 *h_new = (TH2 *) qa_file_new->GetObjectChecked(
680  prefix + TString("SigmalizedDCArPhi_pT"), "TH2");
681  assert(h_new);
682 
683  // h_new->Rebin(1, 2);
684  //h_new->Sumw2();
685  // h_new->Scale(1. / Nevent_new);
686 
687  TH2 *h_ref = NULL;
688  if (qa_file_ref)
689  {
690  h_ref = (TH2 *) qa_file_ref->GetObjectChecked(
691  prefix + TString("SigmalizedDCArPhi_pT"), "TH2");
692  assert(h_ref);
693 
694  // h_ref->Rebin(1, 2);
695  //h_ref->Sumw2();
696  h_ref->Scale(Nevent_new / Nevent_ref);
697  }
698 
699  TCanvas *c1 = new TCanvas(TString("QA_Draw_Tracking_SigmalizedDCArPhi") + TString("_") + hist_name_prefix,
700  TString("QA_Draw_Tracking_SigmalizedDCArPhi") + TString("_") + hist_name_prefix,
701  1800, 1000);
702  c1->Divide(4, 2);
703  int idx = 1;
704  TPad *p;
705 
706  vector<pair<double, double>> gpt_ranges{
707  {0, 0.5},
708  {0.5, 1},
709  {1, 1.5},
710  {1.5, 2},
711  {2, 4},
712  {4, 16},
713  {16, 40}};
714  TF1 *f1 = nullptr;
715  TF1 *fit = nullptr;
716  Double_t sigma = 0;
717  Double_t sigma_unc = 0;
718  char resstr[500];
719  TLatex *res = nullptr;
720  for (auto pt_range : gpt_ranges)
721  {
722  // cout << __PRETTY_FUNCTION__ << " process " << pt_range.first << " - " << pt_range.second << " GeV/c";
723 
724  p = (TPad *) c1->cd(idx++);
725  c1->Update();
726  p->SetLogy();
727 
728  const double epsilon = 1e-6;
729  const int bin_start = h_new->GetXaxis()->FindBin(pt_range.first + epsilon);
730  const int bin_end = h_new->GetXaxis()->FindBin(pt_range.second - epsilon);
731 
732  TH1 *h_proj_new = h_new->ProjectionY(
733  TString::Format(
734  "%s_New_ProjX_%d_%d",
735  h_new->GetName(), bin_start, bin_end),
736  bin_start, bin_end);
737  h_proj_new->GetXaxis()->SetRangeUser(-5.,5.);
738  h_proj_new->Rebin(5);
739  h_proj_new->SetTitle(TString(hist_name_prefix) + TString::Format(
740  ": %.1f - %.1f GeV/c", pt_range.first, pt_range.second));
741  h_proj_new->GetXaxis()->SetTitle(TString::Format(
742  "Sigmalized DCA (r #phi)"));
743  h_proj_new->GetXaxis()->SetNdivisions(5,5);
744 
745  f1 = new TF1("f1","gaus",-4.,4.);
746  h_proj_new->Fit(f1, "mq");
747  sigma = f1->GetParameter(2);
748  sigma_unc = f1->GetParError(2);
749 
750  TH1 *h_proj_ref = nullptr;
751  if (h_ref)
752  {
753  h_proj_ref =
754  h_ref->ProjectionY(
755  TString::Format(
756  "%s_Ref_ProjX_%d_%d",
757  h_new->GetName(), bin_start, bin_end),
758  bin_start, bin_end);
759  //h_proj_ref->GetXaxis()->SetRangeUser(-.05,.05);
760  h_proj_ref->Rebin(5);
761  }
762 
763  DrawReference(h_proj_new, h_proj_ref);
764  sprintf(resstr,"#sigma = %.5f #pm %.5f", sigma, sigma_unc);
765  res = new TLatex(0.325,0.825,resstr);
766  res->SetNDC();
767  res->SetTextSize(0.05);
768  res->SetTextAlign(13);
769  res->Draw();
770  }
771  p = (TPad *) c1->cd(idx++);
772  c1->Update();
773  TPaveText *pt = new TPaveText(.05,.1,.95,.8);
774  pt->AddText("Cuts: MVTX hits>=2, INTT hits>=1,");
775  pt->AddText("TPC hits>=20");
776  pt->Draw();
777 
778  // SaveCanvas(c1, TString(qa_file_name_new) + TString("_") + TString(c1->GetName()), true);
779  c1->Draw();
780  outfilef->cd();
781  c1->Write();
782 }
783 
784  {
785 
786  const char *hist_name_prefix = "QAG4SimulationTracking";
787  TString prefix = TString("h_") + hist_name_prefix + TString("_");
788 
789  // obtain normalization
790  double Nevent_new = 1;
791  double Nevent_ref = 1;
792 
793  if (qa_file_new)
794  {
795  TH1 *h_norm = (TH1 *) qa_file_new->GetObjectChecked(
796  prefix + TString("Normalization"), "TH1");
797  assert(h_norm);
798 
799  Nevent_new = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Truth Track"));
800  }
801  if (qa_file_ref)
802  {
803  TH1 *h_norm = (TH1 *) qa_file_ref->GetObjectChecked(
804  prefix + TString("Normalization"), "TH1");
805  assert(h_norm);
806 
807  Nevent_ref = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Truth Track"));
808  }
809 
810  TH2 *h_new2 = (TH2 *) qa_file_new->GetObjectChecked(
811  prefix + TString("SigmalizedDCAZ_pT"), "TH2");
812  assert(h_new2);
813 
814  // h_new->Rebin(1, 2);
815  //h_new2->Sumw2();
816  // h_new->Scale(1. / Nevent_new);
817 
818  TH2 *h_ref2 = NULL;
819  if (qa_file_ref)
820  {
821  h_ref2 = (TH2 *) qa_file_ref->GetObjectChecked(
822  prefix + TString("SigmalizedDCAZ_pT"), "TH2");
823  assert(h_ref2);
824 
825  // h_ref->Rebin(1, 2);
826  //h_ref2->Sumw2();
827  h_ref2->Scale(Nevent_new / Nevent_ref);
828  }
829 
830  TCanvas *c2 = new TCanvas(TString("QA_Draw_Tracking_SigmalizedDCAZ") + TString("_") + hist_name_prefix,
831  TString("QA_Draw_Tracking_SigmalizedDCAZ") + TString("_") + hist_name_prefix,
832  1800, 1000);
833  c2->Divide(4, 2);
834  int idx2 = 1;
835  TPad *p2;
836 
837  vector<pair<double, double>> gpt_ranges2{
838  {0, 0.5},
839  {0.5, 1},
840  {1, 1.5},
841  {1.5, 2},
842  {2, 4},
843  {4, 16},
844  {16, 40}};
845  TF1 *f2 = nullptr;
846  TF1 *fit2 = nullptr;
847  Double_t sigma2 = 0;
848  Double_t sigma_unc2 = 0;
849  char resstr2[500];
850  TLatex *res2 = nullptr;
851  for (auto pt_range : gpt_ranges2)
852  {
853  // cout << __PRETTY_FUNCTION__ << " process " << pt_range.first << " - " << pt_range.second << " GeV/c";
854 
855  p2 = (TPad *) c2->cd(idx2++);
856  c2->Update();
857  p2->SetLogy();
858 
859  const double epsilon = 1e-6;
860  const int bin_start = h_new2->GetXaxis()->FindBin(pt_range.first + epsilon);
861  const int bin_end = h_new2->GetXaxis()->FindBin(pt_range.second - epsilon);
862 
863  TH1 *h_proj_new2 = h_new2->ProjectionY(
864  TString::Format(
865  "%s_New_ProjX_%d_%d",
866  h_new2->GetName(), bin_start, bin_end),
867  bin_start, bin_end);
868  h_proj_new2->GetXaxis()->SetRangeUser(-5.,5.);
869  h_proj_new2->Rebin(5);
870  h_proj_new2->SetTitle(TString(hist_name_prefix) + TString::Format(
871  ": %.1f - %.1f GeV/c", pt_range.first, pt_range.second));
872  h_proj_new2->GetXaxis()->SetTitle(TString::Format(
873  "Sigmalized DCA (Z)"));
874  h_proj_new2->GetXaxis()->SetNdivisions(5,5);
875 
876  f2 = new TF1("f2","gaus",-4.,4.);
877  h_proj_new2->Fit(f2, "mq");
878  fit2 = f2; //h_proj_new2->GetFunction("f2");
879  sigma2 = fit2->GetParameter(2);
880  sigma_unc2 = fit2->GetParError(2);
881 
882  TH1 *h_proj_ref2 = nullptr;
883  if (h_ref2)
884  {
885  h_proj_ref2 =
886  h_ref2->ProjectionY(
887  TString::Format(
888  "%s_Ref_ProjX_%d_%d",
889  h_new2->GetName(), bin_start, bin_end),
890  bin_start, bin_end);
891  //h_proj_ref->GetXaxis()->SetRangeUser(-.05,.05);
892  h_proj_ref2->Rebin(5);
893  }
894  DrawReference(h_proj_new2, h_proj_ref2);
895  sprintf(resstr2,"#sigma = %.5f #pm %.5f", sigma2, sigma_unc2);
896  res2 = new TLatex(0.325,0.825,resstr2);
897  res2->SetNDC();
898  res2->SetTextSize(0.05);
899  res2->SetTextAlign(13);
900  res2->Draw();
901  }
902  p2 = (TPad *) c2->cd(idx2++);
903  c2->Update();
904  TPaveText *pt2 = new TPaveText(.05,.1,.95,.8);
905  pt2->AddText("Cuts: MVTX hits>=2, INTT hits>=1,");
906  pt2->AddText("TPC hits>=20");
907  pt2->Draw();
908 
909  //SaveCanvas(c2, TString(qa_file_name_new) + TString("_") + TString(c2->GetName()), true);
910  c2->Draw();
911  outfilef->cd();
912  c2->Write();
913 }
914 
915 {
916  const char *hist_name_prefix = "QAG4SimulationTracking";
917  TString prefix = TString("h_") + hist_name_prefix + TString("_");
918 
919 
920  // obtain normalization
921  double Nevent_new = 1;
922  double Nevent_ref = 1;
923 
924  if (qa_file_new)
925  {
926 
927  TH1 *h_norm = (TH1 *) qa_file_new->GetObjectChecked(
928  prefix + TString("Normalization"), "TH1");
929  assert(h_norm);
930 
931  Nevent_new = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Event"));
932  }
933  if (qa_file_ref)
934  {
935  TH1 *h_norm = (TH1 *) qa_file_ref->GetObjectChecked(
936  prefix + TString("Normalization"), "TH1");
937  assert(h_norm);
938 
939  Nevent_ref = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Event"));
940  }
941 
942  TCanvas *c1 = new TCanvas(TString("QA_Draw_Tracking_SigmalizedDCA_Resolution") + TString("_") + hist_name_prefix,
943  TString("QA_Draw_Tracking_SigmalizedDCA_Resolution") + TString("_") + hist_name_prefix,
944  1800, 1000);
945  c1->Divide(2, 1);
946  int idx = 1;
947  TPad *p;
948 
949  {
950  p = (TPad *) c1->cd(idx++);
951  c1->Update();
952  p->SetLogx();
953  TH1 *frame = p->DrawFrame(0.1, -2, 50, 2,
954  ";Truth p_{T} [GeV/c];<Sigmalized DCA (r #phi)> #pm #sigma(Sigmalized DCA (r #phi))");
955  gPad->SetLeftMargin(.2);
956  frame->GetYaxis()->SetTitleOffset(2);
957  TLine *l = new TLine(0.1, 0, 50, 0);
958  l->SetLineColor(kGray);
959  l->Draw();
960  HorizontalLine(gPad, 1)->Draw();
961  HorizontalLine(gPad, -1)->Draw();
962 
963  TH2 *h_QAG4SimulationTracking_DCArPhi = (TH2 *) qa_file_new->GetObjectChecked(
964  prefix + "SigmalizedDCArPhi_pT", "TH2");
965  assert(h_QAG4SimulationTracking_DCArPhi);
966 
967  h_QAG4SimulationTracking_DCArPhi->Rebin2D(20, 1);
968 
969  // h_QAG4SimulationTracking_DCArPhi->Draw("colz");
970  TGraphErrors *ge_QAG4SimulationTracking_DCArPhi = FitProfile(h_QAG4SimulationTracking_DCArPhi);
971  ge_QAG4SimulationTracking_DCArPhi->Draw("pe");
972 
973  TGraphErrors *h_ratio_ref = NULL;
974  if (qa_file_ref)
975  {
976  TH2 *h_QAG4SimulationTracking_DCArPhi = (TH2 *) qa_file_ref->GetObjectChecked(
977  prefix + "SigmalizedDCArPhi_pT", "TH2");
978  assert(h_QAG4SimulationTracking_DCArPhi);
979 
980  h_QAG4SimulationTracking_DCArPhi->Rebin2D(20, 1);
981 
982  h_ratio_ref = FitProfile(h_QAG4SimulationTracking_DCArPhi);
983  ge_QAG4SimulationTracking_DCArPhi->Draw("pe");
984  }
985 
986  ge_QAG4SimulationTracking_DCArPhi->SetTitle("DCA_{r#phi}/#sigma[DCA_{r#phi}]");
987  DrawReference(ge_QAG4SimulationTracking_DCArPhi, h_ratio_ref, true);
988  }
989 
990  {
991  p = (TPad *) c1->cd(idx++);
992  c1->Update();
993  p->SetLogx();
994  TH1 *frame = p->DrawFrame(0.1, -2, 50, 2,
995  "DCA_z/#sigma[DCA_z];Truth p_{T} [GeV/c];<Sigmalized DCA (Z)> #pm #sigma(Sigmalized DCA (Z))");
996  // gPad->SetLeftMargin(.2);
997  gPad->SetTopMargin(-1);
998  frame->GetYaxis()->SetTitleOffset(1.7);
999  TLine *l = new TLine(0.1, 0, 50, 0);
1000  l->SetLineColor(kGray);
1001  l->Draw();
1002  HorizontalLine(gPad, 1)->Draw();
1003  HorizontalLine(gPad, -1)->Draw();
1004 
1005  TH2 *h_QAG4SimulationTracking_DCAZ = (TH2 *) qa_file_new->GetObjectChecked(
1006  prefix + "SigmalizedDCAZ_pT", "TH2");
1007  assert(h_QAG4SimulationTracking_DCAZ);
1008 
1009  h_QAG4SimulationTracking_DCAZ->Rebin2D(40, 1);
1010 
1011  TGraphErrors *ge_QAG4SimulationTracking_DCAZ = FitProfile(h_QAG4SimulationTracking_DCAZ);
1012  ge_QAG4SimulationTracking_DCAZ->Draw("pe");
1013  ge_QAG4SimulationTracking_DCAZ->SetTitle("DCA_z/#sigma[DCA_z]");
1014 
1015  TGraphErrors *h_ratio_ref = NULL;
1016  if (qa_file_ref)
1017  {
1018  TH2 *h_QAG4SimulationTracking_DCAZ = (TH2 *) qa_file_ref->GetObjectChecked(
1019  prefix + "SigmalizedDCAZ_pT", "TH2");
1020  assert(h_QAG4SimulationTracking_DCAZ);
1021 
1022  h_QAG4SimulationTracking_DCAZ->Rebin2D(40, 1);
1023 
1024  h_ratio_ref = FitProfile(h_QAG4SimulationTracking_DCAZ);
1025  ge_QAG4SimulationTracking_DCAZ->Draw("pe");
1026  }
1027 
1028  DrawReference(ge_QAG4SimulationTracking_DCAZ, h_ratio_ref, true);
1029  }
1030 
1031  //SaveCanvas(c1, TString(qa_file_name_new) + TString("_") + TString(c1->GetName()), true);
1032  c1->Draw();
1033 
1034  outfilef->cd();
1035  c1->Write();
1036 }
1037 
1038 
1039 {
1040  const char *hist_name_prefix = "QAG4SimulationVertex_SvtxVertexMap";
1041  TString prefix = TString("h_") + hist_name_prefix + TString("_");
1042 
1043 
1044  TCanvas *c1 = new TCanvas(TString("QA_Draw_Vertex_nVertex") +
1045  TString("_") + hist_name_prefix,
1046  TString("QA_Draw_Vertex_nVertex") +
1047  TString("_") + hist_name_prefix,
1048  1800, 1000);
1049  c1->Divide(2, 2);
1050  int idx = 1;
1051  TPad *p;
1052 
1053  {
1054  static const int nrebin = 1;
1055 
1056  p = (TPad *)c1->cd(idx++);
1057  c1->Update();
1058  // p->SetLogx();
1059  p->SetGridy();
1060 
1061  TH1 *h_pass =
1062  (TH1 *)qa_file_new->GetObjectChecked(prefix + "gntracks", "TH1");
1063  assert(h_pass);
1064 
1065  h_pass->Rebin(nrebin);
1066 
1067  // h_ratio->GetXaxis()->SetRangeUser(min_Et, max_Et);
1068  h_pass->GetYaxis()->SetTitle("Counts");
1069  // h_pass->GetYaxis()->SetRangeUser(-0, 1.);
1070 
1071  TH1 *h_ref = NULL;
1072  if (qa_file_ref) {
1073  h_ref =
1074  (TH1 *)qa_file_ref->GetObjectChecked(prefix + "gntracks", "TH1");
1075  assert(h_ref);
1076 
1077  h_ref->Rebin(nrebin);
1078  }
1079 
1080  h_pass->SetTitle(TString(hist_name_prefix) + ": gntracks");
1081 
1082  DrawReference(h_pass, h_ref, false);
1083  }
1084 
1085  {
1086  static const int nrebin = 1;
1087 
1088  p = (TPad *)c1->cd(idx++);
1089  c1->Update();
1090  // p->SetLogx();
1091  p->SetGridy();
1092 
1093  TH1 *h_pass =
1094  (TH1 *)qa_file_new->GetObjectChecked(prefix + "gntracksmaps", "TH1");
1095  assert(h_pass);
1096 
1097  h_pass->Rebin(nrebin);
1098 
1099  // h_ratio->GetXaxis()->SetRangeUser(min_Et, max_Et);
1100  h_pass->GetYaxis()->SetTitle("Counts");
1101  // h_pass->GetYaxis()->SetRangeUser(-0, 1.);
1102 
1103  TH1 *h_ref = NULL;
1104  if (qa_file_ref) {
1105  h_ref =
1106  (TH1 *)qa_file_ref->GetObjectChecked(prefix + "gntracksmaps", "TH1");
1107  assert(h_pass);
1108 
1109  h_ref->Rebin(nrebin);
1110  }
1111 
1112  h_pass->SetTitle(TString(hist_name_prefix) + ": gntracksmaps");
1113 
1114  DrawReference(h_pass, h_ref, false);
1115  }
1116 
1117  {
1118  static const int nrebin = 1;
1119 
1120  p = (TPad *)c1->cd(idx++);
1121  c1->Update();
1122  // p->SetLogx();
1123  p->SetGridy();
1124 
1125  TH1 *h_pass =
1126  (TH1 *)qa_file_new->GetObjectChecked(prefix + "ntracks", "TH1");
1127  assert(h_pass);
1128 
1129  h_pass->Rebin(nrebin);
1130 
1131  // h_ratio->GetXaxis()->SetRangeUser(min_Et, max_Et);
1132  h_pass->GetYaxis()->SetTitle("Counts");
1133  // h_pass->GetYaxis()->SetRangeUser(-0, 1.);
1134 
1135  TH1 *h_ref = NULL;
1136  if (qa_file_ref) {
1137  h_ref =
1138  (TH1 *)qa_file_ref->GetObjectChecked(prefix + "ntracks", "TH1");
1139  assert(h_pass);
1140 
1141  h_ref->Rebin(nrebin);
1142  }
1143 
1144  h_pass->SetTitle(TString(hist_name_prefix) + ": ntracks");
1145 
1146  DrawReference(h_pass, h_ref, false);
1147  }
1148 
1149  {
1150  static const int nrebin = 1;
1151 
1152  p = (TPad *)c1->cd(idx++);
1153  c1->Update();
1154  // p->SetLogx();
1155  p->SetGridy();
1156 
1157  TH1 *h_pass =
1158  (TH1 *)qa_file_new->GetObjectChecked(prefix + "ntracks_cuts", "TH1");
1159  assert(h_pass);
1160 
1161  h_pass->Rebin(nrebin);
1162 
1163  // h_ratio->GetXaxis()->SetRangeUser(min_Et, max_Et);
1164  h_pass->GetYaxis()->SetTitle("Counts");
1165  // h_pass->GetYaxis()->SetRangeUser(-0, 1.);
1166 
1167  TH1 *h_ref = NULL;
1168  if (qa_file_ref) {
1169  h_ref =
1170  (TH1 *)qa_file_ref->GetObjectChecked(prefix + "ntracks_cuts", "TH1");
1171  assert(h_pass);
1172 
1173  h_ref->Rebin(nrebin);
1174  }
1175 
1176  h_pass->SetTitle(TString(hist_name_prefix) + ": ntracks (#geq 2 MVTX)");
1177 
1178  DrawReference(h_pass, h_ref, false);
1179  }
1180 
1181  // SaveCanvas(c1,
1182  // TString(qa_file_name_new) + TString("_") + TString(c1->GetName()),
1183  // true);
1184 
1185  c1->Draw();
1186  outfilef->cd();
1187  c1->Write();
1188 }
1189 
1190 {
1191  const char *hist_name_prefix = "QAG4SimulationVertex_SvtxVertexMap";
1192  TString prefix = TString("h_") + hist_name_prefix + TString("_");
1193 
1194 
1195  // X-direction
1196 
1197  TH2 *h_new = (TH2 *) qa_file_new->GetObjectChecked(
1198  prefix + TString("vxRes_gvz"), "TH2");
1199  assert(h_new);
1200 
1201  // h_new->Rebin2D(1, 5);
1202  //h_new->Sumw2();
1203  // h_new->GetXaxis()->SetRangeUser(-15,15);
1204  // h_new->Scale(1. / Nevent_new);
1205 
1206  TH2 *h_ref = NULL;
1207  if (qa_file_ref)
1208  {
1209  h_ref = (TH2 *) qa_file_ref->GetObjectChecked(
1210  prefix + TString("vxRes_gvz"), "TH2");
1211  assert(h_ref);
1212 
1213  // h_ref->Rebin2D(1, 5);
1214  //h_ref->Sumw2();
1215  // h_ref->Scale(Nevent_new / Nevent_ref);
1216  }
1217 
1218  TCanvas *c1 = new TCanvas(TString("QA_Draw_Vertex_Resolution_x") + TString("_") + hist_name_prefix,
1219  TString("QA_Draw_Vertex_Resolution_x") + TString("_") + hist_name_prefix,
1220  1800, 1000);
1221  c1->Divide(2,1);
1222  int idx = 1;
1223  TPad *p;
1224 
1225  vector<pair<double, double>> gvz_ranges{
1226  {-10.0, 10.0}};
1227  TF1 *f1 = nullptr;
1228  TF1 *fit = nullptr;
1229  Double_t sigma = 0;
1230  Double_t sigma_unc = 0;
1231  char resstr[500];
1232  TLatex *res = nullptr;
1233  for (auto gvz_range : gvz_ranges)
1234  {
1235  // cout << __PRETTY_FUNCTION__ << " process " << gvz_range.first << " - " << gvz_range.second << " cm";
1236 
1237  p = (TPad *) c1->cd(idx++);
1238  c1->Update();
1239  // p->SetLogy();
1240 
1241  const double epsilon = 1e-6;
1242  const int bin_start = h_new->GetXaxis()->FindBin(gvz_range.first + epsilon);
1243  const int bin_end = h_new->GetXaxis()->FindBin(gvz_range.second - epsilon);
1244 
1245  TH1 *h_proj_new = h_new->ProjectionY(
1246  TString::Format(
1247  "%s_New_ProjX_%d_%d",
1248  h_new->GetName(), bin_start, bin_end));
1249  // bin_start, bin_end);
1250 
1251  h_proj_new->SetTitle(TString(hist_name_prefix) + TString::Format(
1252  ": %.1f - %.1f cm - gvz", gvz_range.first, gvz_range.second));
1253  h_proj_new->GetXaxis()->SetTitle(TString::Format(
1254  "Vertex Resolution (x) [cm]"));
1255  h_proj_new->GetXaxis()->SetNdivisions(5,5);
1256  h_proj_new->GetXaxis()->SetRangeUser(-0.002,0.002);
1257 
1258  f1 = new TF1("f1","gaus",-.002,.002);
1259  h_proj_new->Fit(f1, "qm");
1260  sigma = f1->GetParameter(2);
1261  sigma_unc = f1->GetParError(2);
1262 
1263 
1264  TH1 *h_proj_ref = nullptr;
1265  if (h_ref)
1266  {
1267  h_proj_ref =
1268  h_ref->ProjectionY(
1269  TString::Format(
1270  "%s_Ref_ProjX_%d_%d",
1271  h_new->GetName(), bin_start, bin_end));
1272  // bin_start, bin_end);
1273  h_proj_ref->GetXaxis()->SetRangeUser(-10,10);
1274  }
1275 
1276  DrawReference(h_proj_new, h_proj_ref);
1277  sprintf(resstr,"#sigma = %.5f #pm %.5f cm", sigma, sigma_unc);
1278  res = new TLatex(0.325,0.825,resstr);
1279  res->SetNDC();
1280  res->SetTextSize(0.05);
1281  res->SetTextAlign(13);
1282  res->Draw();
1283  }
1284  p = (TPad *) c1->cd(idx++);
1285  c1->Update();
1286  gPad->SetLeftMargin(.2);
1287  //h_new->GetYaxis()->SetTitleOffset(2);
1288  h_new->Draw("colz");
1289 
1290 
1291 // SaveCanvas(c1, TString(qa_file_name_new) + TString("_") + TString(c1->GetName()), true);
1292  c1->Draw();
1293 
1294  // Y-direction
1295 
1296  TH2 *h_new2 = (TH2 *) qa_file_new->GetObjectChecked(
1297  prefix + TString("vyRes_gvz"), "TH2");
1298  assert(h_new2);
1299 
1300  // h_new->Rebin(1, 2);
1301  //h_new2->Sumw2();
1302  // h_new->Scale(1. / Nevent_new);
1303 
1304  TH2 *h_ref2 = NULL;
1305  if (qa_file_ref)
1306  {
1307  h_ref2 = (TH2 *) qa_file_ref->GetObjectChecked(
1308  prefix + TString("vyRes_gvz"), "TH2");
1309  assert(h_ref2);
1310 
1311  // h_ref->Rebin(1, 2);
1312  //h_ref2->Sumw2();
1313  // h_ref->Scale(Nevent_new / Nevent_ref);
1314  }
1315 
1316  TCanvas *c2 = new TCanvas(TString("QA_Draw_Vertex_Resolution_y") + TString("_") + hist_name_prefix,
1317  TString("QA_Draw_Vertex_Resolution_y") + TString("_") + hist_name_prefix,
1318  1800, 1000);
1319  c2->Divide(2,1);
1320  int idx2 = 1;
1321  TPad *p2;
1322 
1323  vector<pair<double, double>> gvz_ranges2{
1324  {-10.0, 10.0}};
1325  TF1 *f2 = nullptr;
1326  TF1 *fit2 = nullptr;
1327  Double_t sigma2 = 0;
1328  Double_t sigma_unc2 = 0;
1329  char resstr2[500];
1330  TLatex *res2 = nullptr;
1331  for (auto gvz_range : gvz_ranges2)
1332  {
1333  //cout << __PRETTY_FUNCTION__ << " process " << gvz_range.first << " - " << gvz_range.second << " cm";
1334 
1335  p2 = (TPad *) c2->cd(idx2++);
1336  c2->Update();
1337  // p->SetLogy();
1338 
1339  const double epsilon = 1e-6;
1340  const int bin_start = h_new2->GetXaxis()->FindBin(gvz_range.first + epsilon);
1341  const int bin_end = h_new2->GetXaxis()->FindBin(gvz_range.second - epsilon);
1342 
1343  TH1 *h_proj_new2 = h_new2->ProjectionY(
1344  TString::Format(
1345  "%s_New_ProjX_%d_%d",
1346  h_new2->GetName(), bin_start, bin_end),
1347  bin_start, bin_end);
1348 
1349  h_proj_new2->SetTitle(TString(hist_name_prefix) + TString::Format(
1350  ": %.1f - %.1f cm - gvz", gvz_range.first, gvz_range.second));
1351  h_proj_new2->GetXaxis()->SetTitle(TString::Format(
1352  "Vertex Resolution (y) [cm]"));
1353  h_proj_new2->GetXaxis()->SetNdivisions(5,5);
1354  h_proj_new2->GetXaxis()->SetRangeUser(-0.002,0.002);
1355 
1356  f2 = new TF1("f2","gaus",-.002,.002);
1357  h_proj_new2->Fit(f2, "qm");
1358  fit2 = h_proj_new2->GetFunction("f2");
1359  sigma2 = fit2->GetParameter(2);
1360  sigma_unc2 = fit2->GetParError(2);
1361 
1362  TH1 *h_proj_ref2 = nullptr;
1363  if (h_ref2)
1364  {
1365  h_proj_ref2 =
1366  h_ref2->ProjectionY(
1367  TString::Format(
1368  "%s_Ref_ProjX_%d_%d",
1369  h_new2->GetName(), bin_start, bin_end),
1370  bin_start, bin_end);
1371  }
1372 
1373  DrawReference(h_proj_new2, h_proj_ref2);
1374  sprintf(resstr2,"#sigma = %.5f #pm %.5f cm", sigma2, sigma_unc2);
1375  res2 = new TLatex(0.325,0.825,resstr2);
1376  res2->SetNDC();
1377  res2->SetTextSize(0.05);
1378  res2->SetTextAlign(13);
1379  res2->Draw();
1380  }
1381  p2 = (TPad *) c2->cd(idx2++);
1382  c2->Update();
1383  gPad->SetLeftMargin(.2);
1384  //h_new2->GetYaxis()->SetTitleOffset(2);
1385  h_new2->Draw("colz");
1386 
1387  //SaveCanvas(c2, TString(qa_file_name_new) + TString("_") + TString(c2->GetName()), true);
1388  c2->Draw();
1389 
1390  // Z-direction
1391 
1392  TH2 *h_new3 = (TH2 *) qa_file_new->GetObjectChecked(
1393  prefix + TString("vzRes_gvz"), "TH2");
1394  assert(h_new3);
1395 
1396  // h_new->Rebin(1, 2);
1397  //h_new3->Sumw2();
1398  // h_new->Scale(1. / Nevent_new);
1399 
1400  TH2 *h_ref3 = NULL;
1401  if (qa_file_ref)
1402  {
1403  h_ref3 = (TH2 *) qa_file_ref->GetObjectChecked(
1404  prefix + TString("vzRes_gvz"), "TH2");
1405  assert(h_ref3);
1406 
1407  // h_ref->Rebin(1, 2);
1408  //h_ref3->Sumw2();
1409  // h_ref->Scale(Nevent_new / Nevent_ref);
1410  }
1411 
1412  TCanvas *c3 = new TCanvas(TString("QA_Draw_Vertex_Resolution_z") + TString("_") + hist_name_prefix,
1413  TString("QA_Draw_Vertex_Resolution_z") + TString("_") + hist_name_prefix,
1414  1800, 1000);
1415  c3->Divide(2,1);
1416  int idx3 = 1;
1417  TPad *p3;
1418 
1419  vector<pair<double, double>> gvz_ranges3{
1420  {-10.0, 10.0}};
1421  TF1 *f3 = nullptr;
1422  TF1 *fit3 = nullptr;
1423  Double_t sigma3 = 0;
1424  Double_t sigma_unc3 = 0;
1425  char resstr3[500];
1426  TLatex *res3 = nullptr;
1427  for (auto gvz_range : gvz_ranges3)
1428  {
1429  // cout << __PRETTY_FUNCTION__ << " process " << gvz_range.first << " - " << gvz_range.second << " cm";
1430 
1431  p3 = (TPad *) c3->cd(idx3++);
1432  c3->Update();
1433  // p->SetLogy();
1434 
1435  const double epsilon = 1e-6;
1436  const int bin_start = h_new3->GetXaxis()->FindBin(gvz_range.first + epsilon);
1437  const int bin_end = h_new3->GetXaxis()->FindBin(gvz_range.second - epsilon);
1438 
1439  TH1 *h_proj_new3 = h_new3->ProjectionY(
1440  TString::Format(
1441  "%s_New_ProjX_%d_%d",
1442  h_new3->GetName(), bin_start, bin_end),
1443  bin_start, bin_end);
1444 
1445  h_proj_new3->SetTitle(TString(hist_name_prefix) + TString::Format(
1446  ": %.1f - %.1f cm -gvz", gvz_range.first, gvz_range.second));
1447  h_proj_new3->GetXaxis()->SetTitle(TString::Format(
1448  "Vertex Resolution (z) [cm]"));
1449  h_proj_new3->GetXaxis()->SetNdivisions(5,5);
1450  h_proj_new3->GetXaxis()->SetRangeUser(-0.002,0.002);
1451 
1452  f3 = new TF1("f3","gaus",-.002,.002);
1453  h_proj_new3->Fit(f3, "qm");
1454  fit3 = h_proj_new3->GetFunction("f3");
1455  sigma3 = fit3->GetParameter(2);
1456  sigma_unc3 = fit3->GetParError(2);
1457 
1458  TH1 *h_proj_ref3 = nullptr;
1459  if (h_ref3)
1460  {
1461  h_proj_ref3 =
1462  h_ref3->ProjectionY(
1463  TString::Format(
1464  "%s_Ref_ProjX_%d_%d",
1465  h_new3->GetName(), bin_start, bin_end),
1466  bin_start, bin_end);
1467  }
1468 
1469  DrawReference(h_proj_new3, h_proj_ref3);
1470  sprintf(resstr3,"#sigma = %.5f #pm %.5f cm", sigma3, sigma_unc3);
1471  res3 = new TLatex(0.325,0.825,resstr3);
1472  res3->SetNDC();
1473  res3->SetTextSize(0.05);
1474  res3->SetTextAlign(13);
1475  res3->Draw();
1476  }
1477  p3 = (TPad *) c3->cd(idx3++);
1478  c3->Update();
1479  gPad->SetLeftMargin(.2);
1480  //h_new3->GetYaxis()->SetTitleOffset(2);
1481  h_new3->Draw("colz");
1482 
1483 // SaveCanvas(c3, TString(qa_file_name_new) + TString("_") + TString(c3->GetName()), true);
1484  c3->Draw();
1485  outfilef->cd();
1486  c3->Write();
1487 }
1488 
1489 }