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