17 #include <TGraphErrors.h>
31 "/phenix/u/jinhuang/links/sPHENIX_work/Prototype_2016/EMCal_sim/./0Degree_1Col_LightCollectionSeanStoll_CrackScan/Prototype_e-_8_SegALL_DSTReader.root"
36 gStyle->SetOptStat(0);
37 gStyle->SetOptFit(1111);
38 TVirtualFitter::SetDefaultFitter(
"Minuit2");
39 gSystem->Load(
"libg4eval.so");
40 gSystem->Load(
"libqa_modules.so");
44 TString chian_str =
infile;
45 chian_str.ReplaceAll(
"ALL",
"*");
47 TChain *
t =
new TChain(
"T");
48 const int n = t->Add(chian_str);
50 cout <<
"Loaded " << n <<
" root files with " << chian_str << endl;
61 T->SetAlias(
"ActiveTower_LG",
62 "TOWER_CALIB_LG_CEMC[].get_binphi()<8 && TOWER_CALIB_LG_CEMC[].get_bineta()<8");
63 T->SetAlias(
"EnergySum_LG",
64 "1*Sum$(TOWER_CALIB_LG_CEMC[].get_energy() * ActiveTower_LG)");
66 T->SetAlias(
"ActiveTower_HG",
67 "TOWER_CALIB_HG_CEMC[].get_binphi()<8 && TOWER_CALIB_HG_CEMC[].get_bineta()<8");
68 T->SetAlias(
"EnergySum_HG",
69 "1*Sum$(TOWER_CALIB_HG_CEMC[].get_energy() * ActiveTower_HG)");
81 cout <<
"Build event selection of " << (
const char *) event_sel << endl;
83 T->Draw(
">>EventList", event_sel);
84 TEventList * elist = gDirectory->GetObjectChecked(
"EventList",
"TEventList");
85 cout << elist->GetN() <<
" / " <<
T->GetEntriesFast() <<
" events selected"
88 T->SetEventList(elist);
102 TString hname =
"EMCDistribution_" +
gain + TString(log_scale ?
"_Log" :
"")
109 Form(
";Calibrated Tower Energy Sum (GeV);Count / bin"), 300, 10
e-3,
116 Form(
";Calibrated Tower Energy Sum (GeV);Count / bin"), 100, -.050,
121 "TOWER_CALIB_" +
gain +
"_CEMC[].get_bineta() + 8* TOWER_CALIB_" +
gain
122 +
"_CEMC[].get_binphi():TOWER_CALIB_" +
gain
123 +
"_CEMC[].get_energy()>>" + hname,
"",
"goff");
125 TCanvas *c1 =
new TCanvas(
126 "EMCDistribution_" +
gain + TString(log_scale ?
"_Log" :
"") + cuts,
127 "EMCDistribution_" +
gain + TString(log_scale ?
"_Log" :
"") + cuts, 1800,
129 c1->Divide(8, 8, 0., 0.01);
133 for (
int iphi = 8 - 1; iphi >= 0; iphi--)
135 for (
int ieta = 0; ieta < 8; ieta++)
137 p = (TPad *) c1->cd(idx++);
148 TString hname = Form(
"hEnergy_ieta%d_iphi%d", ieta, iphi)
149 + TString(log_scale ?
"_Log" :
"");
151 TH1 *
h = h2->ProjectionX(hname, ieta + 8 * iphi + 1,
152 ieta + 8 * iphi + 1);
155 h->SetLineColor(kBlue + 3);
156 h->SetFillColor(kBlue + 3);
157 h->GetXaxis()->SetTitleSize(.09);
158 h->GetXaxis()->SetLabelSize(.08);
159 h->GetYaxis()->SetLabelSize(.08);
163 TText *t =
new TText(.9, .9, Form(
"Col%d Row%d", ieta, iphi));
172 TString(
_file0->GetName()) + TString(
"_DrawEMCalTower_")
173 + TString(c1->GetName()), kTRUE);
182 TCanvas *c1 =
new TCanvas(
183 "EMCDistribution_" +
gain + TString(log_scale ?
"_Log" :
"") +
cuts,
184 "EMCDistribution_" +
gain + TString(log_scale ?
"_Log" :
"") +
cuts, 1800,
186 c1->Divide(8, 8, 0., 0.01);
190 for (
int iphi = 8 - 1; iphi >= 0; iphi--)
192 for (
int ieta = 0; ieta < 8; ieta++)
194 p = (TPad *) c1->cd(idx++);
205 TString hname = Form(
"hEnergy_ieta%d_iphi%d", ieta, iphi)
206 + TString(log_scale ?
"_Log" :
"");
212 Form(
";Calibrated Tower Energy Sum (GeV);Count / bin"), 300,
216 Form(
";Calibrated Tower Energy Sum (GeV);Count / bin"), 100,
220 h->SetLineColor(kBlue + 3);
221 h->SetFillColor(kBlue + 3);
222 h->GetXaxis()->SetTitleSize(.09);
223 h->GetXaxis()->SetLabelSize(.08);
224 h->GetYaxis()->SetLabelSize(.08);
229 T->Draw(
"TOWER_CALIB_" +
gain +
"_CEMC[].get_energy()>>" + hname,
231 "TOWER_CALIB_%s_CEMC[].get_bineta()==%d && TOWER_CALIB_%s_CEMC[].get_binphi()==%d",
232 gain.Data(), ieta,
gain.Data(), iphi),
"");
234 TText *t =
new TText(.9, .9, Form(
"Col%d Row%d", ieta, iphi));
243 TString(
_file0->GetName()) + TString(
"_DrawEMCalTower_")
244 + TString(c1->GetName()), kTRUE);
250 TH1 * EnergySum_LG =
new TH1F(
"EnergySum_LG",
251 ";Low-gain Tower Energy Sum (GeV);Count / bin", 1500, 0, 100);
252 TH1 * EnergySum_HG =
new TH1F(
"EnergySum_HG",
253 ";High-gain Tower Energy Sum (GeV);Count / bin", 300, 0, 3);
255 T->Draw(
"EnergySum_LG>>EnergySum_LG",
"",
"goff");
256 T->Draw(
"EnergySum_HG>>EnergySum_HG",
"",
"goff");
259 TCanvas *c1 =
new TCanvas(
"EMCDistribution_SUM" +
cuts,
260 "EMCDistribution_SUM" +
cuts, 1000, 960);
265 p = (TPad *) c1->cd(idx++);
271 TH1 *
h = (TH1 *) EnergySum_LG->DrawClone();
273 h->SetLineColor(kBlue + 3);
275 h->GetXaxis()->SetRangeUser(0, h->GetMean() + 5 * h->GetRMS());
277 p = (TPad *) c1->cd(idx++);
283 TH1 * h = (TH1 *) EnergySum_LG->DrawClone();
285 TF1 * fgaus =
new TF1(
"fgaus_LG",
"gaus", 0, 100);
286 fgaus->SetParameters(1, h->GetMean() - 2 * h->GetRMS(),
287 h->GetMean() + 2 * h->GetRMS());
291 h->GetXaxis()->SetRangeUser(h->GetMean() - 4 * h->GetRMS(),
292 h->GetMean() + 4 * h->GetRMS());
295 h->SetMarkerStyle(kFullCircle);
298 Form(
"#DeltaE/<E> = %.1f%%",
299 100 * fgaus->GetParameter(2) / fgaus->GetParameter(1)));
301 p = (TPad *) c1->cd(idx++);
307 TH1 * h = (TH1 *) EnergySum_HG->DrawClone();
309 h->SetLineColor(kBlue + 3);
311 h->GetXaxis()->SetRangeUser(0, h->GetMean() + 5 * h->GetRMS());
313 p = (TPad *) c1->cd(idx++);
319 TH1 * h = (TH1 *) EnergySum_HG->DrawClone();
321 TF1 * fgaus =
new TF1(
"fgaus_HG",
"gaus", 0, 100);
322 fgaus->SetParameters(1, h->GetMean() - 2 * h->GetRMS(),
323 h->GetMean() + 2 * h->GetRMS());
327 h->GetXaxis()->SetRangeUser(h->GetMean() - 4 * h->GetRMS(),
328 h->GetMean() + 4 * h->GetRMS());
331 h->SetMarkerStyle(kFullCircle);
334 Form(
"#DeltaE/<E> = %.1f%%",
335 100 * fgaus->GetParameter(2) / fgaus->GetParameter(1)));
338 TString(
_file0->GetName()) + TString(
"_DrawEMCalTower_")
339 + TString(c1->GetName()), kTRUE);
345 0,
const int n_div = 1)
347 TH3F * EnergySum_LG3 =
348 new TH3F(
"EnergySum_LG3",
349 ";Beam Horizontal Pos (cm);Beam Horizontal Vertical (cm);Low-gain Tower Energy Sum (GeV)",
350 20 * n_div, z_shift - 5, z_shift + 5,
354 T->Draw(
"EnergySum_LG:PHG4VtxPoint.vy:PHG4VtxPoint.vz>>EnergySum_LG3",
"",
357 TProfile2D * EnergySum_LG3_xy = EnergySum_LG3->Project3DProfile(
"yx");
358 TH2 * EnergySum_LG3_zx = EnergySum_LG3->Project3D(
"zx");
359 TH2 * EnergySum_LG3_zy = EnergySum_LG3->Project3D(
"zy");
361 TGraphErrors * ge_EnergySum_LG3_zx =
FitProfile(EnergySum_LG3_zx);
362 TGraphErrors * ge_EnergySum_LG3_zy =
FitProfile(EnergySum_LG3_zy);
365 TCanvas *c1 =
new TCanvas(
366 TString(Form(
"EMCDistributionVSBeam_SUM_NDiv%d", n_div)) +
cuts,
367 TString(Form(
"EMCDistributionVSBeam_SUM_NDiv%d", n_div)) +
cuts, 1000,
373 p = (TPad *) c1->cd(idx++);
379 EnergySum_LG3_xy->Draw(
"colz");
380 EnergySum_LG3_xy->SetTitle(
381 "Position scan;Beam Horizontal Pos (cm);Beam Horizontal Vertical (cm)");
383 p = (TPad *) c1->cd(idx++);
389 EnergySum_LG3_zx->Draw(
"colz");
390 EnergySum_LG3_zx->SetTitle(
391 "Position scan;Beam Horizontal Pos (cm);Energy Sum (GeV)");
393 ge_EnergySum_LG3_zx->SetLineWidth(2);
394 ge_EnergySum_LG3_zx->SetMarkerStyle(kFullCircle);
395 ge_EnergySum_LG3_zx->Draw(
"pe");
397 p = (TPad *) c1->cd(idx++);
403 EnergySum_LG3_zy->Draw(
"colz");
404 EnergySum_LG3_zy->SetTitle(
405 "Position scan;Beam Vertical Pos (cm);Energy Sum (GeV)");
407 ge_EnergySum_LG3_zy->SetLineWidth(2);
408 ge_EnergySum_LG3_zy->SetMarkerStyle(kFullCircle);
409 ge_EnergySum_LG3_zy->Draw(
"pe");
411 p = (TPad *) c1->cd(idx++);
417 TH1 *
h = (TH1 *) EnergySum_LG3->ProjectionZ();
419 TF1 * fgaus =
new TF1(
"fgaus_LG",
"gaus", 0, 100);
420 fgaus->SetParameters(1, h->GetMean() - 2 * h->GetRMS(),
421 h->GetMean() + 2 * h->GetRMS());
425 h->GetXaxis()->SetRangeUser(h->GetMean() - 4 * h->GetRMS(),
426 h->GetMean() + 4 * h->GetRMS());
427 EnergySum_LG3_zx->GetYaxis()->SetRangeUser(h->GetMean() - 4 * h->GetRMS(),
428 h->GetMean() + 4 * h->GetRMS());
429 EnergySum_LG3_zy->GetYaxis()->SetRangeUser(h->GetMean() - 4 * h->GetRMS(),
430 h->GetMean() + 4 * h->GetRMS());
433 h->SetMarkerStyle(kFullCircle);
436 Form(
"#DeltaE/<E> = %.1f%%",
437 100 * fgaus->GetParameter(2) / fgaus->GetParameter(1)));
440 TString(
_file0->GetName()) + TString(
"_DrawEMCalTower_")
441 + TString(c1->GetName()), kTRUE);
449 TProfile * p2 = h2->ProfileX();
457 for (
int i = 1;
i <= h2->GetNbinsX();
i++)
459 TH1D *
h1 = h2->ProjectionY(Form(
"htmp_%d", rand()),
i,
i);
461 if (h1->GetSum() < 30)
463 cout <<
"FitProfile - ignore bin " <<
i << endl;
468 cout <<
"FitProfile - fit bin " <<
i << endl;
471 TF1 fgaus(
"fgaus",
"gaus", -p2->GetBinError(
i) * 4,
472 p2->GetBinError(
i) * 4);
474 TF1
f2(Form(
"dgaus"),
"gaus + [3]*exp(-0.5*((x-[1])/[4])**2) + [5]",
475 -p2->GetBinError(
i) * 4, p2->GetBinError(
i) * 4);
477 fgaus.SetParameter(1, p2->GetBinContent(
i));
478 fgaus.SetParameter(2, p2->GetBinError(
i));
480 h1->Fit(&fgaus,
"MQ");
482 f2.SetParameters(fgaus.GetParameter(0) / 2, fgaus.GetParameter(1),
483 fgaus.GetParameter(2), fgaus.GetParameter(0) / 2,
484 fgaus.GetParameter(2) / 4, 0);
493 x[
n] = p2->GetBinCenter(
i);
494 ex[
n] = (p2->GetBinCenter(2) - p2->GetBinCenter(1)) / 2;
495 y[
n] = fgaus.GetParameter(1);
496 ey[
n] = fgaus.GetParError(1);
505 return new TGraphErrors(n, x, y, ex, ey);