EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QA_Draw_Calorimeter_Sum_TrackProj.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file QA_Draw_Calorimeter_Sum_TrackProj.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 #include <string>
18 #include <vector>
19 
20 //some common style files
21 #include "sPhenixStyle.C"
22 #include "QA_Draw_Utility.C"
23 
24 using namespace std;
25 
27  const char *qa_file_name_new =
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  const char *qa_file_name_ref =
30  "/phenix/u/jinhuang/links/ePHENIX_work/sPHENIX_work/production_analysis_updates/spacal1d/fieldmap/G4Hits_sPHENIX_pi+_eta0.30_32GeV-0000.root_qa.root")
31 //QA_Draw_Calorimeter_Sum_TrackProj(const char * qa_file_name_new =
32 // "data/G4sPHENIXCells_100e24GeV.root_qa.root",
33 // const char * qa_file_name_ref =
34 // "data/G4Hits_sPHENIX_e-_eta0_24GeV-0000.root_qa.root")
35 {
37  TVirtualFitter::SetDefaultFitter("Minuit2");
38 
39  TFile *qa_file_new = new TFile(qa_file_name_new);
40  assert(qa_file_new->IsOpen());
41 
42  TFile *qa_file_ref = NULL;
43  if (qa_file_name_ref)
44  {
45  qa_file_ref = new TFile(qa_file_name_ref);
46  assert(qa_file_ref->IsOpen());
47  }
48 
49  // obtain normalization
50  double Nevent_new = 1;
51  double Nevent_ref = 1;
52 
53  // obtain normalization
54  double Ntrack_new = 0;
55  double Ntrack_ref = 0;
56 
57  if (qa_file_new)
58  {
59  TH1D *h_norm = (TH1D *) qa_file_new->GetObjectChecked(
60  TString("h_QAG4Sim_CalorimeterSum_Normalization"), "TH1D");
61  assert(h_norm);
62 
63  Nevent_new = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Event"));
64  Ntrack_new = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Track"));
65  }
66  if (qa_file_ref)
67  {
68  TH1D *h_norm = (TH1D *) qa_file_ref->GetObjectChecked(
69  TString("h_QAG4Sim_CalorimeterSum_Normalization"), "TH1D");
70  assert(h_norm);
71 
72  Nevent_ref = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Event"));
73  Ntrack_ref = h_norm->GetBinContent(h_norm->GetXaxis()->FindBin("Track"));
74  }
75 
76  vector<string> subsystems;
77  subsystems.push_back("CEMC");
78  subsystems.push_back("HCALIN");
79  subsystems.push_back("HCALOUT");
80 
81  TCanvas *c1 = new TCanvas("QA_Draw_Calorimeter_Sum_TrackProj",
82  "QA_Draw_Calorimeter_Sum_TrackProj", 1100, 1100);
83  c1->Divide(3, 3);
84  int idx = 1;
85  TPad *p;
86 
87  for (int i = 0; i < subsystems.size(); ++i)
88  {
89  const TString subsystem(subsystems[i].c_str());
90 
91  p = (TPad *) c1->cd(idx++);
92  c1->Update();
93  p->SetLogz();
94 
95  TH2F *h_QAG4Sim_CalorimeterSum_TrackProj =
96  (TH2F *) qa_file_new->GetObjectChecked(
97  "h_QAG4Sim_CalorimeterSum_" + subsystem + "_TrackProj", "TH2F");
98  assert(h_QAG4Sim_CalorimeterSum_TrackProj);
99  h_QAG4Sim_CalorimeterSum_TrackProj->GetYaxis()->SetTitleOffset(1.5);
100  h_QAG4Sim_CalorimeterSum_TrackProj->Draw("COLZ");
101 
102  TH2F *h_QAG4Sim_CalorimeterSum_TrackProj_Ref = NULL;
103  if (qa_file_ref)
104  {
105  h_QAG4Sim_CalorimeterSum_TrackProj_Ref =
106  (TH2F *) qa_file_ref->GetObjectChecked(
107  "h_QAG4Sim_CalorimeterSum_" + subsystem + "_TrackProj",
108  "TH2F");
109  assert(h_QAG4Sim_CalorimeterSum_TrackProj);
110  }
111 
112  p = (TPad *) c1->cd(idx++);
113  c1->Update();
114  p->SetLogz();
115 
116  // x projections
117  {
118  TH1 *h_new = h_QAG4Sim_CalorimeterSum_TrackProj->ProjectionX(h_QAG4Sim_CalorimeterSum_TrackProj->GetName() + TString("_px"));
119 
120  h_new->Scale(1. / Ntrack_new);
121 
122  TH1 *h_ref = NULL;
123  if (h_QAG4Sim_CalorimeterSum_TrackProj_Ref)
124  {
125  h_ref = h_QAG4Sim_CalorimeterSum_TrackProj_Ref->ProjectionX(h_QAG4Sim_CalorimeterSum_TrackProj->GetName() + TString("_px_ref"));
126 
127  h_ref->Scale(1. / Ntrack_ref);
128  }
129 
130  h_new->GetXaxis()->SetTitleOffset(1.05);
131  h_new->GetYaxis()->SetTitle("Energy / track / bin");
132 
133  DrawReference(h_new, h_ref);
134  }
135 
136  p = (TPad *) c1->cd(idx++);
137  c1->Update();
138  p->SetLogz();
139 
140  // y projections
141  {
142  TH1 *h_new = h_QAG4Sim_CalorimeterSum_TrackProj->ProjectionY(h_QAG4Sim_CalorimeterSum_TrackProj->GetName() + TString("_py"));
143 
144  h_new->Scale(1. / Ntrack_new);
145 
146  TH1 *h_ref = NULL;
147  if (h_QAG4Sim_CalorimeterSum_TrackProj_Ref)
148  {
149  h_ref = h_QAG4Sim_CalorimeterSum_TrackProj_Ref->ProjectionY(h_QAG4Sim_CalorimeterSum_TrackProj->GetName() + TString("_py_ref"));
150 
151  h_ref->Scale(1. / Ntrack_ref);
152  }
153 
154  h_new->GetXaxis()->SetTitleOffset(1.05);
155  h_new->GetYaxis()->SetTitle("Energy / track / bin");
156 
157  DrawReference(h_new, h_ref);
158  }
159  }
160 
161 // PutInputFileName(c1, .03, qa_file_name_new, qa_file_name_ref);
162 
163  SaveCanvas(c1, TString(qa_file_name_new) + TString(c1->GetName()), true);
164 }