File indexing completed on 2025-08-05 08:11:17
0001 #include "./util_combine.h"
0002
0003 bool docombine = true;
0004 std::string comb_fname = "./systematics/combined/combined.root";
0005 std::vector<TGraphAsymmErrors *> v_sphenix_dNdeta;
0006 std::string color_sphenix_combine = "#1A1423";
0007 std::string leg_sphenix_combine = "sPHENIX (Combined)";
0008 int mkstyle_sphenix_combine = 20;
0009 float mksize_sphenix_combine = 1.3;
0010
0011 std::vector<float> v_sphenix_centralitybin = {0, 3, 6, 10, 15, 20, 25, 30, 35, 40, 45, 50};
0012 int nsphenix = v_sphenix_centralitybin.size() - 1;
0013 std::vector<TH1 *> v_sphenix_dNdeta_cmsapproach_hist;
0014 std::vector<TGraphAsymmErrors *> v_SPHENIX_dNdeta_cmsapproach;
0015 std::vector<std::string> v_SPHENIX_labels = {};
0016 std::string color_sphenix_cmsapproach = "#FF6700";
0017 std::string leg_sphenix_cmsapproach = "The closest-match method";
0018 int mkstyle_sphenix_cmsapproach = 34;
0019 float mksize_sphenix_cmsapproach = 1.3;
0020
0021 std::vector<TH1 *> v_sphenix_dNdeta_phobosapproach_hist;
0022 std::vector<TGraphAsymmErrors *> v_SPHENIX_dNdeta_phobosapproach;
0023 std::string color_sphenix_phobosapproach = "#228B22";
0024 std::string leg_sphenix_phobosapproach = "The combinatoric method";
0025 int mkstyle_sphenix_phobosapproach = 47;
0026 float mksize_sphenix_phobosapproach = 1.3;
0027
0028 bool draw_brahms = false;
0029 std::vector<float> v_brahms_centralitybin = {0, 5, 10, 20, 30, 40, 50};
0030 int nbrahms = v_brahms_centralitybin.size() - 1;
0031 std::vector<TGraphAsymmErrors *> v_BRAHMS_dNdeta;
0032 std::vector<std::string> v_BRAHMS_labels = {};
0033 std::string color_brahms = "#7868E6";
0034 std::string leg_brahms = "BRAHMS [Phys. Rev. Lett. 88, 202301 (2002)]";
0035 int mkstyle_brahms = 28;
0036
0037 bool draw_phobos = docombine;
0038 std::vector<float> v_phobos_centralitybin = {0, 3, 6, 10, 15, 20, 25, 30, 35, 40, 45, 50};
0039 int nphobos = v_phobos_centralitybin.size() - 1;
0040 std::vector<TGraphAsymmErrors *> v_PHOBOS_dNdeta;
0041 std::vector<std::string> v_PHOBOS_labels = {};
0042 std::string color_phobos = "#035397";
0043 std::string leg_phobos = "PHOBOS [Phys. Rev. C 83, 024913 (2011)]";
0044 int mkstyle_phobos = 25;
0045 float mksize_phobos = 1.3;
0046
0047 float absxlim = (draw_phobos) ? 2.49 : 1.59;
0048 std::string prelimtext = "Internal";
0049
0050 float LeftMargin = 0.17;
0051 float RightMargin = 0.05;
0052 float TopMargin = 0.12;
0053 float BottomMargin = 0.13;
0054 float ymax = 970;
0055 float ymin = 50;
0056
0057 void BRAHMS_dNdeta()
0058 {
0059
0060 TFile *f = new TFile("./measurements/HEPData/HEPData-ins567754-v1-root.root", "READ");
0061 f->cd("Table 1a");
0062 for (int i = 0; i < nbrahms; i++)
0063 {
0064 TGraphAsymmErrors *g = (TGraphAsymmErrors *)gDirectory->Get(Form("Graph1D_y%d", i + 1));
0065 v_BRAHMS_dNdeta.push_back(g);
0066 v_BRAHMS_labels.push_back(Form("%d-%d%%", (int)v_brahms_centralitybin[i], (int)v_brahms_centralitybin[i + 1]));
0067 }
0068 f->Close();
0069 }
0070
0071 void PHOBOS_dNdeta()
0072 {
0073
0074 TFile *f = new TFile("./measurements/PHOBOS-PhysRevC.83.024913/auau_200GeV.root", "READ");
0075 f->cd();
0076 for (int i = 0; i < nphobos; i++)
0077 {
0078 TGraphAsymmErrors *g = (TGraphAsymmErrors *)gDirectory->Get(Form("AuAu_200GeV_Centrality_%dto%d", (int)v_phobos_centralitybin[i], (int)v_phobos_centralitybin[i + 1]));
0079 v_PHOBOS_dNdeta.push_back(g);
0080 v_PHOBOS_labels.push_back(Form("%d-%d%%", (int)v_phobos_centralitybin[i], (int)v_phobos_centralitybin[i + 1]));
0081 }
0082 f->Close();
0083 }
0084
0085 TGraphAsymmErrors *TH1toTGraphAsymmErrors(TH1 *h)
0086 {
0087 int Nbins = h->GetNbinsX();
0088
0089 std::vector<float> vx, vy, vxerr, vyerr;
0090 vx.clear();
0091 vy.clear();
0092 vxerr.clear();
0093 vyerr.clear();
0094 for (int i = 1; i <= Nbins; i++)
0095 {
0096 if (h->GetBinContent(i) <= 0)
0097 continue;
0098
0099 if (fabs(h->GetBinCenter(i)) >= 1.1)
0100 continue;
0101
0102 vx.push_back(h->GetBinCenter(i));
0103 vy.push_back(h->GetBinContent(i));
0104 vxerr.push_back(h->GetBinWidth(i) * 0.49);
0105 vyerr.push_back(h->GetBinError(i));
0106 }
0107
0108 TGraphAsymmErrors *g = new TGraphAsymmErrors(vx.size(), vx.data(), vy.data(), vxerr.data(), vxerr.data(), vyerr.data(), vyerr.data());
0109 return g;
0110 }
0111
0112 void SPHENIX_dNdeta()
0113 {
0114 TFile *f_comb = new TFile(comb_fname.c_str(), "READ");
0115
0116 for (int i = 0; i < nsphenix; i++)
0117 {
0118 int Mbin = GetMbinNum(Form("Centrality%dto%d", (int)v_sphenix_centralitybin[i], (int)v_sphenix_centralitybin[i + 1]));
0119
0120
0121 TFile *f = new TFile(Form("./systematics/Centrality%dto%d_Zvtxm10p0to10p0_noasel/finalhists_systematics_Centrality%dto%d_Zvtxm10p0to10p0_noasel.root", (int)v_sphenix_centralitybin[i], (int)v_sphenix_centralitybin[i + 1], (int)v_sphenix_centralitybin[i], (int)v_sphenix_centralitybin[i + 1]), "READ");
0122 TH1D *h = (TH1D *)f->Get("hM_final");
0123 h->SetDirectory(0);
0124 v_sphenix_dNdeta_cmsapproach_hist.push_back(h);
0125 TGraphAsymmErrors *g_cms = TH1toTGraphAsymmErrors(h);
0126 v_SPHENIX_dNdeta_cmsapproach.push_back(g_cms);
0127 v_SPHENIX_labels.push_back(Form("%d-%d%%", (int)v_sphenix_centralitybin[i], (int)v_sphenix_centralitybin[i + 1]));
0128 f->Close();
0129
0130
0131 TFile *fphobos = new TFile(Form("/sphenix/tg/tg01/commissioning/INTT/work/cwshih/seflgendata/run_54280_HR_Feb102025/Run6_EvtZFitWidthChange/EvtVtxZ/FinalResult_10cm_Pol2BkgFit/completed/vtxZ_-10_10cm_MBin%d/Final_Mbin%d_00054280/Final_Mbin%d_00054280.root", Mbin, Mbin, Mbin), "READ");
0132 TH1D *hphobos = (TH1D *)fphobos->Get("h1D_dNdEta_reco");
0133 hphobos->SetDirectory(0);
0134 v_sphenix_dNdeta_phobosapproach_hist.push_back(hphobos);
0135 TGraphAsymmErrors *g_phobos = TH1toTGraphAsymmErrors(hphobos);
0136 v_SPHENIX_dNdeta_phobosapproach.push_back(g_phobos);
0137 fphobos->Close();
0138
0139
0140 TFile *f_comb = new TFile(comb_fname.c_str(), "READ");
0141 TGraphAsymmErrors *g = (TGraphAsymmErrors *)f_comb->Get(Form("tgae_combine_Centrality%dto%d", (int)v_sphenix_centralitybin[i], (int)v_sphenix_centralitybin[i + 1]));
0142 v_sphenix_dNdeta.push_back(g);
0143 f_comb->Close();
0144 }
0145 }
0146
0147 void draw_dNdetaRHIC()
0148 {
0149 std::string plotdir = "./dNdEtaFinal";
0150 system(Form("mkdir -p %s", plotdir.c_str()));
0151
0152 SPHENIX_dNdeta();
0153
0154 if (draw_phobos)
0155 PHOBOS_dNdeta();
0156
0157 if (draw_brahms)
0158 BRAHMS_dNdeta();
0159
0160 auto mg_phobos = new TMultiGraph();
0161 auto mg_brahms = new TMultiGraph();
0162 auto mg_sphenix_cmsapproach = new TMultiGraph();
0163 auto mg_sphenix_phobosapproach = new TMultiGraph();
0164 auto mg_sphenix = new TMultiGraph();
0165
0166 for (int i = 0; i < nsphenix; i++)
0167 {
0168 v_SPHENIX_dNdeta_cmsapproach[i]->SetMarkerStyle(mkstyle_sphenix_cmsapproach);
0169 v_SPHENIX_dNdeta_cmsapproach[i]->SetMarkerSize(mksize_sphenix_cmsapproach);
0170 v_SPHENIX_dNdeta_cmsapproach[i]->SetLineColor(TColor::GetColor(color_sphenix_cmsapproach.c_str()));
0171 v_SPHENIX_dNdeta_cmsapproach[i]->SetLineWidth(1);
0172 v_SPHENIX_dNdeta_cmsapproach[i]->SetMarkerColor(TColor::GetColor(color_sphenix_cmsapproach.c_str()));
0173 v_SPHENIX_dNdeta_cmsapproach[i]->SetFillColorAlpha(TColor::GetColor(color_sphenix_cmsapproach.c_str()), 0.2);
0174 mg_sphenix_cmsapproach->Add(v_SPHENIX_dNdeta_cmsapproach[i], "5 p");
0175
0176 v_SPHENIX_dNdeta_phobosapproach[i]->SetMarkerStyle(mkstyle_sphenix_phobosapproach);
0177 v_SPHENIX_dNdeta_phobosapproach[i]->SetMarkerSize(mksize_sphenix_phobosapproach);
0178 v_SPHENIX_dNdeta_phobosapproach[i]->SetLineColor(TColor::GetColor(color_sphenix_phobosapproach.c_str()));
0179 v_SPHENIX_dNdeta_phobosapproach[i]->SetLineWidth(1);
0180 v_SPHENIX_dNdeta_phobosapproach[i]->SetMarkerColor(TColor::GetColor(color_sphenix_phobosapproach.c_str()));
0181 v_SPHENIX_dNdeta_phobosapproach[i]->SetFillColorAlpha(TColor::GetColor(color_sphenix_phobosapproach.c_str()), 0.2);
0182 mg_sphenix_phobosapproach->Add(v_SPHENIX_dNdeta_phobosapproach[i], "5 p");
0183
0184 v_sphenix_dNdeta[i]->SetMarkerStyle(mkstyle_sphenix_combine);
0185 v_sphenix_dNdeta[i]->SetMarkerSize(mksize_sphenix_combine);
0186 v_sphenix_dNdeta[i]->SetLineColor(TColor::GetColor(color_sphenix_combine.c_str()));
0187 v_sphenix_dNdeta[i]->SetLineWidth(1);
0188 v_sphenix_dNdeta[i]->SetMarkerColor(TColor::GetColor(color_sphenix_combine.c_str()));
0189 v_sphenix_dNdeta[i]->SetFillColorAlpha(TColor::GetColor(color_sphenix_combine.c_str()), 0.2);
0190 mg_sphenix->Add(v_sphenix_dNdeta[i], "5 p");
0191 }
0192
0193 if (draw_phobos)
0194 {
0195 for (int i = 0; i < nphobos; i++)
0196 {
0197 v_PHOBOS_dNdeta[i]->SetMarkerStyle(mkstyle_phobos);
0198 v_PHOBOS_dNdeta[i]->SetMarkerSize(mksize_phobos);
0199 v_PHOBOS_dNdeta[i]->SetLineColor(TColor::GetColor(color_phobos.c_str()));
0200 v_PHOBOS_dNdeta[i]->SetLineWidth(0);
0201 v_PHOBOS_dNdeta[i]->SetMarkerColor(TColor::GetColor(color_phobos.c_str()));
0202 v_PHOBOS_dNdeta[i]->SetFillColorAlpha(TColor::GetColor(color_phobos.c_str()), 0.15);
0203 mg_phobos->Add(v_PHOBOS_dNdeta[i], "3 p");
0204 }
0205 }
0206
0207 if (draw_brahms)
0208 {
0209 for (int i = 0; i < nbrahms; i++)
0210 {
0211 v_BRAHMS_dNdeta[i]->SetMarkerStyle(mkstyle_brahms);
0212 v_BRAHMS_dNdeta[i]->SetMarkerSize(0.8);
0213 v_BRAHMS_dNdeta[i]->SetLineWidth(0);
0214 v_BRAHMS_dNdeta[i]->SetMarkerColor(TColor::GetColor(color_brahms.c_str()));
0215 v_BRAHMS_dNdeta[i]->SetFillColorAlpha(TColor::GetColor(color_brahms.c_str()), 0.2);
0216 mg_brahms->Add(v_BRAHMS_dNdeta[i], "3 p");
0217 }
0218 }
0219
0220 TCanvas *c = new TCanvas("c", "c", 800, 1200);
0221 gPad->SetTopMargin(TopMargin);
0222 gPad->SetLeftMargin(LeftMargin);
0223 gPad->SetRightMargin(RightMargin);
0224
0225 c->cd();
0226 if (draw_phobos)
0227 {
0228 mg_phobos->Draw("A P F");
0229 mg_sphenix->Draw("5 P F");
0230 }
0231 else
0232 {
0233 mg_sphenix_phobosapproach->Draw("A 5 P F");
0234 mg_sphenix_cmsapproach->Draw("5 P F");
0235 }
0236
0237 if (draw_brahms)
0238 mg_brahms->Draw("PF");
0239
0240
0241
0242 if (draw_phobos)
0243 {
0244 for (int i = 0; i < nphobos; i++)
0245 {
0246 double x, y;
0247 for (int j = 0; j < v_PHOBOS_dNdeta[i]->GetN(); j++)
0248 {
0249 v_PHOBOS_dNdeta[i]->GetPoint(j, x, y);
0250 if (x > -2.1)
0251 break;
0252 }
0253 TLatex *l = new TLatex(x, y + 5, v_PHOBOS_labels[i].c_str());
0254
0255 l->SetTextAlign(kHAlignRight + kVAlignBottom);
0256 l->SetTextSize(0.02);
0257
0258 l->SetTextColor(TColor::GetColor(color_phobos.c_str()));
0259 l->Draw();
0260 }
0261 }
0262
0263 if (draw_brahms)
0264 {
0265
0266
0267 for (int i = 0; i < nbrahms; i++)
0268 {
0269 double x, y;
0270 for (int j = 0; j < v_BRAHMS_dNdeta[i]->GetN(); j++)
0271 {
0272 v_BRAHMS_dNdeta[i]->GetPoint(j, x, y);
0273 if (x > 1.8)
0274 break;
0275 }
0276 TLatex *l = new TLatex(x, y + 3, v_BRAHMS_labels[i].c_str());
0277
0278 l->SetTextAlign(kHAlignLeft + kVAlignBottom);
0279 l->SetTextSize(0.02);
0280
0281 l->SetTextColor(TColor::GetColor(color_brahms.c_str()));
0282 l->Draw();
0283 }
0284 }
0285
0286
0287
0288 if (docombine)
0289 {
0290 double x, y;
0291 for (int i = 0; i < nsphenix; i++)
0292 {
0293 double x, y;
0294 x = v_sphenix_dNdeta[i]->GetPointX(v_sphenix_dNdeta[i]->GetN() - 1) + v_sphenix_dNdeta[i]->GetErrorXhigh(v_sphenix_dNdeta[i]->GetN() - 1);
0295 y = v_sphenix_dNdeta[i]->GetPointY(v_sphenix_dNdeta[i]->GetN() - 1) + v_sphenix_dNdeta[i]->GetErrorYhigh(v_sphenix_dNdeta[i]->GetN() - 1);
0296
0297 cout << v_sphenix_dNdeta[i]->GetPointX(0) << " " << v_sphenix_dNdeta[i]->GetPointY(0) << " " << v_sphenix_dNdeta[i]->GetErrorYlow(0) << " " << v_sphenix_dNdeta[i]->GetErrorYhigh(0) << endl;
0298 TLatex *l = new TLatex(x, y, v_SPHENIX_labels[i].c_str());
0299 l->SetTextAlign(kHAlignLeft + kVAlignBottom);
0300 l->SetTextSize(0.02);
0301
0302 l->SetTextColor(TColor::GetColor(color_sphenix_combine.c_str()));
0303 l->Draw();
0304 }
0305 }
0306 else
0307 {
0308 for (int i = 0; i < nsphenix; i++)
0309 {
0310 double x, y;
0311
0312 x = v_SPHENIX_dNdeta_phobosapproach[i]->GetPointX(v_SPHENIX_dNdeta_phobosapproach[i]->GetN() - 1) + v_SPHENIX_dNdeta_phobosapproach[i]->GetErrorXlow(v_SPHENIX_dNdeta_phobosapproach[i]->GetN() - 1);
0313
0314 y = v_SPHENIX_dNdeta_phobosapproach[i]->GetPointY(v_SPHENIX_dNdeta_phobosapproach[i]->GetN() - 1);
0315 cout << "phobos: x=" << x << " y=" << y << endl;
0316 TLatex *lphobos = new TLatex(x + 0.02, y, v_SPHENIX_labels[i].c_str());
0317 lphobos->SetTextAlign(kHAlignLeft + kVAlignCenter);
0318 lphobos->SetTextSize(0.02);
0319
0320 lphobos->SetTextColor(TColor::GetColor(color_sphenix_phobosapproach.c_str()));
0321 lphobos->Draw();
0322
0323
0324 x = v_SPHENIX_dNdeta_cmsapproach[i]->GetPointX(0) - v_SPHENIX_dNdeta_cmsapproach[i]->GetErrorXlow(0);
0325
0326 y = v_SPHENIX_dNdeta_cmsapproach[i]->GetPointY(0);
0327 cout << "cms: x=" << x << " y=" << y << endl;
0328 TLatex *lcms = new TLatex(x - 0.02, y, v_SPHENIX_labels[i].c_str());
0329
0330 lcms->SetTextAlign(kHAlignRight + kVAlignCenter);
0331 lcms->SetTextSize(0.02);
0332
0333 lcms->SetTextColor(TColor::GetColor(color_sphenix_cmsapproach.c_str()));
0334 lcms->Draw();
0335 }
0336 }
0337
0338 gPad->Modified();
0339 if (draw_phobos)
0340 {
0341 mg_phobos->GetXaxis()->SetLimits(-absxlim, absxlim);
0342 mg_phobos->GetXaxis()->SetTitle("Pseudorapidity #eta");
0343 mg_phobos->GetXaxis()->SetNdivisions(505);
0344 mg_phobos->GetYaxis()->SetTitle("dN_{ch}/d#eta");
0345 mg_phobos->GetYaxis()->SetTitleOffset(1.6);
0346 mg_phobos->GetYaxis()->SetNdivisions(505);
0347 mg_phobos->SetMaximum(ymax);
0348 mg_phobos->SetMinimum(ymin);
0349 }
0350 else
0351 {
0352 mg_sphenix_phobosapproach->GetXaxis()->SetLimits(-absxlim, absxlim);
0353 mg_sphenix_phobosapproach->GetXaxis()->SetTitle("Pseudorapidity #eta");
0354 mg_sphenix_phobosapproach->GetXaxis()->SetNdivisions(505);
0355 mg_sphenix_phobosapproach->GetYaxis()->SetTitle("dN_{ch}/d#eta");
0356 mg_sphenix_phobosapproach->GetYaxis()->SetTitleOffset(1.6);
0357 mg_sphenix_phobosapproach->GetYaxis()->SetNdivisions(505);
0358 mg_sphenix_phobosapproach->SetMaximum(ymax);
0359 mg_sphenix_phobosapproach->SetMinimum(ymin);
0360 }
0361 c->RedrawAxis();
0362
0363 TLegend *leg = new TLegend(gPad->GetLeftMargin(), 1 - gPad->GetTopMargin() + 0.02, 1 - gPad->GetRightMargin(), 0.98);
0364 leg->SetTextAlign(kHAlignLeft + kVAlignCenter);
0365 if (docombine)
0366 leg->AddEntry(v_sphenix_dNdeta[0], leg_sphenix_combine.c_str(), "pf");
0367 else
0368 {
0369 leg->AddEntry(v_SPHENIX_dNdeta_phobosapproach[0], leg_sphenix_phobosapproach.c_str(), "pf");
0370 leg->AddEntry(v_SPHENIX_dNdeta_cmsapproach[0], leg_sphenix_cmsapproach.c_str(), "pf");
0371 }
0372 if (draw_phobos)
0373 leg->AddEntry(v_PHOBOS_dNdeta[0], leg_phobos.c_str(), "pf");
0374 if (draw_brahms)
0375 leg->AddEntry(v_BRAHMS_dNdeta[0], leg_brahms.c_str(), "pf");
0376 leg->SetTextSize(0.03);
0377 leg->SetBorderSize(0);
0378 leg->SetFillStyle(0);
0379 leg->Draw();
0380 TLegend *sphnxleg = new TLegend(gPad->GetLeftMargin() + 0.05, (1 - TopMargin) - 0.11, gPad->GetLeftMargin() + 0.2, (1 - TopMargin) - 0.03);
0381 sphnxleg->SetTextAlign(kHAlignLeft + kVAlignCenter);
0382 sphnxleg->SetTextSize(0.04);
0383 sphnxleg->SetFillStyle(0);
0384 sphnxleg->AddEntry("", Form("#it{#bf{sPHENIX}} %s", prelimtext.c_str()), "");
0385 sphnxleg->AddEntry("", "Au+Au #sqrt{s_{NN}}=200 GeV", "");
0386 sphnxleg->Draw();
0387 if (docombine)
0388 {
0389 if (draw_brahms)
0390 {
0391 c->SaveAs(Form("%s/dNdEta_RHIC_combine_wBRAHMS_singlepad.pdf", plotdir.c_str()));
0392 c->SaveAs(Form("%s/dNdEta_RHIC_combine_wBRAHMS_singlepad.png", plotdir.c_str()));
0393 }
0394 else
0395 {
0396 c->SaveAs(Form("%s/dNdEta_RHIC_combine_woBRAHMS_singlepad.pdf", plotdir.c_str()));
0397 c->SaveAs(Form("%s/dNdEta_RHIC_combine_woBRAHMS_singlepad.png", plotdir.c_str()));
0398 }
0399 }
0400 else
0401 {
0402 if (draw_brahms)
0403 {
0404 c->SaveAs(Form("%s/dNdEta_RHIC_wBRAHMS_singlepad.pdf", plotdir.c_str()));
0405 c->SaveAs(Form("%s/dNdEta_RHIC_wBRAHMS_singlepad.png", plotdir.c_str()));
0406 }
0407 else
0408 {
0409 c->SaveAs(Form("%s/dNdEta_RHIC_woBRAHMS_singlepad.pdf", plotdir.c_str()));
0410 c->SaveAs(Form("%s/dNdEta_RHIC_woBRAHMS_singlepad.png", plotdir.c_str()));
0411 }
0412 }
0413 }