17 #include <TGraphErrors.h>
33 "/phenix/u/jinhuang/links/sPHENIX_work/Prototype_2017/sim/MuonCalib//1k_Muon_DSTReader.root"
37 gStyle->SetOptStat(0);
38 gStyle->SetOptFit(1111);
39 TVirtualFitter::SetDefaultFitter(
"Minuit2");
40 gSystem->Load(
"libg4eval.so");
41 gSystem->Load(
"libqa_modules.so");
45 TString chian_str =
infile;
46 chian_str.ReplaceAll(
"ALL",
"*");
48 TChain *
t =
new TChain(
"T");
49 const int n = t->Add(chian_str);
51 cout <<
"Loaded " << n <<
" root files with " << chian_str << endl;
62 T->SetAlias(
"ActiveTower_LG",
63 "TOWER_CALIB_LG_CEMC[].get_binphi()<8 && TOWER_CALIB_LG_CEMC[].get_bineta()<8");
64 T->SetAlias(
"EnergySum_LG",
65 "1*Sum$(TOWER_CALIB_LG_CEMC[].get_energy() * ActiveTower_LG)");
67 T->SetAlias(
"ActiveTower_HG",
68 "TOWER_CALIB_HG_CEMC[].get_binphi()<8 && TOWER_CALIB_HG_CEMC[].get_bineta()<8");
69 T->SetAlias(
"EnergySum_HG",
70 "1*Sum$(TOWER_CALIB_HG_CEMC[].get_energy() * ActiveTower_HG)");
82 cout <<
"Build event selection of " << (
const char *) event_sel << endl;
84 T->Draw(
">>EventList", event_sel);
85 TEventList * elist = gDirectory->GetObjectChecked(
"EventList",
"TEventList");
86 cout << elist->GetN() <<
" / " <<
T->GetEntriesFast() <<
" events selected"
89 T->SetEventList(elist);
103 TString hname =
"EMCDistribution_" +
gain + TString(log_scale ?
"_Log" :
"")
110 Form(
";Calibrated Tower Energy Sum (GeV);Count / bin"), 300, 10
e-3,
117 Form(
";Calibrated Tower Energy Sum (GeV);Count / bin"), 100, -.050,
122 "TOWER_CALIB_" +
gain +
"_CEMC[].get_bineta() + 8* TOWER_CALIB_" +
gain
123 +
"_CEMC[].get_binphi():TOWER_CALIB_" +
gain
124 +
"_CEMC[].get_energy()>>" + hname,
"",
"goff");
126 TCanvas *c1 =
new TCanvas(
127 "EMCDistribution_" +
gain + TString(log_scale ?
"_Log" :
"") + cuts,
128 "EMCDistribution_" +
gain + TString(log_scale ?
"_Log" :
"") + cuts, 1800,
130 c1->Divide(8, 8, 0., 0.01);
134 for (
int iphi = 8 - 1; iphi >= 0; iphi--)
136 for (
int ieta = 0; ieta < 8; ieta++)
138 p = (TPad *) c1->cd(idx++);
149 TString hname = Form(
"hEnergy_ieta%d_iphi%d", ieta, iphi)
150 + TString(log_scale ?
"_Log" :
"");
152 TH1 *
h = h2->ProjectionX(hname, ieta + 8 * iphi + 1,
153 ieta + 8 * iphi + 1);
156 h->SetLineColor(kBlue + 3);
157 h->SetFillColor(kBlue + 3);
158 h->GetXaxis()->SetTitleSize(.09);
159 h->GetXaxis()->SetLabelSize(.08);
160 h->GetYaxis()->SetLabelSize(.08);
164 TText *t =
new TText(.9, .9, Form(
"Col%d Row%d", ieta, iphi));
173 TString(
_file0->GetName()) + TString(
"_DrawEMCalTower_")
174 + TString(c1->GetName()), kTRUE);
183 TCanvas *c1 =
new TCanvas(
184 "EMCDistribution_" +
gain + TString(log_scale ?
"_Log" :
"") +
cuts,
185 "EMCDistribution_" +
gain + TString(log_scale ?
"_Log" :
"") +
cuts, 1800,
187 c1->Divide(8, 8, 0., 0.01);
191 for (
int iphi = 8 - 1; iphi >= 0; iphi--)
193 for (
int ieta = 0; ieta < 8; ieta++)
195 p = (TPad *) c1->cd(idx++);
206 TString hname = Form(
"hEnergy_ieta%d_iphi%d", ieta, iphi)
207 + TString(log_scale ?
"_Log" :
"");
213 Form(
";Calibrated Tower Energy Sum (GeV);Count / bin"), 300,
217 Form(
";Calibrated Tower Energy Sum (GeV);Count / bin"), 100,
221 h->SetLineColor(kBlue + 3);
222 h->SetFillColor(kBlue + 3);
223 h->GetXaxis()->SetTitleSize(.09);
224 h->GetXaxis()->SetLabelSize(.08);
225 h->GetYaxis()->SetLabelSize(.08);
230 T->Draw(
"TOWER_CALIB_" +
gain +
"_CEMC[].get_energy()>>" + hname,
232 "TOWER_CALIB_%s_CEMC[].get_bineta()==%d && TOWER_CALIB_%s_CEMC[].get_binphi()==%d",
233 gain.Data(), ieta,
gain.Data(), iphi),
"");
235 TText *t =
new TText(.9, .9, Form(
"Col%d Row%d", ieta, iphi));
244 TString(
_file0->GetName()) + TString(
"_DrawEMCalTower_")
245 + TString(c1->GetName()), kTRUE);
251 TH1 * EnergySum_LG =
new TH1F(
"EnergySum_LG",
252 ";Low-gain Tower Energy Sum (GeV);Count / bin", 1500, 0, 100);
253 TH1 * EnergySum_HG =
new TH1F(
"EnergySum_HG",
254 ";High-gain Tower Energy Sum (GeV);Count / bin", 300, 0, 3);
256 T->Draw(
"EnergySum_LG>>EnergySum_LG",
"",
"goff");
257 T->Draw(
"EnergySum_HG>>EnergySum_HG",
"",
"goff");
260 TCanvas *c1 =
new TCanvas(
"EMCDistribution_SUM" +
cuts,
261 "EMCDistribution_SUM" +
cuts, 1000, 960);
266 p = (TPad *) c1->cd(idx++);
272 TH1 *
h = (TH1 *) EnergySum_LG->DrawClone();
274 h->SetLineColor(kBlue + 3);
276 h->GetXaxis()->SetRangeUser(0, h->GetMean() + 5 * h->GetRMS());
278 p = (TPad *) c1->cd(idx++);
284 TH1 * h = (TH1 *) EnergySum_LG->DrawClone();
286 TF1 * fgaus =
new TF1(
"fgaus_LG",
"gaus", 0, 100);
287 fgaus->SetParameters(1, h->GetMean() - 2 * h->GetRMS(),
288 h->GetMean() + 2 * h->GetRMS());
292 h->GetXaxis()->SetRangeUser(h->GetMean() - 4 * h->GetRMS(),
293 h->GetMean() + 4 * h->GetRMS());
296 h->SetMarkerStyle(kFullCircle);
299 Form(
"#DeltaE/<E> = %.1f%%",
300 100 * fgaus->GetParameter(2) / fgaus->GetParameter(1)));
302 p = (TPad *) c1->cd(idx++);
308 TH1 * h = (TH1 *) EnergySum_HG->DrawClone();
310 h->SetLineColor(kBlue + 3);
312 h->GetXaxis()->SetRangeUser(0, h->GetMean() + 5 * h->GetRMS());
314 p = (TPad *) c1->cd(idx++);
320 TH1 * h = (TH1 *) EnergySum_HG->DrawClone();
322 TF1 * fgaus =
new TF1(
"fgaus_HG",
"gaus", 0, 100);
323 fgaus->SetParameters(1, h->GetMean() - 2 * h->GetRMS(),
324 h->GetMean() + 2 * h->GetRMS());
328 h->GetXaxis()->SetRangeUser(h->GetMean() - 4 * h->GetRMS(),
329 h->GetMean() + 4 * h->GetRMS());
332 h->SetMarkerStyle(kFullCircle);
335 Form(
"#DeltaE/<E> = %.1f%%",
336 100 * fgaus->GetParameter(2) / fgaus->GetParameter(1)));
339 TString(
_file0->GetName()) + TString(
"_DrawEMCalTower_")
340 + TString(c1->GetName()), kTRUE);
346 0,
const int n_div = 1)
348 TH3F * EnergySum_LG3 =
349 new TH3F(
"EnergySum_LG3",
350 ";Beam Horizontal Pos (cm);Beam Horizontal Vertical (cm);Low-gain Tower Energy Sum (GeV)",
351 20 * n_div, z_shift - 5, z_shift + 5,
355 T->Draw(
"EnergySum_LG:PHG4VtxPoint.vy:PHG4VtxPoint.vz>>EnergySum_LG3",
"",
358 TProfile2D * EnergySum_LG3_xy = EnergySum_LG3->Project3DProfile(
"yx");
359 TH2 * EnergySum_LG3_zx = EnergySum_LG3->Project3D(
"zx");
360 TH2 * EnergySum_LG3_zy = EnergySum_LG3->Project3D(
"zy");
362 TGraphErrors * ge_EnergySum_LG3_zx =
FitProfile(EnergySum_LG3_zx);
363 TGraphErrors * ge_EnergySum_LG3_zy =
FitProfile(EnergySum_LG3_zy);
366 TCanvas *c1 =
new TCanvas(
367 TString(Form(
"EMCDistributionVSBeam_SUM_NDiv%d", n_div)) +
cuts,
368 TString(Form(
"EMCDistributionVSBeam_SUM_NDiv%d", n_div)) +
cuts, 1000,
374 p = (TPad *) c1->cd(idx++);
380 EnergySum_LG3_xy->Draw(
"colz");
381 EnergySum_LG3_xy->SetTitle(
382 "Position scan;Beam Horizontal Pos (cm);Beam Horizontal Vertical (cm)");
384 p = (TPad *) c1->cd(idx++);
390 EnergySum_LG3_zx->Draw(
"colz");
391 EnergySum_LG3_zx->SetTitle(
392 "Position scan;Beam Horizontal Pos (cm);Energy Sum (GeV)");
394 ge_EnergySum_LG3_zx->SetLineWidth(2);
395 ge_EnergySum_LG3_zx->SetMarkerStyle(kFullCircle);
396 ge_EnergySum_LG3_zx->Draw(
"pe");
398 p = (TPad *) c1->cd(idx++);
404 EnergySum_LG3_zy->Draw(
"colz");
405 EnergySum_LG3_zy->SetTitle(
406 "Position scan;Beam Vertical Pos (cm);Energy Sum (GeV)");
408 ge_EnergySum_LG3_zy->SetLineWidth(2);
409 ge_EnergySum_LG3_zy->SetMarkerStyle(kFullCircle);
410 ge_EnergySum_LG3_zy->Draw(
"pe");
412 p = (TPad *) c1->cd(idx++);
418 TH1 *
h = (TH1 *) EnergySum_LG3->ProjectionZ();
420 TF1 * fgaus =
new TF1(
"fgaus_LG",
"gaus", 0, 100);
421 fgaus->SetParameters(1, h->GetMean() - 2 * h->GetRMS(),
422 h->GetMean() + 2 * h->GetRMS());
426 h->GetXaxis()->SetRangeUser(h->GetMean() - 4 * h->GetRMS(),
427 h->GetMean() + 4 * h->GetRMS());
428 EnergySum_LG3_zx->GetYaxis()->SetRangeUser(h->GetMean() - 4 * h->GetRMS(),
429 h->GetMean() + 4 * h->GetRMS());
430 EnergySum_LG3_zy->GetYaxis()->SetRangeUser(h->GetMean() - 4 * h->GetRMS(),
431 h->GetMean() + 4 * h->GetRMS());
434 h->SetMarkerStyle(kFullCircle);
437 Form(
"#DeltaE/<E> = %.1f%%",
438 100 * fgaus->GetParameter(2) / fgaus->GetParameter(1)));
441 TString(
_file0->GetName()) + TString(
"_DrawEMCalTower_")
442 + TString(c1->GetName()), kTRUE);
450 TProfile * p2 = h2->ProfileX();
458 for (
int i = 1;
i <= h2->GetNbinsX();
i++)
460 TH1D *
h1 = h2->ProjectionY(Form(
"htmp_%d", rand()),
i,
i);
462 if (h1->GetSum() < 30)
464 cout <<
"FitProfile - ignore bin " <<
i << endl;
469 cout <<
"FitProfile - fit bin " <<
i << endl;
472 TF1 fgaus(
"fgaus",
"gaus", -p2->GetBinError(
i) * 4,
473 p2->GetBinError(
i) * 4);
475 TF1
f2(Form(
"dgaus"),
"gaus + [3]*exp(-0.5*((x-[1])/[4])**2) + [5]",
476 -p2->GetBinError(
i) * 4, p2->GetBinError(
i) * 4);
478 fgaus.SetParameter(1, p2->GetBinContent(
i));
479 fgaus.SetParameter(2, p2->GetBinError(
i));
481 h1->Fit(&fgaus,
"MQ");
483 f2.SetParameters(fgaus.GetParameter(0) / 2, fgaus.GetParameter(1),
484 fgaus.GetParameter(2), fgaus.GetParameter(0) / 2,
485 fgaus.GetParameter(2) / 4, 0);
494 x[
n] = p2->GetBinCenter(
i);
495 ex[
n] = (p2->GetBinCenter(2) - p2->GetBinCenter(1)) / 2;
496 y[
n] = fgaus.GetParameter(1);
497 ey[
n] = fgaus.GetParError(1);
506 return new TGraphErrors(n, x, y, ex, ey);