EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QA_Draw_CEMC_TowerCluster.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file QA_Draw_CEMC_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 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 
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_CEMC_TowerCluster", "QA_Draw_CEMC_TowerCluster", 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->SetLogx();
51  p->SetLogy();
52 
53  {
54  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
55  "h_QAG4Sim_CEMC_Tower_1x1", "TH1F");
56  assert(h_new);
57 
58  h_new->Scale(1. / h_new->GetSum());
59 
60  TH1F *h_ref = NULL;
61  if (qa_file_ref)
62  {
63  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
64  "h_QAG4Sim_CEMC_Tower_1x1", "TH1F");
65  assert(h_ref);
66 
67  h_ref->Scale(1. / h_ref->GetSum());
68  }
69 
70  h_new->GetYaxis()->SetTitleOffset(1.5);
71  h_new->GetYaxis()->SetTitle("Normalized tower count per bin");
72  // h_new->GetXaxis()->SetRangeUser(-0, .1);
73 
74  DrawReference(h_new, h_ref);
75  }
76 
77  p = (TPad *) c1->cd(idx++);
78  c1->Update();
79  p->SetLogx();
80  p->SetLogy();
81 
82  {
83  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
84  "h_QAG4Sim_CEMC_Tower_3x3", "TH1F");
85  assert(h_new);
86 
87  h_new->Scale(1. / h_new->GetSum());
88 
89  TH1F *h_ref = NULL;
90  if (qa_file_ref)
91  {
92  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
93  "h_QAG4Sim_CEMC_Tower_3x3", "TH1F");
94  assert(h_ref);
95 
96  h_ref->Scale(1. / h_ref->GetSum());
97  }
98 
99  h_new->GetYaxis()->SetTitleOffset(1.5);
100  h_new->GetYaxis()->SetTitle("Normalized tower count per bin");
101  // h_new->GetXaxis()->SetRangeUser(-0, .1);
102 
103  DrawReference(h_new, h_ref);
104  }
105 
106  p = (TPad *) c1->cd(idx++);
107  c1->Update();
108  // p->SetLogx();
109  p->SetLogy();
110 
111  {
112  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
113  "h_QAG4Sim_CEMC_Tower_1x1_max", "TH1F");
114  assert(h_new);
115 
116  h_new->Rebin(40);
117  h_new->Sumw2();
118  h_new->Scale(1. / h_new->GetSum());
119 
120  TH1F *h_ref = NULL;
121  if (qa_file_ref)
122  {
123  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
124  "h_QAG4Sim_CEMC_Tower_1x1_max", "TH1F");
125  assert(h_ref);
126 
127  h_ref->Rebin(40);
128  h_ref->Scale(1. / h_ref->GetSum());
129  }
130 
131  h_new->GetYaxis()->SetTitleOffset(1.5);
132  h_new->GetYaxis()->SetTitle("Probability per bin");
133  // h_new->GetXaxis()->SetRangeUser(-0, .1);
134 
135  DrawReference(h_new, h_ref);
136  }
137 
138  p = (TPad *) c1->cd(idx++);
139  c1->Update();
140  // p->SetLogx();
141  p->SetLogy();
142 
143  {
144  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
145  "h_QAG4Sim_CEMC_Tower_4x4_max", "TH1F");
146  assert(h_new);
147 
148  h_new->Rebin(40);
149  h_new->Sumw2();
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_Tower_4x4_max", "TH1F");
157  assert(h_ref);
158 
159  h_ref->Rebin(40);
160  h_ref->Scale(1. / h_ref->GetSum());
161  }
162 
163  h_new->GetYaxis()->SetTitleOffset(1.5);
164  h_new->GetYaxis()->SetTitle("Probability 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->SetLogz();
173 
174  TH2F *h_QAG4Sim_CEMC_Cluster_LateralTruthProjection =
175  (TH2F *) qa_file_new->GetObjectChecked(
176  "h_QAG4Sim_CEMC_Cluster_LateralTruthProjection", "TH2F");
177  assert(h_QAG4Sim_CEMC_Cluster_LateralTruthProjection);
178  h_QAG4Sim_CEMC_Cluster_LateralTruthProjection->GetYaxis()->SetTitleOffset(
179  1.5);
180  h_QAG4Sim_CEMC_Cluster_LateralTruthProjection->GetXaxis()->SetRangeUser(-5,
181  5);
182  h_QAG4Sim_CEMC_Cluster_LateralTruthProjection->GetYaxis()->SetRangeUser(-5,
183  5);
184  h_QAG4Sim_CEMC_Cluster_LateralTruthProjection->Draw("COLZ");
185 
186  p = (TPad *) c1->cd(idx++);
187  c1->Update();
188  // p->SetLogz();
189 
190  {
191  TH2F *h_QAG4Sim_CEMC_Cluster_LateralTruthProjection =
192  (TH2F *) qa_file_new->GetObjectChecked(
193  "h_QAG4Sim_CEMC_Cluster_LateralTruthProjection", "TH2F");
194  assert(h_QAG4Sim_CEMC_Cluster_LateralTruthProjection);
195 
196  TH1D *proj_new =
197  h_QAG4Sim_CEMC_Cluster_LateralTruthProjection->ProjectionX(
198  "qa_file_new_h_QAG4Sim_CEMC_Cluster_LateralTruthProjection_px");
199 
200  proj_new->Scale(1. / proj_new->GetSum());
201 
202  TH1D *proj_ref = NULL;
203  if (qa_file_ref)
204  {
205  TH2F *h_QAG4Sim_CEMC_Cluster_LateralTruthProjection =
206  (TH2F *) qa_file_ref->GetObjectChecked(
207  "h_QAG4Sim_CEMC_Cluster_LateralTruthProjection", "TH2F");
208  assert(h_QAG4Sim_CEMC_Cluster_LateralTruthProjection);
209 
210  proj_ref = h_QAG4Sim_CEMC_Cluster_LateralTruthProjection->ProjectionX(
211  "qa_file_ref_h_QAG4Sim_CEMC_Cluster_LateralTruthProjection_px");
212  proj_ref->Scale(1. / proj_ref->GetSum());
213  }
214 
215  proj_new->GetYaxis()->SetTitleOffset(1.);
216  proj_new->GetXaxis()->SetTitleOffset(1.);
217  proj_new->GetYaxis()->SetTitle("Normalized energy distribution");
218  proj_new->GetXaxis()->SetRangeUser(-10, 10);
219 
220  DrawReference(proj_new, proj_ref);
221  }
222 
223  p = (TPad *) c1->cd(idx++);
224  c1->Update();
225  // p->SetLogz();
226 
227  {
228  TH2F *h_QAG4Sim_CEMC_Cluster_LateralTruthProjection =
229  (TH2F *) qa_file_new->GetObjectChecked(
230  "h_QAG4Sim_CEMC_Cluster_LateralTruthProjection", "TH2F");
231  assert(h_QAG4Sim_CEMC_Cluster_LateralTruthProjection);
232 
233  TH1D *proj_new =
234  h_QAG4Sim_CEMC_Cluster_LateralTruthProjection->ProjectionY(
235  "qa_file_new_h_QAG4Sim_CEMC_Cluster_LateralTruthProjection_py");
236 
237  proj_new->Scale(1. / proj_new->GetSum());
238 
239  TH1D *proj_ref = NULL;
240  if (qa_file_ref)
241  {
242  TH2F *h_QAG4Sim_CEMC_Cluster_LateralTruthProjection =
243  (TH2F *) qa_file_ref->GetObjectChecked(
244  "h_QAG4Sim_CEMC_Cluster_LateralTruthProjection", "TH2F");
245  assert(h_QAG4Sim_CEMC_Cluster_LateralTruthProjection);
246 
247  proj_ref = h_QAG4Sim_CEMC_Cluster_LateralTruthProjection->ProjectionY(
248  "qa_file_ref_h_QAG4Sim_CEMC_Cluster_LateralTruthProjection_py");
249  proj_ref->Scale(1. / proj_ref->GetSum());
250  }
251 
252  proj_new->GetYaxis()->SetTitleOffset(1.);
253  proj_new->GetXaxis()->SetTitleOffset(1.);
254  proj_new->GetYaxis()->SetTitle("Normalized energy distribution");
255  proj_new->GetXaxis()->SetRangeUser(-10, 10);
256 
257  DrawReference(proj_new, proj_ref);
258  }
259 
260  p = (TPad *) c1->cd(idx++);
261  c1->Update();
262  p->SetLogy();
263 
264  {
265  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
266  "h_QAG4Sim_CEMC_Cluster_BestMatchERatio", "TH1F");
267  assert(h_new);
268 
269  h_new->Rebin(2);
270  h_new->Sumw2();
271  h_new->Scale(1. / h_new->GetSum());
272 
273  TH1F *h_ref = NULL;
274  if (qa_file_ref)
275  {
276  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
277  "h_QAG4Sim_CEMC_Cluster_BestMatchERatio", "TH1F");
278  assert(h_ref);
279 
280  h_ref->Rebin(2);
281  h_ref->Scale(1. / h_ref->GetSum());
282  }
283 
284  h_new->GetYaxis()->SetTitleOffset(1.5);
285  h_new->GetYaxis()->SetTitle("Probability per bin");
286  // h_new->GetXaxis()->SetRangeUser(-0, .1);
287 
288  DrawReference(h_new, h_ref);
289  }
290 
291 // PutInputFileName(c1, .04, qa_file_name_new, qa_file_name_ref);
292  SaveCanvas(c1, TString(qa_file_name_new) + TString(c1->GetName()), true);
293 }