Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-09 08:12:13

0001 int CheckMCCentrality()
0002 {
0003     std::string file_directory = "/sphenix/user/ChengWei/sPH_dNdeta/Run24AuAuMC/Sim_HIJING_MDC2_ana472_20250307/per5k";
0004     std::string file_name = "ntuple_per5k_0*.root";
0005 
0006     // std::string file_directory = "/sphenix/user/ChengWei/sPH_dNdeta/Run24AuAuMC/Sim_HIJING_ananew_20250131/per10k";
0007     // std::string file_name = "ntuple_per10k_0*.root";
0008 
0009     TChain * tree_in = new TChain("EventTree");
0010     tree_in -> Add(Form("%s/%s", file_directory.c_str(), file_name.c_str()));
0011 
0012     tree_in -> SetBranchStatus("*", 0);
0013     tree_in -> SetBranchStatus("MBD_centrality", 1);
0014     tree_in -> SetBranchStatus("is_min_bias", 1);
0015     tree_in -> SetBranchStatus("MBD_z_vtx", 1);
0016 
0017     float MBD_centrality;
0018     bool is_min_bias;
0019     float MBD_z_vtx;
0020 
0021     tree_in -> SetBranchAddress("MBD_centrality", &MBD_centrality);
0022     tree_in -> SetBranchAddress("is_min_bias", &is_min_bias);
0023     tree_in -> SetBranchAddress("MBD_z_vtx", &MBD_z_vtx);
0024 
0025     int n_entries = tree_in -> GetEntries();
0026 
0027     TH1D * h_centrality = new TH1D("h_centrality", "h_centrality", 101, -0.5, 100.5);
0028     
0029     std::vector<TF1 *> v_fit; v_fit.clear();
0030     std::vector<TH1D *> v_h_centrality; v_h_centrality.clear();
0031 
0032     TCanvas * c2 = new TCanvas("c2", "c2", 600, 600);
0033     c2 -> Print("CheckMCCentrality.pdf[");
0034 
0035     TCanvas * c1 = new TCanvas("c1", "c1", 1400, 600);
0036     c1 -> Divide(2, 1);
0037 
0038     TGraph * g_eID_fiterror = new TGraph();
0039     TGraph * g_eID_RChi2 = new TGraph();
0040 
0041 
0042     for (int i = 0; i < n_entries; i++)
0043     {
0044         tree_in -> GetEntry(i);
0045 
0046         if (is_min_bias == 0) continue;
0047         if (MBD_z_vtx != MBD_z_vtx) continue;
0048         if (MBD_centrality != MBD_centrality) continue;
0049 
0050         h_centrality -> Fill(MBD_centrality);
0051 
0052         if (int(h_centrality -> GetEntries()) % 5000 == 0){
0053             v_fit.push_back(new TF1(Form("f_%.0f", h_centrality -> GetEntries()), "pol0", -10,110));
0054 
0055             v_h_centrality.push_back((TH1D*)h_centrality -> Clone(Form("h_centrality_%.0f", h_centrality -> GetEntries())));
0056             v_h_centrality.back() -> Scale(1.0 / v_h_centrality.back() -> GetEntries());
0057             v_h_centrality.back() -> Fit(v_fit.back(), "NQ","",1,92);
0058 
0059             g_eID_fiterror -> SetPoint(g_eID_fiterror -> GetN(), h_centrality -> GetEntries(), v_fit.back() -> GetParError(0));
0060             g_eID_RChi2    -> SetPoint(g_eID_RChi2 -> GetN(), h_centrality -> GetEntries(), v_fit.back() -> GetChisquare() / double(v_fit.back() -> GetNDF()));
0061 
0062             c2 -> cd();
0063             v_h_centrality.back() -> Draw("ep");
0064             v_fit.back() -> Draw("same");
0065 
0066             c2 -> Print("CheckMCCentrality.pdf");
0067         }
0068     }
0069 
0070     c2 -> Print("CheckMCCentrality.pdf]");
0071 
0072     g_eID_fiterror -> SetMarkerStyle(20);
0073     g_eID_fiterror -> SetMarkerSize(0.5);
0074     g_eID_RChi2 -> SetMarkerStyle(20);
0075     g_eID_RChi2 -> SetMarkerSize(0.5);
0076 
0077     c1 -> cd(1);
0078     g_eID_fiterror -> Draw("AP");
0079     c1 -> cd(2);
0080     g_eID_RChi2 -> Draw("AP");
0081 
0082     c1 -> Print("CheckMCCentrality_correlation.pdf");
0083 
0084     return 888;
0085 }