42 gStyle->SetOptStat(0);
43 gStyle->SetOptFit(1111);
44 TVirtualFitter::SetDefaultFitter(
"Minuit2");
45 gSystem->Load(
"libg4eval.so");
49 TString chian_str =
infile;
50 chian_str.ReplaceAll(
"ALL",
"*");
52 TChain *
t =
new TChain(
"T");
53 const int n = t->Add(chian_str);
55 cout <<
"Loaded " << n <<
" root files with " << chian_str << endl;
66 T->SetAlias(
"CEMC_Sample",
67 "Sum$(G4HIT_CEMC.light_yield)/(Sum$(G4HIT_CEMC.edep) + Sum$(G4HIT_ABSORBER_CEMC.edep))");
68 T->SetAlias(
"HCALIN_Sample",
69 "Sum$(G4HIT_HCALIN.light_yield)/(Sum$(G4HIT_HCALIN.edep) + Sum$(G4HIT_ABSORBER_HCALIN.edep))");
70 T->SetAlias(
"HCALOUT_Sample",
71 "Sum$(G4HIT_HCALOUT.light_yield)/(Sum$(G4HIT_HCALOUT.edep) + Sum$(G4HIT_ABSORBER_HCALOUT.edep))");
72 T->SetAlias(
"FHCAL_Sample",
73 "Sum$(G4HIT_FHCAL.light_yield)/(Sum$(G4HIT_FHCAL.edep) + Sum$(G4HIT_ABSORBER_FHCAL.edep))");
75 T->SetAlias(
"PHG4Particle0_e",
"0+(PHG4Particle[0].fe)");
76 T->SetAlias(
"PHG4Particle0_p",
77 "1*sqrt(PHG4Particle[0].fpx**2+PHG4Particle[0].fpy**2+PHG4Particle[0].fpz**2)");
78 T->SetAlias(
"PHG4Particle0_eta",
79 "0.5*log((PHG4Particle0_p+PHG4Particle[0].fpz)/(PHG4Particle0_p-PHG4Particle[0].fpz))");
81 T->SetAlias(
"PHG4Particle_p",
82 "1*sqrt(PHG4Particle.fpx**2+PHG4Particle.fpy**2+PHG4Particle.fpz**2)");
83 T->SetAlias(
"PHG4Particle_eta",
84 "0.5*log((PHG4Particle_p+PHG4Particle.fpz)/(PHG4Particle_p-PHG4Particle.fpz))");
86 T->SetAlias(
"Entrace_CEMC_x",
"G4HIT_ABSORBER_CEMC[0].get_avg_x()+0");
87 T->SetAlias(
"Entrace_CEMC_y",
"G4HIT_ABSORBER_CEMC[0].get_avg_y()+0");
88 T->SetAlias(
"Entrace_CEMC_z",
"G4HIT_ABSORBER_CEMC[0].get_avg_z()+0");
89 T->SetAlias(
"Entrace_CEMC_azimuthal",
90 "atan2(Entrace_CEMC_y, Entrace_CEMC_x)*95.");
91 T->SetAlias(
"Average_CEMC_z",
92 "Sum$(G4HIT_ABSORBER_CEMC.get_avg_z()*G4HIT_ABSORBER_CEMC.edep)/Sum$(G4HIT_ABSORBER_CEMC.edep)");
93 T->SetAlias(
"Average_BH_1_z",
94 "Sum$(G4HIT_BH_1.get_avg_z())/Sum$(G4HIT_BH_1.hit_id>-1)");
96 T->SetAlias(
"CEMC_E",
"Sum$(G4HIT_CEMC.light_yield)+0");
97 T->SetAlias(
"TOWER_CEMC_E",
98 "Sum$(TOWER_CEMC.light_yield * (TOWER_CEMC.light_yield>32))");
99 T->SetAlias(
"ABSORBER_CEMC_E",
"Sum$(G4HIT_ABSORBER_CEMC.edep)+0");
100 T->SetAlias(
"Total_CEMC_E",
101 "Sum$(G4HIT_ABSORBER_CEMC.edep)+Sum$(G4HIT_CEMC.edep)");
102 T->SetAlias(
"HCALIN_E",
"Sum$(G4HIT_HCALIN.light_yield)+0");
103 T->SetAlias(
"HCALOUT_E",
"Sum$(G4HIT_HCALOUT.light_yield)+0");
104 T->SetAlias(
"Total_HCALIN_E",
105 "Sum$(G4HIT_ABSORBER_HCALIN.edep)+Sum$(G4HIT_HCALIN.edep)");
106 T->SetAlias(
"Total_HCALOUT_E",
107 "Sum$(G4HIT_ABSORBER_HCALOUT.edep)+Sum$(G4HIT_HCALOUT.edep)");
108 T->SetAlias(
"BH_1_E",
"Sum$(G4HIT_BH_1.edep)+0");
109 T->SetAlias(
"EMCScale",
"1*1");
111 T->SetAlias(
"PHG4Particle0_pT",
112 "1*sqrt(PHG4Particle[0].fpx**2+PHG4Particle[0].fpy**2)");
113 T->SetAlias(
"PHG4Particle0_theta",
114 "1*atan2(PHG4Particle0_pT,PHG4Particle[0].fpz)");
115 T->SetAlias(
"PHG4Particle0_phi",
116 "1*atan2(PHG4Particle[0].fpy, PHG4Particle[0].fpx)");
118 T->SetAlias(
"PHG4Particle0_xhx",
119 "cos(PHG4Particle0_theta)*cos(PHG4Particle0_phi)");
120 T->SetAlias(
"PHG4Particle0_xhy",
121 "cos(PHG4Particle0_theta)*sin(PHG4Particle0_phi)");
122 T->SetAlias(
"PHG4Particle0_xhz",
"-sin(PHG4Particle0_theta)*1");
123 T->SetAlias(
"PHG4Particle0_yhx",
"1*cos(PHG4Particle0_phi + pi/2)");
124 T->SetAlias(
"PHG4Particle0_yhy",
"1*sin(PHG4Particle0_phi + pi/2)");
125 T->SetAlias(
"PHG4Particle0_yhz",
"0*1");
126 T->SetAlias(
"PHG4Particle0_zhz",
"cos(PHG4Particle0_theta)*1");
127 T->SetAlias(
"PHG4Particle0_zhy",
128 "sin(PHG4Particle0_theta)*cos(PHG4Particle0_phi)");
129 T->SetAlias(
"PHG4Particle0_zhz",
130 "sin(PHG4Particle0_theta)*sin(PHG4Particle0_phi)");
132 T->SetAlias(
"Field",
"0*0");
133 TString field_cor =
"";
136 T->SetAlias(
"CEMC_yp_cor",
137 "(-19.984 + 5.64862 * PHG4Particle0_pT -0.531359* PHG4Particle0_pT * PHG4Particle0_pT) * (-Field) ");
138 T->SetAlias(
"ABSORBER_CEMC_yp_cor",
"CEMC_yp_cor + 0");
139 T->SetAlias(
"HCALIN_yp_cor",
140 "(-25.6969 + 6.24025 * PHG4Particle0_pT -0.472037 * PHG4Particle0_pT * PHG4Particle0_pT) * (-Field) ");
141 T->SetAlias(
"HCALOUT_yp_cor",
142 "(-40.6969 + 6.24025 * PHG4Particle0_pT -0.472037 * PHG4Particle0_pT * PHG4Particle0_pT) * (-Field) ");
144 T->SetAlias(
"CEMC_xp",
145 "G4HIT_CEMC.get_avg_x() * PHG4Particle0_xhx + G4HIT_CEMC.get_avg_y() * PHG4Particle0_xhy + G4HIT_CEMC.get_avg_z() * PHG4Particle0_xhz");
146 T->SetAlias(
"CEMC_yp",
147 "CEMC_yp_cor + G4HIT_CEMC.get_avg_x() * PHG4Particle0_yhx + G4HIT_CEMC.get_avg_y() * PHG4Particle0_yhy + G4HIT_CEMC.get_avg_z() * PHG4Particle0_yhz");
148 T->SetAlias(
"CEMC_zp",
149 "G4HIT_CEMC.get_avg_x() * PHG4Particle0_zhx + G4HIT_CEMC.get_avg_y() * PHG4Particle0_zhy + G4HIT_CEMC.get_avg_z() * PHG4Particle0_zhz");
150 T->SetAlias(
"CEMC_R",
"sqrt(CEMC_xp**2 + CEMC_yp**2)");
152 T->SetAlias(
"ABSORBER_CEMC_xp",
153 "G4HIT_ABSORBER_CEMC.get_avg_x() * PHG4Particle0_xhx + G4HIT_ABSORBER_CEMC.get_avg_y() * PHG4Particle0_xhy + G4HIT_ABSORBER_CEMC.get_avg_z() * PHG4Particle0_xhz");
154 T->SetAlias(
"ABSORBER_CEMC_yp",
155 "ABSORBER_CEMC_yp_cor + G4HIT_ABSORBER_CEMC.get_avg_x() * PHG4Particle0_yhx + G4HIT_ABSORBER_CEMC.get_avg_y() * PHG4Particle0_yhy + G4HIT_ABSORBER_CEMC.get_avg_z() * PHG4Particle0_yhz");
156 T->SetAlias(
"ABSORBER_CEMC_zp",
157 "G4HIT_ABSORBER_CEMC.get_avg_x() * PHG4Particle0_zhx + G4HIT_ABSORBER_CEMC.get_avg_y() * PHG4Particle0_zhy + G4HIT_ABSORBER_CEMC.get_avg_z() * PHG4Particle0_zhz");
158 T->SetAlias(
"ABSORBER_CEMC_R",
159 "sqrt(ABSORBER_CEMC_xp**2 + ABSORBER_CEMC_yp**2)");
161 T->SetAlias(
"HCALIN_xp",
162 "G4HIT_HCALIN.get_avg_x() * PHG4Particle0_xhx + G4HIT_HCALIN.get_avg_y() * PHG4Particle0_xhy + G4HIT_HCALIN.get_avg_z() * PHG4Particle0_xhz");
163 T->SetAlias(
"HCALIN_yp",
164 "HCALIN_yp_cor + G4HIT_HCALIN.get_avg_x() * PHG4Particle0_yhx + G4HIT_HCALIN.get_avg_y() * PHG4Particle0_yhy + G4HIT_HCALIN.get_avg_z() * PHG4Particle0_yhz");
165 T->SetAlias(
"HCALIN_zp",
166 "G4HIT_HCALIN.get_avg_x() * PHG4Particle0_zhx + G4HIT_HCALIN.get_avg_y() * PHG4Particle0_zhy + G4HIT_HCALIN.get_avg_z() * PHG4Particle0_zhz");
167 T->SetAlias(
"HCALIN_R",
"sqrt(HCALIN_xp**2 + HCALIN_yp**2)");
169 T->SetAlias(
"HCALOUT_xp",
170 "G4HIT_HCALOUT.get_avg_x() * PHG4Particle0_xhx + G4HIT_HCALOUT.get_avg_y() * PHG4Particle0_xhy + G4HIT_HCALOUT.get_avg_z() * PHG4Particle0_xhz");
171 T->SetAlias(
"HCALOUT_yp",
172 "HCALOUT_yp_cor + G4HIT_HCALOUT.get_avg_x() * PHG4Particle0_yhx + G4HIT_HCALOUT.get_avg_y() * PHG4Particle0_yhy + G4HIT_HCALOUT.get_avg_z() * PHG4Particle0_yhz");
173 T->SetAlias(
"HCALOUT_zp",
174 "G4HIT_HCALOUT.get_avg_x() * PHG4Particle0_zhx + G4HIT_HCALOUT.get_avg_y() * PHG4Particle0_zhy + G4HIT_HCALOUT.get_avg_z() * PHG4Particle0_zhz");
175 T->SetAlias(
"HCALOUT_R",
"sqrt(HCALOUT_xp**2 + HCALOUT_yp**2)");
177 T->SetAlias(
"TOWER_CEMC_eta_mean",
178 "Sum$(TOWER_CEMC.bineta*TOWER_CEMC.get_energy())/Sum$(TOWER_CEMC.get_energy())");
179 T->SetAlias(
"G4HIT_CEMC_eta_mean",
180 "Sum$(-log(tan(0.5*atan2(sqrt(G4HIT_CEMC.get_avg_x()*G4HIT_CEMC.get_avg_x() + G4HIT_CEMC.get_avg_y()*G4HIT_CEMC.get_avg_y()) , G4HIT_CEMC.get_avg_z()))) * G4HIT_CEMC.edep)/Sum$(G4HIT_CEMC.edep)");
182 T->SetAlias(
"TOWER_CEMC_phi_mean",
183 "Sum$(TOWER_CEMC.binphi*TOWER_CEMC.get_energy())/Sum$(TOWER_CEMC.get_energy())");
184 T->SetAlias(
"G4HIT_CEMC_phi_mean",
185 "Sum$(atan2(G4HIT_CEMC.get_avg_y(),G4HIT_CEMC.get_avg_x()) * G4HIT_CEMC.edep)/Sum$(G4HIT_CEMC.edep)");
190 cout <<
"Build event selection of " << (
const char *) event_sel << endl;
192 T->Draw(
">>EventList", event_sel);
193 TEventList * elist = gDirectory->GetObjectChecked(
"EventList",
"TEventList");
194 cout << elist->GetN() <<
" / " <<
T->GetEntriesFast() <<
" events selected"
197 T->SetEventList(elist);
224 TCanvas *c1 =
new TCanvas(
"DrawCalibratedE" +
cuts,
"DrawCalibratedE" +
cuts,
230 p = (TPad *) c1->cd(idx++);
232 T->Draw(
"CEMC_E>>hCEMC_E(1000,0,.5)");
234 p = (TPad *) c1->cd(idx++);
236 T->Draw(Form(
"CEMC_E/%f>>hCEMC_E_SF(1000,0,15)", SF));
239 TString(
_infile->GetName()) + TString(
"_DrawJet_")
240 + TString(c1->GetName()), kFALSE);
247 TCanvas *c1 =
new TCanvas(
"DrawCalibratedE" +
cuts,
"DrawCalibratedE" +
cuts,
253 p = (TPad *) c1->cd(idx++);
255 T->Draw(
"TOWER_CEMC_E>>hCEMC_E(1000,0,8000)");
257 p = (TPad *) c1->cd(idx++);
259 T->Draw(Form(
"TOWER_CEMC_E/%f>>hCEMC_E_SF(1000,0,15)", SF));
262 TString(
_infile->GetName()) + TString(
"_DrawJet_")
263 + TString(c1->GetName()), kFALSE);
270 gStyle->SetOptStat(0);
271 gStyle->SetOptFit(0);
272 TVirtualFitter::SetDefaultFitter(
"Minuit2");
273 gSystem->Load(
"libg4eval.so");
275 TCanvas *c1 =
new TCanvas(
"DrawTower_Raw_E" +
cuts,
"DrawTower_Raw_E" +
cuts,
281 p = (TPad *) c1->cd(idx++);
287 T->Draw(
"TOWER_RAW_CEMC.energy>>he(100,0,25000)");
289 he->SetTitle(
";Photo-electron count per tower; A. U.");
291 he->SetLineColor(kBlue + 1);
294 TString(
_infile->GetName()) +
"_Draw_PHG4DSTReader_"
295 + TString(c1->GetName()),
true);
300 const TString base_name =
301 "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/SPACAL_TestBeam_Data")
304 gStyle->SetOptStat(0);
305 gStyle->SetOptFit(0);
306 TVirtualFitter::SetDefaultFitter(
"Minuit2");
307 gSystem->Load(
"libg4eval.so");
309 const TString
config =
"nocut";
312 const double beam_res = 2.7e-2;
314 const double beam_E[8] =
315 { 0.995, 2.026, 3.0, 4.12, 6.0, 8.0, 10.0, 12.0 };
318 double res_sub[100] =
320 double res_err[100] =
323 TCanvas *c1 =
new TCanvas(config, config);
324 c1->Print(base_name +
"/input_" + config +
".pdf[");
326 for (
int i = 0;
i <
N;
i++)
328 TFile *
f =
new TFile(
329 base_name + Form(
"/%.0fGeV_", beam_E[
i]) + config +
".root");
332 TH1D * ECalSumElectron = (TH1D *) f->GetObjectChecked(
"ECalSumElectron",
334 TH1D * ECalSumNonElectron = (TH1D *) f->GetObjectChecked(
335 "ECalSumNonElectron",
"TH1D");
337 assert(ECalSumNonElectron);
341 ECalSumElectron->GetListOfFunctions()->At(0);
344 ECalSumElectron->Draw();
345 c1->Print(base_name +
"/input_" + config +
".pdf");
347 res[
i] = fgaus->GetParameter(2)/fgaus->GetParameter(1);
348 res_sub[
i] = sqrt(res[i]*res[i] - beam_res*beam_res);
349 res_err[
i] = fgaus->GetParError(1)/fgaus->GetParameter(1);
351 c1->Print(base_name +
"/input_" + config +
".pdf]");
353 TGraphErrors * gamma_eta0 =
new TGraphErrors(N, beam_E, res_sub, 0, res_err);
355 TGraphErrors * gamma_eta9 =
new TGraphErrors(N, beam_E, res, 0, res_err);
358 TCanvas *c1 =
new TCanvas(
"DrawCalibratedE_PlotTestBeam",
"DrawCalibratedE_PlotTestBeam",
364 p = (TPad *) c1->cd(idx++);
371 p->DrawFrame(0, 0, 14, 20
e-2,
372 ";Beam Energy (GeV);Relative energy resolution, #DeltaE/E");
374 TLegend * lg =
new TLegend(2.*14./35., 9.6
e-2, 17.*14./35., 19.6
e-2, NULL,
"br");
375 TLegend * lg2 =
new TLegend(4, 9
e-2, 33.*14./35., 19
e-2, NULL,
"br");
377 TF1 * f_calo =
new TF1(
"f_calo_gamma_eta0",
"sqrt([0]*[0]+[1]*[1]/x)/100",
379 TF1 * f_calo_l =
new TF1(
"f_calo_l_gamma_eta0",
"([0]+[1]/sqrt(x))/100", 0.5,
381 gamma_eta0->Fit(f_calo,
"RM0");
383 gamma_eta0->Fit(f_calo_l,
"RM0");
386 TF1 * f_caloR =
new TF1(
"f_calo_gamma_eta0R",
"sqrt([0]*[0]+[1]*[1]/x)/100",
388 TF1 * f_calo_lR =
new TF1(
"f_calo_l_gamma_eta0R",
"([0]+[1]/sqrt(x))/100", 1.5,
390 gamma_eta0->Fit(f_caloR,
"RM0");
392 gamma_eta0->Fit(f_calo_lR,
"RM0");
396 gamma_eta0->SetLineColor(kBlack);
397 gamma_eta0->SetMarkerColor(kBlack);
398 gamma_eta0->SetLineWidth(2);
399 gamma_eta0->SetMarkerStyle(kFullSquare);
400 gamma_eta0->SetMarkerSize(2);
402 gamma_eta9->SetLineColor(kBlack);
403 gamma_eta9->SetMarkerColor(kBlack);
404 gamma_eta9->SetLineWidth(2);
405 gamma_eta9->SetMarkerStyle(kOpenSquare);
406 gamma_eta9->SetMarkerSize(2);
408 f_calo->SetLineColor(kRed + 1);
409 f_calo->SetLineWidth(2);
410 f_calo_l->SetLineColor(kRed + 1);
411 f_calo_l->SetLineWidth(2);
412 f_calo_l->SetLineStyle(kDashed);
414 f_caloR->SetLineColor(kBlue + 3);
415 f_caloR->SetLineWidth(2);
416 f_calo_lR->SetLineColor(kBlue + 3);
417 f_calo_lR->SetLineWidth(2);
418 f_calo_lR->SetLineStyle(kDashed);
420 f_calo->Draw(
"same");
421 f_calo_l->Draw(
"same");
422 f_caloR->Draw(
"same");
423 f_calo_lR->Draw(
"same");
424 gamma_eta0->Draw(
"p");
425 gamma_eta9->Draw(
"p");
427 lg2->AddEntry(gamma_eta9,
428 Form(
"Electrons Data, #eta = 0.3-0.4", abs(f_calo->GetParameter(0)),
429 f_calo->GetParameter(1)),
"p");
430 lg2->AddEntry(gamma_eta0,
431 Form(
"Electrons Data - 2.7%% Beam #DeltaE", f_calo->GetParameter(0),
432 f_calo->GetParameter(1)),
"p");
433 lg2->AddEntry(f_calo,
434 Form(
"#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}",abs( f_calo->GetParameter(0)),
435 f_calo->GetParameter(1)),
"l");
436 TLegendEntry *
entry = lg2->AddEntry(f_calo_l,
437 Form(
"#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}", abs(f_calo_l->GetParameter(0)),
438 f_calo_l->GetParameter(1)),
"l");
439 entry->SetTextColor(kGray + 1);
440 lg2->AddEntry(f_caloR,
441 Form(
"#DeltaE/E = %.1f%% #oplus %.1f%%/#sqrt{E}, E #geq 2 GeV", abs(f_caloR->GetParameter(0)),
442 f_caloR->GetParameter(1)),
"l");
443 TLegendEntry * entry = lg2->AddEntry(f_calo_lR,
444 Form(
"#DeltaE/E = %.1f%% + %.1f%%/#sqrt{E}, E #geq 2 GeV",abs( f_calo_lR->GetParameter(0)),
445 f_calo_lR->GetParameter(1)),
"l");
446 entry->SetTextColor(kGray + 1);
451 SaveCanvas(c1, base_name +
"/" + TString(c1->GetName()),
true);
465 gStyle->SetOptStat(0);
466 gStyle->SetOptFit(0);
467 TVirtualFitter::SetDefaultFitter(
"Minuit2");
468 gSystem->Load(
"libg4eval.so");
487 "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/SPACAL_TestBeam_"
489 +
"//Sum_eneg.lst_Process.root_DSTReader.root_DrawJet_DrawCalibratedE_all_event.root");
491 TH1F * h_eneg = (TH1F *) f->GetObjectChecked(
"hCEMC_E_SF",
"TH1F");
495 "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/SPACAL_TestBeam_"
497 +
"//Sum_pineg.lst_Process.root_DSTReader.root_DrawJet_DrawCalibratedE_all_event.root");
499 TH1F * h_pineg = (TH1F *) f->GetObjectChecked(
"hCEMC_E_SF",
"TH1F");
503 "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/SPACAL_TestBeam_"
505 +
"//Sum_kaonneg.lst_Process.root_DSTReader.root_DrawJet_DrawCalibratedE_all_event.root");
507 TH1F * h_kaonneg = (TH1F *) f->GetObjectChecked(
"hCEMC_E_SF",
"TH1F");
511 "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/SPACAL_TestBeam_"
513 +
"//Sum_muonneg.lst_Process.root_DSTReader.root_DrawJet_DrawCalibratedE_all_event.root");
515 TH1F * h_muonneg = (TH1F *) f->GetObjectChecked(
"hCEMC_E_SF",
"TH1F");
518 TH1F * h_eneg_scale_hadron_data_tail = (TH1F *) h_eneg->Clone(
519 "h_eneg_scale_hadron_data_tail");
523 "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/SPACAL_TestBeam_8GeV/beam_data/"
527 TH1D * ECalSumElectron = (TH1D *) f->GetObjectChecked(
"ECalSumElectron",
529 TH1D * ECalSumNonElectron = (TH1D *) f->GetObjectChecked(
"ECalSumNonElectron",
532 assert(ECalSumNonElectron);
533 ECalSumElectron->SetStats(
false);
534 ECalSumNonElectron->SetStats(
false);
535 ECalSumElectron->GetListOfFunctions()->RemoveAt(0);
537 const double sim_E = 7.86131e+00;
538 const double data_E = 1.09505e+03;
540 ECalSumElectron->GetXaxis()->Set(ECalSumElectron->GetXaxis()->GetNbins(),
541 ECalSumElectron->GetXaxis()->GetXmin() * sim_E / data_E,
542 ECalSumElectron->GetXaxis()->GetXmax() * sim_E / data_E
544 ECalSumNonElectron->GetXaxis()->Set(
545 ECalSumNonElectron->GetXaxis()->GetNbins(),
546 ECalSumNonElectron->GetXaxis()->GetXmin() * sim_E / data_E,
547 ECalSumNonElectron->GetXaxis()->GetXmax() * sim_E / data_E
550 const double energy = h_eneg->GetMean();
552 double eneg_scale = ECalSumElectron->Integral(
553 ECalSumElectron->GetXaxis()->FindBin(energy * .7),
554 ECalSumElectron->GetXaxis()->FindBin(energy * 1.3))
555 / h_eneg->Integral(h_eneg->GetXaxis()->FindBin(energy * .7),
556 h_eneg->GetXaxis()->FindBin(energy * 1.3));
558 const double hadron_norm_max_range = 0.7;
560 double muonneg_scale = 0.1 *
561 ECalSumNonElectron->Integral(ECalSumNonElectron->GetXaxis()->FindBin(.01),
562 ECalSumNonElectron->GetXaxis()->FindBin(energy * 1.3))
563 / h_muonneg->Integral(h_muonneg->GetXaxis()->FindBin(.01),
564 h_muonneg->GetXaxis()->FindBin(energy * 1.3));
566 const double muon_ratio_in_MIP = h_muonneg->Integral(
567 h_muonneg->GetXaxis()->FindBin(.01),
568 h_muonneg->GetXaxis()->FindBin(hadron_norm_max_range))
569 / h_muonneg->Integral(h_muonneg->GetXaxis()->FindBin(.01),
570 h_muonneg->GetXaxis()->FindBin(energy * 1.3));
571 const double muon_count_in_MIP = muon_ratio_in_MIP
573 ECalSumNonElectron->Integral(ECalSumNonElectron->GetXaxis()->FindBin(.01),
574 ECalSumNonElectron->GetXaxis()->FindBin(energy * 1.3));
576 cout <<
"DrawCalibratedE_Plot: muon_ratio_in_MIP = " << muon_ratio_in_MIP
577 <<
", muon_count_in_MIP = " << muon_count_in_MIP << endl;
579 double pineg_scale = (ECalSumNonElectron->Integral(
580 ECalSumNonElectron->GetXaxis()->FindBin(.01),
581 ECalSumNonElectron->GetXaxis()->FindBin(hadron_norm_max_range))
583 / h_pineg->Integral(h_pineg->GetXaxis()->FindBin(.01),
584 h_pineg->GetXaxis()->FindBin(hadron_norm_max_range));
586 double kaonneg_scale = (ECalSumNonElectron->Integral(
587 ECalSumNonElectron->GetXaxis()->FindBin(.01),
588 ECalSumNonElectron->GetXaxis()->FindBin(hadron_norm_max_range))
590 / h_kaonneg->Integral(h_kaonneg->GetXaxis()->FindBin(.01),
591 h_kaonneg->GetXaxis()->FindBin(hadron_norm_max_range));
593 double eneg_scale_hadron_data_tail = ECalSumNonElectron->Integral(
594 ECalSumNonElectron->GetXaxis()->FindBin(energy * 0.95),
595 ECalSumNonElectron->GetXaxis()->FindBin(energy * 1.15))
596 / h_eneg_scale_hadron_data_tail->Integral(
597 h_eneg_scale_hadron_data_tail->GetXaxis()->FindBin(energy * 0.95),
598 h_eneg_scale_hadron_data_tail->GetXaxis()->FindBin(energy * 1.15));
604 h_eneg_scale_hadron_data_tail->Rebin(5);
607 ECalSumNonElectron->Rebin(40);
609 ECalSumElectron->Sumw2();
610 ECalSumNonElectron->Sumw2();
612 ECalSumElectron->SetMarkerStyle(kFullCircle);
613 ECalSumElectron->SetMarkerSize(1);
614 ECalSumNonElectron->SetMarkerStyle(kFullCircle);
615 ECalSumNonElectron->SetMarkerSize(1);
617 eneg_scale *= ECalSumElectron->GetBinWidth(1) / h_eneg->GetBinWidth(1);
618 pineg_scale *= ECalSumNonElectron->GetBinWidth(1) / h_pineg->GetBinWidth(1);
619 kaonneg_scale *= ECalSumNonElectron->GetBinWidth(1)
620 / h_kaonneg->GetBinWidth(1);
621 muonneg_scale *= ECalSumNonElectron->GetBinWidth(1)
622 / h_muonneg->GetBinWidth(1);
623 eneg_scale_hadron_data_tail *= ECalSumNonElectron->GetBinWidth(1)
624 / h_eneg_scale_hadron_data_tail->GetBinWidth(1);
628 TF1 * f_gaus_sim =
new TF1(
"f_gaus_sim",
"gaus",
629 h_eneg->GetMean() - 2 * h_eneg->GetRMS(),
630 h_eneg->GetMean() + 2 * h_eneg->GetRMS());
631 f_gaus_sim->SetParameters(1, h_eneg->GetMean(), h_eneg->GetRMS());
633 h_eneg->Fit(f_gaus_sim,
"RM0");
635 f_gaus_sim->Draw(
"same");
637 TF1 * f_gaus_data =
new TF1(
"f_gaus_data",
"gaus",
638 h_eneg->GetMean() - 2 * h_eneg->GetRMS(),
639 h_eneg->GetMean() + 2 * h_eneg->GetRMS());
640 f_gaus_data->SetParameters(1, h_eneg->GetMean(), h_eneg->GetRMS());
642 ECalSumElectron->Fit(f_gaus_data,
"RM0");
643 ECalSumElectron->DrawClone();
644 f_gaus_data->Draw(
"same");
646 h_eneg->Scale(eneg_scale);
647 h_pineg->Scale(pineg_scale);
648 h_kaonneg->Scale(kaonneg_scale);
649 h_muonneg->Scale(muonneg_scale);
650 h_eneg_scale_hadron_data_tail->Scale(eneg_scale_hadron_data_tail);
655 TCanvas *c1 =
new TCanvas(
"DrawCalibratedE_Plot" +
cuts,
656 "DrawCalibratedE_Plot" +
cuts, 1800, 700);
661 p = (TPad *) c1->cd(idx++);
667 h_eneg->SetLineWidth(2);
669 ECalSumElectron->GetXaxis()->SetRangeUser(0, energy * 1.5);
670 ECalSumElectron->Draw();
671 h_eneg->SetLineWidth(3);
672 h_eneg->SetLineColor(kGreen + 3);
673 h_eneg->SetFillColor(kGreen - 7);
674 h_eneg->SetFillStyle(1001);
675 h_eneg->Draw(
"same");
676 ECalSumElectron->Draw(
"same");
678 ECalSumElectron->SetTitle(
";Calibrated Energy (GeV);Count/bin");
680 TLegend * lg =
new TLegend(0.13, 0.65, 0.55, 0.85);
681 lg->AddEntry(ECalSumElectron,
682 Form(
"#splitline{2014 eRD1 beam test (e-cut)}{#DeltaE/E = %.1f%%}",
683 f_gaus_data->GetParameter(2) / f_gaus_data->GetParameter(1) * 100),
686 Form(
"#splitline{e^{-} sim using sPHENIX Geant4,}{#DeltaE/E = %.1f%%}",
687 f_gaus_sim->GetParameter(2) / f_gaus_sim->GetParameter(1) * 100),
691 p = (TPad *) c1->cd(idx++);
697 h_pineg->SetLineColor(kRed);
698 h_pineg->SetLineWidth(3);
699 h_kaonneg->SetLineColor(kBlue);
700 h_kaonneg->SetLineWidth(3);
701 h_muonneg->SetLineColor(kBlack);
702 h_muonneg->SetFillColor(kGray);
703 h_muonneg->SetLineWidth(3);
704 h_muonneg->SetFillStyle(1001);
705 h_eneg_scale_hadron_data_tail->SetLineColor(kGreen + 3);
706 h_eneg_scale_hadron_data_tail->SetLineWidth(2);
707 h_eneg_scale_hadron_data_tail->SetFillColor(kGreen - 7);
708 h_eneg_scale_hadron_data_tail->SetFillStyle(1001);
710 ECalSumNonElectron->GetXaxis()->SetRangeUser(0, energy * 1.5);
712 ECalSumNonElectron->Draw();
713 h_muonneg->Draw(
"same");
715 h_pineg->Draw(
"same");
716 h_kaonneg->Draw(
"same");
717 ECalSumNonElectron->Draw(
"same");
719 ECalSumNonElectron->SetTitle(
";Calibrated Energy (GeV);Count/bin");
721 TLegend * lg =
new TLegend(0.35, 0.65, 0.85, 0.9);
722 lg->AddEntry(ECalSumNonElectron, Form(
"2014 eRD1 beam test (#bar{e-cut})"),
724 lg->AddEntry(h_pineg, Form(
"#pi^{-} sim using sPHENIX Geant4"),
"l");
725 lg->AddEntry(h_kaonneg, Form(
"K^{-} sim using sPHENIX Geant4"),
"l");
728 lg->AddEntry(h_muonneg, Form(
"#mu^{-} (~10%% data) sim using sPHENIX Geant4"),
"lf");
733 "/direct/phenix+sim02/phnxreco/ePHENIX/jinhuang/sPHENIX_work/SPACAL_TestBeam_"
734 + ID +
config +
"/DrawCalibratedE_Plot_DrawJet_")
735 + TString(c1->GetName()),
true);
742 TCanvas *c1 =
new TCanvas(
"DrawTowerIDCheck" +
cuts,
743 "DrawTowerIDCheck" +
cuts, 1800, 900);
748 p = (TPad *) c1->cd(idx++);
751 T->Draw(
"TOWER_CEMC_eta_mean:G4HIT_CEMC_eta_mean",
"",
"*");
753 p = (TPad *) c1->cd(idx++);
756 T->Draw(
"TOWER_CEMC_phi_mean:G4HIT_CEMC_phi_mean",
"",
"*");
759 TString(
_infile->GetName()) + TString(
"_DrawJet_")
760 + TString(c1->GetName()), kFALSE);
767 TCanvas *c1 =
new TCanvas(
"DrawDist" +
cuts,
"DrawDist" +
cuts, 1800, 900);
772 p = (TPad *) c1->cd(idx++);
776 "G4HIT_CEMC.get_avg_y():G4HIT_CEMC.get_avg_x()>>h_EMC_Azim(600,-300,300,600,-300,300)",
777 "G4HIT_CEMC.edep",
"goff");
792 p->DrawFrame(-300, -300, 300, 300,
793 "Azimuthal distribution of hits;X (cm);Y (cm)");
794 h_EMC_Azim->Draw(
"colz same");
798 TEllipse * cBaBar =
new TEllipse(0, 0, 140);
800 cBaBar->SetFillStyle(0);
801 cBaBar->SetLineWidth(3);
802 cBaBar->SetLineColor(kMagenta);
804 TEllipse * cBaBar =
new TEllipse(0, 0, 170);
806 cBaBar->SetFillStyle(0);
807 cBaBar->SetLineWidth(3);
808 cBaBar->SetLineColor(kMagenta);
811 p = (TPad *) c1->cd(idx++);
815 "sqrt(G4HIT_CEMC.get_avg_x()**2 + G4HIT_CEMC.get_avg_y()**2):G4HIT_CEMC.get_avg_z()>>h_CEMC_Rz(600,-300,300,300,0,300)",
816 "G4HIT_CEMC.edep",
"goff");
832 p->DrawFrame(-300, 00, 300, 300,
833 "Azimuthal distribution of hits;Z (cm);R (cm)");
834 h_CEMC_Rz->Draw(
"colz same");
838 TLine * lBaBar =
new TLine(-174.5, 140, 174.5, 140);
840 lBaBar->SetLineWidth(3);
841 lBaBar->SetLineColor(kMagenta);
843 TLine * lBaBar =
new TLine(-174.5, 170, 174.5, 170);
845 lBaBar->SetLineWidth(3);
846 lBaBar->SetLineColor(kMagenta);
850 TString(
_infile->GetName()) + TString(
"_DrawJet_")
851 + TString(c1->GetName()), kFALSE);
858 TCanvas *c1 =
new TCanvas(
"DrawLeakage" +
cuts,
"DrawLeakage" +
cuts, 1800,
864 p = (TPad *) c1->cd(idx++);
867 "Average_CEMC_z:PHG4Particle0_eta>>hAverage_CEMC_z_PHG4Particle0_eta(120,0.8,0.9,120,75,125)",
870 p = (TPad *) c1->cd(idx++);
873 "Entrace_CEMC_z:PHG4Particle0_eta>>hEntrace_CEMC_z_PHG4Particle0_eta(120,0.8,0.9,120,75,125)",
876 p = (TPad *) c1->cd(idx++);
880 "Total_HCALIN_E/PHG4Particle0_e:Average_CEMC_z>>hLeakage_Average_CEMC_z(120,75,125,100,0,0.25)",
883 p = (TPad *) c1->cd(idx++);
887 "Total_HCALIN_E/PHG4Particle0_e:PHG4Particle0_eta>>hLeakage_PHG4Particle0_eta(120,0.8,0.9,100,0,0.25)",
890 p = (TPad *) c1->cd(idx++);
893 "Total_CEMC_E/PHG4Particle0_e:Average_CEMC_z>>hTotal_CEMC_E_Entrance_Z_Entrace_CEMC_z(120,75,125,100,0,1.2)",
896 p = (TPad *) c1->cd(idx++);
899 "Total_CEMC_E/PHG4Particle0_e:PHG4Particle0_eta>>hTotal_CEMC_E_PHG4Particle0_eta(120,0.8,0.9,100,0,1.2)",
903 TString(
_infile->GetName()) + TString(
"_DrawJet_")
904 + TString(c1->GetName()), kFALSE);
910 TCanvas *c1 =
new TCanvas(
"DrawLeakage_LY" +
cuts,
"DrawLeakage_LY" +
cuts,
916 p = (TPad *) c1->cd(idx++);
919 "Sum$(G4HIT_CEMC.light_yield)/PHG4Particle0_e:Average_CEMC_z>>hTotal_CEMC_E_Entrance_Z_Entrace_CEMC_z(120,75,125,100,0,.05)",
922 p = (TPad *) c1->cd(idx++);
925 "Sum$(G4HIT_CEMC.light_yield)/PHG4Particle0_e:PHG4Particle0_eta>>hTotal_CEMC_E_PHG4Particle0_eta(120,0.8,0.9,100,0,.05)",
929 TString(
_infile->GetName()) + TString(
"_DrawJet_")
930 + TString(c1->GetName()), kFALSE);
937 TCanvas *c1 =
new TCanvas(
"DrawLeakage_Wide" +
cuts,
938 "DrawLeakage_Wide" +
cuts, 1800, 900);
943 p = (TPad *) c1->cd(idx++);
946 "Average_CEMC_z:PHG4Particle0_eta>>hAverage_CEMC_z_PHG4Particle0_eta(300,0,1.1,300,0,150)",
949 p = (TPad *) c1->cd(idx++);
952 "Entrace_CEMC_z:PHG4Particle0_eta>>hEntrace_CEMC_z_PHG4Particle0_eta(300,0,1.1,300,0,150)",
955 p = (TPad *) c1->cd(idx++);
959 "Total_HCALIN_E/PHG4Particle0_e:Average_CEMC_z>>hLeakage_Average_CEMC_z(300,0,150,100,0,0.25)",
962 p = (TPad *) c1->cd(idx++);
966 "Total_HCALIN_E/PHG4Particle0_e:PHG4Particle0_eta>>hLeakage_PHG4Particle0_eta(300,0,1.1,100,0,0.25)",
969 p = (TPad *) c1->cd(idx++);
972 "Total_CEMC_E/PHG4Particle0_e:Average_CEMC_z>>hTotal_CEMC_E_Entrance_Z_Entrace_CEMC_z(300,0,150,100,0,1.2)",
975 p = (TPad *) c1->cd(idx++);
978 "Total_CEMC_E/PHG4Particle0_e:PHG4Particle0_eta>>hTotal_CEMC_E_PHG4Particle0_eta(300,0,1.1,100,0,1.2)",
982 TString(
_infile->GetName()) + TString(
"_DrawJet_")
983 + TString(c1->GetName()), kFALSE);
990 TCanvas *c1 =
new TCanvas(
"DrawLeakage_Phi" +
cuts,
"DrawLeakage_Phi" +
cuts,
996 p = (TPad *) c1->cd(idx++);
1000 "Total_HCALIN_E/PHG4Particle0_e:PHG4Particle0_phi>>hLeakage_PHG4Particle0_e(320,-3.14159,3.14159,100,0,0.25)",
1003 p = (TPad *) c1->cd(idx++);
1006 "Total_CEMC_E/PHG4Particle0_e:PHG4Particle0_phi>>hTotal_CEMC_E_PHG4Particle0_e(320,-3.14159,3.14159,100,0,1.2)",
1010 TString(
_infile->GetName()) + TString(
"_DrawJet_")
1011 + TString(c1->GetName()), kFALSE);
1018 gStyle->SetOptStat(0);
1019 gStyle->SetOptFit(1111);
1020 TVirtualFitter::SetDefaultFitter(
"Minuit2");
1021 gSystem->Load(
"libg4eval.so");
1023 TH2F * hLeakage_PHG4Particle0_e = (TH2F *) gDirectory->GetObjectChecked(
1024 "hLeakage_PHG4Particle0_e",
"TH2F");
1025 TH2F * hTotal_CEMC_E_PHG4Particle0_e = (TH2F *) gDirectory->GetObjectChecked(
1026 "hTotal_CEMC_E_PHG4Particle0_e",
"TH2F");
1028 TH2F * hLeakage_PHG4Particle0_e_Fold =
new TH2F(
1029 "hLeakage_PHG4Particle0_e_Fold",
";Phi (rad);Leakage Ratio", 320 / N_fold,
1030 -3.14159 / N_fold, 3.14159 / N_fold, 100, 0, 0.25);
1031 TH2F * hTotal_CEMC_E_PHG4Particle0_e_Fold =
new TH2F(
1032 "hTotal_CEMC_E_PHG4Particle0_e_Fold",
";Phi (rad);EMCal Energy Ratio",
1033 320 / N_fold, -3.14159 / N_fold, 3.14159 / N_fold, 100, 0, 1.2);
1035 for (
int biny = 1; biny <= hLeakage_PHG4Particle0_e->GetNbinsY(); biny++)
1036 for (
int bin = 1; bin <= hLeakage_PHG4Particle0_e->GetNbinsX(); bin++)
1038 const int folded_bin = (bin - 1) % (320 / N_fold) + 1;
1040 hLeakage_PHG4Particle0_e_Fold->SetBinContent(folded_bin, biny,
1041 hLeakage_PHG4Particle0_e_Fold->GetBinContent(folded_bin, biny)
1042 + hLeakage_PHG4Particle0_e->GetBinContent(bin, biny));
1043 hTotal_CEMC_E_PHG4Particle0_e_Fold->SetBinContent(folded_bin, biny,
1044 hTotal_CEMC_E_PHG4Particle0_e_Fold->GetBinContent(folded_bin, biny)
1045 + hTotal_CEMC_E_PHG4Particle0_e->GetBinContent(bin, biny));
1049 TCanvas *c1 =
new TCanvas(
"DrawLeakage_Phi_Folding" +
cuts,
1050 "DrawLeakage_Phi_Folding" +
cuts, 1000, 900);
1055 p = (TPad *) c1->cd(idx++);
1057 hLeakage_PHG4Particle0_e_Fold->Draw(
"colz");
1059 p = (TPad *) c1->cd(idx++);
1061 hTotal_CEMC_E_PHG4Particle0_e_Fold->Draw(
"colz");
1063 SaveCanvas(c1, TString(
"_DrawJet_") + TString(c1->GetName()), kFALSE);
1070 TCanvas *c1 =
new TCanvas(
"Sampling" +
cuts,
"Sampling" +
cuts, 900, 900);
1076 "Sum$(G4HIT_CEMC.light_yield):(Sum$(G4HIT_CEMC.edep) + Sum$(G4HIT_ABSORBER_CEMC.edep))",
1079 (TGraph *) gPad->GetListOfPrimitives()->FindObject(
"Graph")->Clone(
1082 gh2D->SetName(
"gh2D");
1083 gh2D->SetMarkerStyle(kDot);
1085 p->DrawFrame(0, 0, 10, 1,
1086 "EMC Energy Deposition;Absorber+Scintillator (GeV);Scintillator (GeV)");
1089 TF1 * fsampling =
new TF1(
"fsampling",
"[0]*x", 0.4, 100);
1090 gh2D->Fit(fsampling,
"MR");
1093 TString(
_infile->GetName()) + TString(
"_DrawJet_")
1094 + TString(c1->GetName()), kFALSE);