EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QA_Draw_HCALOUT_G4Hit.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file QA_Draw_HCALOUT_G4Hit.C
1 // $Id: $
2 
11 #include <TFile.h>
12 #include <TLine.h>
13 #include <TString.h>
14 #include <TTree.h>
15 #include <cassert>
16 #include <cmath>
17 
18 //some common style files
19 #include "sPhenixStyle.C"
20 #include "QA_Draw_Utility.C"
21 using namespace std;
22 
24  const char *qa_file_name_new =
25  "/phenix/u/jinhuang/links/ePHENIX_work/sPHENIX_work/production_analysis_updates/spacal1d/fieldmap/G4Hits_sPHENIX_pi-_eta0.30_32GeV-0000.root_qa.root",
26  const char *qa_file_name_ref =
27  "/phenix/u/jinhuang/links/ePHENIX_work/sPHENIX_work/production_analysis_updates/spacal1d/fieldmap/G4Hits_sPHENIX_pi+_eta0.30_32GeV-0000.root_qa.root")
28 {
30  TVirtualFitter::SetDefaultFitter("Minuit2");
31 
32  TFile *qa_file_new = new TFile(qa_file_name_new);
33  assert(qa_file_new->IsOpen());
34 
35  TFile *qa_file_ref = NULL;
36  if (qa_file_name_ref)
37  {
38  qa_file_ref = new TFile(qa_file_name_ref);
39  assert(qa_file_ref->IsOpen());
40  }
41 
42  TCanvas *c1 = new TCanvas("QA_Draw_HCALOUT_G4Hit", "QA_Draw_HCALOUT_G4Hit",
43  1800, 900);
44  c1->Divide(4, 2);
45  int idx = 1;
46  TPad *p;
47 
48  p = (TPad *) c1->cd(idx++);
49  c1->Update();
50  p->SetLogz();
51 
52  TH2F *h_QAG4Sim_HCALOUT_G4Hit_XY = (TH2F *) qa_file_new->GetObjectChecked(
53  "h_QAG4Sim_HCALOUT_G4Hit_XY", "TH2F");
54  assert(h_QAG4Sim_HCALOUT_G4Hit_XY);
55  h_QAG4Sim_HCALOUT_G4Hit_XY->GetYaxis()->SetTitleOffset(1.5);
56  h_QAG4Sim_HCALOUT_G4Hit_XY->Draw("COLZ");
57 
58  p = (TPad *) c1->cd(idx++);
59  c1->Update();
60  p->SetLogz();
61 
62  TH2F *h_QAG4Sim_HCALOUT_G4Hit_RZ = (TH2F *) qa_file_new->GetObjectChecked(
63  "h_QAG4Sim_HCALOUT_G4Hit_RZ", "TH2F");
64  assert(h_QAG4Sim_HCALOUT_G4Hit_RZ);
65  h_QAG4Sim_HCALOUT_G4Hit_RZ->GetYaxis()->SetTitleOffset(1.5);
66  h_QAG4Sim_HCALOUT_G4Hit_RZ->Draw("COLZ");
67 
68  p = (TPad *) c1->cd(idx++);
69  c1->Update();
70  // p->SetLogz();
71 
72  {
73  TH2F *h_QAG4Sim_HCALOUT_G4Hit_LateralTruthProjection =
74  (TH2F *) qa_file_new->GetObjectChecked(
75  "h_QAG4Sim_HCALOUT_G4Hit_LateralTruthProjection", "TH2F");
76  assert(h_QAG4Sim_HCALOUT_G4Hit_LateralTruthProjection);
77 
78  TH1D *proj_new =
79  h_QAG4Sim_HCALOUT_G4Hit_LateralTruthProjection->ProjectionX(
80  "qa_file_new_h_QAG4Sim_HCALOUT_G4Hit_LateralTruthProjection_px");
81 
82  proj_new->Scale(1. / proj_new->GetSum());
83 
84  TH1D *proj_ref = NULL;
85  if (qa_file_ref)
86  {
87  TH2F *h_QAG4Sim_HCALOUT_G4Hit_LateralTruthProjection =
88  (TH2F *) qa_file_ref->GetObjectChecked(
89  "h_QAG4Sim_HCALOUT_G4Hit_LateralTruthProjection", "TH2F");
90  assert(h_QAG4Sim_HCALOUT_G4Hit_LateralTruthProjection);
91 
92  proj_ref =
93  h_QAG4Sim_HCALOUT_G4Hit_LateralTruthProjection->ProjectionX(
94  "qa_file_ref_h_QAG4Sim_HCALOUT_G4Hit_LateralTruthProjection_px");
95  proj_ref->Scale(1. / proj_ref->GetSum());
96  }
97 
98  proj_new->GetYaxis()->SetTitle("Normalized energy distribution");
99  // proj_new->GetXaxis()->SetRangeUser(-10, 10);
100 
101  DrawReference(proj_new, proj_ref);
102  }
103 
104  p = (TPad *) c1->cd(idx++);
105  c1->Update();
106  // p->SetLogz();
107 
108  {
109  TH2F *h_QAG4Sim_HCALOUT_G4Hit_LateralTruthProjection =
110  (TH2F *) qa_file_new->GetObjectChecked(
111  "h_QAG4Sim_HCALOUT_G4Hit_LateralTruthProjection", "TH2F");
112  assert(h_QAG4Sim_HCALOUT_G4Hit_LateralTruthProjection);
113 
114  TH1D *proj_new =
115  h_QAG4Sim_HCALOUT_G4Hit_LateralTruthProjection->ProjectionY(
116  "qa_file_new_h_QAG4Sim_HCALOUT_G4Hit_LateralTruthProjection_py");
117 
118  proj_new->Scale(1. / proj_new->GetSum());
119 
120  TH1D *proj_ref = NULL;
121  if (qa_file_ref)
122  {
123  TH2F *h_QAG4Sim_HCALOUT_G4Hit_LateralTruthProjection =
124  (TH2F *) qa_file_ref->GetObjectChecked(
125  "h_QAG4Sim_HCALOUT_G4Hit_LateralTruthProjection", "TH2F");
126  assert(h_QAG4Sim_HCALOUT_G4Hit_LateralTruthProjection);
127 
128  proj_ref =
129  h_QAG4Sim_HCALOUT_G4Hit_LateralTruthProjection->ProjectionY(
130  "qa_file_ref_h_QAG4Sim_HCALOUT_G4Hit_LateralTruthProjection_py");
131  proj_ref->Scale(1. / proj_ref->GetSum());
132  }
133 
134  proj_new->GetYaxis()->SetTitle("Normalized energy distribution");
135  // proj_new->GetXaxis()->SetRangeUser(-10, 10);
136 
137  DrawReference(proj_new, proj_ref);
138  }
139 
140  p = (TPad *) c1->cd(idx++);
141  c1->Update();
142  p->SetLogx();
143  p->SetLogy();
144 
145  {
146  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
147  "h_QAG4Sim_HCALOUT_G4Hit_HitTime", "TH1F");
148  assert(h_new);
149 
150  h_new->Scale(1. / h_new->GetSum());
151 
152  TH1F *h_ref = NULL;
153  if (qa_file_ref)
154  {
155  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
156  "h_QAG4Sim_HCALOUT_G4Hit_HitTime", "TH1F");
157  assert(h_ref);
158 
159  h_ref->Scale(1. / h_ref->GetSum());
160  }
161 
162  h_new->GetYaxis()->SetTitleOffset(1.5);
163  h_new->GetYaxis()->SetTitle("Normalized energy per bin");
164  // h_new->GetXaxis()->SetRangeUser(-0, .1);
165 
166  DrawReference(h_new, h_ref);
167  }
168 
169  p = (TPad *) c1->cd(idx++);
170  c1->Update();
171  // p->SetLogx();
172  p->SetLogy();
173 
174  {
175  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
176  "h_QAG4Sim_HCALOUT_G4Hit_FractionTruthEnergy", "TH1F");
177  assert(h_new);
178 
179  h_new->Rebin(20);
180  h_new->Sumw2();
181  h_new->Scale(1. / h_new->GetSum());
182 
183  TH1F *h_ref = NULL;
184  if (qa_file_ref)
185  {
186  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
187  "h_QAG4Sim_HCALOUT_G4Hit_FractionTruthEnergy", "TH1F");
188  assert(h_ref);
189 
190  h_ref->Rebin(20);
191  h_ref->Scale(1. / h_ref->GetSum());
192  }
193 
194  h_new->GetYaxis()->SetTitleOffset(1.5);
195  h_new->GetYaxis()->SetTitle("Probability per bin");
196  // h_new->GetXaxis()->SetRangeUser(-0, .1);
197 
198  DrawReference(h_new, h_ref);
199  }
200 
201  p = (TPad *) c1->cd(idx++);
202  c1->Update();
203  // p->SetLogz();
204 
205  {
206  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
207  "h_QAG4Sim_HCALOUT_G4Hit_VSF", "TH1F");
208  assert(h_new);
209 
210  // h_new->Rebin(2);
211  // h_new->Sumw2();
212  h_new->Scale(1. / h_new->GetSum());
213 
214  TH1F *h_ref = NULL;
215  if (qa_file_ref)
216  {
217  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
218  "h_QAG4Sim_HCALOUT_G4Hit_VSF", "TH1F");
219  assert(h_ref);
220 
221  h_ref->Scale(1. / h_ref->GetSum());
222  }
223 
224  h_new->GetYaxis()->SetTitleOffset(1.5);
225  h_new->GetYaxis()->SetTitle("Probability per bin");
226  h_new->GetXaxis()->SetRangeUser(-0, .1);
227 
228  DrawReference(h_new, h_ref);
229  }
230 
231  p = (TPad *) c1->cd(idx++);
232  c1->Update();
233  // p->SetLogz();
234 
235  {
236  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
237  "h_QAG4Sim_HCALOUT_G4Hit_FractionEMVisibleEnergy", "TH1F");
238  assert(h_new);
239 
240  h_new->Rebin(4);
241  h_new->Sumw2();
242  h_new->Scale(1. / h_new->GetSum());
243 
244  TH1F *h_ref = NULL;
245  if (qa_file_ref)
246  {
247  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
248  "h_QAG4Sim_HCALOUT_G4Hit_FractionEMVisibleEnergy", "TH1F");
249  assert(h_ref);
250 
251  h_ref->Rebin(4);
252  h_ref->Scale(1. / h_ref->GetSum());
253  }
254 
255  h_new->GetYaxis()->SetTitleOffset(1.5);
256  h_new->GetYaxis()->SetTitle("Probability per bin");
257  // h_new->GetXaxis()->SetRangeUser(-0, .1);
258 
259  DrawReference(h_new, h_ref);
260  }
261 
262 // PutInputFileName(c1, .04, qa_file_name_new, qa_file_name_ref);
263  SaveCanvas(c1, TString(qa_file_name_new) + TString(c1->GetName()), true);
264 }