Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-07-16 08:11:23

0001 // plot_mass_smear_fracs_xi.C
0002 // Xi mass-width-matched proton smearing fractions.
0003 // Pion fracs fixed from K0S analysis; only proton frac was scanned.
0004 // Run with:  root -l -b -q plot_mass_smear_fracs_xi.C
0005 
0006 #include <ctime>
0007 #include <sstream>
0008 #include <algorithm>
0009 #include <cmath>
0010 
0011 std::string _getDate(){
0012     std::time_t t=std::time(0); std::tm* n=std::localtime(&t);
0013     std::stringstream s;
0014     s<<(n->tm_mon+1)<<'/'<<n->tm_mday<<'/'<<(n->tm_year+1900);
0015     return s.str();
0016 }
0017 void _label(double x1,double y1,double x2,double y2){
0018     TPaveText *p=new TPaveText(x1,y1,x2,y2,"NDC");
0019     p->SetFillStyle(0); p->SetBorderSize(0); p->SetTextFont(42);
0020     p->AddText("#it{#bf{sPHENIX}} Internal,  #it{p}+#it{p}  #sqrt{s} = 200 GeV");
0021     p->Draw();
0022 }
0023 void _date(double x1,double y1){
0024     TLatex l; l.SetNDC(); l.SetTextFont(42); l.SetTextSize(0.035);
0025     l.SetTextColor(kGray+2); l.DrawLatex(x1,y1,_getDate().c_str());
0026 }
0027 
0028 void plot_mass_smear_fracs_xi() {
0029     gStyle->SetOptStat(0); gStyle->SetOptTitle(0);
0030 
0031     const int N = 5;
0032     double avg_pt[]    = {0.9680, 1.2450, 1.5860, 1.9768, 2.5107};
0033     double sig_data[]  = {3.1110, 3.7978, 3.4339, 4.7110, 4.7252};
0034     double sig_derr[]  = {0.2621, 0.2145, 0.2349, 0.3638, 0.6131};
0035     double sig_sim0[]  = {3.7236, 3.0454, 3.3467, 3.8444, 4.0506};
0036     double sig_check[] = {3.5505, 4.0020, 3.6392, 5.1739, 4.3156};
0037     double frac_pct[]  = {0.0000, 2.8118, 0.8891, 4.5525, 2.3635};
0038     double xerr[]      = {0.150, 0.150, 0.200, 0.200, 0.400};
0039     double zero[]      = {0, 0, 0, 0, 0};
0040 
0041     // ── canvas 1: sigma comparison ─────────────────────────────────────────────
0042     TCanvas *c1 = new TCanvas("c1","Xi mass sigma comparison",900,650);
0043     c1->SetLeftMargin(0.13); c1->SetBottomMargin(0.13); c1->SetRightMargin(0.06);
0044 
0045     TGraphErrors *gD = new TGraphErrors(N, avg_pt, sig_data, xerr, sig_derr);
0046     TGraph       *gS = new TGraph(N, avg_pt, sig_sim0);
0047     TGraph       *gC = new TGraph(N, avg_pt, sig_check);
0048 
0049     gD->SetMarkerStyle(20); gD->SetMarkerSize(1.3);
0050     gD->SetMarkerColor(kBlack);   gD->SetLineColor(kBlack);   gD->SetLineWidth(2);
0051     gS->SetMarkerStyle(24); gS->SetMarkerSize(1.3);
0052     gS->SetMarkerColor(kAzure+7); gS->SetLineColor(kAzure+7); gS->SetLineWidth(2);
0053     gC->SetMarkerStyle(21); gC->SetMarkerSize(1.3);
0054     gC->SetMarkerColor(kRed+1);   gC->SetLineColor(kRed+1);   gC->SetLineWidth(2);
0055 
0056     double ymax = 0;
0057     for(int i=0;i<N;++i) ymax=std::max(ymax,std::max(sig_data[i]+sig_derr[i],sig_sim0[i]));
0058     ymax *= 1.35;
0059 
0060     TMultiGraph *mg1 = new TMultiGraph();
0061     mg1->Add(gS,"PL"); mg1->Add(gD,"PE"); mg1->Add(gC,"PL");
0062     mg1->Draw("A");
0063     mg1->GetXaxis()->SetTitle("#it{p}_{T}^{#Xi^{-}} (GeV/#it{c})");
0064     mg1->GetYaxis()->SetTitle("Gaussian #sigma of #Xi^{-} mass (MeV/#it{c}^{2})");
0065     mg1->GetYaxis()->SetRangeUser(0, ymax);
0066     mg1->GetXaxis()->SetTitleSize(0.05); mg1->GetYaxis()->SetTitleSize(0.045);
0067     mg1->GetYaxis()->SetTitleOffset(1.30);
0068 
0069     TLegend *leg1 = new TLegend(0.14,0.72,0.70,0.87);
0070     leg1->SetBorderSize(0); leg1->SetFillStyle(0); leg1->SetTextSize(0.033);
0071     leg1->AddEntry(gD,"Data",                             "lpe");
0072     leg1->AddEntry(gS,"SV sim (pion smeared only)",       "lp");
0073     leg1->AddEntry(gC,"SV sim (pion + proton smeared)",   "lp");
0074     leg1->Draw();
0075     _label(0.14,0.88,0.68,0.96);
0076     _date(0.72,0.90);
0077 
0078     c1->SaveAs("plot_mass_smear_sigma_xi.pdf");
0079     c1->SaveAs("plot_mass_smear_sigma_xi.png");
0080     std::cout << "Saved plot_mass_smear_sigma_xi.pdf/.png\n";
0081 
0082     // ── canvas 2: proton fracs vs pT ───────────────────────────────────────────
0083     TCanvas *c2 = new TCanvas("c2","Xi proton smearing fractions",900,650);
0084     c2->SetLeftMargin(0.13); c2->SetBottomMargin(0.13); c2->SetRightMargin(0.06);
0085 
0086     TGraphErrors *gF = new TGraphErrors(N, avg_pt, frac_pct, xerr, zero);
0087     gF->SetMarkerStyle(20); gF->SetMarkerSize(1.4);
0088     gF->SetMarkerColor(kOrange+1); gF->SetLineColor(kOrange+1); gF->SetLineWidth(2);
0089     gF->Draw("APE");
0090     gF->GetXaxis()->SetTitle("#it{p}_{T}^{#Xi^{-}} (GeV/#it{c})");
0091     gF->GetYaxis()->SetTitle("Proton smearing fraction (%)");
0092     double fmax = *std::max_element(frac_pct,frac_pct+N)*1.4 + 0.5;
0093     gF->GetYaxis()->SetRangeUser(0, fmax);
0094     gF->GetXaxis()->SetTitleSize(0.05); gF->GetYaxis()->SetTitleSize(0.05);
0095     gF->GetYaxis()->SetTitleOffset(1.2);
0096 
0097     _label(0.14,0.88,0.68,0.96);
0098     _date(0.72,0.90);
0099 
0100     TLegend *leg2 = new TLegend(0.14,0.74,0.65,0.85);
0101     leg2->SetBorderSize(0); leg2->SetFillStyle(0); leg2->SetTextSize(0.033);
0102     leg2->AddEntry(gF,"Proton frac to match #Xi^{-} mass #sigma (pion fixed from K_{S}^{0})","lp");
0103     leg2->Draw();
0104 
0105     c2->SaveAs("plot_mass_smear_fracs_xi.pdf");
0106     c2->SaveAs("plot_mass_smear_fracs_xi.png");
0107     std::cout << "Saved plot_mass_smear_fracs_xi.pdf/.png\n";
0108 }