13 #define NELEMS(arr) (sizeof(arr)/sizeof(arr[0]))
17 "/sphenix/user/gregtom3/data/Summer2018/ECAL_energy_studies";
26 TTree *
load_tree(
const char *
const file_name,
const char *
const tree_name);
27 void fill_histogram(TH1F *
const h, TTree *
const t,
const Float_t true_energy,
28 const Float_t min_value,
const bool normalize);
29 void histogram_to_png(TH1F *
const h_pion_CEMC, TH1F *
const h_electron_CEMC,
30 TH1F *
const h_pion_EEMC, TH1F *
const h_electron_EEMC,
31 TH1F *
const h_pion_FEMC, TH1F *
const h_electron_FEMC,
32 const char *
const title,
const char *
const save_file_name,
33 const char *
const cemc_label,
34 const char *
const eemc_label,
35 const char *
const femc_label);
52 (
"/sphenix/user/gregtom3/SBU/research/macros/macros/sPHENIXStyle/sPhenixStyle.C");
55 gROOT->SetBatch(kTRUE);
61 TH1F *h_base =
new TH1F(
"h_base",
"", 25, 0.0, 2.5);
62 TH1F *h_base_e = (TH1F *) h_base->Clone();
63 TH1F *h_base_p = (TH1F *) h_base->Clone();
64 h_base_e->SetLineColor(kRed);
65 h_base_p->SetLineColor(kBlue);
71 TH1F *
const h_pion_cemc = h_base_p->Clone();
72 TH1F *
const h_electron_cemc = h_base_e->Clone();
78 TTree *
const t_pion_cemc =
81 TTree *
const t_electron_cemc =
92 TH1F *
const h_pion_eemc = h_base_p->Clone();
93 TH1F *
const h_electron_eemc = h_base_e->Clone();
99 TTree *
const t_pion_eemc =
102 TTree *
const t_electron_eemc =
113 TH1F *
const h_pion_femc = h_base_p->Clone();
114 TH1F *
const h_electron_femc = h_base_e->Clone();
120 TTree *
const t_pion_femc =
123 TTree *
const t_electron_femc =
134 h_pion_eemc, h_electron_eemc,
135 h_pion_femc, h_electron_femc,
145 TTree *
load_tree(
const char *
const file_name,
const char *
const tree_name)
147 return (TTree *) (
new TFile(file_name,
"READ"))->
Get(tree_name);
160 const Float_t min_value,
const bool normalize)
162 Float_t measured_energy;
164 t->SetBranchAddress(
"e", &measured_energy);
167 t->SetBranchAddress(
"geta", &true_eta);
169 Int_t nentries = Int_t(t->GetEntries());
171 for (Int_t
i = 0;
i < nentries; ++
i) {
172 if (t->LoadTree(
i) < 0)
176 if (((true_eta > -0.5 && true_eta < 0.5)
177 || (true_eta > -3 && true_eta < -2)
178 || (true_eta > 2 && true_eta < 3))
179 && (measured_energy > min_value && true_energy > 0.1))
180 h->Fill(measured_energy / true_energy);
183 h->Scale(1 / h->GetEntries());
185 h->SetXTitle(
"E_{cluster} / E_{true}");
186 h->SetYTitle(
"entries / #scale[0.5]{#sum} entries ");
190 TH1F *
const h_pion_EEMC, TH1F *
const h_electron_EEMC,
191 TH1F *
const h_pion_FEMC, TH1F *
const h_electron_FEMC,
192 const char *
const title,
const char *
const save_file_name,
193 const char *
const cemc_label,
194 const char *
const eemc_label,
195 const char *
const femc_label)
199 TCanvas cPNG(
"cPNG", title, gStyle->GetCanvasDefW() * 3,
200 gStyle->GetCanvasDefH());
201 TImage *img = TImage::Create();
205 h_pion_CEMC->GetYaxis()->SetRangeUser(0.0001, 1);
206 h_electron_CEMC->GetYaxis()->SetRangeUser(0.0001, 1);
209 h_electron_CEMC->Draw(
"SAME");
212 auto cemc_legend =
new TLegend(0.70, 0.9, 0.95, 0.65, cemc_label);
213 cemc_legend->AddEntry(h_pion_CEMC,
"Pions",
"l");
214 cemc_legend->AddEntry(h_electron_CEMC,
"Electrons",
"l");
218 h_pion_EEMC->GetYaxis()->SetRangeUser(0.0001, 1);
219 h_electron_EEMC->GetYaxis()->SetRangeUser(0.0001, 1);
222 h_electron_EEMC->Draw(
"SAME");
225 auto eemc_legend =
new TLegend(0.65, 0.9, 0.9, 0.65, eemc_label);
226 eemc_legend->AddEntry(h_pion_EEMC,
"Pions",
"l");
227 eemc_legend->AddEntry(h_electron_EEMC,
"Electrons",
"l");
231 h_pion_FEMC->GetYaxis()->SetRangeUser(0.0001, 1);
232 h_electron_FEMC->GetYaxis()->SetRangeUser(0.0001, 1);
235 h_electron_FEMC->Draw(
"SAME");
238 auto femc_legend =
new TLegend(0.65, 0.9, 0.9, 0.65, femc_label);
239 femc_legend->AddEntry(h_pion_FEMC,
"Pions",
"l");
240 femc_legend->AddEntry(h_electron_FEMC,
"Electrons",
"l");
244 img->WriteImage(save_file_name);
251 char *
const t =
new char[strlen(s) + 1];
258 std::stringstream
name;
269 name <<
"_" << particle_energy_gev <<
"GeV";
279 return strdup(name.str().c_str());
283 const int particle_energy_gev,
const detector d)
285 std::stringstream
path;
290 path <<
"/Electrons/Electrons";
293 path <<
"/Pions/Pions";
297 path << particle_energy_gev;
312 return strdup(path.str().c_str());
317 std::stringstream
name;
318 name <<
"Electron-Pion-" << particle_energy_gev <<
319 "GeV-CEMC-EEMC-FEMC.png";
321 return strdup(name.str().c_str());
326 std::stringstream
title;
327 title << particle_energy_gev <<
"GeV";
329 return strdup(title.str().c_str());
334 std::stringstream
label;
347 label << particle_energy_gev <<
"GeV";
349 return strdup(label.str().c_str());