2 #include <TPaveStats.h>
9 #include "FitSpectra.h"
16 const std::vector<Color_t> vParticleColor = {kOrange, kMagenta, kRed, kBlue, kBlack, kYellow, kGreen+3, kAzure+10};
22 void RedrawBorder(
bool isYLinear =
false)
29 double ymin = pow(10, gPad->GetUymin());
30 double ymax = pow(10, gPad->GetUymax());
32 if (isYLinear ==
true)
34 ymin = gPad->GetUymin();
35 ymax = gPad->GetUymax();
38 l.DrawLine(gPad->GetUxmin(), ymin, gPad->GetUxmax(), ymin);
39 l.DrawLine(gPad->GetUxmin(), ymin, gPad->GetUxmin(), ymax);
40 l.DrawLine(gPad->GetUxmin(), ymax, gPad->GetUxmax(), ymax);
41 l.DrawLine(gPad->GetUxmax(), ymin, gPad->GetUxmax(), ymax);
47 void PrintDxDy (TH2D * h,
const string name,
const string year)
49 TCanvas * c1 =
new TCanvas(
"c1",
"c1", 1200, 1200);
51 gStyle->SetOptStat(0);
56 c1->SetTopMargin(0.04);
57 c1->SetBottomMargin(0.09);
58 c1->SetRightMargin(0.15);
59 c1->SetLeftMargin(0.09);
61 h->GetZaxis()->SetTitle(
"Counts");
62 h->GetXaxis()->SetTitleOffset(1.2);
63 h->GetYaxis()->SetTitleOffset(1.1);
64 h->GetZaxis()->SetTitleOffset(1.3);
66 h->SetAxisRange(-6, 6,
"X");
67 h->SetAxisRange(-6, 6,
"Y");
75 string filename = name + h->GetName() +
"_" + year +
".png";
76 c1->SaveAs(filename.c_str());
84 void Print1DMassSqFits (
const TH1D * h1, vector<TH1D*> vFits,
const string name,
const string year,
bool titleOn =
false)
89 cerr<<
"[WARNING]: Specified histogram not found!"<<endl;
93 TH1D * h = (TH1D*)h1->Clone();
97 gStyle->SetOptStat(0);
99 TCanvas * c1 =
new TCanvas(
"c1",
"c1", 1800, 1200);
100 TPad * pad0 =
new TPad(
"pad0",
"The top pad with 70% of the height", 0, 0.3, 1, 1);
101 TPad * pad1 =
new TPad(
"pad1",
"The bottom pad with 30% of the height", 0, 0, 1, 0.3);
111 pad0->SetTopMargin(0.03);
112 pad0->SetBottomMargin(0.005);
113 pad0->SetRightMargin(0.02);
114 pad0->SetLeftMargin(0.1);
118 pad0->SetTopMargin(0.08);
119 gStyle->SetTitleX(0.5);
120 gStyle->SetTitleAlign(23);
121 gStyle->SetTitleBorderSize(0);
125 h->GetXaxis()->SetTitleOffset(1.3);
126 h->GetYaxis()->SetTitle(
"Counts");
127 h->GetYaxis()->SetTitleOffset(0.65);
128 h->GetYaxis()->SetTitleSize(0.07);
131 h->SetAxisRange(xMin, 4.9,
"X");
134 TLegend * leg =
new TLegend(0.15, 0.6, 0.4, 0.9);
138 leg->SetFillStyle(0);
139 leg->SetBorderSize(0);
140 leg->AddEntry(h,
"Data",
"LE");
142 vector<string> legLabel = {
"Fit total",
"Fit kaon",
"Fit proton",
"Fit deuteron",
"Fit pion",
"Fit electron"};
143 vector<Color_t> colors = {kRed, kGreen, kBlack, kAzure+10, kBlue, kMagenta};
144 for (
int k =
int(vFits.size())-1; k >= 0; k--)
147 vFits[k]->SetLineStyle(9);
149 vFits[k]->Rebin(rebin);
150 vFits[k]->SetLineColor(colors[k]);
151 vFits[k]->SetLineWidth(3);
152 vFits[k]->Draw(
"SAME");
153 leg->AddEntry(vFits[k], legLabel[k].c_str(),
"l");
166 pad1->SetTopMargin(0.005);
167 pad1->SetBottomMargin(0.35);
168 pad1->SetRightMargin(0.02);
169 pad1->SetLeftMargin(0.1);
171 TH1D * hRatio = GetRatioTH1D(h, vFits[0]);
172 hRatio->SetTitle(
"");
173 hRatio->SetLineColor(kBlack);
174 hRatio->SetLineWidth(3);
175 hRatio->SetMarkerSize(5);
176 hRatio->SetMinimum(0.1);
177 hRatio->SetMaximum(5);
178 hRatio->SetAxisRange(xMin, 4.9,
"X");
179 hRatio->GetXaxis()->SetTitleOffset(1.0);
180 hRatio->GetXaxis()->SetTitleSize(0.16);
181 hRatio->GetXaxis()->SetLabelSize(0.12);
182 hRatio->GetYaxis()->SetTitle(
"Data/Model");
183 hRatio->GetYaxis()->SetTitleOffset(0.3);
184 hRatio->GetYaxis()->SetTitleSize(0.15);
185 hRatio->GetYaxis()->SetLabelSize(0.08);
186 hRatio->Draw(
"E1 C P X0");
189 TLine * line =
new TLine(xMin, 1, 5.0, 1);
190 line->SetLineColor(kRed);
191 line->SetLineWidth(3);
199 string filename = name + h->GetName() +
"_" + year +
".png";
200 c1->SaveAs(filename.c_str());
211 void Print1DMassSqFitsNoRatio (
const TH1D * h1,
215 bool titleOn =
false,
216 double d_norm_PercentErr = 0,
217 double chiSquaredperNDF = 0)
222 cerr<<
"[WARNING]: Specified histogram not found!"<<endl;
226 TH1D * h = (TH1D*)h1->Clone();
230 gStyle->SetOptStat(0);
232 TCanvas * c1 =
new TCanvas(
"c1",
"c1", 1200, 1200);
238 c1->SetTopMargin(0.03);
239 c1->SetBottomMargin(0.12);
240 c1->SetRightMargin(0.02);
241 c1->SetLeftMargin(0.11);
245 c1->SetTopMargin(0.08);
246 gStyle->SetTitleX(0.55);
247 gStyle->SetTitleAlign(23);
248 gStyle->SetTitleBorderSize(0);
253 gStyle->SetTitleW(0.9);
257 h->GetXaxis()->SetTitle(
"TOF m^{2} (GeV/c^{2})^{2}");
258 h->GetXaxis()->SetTitleOffset(0.70);
259 h->GetXaxis()->SetTitleSize(0.07);
260 h->GetYaxis()->SetTitle(
"Counts");
261 h->GetYaxis()->SetTitleOffset(0.75);
262 h->GetYaxis()->SetTitleSize(0.07);
264 h->SetAxisRange(xMin, 4.9,
"X");
266 h->SetLineColor(kBlack);
267 h->SetMarkerStyle(20);
271 TLegend * leg =
new TLegend(0.12, 0.60, 0.4, 0.90);
275 leg->SetFillStyle(0);
276 leg->SetBorderSize(0);
277 leg->AddEntry(h,
"Data",
"PE");
279 vector<string> legLabel = {
"Fit total",
"Fit kaon",
"Fit proton",
"Fit deuteron",
"Fit pion",
"Fit electron"};
280 vector<Color_t> colors = {kRed, kMagenta, kBlue, kAzure+10, kYellow, kGreen};
281 for (
int k =
int(vFits.size())-1; k >= 0; k--)
284 vFits[k]->SetLineStyle(9);
287 vFits[k]->SetLineWidth(5);
289 vFits[k]->SetLineWidth(3);
291 vFits[k]->Rebin(rebin);
292 vFits[k]->SetLineColor(colors[k]);
293 vFits[k]->Draw(
"SAME");
294 leg->AddEntry(vFits[k], legLabel[k].c_str(),
"l");
301 TPaveText * pt1 = NULL;
302 if (vFits[3]->GetMaximum() > 5)
304 pt1 =
new TPaveText(0.71, 0.40, 0.95, 0.60,
"NB NDC");
305 pt1->SetTextSize(0.06);
306 pt1->SetTextColor(kAzure+10);
307 pt1->SetFillColor(0);
308 pt1->SetFillStyle(0);
309 pt1->SetBorderSize(0);
311 pt1->AddText(
"Deuteron");
316 TPaveText * pt2 =
new TPaveText(0.60, 0.77, 0.7, 0.90,
"NB NDC");
317 pt2->SetTextSize(0.06);
318 pt2->SetTextColor(kBlue);
319 pt2->SetFillColor(0);
320 pt2->SetFillStyle(0);
321 pt2->SetBorderSize(0);
323 pt2->AddText(
"Proton");
327 TPaveText * pt3 = NULL;
328 if (d_norm_PercentErr > 0 && vFits[3]->GetMaximum() > 0.5)
330 pt3 =
new TPaveText(0.70, 0.55, 0.94, 0.60,
"NB NDC");
331 pt3->SetTextSize(0.025);
332 pt3->SetFillColor(0);
333 pt3->SetFillStyle(0);
334 pt3->SetBorderSize(0);
335 pt3->AddText(Form(
"Amplitude error = %5.2f%%", d_norm_PercentErr));
338 pt3 =
new TPaveText(0.70, 0.60, 0.94, 0.65,
"NB NDC");
339 pt3->SetTextSize(0.025);
340 pt3->SetFillColor(0);
341 pt3->SetFillStyle(0);
342 pt3->SetBorderSize(0);
343 pt3->AddText(Form(
"Chi-sq/NDF = %5.2f", chiSquaredperNDF));
349 h->Draw(
"P E1 X0 SAME");
351 string filename = name + h->GetName() +
"_" + year +
".png";
352 c1->SaveAs(filename.c_str());
370 void Print1DMassSqFits (TH1D * h1, vector<TF1*> vFits,
const string name,
const string year,
bool titleOn =
false)
375 cerr<<
"[WARNING]: Specified histogram not found!"<<endl;
379 TH1D * h = (TH1D*)h1->Clone();
381 TCanvas * c1 =
new TCanvas(
"c1",
"c1", 1800, 1200);
382 gStyle->SetOptStat(0);
387 c1->SetTopMargin(0.03);
388 c1->SetBottomMargin(0.1);
389 c1->SetRightMargin(0.05);
390 c1->SetLeftMargin(0.1);
394 c1->SetTopMargin(0.08);
395 gStyle->SetTitleX(0.5);
396 gStyle->SetTitleAlign(23);
397 gStyle->SetTitleBorderSize(0);
400 h->GetYaxis()->SetTitle(
"Counts");
401 h->GetXaxis()->SetTitleOffset(1.3);
402 h->GetYaxis()->SetTitleOffset(1.3);
408 std::vector<Color_t> colors = {kRed, kGreen, kBlack, kAzure+10, kBlue, kMagenta};
409 for (
int k =
int(vFits.size())-1; k >= 0; k--)
412 vFits[k]->SetLineStyle(9);
414 vFits[k]->SetLineColor(colors[k]);
415 vFits[k]->SetLineWidth(3);
416 vFits[k]->Draw(
"HIST SAME L X0");
422 string filename = name + h->GetName() +
"_" + year +
".png";
423 c1->SaveAs(filename.c_str());
434 void Print1DHist (
const TH1D * h1,
438 bool titleOn =
false,
444 const string &YAxisTitle =
"Counts")
449 cerr<<
"[WARNING]: Specified histogram "<<name<<
" not found!"<<endl;
453 TH1D * h = (TH1D*)h1->Clone();
455 TCanvas * c1 =
new TCanvas(
"c1",
"c1", 1200, 1200);
456 gStyle->SetOptStat(0);
461 c1->SetTopMargin(0.04);
462 c1->SetBottomMargin(0.1);
463 c1->SetRightMargin(0.05);
464 c1->SetLeftMargin(0.1);
468 c1->SetTopMargin(0.08);
469 gStyle->SetTitleX(0.5);
470 gStyle->SetTitleAlign(23);
471 gStyle->SetTitleBorderSize(0);
474 h->GetYaxis()->SetTitle(YAxisTitle.c_str());
475 h->GetXaxis()->SetTitleOffset(1.3);
476 h->GetYaxis()->SetTitleOffset(1.3);
482 if (zMax > 0) h->SetMaximum(zMax);
483 if (xMax != xMin) h->SetAxisRange(xMin, xMax,
"X");
490 string filename = name + h->GetName() +
"_" + year +
".png";
491 c1->SaveAs(filename.c_str());
502 void Print2DHist (
const TH2D * h1,
507 const string &YAxisTitle =
"Counts")
512 cerr<<
"[WARNING]: Specified histogram not found!"<<endl;
516 TH1D * h = (TH1D*)h1->Clone();
518 TCanvas * c1 =
new TCanvas(
"c1",
"c1", 1800, 1200);
519 gStyle->SetOptStat(0);
524 c1->SetTopMargin(0.03);
525 c1->SetBottomMargin(0.10);
526 c1->SetRightMargin(0.15);
527 c1->SetLeftMargin(0.1);
529 h->GetZaxis()->SetTitle(YAxisTitle.c_str());
530 h->GetXaxis()->SetTitleOffset(1.3);
531 h->GetYaxis()->SetTitleOffset(1.3);
535 if (yMax != yMin) h->SetAxisRange(yMin, yMax,
"Y");
540 string filename = name + h->GetName() +
"_" + year +
".png";
541 c1->SaveAs(filename.c_str());
550 void Print1DHistVector (
const vector<TH1D*> vHist1D,
553 bool titleOn =
false,
559 const string &YAxisTitle =
"Counts")
561 TCanvas * c1 =
new TCanvas(
"c1",
"c1", 1200, 1200);
562 gStyle->SetOptStat(0);
567 c1->SetTopMargin(0.04);
568 c1->SetBottomMargin(0.1);
569 c1->SetRightMargin(0.05);
570 c1->SetLeftMargin(0.1);
574 c1->SetTopMargin(0.08);
575 gStyle->SetTitleX(0.5);
576 gStyle->SetTitleAlign(23);
577 gStyle->SetTitleBorderSize(0);
581 TH1D * h =
new TH1D();
582 TLegend * leg =
new TLegend(0.75, 0.60, 0.94, 0.95);
584 for (
int k = 0; k < int(vHist1D.size()); k++)
586 h = (TH1D*)vHist1D[k]->Clone();
588 h->GetYaxis()->SetTitle(YAxisTitle.c_str());
589 h->GetXaxis()->SetTitleOffset(1.3);
590 h->GetYaxis()->SetTitleOffset(1.3);
593 h->SetLineColor(vParticleColor[k]);
596 if (zMax > 0) h->SetMaximum(zMax);
597 if (xMax != xMin) h->SetAxisRange(xMin, xMax,
"X");
599 if (k == 0) h->Draw(
"HIST CP");
600 else h->Draw(
"HIST CP same");
602 int p0_percent_change = -10*(k-3);
604 if (p0_percent_change > 0) p0_label =
" + " + to_string(p0_percent_change) +
"%";
605 else if (p0_percent_change == 0) p0_label =
" ";
606 else p0_label =
" - " + to_string(-p0_percent_change)+
"%";
607 leg->AddEntry(h, Form(
"p_{0}%s", p0_label.c_str()),
"l");
610 leg->SetBorderSize(0);
615 string filename = name + vHist1D[0]->GetName() +
"_" + year +
"_overlaid.png";
616 c1->SaveAs(filename.c_str());
626 void make_y_pT_plots(
const TH2D * h1,
632 string ZAxisTitle=
"Counts",
633 bool printText =
false,
634 bool zoomDeuteron =
false)
636 TH2D * h = (TH2D*)h1->Clone();
663 TCanvas *c1 =
new TCanvas(
"c1",
"c1", 1200, 1200);
666 gStyle->SetOptStat(0);
671 c1->SetTopMargin(0.04);
672 c1->SetBottomMargin(0.10);
673 c1->SetRightMargin(0.17);
674 c1->SetLeftMargin(0.13);
676 h->GetZaxis()->SetTitle(ZAxisTitle.c_str());
677 h->GetYaxis()->SetTitle(
"p_{T} (GeV/c)");
679 h->GetXaxis()->SetTitleOffset(0.95);
680 h->GetYaxis()->SetTitleOffset(1.2);
683 if (zoomDeuteron ==
false)
685 h->SetAxisRange(0, 1.9,
"Y");
686 h->SetAxisRange(-2.0, 1.9,
"X");
690 h->SetAxisRange(0, 1.0,
"Y");
691 h->SetAxisRange(-1.7, 0.3,
"X");
697 h->GetXaxis()->SetTitleSize(0.05);
698 h->GetYaxis()->SetTitleSize(0.05);
699 h->GetZaxis()->SetTitleSize(0.05);
701 if (printText ==
true)
703 gStyle->SetPaintTextFormat(
"3.1f");
704 h->SetMarkerSize(1.2);
705 h->Draw(
"colz TEXT01");
715 string filename = name + h->GetName() +
"_" + year +
".png";
716 c1->SaveAs(filename.c_str());
726 void makeNormalizationPlots(TH1D * hist_all,
const TH1D * hist_d,
const string &name,
const string &year,
bool IsPrintRMS =
false)
728 TCanvas * c1 =
new TCanvas(
"c1",
"c1", 1800, 1200);
730 double integral_all = hist_all->Integral();
731 double integral_d = hist_d->Integral();
732 double normalization = integral_all/integral_d;
734 TH1D * hist_d_scaled = (TH1D*) hist_d->Clone();
735 hist_d_scaled->Scale(normalization);
738 gStyle->SetOptStat(0);
743 c1->SetTopMargin(0.03);
744 c1->SetBottomMargin(0.1);
745 c1->SetRightMargin(0.05);
746 c1->SetLeftMargin(0.1);
748 hist_all->SetLineColor(kBlack);
749 hist_all->SetLineWidth(3);
750 hist_all->GetXaxis()->SetTitleOffset(1.3);
751 hist_all->GetYaxis()->SetTitleOffset(1.3);
754 hist_d_scaled->SetLineColor(kRed);
755 hist_d_scaled->SetLineWidth(3);
756 hist_d_scaled->Draw(
"same");
759 string filename = name + hist_all->GetName() +
"_OverlayScaled_" + year +
".png";
760 c1->SaveAs(filename.c_str());
762 if (IsPrintRMS ==
true)
763 cout<<
"RMS hist_all = "<<hist_all->GetStdDev()<<
" +/- "<<hist_all->GetStdDevError()<<
". RMS hist_d_scaled = "<<hist_d->GetStdDev()<<
" +/- "<<hist_d->GetStdDevError()<<endl;
765 delete hist_d_scaled;
776 void makeMomentumTOFmassSqPlots (TH2D * h,
const string &name,
const string &year)
781 cerr<<
"[WARNING]: Specified histogram not found!"<<endl;
785 TCanvas * c1 =
new TCanvas(
"c1",
"c1", 1800, 1200);
787 gStyle->SetOptStat(0);
792 c1->SetTopMargin(0.04);
793 c1->SetBottomMargin(0.09);
794 c1->SetRightMargin(0.12);
795 c1->SetLeftMargin(0.07);
797 h->GetZaxis()->SetTitle(
"Counts");
798 h->GetXaxis()->SetTitleOffset(1.0);
799 h->GetYaxis()->SetTitleOffset(1.0);
800 h->GetZaxis()->SetTitleOffset(0.9);
804 h->SetAxisRange(4, 15,
"X");
812 string filename = name + year +
".png";
813 c1->SaveAs(filename.c_str());
820 void PrintPhaseSpace (TH2D * h1,
const string &name,
const string &year,
bool trimPhaseSpace =
true,
int RebinX = 1,
int RebinY = 1,
bool printText =
true)
822 TH2D * h = (TH2D*)h1->Clone();
824 TCanvas * c1 =
new TCanvas(
"c1",
"c1", 1800, 1200);
825 gStyle->SetOptStat(0);
830 c1->SetTopMargin(0.04);
831 c1->SetBottomMargin(0.09);
832 c1->SetRightMargin(0.12);
833 c1->SetLeftMargin(0.07);
835 h->GetZaxis()->SetTitle(
"Counts");
836 h->GetXaxis()->SetTitleOffset(1.0);
837 h->GetYaxis()->SetTitleOffset(1.0);
838 h->GetZaxis()->SetTitleOffset(0.9);
843 if (trimPhaseSpace ==
true)
845 h->SetAxisRange(4, 15,
"X");
846 h->SetAxisRange(0, 1.9,
"Y");
853 if (printText ==
true)
855 gStyle->SetPaintTextFormat(
"4.0f");
856 h->SetMarkerSize(1.2);
857 h->Draw(
"colz TEXT");
864 string filename = name + h->GetName() +
"_" + year +
".png";
866 c1->SaveAs(filename.c_str());
876 void SimpleCleanUpDEdxTOFmassSqPlot (TH2D * h1)
880 for (
int i = 0; i <= h1->GetNbinsX(); i++)
882 double dEdx_value = h1->GetXaxis()->GetBinCenter(i);
884 for (
int j = 0; j <= h1->GetNbinsY(); j++)
886 double m2_value = h1->GetYaxis()->GetBinCenter(j);
888 if (dEdx_value > 1.16 && m2_value > 2.5)
890 h1->SetBinContent(i, j, 0);
891 h1->SetBinError(i, j, 0);
894 entries = entries + h1->GetBinContent(i, j);
898 h1->SetEntries(entries);
905 void BetheBlochCleanUpDEdxTOFmassSqPlot (TH2D * h1,
double pBinCenter)
907 double pion_dEdx_cut = BetheBlochAntoniMod(pBinCenter/0.335);
910 for (
int i = 0; i <= h1->GetNbinsX(); i++)
912 double dEdx_value = h1->GetXaxis()->GetBinCenter(i);
914 for (
int j = 0; j <= h1->GetNbinsY(); j++)
916 double m2_value = h1->GetYaxis()->GetBinCenter(j);
918 if (dEdx_value > pion_dEdx_cut && m2_value > 2.5)
920 h1->SetBinContent(i, j, 0);
921 h1->SetBinError(i, j, 0);
924 entries = entries + h1->GetBinContent(i, j);
928 h1->SetEntries(entries);
936 void makedEdxTOFmassSqPlots (TH2D * h1,
double pBinCenter,
int RebinY,
const string &name,
string year,
bool titleOn =
false,
bool cleanUpPions =
false,
string drawBox =
"",
int nD = 0)
941 cerr<<
"[WARNING]: Specified histogram not found!"<<endl;
945 TH2D * h = (TH2D*)h1->Clone();
947 TCanvas * c1 =
new TCanvas(
"c1",
"c1", 1800, 1200);
948 gStyle->SetOptStat(0);
953 c1->SetBottomMargin(0.09);
954 c1->SetRightMargin(0.12);
955 c1->SetLeftMargin(0.07);
957 if (titleOn ==
false)
959 c1->SetTopMargin(0.04);
962 else c1->SetTopMargin(0.1);
964 h->GetZaxis()->SetTitle(
"Counts");
965 h->GetXaxis()->SetTitleOffset(1.0);
966 h->GetYaxis()->SetTitleOffset(1.0);
967 h->GetZaxis()->SetTitleOffset(0.9);
974 if (pBinCenter < 0) cleanUpPions =
false;
975 if (cleanUpPions ==
true)
978 BetheBlochCleanUpDEdxTOFmassSqPlot(h, pBinCenter);
979 year = year +
"_PionRemoved";
982 h->SetAxisRange(0.8, 1.78,
"X");
989 if (drawBox ==
"deuteron")
991 TBox * DeuteronBox =
new TBox(0.9, 3.16, 1.2, 4.2);
992 DeuteronBox->SetFillColorAlpha(0, 0.);
993 DeuteronBox->SetFillStyle(0);
994 DeuteronBox->SetLineColor(kRed);
995 DeuteronBox->SetLineWidth(4);
1002 gStyle->SetOptStat(
"e");
1003 TPaveStats * st = (TPaveStats*)c1->GetPrimitive(
"stats");
1011 TPaveText * pt =
new TPaveText(0.60, 0.80, 0.85, 0.84,
"NB NDC");
1012 pt->SetTextSize(0.04);
1013 pt->SetFillColor(0);
1015 pt->AddText(Form(
"nDeuterons = %d", nD));
1020 if (drawBox ==
"piMinus")
1022 TBox * PiMinusBox =
new TBox(1.22, -0.5, 1.40, 0.5);
1023 PiMinusBox->SetFillColorAlpha(0, 0.);
1024 PiMinusBox->SetFillStyle(0);
1025 PiMinusBox->SetLineColor(kBlack);
1026 PiMinusBox->SetLineWidth(4);
1031 string filename = name + year +
".png";
1033 c1->SaveAs(filename.c_str());
1041 void Make_YPt_ParticleSpectra (
const TH2D * h,
1042 const string &particle_name,
1043 const string &MC_type,
1047 int rapidity_bin_max_data,
1048 int rapidity_bin_min_data,
1049 bool makeFit =
false,
1050 bool isLogYAxis =
true,
1051 bool doScaling =
true,
1052 bool showEPOS =
false)
1054 double pT_max = 1.6;
1055 if (particle_name ==
"deuteron" && makeFit == 0) pT_max = 1.0;
1056 else if (particle_name ==
"deuteron" && makeFit == 1) pT_max = 1.0;
1057 else if (particle_name ==
"proton" && makeFit == 0) pT_max = 1.6;
1058 else if (particle_name ==
"proton" && makeFit == 1) pT_max = 1.8;
1060 TMultiGraph * MG1 =
new TMultiGraph();
1074 vector<TGraphErrors*> vDataGraphs = GetGraphsfromTH2D(h, year, particle_name, rapidity_bin_max_data, rapidity_bin_min_data, doScaling);
1075 for (
int k = 0; k < int(vDataGraphs.size()); k++)
1077 vDataGraphs[k] = RemoveZeroFromGraph(vDataGraphs[k]);
1078 vDataGraphs[k]->SetLineWidth(5);
1079 vDataGraphs[k]->SetLineColor(vParticleColor[k]);
1080 vDataGraphs[k]->SetMarkerSize(2);
1081 vDataGraphs[k]->SetMarkerStyle(20);
1082 vDataGraphs[k]->SetMarkerColor(vParticleColor[k]);
1084 if (makeFit ==
true)
1085 MG1->Add(vDataGraphs[k],
"p");
1087 MG1->Add(vDataGraphs[k],
"cp");
1092 TCanvas * c2 =
new TCanvas(
"c2",
"c2", 1600, 1600);
1093 c2->SetLogy(isLogYAxis);
1096 c2->SetLeftMargin(0.19);
1097 c2->SetRightMargin(0.025);
1098 c2->SetBottomMargin(0.12);
1099 c2->SetTopMargin(0.02);
if (!isLogYAxis) c2->SetTopMargin(0.04);
1104 vector<TF1*> vDataFits;
1105 if (makeFit ==
true)
1107 vector<TGraphErrors*> vGFitConfidenceBands;
1108 vector<int> vMissingPointIndex;
1109 vDataFits = GetPtSpectraFitAndEval(vDataGraphs, vGFitConfidenceBands, vMissingPointIndex, particle_name);
1112 for (
int k = 0; k < int(vDataFits.size()); k++)
1114 vDataFits[k]->SetLineColor(vParticleColor[k]);
1115 vDataFits[k]->SetLineWidth(3);
1116 vDataFits[k]->Draw(
"same");
1118 if (particle_name ==
"deuteron")
1120 vGFitConfidenceBands[k]->SetFillColorAlpha(vParticleColor[k]-2, 0.30);
1121 vGFitConfidenceBands[k]->SetFillStyle(1001);
1122 vGFitConfidenceBands[k]->Draw(
"e3 same");
1129 if (showEPOS ==
true)
1131 cerr<<
"\n[INFO] Adding EPOS comparisons..."<<endl;
1132 const vector<double> vP0 = {109.45, 101.03, 92.61, 84.19, 75.77, 67.35, 58.94};
1135 double pT_max_EPOS = 1.0;
1136 int j_min = 3;
int j_max = 4;
1137 int y_bin_min_EPOS = 48;
int y_bin_max_EPOS = 51;
1138 if (particle_name ==
"deuteron")
1141 j_min = 0; j_max = int(vP0.size());
1142 y_bin_min_EPOS = 45; y_bin_max_EPOS = 48;
1146 for (
int j = j_min; j < j_max; j++)
1148 vector<TGraphErrors*> vG_EPOS = GetEPOS_Y_PT_Spectra_Graphs(particle_name, vP0[j], 2, doScaling, pT_max_EPOS, y_bin_max_EPOS, y_bin_min_EPOS);
1149 if (vDataGraphs.size() != vG_EPOS.size())
1150 cerr<<
"\n\n[WARNING] DataGraphs size != vG_EPOS size"<<endl;
1154 if (particle_name ==
"proton")
1156 vector<TGraphErrors*> vGFitConfidenceBands;
1157 vector<TF1*> vEPOSTestFits = GetPtSpectraFit(vG_EPOS, vGFitConfidenceBands, particle_name,
true, 0.139, 0.1, 1.5,
false);
1158 for (
int k = 0; k < int(vG_EPOS.size()); k++)
1160 vEPOSTestFits[k]->SetLineColor(vParticleColor[k]);
1161 vEPOSTestFits[k]->SetLineWidth(1);
1162 vEPOSTestFits[k]->Draw(
"c same");
1167 for (
int k = 0; k < int(vG_EPOS.size()); k++)
1169 vG_EPOS[k]->SetLineColor(vParticleColor[k]);
1170 vG_EPOS[k]->SetLineWidth(1);
1171 vG_EPOS[k]->SetLineStyle(2);
1172 vG_EPOS[k]->Draw(
"c same");
1177 if (particle_name ==
"deuteron")
1179 vector<TGraphAsymmErrors*> vG_EPOSBands = GetEPOS_Y_PT_SpectraBand_Graphs(particle_name);
1180 if (vG_EPOSBands.size() != vDataGraphs.size()) cerr<<
"\n\n[WARNING] vG_EPOSBands size != vDataGraphs size"<<endl;
1181 for (
int k = 0; k < int(vG_EPOSBands.size()); k++)
1184 vG_EPOSBands[k]->SetFillColorAlpha(vParticleColor[k]-2, 0.3);
1186 vG_EPOSBands[k]->SetFillColorAlpha(vParticleColor[k]-2, 0.3);
1188 vG_EPOSBands[k]->SetFillStyle(3008);
1189 vG_EPOSBands[k]->Draw(
"e3 same");
1193 cerr<<
"[INFO] Completed EPOS comparisons.\n\n"<<endl;
1198 TLegend * leg = GetTLegend(particle_name, year,
"ExtraPoints");
1199 for (
int k = 0; k < int(vDataGraphs.size()); k++)
1201 if (makeFit ==
true)
1204 leg->AddEntry(vDataGraphs[k], Form(
"#times10^{%d} y = %0.1f, T=%4.1f MeV", -1*k, -1.9+2*
double(k+rapidity_bin_min_data-1)/10, 1000*vDataFits[k]->GetParameter(1)),
"l");
1206 leg->AddEntry(vDataGraphs[k], Form(
"y = %0.1f, T=%4.1f MeV", -1.9+2*
double(k+rapidity_bin_min_data-1)/10, 1000*vDataFits[k]->GetParameter(1)),
"l");
1212 leg->AddEntry(vDataGraphs[k], Form(
"#times10^{%d} y = %0.1f", -1*k, -1.9+2*
double(k+rapidity_bin_min_data-1)/10),
"pl");
1214 leg->AddEntry(vDataGraphs[k], Form(
"y = %0.1f", -1.9+2*
double(k+rapidity_bin_min_data-1)/10),
"pl");
1217 leg->SetBorderSize(0);
1222 MG1->GetXaxis()->SetTitle(
"p_{T} (GeV/c)");
1223 MG1->GetXaxis()->SetTitleOffset(1.0);
1224 MG1->GetXaxis()->SetTitleSize(0.05);
1225 MG1->GetYaxis()->SetTitle(
"#frac{d^{2}n}{dydp_{T}} (GeV/c)^{-1}");
1226 MG1->GetYaxis()->SetTitleOffset(1.65);
1227 MG1->GetYaxis()->SetTitleSize(0.05);
1228 MG1->GetHistogram()->SetMaximum(yAxis_max);
1229 MG1->GetHistogram()->SetMinimum(yAxis_min);
1230 MG1->GetXaxis()->SetLimits(0.0, pT_max);
1233 string name =
"plots_spectra/" + particle_name +
"/" +
"spectra_" + to_string(
int(year)) +
"_" + particle_name +
"_" + MC_type +
".png";
1234 c2->SaveAs(name.c_str());
1236 bool makePDFtoPNG =
false;
1237 if (makePDFtoPNG ==
true && makeFit ==
true && showEPOS ==
true)
1239 name =
"plots_spectra/" + particle_name +
"/" +
"spectra_" + to_string(
int(year)) +
"_" + particle_name +
"_" + MC_type +
".pdf";
1240 c2->SaveAs(name.c_str());
1242 std::string command = std::string(
"pdftoppm -png -rx 300 -ry 300 -cropbox ") + name +
" " + name;
1243 int conversion_exit_code = system(command.c_str());
1244 cerr<<
"'"<<command<<
"' returned with code "<<conversion_exit_code<<endl;
1254 void Make_YPt_1DParticleSpectraStacked (
const TH2D * h,
1255 const string &particle_name,
1256 const string &MC_type,
1260 int rapidity_bin_max_data,
1261 int rapidity_bin_min_data,
1262 bool makeFit =
false,
1263 bool isLogYAxis =
true,
1264 bool doScaling =
true)
1266 double pT_max = 1.6;
1267 if (particle_name ==
"deuteron") pT_max = 1.0;
1269 TMultiGraph * MG1 =
new TMultiGraph();
1274 vector<TGraphErrors*> vDataGraphs = GetGraphsfromTH2D(h, year, particle_name, rapidity_bin_max_data, rapidity_bin_min_data, doScaling);
1275 for (
int k = 0; k < int(vDataGraphs.size()); k++)
1277 vDataGraphs[k] = RemoveZeroFromGraph(vDataGraphs[k]);
1278 vDataGraphs[k]->SetLineWidth(5);
1279 vDataGraphs[k]->SetLineColor(vParticleColor[k]);
1280 vDataGraphs[k]->SetMarkerSize(2);
1281 vDataGraphs[k]->SetMarkerStyle(20);
1282 vDataGraphs[k]->SetMarkerColor(vParticleColor[k]);
1287 vector<TGraphErrors*> vGFitConfidenceBands;
1288 vector<int> vMissingPointIndex;
1289 vector<TF1*> vDataFits;
1290 if (makeFit ==
true)
1292 vDataFits = GetPtSpectraFitAndEval(vDataGraphs, vGFitConfidenceBands, vMissingPointIndex, particle_name);
1294 if (vDataFits.size() != vGFitConfidenceBands.size())
1295 cerr<<
"\n\n[ERROR] Size of vGFitConfidenceBands = "<<vGFitConfidenceBands.size()<<
" is not equal to size of vDataFits = "<<vDataFits.size()<<endl;
1300 TCanvas * c2 =
new TCanvas(
"c2",
"c2", 3000, 3000);
1301 int nPlots = int(vDataGraphs.size());
1303 for (
int k = 0; k < nPlots; k++)
1305 double fraction = 0.22;
1306 double y_up = 1-(k+0)*fraction;
1307 double y_low = 1-(k+1)*fraction;
if (k == nPlots-1) y_low = 0;
1308 TPad * pad =
new TPad(Form(
"pad_%d", k),
"", 0.0, y_low, 1.0, y_up);
1312 pad->SetLogy(isLogYAxis);
1317 pad->SetLeftMargin(0.15);
1318 pad->SetRightMargin(0.02);
1319 pad->SetBottomMargin(0.04);
if (k == nPlots-1) pad->SetBottomMargin(0.35);
1320 pad->SetTopMargin(0.10);
1322 vDataGraphs[k]->Draw(
"ap");
1323 vDataGraphs[k]->GetXaxis()->SetTitle(
"");
if (k == nPlots-1) vDataGraphs[k]->GetXaxis()->SetTitle(
"p_{T} (GeV/c)");
1324 vDataGraphs[k]->GetXaxis()->SetTitleOffset(0);
if (k == nPlots-1) vDataGraphs[k]->GetXaxis()->SetTitleOffset(0.95);
1325 vDataGraphs[k]->GetXaxis()->SetTitleSize(0);
if (k == nPlots-1) vDataGraphs[k]->GetXaxis()->SetTitleSize(0.16);
1326 vDataGraphs[k]->GetXaxis()->SetLabelSize(0);
if (k == nPlots-1) vDataGraphs[k]->GetXaxis()->SetLabelSize(0.10);
1328 vDataGraphs[k]->GetYaxis()->SetTitle(
"#frac{d^{2}n}{dydp_{T}} (GeV/c)^{-1}");
1329 vDataGraphs[k]->GetYaxis()->SetLabelFont(63);
1330 vDataGraphs[k]->GetYaxis()->SetTitleFont(63);
1331 vDataGraphs[k]->GetYaxis()->SetTitleOffset(2.2);
1332 vDataGraphs[k]->GetYaxis()->SetTitleSize(0);
if (k == 1) vDataGraphs[k]->GetYaxis()->SetTitleSize(90);
1333 vDataGraphs[k]->GetYaxis()->SetLabelSize(60);
1335 vDataGraphs[k]->GetHistogram()->SetMaximum(yAxis_max);
1336 vDataGraphs[k]->GetHistogram()->SetMinimum(yAxis_min);
1337 vDataGraphs[k]->GetXaxis()->SetLimits(0.0, pT_max);
1341 if (makeFit ==
true)
1343 vDataFits[k]->SetLineColor(vParticleColor[k]);
1344 vDataFits[k]->SetLineWidth(3);
1346 vDataFits[k]->Draw(
"same");
1348 vGFitConfidenceBands[k]->SetFillColorAlpha(vParticleColor[k]-2, 0.30);
1349 vGFitConfidenceBands[k]->SetFillStyle(1001);
1351 vGFitConfidenceBands[k]->Draw(
"e3 psame");
1356 TLegend * leg = GetTLegend(particle_name, year,
"stackedspectra");
1357 leg->AddEntry(vDataGraphs[k], Form(
"y = %0.1f", -1.9+2*
double(k+rapidity_bin_min_data-1)/10),
"l");
1358 leg->SetBorderSize(0);
1359 leg->SetFillStyle(0);
1368 string name =
"plots_spectra/" + particle_name +
"/" +
"spectra_" + to_string(
int(year)) +
"_" + particle_name +
"_" + MC_type +
"_stacked.png";
1369 c2->SaveAs(name.c_str());
1377 void Make_PtIntegrated_rapidity_spectra (
const TH2D * h,
1378 const string &particle_name,
1379 const string &MC_type,
1383 int rapidity_bin_max_data,
1384 int rapidity_bin_min_data,
1385 bool isLogYAxis =
true)
1391 cerr<<
"\n\n[INFO] Making pT-integrated dn/dy spectra plots for "<<particle_name<<
" "<<MC_type<<endl;
1394 TCanvas * c2 =
new TCanvas(
"c2",
"c2", 2000, 2000);
1395 c2->SetLogy(isLogYAxis);
1398 c2->SetLeftMargin(0.18);
1399 c2->SetRightMargin(0.035);
1400 c2->SetBottomMargin(0.12);
1401 c2->SetTopMargin(0.02);
if (!isLogYAxis) c2->SetTopMargin(0.04);
1402 TMultiGraph * MG1 =
new TMultiGraph();
1407 vector<TGraphErrors*> vDataGraphs = GetGraphsfromTH2D(h, year, particle_name, rapidity_bin_max_data, rapidity_bin_min_data,
false);
1410 TFile * fOut =
new TFile (Form(
"plots/Spectra_TGraphErrors_%s.root", MC_type.c_str()),
"RECREATE");
1411 for (
int i = 0; i < int(vDataGraphs.size()); i++)
1413 vDataGraphs[i] = RemoveZeroFromGraph(vDataGraphs[i]);
1414 vDataGraphs[i]->Write();
1420 vector<TGraphErrors*> vGFitConfidenceBands;
1421 vector<TGraphErrors*> vIntegratedYSpectraGraphs = GetFitEvaluatedIntegratedYSpectraGraphs(vDataGraphs, vGFitConfidenceBands);
1422 for (
int k = 0; k < int(vIntegratedYSpectraGraphs.size()); k++)
1424 vIntegratedYSpectraGraphs[k]->SetLineColor(vParticleColor[k]);
1425 vIntegratedYSpectraGraphs[k]->SetLineWidth(3);
1427 MG1->Add(vIntegratedYSpectraGraphs[k],
"cp");
1433 auto GFitConfidenceBand = MergeSinglePointTGraphErrors(vGFitConfidenceBands);
1434 GFitConfidenceBand->SetFillColorAlpha(14, 0.30);
1435 GFitConfidenceBand->SetFillStyle(1001);
1436 GFitConfidenceBand->Draw(
"e3 same");
1440 const vector<double> vP0 = {58.94, 67.35, 75.77, 84.19, 92.61, 101.03, 109.45};
1442 vector<TH1D*> vHistEPOS = GetEPOSYGraphs(particle_name, vP0);
1443 for (
int k = 0; k < int(vHistEPOS.size()); k++)
1445 vHistEPOS[k]->SetLineColor(kGreen-10+2*k);
1446 vHistEPOS[k]->SetLineWidth(3);
1447 vHistEPOS[k]->SetLineStyle(9);
1448 vHistEPOS[k]->SetAxisRange(-1.4, -0.2,
"X");
1449 vHistEPOS[k]->Draw(
"HIST c same");
1451 TLegend * leg_p0 = GetTLegend(particle_name, k,
"p0");
1452 leg_p0->SetFillStyle(0);
1453 leg_p0->SetBorderSize(0);
1454 leg_p0->AddEntry(
"", Form(
"%4.1f", vP0[k]),
"");
1460 TLegend * leg = GetTLegend(particle_name, year,
"p0");
1461 leg->SetFillStyle(0);
1462 leg->SetBorderSize(0);
1463 leg->AddEntry(
"",
"p_{0} (MeV/c)",
"");
1477 MG1->GetXaxis()->SetLimits(-1.4, 0.2);
1478 MG1->GetHistogram()->SetMaximum(yAxis_max);
1479 MG1->GetHistogram()->SetMinimum(yAxis_min);
1480 MG1->GetXaxis()->SetTitle(
"y_{c.m.}");
1481 MG1->GetXaxis()->SetTitleOffset(0.7);
1482 MG1->GetXaxis()->SetTitleSize(0.07);
1483 MG1->GetYaxis()->SetTitle(
"#frac{dn}{dy}");
1484 MG1->GetYaxis()->SetTitleOffset(1.3);
1485 MG1->GetYaxis()->SetTitleSize(0.06);
1491 name =
"plots/hist_spectra_yCM_integrated/spectra_y_" + to_string(
int(year)) +
"_" + particle_name +
"_" + MC_type +
".png";
1492 c2->SaveAs(name.c_str());
1493 name =
"plots/hist_spectra_yCM_integrated/spectra_y_" + to_string(
int(year)) +
"_" + particle_name +
"_" + MC_type +
".pdf";
1494 c2->SaveAs(name.c_str());
1502 void Make_YPt_EPOSSpectra (vector<TGraphErrors*> vGraphs,
1505 const string &particle_name,
1506 const string &MC_type,
1510 int rapidity_bin_min_data = 45,
1511 bool isLogYAxis =
true,
1512 bool doScaling =
true
1515 if (vGraphs.size() != vFits.size()) cerr<<
"\n\n[WARNING] DataGraphs size != vFits size"<<endl;
1517 double pT_max = 3.5;
1519 TMultiGraph * MG1 =
new TMultiGraph();
1524 for (
int k = 0; k < int(vGraphs.size()); k++)
1526 vGraphs[k] = RemoveZeroFromGraph(vGraphs[k]);
1527 vGraphs[k]->SetLineWidth(5);
1528 vGraphs[k]->SetLineColor(vParticleColor[k]);
1529 vGraphs[k]->SetMarkerSize(2.5);
1530 vGraphs[k]->SetMarkerStyle(20);
1531 vGraphs[k]->SetMarkerColor(vParticleColor[k]);
1533 MG1->Add(vGraphs[k],
"p");
1538 TCanvas * c2 =
new TCanvas(
"c2",
"c2", 1200, 1200);
1539 c2->SetLogy(isLogYAxis);
1542 c2->SetLeftMargin(0.19);
1543 c2->SetRightMargin(0.025);
1544 c2->SetBottomMargin(0.12);
1545 c2->SetTopMargin(0.02);
if (!isLogYAxis) c2->SetTopMargin(0.04);
1550 for (
int k = 0; k < int(vFits.size()); k++)
1552 vFits[k]->SetLineColor(vParticleColor[k]);
1553 vFits[k]->SetLineWidth(3);
1554 vFits[k]->Draw(
"c same");
1559 TLegend * leg = GetTLegend(particle_name, year,
"ExtraPoints");
1560 for (
int k = 0; k < int(vGraphs.size()); k++)
1563 leg->AddEntry(vGraphs[k], Form(
"#times10^{%d} y = %0.1f, T=%4.1f MeV", -1*k, -9.9+2*
double(k+rapidity_bin_min_data-1)/10, 1000*vFits[k]->GetParameter(1)),
"l");
1565 leg->AddEntry(vGraphs[k], Form(
"y = %0.1f, T=%4.1f MeV", -9.9+2*
double(k+rapidity_bin_min_data-1)/10, 1000*vFits[k]->GetParameter(1)),
"l");
1567 leg->SetBorderSize(0);
1572 MG1->GetXaxis()->SetTitle(
"p_{T} (GeV/c)");
1573 MG1->GetXaxis()->SetTitleOffset(1.0);
1574 MG1->GetXaxis()->SetTitleSize(0.05);
1575 MG1->GetYaxis()->SetTitle(
"#frac{d^{2}n}{dydp_{T}} (GeV/c)^{-1}");
1576 MG1->GetYaxis()->SetTitleOffset(1.65);
1577 MG1->GetYaxis()->SetTitleSize(0.05);
1578 MG1->GetHistogram()->SetMaximum(yAxis_max);
1579 MG1->GetHistogram()->SetMinimum(yAxis_min);
1580 MG1->GetXaxis()->SetLimits(0.0, pT_max);
1582 string filename = name + particle_name +
"_" + MC_type +
".png";
1583 c2->SaveAs(filename.c_str());