EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QA_Draw_Calorimeter_Sum_Cluster.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file QA_Draw_Calorimeter_Sum_Cluster.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 //QA_Draw_Calorimeter_Sum_Cluster(const char * qa_file_name_new =
30 // "data/G4sPHENIXCells_100e24GeV.root_qa.root",
31 // const char * qa_file_name_ref =
32 // "data/G4Hits_sPHENIX_e-_eta0_24GeV-0000.root_qa.root")
33 {
35  TVirtualFitter::SetDefaultFitter("Minuit2");
36 
37  TFile *qa_file_new = new TFile(qa_file_name_new);
38  assert(qa_file_new->IsOpen());
39 
40  TFile *qa_file_ref = NULL;
41  if (qa_file_name_ref)
42  {
43  qa_file_ref = new TFile(qa_file_name_ref);
44  assert(qa_file_ref->IsOpen());
45  }
46 
47  // obtain normalization
48  double Nevent_new = 1;
49  double Nevent_ref = 1;
50 
51  if (qa_file_new)
52  {
53  TH1D *h_norm = (TH1D *) qa_file_new->GetObjectChecked(
54  TString("h_QAG4Sim_CalorimeterSum_Normalization"), "TH1D");
55  assert(h_norm);
56 
57  Nevent_new = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Event"));
58  }
59  if (qa_file_ref)
60  {
61  TH1D *h_norm = (TH1D *) qa_file_ref->GetObjectChecked(
62  TString("h_QAG4Sim_CalorimeterSum_Normalization"), "TH1D");
63  assert(h_norm);
64 
65  Nevent_ref = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Event"));
66  }
67 
68  TCanvas *c1 = new TCanvas("QA_Draw_Calorimeter_Sum_Cluster",
69  "QA_Draw_Calorimeter_Sum_Cluster", 1800, 900);
70  c1->Divide(3, 2);
71  int idx = 1;
72  TPad *p;
73 
74  p = (TPad *) c1->cd(idx++);
75  c1->Update();
76  p->SetLogz();
77 
78  {
79  TH2F *h_QAG4Sim_CalorimeterSum_Cluster_CEMC_HCALIN =
80  (TH2F *) qa_file_new->GetObjectChecked(
81  "h_QAG4Sim_CalorimeterSum_Cluster_CEMC_HCALIN", "TH2F");
82  assert(h_QAG4Sim_CalorimeterSum_Cluster_CEMC_HCALIN);
83  h_QAG4Sim_CalorimeterSum_Cluster_CEMC_HCALIN->GetYaxis()->SetTitleOffset(
84  1.5);
85  h_QAG4Sim_CalorimeterSum_Cluster_CEMC_HCALIN->Draw("COLZ");
86  }
87 
88  p = (TPad *) c1->cd(idx++);
89  c1->Update();
90  p->SetLogz();
91 
92  {
93  TH2F *h_QAG4Sim_CalorimeterSum_Cluster_CEMC_HCALIN_HCALOUT =
94  (TH2F *) qa_file_new->GetObjectChecked(
95  "h_QAG4Sim_CalorimeterSum_Cluster_CEMC_HCALIN_HCALOUT", "TH2F");
96  assert(h_QAG4Sim_CalorimeterSum_Cluster_CEMC_HCALIN_HCALOUT);
97  h_QAG4Sim_CalorimeterSum_Cluster_CEMC_HCALIN_HCALOUT->GetYaxis()->SetTitleOffset(
98  1.5);
99  h_QAG4Sim_CalorimeterSum_Cluster_CEMC_HCALIN_HCALOUT->Draw("COLZ");
100  }
101 
102  p = (TPad *) c1->cd(idx++);
103  c1->Update();
104  // empty pannel
105 
106  p = (TPad *) c1->cd(idx++);
107  c1->Update();
108  p->SetLogy();
109 
110  {
111  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
112  "h_QAG4Sim_CalorimeterSum_Cluster_Ratio_CEMC_HCALIN", "TH1F");
113  assert(h_new);
114 
115  h_new->Sumw2();
116  h_new->Scale(1. / Nevent_new);
117 
118  TH1F *h_ref = NULL;
119  if (qa_file_ref)
120  {
121  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
122  "h_QAG4Sim_CalorimeterSum_Cluster_Ratio_CEMC_HCALIN", "TH1F");
123  assert(h_ref);
124 
125  h_ref->Scale(1. / Nevent_ref);
126  }
127 
128  h_new->GetYaxis()->SetTitleOffset(1.5);
129  h_new->GetYaxis()->SetTitle("Count / event / bin");
130  // h_new->GetXaxis()->SetRangeUser(-0, .1);
131 
132  DrawReference(h_new, h_ref);
133  }
134 
135  p = (TPad *) c1->cd(idx++);
136  c1->Update();
137  p->SetLogy();
138 
139  {
140  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
141  "h_QAG4Sim_CalorimeterSum_Cluster_Ratio_CEMC_HCALIN_HCALOUT", "TH1F");
142  assert(h_new);
143 
144  h_new->Sumw2();
145  h_new->Scale(1. / Nevent_new);
146 
147  TH1F *h_ref = NULL;
148  if (qa_file_ref)
149  {
150  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
151  "h_QAG4Sim_CalorimeterSum_Cluster_Ratio_CEMC_HCALIN_HCALOUT",
152  "TH1F");
153  assert(h_ref);
154 
155  h_ref->Scale(1. / Nevent_ref);
156  }
157 
158  h_new->GetYaxis()->SetTitleOffset(1.5);
159  h_new->GetYaxis()->SetTitle("Count / event / bin");
160  // h_new->GetXaxis()->SetRangeUser(-0, .1);
161 
162  DrawReference(h_new, h_ref);
163  }
164 
165  p = (TPad *) c1->cd(idx++);
166  c1->Update();
167  p->SetLogy();
168 
169  {
170  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
171  "h_QAG4Sim_CalorimeterSum_Cluster_EP", "TH1F");
172  assert(h_new);
173 
174  h_new->Sumw2();
175  h_new->Scale(1. / Nevent_new);
176 
177  TH1F *h_ref = NULL;
178  if (qa_file_ref)
179  {
180  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
181  "h_QAG4Sim_CalorimeterSum_Cluster_EP", "TH1F");
182  assert(h_ref);
183 
184  h_ref->Scale(1. / Nevent_ref);
185  }
186 
187  h_new->GetYaxis()->SetTitleOffset(1.5);
188  h_new->GetYaxis()->SetTitle("Count / event / bin");
189  // h_new->GetXaxis()->SetRangeUser(-0, .1);
190 
191  DrawReference(h_new, h_ref);
192  }
193 
194 // PutInputFileName(c1, .04, qa_file_name_new, qa_file_name_ref);
195  SaveCanvas(c1, TString(qa_file_name_new) + TString(c1->GetName()), true);
196 }