File indexing completed on 2025-08-06 08:12:39
0001 #include "sPhenixStyle.C"
0002 #include "../Constants.cpp"
0003
0004 int MakePlot_PariDeltaPhi()
0005 {
0006 int Mbin = 0;
0007
0008 std::string input_file_directory = 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/Folder_BaseLine/Run_0/completed", Mbin);
0009 std::string input_file_name = Form("Data_PreparedNdEtaEach_AlphaCorr_AllSensor_VtxZ10_Mbin%d_00054280_00000_DeltaPhi.root", Mbin);
0010
0011 std::string target_canvas_name = "c1_hstack1D_DeltaPhi_Eta8";
0012
0013 std::string output_directory = input_file_directory;
0014
0015 std::pair<std::string, std::string> axes_label = {"Valid cluster pair#kern[0.3]{#Delta#phi} [Radian]", "Counts (/0.001 Radian)"};
0016
0017 std::string sPH_label = "";
0018 std::vector<std::tuple<double,double,std::string>> additional_text = {
0019
0020
0021
0022
0023
0024
0025
0026
0027 {0.21, 0.83, "Au+Au#kern[0.25]{#sqrt{s_{NN}}} = 200 GeV"},
0028
0029 {0.21, 0.78, "-1.1 <#kern[1]{#eta} < -0.9"},
0030 {0.21, 0.73, Form("Centrality: %s%%", Constants::centrality_text[Mbin].c_str())}
0031
0032
0033 };
0034
0035 std::vector<std::tuple<int, std::string,std::string, int>> legend_text = {
0036 {1, "Nominal", "ep", 20},
0037 {95, "Inner layer rotated by#kern[0.6]{#pi}", "ep", 24},
0038 {3, "Subtracted", "f", 20},
0039 {41, "Pol-2 Bkg Fit", "l", 20}
0040 };
0041
0042 double y_max = 2300000;
0043
0044 SetsPhenixStyle();
0045
0046 TCanvas * c2 = new TCanvas("c2", "c2", 950, 800);
0047
0048 TLatex * ltx = new TLatex();
0049 ltx->SetNDC();
0050 ltx->SetTextSize(0.045);
0051
0052
0053 TLatex * draw_text = new TLatex();
0054 draw_text -> SetNDC();
0055 draw_text -> SetTextSize(0.045);
0056
0057 TLegend * leg = new TLegend(0.4,0.6,0.73,0.70);
0058
0059
0060 leg -> SetTextSize(0.04);
0061 leg -> SetMargin(0.15);
0062
0063 TFile * file_in = TFile::Open(Form("%s/%s", input_file_directory.c_str(), input_file_name.c_str()));
0064 TCanvas * c1 = (TCanvas*)file_in->Get(target_canvas_name.c_str());
0065
0066
0067
0068 TList* primitives = c1->GetListOfPrimitives();
0069 if (!primitives) {
0070 std::cerr << "No primitives found in TCanvas!" << std::endl;
0071 file_in->Close();
0072 return 666;
0073 }
0074
0075 int legend_index = 0;
0076
0077
0078 std::vector<TH1D*> hists; hists.clear();
0079 std::vector<TF1*> fits; fits.clear();
0080
0081 for (auto* obj : *primitives) {
0082
0083 TH1D* hist = dynamic_cast<TH1D*>(obj);
0084 TF1 * fit = dynamic_cast<TF1*>(obj);
0085
0086 if (hist) {
0087
0088 int color = std::get<0>(legend_text[legend_index]);
0089 std::string text = std::get<1>(legend_text[legend_index]);
0090 std::string draw_type = std::get<2>(legend_text[legend_index]);
0091 int marker_style = std::get<3>(legend_text[legend_index]);
0092
0093 hist -> SetLineColor( color );
0094 std::cout<<hist->GetName()<<", set line color : "<<hist->GetLineColor()<<std::endl;
0095
0096
0097 hist -> SetMaximum(y_max);
0098 hist -> SetMinimum(0);
0099
0100 hist -> SetMarkerSize(0.65);
0101 hist -> SetMarkerColor(color);
0102 hist -> SetMarkerStyle(marker_style);
0103
0104 hist -> GetXaxis() -> SetNdivisions(504, false);
0105 hist -> GetYaxis() -> SetNdivisions(505);
0106
0107
0108 if (axes_label.first.size() > 0){
0109 hist -> GetXaxis() -> SetTitle(axes_label.first.c_str());
0110 }
0111 if (axes_label.second.size() > 0){
0112 hist -> GetYaxis() -> SetTitle(axes_label.second.c_str());
0113 }
0114
0115 hists.push_back(hist);
0116
0117 legend_index += 1;
0118 }
0119
0120 if (fit){
0121 int color = std::get<0>(legend_text[legend_index]);
0122 std::string text = std::get<1>(legend_text[legend_index]);
0123 std::string draw_type = std::get<2>(legend_text[legend_index]);
0124
0125 fit -> SetLineColor( color );
0126 fit -> SetLineWidth(1);
0127 fit -> SetLineStyle(2);
0128 std::cout<<fit->GetName()<<", set line color : "<<fit->GetLineColor()<<", lien style : "<<fit -> GetLineStyle()<<std::endl;
0129
0130
0131 fits.push_back(fit);
0132
0133 legend_index += 1;
0134 }
0135 }
0136
0137
0138
0139
0140 c2 -> cd();
0141
0142 hists[0] -> Draw("ep");
0143
0144
0145 std::string text = std::get<1>(legend_text[0]);
0146 std::string draw_type = std::get<2>(legend_text[0]);
0147 leg -> AddEntry(hists[0], text.c_str(), draw_type.c_str());
0148
0149 hists[1] -> Draw("ep same");
0150
0151
0152 text = std::get<1>(legend_text[1]);
0153 draw_type = std::get<2>(legend_text[1]);
0154 leg -> AddEntry(hists[1], text.c_str(), draw_type.c_str());
0155
0156
0157 ltx->DrawLatex(0.21, 0.89, Form("#it{#bf{sPHENIX}} %s", sPH_label.c_str()));
0158
0159 for (auto text : additional_text){
0160 double x = std::get<0>(text);
0161 double y = std::get<1>(text);
0162 std::string text_str = std::get<2>(text);
0163
0164 draw_text -> DrawLatex(x, y, text_str.c_str());
0165 }
0166
0167 leg -> Draw("same");
0168
0169 c2 -> Print(Form("%s/%s.pdf", output_directory.c_str(), target_canvas_name.c_str()));
0170
0171
0172 return 0;
0173 }