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 Combinatorial_Bkg()
0004 {
0005     std::string mother_directory = "/sphenix/tg/tg01/commissioning/INTT/work/cwshih/seflgendata/run_54280_HR_Feb102025/Run6_EvtZFitWidthChange/EvtVtxZ/FinalResult_10cm_Pol2BkgFit/completed";
0006     std::string sPH_label = "Internal";
0007     
0008     SetsPhenixStyle();
0009     TCanvas * c1 = new TCanvas("c1", "c1", 950,800);
0010     
0011     TLatex * ltx = new TLatex();
0012     ltx->SetNDC();
0013     ltx->SetTextSize(0.045);
0014     ltx->SetTextAlign(31);
0015 
0016     TLatex * draw_text = new TLatex();
0017     draw_text -> SetNDC();
0018     draw_text -> SetTextSize(0.03);
0019 
0020     TGraph * MC_sbRatio = new TGraph();
0021     TGraph * data_sbRatio = new TGraph();
0022 
0023     TH2D * h2D_sbRatio = new TH2D("h2D_sbRatio", "h2D_sbRatio;Centrality class index;Combinatorial background ratio, B/(S+B)", 15, 0, 15, 100,0,1);
0024 
0025     
0026     for (int i = 0; i < 15; i++) // note : 0 to 14, the Mbin
0027     {
0028         std::string Mbin_folder_name = Form("vtxZ_-10_10cm_MBin%d",i);
0029         
0030         std::string data_file = Form("Data_PreparedNdEtaEach_AlphaCorr_AllSensor_VtxZ10_Mbin%d_00054280_00000_DeltaPhi.root",i);
0031         std::string MC_file = Form("MC_PreparedNdEtaEach_AllSensor_VtxZ10_Mbin%d_00001_DeltaPhi.root",i);
0032 
0033         TFile * file_data = TFile::Open(Form("%s/%s/Folder_BaseLine/Run_0/completed/%s", mother_directory.c_str(), Mbin_folder_name.c_str(), data_file.c_str()));
0034         TFile * file_MC = TFile::Open(Form("%s/%s/Folder_BaseLine/Run_0/completed/%s", mother_directory.c_str(), Mbin_folder_name.c_str(), MC_file.c_str()));
0035         
0036 
0037         for (int eta_i = 8; eta_i <= 18; eta_i++)
0038         {
0039             std::string hist_name = Form("hstack1D_DeltaPhi_Eta%d", eta_i);
0040             std::string hist_name_rotated = Form("hstack1D_DeltaPhi_Eta%d_rotated", eta_i);
0041 
0042             TH1D * data = (TH1D*)((THStack*)file_data->Get(hist_name.c_str()))->GetStack()->Last();
0043             TH1D * MC = (TH1D*)((THStack*)file_MC->Get(hist_name.c_str()))->GetStack()->Last();
0044 
0045             TH1D * data_rotated = (TH1D*)((THStack*)file_data->Get(hist_name_rotated.c_str()))->GetStack()->Last();
0046             TH1D * MC_rotated = (TH1D*)((THStack*)file_MC->Get(hist_name_rotated.c_str()))->GetStack()->Last();
0047 
0048             MC_sbRatio -> SetPoint(MC_sbRatio->GetN(), i, MC_rotated->Integral() / MC->Integral()); // note : B / S+B
0049             data_sbRatio -> SetPoint(data_sbRatio->GetN(), i, data_rotated->Integral() / data->Integral()); // note : B / S+B
0050 
0051             // h2D_sbRatio -> Fill(i, MC_rotated->Integral() / MC->Integral());
0052             h2D_sbRatio -> Fill(i, data_rotated->Integral() / data->Integral());
0053         }
0054     }
0055 
0056     MC_sbRatio -> SetMarkerStyle(20);
0057     MC_sbRatio -> SetMarkerSize(0.8);
0058     MC_sbRatio -> SetMarkerColor(kBlue);
0059 
0060     data_sbRatio -> SetMarkerStyle(20);
0061     data_sbRatio -> SetMarkerSize(0.8);
0062     data_sbRatio -> SetMarkerColor(kBlack);
0063 
0064     MC_sbRatio -> GetXaxis() -> SetTitle("Mbin");
0065     MC_sbRatio -> GetYaxis() -> SetTitle("B / S+B");
0066 
0067     // MC_sbRatio -> Draw("AP");
0068     // data_sbRatio -> Draw("P same");
0069 
0070     h2D_sbRatio -> Draw("colz");
0071 
0072     // draw profile of h2D_sbRatio
0073     TProfile * profile = h2D_sbRatio -> ProfileX();
0074     profile -> SetMarkerStyle(20);
0075     profile -> SetMarkerSize(0.8);
0076     profile -> SetMarkerColor(kRed);
0077     profile -> Draw("pl same");
0078 
0079     ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, Form("#it{#bf{sPHENIX}} %s", sPH_label.c_str())); 
0080     draw_text -> DrawLatex(0.52, 0.85 + 0.02, "Centrality class 0: 0-3%");
0081     draw_text -> DrawLatex(0.52, 0.81 + 0.02, "Centrality class 14: 65-70%");
0082     draw_text -> DrawLatex(0.52, 0.77 + 0.02, "|INTT vtxZ|#kern[1]{#leq} 10.0 cm");
0083     draw_text -> DrawLatex(0.52, 0.73 + 0.02, "|#eta bin|#kern[1]{#leq} 1.1");
0084 
0085     c1 -> Print("Combinatorial_Bkg.pdf");
0086 
0087     // print the points of the profile
0088     for (int i = 0; i < profile->GetNbinsX(); i++)
0089     {
0090         std::cout<<profile->GetBinCenter(i + 1)<<" "<<profile->GetBinContent(i + 1)<<std::endl;
0091     }
0092 
0093 
0094     return 0;
0095 }