Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-04-06 08:10:20

0001 #include "util.C"
0002 
0003 template <typename T>
0004 string to_string_with_precision(const T a_value, const int n = 0)
0005 {
0006     ostringstream out;
0007     out.precision(n);
0008     out << fixed << a_value;
0009     return out.str();
0010 }
0011 
0012 //=====================
0013 void lfRatio(bool save_plot = true)
0014 {
0015   string plotName = "lfRatio";
0016 
0017   string axisTitles = ";p_{T} [GeV];#Lambda^{0}/2K^{0}_{S}";
0018 
0019   // ===== Graph configuration =====
0020   vector<plot_info> plot_infos;
0021 
0022   //sPHENIX Proj
0023   float proj_lumi = 4; // inv nb
0024   float scale = 13./proj_lumi; // Simulated lumi / projected lumi
0025   float yValue = 0.9;
0026 
0027   //CMS https://www.hepdata.net/record/ins1464834 
0028   vector<data_point> cms_high_mult;
0029   cms_high_mult.push_back({0.5,0.4,0.6,0.094,0.007,0.0076,0.0076});
0030   cms_high_mult.push_back({0.7,0.6,0.8,0.168,0.0042,0.0136,0.0136});
0031   cms_high_mult.push_back({0.9,0.8,1.0,0.229,0.0037,0.0185,0.0185});
0032   cms_high_mult.push_back({1.1,1.0,1.2,0.287,0.0039,0.0232,0.0232});
0033   cms_high_mult.push_back({1.3,1.2,1.4,0.35,0.0044,0.0286,0.0286});
0034   cms_high_mult.push_back({1.5,1.4,1.6,0.43,0.0051,0.0266,0.0266});
0035   cms_high_mult.push_back({1.7,1.6,1.8,0.49,0.0059,0.0301,0.0301});
0036   cms_high_mult.push_back({1.9,1.8,2.0,0.54,0.0067,0.033,0.033});
0037   cms_high_mult.push_back({2.1,2.0,2.2,0.57,0.0076,0.036,0.036});
0038   cms_high_mult.push_back({2.3,2.2,2.4,0.63,0.0089,0.039,0.039});
0039   cms_high_mult.push_back({2.5,2.4,2.6,0.65,0.01,0.041,0.041});
0040   cms_high_mult.push_back({2.7,2.6,2.8,0.68,0.012,0.042,0.042});
0041   cms_high_mult.push_back({2.9,2.8,3.0,0.68,0.013,0.042,0.042});
0042   cms_high_mult.push_back({3.2,3.0,3.4,0.69,0.011,0.043,0.043});
0043   cms_high_mult.push_back({3.6,3.4,3.8,0.67,0.013,0.042,0.042});
0044   cms_high_mult.push_back({4.0,3.8,4.2,0.66,0.016,0.041,0.041});
0045   cms_high_mult.push_back({4.6,4.2,5.0,0.64,0.015,0.04,0.04});
0046   plot_infos.push_back(plot_info("CMS 6.2 pb^{-1} pp, 7 TeV, 110#kern[0.3]{#leq}N_{trk}#kern[-0.3]{#leq}130", black_color, 34, cms_high_mult));
0047 
0048   vector<data_point> cms_low_mult;
0049   cms_low_mult.push_back({0.5,0.4,0.6,0.24,0.0052,0.0195,0.0195});
0050   cms_low_mult.push_back({0.7,0.6,0.8,0.299,0.0037,0.0242,0.0242});
0051   cms_low_mult.push_back({0.9,0.8,1.0,0.37,0.0037,0.0297,0.0297});
0052   cms_low_mult.push_back({1.1,1.0,1.2,0.41,0.0042,0.033,0.033});
0053   cms_low_mult.push_back({1.3,1.2,1.4,0.47,0.005,0.038,0.038});
0054   cms_low_mult.push_back({1.5,1.4,1.6,0.51,0.0058,0.0314,0.0314});
0055   cms_low_mult.push_back({1.7,1.6,1.8,0.54,0.0068,0.033,0.033});
0056   cms_low_mult.push_back({1.9,1.8,2.0,0.55,0.0079,0.034,0.034});
0057   cms_low_mult.push_back({2.1,2.0,2.2,0.54,0.0088,0.034,0.034});
0058   cms_low_mult.push_back({2.3,2.2,2.4,0.55,0.0083,0.034,0.034});
0059   cms_low_mult.push_back({2.5,2.4,2.6,0.55,0.012,0.034,0.034});
0060   cms_low_mult.push_back({2.7,2.6,2.8,0.52,0.013,0.032,0.032});
0061   cms_low_mult.push_back({2.9,2.8,3.0,0.54,0.016,0.033,0.033});
0062   cms_low_mult.push_back({3.2,3.0,3.4,0.49,0.012,0.031,0.031});
0063   cms_low_mult.push_back({3.6,3.4,3.8,0.44,0.015,0.027,0.027});
0064   cms_low_mult.push_back({4.0,3.8,4.2,0.4,0.018,0.025,0.025});
0065   cms_low_mult.push_back({4.6,4.2,5.0,0.32,0.016,0.02,0.02});
0066   plot_infos.push_back(plot_info("CMS 6.2 pb^{-1} pp, 7 TeV, 0#kern[0.]{#leq}N_{trk}#kern[0.]{#leq}35", red_color, 29, cms_low_mult));
0067 
0068 
0069   //STAR anti-proton/pion https://www.hepdata.net/record/ins709170
0070   vector<data_point> star;
0071   star.push_back({0.468,0.468,0.468,0.068,0.005,0.01,0.01});
0072   star.push_back({0.563,0.563,0.563,0.091,0.006,0.014,0.014});
0073   star.push_back({0.661,0.661,0.661,0.123,0.008,0.019,0.019});
0074   star.push_back({0.759,0.759,0.759,0.132,0.009,0.02,0.02});
0075   star.push_back({0.858,0.858,0.858,0.165,0.012,0.026,0.026});
0076   star.push_back({0.957,0.957,0.957,0.188,0.016,0.029,0.029});
0077   star.push_back({1.06,1.06,1.06,0.229,0.018,0.026,0.026});
0078   star.push_back({1.16,1.16,1.16,0.238,0.022,0.027,0.027});
0079   star.push_back({1.31,1.31,1.31,0.265,0.021,0.03,0.03});
0080   star.push_back({1.5,1.5,1.5,0.268,0.03,0.03,0.03});
0081   star.push_back({1.7,1.7,1.7,0.352,0.054,0.04,0.04});
0082   star.push_back({1.9,1.9,1.9,0.324,0.064,0.046,0.046});
0083   star.push_back({2.25,2.25,2.25,0.32,0.071,0.084,0.084});
0084   star.push_back({2.75,2.75,2.75,0.289,0.007,0.04,0.04});
0085   star.push_back({3.25,3.25,3.25,0.34,0.013,0.048,0.048});
0086   star.push_back({3.75,3.75,3.75,0.34,0.061,0.049,0.049});
0087   star.push_back({4.25,4.25,4.25,0.271,0.027,0.039,0.039});
0088   star.push_back({4.75,4.75,4.75,0.269,0.042,0.039,0.039});
0089   star.push_back({5.5,5.5,5.5,0.236,0.048,0.035,0.035});
0090   star.push_back({6.5,6.5,6.5,0.179,0.075,0.027,0.027});
0091   //plot_infos.push_back(plot_info("STAR pp, 200 GeV, R(#bar{p}/#pi^{-})", green_color, 33, star));
0092 
0093   //sPHENIX
0094   vector<data_point> sphenix;
0095   // xMean, xLow, xHigh, yMean, yStat, ySystLow, ySystHigh
0096   sphenix.push_back({.1, 0, .2, 0.001726438, 0.0003682367, 0, 0});
0097   sphenix.push_back({.3, .2, .4, 0.01498159, 0.0006501319, 0, 0});
0098   sphenix.push_back({.5, .4, .6, 0.1310696, 0.001475939, 0, 0});
0099   sphenix.push_back({.7, .6, .8, 0.2864402, 0.002205694, 0, 0});
0100   sphenix.push_back({.9, .8, 1.0, 0.3850074, 0.002991455, 0, 0});
0101   sphenix.push_back({1.1, 1.0, 1.2, 0.4419578, 0.004010049, 0, 0});
0102   sphenix.push_back({1.3, 1.2, 1.4, 0.4672351, 0.005322076, 0, 0});
0103   sphenix.push_back({1.5, 1.4, 1.6, 0.4689924, 0.007005992, 0, 0});
0104   sphenix.push_back({1.7, 1.6, 1.8, 0.4359442, 0.0088045, 0, 0});
0105   sphenix.push_back({1.9, 1.8, 2.0, 0.4278972, 0.01167023, 0, 0});
0106   sphenix.push_back({2.1, 2.0, 2.2, 0.3912449, 0.01460502, 0, 0});
0107   sphenix.push_back({2.3, 2.2, 2.4, 0.3576375, 0.01853251, 0, 0});
0108   sphenix.push_back({2.5, 2.4, 2.6, 0.2896642, 0.02089558, 0, 0});
0109   sphenix.push_back({2.7, 2.6, 2.8, 0.2957284, 0.02726913, 0, 0});
0110   sphenix.push_back({2.9, 2.8, 3.0, 0.2348485, 0.03152833, 0, 0});
0111   sphenix.push_back({3.1, 3.0, 3.2, 0.1843575, 0.03353905, 0, 0});
0112   sphenix.push_back({3.3, 3.2, 3.4, 0.2028985, 0.04646774, 0, 0});
0113   sphenix.push_back({3.5, 3.4, 3.6, 0.09677419, 0.04045244, 0, 0});
0114   sphenix.push_back({3.7, 3.6, 3.8, 0.1388889, 0.0642335, 0, 0});
0115   sphenix.push_back({3.9, 3.8, 4.0, 0.212766, 0.1000852, 0, 0});
0116   sphenix.push_back({4.1, 4.0, 4.2, 0.05128205, 0.05193535, 0, 0});
0117   //sphenix.push_back({4.3, 4.2, 4.4, , , 0, 0});
0118   sphenix.push_back({4.5, 4.4, 4.6, 0.2352941, 0.1758929, 0, 0});
0119   sphenix.push_back({4.7, 4.6, 4.8, 0.2857143, 0.2159797, 0, 0});
0120   sphenix.push_back({4.9, 4.8, 5.0, 0.25, 0.265165, 0, 0});
0121   //plot_infos.push_back(plot_info("sPHENIX, 0.05 pb^{-1}, 200 GeV, 0#kern[0.]{#leq}N_{trk}#kern[0.]{#leq}25", blue_color, 22, sphenix));
0122 
0123   vector<data_point> sphenix_OO;
0124   sphenix_OO.push_back({.3, .2, .4, 0.01089852, 0.001913207, 0, 0});
0125   sphenix_OO.push_back({.5, .4, .6, 0.03602371, 0.001676573, 0, 0});
0126   sphenix_OO.push_back({.7, .6, .8, 0.04499276, 0.001248984, 0, 0});
0127   sphenix_OO.push_back({.9, .8, 1.0, 0.05446533, 0.001498692, 0, 0});
0128   sphenix_OO.push_back({1.1, 1.0, 1.2, 0.06701498, 0.002057071, 0, 0});
0129   sphenix_OO.push_back({1.3, 1.2, 1.4, 0.08006025, 0.002934237, 0, 0});
0130   sphenix_OO.push_back({1.5, 1.4, 1.6, 0.09150492, 0.004256059, 0, 0});
0131   sphenix_OO.push_back({1.7, 1.6, 1.8, 0.09419005, 0.005842278, 0, 0});
0132   sphenix_OO.push_back({1.9, 1.8, 2.0, 0.1107023, 0.009028991, 0, 0});
0133   sphenix_OO.push_back({2.1, 2.0, 2.2, 0.05622295, 0.007143845, 0, 0});
0134   sphenix_OO.push_back({2.3, 2.2, 2.4, 0.09146372, 0.01814119, 0, 0});
0135   sphenix_OO.push_back({2.5, 2.4, 2.6, 0.01732629, 0.005819996, 0, 0});
0136   sphenix_OO.push_back({2.7, 2.6, 2.8, 0.0410619, 0.0243738, 0, 0});
0137   sphenix_OO.push_back({2.9, 2.8, 3.0, 0.08192092, 0.106904, 0, 0});
0138   //plot_infos.push_back(plot_info("sPHENIX, 200GeV, O+O",green_color,22,sphenix_OO));
0139 
0140   vector<data_point> sphenix_3run;
0141   sphenix_3run.push_back({.34, .20, .48, 0.04549573, 0.003857831, 0, 0});
0142   sphenix_3run.push_back({.62, .48, .76, 0.2267537, 0.001509736, 0, 0});
0143   sphenix_3run.push_back({.90, .76, 1.04, 0.3664095, 0.002076299, 0, 0});
0144   sphenix_3run.push_back({1.18, 1.04, 1.32, 0.4429479, 0.003736974, 0, 0});
0145   sphenix_3run.push_back({1.46, 1.32, 1.60, 0.4611664, 0.006344749, 0, 0});
0146   sphenix_3run.push_back({1.74, 1.60, 1.88, 0.4358365, 0.01007528, 0, 0});
0147   sphenix_3run.push_back({2.02, 1.88, 2.16, 0.3596045, 0.01446338, 0, 0});
0148   sphenix_3run.push_back({2.30, 2.16, 2.44, 0.2959594, 0.02216775, 0, 0});
0149   sphenix_3run.push_back({2.58, 2.44, 2.72, 0.2461123, 0.03135817, 0, 0});
0150   sphenix_3run.push_back({2.86, 2.72, 3.00, 0.2900647, 0.0132378, 0, 0});
0151   //plot_infos.push_back(plot_info("sPHENIX, run3 pp, runs 79514-79516",green_color,22,sphenix_3run));
0152 
0153   vector<data_point> sphenix_effcorr;
0154   sphenix_effcorr.push_back({0.65,0.5,0.8,0.5344604,0.001185643,0,0});
0155   sphenix_effcorr.push_back({0.95,0.8,1.1,0.5638949,0.001404973,0,0});
0156   sphenix_effcorr.push_back({1.25,1.1,1.4,0.5729109,0.001866033,0,0});
0157   sphenix_effcorr.push_back({1.6,1.4,1.8,0.5708982,0.002445078,0,0});
0158   sphenix_effcorr.push_back({2.,1.8,2.2,0.5638121,0.004267988,0,0});
0159   sphenix_effcorr.push_back({2.6,2.2,3.,0.532113,0.005824996,0,0});
0160   sphenix_effcorr.push_back({3.5,3.,4.,0.5047523,0.0100021,0,0});
0161   plot_infos.push_back(plot_info("sPHENIX, run3 pp, runs 79514-79516",blue_color,22,sphenix_effcorr));
0162 
0163   vector<data_point> sphenix_79514;
0164   sphenix_79514.push_back({.34, .20, .48, 0.01089852, 0.001913207, 0, 0});
0165   sphenix_79514.push_back({.62, .48, .76, 0.03602371, 0.001676573, 0, 0});
0166   sphenix_79514.push_back({.90, .76, 1.04, 0.04499276, 0.001248984, 0, 0});
0167   sphenix_79514.push_back({1.18, 1.04, 1.32, 0.05446533, 0.001498692, 0, 0});
0168   sphenix_79514.push_back({1.46, 1.32, 1.60, 0.06701498, 0.002057071, 0, 0});
0169   sphenix_79514.push_back({1.74, 1.60, 1.88, 0.08006025, 0.002934237, 0, 0});
0170   sphenix_79514.push_back({2.02, 1.88, 2.16, 0.09150492, 0.004256059, 0, 0});
0171   sphenix_79514.push_back({2.30, 2.16, 2.44, 0.09419005, 0.005842278, 0, 0});
0172   sphenix_79514.push_back({2.58, 2.44, 2.72, 0.1107023, 0.009028991, 0, 0});
0173   sphenix_79514.push_back({2.86, 2.72, 3.00, 0.05622295, 0.007143845, 0, 0});
0174   //plot_infos.push_back(plot_info("sPHENIX, run3 pp, run 79514",green_color,22,sphenix_79514));
0175 
0176   // ===== Draw histograms =====
0177   TCanvas *canvas = new TCanvas("canvas", "", 800, 600);
0178   canvas->cd();
0179 
0180   auto multigraph = new TMultiGraph();
0181 
0182   TLegend *legend = new TLegend(0.15, 0.68, 0.8, 0.88);
0183   legend->SetBorderSize(0);
0184   legend->SetLineColor(1);
0185   legend->SetLineStyle(1);
0186   legend->SetLineWidth(1);
0187   legend->SetFillColor(0);
0188   legend->SetFillStyle(0);
0189   legend->SetTextSize(text_size);
0190 
0191   for (unsigned int i = 0; i < plot_infos.size(); ++i)
0192   {
0193     TGraphMultiErrors* myGraph = makeGraph(plot_infos[i]);
0194     multigraph->Add(myGraph);
0195     TLegendEntry *entry=legend->AddEntry(myGraph, plot_infos[i].legend_info.c_str(), "PE1");
0196   }
0197 
0198   multigraph->SetTitle(axisTitles.c_str());
0199   //multigraph->GetXaxis()->SetRangeUser(0, 33);
0200   multigraph->GetYaxis()->SetRangeUser(0, 1.1);
0201   multigraph->Draw("APE1S ; E1 ; 5 s=0.1");
0202   
0203   //makeLine(0, 33);
0204 
0205   legend->Draw();
0206 
0207   TPaveText *pt;
0208   pt = new TPaveText(0.15,0.9,0.95,1., "NDC");
0209   pt->SetFillColor(0);
0210   pt->SetFillStyle(0);
0211   pt->SetTextFont(42);
0212   TText *pt_LaTex;
0213   string labelString = "#it{#bf{sPHENIX}} Internal, Preliminary efficiency correction";
0214   pt_LaTex = pt->AddText(labelString.c_str());
0215   pt->SetBorderSize(0);
0216   pt->Draw();
0217   gPad->Modified();
0218 
0219 
0220   if(save_plot)
0221   {
0222     string extensions[] = {".png", ".pdf"};
0223     for (auto extension : extensions)
0224     {
0225       string output = "plots/" + plotName + extension;
0226       canvas->SaveAs(output.c_str());
0227     }
0228   }
0229 }