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_2DTrackletFill()
0004 {
0005     std::string input_file_directory = "/sphenix/user/ChengWei/sPH_dNdeta/Run24AuAuMC/Sim_HIJING_MDC2_ana472_20250307/Run7/AvgVtxXY/completed"; 
0006     std::string input_file_name = "MC_AvgVtxXY_00000";
0007     std::string target_plot1_name = "h2_LineFilled_XY";
0008     std::string target_plot2_name = "h2_LineFilled_XY_bkgrm";
0009 
0010     std::string output_directory = input_file_directory;
0011 
0012     std::pair<std::string, std::string> axes_label = {"X axis [cm]", "Y axis [cm]"};
0013     
0014     std::string sPH_label = "Simulation";
0015     std::vector<std::tuple<double,double,std::string>> additional_text = {
0016         // {0.2, 0.9, "The cluster pairs post the VtxZ linking requirement are filled"},
0017 
0018         // {0.22, 0.9, "Au+Au 200 GeV"},
0019         {0.16, 0.96, "Generator: HIJING"} // todo: change the generator if needed
0020     };
0021     
0022     SetsPhenixStyle();
0023 
0024     TCanvas * c1 = new TCanvas("c1", "c1", 950, 800);
0025 
0026     TLatex * ltx = new TLatex();
0027     ltx->SetNDC();
0028     ltx->SetTextSize(0.045);
0029     ltx->SetTextAlign(31);
0030 
0031     TLatex * draw_text = new TLatex();
0032     draw_text -> SetNDC();
0033     draw_text -> SetTextSize(0.03);
0034 
0035     TFile * file_in = TFile::Open(Form("%s/%s.root", input_file_directory.c_str(), input_file_name.c_str()));
0036     TH2D * h2D_plot1 = (TH2D*)file_in->Get(target_plot1_name.c_str());
0037     TH2D * h2D_plot2 = (TH2D*)file_in->Get(target_plot2_name.c_str());
0038 
0039     h2D_plot1 -> GetXaxis() -> SetTitle(axes_label.first.c_str());
0040     h2D_plot1 -> GetYaxis() -> SetTitle(axes_label.second.c_str());
0041     h2D_plot1 -> GetXaxis() -> SetNdivisions(505);
0042     
0043     h2D_plot2 -> GetXaxis() -> SetTitle(axes_label.first.c_str());
0044     h2D_plot2 -> GetYaxis() -> SetTitle(axes_label.second.c_str());
0045     h2D_plot2 -> GetXaxis() -> SetNdivisions(505);
0046 
0047 
0048     c1 -> cd();
0049     h2D_plot1 -> Draw("colz0");
0050     ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, Form("#it{#bf{sPHENIX}} %s", sPH_label.c_str()));
0051     
0052     for (auto text : additional_text){
0053         double x = std::get<0>(text);
0054         double y = std::get<1>(text);
0055         std::string text_str = std::get<2>(text);
0056 
0057         draw_text -> DrawLatex(x, y, text_str.c_str());
0058     }
0059 
0060     c1 -> Print(Form("%s/%s_%s.pdf", output_directory.c_str(),input_file_name.c_str(),target_plot1_name.c_str()));
0061     c1 -> Clear();
0062 
0063     c1 -> cd();
0064     h2D_plot2 -> Draw("colz0");
0065     ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, Form("#it{#bf{sPHENIX}} %s", sPH_label.c_str()));
0066 
0067     TGraph * gr = new TGraph();
0068     gr -> SetPoint(0, h2D_plot2->GetMean(1), h2D_plot2->GetMean(2));
0069     gr -> SetMarkerStyle(34);
0070     gr -> SetMarkerSize(1);
0071     gr -> SetMarkerColor(kRed);
0072 
0073     for (auto text : additional_text){
0074         double x = std::get<0>(text);
0075         double y = std::get<1>(text);
0076         std::string text_str = std::get<2>(text);
0077 
0078         draw_text -> DrawLatex(x, y, text_str.c_str());
0079     }
0080 
0081     draw_text -> DrawLatex(0.22, 0.88, Form("Beam spot of the sub-sample: %.4f cm, %.4f cm", h2D_plot2->GetMean(1), h2D_plot2->GetMean(2)));
0082     gr -> Draw("P same");
0083 
0084     c1 -> Print(Form("%s/%s_%s.pdf", output_directory.c_str(),input_file_name.c_str(),target_plot2_name.c_str()));
0085     return 0;
0086 
0087 
0088 }