17 #include <TGraphErrors.h>
34 TGraphErrors * linearity;
35 TGraphErrors * resolution;
45 gStyle->SetOptStat(0);
46 gStyle->SetOptFit(1111);
47 gStyle->SetPadGridX(0);
48 gStyle->SetPadGridY(0);
49 TVirtualFitter::SetDefaultFitter(
"Minuit2");
51 gSystem->Load(
"libPrototype2.so");
52 gSystem->Load(
"libProto2ShowCalib.so");
95 cout <<
"GetMu2Pi - missing mu2pi data!!" << endl;
108 TString
energy(Form(
"%.0f",
E));
111 "/phenix/u/jinhuang/links/sPHENIX_work/Prototype_2016/ShowerCalib/Tilt0.lst_EMCalCalib.root_DrawPrototype2ShowerCalib_LineShapeData_Neg"
112 + energy +
"GeV_quality_h12345_v34567_col2_row2.root");
114 TFile * fdata =
new TFile(data_file);
119 "/phenix/u/jinhuang/links/sPHENIX_work/Prototype_2016/EMCal_sim/./0Degree_1Col_LightCollectionSeanStoll/Prototype_mu-_"
121 +
"_SegALL_EMCalCalib.root_DrawPrototype2ShowerCalib_LineShapeSim_0DegreeRot_h5_v5_col2_row2.root");
123 cout <<
"Processing " << fmu->GetName() << endl;
125 TH1F * h_5x5sum_c2_sum_mu = fmu->Get(
"h_5x5sum_c2_sum")->Clone(
126 "h_5x5sum_c2_sum_mu");
131 TH1F * h_5x5sum_c2_h = fdata->Get(
"h_5x5sum_c2_h");
133 TH1F * h_5x5sum_c2_sum_data_sub_mu = h_5x5sum_c2_h->Clone(
134 "h_5x5sum_c2_sum_data_sub_mu");
136 cout <<
"h_5x5sum_c2_sum_data->GetNbinsX() = "
137 << h_5x5sum_c2_sum_data_sub_mu->GetNbinsX() << endl;
138 cout <<
"h_5x5sum_c2_sum_mu->GetNbinsX() = "
139 << h_5x5sum_c2_sum_mu->GetNbinsX() << endl;
142 h_5x5sum_c2_sum_data_sub_mu->GetNbinsX()
143 == h_5x5sum_c2_sum_mu->GetNbinsX());
145 const double muon_count = h_5x5sum_c2_sum_data_sub_mu->GetSum()
146 * (mu2pi / (1 + mu2pi));
147 h_5x5sum_c2_sum_data_sub_mu->Add(h_5x5sum_c2_sum_mu,
148 -muon_count / h_5x5sum_c2_sum_mu->GetSum());
151 ge_data->SetFillColor(kGray);
152 ge_data->SetLineWidth(3);
154 TGraphErrors * ge_pi_QGSP_BERT_HP =
GetSimRejCurve(
"QGSP_BERT_HP", energy,
156 TGraphErrors * ge_kaon_QGSP_BERT_HP =
GetSimRejCurve(
"QGSP_BERT_HP", energy,
159 ge_pi_QGSP_BERT_HP->SetLineColor(kBlue);
160 ge_kaon_QGSP_BERT_HP->SetLineColor(kCyan + 3);
162 TGraphErrors * ge_pi_FTFP_BERT_HP =
GetSimRejCurve(
"FTFP_BERT_HP", energy,
164 TGraphErrors * ge_kaon_FTFP_BERT_HP =
GetSimRejCurve(
"FTFP_BERT_HP", energy,
167 ge_pi_FTFP_BERT_HP->SetLineColor(kBlue);
168 ge_kaon_FTFP_BERT_HP->SetLineColor(kCyan + 3);
169 ge_pi_FTFP_BERT_HP->SetLineStyle(kDashed);
170 ge_kaon_FTFP_BERT_HP->SetLineStyle(kDashed);
172 TGraphErrors * ge_pi_BirkConst18 =
GetSimRejCurve(
"BirkConst0.18", energy,
174 TGraphErrors * ge_kaon_BirkConst18 =
GetSimRejCurve(
"BirkConst0.18", energy,
177 ge_pi_BirkConst18->SetLineColor(kBlue);
178 ge_kaon_BirkConst18->SetLineColor(kCyan + 3);
179 ge_pi_BirkConst18->SetLineStyle(9);
180 ge_kaon_BirkConst18->SetLineStyle(9);
186 TGraphErrors * ge_ref = ge_pi_QGSP_BERT_HP->Clone(
"ge_ref");
188 for (
int i = 0;
i < ge_ref->GetN(); ++
i)
190 (ge_ref->GetY())[
i] = ((ge_pi_QGSP_BERT_HP->GetY())[
i]
191 + (ge_kaon_QGSP_BERT_HP->GetY())[
i]) / 2.;
195 TCanvas *c1 =
new TCanvas(
"RejectionCompare_" + energy +
"GeV_",
196 "RejectionCompare_" + energy +
"GeV_", 800, 1000);
200 p = (TPad *) c1->cd(idx++);
204 p->SetBottomMargin(0.03);
206 TH1 * hframe = p->DrawFrame(0, 5
e-4,
E * 1, 1);
209 ";;1/(Hadron Rejection)",
211 hframe->GetXaxis()->SetLabelSize(.06);
212 hframe->GetXaxis()->SetTitleSize(.06);
213 hframe->GetYaxis()->SetLabelSize(.06);
214 hframe->GetYaxis()->SetTitleSize(.06);
215 hframe->GetYaxis()->SetTitleOffset(0.8);
220 ge_pi_QGSP_BERT_HP->Draw(
"lX");
221 ge_kaon_QGSP_BERT_HP->Draw(
"lX");
222 ge_pi_FTFP_BERT_HP->Draw(
"lX");
223 ge_kaon_FTFP_BERT_HP->Draw(
"lX");
224 ge_pi_BirkConst18->Draw(
"lX");
225 ge_kaon_BirkConst18->Draw(
"lX");
227 TLegend *
leg =
new TLegend(.12, .05, .72, .5);
228 leg->SetHeader(Form(
"Beam momentum = -%.0f GeV/c",
E));
229 leg->AddEntry(ge_data,
"T-1044 non-e^{-} Data - Muon Sim.",
"fl");
230 leg->AddEntry(ge_pi_QGSP_BERT_HP,
"\pi^{-}, QGSP_BERT_HP (Default)",
"l");
231 leg->AddEntry(ge_kaon_QGSP_BERT_HP,
"K^{-}, QGSP_BERT_HP (Default)",
"l");
232 leg->AddEntry(ge_pi_FTFP_BERT_HP,
"\pi^{-}, FTFP_BERT_HP",
"l");
233 leg->AddEntry(ge_kaon_FTFP_BERT_HP,
"K^{-}, FTFP_BERT_HP",
"l");
234 leg->AddEntry(ge_pi_BirkConst18,
"\pi^{-}, k_{B} = 0.18 mm/MeV",
"l");
235 leg->AddEntry(ge_kaon_BirkConst18,
"K^{-}, k_{B} = 0.18 mm/MeV",
"l");
239 p = (TPad *) c1->cd(idx++);
245 p->DrawFrame(0, 0,
E * 1, 2);
248 ";Minimal cut on 5x5 Cluster Energy (GeV/c);Ratio of 1/(Hadron Rejection) and Ref.",
250 hframe->GetXaxis()->SetLabelSize(.06);
251 hframe->GetXaxis()->SetTitleSize(.06);
252 hframe->GetYaxis()->SetLabelSize(.06);
253 hframe->GetYaxis()->SetTitleSize(.06);
254 hframe->GetYaxis()->SetTitleOffset(0.8);
258 ge_data_ratio->Draw(
"p3");
259 ge_data_ratio->Draw(
"lX");
269 data_file +
"_DrawPrototype2ShowerCalib_Sum" + TString(c1->GetName()),
278 "/phenix/u/jinhuang/links/sPHENIX_work/Prototype_2016/EMCal_sim/./0Degree_1Col_LightCollectionSeanStoll_"
279 + physics_lst +
"/Prototype_" + particle +
"_" + energy
280 +
"_SegALL_EMCalCalib.root_DrawPrototype2ShowerCalib_LineShapeSim_0DegreeRot_h5_v5_col2_row2.root";
281 cout <<
"GetSimRejCurve - processing " << filename << endl;
283 TFile *
f =
new TFile(filename);
287 (TH1F *) f->Get(
"h_5x5sum_c2_sum"));
296 const TString physics_lst =
"QGSP_BERT_HP")
301 TString
energy(Form(
"%.0f",
E));
304 TCanvas *c1 =
new TCanvas(
"LineShapeCompare_" + energy +
"GeV_" + physics_lst,
305 "LineShapeCompare_" + energy +
"GeV_" + physics_lst, 1000, 650);
310 p = (TPad *) c1->cd(idx++);
315 "/phenix/u/jinhuang/links/sPHENIX_work/Prototype_2016/ShowerCalib/Tilt0.lst_EMCalCalib.root_DrawPrototype2ShowerCalib_LineShapeData_Neg"
316 + energy +
"GeV_quality_h12345_v34567_col2_row2.root");
318 TFile * fdata =
new TFile(data_file);
321 TH1F * h_5x5sum_c2_sum_data = fdata->Get(
"h_5x5sum_c2_h3")->Clone(
322 "h_5x5sum_c2_sum_data");
323 assert(h_5x5sum_c2_sum_data);
325 h_5x5sum_c2_sum_data->Scale(1. / h_5x5sum_c2_sum_data->GetSum());
326 h_5x5sum_c2_sum_data->SetLineColor(kBlack);
329 h_5x5sum_c2_sum_data->Draw();
333 "/phenix/u/jinhuang/links/sPHENIX_work/Prototype_2016/EMCal_sim/./0Degree_1Col_LightCollectionSeanStoll_"
334 + physics_lst +
"/Prototype_pi-_" + energy
335 +
"_SegALL_EMCalCalib.root_DrawPrototype2ShowerCalib_LineShapeSim_0DegreeRot_h5_v5_col2_row2.root");
338 TH1F * h_5x5sum_c2_sum_pi = fpi->Get(
"h_5x5sum_c2_sum")->Clone(
339 "h_5x5sum_c2_sum_pi");
340 assert(h_5x5sum_c2_sum_pi);
342 h_5x5sum_c2_sum_pi->Scale((1. / (1 + mu2pi)) / h_5x5sum_c2_sum_pi->GetSum());
343 h_5x5sum_c2_sum_pi->SetLineColor(kBlue);
346 h_5x5sum_c2_sum_pi->Draw(
"same");
350 "/phenix/u/jinhuang/links/sPHENIX_work/Prototype_2016/EMCal_sim/./0Degree_1Col_LightCollectionSeanStoll_"
351 + physics_lst +
"/Prototype_kaon-_" + energy
352 +
"_SegALL_EMCalCalib.root_DrawPrototype2ShowerCalib_LineShapeSim_0DegreeRot_h5_v5_col2_row2.root");
355 TH1F * h_5x5sum_c2_sum_kaon = fkaon->Get(
"h_5x5sum_c2_sum")->Clone(
356 "h_5x5sum_c2_sum_kaon");
357 assert(h_5x5sum_c2_sum_kaon);
359 h_5x5sum_c2_sum_kaon->Scale(
360 (1. / (1 + mu2pi)) / h_5x5sum_c2_sum_kaon->GetSum());
361 h_5x5sum_c2_sum_kaon->SetLineColor(kCyan + 3);
364 h_5x5sum_c2_sum_kaon->Draw(
"same");
368 "/phenix/u/jinhuang/links/sPHENIX_work/Prototype_2016/EMCal_sim/./0Degree_1Col_LightCollectionSeanStoll_"
369 + physics_lst +
"/Prototype_mu-_" + energy
370 +
"_SegALL_EMCalCalib.root_DrawPrototype2ShowerCalib_LineShapeSim_0DegreeRot_h5_v5_col2_row2.root");
372 cout <<
"Processing " << fmu->GetName() << endl;
374 TH1F * h_5x5sum_c2_sum_mu = fmu->Get(
"h_5x5sum_c2_sum")->Clone(
375 "h_5x5sum_c2_sum_mu");
376 assert(h_5x5sum_c2_sum_mu);
378 h_5x5sum_c2_sum_mu->Scale(
379 (mu2pi / (1 + mu2pi)) / h_5x5sum_c2_sum_mu->GetSum());
380 h_5x5sum_c2_sum_mu->SetLineColor(kBlack);
383 h_5x5sum_c2_sum_mu->Draw(
"same");
388 data_file +
"_DrawPrototype2ShowerCalib_Sum" + TString(c1->GetName()),
395 const TString physics_lst =
"QGSP_BERT_HP")
398 TString
energy(Form(
"%.0f",
E));
401 TCanvas *c1 =
new TCanvas(
402 "LineShapeCompare_Electron_" + energy +
"GeV_" + physics_lst,
403 "LineShapeCompare_Electron_" + energy +
"GeV_" + physics_lst, 1000, 650);
408 p = (TPad *) c1->cd(idx++);
413 "/phenix/u/jinhuang/links/sPHENIX_work/Prototype_2016/ShowerCalib/Tilt0.lst_EMCalCalib.root_DrawPrototype2ShowerCalib_LineShapeData_Neg"
414 + energy +
"GeV_quality_h3_v5_col2_row2.root");
416 TFile * fdata =
new TFile(data_file);
419 TH1F * h_5x5sum_c2_sum_data = fdata->Get(
"h_5x5sum_c2_e");
420 assert(h_5x5sum_c2_sum_data);
422 h_5x5sum_c2_sum_data->Scale(1. / h_5x5sum_c2_sum_data->GetSum());
423 h_5x5sum_c2_sum_data->SetLineColor(kBlack);
426 h_5x5sum_c2_sum_data->Draw();
430 "/phenix/u/jinhuang/links/sPHENIX_work/Prototype_2016/EMCal_sim/./0Degree_1Col_LightCollectionSeanStoll_"
431 + physics_lst +
"/Prototype_e-_" + energy
432 +
"_SegALL_EMCalCalib.root_DrawPrototype2ShowerCalib_LineShapeSim_0DegreeRot_h1_v1_col2_row2.root");
435 TH1F * h_5x5sum_c2_sum_e = fe->Get(
"h_5x5sum_c2_sum");
436 assert(h_5x5sum_c2_sum_e);
438 h_5x5sum_c2_sum_e->Scale((0.27 / 0.30) / h_5x5sum_c2_sum_e->GetSum());
439 h_5x5sum_c2_sum_e->SetLineColor(kBlue + 3);
442 h_5x5sum_c2_sum_e->Draw(
"same");
447 data_file +
"_DrawPrototype2ShowerCalib_Sum" + TString(c1->GetName()),
455 TProfile * p2 = h2->ProfileX();
463 for (
int i = 1;
i <= h2->GetNbinsX();
i++)
465 TH1D *
h1 = h2->ProjectionY(Form(
"htmp_%d", rand()),
i,
i);
467 if (h1->GetSum() < 30)
469 cout <<
"FitProfile - ignore bin " <<
i << endl;
474 cout <<
"FitProfile - fit bin " <<
i << endl;
477 TF1 fgaus(
"fgaus",
"gaus", -p2->GetBinError(
i) * 4,
478 p2->GetBinError(
i) * 4);
480 TF1
f2(Form(
"dgaus"),
"gaus + [3]*exp(-0.5*((x-[1])/[4])**2) + [5]",
481 -p2->GetBinError(
i) * 4, p2->GetBinError(
i) * 4);
483 fgaus.SetParameter(1, p2->GetBinContent(
i));
484 fgaus.SetParameter(2, p2->GetBinError(
i));
486 h1->Fit(&fgaus,
"MQ");
488 f2.SetParameters(fgaus.GetParameter(0) / 2, fgaus.GetParameter(1),
489 fgaus.GetParameter(2), fgaus.GetParameter(0) / 2,
490 fgaus.GetParameter(2) / 4, 0);
499 x[
n] = p2->GetBinCenter(
i);
500 ex[
n] = (p2->GetBinCenter(2) - p2->GetBinCenter(1)) / 2;
501 y[
n] = fgaus.GetParameter(1);
502 ey[
n] = fgaus.GetParError(1);
511 return new TGraphErrors(n, x, y, ex, ey);
517 double threshold[10000] =
521 double eff_err[10000] =
524 assert(hCEMC3_Max->GetNbinsX() < 10000);
526 const double n = hCEMC3_Max->GetSum();
529 for (
int i = hCEMC3_Max->GetNbinsX();
i >= 1;
i--)
531 pass += hCEMC3_Max->GetBinContent(
i);
533 const double pp = pass /
n;
537 const double A = z * sqrt(1. / n * pp * (1 - pp) + z * z / 4 / n / n);
538 const double B = 1 / (1 + z * z /
n);
540 threshold[cnt] = hCEMC3_Max->GetBinCenter(
i);
541 eff[cnt] = (pp + z * z / 2 /
n) * B;
542 eff_err[cnt] = A * B;
548 TGraphErrors * ge =
new TGraphErrors(cnt, threshold, eff, NULL, eff_err);
549 ge->SetName(TString(
"ge_") + hCEMC3_Max->GetName());
559 assert(input->GetN() == baseline->GetN());
561 TGraphErrors * ge = input->Clone(TString(input->GetName()) +
"_Ratio");
563 for (
int i = 0;
i < input->GetN(); ++
i)
565 (ge->GetY())[
i] /= (baseline->GetY())[
i];
566 (ge->GetEY())[
i] /= (baseline->GetY())[
i];