EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QA_Draw_Calorimeter_Sum_TrackProjEP.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file QA_Draw_Calorimeter_Sum_TrackProjEP.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_TrackProjEP(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  // obtain normalization
52  double Ntrack_new = 0;
53  double Ntrack_ref = 0;
54 
55  if (qa_file_new)
56  {
57  TH1D *h_norm = (TH1D *) qa_file_new->GetObjectChecked(
58  TString("h_QAG4Sim_CalorimeterSum_Normalization"), "TH1D");
59  assert(h_norm);
60 
61  Nevent_new = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Event"));
62  Ntrack_new = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Track"));
63  }
64  if (qa_file_ref)
65  {
66  TH1D *h_norm = (TH1D *) qa_file_ref->GetObjectChecked(
67  TString("h_QAG4Sim_CalorimeterSum_Normalization"), "TH1D");
68  assert(h_norm);
69 
70  Nevent_ref = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Event"));
71  Ntrack_ref = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Track"));
72  }
73 
74  TCanvas *c1 = new TCanvas("QA_Draw_Calorimeter_Sum_TrackProjEP",
75  "QA_Draw_Calorimeter_Sum_TrackProjEP", 1800, 600);
76  c1->Divide(3, 1);
77  int idx = 1;
78  TPad *p;
79 
80  p = (TPad *) c1->cd(idx++);
81  c1->Update();
82  p->SetLogy();
83 
84  if (Ntrack_new > 0)
85  {
86  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
87  "h_QAG4Sim_CalorimeterSum_TrackProj_3x3Tower_EP", "TH1F");
88  assert(h_new);
89 
90  h_new->Sumw2();
91  h_new->Scale(1. / Ntrack_new);
92 
93  TH1F *h_ref = NULL;
94  if (qa_file_ref)
95  {
96  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
97  "h_QAG4Sim_CalorimeterSum_TrackProj_3x3Tower_EP", "TH1F");
98  assert(h_ref);
99 
100  h_ref->Scale(1. / Ntrack_ref);
101  }
102 
103  h_new->GetYaxis()->SetTitleOffset(1.5);
104  h_new->GetYaxis()->SetTitle("Count / track / bin");
105  // h_new->GetXaxis()->SetRangeUser(-0, .1);
106 
107  DrawReference(h_new, h_ref);
108  }
109 
110  p = (TPad *) c1->cd(idx++);
111  c1->Update();
112  p->SetLogy();
113 
114  if (Ntrack_new > 0)
115  {
116  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
117  "h_QAG4Sim_CalorimeterSum_TrackProj_5x5Tower_EP", "TH1F");
118  assert(h_new);
119 
120  h_new->Sumw2();
121  h_new->Scale(1. / Ntrack_new);
122 
123  TH1F *h_ref = NULL;
124  if (qa_file_ref)
125  {
126  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
127  "h_QAG4Sim_CalorimeterSum_TrackProj_5x5Tower_EP", "TH1F");
128  assert(h_ref);
129 
130  h_ref->Scale(1. / Ntrack_ref);
131  }
132 
133  h_new->GetYaxis()->SetTitleOffset(1.5);
134  h_new->GetYaxis()->SetTitle("Count / track / bin");
135  // h_new->GetXaxis()->SetRangeUser(-0, .1);
136 
137  DrawReference(h_new, h_ref);
138  }
139 
140  p = (TPad *) c1->cd(idx++);
141  c1->Update();
142  p->SetLogy();
143 
144  if (Nevent_new > 0)
145  {
146  TH1F *h_new = (TH1F *) qa_file_new->GetObjectChecked(
147  "h_QAG4Sim_CalorimeterSum_Cluster_EP", "TH1F");
148  if (h_new)
149  {
150  h_new->Sumw2();
151  h_new->Scale(1. / Nevent_new);
152 
153  TH1F *h_ref = NULL;
154  if (qa_file_ref)
155  {
156  h_ref = (TH1F *) qa_file_ref->GetObjectChecked(
157  "h_QAG4Sim_CalorimeterSum_Cluster_EP", "TH1F");
158  assert(h_ref);
159 
160  h_ref->Scale(1. / Nevent_ref);
161  }
162 
163  h_new->GetYaxis()->SetTitleOffset(1.5);
164  h_new->GetYaxis()->SetTitle("Count / event / bin");
165  // h_new->GetXaxis()->SetRangeUser(-0, .1);
166 
167  DrawReference(h_new, h_ref);
168  }
169  }
170 
171 // PutInputFileName(c1, 0.07, qa_file_name_new, qa_file_name_ref);
172  SaveCanvas(c1, TString(qa_file_name_new) + TString(c1->GetName()), true);
173 }