EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QA_Draw_HCALIN_TowerCluster.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file QA_Draw_HCALIN_TowerCluster.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 {
31  TVirtualFitter::SetDefaultFitter("Minuit2");
32 
33  TFile *qa_file_new = new TFile(qa_file_name_new);
34  assert(qa_file_new->IsOpen());
35 
36  TFile *qa_file_ref = NULL;
37  if (qa_file_name_ref)
38  {
39  qa_file_ref = new TFile(qa_file_name_ref);
40  assert(qa_file_ref->IsOpen());
41  }
42 
43  TCanvas *c1 = new TCanvas("QA_Draw_HCALIN_TowerCluster",
44  "QA_Draw_HCALIN_TowerCluster", 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->SetLogx();
52  p->SetLogy();
53 
54  {
55  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
56  "h_QAG4Sim_HCALIN_Tower_1x1", "TH1F");
57  assert(h_new);
58 
59  h_new->Scale(1. / h_new->GetSum());
60 
61  TH1F *h_ref = NULL;
62  if (qa_file_ref)
63  {
64  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
65  "h_QAG4Sim_HCALIN_Tower_1x1", "TH1F");
66  assert(h_ref);
67 
68  h_ref->Scale(1. / h_ref->GetSum());
69  }
70 
71  h_new->GetYaxis()->SetTitleOffset(1.5);
72  h_new->GetYaxis()->SetTitle("Normalized tower count per bin");
73  // h_new->GetXaxis()->SetRangeUser(-0, .1);
74 
75  DrawReference(h_new, h_ref);
76  }
77 
78  p = (TPad *) c1->cd(idx++);
79  c1->Update();
80  p->SetLogx();
81  p->SetLogy();
82 
83  {
84  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
85  "h_QAG4Sim_HCALIN_Tower_3x3", "TH1F");
86  assert(h_new);
87 
88  h_new->Scale(1. / h_new->GetSum());
89 
90  TH1F *h_ref = NULL;
91  if (qa_file_ref)
92  {
93  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
94  "h_QAG4Sim_HCALIN_Tower_3x3", "TH1F");
95  assert(h_ref);
96 
97  h_ref->Scale(1. / h_ref->GetSum());
98  }
99 
100  h_new->GetYaxis()->SetTitleOffset(1.5);
101  h_new->GetYaxis()->SetTitle("Normalized tower count per bin");
102  // h_new->GetXaxis()->SetRangeUser(-0, .1);
103 
104  DrawReference(h_new, h_ref);
105  }
106 
107  p = (TPad *) c1->cd(idx++);
108  c1->Update();
109  // p->SetLogx();
110  p->SetLogy();
111 
112  {
113  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
114  "h_QAG4Sim_HCALIN_Tower_1x1_max", "TH1F");
115  assert(h_new);
116 
117  h_new->Rebin(40);
118  h_new->Sumw2();
119  h_new->Scale(1. / h_new->GetSum());
120 
121  TH1F *h_ref = NULL;
122  if (qa_file_ref)
123  {
124  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
125  "h_QAG4Sim_HCALIN_Tower_1x1_max", "TH1F");
126  assert(h_ref);
127 
128  h_ref->Rebin(40);
129  h_ref->Scale(1. / h_ref->GetSum());
130  }
131 
132  h_new->GetYaxis()->SetTitleOffset(1.5);
133  h_new->GetYaxis()->SetTitle("Probability per bin");
134  // h_new->GetXaxis()->SetRangeUser(-0, .1);
135 
136  DrawReference(h_new, h_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_HCALIN_Tower_4x4_max", "TH1F");
147  assert(h_new);
148 
149  h_new->Rebin(40);
150  h_new->Sumw2();
151  h_new->Scale(1. / h_new->GetSum());
152 
153  TH1F *h_ref = NULL;
154  if (qa_file_ref)
155  {
156  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
157  "h_QAG4Sim_HCALIN_Tower_4x4_max", "TH1F");
158  assert(h_ref);
159 
160  h_ref->Rebin(40);
161  h_ref->Scale(1. / h_ref->GetSum());
162  }
163 
164  h_new->GetYaxis()->SetTitleOffset(1.5);
165  h_new->GetYaxis()->SetTitle("Probability per bin");
166  // h_new->GetXaxis()->SetRangeUser(-0, .1);
167 
168  DrawReference(h_new, h_ref);
169  }
170 
171  p = (TPad *) c1->cd(idx++);
172  c1->Update();
173  p->SetLogz();
174 
175  TH2F *h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection =
176  (TH2F *) qa_file_new->GetObjectChecked(
177  "h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection", "TH2F");
178  assert(h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection);
179  h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection->GetYaxis()->SetTitleOffset(
180  1.5);
181  // h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection->GetXaxis()->SetRangeUser(-5,
182  // 5);
183  // h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection->GetYaxis()->SetRangeUser(-5,
184  // 5);
185  h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection->Draw("COLZ");
186 
187  p = (TPad *) c1->cd(idx++);
188  c1->Update();
189  // p->SetLogz();
190 
191  {
192  TH2F *h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection =
193  (TH2F *) qa_file_new->GetObjectChecked(
194  "h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection", "TH2F");
195  assert(h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection);
196 
197  TH1D *proj_new =
198  h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection->ProjectionX(
199  "qa_file_new_h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection_px");
200  proj_new->Rebin(4);
201 
202  proj_new->Scale(1. / proj_new->GetSum());
203 
204  TH1D *proj_ref = NULL;
205  if (qa_file_ref)
206  {
207  TH2F *h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection =
208  (TH2F *) qa_file_ref->GetObjectChecked(
209  "h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection", "TH2F");
210  assert(h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection);
211 
212  proj_ref =
213  h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection->ProjectionX(
214  "qa_file_ref_h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection_px");
215  proj_ref->Rebin(4);
216  proj_ref->Scale(1. / proj_ref->GetSum());
217  }
218 
219  proj_new->GetYaxis()->SetTitleOffset(1.);
220  proj_new->GetXaxis()->SetTitleOffset(1.);
221  proj_new->GetYaxis()->SetTitle("Normalized energy distribution");
222  // proj_new->GetXaxis()->SetRangeUser(-10, 10);
223 
224  DrawReference(proj_new, proj_ref);
225  }
226 
227  p = (TPad *) c1->cd(idx++);
228  c1->Update();
229  // p->SetLogz();
230 
231  {
232  TH2F *h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection =
233  (TH2F *) qa_file_new->GetObjectChecked(
234  "h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection", "TH2F");
235  assert(h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection);
236 
237  TH1D *proj_new =
238  h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection->ProjectionY(
239  "qa_file_new_h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection_py");
240 
241  proj_new->Rebin(4);
242  proj_new->Scale(1. / proj_new->GetSum());
243 
244  TH1D *proj_ref = NULL;
245  if (qa_file_ref)
246  {
247  TH2F *h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection =
248  (TH2F *) qa_file_ref->GetObjectChecked(
249  "h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection", "TH2F");
250  assert(h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection);
251 
252  proj_ref =
253  h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection->ProjectionY(
254  "qa_file_ref_h_QAG4Sim_HCALIN_Cluster_LateralTruthProjection_py");
255  proj_ref->Rebin(4);
256  proj_ref->Scale(1. / proj_ref->GetSum());
257  }
258 
259  proj_new->GetYaxis()->SetTitleOffset(1.);
260  proj_new->GetXaxis()->SetTitleOffset(1.);
261  proj_new->GetYaxis()->SetTitle("Normalized energy distribution");
262  // proj_new->GetXaxis()->SetRangeUser(-10, 10);
263 
264  DrawReference(proj_new, proj_ref);
265  }
266 
267  p = (TPad *) c1->cd(idx++);
268  c1->Update();
269  p->SetLogy();
270 
271  {
272  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
273  "h_QAG4Sim_HCALIN_Cluster_BestMatchERatio", "TH1F");
274  assert(h_new);
275 
276  h_new->Rebin(2);
277  h_new->Sumw2();
278  h_new->Scale(1. / h_new->GetSum());
279 
280  TH1F *h_ref = NULL;
281  if (qa_file_ref)
282  {
283  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
284  "h_QAG4Sim_HCALIN_Cluster_BestMatchERatio", "TH1F");
285  assert(h_ref);
286 
287  h_ref->Rebin(2);
288  h_ref->Scale(1. / h_ref->GetSum());
289  }
290 
291  h_new->GetYaxis()->SetTitleOffset(1.5);
292  h_new->GetYaxis()->SetTitle("Probability per bin");
293  // h_new->GetXaxis()->SetRangeUser(-0, .1);
294 
295  DrawReference(h_new, h_ref);
296  }
297 
298 // PutInputFileName(c1, .04, qa_file_name_new, qa_file_name_ref);
299  SaveCanvas(c1, TString(qa_file_name_new) + TString(c1->GetName()), true);
300 }