EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QA_Draw_CEMC_G4Hit.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file QA_Draw_CEMC_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 
22 using namespace std;
23 
25  const char *qa_file_name_new =
26  "/phenix/u/jinhuang/links/ePHENIX_work/sPHENIX_work/production_analysis_updates/spacal1d/fieldmap/G4Hits_sPHENIX_pi-_eta0.30_32GeV-0000.root_qa.root",
27  const char *qa_file_name_ref =
28  "/phenix/u/jinhuang/links/ePHENIX_work/sPHENIX_work/production_analysis_updates/spacal1d/fieldmap/G4Hits_sPHENIX_pi+_eta0.30_32GeV-0000.root_qa.root")
29 
30 {
32  TVirtualFitter::SetDefaultFitter("Minuit2");
33 
34  TFile *qa_file_new = new TFile(qa_file_name_new);
35  assert(qa_file_new->IsOpen());
36 
37  TFile *qa_file_ref = NULL;
38  if (qa_file_name_ref)
39  {
40  qa_file_ref = new TFile(qa_file_name_ref);
41  assert(qa_file_ref->IsOpen());
42  }
43 
44  TCanvas *c1 = new TCanvas("QA_Draw_CEMC_G4Hit", "QA_Draw_CEMC_G4Hit", 1800, 900);
45  c1->Divide(4, 2);
46  int idx = 1;
47  TPad *p;
48 
49  p = (TPad *) c1->cd(idx++);
50  c1->Update();
51  p->SetLogz();
52 
53  TH2F *h_QAG4Sim_CEMC_G4Hit_XY = (TH2F *) qa_file_new->GetObjectChecked(
54  "h_QAG4Sim_CEMC_G4Hit_XY", "TH2F");
55  assert(h_QAG4Sim_CEMC_G4Hit_XY);
56  h_QAG4Sim_CEMC_G4Hit_XY->GetYaxis()->SetTitleOffset(1.5);
57  h_QAG4Sim_CEMC_G4Hit_XY->Draw("COLZ");
58 
59  p = (TPad *) c1->cd(idx++);
60  c1->Update();
61  p->SetLogz();
62 
63  TH2F *h_QAG4Sim_CEMC_G4Hit_RZ = (TH2F *) qa_file_new->GetObjectChecked(
64  "h_QAG4Sim_CEMC_G4Hit_RZ", "TH2F");
65  assert(h_QAG4Sim_CEMC_G4Hit_RZ);
66  h_QAG4Sim_CEMC_G4Hit_RZ->GetYaxis()->SetTitleOffset(1.5);
67  h_QAG4Sim_CEMC_G4Hit_RZ->Draw("COLZ");
68 
69  p = (TPad *) c1->cd(idx++);
70  c1->Update();
71  // p->SetLogz();
72 
73  {
74  TH2F *h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection =
75  (TH2F *) qa_file_new->GetObjectChecked(
76  "h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection", "TH2F");
77  assert(h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection);
78 
79  TH1D *proj_new =
80  h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection->ProjectionX(
81  "qa_file_new_h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection_px");
82 
83  proj_new->Scale(1. / proj_new->GetSum());
84 
85  TH1D *proj_ref = NULL;
86  if (qa_file_ref)
87  {
88  TH2F *h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection =
89  (TH2F *) qa_file_ref->GetObjectChecked(
90  "h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection", "TH2F");
91  assert(h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection);
92 
93  proj_ref = h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection->ProjectionX(
94  "qa_file_ref_h_QAG4Sim_CEMC_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_CEMC_G4Hit_LateralTruthProjection =
110  (TH2F *) qa_file_new->GetObjectChecked(
111  "h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection", "TH2F");
112  assert(h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection);
113 
114  TH1D *proj_new =
115  h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection->ProjectionY(
116  "qa_file_new_h_QAG4Sim_CEMC_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_CEMC_G4Hit_LateralTruthProjection =
124  (TH2F *) qa_file_ref->GetObjectChecked(
125  "h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection", "TH2F");
126  assert(h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection);
127 
128  proj_ref = h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection->ProjectionY(
129  "qa_file_ref_h_QAG4Sim_CEMC_G4Hit_LateralTruthProjection_py");
130  proj_ref->Scale(1. / proj_ref->GetSum());
131  }
132 
133  proj_new->GetYaxis()->SetTitle("Normalized energy distribution");
134  proj_new->GetXaxis()->SetRangeUser(-10, 10);
135 
136  DrawReference(proj_new, proj_ref);
137  }
138 
139  p = (TPad *) c1->cd(idx++);
140  c1->Update();
141  p->SetLogx();
142  p->SetLogy();
143 
144  {
145  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
146  "h_QAG4Sim_CEMC_G4Hit_HitTime", "TH1F");
147  assert(h_new);
148 
149  h_new->Rebin(5);
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_CEMC_G4Hit_HitTime", "TH1F");
157  assert(h_ref);
158 
159  h_ref->Rebin(5);
160  h_ref->Scale(1. / h_ref->GetSum());
161  }
162 
163  h_new->GetYaxis()->SetTitleOffset(1.5);
164  h_new->GetYaxis()->SetTitle("Normalized energy per bin");
165  // h_new->GetXaxis()->SetRangeUser(-0, .1);
166 
167  DrawReference(h_new, h_ref);
168  }
169 
170  p = (TPad *) c1->cd(idx++);
171  c1->Update();
172  // p->SetLogx();
173  p->SetLogy();
174 
175  {
176  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
177  "h_QAG4Sim_CEMC_G4Hit_FractionTruthEnergy", "TH1F");
178  assert(h_new);
179 
180  h_new->Rebin(20);
181  h_new->Sumw2();
182  h_new->Scale(1. / h_new->GetSum());
183 
184  TH1F *h_ref = NULL;
185  if (qa_file_ref)
186  {
187  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
188  "h_QAG4Sim_CEMC_G4Hit_FractionTruthEnergy", "TH1F");
189  assert(h_ref);
190 
191  h_ref->Rebin(20);
192  h_ref->Scale(1. / h_ref->GetSum());
193  }
194 
195  h_new->GetYaxis()->SetTitleOffset(1.5);
196  h_new->GetYaxis()->SetTitle("Probability per bin");
197  // h_new->GetXaxis()->SetRangeUser(-0, .1);
198 
199  DrawReference(h_new, h_ref);
200  }
201 
202  p = (TPad *) c1->cd(idx++);
203  c1->Update();
204  // p->SetLogz();
205 
206  {
207  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
208  "h_QAG4Sim_CEMC_G4Hit_VSF", "TH1F");
209  assert(h_new);
210 
211  h_new->Rebin(2);
212  h_new->Sumw2();
213  h_new->Scale(1. / h_new->GetSum());
214 
215  TH1F *h_ref = NULL;
216  if (qa_file_ref)
217  {
218  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
219  "h_QAG4Sim_CEMC_G4Hit_VSF", "TH1F");
220  assert(h_ref);
221 
222  h_ref->Rebin(2);
223  h_ref->Sumw2();
224  h_ref->Scale(1. / h_ref->GetSum());
225  }
226 
227  h_new->GetYaxis()->SetTitleOffset(1.5);
228  h_new->GetYaxis()->SetTitle("Probability per bin");
229  h_new->GetXaxis()->SetRangeUser(-0, .1);
230 
231  DrawReference(h_new, h_ref);
232  }
233 
234  p = (TPad *) c1->cd(idx++);
235  c1->Update();
236  // p->SetLogz();
237 
238  {
239  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
240  "h_QAG4Sim_CEMC_G4Hit_FractionEMVisibleEnergy", "TH1F");
241  assert(h_new);
242 
243  h_new->Rebin(4);
244  h_new->Sumw2();
245  h_new->Scale(1. / h_new->GetSum());
246 
247  TH1F *h_ref = NULL;
248  if (qa_file_ref)
249  {
250  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
251  "h_QAG4Sim_CEMC_G4Hit_FractionEMVisibleEnergy", "TH1F");
252  assert(h_ref);
253 
254  h_ref->Rebin(4);
255  h_ref->Scale(1. / h_ref->GetSum());
256  }
257 
258  h_new->GetYaxis()->SetTitleOffset(1.5);
259  h_new->GetYaxis()->SetTitle("Probability per bin");
260  // h_new->GetXaxis()->SetRangeUser(-0, .1);
261 
262  DrawReference(h_new, h_ref);
263  }
264 
265 // PutInputFileName(c1, .04, qa_file_name_new, qa_file_name_ref);
266  SaveCanvas(c1, TString(qa_file_name_new) + TString(c1->GetName()), true);
267 }