29 "../..//sPHENIX_work/production_analysis_cemc2x2/emcstudies/pidstudies/spacal2d/fieldmap/",
34 TString kine_config =
"eta0_8GeV",
int eval_mode = 1)
37 const TString
infile = base_dir +
"G4Hits_sPHENIX_" +
pid +
"_" + kine_config
38 +
"-ALL.root_Ana.root.lst_EMCalLikelihood.root";
42 gStyle->SetOptStat(0);
43 gStyle->SetOptFit(1111);
44 TVirtualFitter::SetDefaultFitter(
"Minuit2");
46 gSystem->Load(
"libg4eval.so");
47 gSystem->Load(
"libemcal_ana.so");
48 gSystem->Load(
"libg4vertex.so");
52 TString chian_str =
infile;
53 chian_str.ReplaceAll(
"ALL",
"*");
54 chian_str.ReplaceAll(
"+",
"\\+");
57 TChain *
t =
new TChain(
"T");
58 const int n = t->Add(chian_str);
60 cout <<
"Loaded " << n <<
" root files with " << chian_str << endl;
70 TObjArray *fileElements = t->GetListOfFiles();
71 TIter
next(fileElements);
72 TChainElement *chEl = 0;
73 while ((chEl = (TChainElement*)
next()))
75 flst << chEl->GetTitle() << endl;
79 cout <<
"Saved file list to " << infile +
".lst" << endl;
84 T->SetAlias(
"UpsilonPair_trk_gpt",
85 "1*sqrt(DST.UpsilonPair.trk.gpx**2 + DST.UpsilonPair.trk.gpy**2)");
86 T->SetAlias(
"UpsilonPair_trk_pt",
87 "1*sqrt(DST.UpsilonPair.trk.px**2 + DST.UpsilonPair.trk.py**2)");
89 T->SetAlias(
"EMCalTrk_pt",
"1*sqrt(DST.EMCalTrk.px**2 + DST.EMCalTrk.py**2)");
90 T->SetAlias(
"EMCalTrk_gpt",
91 "1*sqrt(DST.EMCalTrk.gpx**2 + DST.EMCalTrk.gpy**2)");
97 event_sel =
"Entry$<50000 && fabs(EMCalTrk_pt/EMCalTrk_gpt - 1)<0.05";
100 else if (eval_mode == 1)
103 event_sel =
" fabs(EMCalTrk_pt/EMCalTrk_gpt - 1)<0.05";
104 cuts =
"_eval_sample";
106 cout <<
"Build event selection of " << (
const char *) event_sel << endl;
108 T->Draw(
">>EventList", event_sel);
109 TEventList * elist = gDirectory->GetObjectChecked(
"EventList",
"TEventList");
110 cout << elist->GetN() <<
" / " <<
T->GetEntriesFast() <<
" events selected"
113 T->SetEventList(elist);
119 else if (eval_mode == 1)
136 TCanvas *c1 =
new TCanvas(
"EP_LL_Distribution" +
cuts,
137 "EP_LL_Distribution" +
cuts, 1900, 900);
142 p = (TPad *) c1->cd(idx++);
145 T->Draw(
"DST.EMCalTrk.ll_ep_e>>hll_ep_e(300,-30,30)",
"",
"");
148 "EMCal only: Electron likelihood distribution;log(Electron likelihood);A. U."));
150 p = (TPad *) c1->cd(idx++);
153 T->Draw(
"DST.EMCalTrk.ll_ep_h>>hll_ep_h(300,-30,30)",
"",
"");
156 "EMCal only: Hadron likelihood distribution;log(Hadron likelihood);A. U."));
158 p = (TPad *) c1->cd(idx++);
162 "DST.EMCalTrk.ll_ep_e - DST.EMCalTrk.ll_ep_h>>hll_ep_diff(300,-30,30)",
164 TH1F *hll_ep_diff = (TH1F *) gDirectory->GetObjectChecked(
"hll_ep_diff",
167 hll_ep_diff->SetTitle(
169 "EMCal only: log likelihood cut;log(Electron likelihood) - log(Hadron likelihood);Count / bin"));
172 p = (TPad *) c1->cd(idx++);
176 p->DrawFrame(-30, 1
e-4, 30, 1,
177 "EMCal only: Cut Efficiency;Cut on log(Electron likelihood) - log(Hadron likelihood);Cut Efficiency");
179 ge->SetLineColor(kBlue + 2);
180 ge->SetMarkerColor(kBlue + 21);
181 ge->SetMarkerColor(kFullCircle);
186 TString(
_file0->GetName()) + TString(
"_DrawEcal_Likelihood_")
187 + TString(c1->GetName()), kFALSE);
195 TCanvas *c1 =
new TCanvas(
"Edep_LL_Distribution" +
cuts,
196 "Edep_LL_Distribution" +
cuts, 1900, 900);
201 p = (TPad *) c1->cd(idx++);
204 T->Draw(
"DST.EMCalTrk.ll_edep_e>>hll_edep_e(300,-30,30)",
"",
"");
205 hll_edep_e->SetTitle(
207 "EMCal + HCal_{in}: Electron likelihood distribution;log(Electron likelihood);A. U."));
209 p = (TPad *) c1->cd(idx++);
212 T->Draw(
"DST.EMCalTrk.ll_edep_h>>hll_edep_h(300,-30,30)",
"",
"");
213 hll_edep_h->SetTitle(
215 "EMCal + HCal_{in}: Hadron likelihood distribution;log(Hadron likelihood);A. U."));
217 p = (TPad *) c1->cd(idx++);
221 "DST.EMCalTrk.ll_edep_e - DST.EMCalTrk.ll_edep_h>>hll_edep_diff(300,-30,30)",
223 TH1F *hll_edep_diff = (TH1F *) gDirectory->GetObjectChecked(
"hll_edep_diff",
226 hll_edep_diff->SetTitle(
228 "EMCal + HCal_{in}: log likelihood cut;log(Electron likelihood) - log(Hadron likelihood);Count / bin"));
231 p = (TPad *) c1->cd(idx++);
235 p->DrawFrame(-30, 1
e-4, 30, 1,
236 "EMCal + HCal_{in}: Cut Efficiency;log(Electron likelihood) - log(Hadron likelihood);Cut Efficiency");
238 ge->SetLineColor(kBlue + 2);
239 ge->SetMarkerColor(kBlue + 21);
240 ge->SetMarkerColor(kFullCircle);
245 TString(
_file0->GetName()) + TString(
"_DrawEcal_Likelihood_")
246 + TString(c1->GetName()), kFALSE);
254 double N_Event =
T->GetEntries();
256 TCanvas *c1 =
new TCanvas(
"Edep_Distribution" +
cuts,
257 "Edep_Distribution" +
cuts, 1900, 900);
262 p = (TPad *) c1->cd(idx++);
266 "DST.EMCalTrk.hcalin_sum_energy:DST.EMCalTrk.get_ep()>>h2_Edep_Distribution_raw(240,-.0,2, 240,-.0,12)",
268 h2_Edep_Distribution_raw->SetTitle(
270 "Energy distribution;CEMC Cluster Energy in GeV;HCal_{in} Cluster Energy in GeV"));
271 h2_Edep_Distribution_raw->Scale(1. / N_Event);
274 p = (TPad *) c1->cd(idx++);
278 TH2F * h2_Edep_Distribution = (TH2F *) h2_Edep_Distribution_raw->Clone(
279 "h2_Edep_Distribution");
281 h2_Edep_Distribution->Smooth(1,
"k5b");
282 h2_Edep_Distribution->Scale(1. / h2_Edep_Distribution->GetSum());
283 h2_Edep_Distribution->Draw(
"colz");
286 TString(
_file0->GetName()) + TString(
"_DrawEcal_Likelihood_")
287 + TString(c1->GetName()), kFALSE);
295 double N_Event =
T->GetEntries();
297 TCanvas *c1 =
new TCanvas(
"ShowerShape_Checks" +
cuts,
298 "ShowerShape_Checks" +
cuts, 1900, 900);
303 p = (TPad *) c1->cd(idx++);
308 "DST.EMCalTrk.cemc_energy/DST.EMCalTrk.cemc_sum_energy:DST.EMCalTrk.cemc_radius>>hEMCalTrk_cemc_shape(30,0,2,100,0,1)",
309 good_track_cut,
"goff");
311 TH2 * hEMCalTrk_cemc_shape = (TH2 *) gDirectory->GetObjectChecked(
312 "hEMCalTrk_cemc_shape",
"TH2");
313 hEMCalTrk_cemc_shape->SetTitle(
315 "CEMC Shower Shape;Distance to track projection (Cluster width);Tower Energy/Cluster Energy"));
318 TH1D * hEMCalTrk_cemc_shape_px = hEMCalTrk_cemc_shape->ProjectionX(
319 "hEMCalTrk_cemc_shape_px");
321 for (
int r = 1;
r <= hEMCalTrk_cemc_shape->GetNbinsX();
r++)
322 for (
int e = 1;
e <= hEMCalTrk_cemc_shape->GetNbinsY();
e++)
324 hEMCalTrk_cemc_shape->SetBinContent(
r,
e,
325 hEMCalTrk_cemc_shape->GetBinContent(
r,
e)
326 / hEMCalTrk_cemc_shape_px->GetBinContent(
r));
329 hEMCalTrk_cemc_shape->Draw(
"colz");
332 p = (TPad *) c1->cd(idx++);
337 "DST.EMCalTrk.hcalin_energy/DST.EMCalTrk.hcalin_sum_energy:DST.EMCalTrk.hcalin_radius>>hEMCalTrk_hcalin_shape(30,0,2,100,0,1)",
338 good_track_cut,
"colz");
339 TH2 * hEMCalTrk_hcalin_shape = (TH2 *) gDirectory->GetObjectChecked(
340 "hEMCalTrk_hcalin_shape",
"TH2");
342 hEMCalTrk_hcalin_shape->SetTitle(
344 "HCal_{in} Shower Shape;Distance to track projection (Cluster width);Tower Energy/Cluster Energy"));
347 TH1D * hEMCalTrk_hcalin_shape_px = hEMCalTrk_hcalin_shape->ProjectionX(
348 "hEMCalTrk_hcalin_shape_px");
350 for (
int r = 1;
r <= hEMCalTrk_hcalin_shape->GetNbinsX();
r++)
351 for (
int e = 1;
e <= hEMCalTrk_hcalin_shape->GetNbinsY();
e++)
353 hEMCalTrk_hcalin_shape->SetBinContent(
r,
e,
354 hEMCalTrk_hcalin_shape->GetBinContent(
r,
e)
355 / hEMCalTrk_hcalin_shape_px->GetBinContent(
r));
358 hEMCalTrk_hcalin_shape->Draw(
"colz");
361 TString(
_file0->GetName()) + TString(
"_DrawEcal_Likelihood_")
362 + TString(c1->GetName()), kFALSE);
370 double N_Event =
T->GetEntries();
372 TCanvas *c1 =
new TCanvas(
"Edep_Checks" +
cuts,
"Edep_Checks" +
cuts, 1900,
378 p = (TPad *) c1->cd(idx++);
381 T->Draw(
"DST.EMCalTrk.cemc_sum_n_tower>>hEMCalTrk_cemc_ntower(16,-.5,15.5)",
383 hEMCalTrk_cemc_ntower->SetTitle(
384 Form(
"CEMC Cluster Size;Cluster Size (Towers);Probability"));
385 hEMCalTrk_cemc_ntower->Scale(1. / N_Event);
387 p = (TPad *) c1->cd(idx++);
390 T->Draw(
"DST.EMCalTrk.cemc_sum_energy>>hEMCalTrk_cemc_e(240,-.0,12)",
392 hEMCalTrk_cemc_e->SetTitle(
393 Form(
"CEMC Cluster Energy;Cluster Energy (GeV);Count/bin"));
396 p = (TPad *) c1->cd(idx++);
399 p->DrawFrame(-.0, 1
e-3, 12, 1,
400 "CEMC Cut Eff;Cut on Cluster Energy (GeV);Efficiency");
403 ge->SetLineColor(kBlue + 2);
404 ge->SetMarkerColor(kBlue + 21);
405 ge->SetMarkerColor(kFullCircle);
409 p = (TPad *) c1->cd(idx++);
413 "DST.EMCalTrk.hcalin_sum_n_tower>>hEMCalTrk_hcalin_ntower(16,-.5,15.5)",
415 hEMCalTrk_hcalin_ntower->SetTitle(
416 Form(
"HCal_{in} Cluster Size;Cluster Size (Towers);Probability"));
417 hEMCalTrk_hcalin_ntower->Scale(1. / N_Event);
419 p = (TPad *) c1->cd(idx++);
422 T->Draw(
"DST.EMCalTrk.hcalin_sum_energy>>hEMCalTrk_hcalin_e(240,-.0,12)",
424 hEMCalTrk_hcalin_e->SetTitle(
425 Form(
"HCal_{in} Cluster Energy;Cluster Energy (GeV);Count/bin"));
428 p = (TPad *) c1->cd(idx++);
431 p->DrawFrame(-.0, 1
e-3, 12, 1,
432 "HCal_{in} Cut Eff;Cut on Cluster Energy (GeV);Efficiency");
435 ge->SetLineColor(kBlue + 2);
436 ge->SetMarkerColor(kBlue + 21);
437 ge->SetMarkerColor(kFullCircle);
442 TString(
_file0->GetName()) + TString(
"_DrawEcal_pDST_")
443 + TString(c1->GetName()), kFALSE);
445 TCanvas *c1 =
new TCanvas(
"Edep_Checks_2D" +
cuts,
"Edep_Checks_2D" +
cuts,
451 p = (TPad *) c1->cd(idx++);
455 "DST.EMCalTrk.hcalin_sum_energy:DST.EMCalTrk.cemc_sum_energy>>h2_EMCalTrk_hcalin_e_EMCalTrk_cemc_e(240,-.0,8, 240,-.0,8)",
456 good_track_cut,
"colz");
457 h2_EMCalTrk_hcalin_e_EMCalTrk_cemc_e->SetTitle(
459 "Energy distribution;CEMC Cluster Energy in GeV;HCal_{in} Cluster Energy in GeV"));
460 h2_EMCalTrk_hcalin_e_EMCalTrk_cemc_e->Scale(1. / N_Event);
461 h2_EMCalTrk_hcalin_e_EMCalTrk_cemc_e->GetZaxis()->SetRangeUser(1. / N_Event,
465 TString(
_file0->GetName()) + TString(
"_DrawEcal_Likelihood_")
466 + TString(c1->GetName()), kFALSE);
474 double N_Event =
T->GetEntries();
476 TCanvas *c1 =
new TCanvas(
"Ep_Checks" +
cuts,
"Ep_Checks" +
cuts, 1900, 950);
481 p = (TPad *) c1->cd(idx++);
484 T->Draw(
"DST.EMCalTrk.get_ep()>>hEMCalTrk_get_ep(240,-.0,2)",
486 hEMCalTrk_get_ep->SetTitle(
487 Form(
"CEMC Cluster Energy/Track Momentum;E/p;Count/bin"));
490 p = (TPad *) c1->cd(idx++);
493 if (infile.Contains(
"e-") || infile.Contains(
"e+"))
495 p->DrawFrame(-.0, 0.8, 1.5, 1,
496 "CEMC E/p Cut Eff;Cut on E/p;Signal Efficiency");
500 p->DrawFrame(-.0, 1
e-3, 1.5, 1,
501 "CEMC E/p Cut Eff;Cut on E/p;Background Efficiency or 1/Rejection");
505 ge->SetLineColor(kBlue + 2);
506 ge->SetMarkerColor(kBlue + 21);
507 ge->SetMarkerColor(kFullCircle);
512 TString(
_file0->GetName()) + TString(
"_DrawEcal_Likelihood_")
513 + TString(c1->GetName()), kFALSE);
520 double threshold[10000] =
524 double eff_err[10000] =
527 assert(hCEMC3_Max->GetNbinsX()<10000);
529 const double n = hCEMC3_Max->GetSum();
532 for (
int i = hCEMC3_Max->GetNbinsX();
i >= 1;
i--)
534 pass += hCEMC3_Max->GetBinContent(
i);
536 const double pp = pass /
n;
540 const double A = z * sqrt(1. / n * pp * (1 - pp) + z * z / 4 / n / n);
541 const double B = 1 / (1 + z * z /
n);
543 threshold[cnt] = hCEMC3_Max->GetBinCenter(
i);
544 eff[cnt] = (pp + z * z / 2 /
n) * B;
545 eff_err[cnt] = A * B;
551 TGraphErrors * ge =
new TGraphErrors(cnt, threshold, eff, NULL, eff_err);