Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:12:38

0001 #include "sPhenixStyle.C"
0002 
0003 int MakePlot_2Obj()
0004 {
0005     std::string input_file_directory_1 = "/sphenix/tg/tg01/commissioning/INTT/work/cwshih/seflgendata/run_54280_HR_Feb102025/Run6_EvtZFitWidthChange/EvtVtxZ/old_folder/FinalResult_10cm_Pol2BkgFit/completed/vtxZ_-10_10cm_MBin70/Folder_BaseLine/Run_0/completed"; 
0006     std::string input_file_name_1 = "Data_PreparedNdEtaEach_AlphaCorr_AllSensor_VtxZ10_Mbin70_00054280_00000_dNdEta.root";
0007     std::string target_plot_name_1 = "h1D_RotatedBkg_RecoTrackletEtaPerEvt";
0008     
0009     std::string input_file_directory_2 = "/sphenix/tg/tg01/commissioning/INTT/work/cwshih/seflgendata/run_54280_HR_Feb102025/Run6_EvtZFitWidthChange/EvtVtxZ/FinalResult_10cm_Pol2BkgFit/completed/vtxZ_-10_10cm_MBin70/Folder_DeltaPhiCut/Run_0/completed";
0010     std::string input_file_name_2 = "Data_PreparedNdEtaEach_AlphaCorr_AllSensor_VtxZ10_Mbin70_00054280_00000_dNdEta.root";
0011     std::string target_plot_name_2 = "h1D_RotatedBkg_RecoTrackletEtaPerEvt";
0012     
0013     
0014     std::string output_directory = input_file_directory_1;
0015     std::string output_file_name = "h1D_RotatedBkg_RecoTrackletEtaPerEvt";
0016     std::pair<std::string, std::string> axes_label = {"Tracklet #eta", "Average Multiplicity Per Event  (/0.2)"};
0017     std::string sPH_label = "Internal";
0018     std::vector<std::tuple<double,double,std::string>> additional_text = {
0019         // {0.2, 0.9, "The cluster pairs post the VtxZ linking requirement are filled"},
0020 
0021         {0.22, 0.9, "Au+Au 200 GeV"},
0022         // {0.22, 0.86, "HIJING"},
0023         {0.22, 0.86, "Centrality 0-70%"},
0024         {0.22, 0.82, "|INTT vtxZ| #leq 10 cm"}
0025 
0026         // {0.22, 0.90, "Inner clusters rotated by #pi in #phi angle"},
0027         // {0.22, 0.86 + 0.04, "#eta: [0.5 - 0.7]"},
0028         // {0.22, 0.82 + 0.04, "Centrality 0-70%"},
0029         // {0.22, 0.78 + 0.04, "|INTT vtxZ| #leq 10 cm"}
0030 
0031     };
0032 
0033     // std::vector<std::tuple<int, std::string,std::string>> legend_text = {
0034     //     {4, "Nominal", "l"},
0035     //     {2, "Rotated", "l"},
0036     //     {3, "Subtracted", "l"}
0037     // };
0038 
0039     std::vector<std::tuple<int, std::string, std::string>> legend_text = {
0040         {2, "HIJING generator level", "l"},
0041         {4, "Reco. Tracklets", "pl"}
0042     };
0043 
0044     bool isSetLogY = false;
0045     bool isSetLogZ = false;
0046     double y_min = 0;
0047     double y_max = 350;
0048     bool set_X_505 = true;
0049 
0050     system(Form("mkdir -p %s", output_directory.c_str()));
0051     
0052     SetsPhenixStyle();
0053 
0054     TLegend * leg = new TLegend(0.52,0.81,0.72,0.9);
0055     // leg -> SetNColumns(2);
0056     leg -> SetBorderSize(0);
0057     leg -> SetTextSize(0.025);
0058     leg -> SetMargin(0.2);
0059 
0060     TCanvas * c1 = new TCanvas("c1", "c1", 950, 800);
0061 
0062     TLatex * ltx = new TLatex();
0063     ltx->SetNDC();
0064     ltx->SetTextSize(0.045);
0065     ltx->SetTextAlign(31);
0066 
0067     TLatex * draw_text = new TLatex();
0068     draw_text -> SetNDC();
0069     draw_text -> SetTextSize(0.03);
0070 
0071     TFile * file_in = TFile::Open(Form("%s/%s", input_file_directory.c_str(), input_file_name.c_str()));
0072     if (!file_in){
0073         std::cout<<"Error: cannot open file: "<<input_file_name<<std::endl;
0074         return 1;
0075     }
0076 
0077     TH1D * h1D_in_1 = (TH1D*) file_in -> Get(Form("%s", target_plot_name_1.c_str()));
0078     if (!h1D_in_1){
0079         std::cout<<"Error: cannot find histogram: "<<target_plot_name_1<<std::endl;
0080         return 1;
0081     }
0082 
0083     h1D_in_1 -> SetMarkerStyle(20);
0084     h1D_in_1 -> SetMarkerSize(0.7);
0085     h1D_in_1  -> SetMarkerColor(std::get<0>(legend_text[0]));
0086     h1D_in_1    -> SetLineColor(std::get<0>(legend_text[0]));
0087     leg -> AddEntry(h1D_in_1, std::get<1>(legend_text[0]).c_str(), std::get<2>(legend_text[0]).c_str());
0088 
0089     TH1D * h1D_in_2 = (TH1D*) file_in -> Get(Form("%s", target_plot_name_2.c_str()));
0090     if (!h1D_in_2){
0091         std::cout<<"Error: cannot find histogram: "<<target_plot_name_2<<std::endl;
0092         return 1;
0093     }
0094 
0095     h1D_in_2 -> SetMarkerStyle(20);
0096     h1D_in_2 -> SetMarkerSize(0.7);
0097     h1D_in_2  -> SetMarkerColor(std::get<0>(legend_text[1]));
0098     h1D_in_2    -> SetLineColor(std::get<0>(legend_text[1]));
0099     leg -> AddEntry(h1D_in_2, std::get<1>(legend_text[1]).c_str(), std::get<2>(legend_text[1]).c_str());
0100 
0101 
0102     if (isSetLogY){ // note : logy
0103         h1D_in_1 -> SetMaximum(y_max);
0104         c1 -> SetLogy(true);
0105     }
0106     else if (!isSetLogY) // note : linear y
0107     {
0108         h1D_in_1 -> SetMinimum(y_min);
0109         h1D_in_1 -> SetMaximum(y_max);
0110     }
0111 
0112 
0113 
0114     if (axes_label.first.size() > 0){
0115         h1D_in_1 -> GetXaxis() -> SetTitle(axes_label.first.c_str());
0116     }
0117     if (axes_label.second.size() > 0){
0118         h1D_in_1 -> GetYaxis() -> SetTitle(axes_label.second.c_str());
0119     }
0120 
0121     if (set_X_505) {h1D_in_1 -> GetXaxis() -> SetNdivisions(505);}
0122 
0123 
0124     // todo : the drawing 
0125     c1 -> cd();
0126 
0127     gStyle->SetPaintTextFormat("1.3f");
0128 
0129     h1D_in_1 -> Draw("hist");
0130     h1D_in_2 -> Draw("ep same");
0131 
0132     // hist_in -> SetMarkerSize(0.5);
0133     // hist_in -> Draw("hist TEXT90");
0134 
0135     // hstack1D_in -> SetMarkerSize(0.8);
0136     // hstack1D_in -> Draw("hist TEXT90 E");
0137     // temp_h1D -> Draw("hist");
0138     // hstack1D_in -> Draw("hist same");
0139 
0140 
0141 
0142     ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, Form("#it{#bf{sPHENIX}} %s", sPH_label.c_str())); 
0143 
0144     for (auto text : additional_text){
0145         double x = std::get<0>(text);
0146         double y = std::get<1>(text);
0147         std::string text_str = std::get<2>(text);
0148 
0149         draw_text -> DrawLatex(x, y, text_str.c_str());
0150     }
0151 
0152     leg -> Draw("same");
0153 
0154     c1 -> Print(Form("%s/%s.pdf", output_directory.c_str(), output_file_name.c_str()));
0155     c1 -> Clear();
0156 
0157     return 0;
0158 }