Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DrawEcal.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DrawEcal.C
1 #include <cmath>
2 #include <TFile.h>
3 #include <TString.h>
4 #include <TLine.h>
5 #include <TTree.h>
6 #include <cassert>
7 #include "SaveCanvas.C"
8 #include "SetOKStyle.C"
9 using namespace std;
10 
11 void
12 DrawEcal(void)
13 {
14  SetOKStyle();
15  gStyle->SetOptStat(0);
16  gStyle->SetOptFit(1111);
17  TVirtualFitter::SetDefaultFitter("Minuit2");
18  gSystem->Load("libg4eval.so");
19 
20 // DrawSF();
21 
22 // DrawCluster_SingleE();
23 // DrawCluster_AnaP() ;
24 // DrawCluster_Linearality();
25 // DrawCluster_Res();
26 // DrawCluster_Res_2Fit();
27 // DrawTowerSum_SingleE();
28 // DrawTowerSum_AnaP()->Draw("ap*");
29 // DrawCluster_Res_2Fit_Electron_NoSVX();
30  // DrawTowerSum_Res_2Fit_1DSpacalNoSVX();
31 // DrawTowerSum_Res_2Fit_1DSpacalNoSVX_Eta3();
32  // DrawCluster_Res_2Fit_2DSpacalNoSVX();
33 // DrawCluster_Res_2Fit_1DSpacalNoSVX_Eta3();
34 
35 // DrawTower_EMCDistribution(
36 // "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/sHijing/spacal2d/G4Hits_sPHENIX_sHijing-0-4.4fm_ALL.root_EMCalAna.root",
37 // "2D-proj. SPACAL in HIJING Au+Au 0-10% C");
38  // DrawTower_EMCDistribution(
39  // "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/sHijing/spacal1d/G4Hits_sPHENIX_sHijing-0-4.4fm_ALL.root_EMCalAna.root",
40  // "1D-proj. SPACAL in HIJING Au+Au 0-10% C");
41 // DrawTower_EMCDistribution5x5(
42 // "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/sHijing/spacal1d/G4Hits_sPHENIX_sHijing-0-4.4fm_ALL.root_EMCalAna.root",
43 // "1D-proj. SPACAL in HIJING Au+Au 0-10% C");
44 
45 // DrawEnergyDensity(
46 // "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/sHijing/spacal2d/G4Hits_sPHENIX_sHijing-0-4.4fm_ALL.root_EMCalAna.root",
47 // "Scintilator Energy Density with 2D-proj. SPACAL in HIJING Au+Au 0-10% C");
48  // DrawEnergyDensity(
49  // "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/sHijing/spacal1d/G4Hits_sPHENIX_sHijing-0-4.4fm_ALL.root_EMCalAna.root",
50  // "Scintilator Energy Density with 1D-proj. SPACAL in HIJING Au+Au 0-10% C");
51 // DrawEnergyDensityXY(
52 // "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/sHijing/spacal2d/G4Hits_sPHENIX_sHijing-0-4.4fm_ALL.root_EMCalAna.root",
53 // "Scintilator Energy Density with 2D-proj. SPACAL in HIJING Au+Au 0-10% C");
54 // DrawEnergyDensityXY(
55 // "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/sHijing/spacal1d/G4Hits_sPHENIX_sHijing-0-4.4fm_ALL.root_EMCalAna.root",
56 // "Scintilator Energy Density with 1D-proj. SPACAL in HIJING Au+Au 0-10% C");
57 
58 
59 // DrawTower_EMCTrigEff();
60 // DrawTower_EMCTrigEff_SlideingWindow2();
61 
62 }
63 
64 void
66  const TString infile =
67  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/sHijing/spacal2d/G4Hits_sPHENIX_sHijing-0-4.4fm_ALL.root_EMCalAna.root",
68  const TString title = "HIJING Au+Au 0-10% C + Geant4")
69 {
70  TH1 * EMCalAna_h_CEMC_RZ = DrawTower_Load(infile, "EMCalAna_h_CEMC_RZ");
71  TH1 * EMCalAna_h_HCALIN_RZ = DrawTower_Load(infile, "EMCalAna_h_HCALIN_RZ");
72  TH1 * EMCalAna_h_HCALOUT_RZ = DrawTower_Load(infile, "EMCalAna_h_HCALOUT_RZ");
73 
74  EMCalAna_h_CEMC_RZ->Add(EMCalAna_h_HCALIN_RZ);
75  EMCalAna_h_CEMC_RZ->Add(EMCalAna_h_HCALOUT_RZ);
76 
77  for (int r = 1; r <= EMCalAna_h_CEMC_RZ->GetNbinsY(); r++)
78  {
79  const double radius = EMCalAna_h_CEMC_RZ->GetYaxis()->GetBinCenter(r);
80  const double circ = 2 * TMath::Pi() * radius;
81  for (int z = 1; z <= EMCalAna_h_CEMC_RZ->GetNbinsX(); z++)
82  {
83 
84  EMCalAna_h_CEMC_RZ->SetBinContent(z, r,
85  EMCalAna_h_CEMC_RZ->GetBinContent(z, r) / circ);
86  }
87  }
88 
89  TCanvas *c1 = new TCanvas("DrawEnergyDensity", "DrawEnergyDensity", 1800,
90  900);
91  c1->Divide(1, 1);
92  int idx = 1;
93  TPad * p;
94  p = (TPad *) c1->cd(idx++);
95  c1->Update();
96  p->SetLogz();
97 // p->SetGridx(0);
98 // p->SetGridy(0);
99 
100  EMCalAna_h_CEMC_RZ->SetTitle(";Z (cm);Radius (cm)");
101  EMCalAna_h_CEMC_RZ->Draw("colz");
102 
103  t = new TText(.5, .95, (title));
104  t->SetNDC();
105  t->SetTextAlign(22);
106  t->Draw();
107 
108  SaveCanvas(c1, infile + TString("_DrawEcal_") + TString(c1->GetName()),
109  kTRUE);
110 }
111 
112 void
114  const TString infile =
115  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/sHijing/spacal2d/G4Hits_sPHENIX_sHijing-0-4.4fm_ALL.root_EMCalAna.root",
116  const TString title = "HIJING Au+Au 0-10% C + Geant4")
117 {
118  TH1 * EMCalAna_h_CEMC_RZ = DrawTower_Load(infile, "EMCalAna_h_CEMC_XY");
119  TH1 * EMCalAna_h_HCALIN_RZ = DrawTower_Load(infile, "EMCalAna_h_HCALIN_XY");
120  TH1 * EMCalAna_h_HCALOUT_RZ = DrawTower_Load(infile, "EMCalAna_h_HCALOUT_XY");
121 
122  EMCalAna_h_CEMC_RZ->Add(EMCalAna_h_HCALIN_RZ);
123  EMCalAna_h_CEMC_RZ->Add(EMCalAna_h_HCALOUT_RZ);
124 
125 // for (int r = 1; r <= EMCalAna_h_CEMC_RZ->GetNbinsY(); r++)
126 // {
127 // const double radius = EMCalAna_h_CEMC_RZ->GetYaxis()->GetBinCenter(r);
128 // const double circ = 2 * TMath::Pi() * radius;
129 // for (int z = 1; z <= EMCalAna_h_CEMC_RZ->GetNbinsX(); z++)
130 // {
131 //
132 // EMCalAna_h_CEMC_RZ->SetBinContent(z, r,
133 // EMCalAna_h_CEMC_RZ->GetBinContent(z, r) / circ);
134 // }
135 // }
136 
137  TCanvas *c1 = new TCanvas("DrawEnergyDensityXY", "DrawEnergyDensityXY", 900,
138  900);
139  c1->Divide(1, 1);
140  int idx = 1;
141  TPad * p;
142  p = (TPad *) c1->cd(idx++);
143  c1->Update();
144  p->SetLogz();
145 // p->SetGridx(0);
146 // p->SetGridy(0);
147 
148  EMCalAna_h_CEMC_RZ->SetTitle(";X (cm);Y (cm)");
149  EMCalAna_h_CEMC_RZ->Draw("colz");
150 
151  TText *
152  t = new TText(.5, .95, (title));
153  t->SetNDC();
154  t->SetTextSize(0.03);
155  t->SetTextAlign(22);
156  t->Draw();
157 
158  SaveCanvas(c1, infile + TString("_DrawEcal_") + TString(c1->GetName()),
159  kTRUE);
160 }
161 
162 void
164  const TString infile =
165  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/")
166 {
167  TH1F * rej_EMCalAna_h_CEMC_TOWER_4x4_max = DrawTower_Load(
168  infile
169  + "/pythia8/spacal2d/G4Hits_sPHENIX_pythia8-ALL.root_EMCalAna.root",
170  "EMCalAna_h_CEMC_TOWER_4x4_max");
171 // TH1F * sig_EMCalAna_h_CEMC_TOWER_4x4_max =
172 // DrawTower_Load(
173 // infile
174 // + "/single_particle/spacal2d/fieldmap/G4Hits_sPHENIX_e-_eta0ALL_4GeVALL_EMCalAna.root",
175 // "EMCalAna_h_CEMC_TOWER_4x4_max");
176 // TH1F * sig_EMCalAna_h_CEMC_TOWER_4x4_max =
177 // DrawTower_Load(
178 // infile
179 // + "emcstudies/nosvtx/spacal2d/fieldmap/ALLe-ALL_4GeVALLEMCalAna.root",
180 // "EMCalAna_h_CEMC_TOWER_4x4_max");
181  TH1F * sig_EMCalAna_h_CEMC_TOWER_4x4_max =
183  infile
184  + "../test_production/Upsilon/spacal2d/fieldon/SimALL_PythiaUpsilon.root_EMCalAna.root",
185  "EMCalAna_h_CEMC_TOWER_4x4_max");
186 
187  TH1F * rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC = DrawTower_Load(
188  infile
189  + "/pythia8/spacal2d/G4Hits_sPHENIX_pythia8-ALL.root_EMCalAna.root",
190  "EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC");
191 // TH1F * sig_EMCalAna_h_CEMC_TOWER_4x4_max =
192 // DrawTower_Load(
193 // infile
194 // + "/single_particle/spacal2d/fieldmap/G4Hits_sPHENIX_e-_eta0ALL_4GeVALL_EMCalAna.root",
195 // "EMCalAna_h_CEMC_TOWER_4x4_max");
196 // TH1F * sig_EMCalAna_h_CEMC_TOWER_4x4_max =
197 // DrawTower_Load(
198 // infile
199 // + "emcstudies/nosvtx/spacal2d/fieldmap/ALLe-ALL_4GeVALLEMCalAna.root",
200 // "EMCalAna_h_CEMC_TOWER_4x4_max");
201  TH1F * sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC =
203  infile
204  + "../test_production/Upsilon/spacal2d/fieldon/SimALL_PythiaUpsilon.root_EMCalAna.root",
205  "EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC");
206 
207  TGraphErrors* ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max = Distribution2Efficiency(
208  rej_EMCalAna_h_CEMC_TOWER_4x4_max);
209  TGraphErrors* ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max = Distribution2Efficiency(
210  sig_EMCalAna_h_CEMC_TOWER_4x4_max);
211 
212  TGraphErrors* ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC = Distribution2Efficiency(
213  rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC);
214  TGraphErrors* ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC = Distribution2Efficiency(
215  sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC);
216 
217  TCanvas *c1 = new TCanvas("DrawTower_EMCTrigEff", "DrawTower_EMCTrigEff",
218  1800, 900);
219  c1->Divide(2, 2);
220  int idx = 1;
221  TPad * p;
222 
223  p = (TPad *) c1->cd(idx++);
224  c1->Update();
225  p->SetLogy();
226  rej_EMCalAna_h_CEMC_TOWER_4x4_max->Draw();
227  rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->Draw("same");
228  rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->SetLineColor(kRed);
229  rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->SetMarkerColor(kRed);
230 
231  p = (TPad *) c1->cd(idx++);
232  c1->Update();
233  p->SetLogy();
234  sig_EMCalAna_h_CEMC_TOWER_4x4_max->Draw();
235  sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->Draw("same");
236  sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->SetLineColor(kRed);
237  sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->SetMarkerColor(kRed);
238 
239  p = (TPad *) c1->cd(idx++);
240  c1->Update();
241  p->SetLogy();
242  ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->Draw("AP*");
243  ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->Draw("P");
244  ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->SetLineColor(kRed);
245  ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->SetMarkerColor(kRed);
246 
247  p = (TPad *) c1->cd(idx++);
248  c1->Update();
249  p->SetLogy();
250  ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->Draw("AP*");
251  ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->Draw("P");
252  ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->SetLineColor(kRed);
253  ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->SetMarkerColor(kRed);
254 
255  SaveCanvas(c1, infile + TString("_DrawEcal_") + TString(c1->GetName()),
256  kTRUE);
257 
258  TGraphErrors* reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max =
259  (TGraphErrors*) ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->Clone(
260  "reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max");
261 
262  TGraphErrors* reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC =
263  (TGraphErrors*) ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->Clone(
264  "reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC");
265 
266 // const double * eff = reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->GetY();
267 // const double reg = eff[reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->GetN()-1];
268 // for (int i = 0; i < reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->GetN(); ++i)
269 // {
270 //
271 // eff[i] /=reg;
272 //
273 // cout << i << ": regularted to "
274 // << eff[i] << " by "
275 // <<reg << endl;
276 // }
277 
278  const double y_min = 1;
279  const double y_max = 1e5;
280  const double y_min2 = .8;
281  const double y_max2 = 1;
282 
283  TGraphErrors* plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max =
284  (TGraphErrors*) reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->Clone(
285  "plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max");
286  TGraphErrors* plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max =
287  (TGraphErrors*) ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->Clone(
288  "plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max");
289 
290 
291  TGraphErrors* plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC =
292  (TGraphErrors*) reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->Clone(
293  "plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC");
294  TGraphErrors* plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC =
295  (TGraphErrors*) ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->Clone(
296  "plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC");
297 
298  for (int i = 0; i < plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->GetN(); ++i)
299  {
300  (plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->GetY())[i] =1./(plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->GetY())[i];
301  }
302 
303  for (int i = 0; i < plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->GetN(); ++i)
304  {
305  (plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->GetY())[i] = exp(
306 
307  ((plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->GetY())[i] - y_min2)/(y_max2 - y_min2)*(log(y_max) - log(y_min)) + log(y_min)
308 
309  );
310  }
311 
312 
313  for (int i = 0; i < plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->GetN(); ++i)
314  {
315  (plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->GetY())[i] =1./(plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->GetY())[i];
316  }
317 
318  for (int i = 0; i < plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->GetN(); ++i)
319  {
320  (plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->GetY())[i] = exp(
321 
322  ((plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->GetY())[i] - y_min2)/(y_max2 - y_min2)*(log(y_max) - log(y_min)) + log(y_min)
323 
324  );
325  }
326 
327 
328  TCanvas *c1 = new TCanvas("DrawTower_EMCTrigEff_Compile",
329  "DrawTower_EMCTrigEff_Compile", 1800, 900);
330 // c1->Divide(2, 2);
331  int idx = 1;
332  TPad * p;
333 
334  p = (TPad *) c1->cd(idx++);
335  c1->Update();
336  p->SetLogy();
337  p->SetGridx(0);
338  p->SetGridy(0);
339  p->SetTicky(0);
340 
341  p->DrawFrame(0, y_min, 5.5, y_max,
342  ";EMCal trigger #Sigma_{4x4}[ E_{Tower} ] requirement (GeV);Rejection factor for MB events");
343 
344  TGaxis * a = new TGaxis(5.5,y_min,5.5, y_max,y_min2,y_max2,510,"+L");
345  a->SetTitle("Trigger efficiency for inclusive Upsilon (1S)");
346  a->SetLabelColor(kRed);
347  a->SetTitleColor(kRed);
348  a->SetLineColor(kRed);
349  a->SetTextFont(42);
350  a->Draw();
351 
352  TLine * l = new TLine(4.3,y_min,4.3,y_max);
353  l->SetLineColor(kGray);
354  l->SetLineWidth(5);
355  l->Draw();
356 
357  TLatex * t = new TLatex(0, y_max*1.1,"PYTHIA8 p+p #sqrt{s} = 200 GeV + Geant4 + Trigger Emulator");
358  t->Draw();
359 
360  plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->SetFillColor(kRed);
361  plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->SetLineColor(kRed);
362  plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->SetLineWidth(3);
363  plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->SetLineStyle(kDashed);
364 // plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->Draw("3");
365  plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->Draw("lx");
366 
367  plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->SetFillColor(kBlack);
368  plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->SetLineColor(kBlack);
369  plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->SetLineWidth(3);
370  plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->SetLineStyle(kDashed);
371 // plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->Draw("3");
372  plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->Draw("lx");
373 
374 
375  plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->SetFillColor(kRed);
376  plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->SetLineColor(kRed);
377  plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->SetLineWidth(3);
378  plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->Draw("3");
379  plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->Draw("lx");
380 
381  plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->SetFillColor(kBlack);
382  plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->SetLineColor(kBlack);
383  plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->SetLineWidth(3);
384  plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->Draw("3");
385  plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC->Draw("lx");
386 
387  TLegend * legd = new TLegend(0.13,0.5,0.5,0.9);
388 
389  TLegendEntry * le =
390  legd->AddEntry(plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC, "Rej. for MB (8-bit truncated)", "lx");
391  le->SetTextFont(42);
392  TLegendEntry * le =
393  legd->AddEntry(plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC, "Eff. for #Upsilon (8-bit truncated)", "lx");
394  le->SetTextFont(42);
395  le->SetTextColor(kRed);
396  TLegendEntry * le =
397  legd->AddEntry(plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max, "Rej. for MB (full bit ADC)", "lx");
398  le->SetTextFont(42);
399  TLegendEntry * le =
400  legd->AddEntry(plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max, "Eff. for #Upsilon (full bit ADC)", "lx");
401  le->SetTextFont(42);
402  le->SetTextColor(kRed);
403 
404  legd->Draw();
405 
406  SaveCanvas(c1, infile + TString("_DrawEcal_") + TString(c1->GetName()),
407  kTRUE);
408 }
409 
410 
411 void
413  const TString infile =
414  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/")
415 {
416  TH1F * rej_EMCalAna_h_CEMC_TOWER_4x4_max = DrawTower_Load(
417  infile
418  + "/pythia8/spacal2d/G4Hits_sPHENIX_pythia8-ALL.root_EMCalAna.root",
419  "EMCalAna_h_CEMC_TOWER_4x4_max");
420 // TH1F * sig_EMCalAna_h_CEMC_TOWER_4x4_max =
421 // DrawTower_Load(
422 // infile
423 // + "/single_particle/spacal2d/fieldmap/G4Hits_sPHENIX_e-_eta0ALL_4GeVALL_EMCalAna.root",
424 // "EMCalAna_h_CEMC_TOWER_4x4_max");
425 // TH1F * sig_EMCalAna_h_CEMC_TOWER_4x4_max =
426 // DrawTower_Load(
427 // infile
428 // + "emcstudies/nosvtx/spacal2d/fieldmap/ALLe-ALL_4GeVALLEMCalAna.root",
429 // "EMCalAna_h_CEMC_TOWER_4x4_max");
430  TH1F * sig_EMCalAna_h_CEMC_TOWER_4x4_max =
432  infile
433  + "../test_production/Upsilon/spacal2d/fieldon/SimALL_PythiaUpsilon.root_EMCalAna.root",
434  "EMCalAna_h_CEMC_TOWER_4x4_max");
435 
436  TH1F * rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC = DrawTower_Load(
437  infile
438  + "/pythia8/spacal2d/G4Hits_sPHENIX_pythia8-ALL.root_EMCalAna.root",
439  "EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC");
440 // TH1F * sig_EMCalAna_h_CEMC_TOWER_4x4_max =
441 // DrawTower_Load(
442 // infile
443 // + "/single_particle/spacal2d/fieldmap/G4Hits_sPHENIX_e-_eta0ALL_4GeVALL_EMCalAna.root",
444 // "EMCalAna_h_CEMC_TOWER_4x4_max");
445 // TH1F * sig_EMCalAna_h_CEMC_TOWER_4x4_max =
446 // DrawTower_Load(
447 // infile
448 // + "emcstudies/nosvtx/spacal2d/fieldmap/ALLe-ALL_4GeVALLEMCalAna.root",
449 // "EMCalAna_h_CEMC_TOWER_4x4_max");
450  TH1F * sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC =
452  infile
453  + "../test_production/Upsilon/spacal2d/fieldon/SimALL_PythiaUpsilon.root_EMCalAna.root",
454  "EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC");
455 
456  TGraphErrors* ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max = Distribution2Efficiency(
457  rej_EMCalAna_h_CEMC_TOWER_4x4_max);
458  TGraphErrors* ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max = Distribution2Efficiency(
459  sig_EMCalAna_h_CEMC_TOWER_4x4_max);
460 
461  TGraphErrors* ge_rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC = Distribution2Efficiency(
462  rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC);
463  TGraphErrors* ge_sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC = Distribution2Efficiency(
464  sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC);
465 
466  TCanvas *c1 = new TCanvas("DrawTower_EMCTrigEff_SlideingWindow2", "DrawTower_EMCTrigEff_SlideingWindow2",
467  1800, 900);
468  c1->Divide(2, 2);
469  int idx = 1;
470  TPad * p;
471 
472  p = (TPad *) c1->cd(idx++);
473  c1->Update();
474  p->SetLogy();
475  rej_EMCalAna_h_CEMC_TOWER_4x4_max->Draw();
476  rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->Draw("same");
477  rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->SetLineColor(kRed);
478  rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->SetMarkerColor(kRed);
479 
480  p = (TPad *) c1->cd(idx++);
481  c1->Update();
482  p->SetLogy();
483  sig_EMCalAna_h_CEMC_TOWER_4x4_max->Draw();
484  sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->Draw("same");
485  sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->SetLineColor(kRed);
486  sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->SetMarkerColor(kRed);
487 
488  p = (TPad *) c1->cd(idx++);
489  c1->Update();
490  p->SetLogy();
491  ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->Draw("AP*");
492  ge_rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->Draw("P");
493  ge_rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->SetLineColor(kRed);
494  ge_rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->SetMarkerColor(kRed);
495 
496  p = (TPad *) c1->cd(idx++);
497  c1->Update();
498  p->SetLogy();
499  ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->Draw("AP*");
500  ge_sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->Draw("P");
501  ge_sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->SetLineColor(kRed);
502  ge_sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->SetMarkerColor(kRed);
503 
504  SaveCanvas(c1, infile + TString("_DrawEcal_") + TString(c1->GetName()),
505  kTRUE);
506 
507  TGraphErrors* reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max =
508  (TGraphErrors*) ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->Clone(
509  "reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max");
510 
511  TGraphErrors* reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC =
512  (TGraphErrors*) ge_sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->Clone(
513  "reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC");
514 
515 // const double * eff = reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->GetY();
516 // const double reg = eff[reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->GetN()-1];
517 // for (int i = 0; i < reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->GetN(); ++i)
518 // {
519 //
520 // eff[i] /=reg;
521 //
522 // cout << i << ": regularted to "
523 // << eff[i] << " by "
524 // <<reg << endl;
525 // }
526 
527  const double y_min = 1;
528  const double y_max = 1e5;
529  const double y_min2 = .8;
530  const double y_max2 = 1;
531 
532  TGraphErrors* plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max =
533  (TGraphErrors*) reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->Clone(
534  "plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max");
535  TGraphErrors* plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max =
536  (TGraphErrors*) ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->Clone(
537  "plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max");
538 
539 
540  TGraphErrors* plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC =
541  (TGraphErrors*) reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->Clone(
542  "plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC");
543  TGraphErrors* plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC =
544  (TGraphErrors*) ge_rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->Clone(
545  "plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC");
546 
547  for (int i = 0; i < plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->GetN(); ++i)
548  {
549  (plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->GetY())[i] =1./(plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->GetY())[i];
550  }
551 
552  for (int i = 0; i < plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->GetN(); ++i)
553  {
554  (plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->GetY())[i] = exp(
555 
556  ((plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->GetY())[i] - y_min2)/(y_max2 - y_min2)*(log(y_max) - log(y_min)) + log(y_min)
557 
558  );
559  }
560 
561 
562  for (int i = 0; i < plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->GetN(); ++i)
563  {
564  (plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->GetY())[i] =1./(plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->GetY())[i];
565  }
566 
567  for (int i = 0; i < plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->GetN(); ++i)
568  {
569  (plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->GetY())[i] = exp(
570 
571  ((plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->GetY())[i] - y_min2)/(y_max2 - y_min2)*(log(y_max) - log(y_min)) + log(y_min)
572 
573  );
574  }
575 
576 
577  TCanvas *c1 = new TCanvas("DrawTower_EMCTrigEff_SlideingWindow2_Compile",
578  "DrawTower_EMCTrigEff_SlideingWindow2_Compile", 1800, 900);
579 // c1->Divide(2, 2);
580  int idx = 1;
581  TPad * p;
582 
583  p = (TPad *) c1->cd(idx++);
584  c1->Update();
585  p->SetLogy();
586  p->SetGridx(0);
587  p->SetGridy(0);
588  p->SetTicky(0);
589 
590  p->DrawFrame(0, y_min, 5.5, y_max,
591  ";EMCal trigger #Sigma_{4x4}[ E_{Tower} ] requirement (GeV);Rejection factor for MB events");
592 
593  TGaxis * a = new TGaxis(5.5,y_min,5.5, y_max,y_min2,y_max2,510,"+L");
594  a->SetTitle("Trigger efficiency for inclusive Upsilon (1S)");
595  a->SetLabelColor(kRed);
596  a->SetTitleColor(kRed);
597  a->SetLineColor(kRed);
598  a->SetTextFont(42);
599  a->Draw();
600 
601  TLine * l = new TLine(4.3,y_min,4.3,y_max);
602  l->SetLineColor(kGray);
603  l->SetLineWidth(5);
604  l->Draw();
605 
606  TLatex * t = new TLatex(0, y_max*1.1,"PYTHIA8 p+p #sqrt{s} = 200 GeV + Geant4 + Trigger Emulator");
607  t->Draw();
608 
609  plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->SetFillColor(kRed);
610  plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->SetLineColor(kRed);
611  plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->SetLineWidth(3);
612  plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->SetLineStyle(kDashed);
613 // plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->Draw("3");
614  plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max->Draw("lx");
615 
616  plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->SetFillColor(kBlack);
617  plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->SetLineColor(kBlack);
618  plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->SetLineWidth(3);
619  plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->SetLineStyle(kDashed);
620 // plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->Draw("3");
621  plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max->Draw("lx");
622 
623 
624  plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->SetFillColor(kRed);
625  plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->SetLineColor(kRed);
626  plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->SetLineWidth(3);
627  plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->Draw("3");
628  plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->Draw("lx");
629 
630  plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->SetFillColor(kBlack);
631  plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->SetLineColor(kBlack);
632  plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->SetLineWidth(3);
633  plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->Draw("3");
634  plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC->Draw("lx");
635 
636  TLegend * legd = new TLegend(0.13,0.5,0.6,0.9);
637 
638  TLegendEntry * le =
639  legd->AddEntry(plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC, "Rej. for MB (8-bit truncated 2x2 Sum)", "lx");
640  le->SetTextFont(42);
641  TLegendEntry * le =
642  legd->AddEntry(plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC, "Eff. for #Upsilon (8-bit truncated 2x2 Sum)", "lx");
643  le->SetTextFont(42);
644  le->SetTextColor(kRed);
645  TLegendEntry * le =
646  legd->AddEntry(plot_ge_rej_EMCalAna_h_CEMC_TOWER_4x4_max, "Rej. for MB (full ADC info)", "lx");
647  le->SetTextFont(42);
648  TLegendEntry * le =
649  legd->AddEntry(plot_reg_ge_sig_EMCalAna_h_CEMC_TOWER_4x4_max, "Eff. for #Upsilon (full ADC info)", "lx");
650  le->SetTextFont(42);
651  le->SetTextColor(kRed);
652 
653  legd->Draw();
654 
655  SaveCanvas(c1, infile + TString("_DrawEcal_") + TString(c1->GetName()),
656  kTRUE);
657 }
658 
659 
660 
661 TGraphErrors *
662 Distribution2Efficiency(TH1F * hCEMC3_Max)
663 {
664  double threshold[10000] =
665  { 0 };
666  double eff[10000] =
667  { 0 };
668  double eff_err[10000] =
669  { 0 };
670 
671  assert(hCEMC3_Max->GetNbinsX()<10000);
672 
673  const double n = hCEMC3_Max->GetSum();
674  double pass = 0;
675  int cnt = 0;
676  for (int i = hCEMC3_Max->GetNbinsX(); i >= 1; i--)
677  {
678  pass += hCEMC3_Max->GetBinContent(i);
679 
680  const double pp = pass / n;
681 // const double z = 1.96;
682  const double z = 1.;
683 
684  const double A = z * sqrt(1. / n * pp * (1 - pp) + z * z / 4 / n / n);
685  const double B = 1 / (1 + z * z / n);
686 
687  threshold[cnt] = hCEMC3_Max->GetBinCenter(i);
688  eff[cnt] = (pp + z * z / 2 / n) * B;
689  eff_err[cnt] = A * B;
690 
691  cout << threshold[cnt] << ": " << "CL " << eff[cnt] << "+/-"
692  << eff_err[cnt] << endl;
693  cnt++;
694  }
695  TGraphErrors * ge = new TGraphErrors(cnt, threshold, eff, NULL, eff_err);
696 
697  return ge;
698 }
699 
700 void
702  const TString infile =
703  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/sHijing/spacal2d/G4Hits_sPHENIX_sHijing-0-4.4fm_ALL.root_EMCalAna.root",
704  const TString title = "HIJING Au+Au 0-10% C + Geant4 + Digi.")
705 {
706  TH1F * hCEMC1 = DrawTower_Load(infile, "EMCalAna_h_CEMC_TOWER_1x1");
707  TH1F * hCEMC3 = DrawTower_Load(infile, "EMCalAna_h_CEMC_TOWER_3x3");
708 
709  hCEMC1->Scale(1. / hCEMC1->GetSum());
710  const double mean1 = hCEMC1->GetMean();
711  hCEMC3->Scale(1. / hCEMC3->GetSum());
712  const double mean3 = hCEMC3->GetMean();
713 
714  TCanvas *c1 = new TCanvas("DrawTower_EMCDistribution",
715  "DrawTower_EMCDistribution", 1800, 900);
716  c1->Divide(2, 1);
717  int idx = 1;
718  TPad * p;
719  p = (TPad *) c1->cd(idx++);
720  c1->Update();
721  p->SetLogy();
722  p->SetGridx(0);
723  p->SetGridy(0);
724 
725  hCEMC1->GetXaxis()->SetRangeUser(0, .6);
726  hCEMC1->SetTitle(";EMCal Single Tower Energy [GeV];A.U.");
727  hCEMC1->SetLineColor(kBlue + 2);
728  hCEMC1->SetLineWidth(3);
729  hCEMC1->Draw();
730 
731  TText * t;
732  t = new TText(.6, .8, Form("Tower Mean = %.0f MeV", mean1 * 1000));
733  t->SetNDC();
734  t->SetTextAlign(22);
735  t->Draw();
736  t = new TText(.5, .95, (title));
737  t->SetNDC();
738  t->SetTextAlign(22);
739  t->Draw();
740 
741  p = (TPad *) c1->cd(idx++);
742  c1->Update();
743  p->SetLogy();
744  p->SetGridx(0);
745  p->SetGridy(0);
746 
747  hCEMC3->GetXaxis()->SetRangeUser(0, 2);
748  hCEMC3->SetTitle(";EMCal 3x3 Tower Energy Sum [GeV];A.U.");
749  hCEMC3->SetLineColor(kRed + 2);
750  hCEMC3->SetLineWidth(3);
751  hCEMC3->Draw();
752 
753  t = new TText(.6, .8, Form("3x3 Tower Mean = %.0f MeV", mean3 * 1000));
754  t->SetNDC();
755  t->SetTextAlign(22);
756  t->Draw();
757 
758  SaveCanvas(c1, infile + TString("_DrawEcal_") + TString(c1->GetName()),
759  kTRUE);
760 }
761 
762 void
764  const TString infile =
765  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/sHijing/spacal2d/G4Hits_sPHENIX_sHijing-0-4.4fm_ALL.root_EMCalAna.root",
766  const TString title = "HIJING Au+Au 0-10% C + Geant4 + Digi.")
767 {
768  TH1F * hCEMC1 = DrawTower_Load(infile, "EMCalAna_h_CEMC_TOWER_1x1");
769  TH1F * hCEMC3 = DrawTower_Load(infile, "EMCalAna_h_CEMC_TOWER_5x5");
770 
771  hCEMC1->Scale(1. / hCEMC1->GetSum());
772  const double mean1 = hCEMC1->GetMean();
773  hCEMC3->Scale(1. / hCEMC3->GetSum());
774  const double mean3 = hCEMC3->GetMean();
775 
776  TCanvas *c1 = new TCanvas("DrawTower_EMCDistribution5x5",
777  "DrawTower_EMCDistribution5x5", 1800, 900);
778  c1->Divide(2, 1);
779  int idx = 1;
780  TPad * p;
781  p = (TPad *) c1->cd(idx++);
782  c1->Update();
783  p->SetLogy();
784  p->SetGridx(0);
785  p->SetGridy(0);
786 
787  hCEMC1->GetXaxis()->SetRangeUser(0, .6);
788  hCEMC1->SetTitle(";EMCal Single Tower Energy [GeV];A.U.");
789  hCEMC1->SetLineColor(kBlue + 2);
790  hCEMC1->SetLineWidth(3);
791  hCEMC1->Draw();
792 
793  TText * t;
794  t = new TText(.6, .8, Form("Tower Mean = %.0f MeV", mean1 * 1000));
795  t->SetNDC();
796  t->SetTextAlign(22);
797  t->Draw();
798  t = new TText(.5, .95, (title));
799  t->SetNDC();
800  t->SetTextAlign(22);
801  t->Draw();
802 
803  p = (TPad *) c1->cd(idx++);
804  c1->Update();
805  p->SetLogy();
806  p->SetGridx(0);
807  p->SetGridy(0);
808 
809  hCEMC3->GetXaxis()->SetRangeUser(0, 2);
810  hCEMC3->SetTitle(";EMCal 5x5 Tower Energy Sum [GeV];A.U.");
811  hCEMC3->SetLineColor(kRed + 2);
812  hCEMC3->SetLineWidth(3);
813  hCEMC3->Draw();
814 
815  t = new TText(.6, .8, Form("5x5 Tower Mean = %.0f MeV", mean3 * 1000));
816  t->SetNDC();
817  t->SetTextAlign(22);
818  t->Draw();
819 
820  SaveCanvas(c1, infile + TString("_DrawEcal_") + TString(c1->GetName()),
821  kTRUE);
822 }
823 
824 TH1 *
826  const TString infile =
827  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/sHijing/spacal2d/G4Hits_sPHENIX_sHijing-0-4.4fm_ALL.root_EMCalAna.root",
828  const TString hist_name = "EMCalAna_h_CEMC_TOWER_1x1")
829 {
830  TString chian_str = infile;
831  chian_str.ReplaceAll("ALL", "*");
832 
833  TChain * t = new TChain("T_Index");
834  const int n = t->Add(chian_str);
835 
836  cout << "Loaded " << n << " root files with " << chian_str << endl;
837  assert(n>0);
838 
839  TH1 * h_sum = NULL;
840 
841  TObjArray *fileElements = t->GetListOfFiles();
842  TIter next(fileElements);
843  TChainElement *chEl = 0;
844  while ((chEl = (TChainElement*) next()))
845  {
846 
847  cout << "DrawTower_Load - processing " << chEl->GetTitle() << endl;
848  TFile * f = new TFile(chEl->GetTitle());
849  assert(f);
850 
851  TH1 * h = (TH1 *) f->GetObjectChecked(hist_name, "TH1");
852  assert(h);
853 
854  if (!h_sum)
855  {
856  gDirectory->cd("/");
857  h_sum = (TH1 *) h->Clone();
858  h_sum->ResetBit(kMustCleanup);
859  assert(h_sum);
860  }
861  else
862  {
863  h_sum->Add(h);
864  delete f;
865  }
866  }
867 
868  return h_sum;
869 }
870 
871 void
873  const TString base =
874  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/",
875  const TString config = "")
876 {
877  gStyle->SetOptStat(0);
878  gStyle->SetOptFit(0);
879 
880 // TGraphErrors * gamma_eta0 = DrawCluster_AnaP(
881 // base + "/spacal2d/zerofield/old/G4Hits_sPHENIX", "gamma_eta0", true);
882 // TGraphErrors * gamma_eta9 = DrawCluster_AnaP(
883 // base + "/spacal2d/zerofield/old/G4Hits_sPHENIX", "gamma_eta0.90", true);
884 //
885 // TGraphErrors * gamma_eta0_1d = DrawCluster_AnaP(
886 // base + "/spacal1d/zerofield/old/G4Hits_sPHENIX", "gamma_eta0", true);
887 // TGraphErrors * gamma_eta9_1d = DrawCluster_AnaP(
888 // base + "/spacal1d/zerofield/old/G4Hits_sPHENIX", "gamma_eta0.90", true);
889 
890 // TGraphErrors * gamma_eta0 = DrawCluster_AnaP(
891 // base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0", true);
892 // TGraphErrors * gamma_eta9 = DrawCluster_AnaP(
893 // base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0.90", true);
894 //
895 // TGraphErrors * gamma_eta0_1d = DrawCluster_AnaP(
896 // base + "/spacal1d_1dtower/zerofield/G4Hits_sPHENIX", "gamma_eta0", true);
897 // TGraphErrors * gamma_eta9_1d = DrawCluster_AnaP(
898 // base + "/spacal1d_1dtower/zerofield/G4Hits_sPHENIX", "gamma_eta0.90", true);
899 
900  TGraphErrors * gamma_eta0 = DrawCluster_AnaP(
901  base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0", true);
902  TGraphErrors * gamma_eta9 = DrawCluster_AnaP(
903  base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0.90", true);
904 
905  TGraphErrors * gamma_eta0_1d = DrawCluster_AnaP(
906  base + "/spacal1d/zerofield/G4Hits_sPHENIX", "gamma_eta0", true);
907  TGraphErrors * gamma_eta9_1d = DrawCluster_AnaP(
908  base + "/spacal1d/zerofield/G4Hits_sPHENIX", "gamma_eta0.90", true);
909 
910  TCanvas *c1 = new TCanvas("DrawCluster_Linearality",
911  "DrawCluster_Linearality", 1100, 900);
912  c1->Divide(1, 1);
913  int idx = 1;
914  TPad * p;
915 
916  p = (TPad *) c1->cd(idx++);
917  c1->Update();
918 
919  p->SetGridx(0);
920  p->SetGridy(0);
921 
922  p->DrawFrame(0, 0, 55, 55,
923  ";Incoming Energy (GeV);Reconstructed cluster energy, E_{reco} (GeV)");
924  TLine * l = new TLine(0, 0, 55, 55);
925  l->SetLineColor(kGray);
926  l->Draw();
927 
928  TLegend * lg = new TLegend(1, 42, 44, 53, NULL, "br");
929  TLegend * lg2 = new TLegend(12, 40 - 40, 43 + 12, 51 - 40, NULL, "br");
930 
931  p = (TPad *) c1->cd(idx);
932  c1->Update();
933 
934  TF1 * f_calo = new TF1("f_calo_gamma_eta0", "pol2", 0.5, 60);
935  gamma_eta0->Fit(f_calo, "RM0");
936 
937  double * Ys = gamma_eta0->GetY();
938  for (int i = 0; i < gamma_eta0->GetN(); i++)
939  {
940  Ys[i] /= f_calo->GetParameter(1);
941  }
942  gamma_eta0->Fit(f_calo, "RM0");
943 
944  gamma_eta0->SetLineColor(kRed + 1);
945  gamma_eta0->SetMarkerColor(kRed + 1);
946  gamma_eta0->SetLineWidth(2);
947  gamma_eta0->SetMarkerStyle(kFullSquare);
948  gamma_eta0->SetMarkerSize(2);
949  f_calo->SetLineColor(kRed + 1);
950  f_calo->SetLineWidth(2);
951 
952  gamma_eta0->Draw("p");
953  f_calo->Draw("same");
954 
955  TString ltitle = Form(
956  "2D-proj., #eta = 0.0-0.1, E_{reco} ~ %.2f E + %.1e E^{2} ",
957  f_calo->GetParameter(1), f_calo->GetParameter(2));
958  lg->AddEntry(gamma_eta0, ltitle.Data(), "pl");
959 
960  TF1 * f_calo = new TF1("f_calo_gamma_eta9", "pol2", 0.5, 60);
961  gamma_eta9->Fit(f_calo, "RM0");
962  double * Ys = gamma_eta9->GetY();
963  for (int i = 0; i < gamma_eta9->GetN(); i++)
964  {
965  Ys[i] /= f_calo->GetParameter(1);
966  }
967  gamma_eta9->Fit(f_calo, "RM0");
968 
969  gamma_eta9->SetLineColor(kRed + 3);
970  gamma_eta9->SetMarkerColor(kRed + 3);
971  gamma_eta9->SetLineWidth(2);
972  gamma_eta9->SetMarkerStyle(kFullCircle);
973  gamma_eta9->SetMarkerSize(2);
974  f_calo->SetLineColor(kRed + 3);
975  f_calo->SetLineWidth(2);
976 
977  gamma_eta9->Draw("p");
978  f_calo->Draw("same");
979 
980  TString ltitle = Form(
981  "2D-proj., #eta = 0.9-1.0, E_{reco} ~ %.2f E + %.1e E^{2} ",
982  f_calo->GetParameter(1), f_calo->GetParameter(2));
983  lg->AddEntry(gamma_eta9, ltitle.Data(), "pl");
984  cout << "Title = " << ltitle << endl;
985 //
986 //
987 //
988  TF1 * f_calo = new TF1("f_calo_gamma_eta0_1d", "pol2", 0.5, 60);
989  gamma_eta0_1d->Fit(f_calo, "RM0");
990  double * Ys = gamma_eta0_1d->GetY();
991  for (int i = 0; i < gamma_eta0_1d->GetN(); i++)
992  {
993  Ys[i] /= f_calo->GetParameter(1);
994  }
995  gamma_eta0_1d->Fit(f_calo, "RM0");
996 
997  gamma_eta0_1d->SetLineColor(kBlue + 1);
998  gamma_eta0_1d->SetMarkerColor(kBlue + 1);
999  gamma_eta0_1d->SetLineWidth(2);
1000  gamma_eta0_1d->SetMarkerStyle(kOpenSquare);
1001  gamma_eta0_1d->SetMarkerSize(2);
1002  f_calo->SetLineColor(kBlue + 1);
1003  f_calo->SetLineWidth(2);
1004 
1005  gamma_eta0_1d->Draw("p");
1006  f_calo->Draw("same");
1007 
1008  TString ltitle = Form(
1009  "1D-proj., #eta = 0.0-0.1, E_{reco} ~ %.2f E + %.1e E^{2} ",
1010  f_calo->GetParameter(1), f_calo->GetParameter(2));
1011  lg2->AddEntry(gamma_eta0_1d, ltitle.Data(), "pl");
1012 //
1013 //
1014 //
1015  TF1 * f_calo = new TF1("f_calo_gamma_eta9_1d", "pol2", 0.5, 60);
1016  gamma_eta9_1d->Fit(f_calo, "RM0");
1017  double * Ys = gamma_eta9_1d->GetY();
1018  for (int i = 0; i < gamma_eta9_1d->GetN(); i++)
1019  {
1020  Ys[i] /= f_calo->GetParameter(1);
1021  }
1022  gamma_eta9_1d->Fit(f_calo, "RM0");
1023 
1024  gamma_eta9_1d->SetLineColor(kBlue + 3);
1025  gamma_eta9_1d->SetMarkerColor(kBlue + 3);
1026  gamma_eta9_1d->SetLineWidth(2);
1027  gamma_eta9_1d->SetMarkerStyle(kOpenCircle);
1028  gamma_eta9_1d->SetMarkerSize(2);
1029  f_calo->SetLineColor(kBlue + 3);
1030  f_calo->SetLineWidth(2);
1031 
1032  gamma_eta9_1d->Draw("p");
1033  f_calo->Draw("same");
1034 
1035  TString ltitle = Form(
1036  "1D-proj., #eta = 0.9-1.0, E_{reco} ~ %.2f E + %.1e E^{2} ",
1037  f_calo->GetParameter(1), f_calo->GetParameter(2));
1038  lg2->AddEntry(gamma_eta9_1d, ltitle.Data(), "pl");
1039  cout << "Title = " << ltitle << endl;
1040 
1041  lg->Draw();
1042  lg2->Draw();
1043 
1044  SaveCanvas(c1, base + "DrawEcal_" + TString(c1->GetName()), true);
1045 }
1046 
1047 void
1049  const TString base =
1050  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/",
1051  const TString config = "")
1052 {
1053  gStyle->SetOptStat(0);
1054  gStyle->SetOptFit(0);
1055 
1056 // TGraphErrors * gamma_eta0 = DrawCluster_AnaP(
1057 // base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0", false);
1058 // TGraphErrors * gamma_eta9 = DrawCluster_AnaP(
1059 // base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0.90", false);
1060 //
1061 // TGraphErrors * gamma_eta0_1d = DrawCluster_AnaP(
1062 // base + "/spacal1d_1dtower/zerofield/G4Hits_sPHENIX", "gamma_eta0", false);
1063 // TGraphErrors * gamma_eta9_1d = DrawCluster_AnaP(
1064 // base + "/spacal1d_1dtower/zerofield/G4Hits_sPHENIX", "gamma_eta0.90",
1065 // false);
1066 
1067  TGraphErrors * gamma_eta0 = DrawCluster_AnaP(
1068  base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0", false);
1069  TGraphErrors * gamma_eta9 = DrawCluster_AnaP(
1070  base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0.90", false);
1071 
1072  TGraphErrors * gamma_eta0_1d = DrawCluster_AnaP(
1073  base + "/spacal1d/zerofield/G4Hits_sPHENIX", "gamma_eta0", false);
1074  TGraphErrors * gamma_eta9_1d = DrawCluster_AnaP(
1075  base + "/spacal1d/zerofield/G4Hits_sPHENIX", "gamma_eta0.90", false);
1076 
1077  TCanvas *c1 = new TCanvas("DrawCluster_Res_2Fit", "DrawCluster_Res_2Fit",
1078  1100, 900);
1079  c1->Divide(1, 1);
1080  int idx = 1;
1081  TPad * p;
1082 
1083  p = (TPad *) c1->cd(idx++);
1084  c1->Update();
1085 
1086  p->SetGridx(0);
1087  p->SetGridy(0);
1088 
1089  p->DrawFrame(0, 0, 35, 20e-2,
1090  ";Incoming Energy (GeV);Relative energy resolution, #DeltaE/E");
1091 
1092  TLegend * lg = new TLegend(2, 9.6e-2, 17, 19.6e-2, NULL, "br");
1093  TLegend * lg2 = new TLegend(16, 9e-2, 33, 19e-2, NULL, "br");
1094 
1095  TF1 * f_calo = new TF1("f_calo_gamma_eta0", "sqrt([0]*[0]+[1]*[1]/x)/100",
1096  0.5, 60);
1097  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta0", "([0]+[1]/sqrt(x))/100", 0.5,
1098  60);
1099  gamma_eta0->Fit(f_calo, "RM0");
1100  gamma_eta0->Fit(f_calo_l, "RM0");
1101 
1102  gamma_eta0->SetLineColor(kRed + 1);
1103  gamma_eta0->SetMarkerColor(kRed + 1);
1104  gamma_eta0->SetLineWidth(2);
1105  gamma_eta0->SetMarkerStyle(kFullSquare);
1106  gamma_eta0->SetMarkerSize(2);
1107  f_calo->SetLineColor(kRed + 1);
1108  f_calo->SetLineWidth(2);
1109  f_calo_l->SetLineColor(kRed + 1);
1110  f_calo_l->SetLineWidth(2);
1111  f_calo_l->SetLineStyle(kDashed);
1112 
1113  f_calo->Draw("same");
1114  f_calo_l->Draw("same");
1115  gamma_eta0->Draw("p");
1116 
1117  lg->AddEntry(gamma_eta0,
1118  Form("2D-proj., #eta = 0.0-0.1", f_calo->GetParameter(0),
1119  f_calo->GetParameter(1)), "p");
1120  lg2->AddEntry(f_calo,
1121  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
1122  f_calo->GetParameter(1)), "l");
1123  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
1124  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
1125  f_calo_l->GetParameter(1)), "l");
1126  entry->SetTextColor(kGray + 1);
1127 
1128  TF1 * f_calo = new TF1("f_calo_gamma_eta9", "sqrt([0]*[0]+[1]*[1]/x)/100",
1129  0.5, 60);
1130  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta9", "([0]+[1]/sqrt(x))/100", 0.5,
1131  60);
1132  gamma_eta9->Fit(f_calo, "RM0");
1133  gamma_eta9->Fit(f_calo_l, "RM0");
1134 
1135  gamma_eta9->SetLineColor(kRed + 3);
1136  gamma_eta9->SetMarkerColor(kRed + 3);
1137  gamma_eta9->SetLineWidth(2);
1138  gamma_eta9->SetMarkerStyle(kFullCircle);
1139  gamma_eta9->SetMarkerSize(2);
1140  f_calo->SetLineColor(kRed + 3);
1141  f_calo->SetLineWidth(2);
1142  f_calo_l->SetLineColor(kRed + 3);
1143  f_calo_l->SetLineWidth(2);
1144  f_calo_l->SetLineStyle(kDashed);
1145 
1146  f_calo->Draw("same");
1147  f_calo_l->Draw("same");
1148  gamma_eta9->Draw("p");
1149 
1150  TString ltitle = Form("2D-proj., #eta = 0.9-1.0", f_calo->GetParameter(0),
1151  f_calo->GetParameter(1));
1152  lg->AddEntry(gamma_eta9, ltitle.Data(), "p");
1153  lg2->AddEntry(f_calo,
1154  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
1155  f_calo->GetParameter(1)), "l");
1156  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
1157  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
1158  f_calo_l->GetParameter(1)), "l");
1159  entry->SetTextColor(kGray + 1);
1160  cout << "Title = " << ltitle << endl;
1161 
1162  TF1 * f_calo = new TF1("f_calo_gamma_eta0_1d", "sqrt([0]*[0]+[1]*[1]/x)/100",
1163  0.5, 60);
1164  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta0_1d", "([0]+[1]/sqrt(x))/100",
1165  0.5, 60);
1166  gamma_eta0_1d->Fit(f_calo, "RM0");
1167  gamma_eta0_1d->Fit(f_calo_l, "RM0");
1168 
1169  gamma_eta0_1d->SetLineColor(kBlue + 1);
1170  gamma_eta0_1d->SetMarkerColor(kBlue + 1);
1171  gamma_eta0_1d->SetLineWidth(2);
1172  gamma_eta0_1d->SetMarkerStyle(kOpenSquare);
1173  gamma_eta0_1d->SetMarkerSize(2);
1174  f_calo->SetLineColor(kBlue + 1);
1175  f_calo->SetLineWidth(2);
1176  f_calo_l->SetLineColor(kBlue + 1);
1177  f_calo_l->SetLineWidth(2);
1178  f_calo_l->SetLineStyle(kDashed);
1179 
1180  f_calo->Draw("same");
1181  f_calo_l->Draw("same");
1182  gamma_eta0_1d->Draw("p");
1183 
1184  TString ltitle = Form("1D-proj., #eta = 0.0-0.1", f_calo->GetParameter(0),
1185  f_calo->GetParameter(1));
1186  lg->AddEntry(gamma_eta0_1d, ltitle.Data(), "p");
1187  lg2->AddEntry(f_calo,
1188  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
1189  f_calo->GetParameter(1)), "l");
1190  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
1191  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
1192  f_calo_l->GetParameter(1)), "l");
1193  entry->SetTextColor(kGray + 1);
1194 
1195  TF1 * f_calo = new TF1("f_calo_gamma_eta0_1d", "sqrt([0]*[0]+[1]*[1]/x)/100",
1196  0.5, 60);
1197  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta0_1d", "([0]+[1]/sqrt(x))/100",
1198  0.5, 60);
1199  gamma_eta9_1d->Fit(f_calo, "RM0");
1200  gamma_eta9_1d->Fit(f_calo_l, "RM0");
1201 
1202  gamma_eta9_1d->SetLineColor(kBlue + 3);
1203  gamma_eta9_1d->SetMarkerColor(kBlue + 3);
1204  gamma_eta9_1d->SetLineWidth(2);
1205  gamma_eta9_1d->SetMarkerStyle(kOpenCircle);
1206  gamma_eta9_1d->SetMarkerSize(2);
1207  f_calo->SetLineColor(kBlue + 3);
1208  f_calo->SetLineWidth(2);
1209  f_calo_l->SetLineColor(kBlue + 3);
1210  f_calo_l->SetLineWidth(2);
1211  f_calo_l->SetLineStyle(kDashed);
1212 
1213  f_calo->Draw("same");
1214  f_calo_l->Draw("same");
1215  gamma_eta9_1d->Draw("p");
1216 
1217  TString ltitle = Form("1D-proj., #eta = 0.9-1.0", f_calo->GetParameter(0),
1218  f_calo->GetParameter(1));
1219  lg->AddEntry(gamma_eta9_1d, ltitle.Data(), "p");
1220  lg2->AddEntry(f_calo,
1221  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
1222  f_calo->GetParameter(1)), "l");
1223  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
1224  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
1225  f_calo_l->GetParameter(1)), "l");
1226  entry->SetTextColor(kGray + 1);
1227  cout << "Title = " << ltitle << endl;
1228 
1229  lg->Draw();
1230  lg2->Draw();
1231 
1232  TLatex * t = new TLatex(0, 0.205,"Single photon in full sPHENIX detector");
1233  t->Draw();
1234 
1235  SaveCanvas(c1, base + "DrawEcal_" + TString(c1->GetName()), true);
1236 }
1237 
1238 
1239 void
1241  const TString base =
1242  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/emcstudies/",
1243  const TString config = "")
1244 {
1245  gStyle->SetOptStat(0);
1246  gStyle->SetOptFit(0);
1247 
1248  TGraphErrors * gamma_eta0 = DrawCluster_AnaP(
1249  base + "/nosvtx/spacal2d/fieldmap/G4Hits_sPHENIX", "e-_eta0", false);
1250  TGraphErrors * gamma_eta9 = DrawCluster_AnaP(
1251  base + "/nosvtx/spacal2d/fieldmap/G4Hits_sPHENIX", "e-_eta0.90", false);
1252 //
1253  TGraphErrors * gamma_eta0_1d = DrawCluster_AnaP(
1254  base + "/nosvtx/spacal1d/fieldmap/G4Hits_sPHENIX", "e-_eta0", false);
1255  TGraphErrors * gamma_eta9_1d = DrawCluster_AnaP(
1256  base + "/nosvtx/spacal1d/fieldmap/G4Hits_sPHENIX", "e-_eta0.90", false);
1257 
1258 
1259  TCanvas *c1 = new TCanvas("DrawCluster_Res_2Fit_Electron_NoSVX", "DrawCluster_Res_2Fit_Electron_NoSVX",
1260  1100, 900);
1261  c1->Divide(1, 1);
1262  int idx = 1;
1263  TPad * p;
1264 
1265  p = (TPad *) c1->cd(idx++);
1266  c1->Update();
1267 
1268  p->SetGridx(0);
1269  p->SetGridy(0);
1270 
1271  p->DrawFrame(0, 0, 35, 20e-2,
1272  ";Incoming Energy (GeV);Relative energy resolution, #DeltaE/E");
1273 
1274  TLegend * lg = new TLegend(2, 9.6e-2, 17, 19.6e-2, NULL, "br");
1275  TLegend * lg2 = new TLegend(16, 9e-2, 33, 19e-2, NULL, "br");
1276 
1277  TF1 * f_calo = new TF1("f_calo_gamma_eta0", "sqrt([0]*[0]+[1]*[1]/x)/100",
1278  0.5, 60);
1279  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta0", "([0]+[1]/sqrt(x))/100", 0.5,
1280  60);
1281  gamma_eta0->Fit(f_calo, "RM0");
1282  gamma_eta0->Fit(f_calo_l, "RM0");
1283 
1284  gamma_eta0->SetLineColor(kRed + 1);
1285  gamma_eta0->SetMarkerColor(kRed + 1);
1286  gamma_eta0->SetLineWidth(2);
1287  gamma_eta0->SetMarkerStyle(kFullSquare);
1288  gamma_eta0->SetMarkerSize(2);
1289  f_calo->SetLineColor(kRed + 1);
1290  f_calo->SetLineWidth(2);
1291  f_calo_l->SetLineColor(kRed + 1);
1292  f_calo_l->SetLineWidth(2);
1293  f_calo_l->SetLineStyle(kDashed);
1294 
1295  f_calo->Draw("same");
1296  f_calo_l->Draw("same");
1297  gamma_eta0->Draw("p");
1298 
1299  lg->AddEntry(gamma_eta0,
1300  Form("2D-proj., #eta = 0.0-0.1", f_calo->GetParameter(0),
1301  f_calo->GetParameter(1)), "p");
1302  lg2->AddEntry(f_calo,
1303  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
1304  f_calo->GetParameter(1)), "l");
1305  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
1306  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
1307  f_calo_l->GetParameter(1)), "l");
1308  entry->SetTextColor(kGray + 1);
1309 
1310  TF1 * f_calo = new TF1("f_calo_gamma_eta9", "sqrt([0]*[0]+[1]*[1]/x)/100",
1311  0.5, 60);
1312  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta9", "([0]+[1]/sqrt(x))/100", 0.5,
1313  60);
1314  gamma_eta9->Fit(f_calo, "RM0");
1315  gamma_eta9->Fit(f_calo_l, "RM0");
1316 
1317  gamma_eta9->SetLineColor(kRed + 3);
1318  gamma_eta9->SetMarkerColor(kRed + 3);
1319  gamma_eta9->SetLineWidth(2);
1320  gamma_eta9->SetMarkerStyle(kFullCircle);
1321  gamma_eta9->SetMarkerSize(2);
1322  f_calo->SetLineColor(kRed + 3);
1323  f_calo->SetLineWidth(2);
1324  f_calo_l->SetLineColor(kRed + 3);
1325  f_calo_l->SetLineWidth(2);
1326  f_calo_l->SetLineStyle(kDashed);
1327 
1328  f_calo->Draw("same");
1329  f_calo_l->Draw("same");
1330  gamma_eta9->Draw("p");
1331 
1332  TString ltitle = Form("2D-proj., #eta = 0.9-1.0", f_calo->GetParameter(0),
1333  f_calo->GetParameter(1));
1334  lg->AddEntry(gamma_eta9, ltitle.Data(), "p");
1335  lg2->AddEntry(f_calo,
1336  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
1337  f_calo->GetParameter(1)), "l");
1338  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
1339  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
1340  f_calo_l->GetParameter(1)), "l");
1341  entry->SetTextColor(kGray + 1);
1342  cout << "Title = " << ltitle << endl;
1343 
1344  TF1 * f_calo = new TF1("f_calo_gamma_eta0_1d", "sqrt([0]*[0]+[1]*[1]/x)/100",
1345  0.5, 60);
1346  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta0_1d", "([0]+[1]/sqrt(x))/100",
1347  0.5, 60);
1348  gamma_eta0_1d->Fit(f_calo, "RM0");
1349  gamma_eta0_1d->Fit(f_calo_l, "RM0");
1350 
1351  gamma_eta0_1d->SetLineColor(kBlue + 1);
1352  gamma_eta0_1d->SetMarkerColor(kBlue + 1);
1353  gamma_eta0_1d->SetLineWidth(2);
1354  gamma_eta0_1d->SetMarkerStyle(kOpenSquare);
1355  gamma_eta0_1d->SetMarkerSize(2);
1356  f_calo->SetLineColor(kBlue + 1);
1357  f_calo->SetLineWidth(2);
1358  f_calo_l->SetLineColor(kBlue + 1);
1359  f_calo_l->SetLineWidth(2);
1360  f_calo_l->SetLineStyle(kDashed);
1361 
1362  f_calo->Draw("same");
1363  f_calo_l->Draw("same");
1364  gamma_eta0_1d->Draw("p");
1365 
1366  TString ltitle = Form("1D-proj., #eta = 0.0-0.1", f_calo->GetParameter(0),
1367  f_calo->GetParameter(1));
1368  lg->AddEntry(gamma_eta0_1d, ltitle.Data(), "p");
1369  lg2->AddEntry(f_calo,
1370  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
1371  f_calo->GetParameter(1)), "l");
1372  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
1373  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
1374  f_calo_l->GetParameter(1)), "l");
1375  entry->SetTextColor(kGray + 1);
1376 
1377  TF1 * f_calo = new TF1("f_calo_gamma_eta0_1d", "sqrt([0]*[0]+[1]*[1]/x)/100",
1378  0.5, 60);
1379  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta0_1d", "([0]+[1]/sqrt(x))/100",
1380  0.5, 60);
1381  gamma_eta9_1d->Fit(f_calo, "RM0");
1382  gamma_eta9_1d->Fit(f_calo_l, "RM0");
1383 
1384  gamma_eta9_1d->SetLineColor(kBlue + 3);
1385  gamma_eta9_1d->SetMarkerColor(kBlue + 3);
1386  gamma_eta9_1d->SetLineWidth(2);
1387  gamma_eta9_1d->SetMarkerStyle(kOpenCircle);
1388  gamma_eta9_1d->SetMarkerSize(2);
1389  f_calo->SetLineColor(kBlue + 3);
1390  f_calo->SetLineWidth(2);
1391  f_calo_l->SetLineColor(kBlue + 3);
1392  f_calo_l->SetLineWidth(2);
1393  f_calo_l->SetLineStyle(kDashed);
1394 
1395  f_calo->Draw("same");
1396  f_calo_l->Draw("same");
1397  gamma_eta9_1d->Draw("p");
1398 
1399  TString ltitle = Form("1D-proj., #eta = 0.9-1.0", f_calo->GetParameter(0),
1400  f_calo->GetParameter(1));
1401  lg->AddEntry(gamma_eta9_1d, ltitle.Data(), "p");
1402  lg2->AddEntry(f_calo,
1403  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
1404  f_calo->GetParameter(1)), "l");
1405  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
1406  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
1407  f_calo_l->GetParameter(1)), "l");
1408  entry->SetTextColor(kGray + 1);
1409  cout << "Title = " << ltitle << endl;
1410 
1411  lg->Draw();
1412  lg2->Draw();
1413 
1414 
1415  TLatex * t = new TLatex(0, 0.205,"Single electron in sPHENIX calorimetry (no tracker)");
1416  t->Draw();
1417 
1418 
1419  SaveCanvas(c1, base + "DrawEcal_" + TString(c1->GetName()), true);
1420 }
1421 
1422 
1423 void
1425  const TString base =
1426  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/emcstudies/",
1427  const TString config = "")
1428 {
1429  gStyle->SetOptStat(0);
1430  gStyle->SetOptFit(0);
1431 
1432 // TGraphErrors * gamma_eta0 = DrawCluster_AnaP(
1433 // base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0", false);
1434 // TGraphErrors * gamma_eta9 = DrawCluster_AnaP(
1435 // base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0.90", false);
1436 //
1437 // TGraphErrors * gamma_eta0_1d = DrawCluster_AnaP(
1438 // base + "/spacal1d_1dtower/zerofield/G4Hits_sPHENIX", "gamma_eta0", false);
1439 // TGraphErrors * gamma_eta9_1d = DrawCluster_AnaP(
1440 // base + "/spacal1d_1dtower/zerofield/G4Hits_sPHENIX", "gamma_eta0.90",
1441 // false);
1442 
1443 // TGraphErrors * gamma_eta0 = DrawCluster_AnaP(
1444 // base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0", false);
1445 // TGraphErrors * gamma_eta9 = DrawCluster_AnaP(
1446 // base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0.90", false);
1447 //
1448 // TGraphErrors * gamma_eta0_1d = DrawCluster_AnaP(
1449 // base + "/spacal1d/zerofield/G4Hits_sPHENIX", "gamma_eta0", false);
1450 // TGraphErrors * gamma_eta9_1d = DrawCluster_AnaP(
1451 // base + "/spacal1d/zerofield/G4Hits_sPHENIX", "gamma_eta0.90", false);
1452 
1453  TGraphErrors * gamma_eta0 = DrawCluster_AnaP(
1454  base + "/nosvtx/spacal1d/fieldmap/G4Hits_sPHENIX", "e-_eta0", false);
1455  TGraphErrors * gamma_eta9 = DrawCluster_AnaP(
1456  base + "/nosvtx/spacal1d/fieldmap/G4Hits_sPHENIX", "e-_eta0.90", false);
1457 
1458  TGraphErrors * gamma_eta0_1d = DrawCluster_AnaP(
1459  base + "/nosvtx/spacal1d/fieldmap/G4Hits_sPHENIX", "gamma_eta0", false);
1460  TGraphErrors * gamma_eta9_1d = DrawCluster_AnaP(
1461  base + "/nosvtx/spacal1d/fieldmap/G4Hits_sPHENIX", "gamma_eta0.90",
1462  false);
1463  TCanvas *c1 = new TCanvas("DrawCluster_Res_2Fit_1DSpacalNoSVX",
1464  "DrawCluster_Res_2Fit_1DSpacalNoSVX", 1100, 900);
1465  c1->Divide(1, 1);
1466  int idx = 1;
1467  TPad * p;
1468 
1469  p = (TPad *) c1->cd(idx++);
1470  c1->Update();
1471 
1472  p->SetGridx(0);
1473  p->SetGridy(0);
1474 
1475  p->DrawFrame(0, 0, 35, 20e-2,
1476  ";Incoming Energy (GeV);Relative energy resolution, #DeltaE/E");
1477 
1478  TLegend * lg = new TLegend(2, 9.6e-2, 17, 19.6e-2, NULL, "br");
1479  TLegend * lg2 = new TLegend(16, 9e-2, 33, 19e-2, NULL, "br");
1480 
1481  TF1 * f_calo = new TF1("f_calo_gamma_eta0", "sqrt([0]*[0]+[1]*[1]/x)/100",
1482  0.5, 60);
1483  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta0", "([0]+[1]/sqrt(x))/100", 0.5,
1484  60);
1485  gamma_eta0->Fit(f_calo, "RM0");
1486  gamma_eta0->Fit(f_calo_l, "RM0");
1487 
1488  gamma_eta0->SetLineColor(kRed + 1);
1489  gamma_eta0->SetMarkerColor(kRed + 1);
1490  gamma_eta0->SetLineWidth(2);
1491  gamma_eta0->SetMarkerStyle(kFullSquare);
1492  gamma_eta0->SetMarkerSize(2);
1493  f_calo->SetLineColor(kRed + 1);
1494  f_calo->SetLineWidth(2);
1495  f_calo_l->SetLineColor(kRed + 1);
1496  f_calo_l->SetLineWidth(2);
1497  f_calo_l->SetLineStyle(kDashed);
1498 
1499  f_calo->Draw("same");
1500  f_calo_l->Draw("same");
1501  gamma_eta0->Draw("p");
1502 
1503  lg->AddEntry(gamma_eta0,
1504  Form("Electrons, #eta = 0.0-0.1", f_calo->GetParameter(0),
1505  f_calo->GetParameter(1)), "p");
1506  lg2->AddEntry(f_calo,
1507  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
1508  f_calo->GetParameter(1)), "l");
1509  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
1510  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
1511  f_calo_l->GetParameter(1)), "l");
1512  entry->SetTextColor(kGray + 1);
1513 
1514  TF1 * f_calo = new TF1("f_calo_gamma_eta9", "sqrt([0]*[0]+[1]*[1]/x)/100",
1515  0.5, 60);
1516  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta9", "([0]+[1]/sqrt(x))/100", 0.5,
1517  60);
1518  gamma_eta9->Fit(f_calo, "RM0");
1519  gamma_eta9->Fit(f_calo_l, "RM0");
1520 
1521  gamma_eta9->SetLineColor(kRed + 3);
1522  gamma_eta9->SetMarkerColor(kRed + 3);
1523  gamma_eta9->SetLineWidth(2);
1524  gamma_eta9->SetMarkerStyle(kFullCircle);
1525  gamma_eta9->SetMarkerSize(2);
1526  f_calo->SetLineColor(kRed + 3);
1527  f_calo->SetLineWidth(2);
1528  f_calo_l->SetLineColor(kRed + 3);
1529  f_calo_l->SetLineWidth(2);
1530  f_calo_l->SetLineStyle(kDashed);
1531 
1532  f_calo->Draw("same");
1533  f_calo_l->Draw("same");
1534  gamma_eta9->Draw("p");
1535 
1536  TString ltitle = Form("Electrons, #eta = 0.9-1.0", f_calo->GetParameter(0),
1537  f_calo->GetParameter(1));
1538  lg->AddEntry(gamma_eta9, ltitle.Data(), "p");
1539  lg2->AddEntry(f_calo,
1540  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
1541  f_calo->GetParameter(1)), "l");
1542  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
1543  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
1544  f_calo_l->GetParameter(1)), "l");
1545  entry->SetTextColor(kGray + 1);
1546  cout << "Title = " << ltitle << endl;
1547 
1548  TF1 * f_calo = new TF1("f_calo_gamma_eta0_1d", "sqrt([0]*[0]+[1]*[1]/x)/100",
1549  0.5, 60);
1550  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta0_1d", "([0]+[1]/sqrt(x))/100",
1551  0.5, 60);
1552  gamma_eta0_1d->Fit(f_calo, "RM0");
1553  gamma_eta0_1d->Fit(f_calo_l, "RM0");
1554 
1555  gamma_eta0_1d->SetLineColor(kBlue + 1);
1556  gamma_eta0_1d->SetMarkerColor(kBlue + 1);
1557  gamma_eta0_1d->SetLineWidth(2);
1558  gamma_eta0_1d->SetMarkerStyle(kOpenSquare);
1559  gamma_eta0_1d->SetMarkerSize(2);
1560  f_calo->SetLineColor(kBlue + 1);
1561  f_calo->SetLineWidth(2);
1562  f_calo_l->SetLineColor(kBlue + 1);
1563  f_calo_l->SetLineWidth(2);
1564  f_calo_l->SetLineStyle(kDashed);
1565 
1566  f_calo->Draw("same");
1567  f_calo_l->Draw("same");
1568  gamma_eta0_1d->Draw("p");
1569 
1570  TString ltitle = Form("Photons, #eta = 0.0-0.1", f_calo->GetParameter(0),
1571  f_calo->GetParameter(1));
1572  lg->AddEntry(gamma_eta0_1d, ltitle.Data(), "p");
1573  lg2->AddEntry(f_calo,
1574  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
1575  f_calo->GetParameter(1)), "l");
1576  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
1577  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
1578  f_calo_l->GetParameter(1)), "l");
1579  entry->SetTextColor(kGray + 1);
1580 
1581  TF1 * f_calo = new TF1("f_calo_gamma_eta0_1d", "sqrt([0]*[0]+[1]*[1]/x)/100",
1582  0.5, 60);
1583  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta0_1d", "([0]+[1]/sqrt(x))/100",
1584  0.5, 60);
1585  gamma_eta9_1d->Fit(f_calo, "RM0");
1586  gamma_eta9_1d->Fit(f_calo_l, "RM0");
1587 
1588  gamma_eta9_1d->SetLineColor(kBlue + 3);
1589  gamma_eta9_1d->SetMarkerColor(kBlue + 3);
1590  gamma_eta9_1d->SetLineWidth(2);
1591  gamma_eta9_1d->SetMarkerStyle(kOpenCircle);
1592  gamma_eta9_1d->SetMarkerSize(2);
1593  f_calo->SetLineColor(kBlue + 3);
1594  f_calo->SetLineWidth(2);
1595  f_calo_l->SetLineColor(kBlue + 3);
1596  f_calo_l->SetLineWidth(2);
1597  f_calo_l->SetLineStyle(kDashed);
1598 
1599  f_calo->Draw("same");
1600  f_calo_l->Draw("same");
1601  gamma_eta9_1d->Draw("p");
1602 
1603  TString ltitle = Form("Photons, #eta = 0.9-1.0", f_calo->GetParameter(0),
1604  f_calo->GetParameter(1));
1605  lg->AddEntry(gamma_eta9_1d, ltitle.Data(), "p");
1606  lg2->AddEntry(f_calo,
1607  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
1608  f_calo->GetParameter(1)), "l");
1609  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
1610  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
1611  f_calo_l->GetParameter(1)), "l");
1612  entry->SetTextColor(kGray + 1);
1613  cout << "Title = " << ltitle << endl;
1614 
1615  lg->Draw();
1616  lg2->Draw();
1617 
1618  SaveCanvas(c1, base + "DrawEcal_" + TString(c1->GetName()), true);
1619 }
1620 
1621 void
1623  const TString base =
1624  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/emcstudies/",
1625  const TString config = "")
1626 {
1627  gStyle->SetOptStat(0);
1628  gStyle->SetOptFit(0);
1629 
1630 // TGraphErrors * gamma_eta0 = DrawCluster_AnaP(
1631 // base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0", false);
1632 // TGraphErrors * gamma_eta9 = DrawCluster_AnaP(
1633 // base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0.90", false);
1634 //
1635 // TGraphErrors * gamma_eta0_1d = DrawCluster_AnaP(
1636 // base + "/spacal1d_1dtower/zerofield/G4Hits_sPHENIX", "gamma_eta0", false);
1637 // TGraphErrors * gamma_eta9_1d = DrawCluster_AnaP(
1638 // base + "/spacal1d_1dtower/zerofield/G4Hits_sPHENIX", "gamma_eta0.90",
1639 // false);
1640 
1641 // TGraphErrors * gamma_eta0 = DrawCluster_AnaP(
1642 // base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0", false);
1643 // TGraphErrors * gamma_eta9 = DrawCluster_AnaP(
1644 // base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0.90", false);
1645 //
1646 // TGraphErrors * gamma_eta0_1d = DrawCluster_AnaP(
1647 // base + "/spacal1d/zerofield/G4Hits_sPHENIX", "gamma_eta0", false);
1648 // TGraphErrors * gamma_eta9_1d = DrawCluster_AnaP(
1649 // base + "/spacal1d/zerofield/G4Hits_sPHENIX", "gamma_eta0.90", false);
1650 
1651  TGraphErrors * gamma_eta0 = DrawCluster_AnaP(
1652  base + "/nosvtx/spacal1d/fieldmap/G4Hits_sPHENIX", "e-_eta0.30", false);
1653 
1654  TGraphErrors * gamma_eta0_1d = DrawCluster_AnaP(
1655  base + "/nosvtx/spacal1d/fieldmap/G4Hits_sPHENIX", "gamma_eta0.30",
1656  false);
1657  TCanvas *c1 = new TCanvas("DrawCluster_Res_2Fit_1DSpacalNoSVX_Eta3",
1658  "DrawCluster_Res_2Fit_1DSpacalNoSVX_Eta3", 1100, 900);
1659  c1->Divide(1, 1);
1660  int idx = 1;
1661  TPad * p;
1662 
1663  p = (TPad *) c1->cd(idx++);
1664  c1->Update();
1665 
1666  p->SetGridx(0);
1667  p->SetGridy(0);
1668 
1669  p->DrawFrame(0, 0, 35, 20e-2,
1670  ";Incoming Energy (GeV);Relative energy resolution, #DeltaE/E");
1671 
1672  TLegend * lg = new TLegend(2, 10e-2, 17, 20e-2, NULL, "br");
1673  TLegend * lg2 = new TLegend(16, 9e-2, 33, 19e-2, NULL, "br");
1674 
1675  TF1 * f_calo = new TF1("f_calo_gamma_eta0", "sqrt([0]*[0]+[1]*[1]/x)/100",
1676  0.5, 60);
1677  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta0", "([0]+[1]/sqrt(x))/100", 0.5,
1678  60);
1679  gamma_eta0->Fit(f_calo, "RM0");
1680  gamma_eta0->Fit(f_calo_l, "RM0");
1681 
1682  gamma_eta0->SetLineColor(kRed + 1);
1683  gamma_eta0->SetMarkerColor(kRed + 1);
1684  gamma_eta0->SetLineWidth(2);
1685  gamma_eta0->SetMarkerStyle(kFullSquare);
1686  gamma_eta0->SetMarkerSize(2);
1687  f_calo->SetLineColor(kRed + 1);
1688  f_calo->SetLineWidth(2);
1689  f_calo_l->SetLineColor(kRed + 1);
1690  f_calo_l->SetLineWidth(2);
1691  f_calo_l->SetLineStyle(kDashed);
1692 
1693  f_calo->Draw("same");
1694  f_calo_l->Draw("same");
1695  gamma_eta0->Draw("p");
1696 
1697  lg->AddEntry(gamma_eta0,
1698  Form("Electrons, #eta = 0.3-0.4", f_calo->GetParameter(0),
1699  f_calo->GetParameter(1)), "p");
1700  lg2->AddEntry(f_calo,
1701  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
1702  f_calo->GetParameter(1)), "l");
1703  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
1704  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
1705  f_calo_l->GetParameter(1)), "l");
1706  entry->SetTextColor(kGray + 1);
1707 
1708  TF1 * f_calo = new TF1("f_calo_gamma_eta0_1d", "sqrt([0]*[0]+[1]*[1]/x)/100",
1709  0.5, 60);
1710  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta0_1d", "([0]+[1]/sqrt(x))/100",
1711  0.5, 60);
1712  gamma_eta0_1d->Fit(f_calo, "RM0");
1713  gamma_eta0_1d->Fit(f_calo_l, "RM0");
1714 
1715  gamma_eta0_1d->SetLineColor(kBlue + 1);
1716  gamma_eta0_1d->SetMarkerColor(kBlue + 1);
1717  gamma_eta0_1d->SetLineWidth(2);
1718  gamma_eta0_1d->SetMarkerStyle(kOpenSquare);
1719  gamma_eta0_1d->SetMarkerSize(2);
1720  f_calo->SetLineColor(kBlue + 1);
1721  f_calo->SetLineWidth(2);
1722  f_calo_l->SetLineColor(kBlue + 1);
1723  f_calo_l->SetLineWidth(2);
1724  f_calo_l->SetLineStyle(kDashed);
1725 
1726  f_calo->Draw("same");
1727  f_calo_l->Draw("same");
1728  gamma_eta0_1d->Draw("p");
1729 
1730  TString ltitle = Form("Photons, #eta = 0.3-0.4", f_calo->GetParameter(0),
1731  f_calo->GetParameter(1));
1732  lg->AddEntry(gamma_eta0_1d, ltitle.Data(), "p");
1733  lg2->AddEntry(f_calo,
1734  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
1735  f_calo->GetParameter(1)), "l");
1736  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
1737  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
1738  f_calo_l->GetParameter(1)), "l");
1739  entry->SetTextColor(kGray + 1);
1740 
1741  lg->Draw();
1742  lg2->Draw();
1743 
1744  SaveCanvas(c1, base + "DrawEcal_" + TString(c1->GetName()), true);
1745 }
1746 
1747 void
1749  const TString base =
1750  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/emcstudies/",
1751  const TString config = "")
1752 {
1753  gStyle->SetOptStat(0);
1754  gStyle->SetOptFit(0);
1755 
1756 // TGraphErrors * gamma_eta0 = DrawCluster_AnaP(
1757 // base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0", false);
1758 // TGraphErrors * gamma_eta9 = DrawCluster_AnaP(
1759 // base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0.90", false);
1760 //
1761 // TGraphErrors * gamma_eta0_1d = DrawCluster_AnaP(
1762 // base + "/spacal1d_1dtower/zerofield/G4Hits_sPHENIX", "gamma_eta0", false);
1763 // TGraphErrors * gamma_eta9_1d = DrawCluster_AnaP(
1764 // base + "/spacal1d_1dtower/zerofield/G4Hits_sPHENIX", "gamma_eta0.90",
1765 // false);
1766 
1767 // TGraphErrors * gamma_eta0 = DrawCluster_AnaP(
1768 // base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0", false);
1769 // TGraphErrors * gamma_eta9 = DrawCluster_AnaP(
1770 // base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0.90", false);
1771 //
1772 // TGraphErrors * gamma_eta0_1d = DrawCluster_AnaP(
1773 // base + "/spacal1d/zerofield/G4Hits_sPHENIX", "gamma_eta0", false);
1774 // TGraphErrors * gamma_eta9_1d = DrawCluster_AnaP(
1775 // base + "/spacal1d/zerofield/G4Hits_sPHENIX", "gamma_eta0.90", false);
1776 
1777  TGraphErrors * gamma_eta0 = DrawCluster_AnaP(
1778  base + "/nosvtx/spacal2d/fieldmap/G4Hits_sPHENIX", "e-_eta0", false);
1779  TGraphErrors * gamma_eta9 = DrawCluster_AnaP(
1780  base + "/nosvtx/spacal2d/fieldmap/G4Hits_sPHENIX", "e-_eta0.90", false);
1781 
1782  TGraphErrors * gamma_eta0_1d = DrawCluster_AnaP(
1783  base + "/nosvtx/spacal2d/fieldmap/G4Hits_sPHENIX", "gamma_eta0", false);
1784  TGraphErrors * gamma_eta9_1d = DrawCluster_AnaP(
1785  base + "/nosvtx/spacal2d/fieldmap/G4Hits_sPHENIX", "gamma_eta0.90",
1786  false);
1787  TCanvas *c1 = new TCanvas("DrawCluster_Res_2Fit_2DSpacalNoSVX",
1788  "DrawCluster_Res_2Fit_2DSpacalNoSVX", 1100, 900);
1789  c1->Divide(1, 1);
1790  int idx = 1;
1791  TPad * p;
1792 
1793  p = (TPad *) c1->cd(idx++);
1794  c1->Update();
1795 
1796  p->SetGridx(0);
1797  p->SetGridy(0);
1798 
1799  p->DrawFrame(0, 0, 35, 20e-2,
1800  ";Incoming Energy (GeV);Relative energy resolution, #DeltaE/E");
1801 
1802  TLegend * lg = new TLegend(2, 9.6e-2, 17, 19.6e-2, NULL, "br");
1803  TLegend * lg2 = new TLegend(16, 9e-2, 33, 19e-2, NULL, "br");
1804 
1805  TF1 * f_calo = new TF1("f_calo_gamma_eta0", "sqrt([0]*[0]+[1]*[1]/x)/100",
1806  0.5, 60);
1807  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta0", "([0]+[1]/sqrt(x))/100", 0.5,
1808  60);
1809  gamma_eta0->Fit(f_calo, "RM0");
1810  gamma_eta0->Fit(f_calo_l, "RM0");
1811 
1812  gamma_eta0->SetLineColor(kRed + 1);
1813  gamma_eta0->SetMarkerColor(kRed + 1);
1814  gamma_eta0->SetLineWidth(2);
1815  gamma_eta0->SetMarkerStyle(kFullSquare);
1816  gamma_eta0->SetMarkerSize(2);
1817  f_calo->SetLineColor(kRed + 1);
1818  f_calo->SetLineWidth(2);
1819  f_calo_l->SetLineColor(kRed + 1);
1820  f_calo_l->SetLineWidth(2);
1821  f_calo_l->SetLineStyle(kDashed);
1822 
1823  f_calo->Draw("same");
1824  f_calo_l->Draw("same");
1825  gamma_eta0->Draw("p");
1826 
1827  lg->AddEntry(gamma_eta0,
1828  Form("Electrons, #eta = 0.0-0.1", f_calo->GetParameter(0),
1829  f_calo->GetParameter(1)), "p");
1830  lg2->AddEntry(f_calo,
1831  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
1832  f_calo->GetParameter(1)), "l");
1833  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
1834  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
1835  f_calo_l->GetParameter(1)), "l");
1836  entry->SetTextColor(kGray + 1);
1837 
1838  TF1 * f_calo = new TF1("f_calo_gamma_eta9", "sqrt([0]*[0]+[1]*[1]/x)/100",
1839  0.5, 60);
1840  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta9", "([0]+[1]/sqrt(x))/100", 0.5,
1841  60);
1842  gamma_eta9->Fit(f_calo, "RM0");
1843  gamma_eta9->Fit(f_calo_l, "RM0");
1844 
1845  gamma_eta9->SetLineColor(kRed + 3);
1846  gamma_eta9->SetMarkerColor(kRed + 3);
1847  gamma_eta9->SetLineWidth(2);
1848  gamma_eta9->SetMarkerStyle(kFullCircle);
1849  gamma_eta9->SetMarkerSize(2);
1850  f_calo->SetLineColor(kRed + 3);
1851  f_calo->SetLineWidth(2);
1852  f_calo_l->SetLineColor(kRed + 3);
1853  f_calo_l->SetLineWidth(2);
1854  f_calo_l->SetLineStyle(kDashed);
1855 
1856  f_calo->Draw("same");
1857  f_calo_l->Draw("same");
1858  gamma_eta9->Draw("p");
1859 
1860  TString ltitle = Form("Electrons, #eta = 0.9-1.0", f_calo->GetParameter(0),
1861  f_calo->GetParameter(1));
1862  lg->AddEntry(gamma_eta9, ltitle.Data(), "p");
1863  lg2->AddEntry(f_calo,
1864  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
1865  f_calo->GetParameter(1)), "l");
1866  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
1867  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
1868  f_calo_l->GetParameter(1)), "l");
1869  entry->SetTextColor(kGray + 1);
1870  cout << "Title = " << ltitle << endl;
1871 
1872  TF1 * f_calo = new TF1("f_calo_gamma_eta0_1d", "sqrt([0]*[0]+[1]*[1]/x)/100",
1873  0.5, 60);
1874  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta0_1d", "([0]+[1]/sqrt(x))/100",
1875  0.5, 60);
1876  gamma_eta0_1d->Fit(f_calo, "RM0");
1877  gamma_eta0_1d->Fit(f_calo_l, "RM0");
1878 
1879  gamma_eta0_1d->SetLineColor(kBlue + 1);
1880  gamma_eta0_1d->SetMarkerColor(kBlue + 1);
1881  gamma_eta0_1d->SetLineWidth(2);
1882  gamma_eta0_1d->SetMarkerStyle(kOpenSquare);
1883  gamma_eta0_1d->SetMarkerSize(2);
1884  f_calo->SetLineColor(kBlue + 1);
1885  f_calo->SetLineWidth(2);
1886  f_calo_l->SetLineColor(kBlue + 1);
1887  f_calo_l->SetLineWidth(2);
1888  f_calo_l->SetLineStyle(kDashed);
1889 
1890  f_calo->Draw("same");
1891  f_calo_l->Draw("same");
1892  gamma_eta0_1d->Draw("p");
1893 
1894  TString ltitle = Form("Photons, #eta = 0.0-0.1", f_calo->GetParameter(0),
1895  f_calo->GetParameter(1));
1896  lg->AddEntry(gamma_eta0_1d, ltitle.Data(), "p");
1897  lg2->AddEntry(f_calo,
1898  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
1899  f_calo->GetParameter(1)), "l");
1900  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
1901  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
1902  f_calo_l->GetParameter(1)), "l");
1903  entry->SetTextColor(kGray + 1);
1904 
1905  TF1 * f_calo = new TF1("f_calo_gamma_eta0_1d", "sqrt([0]*[0]+[1]*[1]/x)/100",
1906  0.5, 60);
1907  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta0_1d", "([0]+[1]/sqrt(x))/100",
1908  0.5, 60);
1909  gamma_eta9_1d->Fit(f_calo, "RM0");
1910  gamma_eta9_1d->Fit(f_calo_l, "RM0");
1911 
1912  gamma_eta9_1d->SetLineColor(kBlue + 3);
1913  gamma_eta9_1d->SetMarkerColor(kBlue + 3);
1914  gamma_eta9_1d->SetLineWidth(2);
1915  gamma_eta9_1d->SetMarkerStyle(kOpenCircle);
1916  gamma_eta9_1d->SetMarkerSize(2);
1917  f_calo->SetLineColor(kBlue + 3);
1918  f_calo->SetLineWidth(2);
1919  f_calo_l->SetLineColor(kBlue + 3);
1920  f_calo_l->SetLineWidth(2);
1921  f_calo_l->SetLineStyle(kDashed);
1922 
1923  f_calo->Draw("same");
1924  f_calo_l->Draw("same");
1925  gamma_eta9_1d->Draw("p");
1926 
1927  TString ltitle = Form("Photons, #eta = 0.9-1.0", f_calo->GetParameter(0),
1928  f_calo->GetParameter(1));
1929  lg->AddEntry(gamma_eta9_1d, ltitle.Data(), "p");
1930  lg2->AddEntry(f_calo,
1931  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
1932  f_calo->GetParameter(1)), "l");
1933  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
1934  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
1935  f_calo_l->GetParameter(1)), "l");
1936  entry->SetTextColor(kGray + 1);
1937  cout << "Title = " << ltitle << endl;
1938 
1939  lg->Draw();
1940  lg2->Draw();
1941 
1942  SaveCanvas(c1, base + "DrawEcal_" + TString(c1->GetName()), true);
1943 }
1944 
1945 void
1947  const TString base =
1948  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/",
1949  const TString config = "")
1950 {
1951  gStyle->SetOptStat(0);
1952  gStyle->SetOptFit(0);
1953 
1954  TGraphErrors * gamma_eta0 = DrawCluster_AnaP(
1955  base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0", false);
1956  TGraphErrors * gamma_eta9 = DrawCluster_AnaP(
1957  base + "/spacal2d/zerofield/G4Hits_sPHENIX", "gamma_eta0.90", false);
1958 
1959  TGraphErrors * gamma_eta0_1d = DrawCluster_AnaP(
1960  base + "/spacal1d_1dtower/zerofield/G4Hits_sPHENIX", "gamma_eta0", false);
1961  TGraphErrors * gamma_eta9_1d = DrawCluster_AnaP(
1962  base + "/spacal1d_1dtower/zerofield/G4Hits_sPHENIX", "gamma_eta0.90",
1963  false);
1964 
1965  TCanvas *c1 = new TCanvas("DrawCluster_Res", "DrawCluster_Res", 1100, 900);
1966  c1->Divide(1, 1);
1967  int idx = 1;
1968  TPad * p;
1969 
1970  p = (TPad *) c1->cd(idx++);
1971  c1->Update();
1972 
1973  p->SetGridx(0);
1974  p->SetGridy(0);
1975 
1976  p->DrawFrame(0, 0, 35, 20e-2,
1977  ";Incoming Energy (GeV);Relative energy resolution, #DeltaE/E");
1978 
1979  TLegend * lg = new TLegend(2, 10e-2, 33, 18e-2, NULL, "br");
1980 
1981  TF1 * f_calo = new TF1("f_calo_gamma_eta0", "sqrt([0]*[0]+[1]*[1]/x)/100",
1982  0.5, 60);
1983  gamma_eta0->Fit(f_calo, "RM0");
1984 
1985  gamma_eta0->SetLineColor(kRed + 1);
1986  gamma_eta0->SetMarkerColor(kRed + 1);
1987  gamma_eta0->SetLineWidth(2);
1988  gamma_eta0->SetMarkerStyle(kFullSquare);
1989  gamma_eta0->SetMarkerSize(2);
1990  f_calo->SetLineColor(kRed + 1);
1991  f_calo->SetLineWidth(2);
1992 
1993  gamma_eta0->Draw("p");
1994  f_calo->Draw("same");
1995 
1996  TString ltitle = Form(
1997  "2D-proj., #eta = 0.0-0.1, #DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}",
1998  f_calo->GetParameter(0), f_calo->GetParameter(1));
1999  lg->AddEntry(gamma_eta0, ltitle.Data(), "pl");
2000 
2001  TF1 * f_calo = new TF1("f_calo_gamma_eta9", "sqrt([0]*[0]+[1]*[1]/x)/100",
2002  0.5, 60);
2003  gamma_eta9->Fit(f_calo, "RM0");
2004 
2005  gamma_eta9->SetLineColor(kRed + 3);
2006  gamma_eta9->SetMarkerColor(kRed + 3);
2007  gamma_eta9->SetLineWidth(2);
2008  gamma_eta9->SetMarkerStyle(kFullCircle);
2009  gamma_eta9->SetMarkerSize(2);
2010  f_calo->SetLineColor(kRed + 3);
2011  f_calo->SetLineWidth(2);
2012 
2013  gamma_eta9->Draw("p");
2014  f_calo->Draw("same");
2015 
2016  TString ltitle = Form(
2017  "2D-proj., #eta = 0.9-1.0, #DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}",
2018  f_calo->GetParameter(0), f_calo->GetParameter(1));
2019  lg->AddEntry(gamma_eta9, ltitle.Data(), "pl");
2020  cout << "Title = " << ltitle << endl;
2021 
2022  TF1 * f_calo = new TF1("f_calo_gamma_eta0_1d", "sqrt([0]*[0]+[1]*[1]/x)/100",
2023  0.5, 60);
2024  gamma_eta0_1d->Fit(f_calo, "RM0");
2025 
2026  gamma_eta0_1d->SetLineColor(kBlue + 1);
2027  gamma_eta0_1d->SetMarkerColor(kBlue + 1);
2028  gamma_eta0_1d->SetLineWidth(2);
2029  gamma_eta0_1d->SetMarkerStyle(kOpenSquare);
2030  gamma_eta0_1d->SetMarkerSize(2);
2031  f_calo->SetLineColor(kBlue + 1);
2032  f_calo->SetLineWidth(2);
2033 
2034  gamma_eta0_1d->Draw("p");
2035  f_calo->Draw("same");
2036 
2037  TString ltitle = Form(
2038  "1D-proj., #eta = 0.0-0.1, #DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}",
2039  f_calo->GetParameter(0), f_calo->GetParameter(1));
2040  lg->AddEntry(gamma_eta0_1d, ltitle.Data(), "pl");
2041 
2042  TF1 * f_calo = new TF1("f_calo_gamma_eta9_1d", "sqrt([0]*[0]+[1]*[1]/x)/100",
2043  0.5, 60);
2044  gamma_eta9_1d->Fit(f_calo, "RM0");
2045 
2046  gamma_eta9_1d->SetLineColor(kBlue + 3);
2047  gamma_eta9_1d->SetMarkerColor(kBlue + 3);
2048  gamma_eta9_1d->SetLineWidth(2);
2049  gamma_eta9_1d->SetMarkerStyle(kOpenCircle);
2050  gamma_eta9_1d->SetMarkerSize(2);
2051  f_calo->SetLineColor(kBlue + 3);
2052  f_calo->SetLineWidth(2);
2053 
2054  gamma_eta9_1d->Draw("p");
2055  f_calo->Draw("same");
2056 
2057  TString ltitle = Form(
2058  "1D-proj., #eta = 0.9-1.0, #DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}",
2059  f_calo->GetParameter(0), f_calo->GetParameter(1));
2060  lg->AddEntry(gamma_eta9_1d, ltitle.Data(), "pl");
2061  cout << "Title = " << ltitle << endl;
2062 
2063  lg->Draw();
2064 
2065  SaveCanvas(c1, base + "DrawEcal_" + TString(c1->GetName()), true);
2066 }
2067 
2068 TGraphErrors *
2070  const TString config =
2071 // "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX", //
2072  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal1d_1dtower/zerofield/G4Hits_sPHENIX",//
2073  const TString particle = "gamma_eta0.90", bool mean_or_res = false)
2074 {
2075 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_10GeV.root_hist.root
2076 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_16GeV.root_hist.root
2077 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_1GeV.root_hist.root
2078 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_24GeV.root_hist.root
2079 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_2GeV.root_hist.root
2080 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_32GeV.root_hist.root
2081 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_40GeV.root_hist.root
2082 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_4GeV.root_hist.root
2083 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_50GeV.root_hist.root
2084 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_8GeV.root_hist.root
2085 
2086  const int N = 10;
2087  double es[100] =
2088  { 1, 2, 4, 8, 10, 16, 24, 32, 40, 50 };
2089  double mean[100] =
2090  { 0 };
2091  double mean_err[100] =
2092  { 0 };
2093  double res[100] =
2094  { 0 };
2095  double res_err[100] =
2096  { 0 };
2097 
2098  TCanvas *c1 = new TCanvas(config, config);
2099  c1->Print(config + ".pdf[");
2100 
2101  for (int i = 0; i < N; ++i)
2102  {
2103  TVectorD fit(4);
2104 
2105  fit = DrawCluster_SingleE(config, particle, es[i]);
2106 
2107  mean[i] = fit[0];
2108  mean_err[i] = fit[1];
2109  res[i] = fit[2] / mean[i];
2110  res_err[i] = fit[3] / mean[i];
2111  }
2112  c1->Print(config + ".pdf]");
2113  cout << "DrawCluster_AnaP - save to " << config << ".pdf" << endl;
2114 
2115  if (mean_or_res)
2116  {
2117  TGraphErrors * ge = new TGraphErrors(N, es, mean, 0, mean_err);
2118  ge->Print();
2119  return ge;
2120  }
2121  else
2122  {
2123  TGraphErrors * ge = new TGraphErrors(N, es, res, 0, res_err);
2124  ge->Print();
2125  return ge;
2126  }
2127 
2128 }
2129 
2130 TVectorD
2132  const TString config =
2133  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX", //
2134  const TString particle = "gamma_eta0", const double e = 8)
2135 {
2136 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_8GeV.root_g4cemc_eval.root
2137 
2138  const TString e_GeV = Form("%.0fGeV", e);
2139 
2140  const TString file_name = config + "_" + particle + "_" + e_GeV
2141  + ".root_g4cemc_eval.root";
2142  +".root_hist.root";
2143  cout << "DrawCluster_SingleE - lead " << file_name << endl;
2144 
2145  TFile *f = new TFile(file_name);
2146  assert(f);
2147  TTree * ntp_cluster = (TTree *) f->GetObjectChecked("ntp_cluster", "TTree");
2148  assert(ntp_cluster);
2149 
2150  const TString h_cluster_E_name = TString("h_cluster_E_") + particle + e_GeV;
2151  TH1F * h_cluster_E = new TH1F(h_cluster_E_name, file_name, 200, 0, e * 1.5);
2152 
2153  TCanvas *c1 = new TCanvas(file_name, file_name);
2154  ntp_cluster->Draw("e>>" + h_cluster_E_name, "gparticleID==1 && e>0.2");
2155 
2156  const double mean = h_cluster_E->GetMean();
2157  const double rms = h_cluster_E->GetRMS();
2158 
2159 // const double lower_lim = mean - ((e >= 8) ? (4 / e * rms) : (1.5 * rms));
2160 // const double lower_lim = mean - ((e >= 8) ? (rms) : (1.5 * rms));
2161  TF1 * f_gaus_pilot = new TF1("f_gaus_pilot" + h_cluster_E_name, "gaus",
2162  e * 0.5, e * 1.5);
2163  f_gaus_pilot->SetParameters(1, mean, rms);
2164  f_gaus_pilot->SetLineColor(kRed);
2165  h_cluster_E->Fit(f_gaus_pilot, "MRQS0");
2166  f_gaus_pilot->Draw("same");
2167 
2168  TF1 * f_gaus = new TF1("f_gaus" + h_cluster_E_name, "gaus",
2169  f_gaus_pilot->GetParameter(1) - 1.5 * f_gaus_pilot->GetParameter(2),
2170  f_gaus_pilot->GetParameter(1) + 4 * f_gaus_pilot->GetParameter(2));
2171  f_gaus->SetParameters(f_gaus_pilot->GetParameter(0),
2172  f_gaus_pilot->GetParameter(1), f_gaus_pilot->GetParameter(2));
2173 
2174  h_cluster_E->Fit(f_gaus, "MRQS0");
2175  f_gaus->Draw("same");
2176 
2177  cout << "load_SF - result = " << f_gaus->GetParameter(1) << "+/-"
2178  << f_gaus->GetParError(1) << endl;
2179 
2180  TVectorD ret(4);
2181  ret[0] = f_gaus->GetParameter(1);
2182  ret[1] = f_gaus->GetParError(1);
2183  ret[2] = f_gaus->GetParameter(2);
2184  ret[3] = f_gaus->GetParError(2);
2185 
2186  c1->Print(config + ".pdf");
2187 
2188  return ret;
2189 }
2190 
2191 void
2193  const TString base =
2194  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/emcstudies/",
2195  const TString config = "")
2196 {
2197  gStyle->SetOptStat(0);
2198  gStyle->SetOptFit(0);
2199 
2200  TGraphErrors * gamma_eta0 = DrawTowerSum_AnaP(
2201  base + "/nosvtx/spacal1d/fieldmap/G4Hits_sPHENIX", "e-_eta0", false);
2202  TGraphErrors * gamma_eta9 = DrawTowerSum_AnaP(
2203  base + "/nosvtx/spacal1d/fieldmap/G4Hits_sPHENIX", "e-_eta0.90", false);
2204 
2205  TGraphErrors * gamma_eta0_1d = DrawTowerSum_AnaP(
2206  base + "/nosvtx/spacal1d/fieldmap/G4Hits_sPHENIX", "gamma_eta0", false);
2207  TGraphErrors * gamma_eta9_1d = DrawTowerSum_AnaP(
2208  base + "/nosvtx/spacal1d/fieldmap/G4Hits_sPHENIX", "gamma_eta0.90",
2209  false);
2210 
2211  TCanvas *c1 = new TCanvas("DrawTowerSum_Res_2Fit_1DSpacalNoSVX",
2212  "DrawTowerSum_Res_2Fit_1DSpacalNoSVX", 1100, 900);
2213  c1->Divide(1, 1);
2214  int idx = 1;
2215  TPad * p;
2216 
2217  p = (TPad *) c1->cd(idx++);
2218  c1->Update();
2219 
2220  p->SetGridx(0);
2221  p->SetGridy(0);
2222 
2223  p->DrawFrame(0, 0, 35, 20e-2,
2224  ";Incoming Energy (GeV);Relative energy resolution, #DeltaE/E");
2225 
2226  TLegend * lg = new TLegend(2, 9.6e-2, 17, 19.6e-2, NULL, "br");
2227  TLegend * lg2 = new TLegend(16, 9e-2, 33, 19e-2, NULL, "br");
2228 
2229  TF1 * f_calo = new TF1("f_calo_gamma_eta0", "sqrt([0]*[0]+[1]*[1]/x)/100",
2230  0.5, 60);
2231  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta0", "([0]+[1]/sqrt(x))/100", 0.5,
2232  60);
2233  gamma_eta0->Fit(f_calo, "RM0");
2234  gamma_eta0->Fit(f_calo_l, "RM0");
2235 
2236  gamma_eta0->SetLineColor(kRed + 1);
2237  gamma_eta0->SetMarkerColor(kRed + 1);
2238  gamma_eta0->SetLineWidth(2);
2239  gamma_eta0->SetMarkerStyle(kFullSquare);
2240  gamma_eta0->SetMarkerSize(2);
2241  f_calo->SetLineColor(kRed + 1);
2242  f_calo->SetLineWidth(2);
2243  f_calo_l->SetLineColor(kRed + 1);
2244  f_calo_l->SetLineWidth(2);
2245  f_calo_l->SetLineStyle(kDashed);
2246 
2247  f_calo->Draw("same");
2248  f_calo_l->Draw("same");
2249  gamma_eta0->Draw("p");
2250 
2251  lg->AddEntry(gamma_eta0,
2252  Form("Electrons, #eta = 0.0-0.1", f_calo->GetParameter(0),
2253  f_calo->GetParameter(1)), "p");
2254  lg2->AddEntry(f_calo,
2255  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
2256  f_calo->GetParameter(1)), "l");
2257  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
2258  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
2259  f_calo_l->GetParameter(1)), "l");
2260  entry->SetTextColor(kGray + 1);
2261 
2262  TF1 * f_calo = new TF1("f_calo_gamma_eta9", "sqrt([0]*[0]+[1]*[1]/x)/100",
2263  0.5, 60);
2264  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta9", "([0]+[1]/sqrt(x))/100", 0.5,
2265  60);
2266  gamma_eta9->Fit(f_calo, "RM0");
2267  gamma_eta9->Fit(f_calo_l, "RM0");
2268 
2269  gamma_eta9->SetLineColor(kRed + 3);
2270  gamma_eta9->SetMarkerColor(kRed + 3);
2271  gamma_eta9->SetLineWidth(2);
2272  gamma_eta9->SetMarkerStyle(kFullCircle);
2273  gamma_eta9->SetMarkerSize(2);
2274  f_calo->SetLineColor(kRed + 3);
2275  f_calo->SetLineWidth(2);
2276  f_calo_l->SetLineColor(kRed + 3);
2277  f_calo_l->SetLineWidth(2);
2278  f_calo_l->SetLineStyle(kDashed);
2279 
2280  f_calo->Draw("same");
2281  f_calo_l->Draw("same");
2282  gamma_eta9->Draw("p");
2283 
2284  TString ltitle = Form("Electrons, #eta = 0.9-1.0", f_calo->GetParameter(0),
2285  f_calo->GetParameter(1));
2286  lg->AddEntry(gamma_eta9, ltitle.Data(), "p");
2287  lg2->AddEntry(f_calo,
2288  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
2289  f_calo->GetParameter(1)), "l");
2290  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
2291  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
2292  f_calo_l->GetParameter(1)), "l");
2293  entry->SetTextColor(kGray + 1);
2294  cout << "Title = " << ltitle << endl;
2295 
2296  TF1 * f_calo = new TF1("f_calo_gamma_eta0_1d", "sqrt([0]*[0]+[1]*[1]/x)/100",
2297  0.5, 60);
2298  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta0_1d", "([0]+[1]/sqrt(x))/100",
2299  0.5, 60);
2300  gamma_eta0_1d->Fit(f_calo, "RM0");
2301  gamma_eta0_1d->Fit(f_calo_l, "RM0");
2302 
2303  gamma_eta0_1d->SetLineColor(kBlue + 1);
2304  gamma_eta0_1d->SetMarkerColor(kBlue + 1);
2305  gamma_eta0_1d->SetLineWidth(2);
2306  gamma_eta0_1d->SetMarkerStyle(kOpenSquare);
2307  gamma_eta0_1d->SetMarkerSize(2);
2308  f_calo->SetLineColor(kBlue + 1);
2309  f_calo->SetLineWidth(2);
2310  f_calo_l->SetLineColor(kBlue + 1);
2311  f_calo_l->SetLineWidth(2);
2312  f_calo_l->SetLineStyle(kDashed);
2313 
2314  f_calo->Draw("same");
2315  f_calo_l->Draw("same");
2316  gamma_eta0_1d->Draw("p");
2317 
2318  TString ltitle = Form("Photons, #eta = 0.0-0.1", f_calo->GetParameter(0),
2319  f_calo->GetParameter(1));
2320  lg->AddEntry(gamma_eta0_1d, ltitle.Data(), "p");
2321  lg2->AddEntry(f_calo,
2322  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
2323  f_calo->GetParameter(1)), "l");
2324  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
2325  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
2326  f_calo_l->GetParameter(1)), "l");
2327  entry->SetTextColor(kGray + 1);
2328 
2329  TF1 * f_calo = new TF1("f_calo_gamma_eta0_1d", "sqrt([0]*[0]+[1]*[1]/x)/100",
2330  0.5, 60);
2331  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta0_1d", "([0]+[1]/sqrt(x))/100",
2332  0.5, 60);
2333  gamma_eta9_1d->Fit(f_calo, "RM0");
2334  gamma_eta9_1d->Fit(f_calo_l, "RM0");
2335 
2336  gamma_eta9_1d->SetLineColor(kBlue + 3);
2337  gamma_eta9_1d->SetMarkerColor(kBlue + 3);
2338  gamma_eta9_1d->SetLineWidth(2);
2339  gamma_eta9_1d->SetMarkerStyle(kOpenCircle);
2340  gamma_eta9_1d->SetMarkerSize(2);
2341  f_calo->SetLineColor(kBlue + 3);
2342  f_calo->SetLineWidth(2);
2343  f_calo_l->SetLineColor(kBlue + 3);
2344  f_calo_l->SetLineWidth(2);
2345  f_calo_l->SetLineStyle(kDashed);
2346 
2347  f_calo->Draw("same");
2348  f_calo_l->Draw("same");
2349  gamma_eta9_1d->Draw("p");
2350 
2351  TString ltitle = Form("Photons, #eta = 0.9-1.0", f_calo->GetParameter(0),
2352  f_calo->GetParameter(1));
2353  lg->AddEntry(gamma_eta9_1d, ltitle.Data(), "p");
2354  lg2->AddEntry(f_calo,
2355  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
2356  f_calo->GetParameter(1)), "l");
2357  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
2358  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
2359  f_calo_l->GetParameter(1)), "l");
2360  entry->SetTextColor(kGray + 1);
2361  cout << "Title = " << ltitle << endl;
2362 
2363  lg->Draw();
2364  lg2->Draw();
2365 
2366  SaveCanvas(c1, base + "DrawEcal_" + TString(c1->GetName()), true);
2367 }
2368 
2369 void
2371  const TString base =
2372  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/emcstudies/",
2373  const TString config = "")
2374 {
2375  gStyle->SetOptStat(0);
2376  gStyle->SetOptFit(0);
2377 
2378  TGraphErrors * gamma_eta0 = DrawTowerSum_AnaP(
2379  base + "/nosvtx/spacal1d/fieldmap/G4Hits_sPHENIX", "e-_eta0.30", false);
2380 // TGraphErrors * gamma_eta9 = DrawTowerSum_AnaP(
2381 // base + "/nosvtx/spacal1d/fieldmap/G4Hits_sPHENIX", "e-_eta0.90", false);
2382 
2383  TGraphErrors * gamma_eta0_1d = DrawTowerSum_AnaP(
2384  base + "/nosvtx/spacal1d/fieldmap/G4Hits_sPHENIX", "gamma_eta0.30",
2385  false);
2386 // TGraphErrors * gamma_eta9_1d = DrawTowerSum_AnaP(
2387 // base + "/nosvtx/spacal1d/fieldmap/G4Hits_sPHENIX", "gamma_eta0.90",
2388 // false);
2389 
2390  TCanvas *c1 = new TCanvas("DrawTowerSum_Res_2Fit_1DSpacalNoSVX_Eta3",
2391  "DrawTowerSum_Res_2Fit_1DSpacalNoSVX_Eta3", 1100, 900);
2392  c1->Divide(1, 1);
2393  int idx = 1;
2394  TPad * p;
2395 
2396  p = (TPad *) c1->cd(idx++);
2397  c1->Update();
2398 
2399  p->SetGridx(0);
2400  p->SetGridy(0);
2401 
2402  p->DrawFrame(0, 0, 35, 20e-2,
2403  ";Incoming Energy (GeV);Relative energy resolution, #DeltaE/E");
2404 
2405  TLegend * lg = new TLegend(2, 9.6e-2, 17, 19.6e-2, NULL, "br");
2406  TLegend * lg2 = new TLegend(16, 9e-2, 33, 19e-2, NULL, "br");
2407 
2408  TF1 * f_calo = new TF1("f_calo_gamma_eta0", "sqrt([0]*[0]+[1]*[1]/x)/100",
2409  0.5, 60);
2410  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta0", "([0]+[1]/sqrt(x))/100", 0.5,
2411  60);
2412  gamma_eta0->Fit(f_calo, "RM0");
2413  gamma_eta0->Fit(f_calo_l, "RM0");
2414 
2415  gamma_eta0->SetLineColor(kRed + 1);
2416  gamma_eta0->SetMarkerColor(kRed + 1);
2417  gamma_eta0->SetLineWidth(2);
2418  gamma_eta0->SetMarkerStyle(kFullSquare);
2419  gamma_eta0->SetMarkerSize(2);
2420  f_calo->SetLineColor(kRed + 1);
2421  f_calo->SetLineWidth(2);
2422  f_calo_l->SetLineColor(kRed + 1);
2423  f_calo_l->SetLineWidth(2);
2424  f_calo_l->SetLineStyle(kDashed);
2425 
2426  f_calo->Draw("same");
2427  f_calo_l->Draw("same");
2428  gamma_eta0->Draw("p");
2429 
2430  lg->AddEntry(gamma_eta0,
2431  Form("Electrons, #eta = 0.3-0.4", f_calo->GetParameter(0),
2432  f_calo->GetParameter(1)), "p");
2433  lg2->AddEntry(f_calo,
2434  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
2435  f_calo->GetParameter(1)), "l");
2436  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
2437  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
2438  f_calo_l->GetParameter(1)), "l");
2439  entry->SetTextColor(kGray + 1);
2440 
2441  TF1 * f_calo = new TF1("f_calo_gamma_eta0_1d", "sqrt([0]*[0]+[1]*[1]/x)/100",
2442  0.5, 60);
2443  TF1 * f_calo_l = new TF1("f_calo_l_gamma_eta0_1d", "([0]+[1]/sqrt(x))/100",
2444  0.5, 60);
2445  gamma_eta0_1d->Fit(f_calo, "RM0");
2446  gamma_eta0_1d->Fit(f_calo_l, "RM0");
2447 
2448  gamma_eta0_1d->SetLineColor(kBlue + 1);
2449  gamma_eta0_1d->SetMarkerColor(kBlue + 1);
2450  gamma_eta0_1d->SetLineWidth(2);
2451  gamma_eta0_1d->SetMarkerStyle(kOpenSquare);
2452  gamma_eta0_1d->SetMarkerSize(2);
2453  f_calo->SetLineColor(kBlue + 1);
2454  f_calo->SetLineWidth(2);
2455  f_calo_l->SetLineColor(kBlue + 1);
2456  f_calo_l->SetLineWidth(2);
2457  f_calo_l->SetLineStyle(kDashed);
2458 
2459  f_calo->Draw("same");
2460  f_calo_l->Draw("same");
2461  gamma_eta0_1d->Draw("p");
2462 
2463  TString ltitle = Form("Photons, #eta = 0.3-0.4", f_calo->GetParameter(0),
2464  f_calo->GetParameter(1));
2465  lg->AddEntry(gamma_eta0_1d, ltitle.Data(), "p");
2466  lg2->AddEntry(f_calo,
2467  Form("#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}", f_calo->GetParameter(0),
2468  f_calo->GetParameter(1)), "l");
2469  TLegendEntry * entry = lg2->AddEntry(f_calo_l,
2470  Form("#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", f_calo_l->GetParameter(0),
2471  f_calo_l->GetParameter(1)), "l");
2472  entry->SetTextColor(kGray + 1);
2473 
2474  lg->Draw();
2475  lg2->Draw();
2476 
2477  SaveCanvas(c1, base + "DrawEcal_" + TString(c1->GetName()), true);
2478 }
2479 
2480 TGraphErrors *
2482  const TString config =
2483  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/emcstudies/nosvtx/spacal1d/fieldmap/G4Hits_sPHENIX", //
2484  const TString particle = "e-_eta0", bool mean_or_res = false)
2485 {
2486 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_10GeV.root_hist.root
2487 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_16GeV.root_hist.root
2488 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_1GeV.root_hist.root
2489 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_24GeV.root_hist.root
2490 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_2GeV.root_hist.root
2491 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_32GeV.root_hist.root
2492 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_40GeV.root_hist.root
2493 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_4GeV.root_hist.root
2494 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_50GeV.root_hist.root
2495 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_8GeV.root_hist.root
2496 
2497  const int N = 10;
2498  double es[100] =
2499  { 1, 2, 4, 8, 10, 16, 24, 32, 40, 50 };
2500  double mean[100] =
2501  { 0 };
2502  double mean_err[100] =
2503  { 0 };
2504  double res[100] =
2505  { 0 };
2506  double res_err[100] =
2507  { 0 };
2508 
2509  TCanvas *c1 = new TCanvas(config, config);
2510  c1->Print(config + ".pdf[");
2511 
2512  for (int i = 0; i < N; ++i)
2513  {
2514  TVectorD fit(4);
2515 
2516  fit = DrawTowerSum_SingleE(config, particle, es[i]);
2517 
2518  mean[i] = fit[0];
2519  mean_err[i] = fit[1];
2520  res[i] = fit[2] / mean[i];
2521  res_err[i] = fit[3] / mean[i];
2522  }
2523  c1->Print(config + ".pdf]");
2524  cout << "DrawTowerSum_AnaP - save to " << config << ".pdf" << endl;
2525 
2526  if (mean_or_res)
2527  {
2528  TGraphErrors * ge = new TGraphErrors(N, es, mean, 0, mean_err);
2529  ge->Print();
2530  return ge;
2531  }
2532  else
2533  {
2534  TGraphErrors * ge = new TGraphErrors(N, es, res, 0, res_err);
2535  ge->Print();
2536  return ge;
2537  }
2538 
2539 }
2540 
2541 TVectorD
2543  const TString config =
2544  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/production_analysis/emcstudies/nosvtx/spacal1d/fieldmap/G4Hits_sPHENIX", //
2545  const TString particle = "e-_eta0", const double e = 8)
2546 {
2547 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_8GeV.root_g4cemc_eval.root
2548 
2549  const TString e_GeV = Form("%.0fGeV", e);
2550 
2551  const TString file_name = config + "_" + particle + "_" + e_GeV
2552  + ".root_DSTReader.root";
2553  cout << "DrawTowerSum_SingleE - lead " << file_name << endl;
2554 
2555  TFile *f = new TFile(file_name);
2556  assert(f);
2557  TTree * T = (TTree *) f->GetObjectChecked("T", "TTree");
2558  assert(T);
2559 
2560  const TString h_cluster_E_name = TString("h_cluster_E_") + particle + e_GeV;
2561  TH1F * h_cluster_E = new TH1F(h_cluster_E_name, file_name, 200, 0, e * 1.5);
2562 
2563  TCanvas *c1 = new TCanvas(file_name, file_name);
2564  T->Draw("Sum$(TOWER_SIM_CEMC.energy)/ 2.36081e-02>>" + h_cluster_E_name, "");
2565 
2566  const double mean = h_cluster_E->GetMean();
2567  const double rms = h_cluster_E->GetRMS();
2568 
2569 // const double lower_lim = mean - ((e >= 8) ? (4 / e * rms) : (1.5 * rms));
2570 // const double lower_lim = mean - ((e >= 8) ? (rms) : (1.5 * rms));
2571  TF1 * f_gaus_pilot = new TF1("f_gaus_pilot" + h_cluster_E_name, "gaus",
2572  e * 0.5, e * 1.5);
2573  f_gaus_pilot->SetParameters(1, mean, rms);
2574  f_gaus_pilot->SetLineColor(kRed);
2575  h_cluster_E->Fit(f_gaus_pilot, "MRQS0");
2576  f_gaus_pilot->Draw("same");
2577 
2578  TF1 * f_gaus = new TF1("f_gaus" + h_cluster_E_name, "gaus",
2579  f_gaus_pilot->GetParameter(1) - 1.5 * f_gaus_pilot->GetParameter(2),
2580  f_gaus_pilot->GetParameter(1) + 4 * f_gaus_pilot->GetParameter(2));
2581  f_gaus->SetParameters(f_gaus_pilot->GetParameter(0),
2582  f_gaus_pilot->GetParameter(1), f_gaus_pilot->GetParameter(2));
2583 
2584  h_cluster_E->Fit(f_gaus, "MRQS0");
2585  f_gaus->Draw("same");
2586 
2587  cout << "load_SF - result = " << f_gaus->GetParameter(1) << "+/-"
2588  << f_gaus->GetParError(1) << endl;
2589 
2590  TVectorD ret(4);
2591  ret[0] = f_gaus->GetParameter(1);
2592  ret[1] = f_gaus->GetParError(1);
2593  ret[2] = f_gaus->GetParameter(2);
2594  ret[3] = f_gaus->GetParError(2);
2595 
2596  c1->Print(config + ".pdf");
2597 
2598  return ret;
2599 }
2600 
2601 void
2603  const TString base =
2604  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/",
2605  const TString config = "")
2606 {
2607  gStyle->SetOptStat(0);
2608  gStyle->SetOptFit(0);
2609 
2610  TCanvas *c1 = new TCanvas("DrawSF", "DrawSF", 1800, 900);
2611  c1->Divide(1, 1);
2612  int idx = 1;
2613  TPad * p;
2614 
2615  p = (TPad *) c1->cd(idx++);
2616  c1->Update();
2617 
2618  p->SetGridx(0);
2619  p->SetGridy(0);
2620 
2621  p->DrawFrame(-0.1, 2e-2, 1.2, 3.0e-2,
2622  ";Pseudorapidity;EMCal Sampling fraction");
2623 
2624  TLegend * lg = new TLegend(0, 2.55e-2, 0.6, 2.9e-2, NULL, "br");
2625 
2626  TGraphErrors * ge = Load_CurveSet(
2627  base + "/spacal2d/zerofield/G4Hits_sPHENIX_gamma", "24GeV");
2628  ge->SetLineColor(kRed + 3);
2629  ge->SetMarkerColor(kRed + 3);
2630  ge->SetLineWidth(2);
2631  ge->SetMarkerStyle(kFullSquare);
2632  ge->SetMarkerSize(2);
2633  ge->Draw("lep");
2634  lg->AddEntry(ge, "24 GeV #gamma in 2D-proj. SPACAL", "lp");
2635 
2636  TGraphErrors * ge = Load_CurveSet(
2637  base + "/spacal1d/zerofield/G4Hits_sPHENIX_gamma", "24GeV");
2638  ge->SetLineColor(kBlue + 3);
2639  ge->SetMarkerColor(kBlue + 3);
2640  ge->SetLineStyle(kDashed);
2641  ge->SetLineWidth(2);
2642  ge->SetMarkerStyle(kOpenSquare);
2643  ge->SetMarkerSize(2);
2644  ge->Draw("lep");
2645  lg->AddEntry(ge, "24 GeV #gamma in 1D-proj. SPACAL", "lp");
2646 
2647  TGraphErrors * ge = Load_CurveSet(
2648  base + "/spacal2d/zerofield/G4Hits_sPHENIX_e-", "4GeV");
2649  ge->SetLineColor(kRed + 3);
2650  ge->SetMarkerColor(kRed + 3);
2651  ge->SetLineWidth(2);
2652  ge->SetMarkerStyle(kFullCircle);
2653  ge->SetMarkerSize(2);
2654  ge->Draw("lep");
2655  lg->AddEntry(ge, "4 GeV e^{-} in 2D-proj. SPACAL", "lp");
2656 
2657  TGraphErrors * ge = Load_CurveSet(
2658  base + "/spacal1d/zerofield/G4Hits_sPHENIX_e-", "4GeV");
2659  ge->SetLineColor(kBlue + 3);
2660  ge->SetMarkerColor(kBlue + 3);
2661  ge->SetLineStyle(kDashed);
2662  ge->SetLineWidth(2);
2663  ge->SetMarkerStyle(kOpenCircle);
2664  ge->SetMarkerSize(2);
2665  ge->Draw("lep");
2666  lg->AddEntry(ge, "4 GeV e^{-} in 1D-proj. SPACAL", "lp");
2667 
2668  lg->Draw();
2669 
2670  SaveCanvas(c1, base + "DrawEcal_" + TString(c1->GetName()), true);
2671 }
2672 
2673 TGraphErrors *
2675  const TString config =
2676  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma",
2677  const TString energy = "24GeV")
2678 {
2679  double etas[100] =
2680  { 0 };
2681  double SFs[100] =
2682  { 0 };
2683  double SF_Errs[100] =
2684  { 0 };
2685 
2686  int n = 0;
2687  TVectorD SF(2);
2688 
2689  etas[n] = 0 + 0.05;
2690  SF = Load_SF("eta0", config, energy);
2691  SFs[n] = SF[0];
2692  SF_Errs[n] = SF[1];
2693  n++;
2694 
2695  etas[n] = 0.3 + 0.05;
2696  SF = Load_SF("eta0.30", config, energy);
2697  SFs[n] = SF[0];
2698  SF_Errs[n] = SF[1];
2699  n++;
2700 
2701  etas[n] = 0.6 + 0.05;
2702  SF = Load_SF("eta0.60", config, energy);
2703  SFs[n] = SF[0];
2704  SF_Errs[n] = SF[1];
2705  n++;
2706 
2707  etas[n] = 0.9 + 0.05;
2708  SF = Load_SF("eta0.90", config, energy);
2709  SFs[n] = SF[0];
2710  SF_Errs[n] = SF[1];
2711  n++;
2712 
2713  TGraphErrors * ge = new TGraphErrors(n, etas, SFs, 0, SF_Errs);
2714 
2715  return ge;
2716 
2717 }
2718 
2719 TVectorD
2720 Load_SF(const TString eta_bin = "eta0",
2721  const TString config =
2722  "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal1d/zerofield/G4Hits_sPHENIX_gamma",
2723  const TString energy = "24GeV")
2724 {
2725 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal1d/zerofield/G4Hits_sPHENIX_gamma_eta0.30_24GeV.root_hist.root
2726 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal1d/zerofield/G4Hits_sPHENIX_gamma_eta0.60_24GeV.root_hist.root
2727 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal1d/zerofield/G4Hits_sPHENIX_gamma_eta0.90_24GeV.root_hist.root
2728 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal1d/zerofield/G4Hits_sPHENIX_gamma_eta0_24GeV.root_hist.root
2729 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0.30_24GeV.root_hist.root
2730 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0.60_24GeV.root_hist.root
2731 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0.90_24GeV.root_hist.root
2732 // /direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/single_particle/spacal2d/zerofield/G4Hits_sPHENIX_gamma_eta0_24GeV.root_hist.root
2733 
2734  const TString file_name = config + "_" + eta_bin + "_" + energy
2735  + ".root_EMCalAna.root";
2736  cout << "load_SF - lead " << file_name << endl;
2737 
2738  TFile *f = new TFile(file_name);
2739  assert(f);
2740  TH1F * EMCalAna_h_CEMC_SF = (TH1F *) f->GetObjectChecked("EMCalAna_h_CEMC_SF",
2741  "TH1F");
2742  assert(EMCalAna_h_CEMC_SF);
2743 
2744  const double mean = EMCalAna_h_CEMC_SF->GetMean();
2745  const double rms = EMCalAna_h_CEMC_SF->GetRMS();
2746 
2747  TF1 * f_gaus = new TF1("f_gaus" + eta_bin, "gaus", mean - 2 * rms,
2748  mean + 2 * rms);
2749  f_gaus->SetParameters(1, mean, rms);
2750 
2751  EMCalAna_h_CEMC_SF->Fit(f_gaus, "MRQS0");
2752 
2753  cout << "load_SF - result = " << f_gaus->GetParameter(1) << "+/-"
2754  << f_gaus->GetParError(1) << endl;
2755 
2756  TVectorD ret(2);
2757  ret[0] = f_gaus->GetParameter(1);
2758  ret[1] = f_gaus->GetParError(1);
2759 
2760  return ret;
2761 }