Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:11:56

0001 #include "ReadINTTZ_v2.C"
0002 #include "../sPhenixStyle.C"
0003 
0004 void zvtx_study()
0005 {   
0006     string input_directory = "/sphenix/user/ChengWei/sPH_dNdeta/HIJING_ana398_xvtx-0p04cm_yvtx0p24cm_zvtx-20cm_dummyAlignParams/SemiFinal_EvtZ_MC_ZF_zvtx";
0007     string input_filename = "INTT_zvtx.root";
0008     TFile * file_in = TFile::Open(Form("%s/%s",input_directory.c_str(), input_filename.c_str()));
0009     TTree * tree_in = (TTree *)file_in->Get("tree_Z");
0010     ReadINTTZ_v2 * read_tree = new ReadINTTZ_v2(tree_in);
0011 
0012     cout<<"tree entry : "<<tree_in -> GetEntries()<<endl;
0013 
0014     SetsPhenixStyle();
0015     
0016     TCanvas * c1 = new TCanvas("","",950,800);
0017     c1 -> cd();
0018 
0019     TLatex * ltx = new TLatex();
0020     ltx->SetNDC();
0021     ltx->SetTextSize(0.045);
0022     ltx->SetTextAlign(31);
0023 
0024     TLatex * draw_text = new TLatex();
0025     draw_text -> SetNDC();
0026     draw_text -> SetTextSize(0.03);
0027 
0028     map<int,int> centrality_map = {
0029         {5, 0},
0030         {15, 1},
0031         {25, 2},
0032         {35, 3},
0033         {45, 4},
0034         {55, 5},
0035         {65, 6},
0036         {75, 7},
0037         {85, 8},
0038         {95, 9}
0039     };
0040 
0041     vector<string> centrality_region = {
0042         "0-5%",
0043         "5-15%",
0044         "15-25%",
0045         "25-35%",
0046         "35-45%",
0047         "45-55%",
0048         "55-65%",
0049         "65-75%",
0050         "75-85%",
0051         "85-95%",
0052         "0-95%"
0053     };
0054 
0055     TF1 * gaus_fit = new TF1("gaus_fit","gaus",-40,40);
0056     gaus_fit -> SetLineColor(2);
0057     gaus_fit -> SetNpx(2000);
0058 
0059     // TH2F * Z
0060     TGraph * Z_resolution_centrality_gr = new TGraph();
0061     Z_resolution_centrality_gr -> SetMarkerStyle(20);
0062     Z_resolution_centrality_gr -> SetMarkerSize(1.5);
0063     Z_resolution_centrality_gr -> GetXaxis()->SetTitle("Centrality bin"); 
0064     Z_resolution_centrality_gr -> GetYaxis()->SetTitle("#DeltaZ width");
0065 
0066     vector<TH1F *> Z_resolution; Z_resolution.clear();
0067     for (int i = 0; i < centrality_region.size(); i++)
0068     {
0069         Z_resolution.push_back(new TH1F("","",100,-40,40)); // note : unit: mm
0070         Z_resolution[i]->GetXaxis()->SetTitle("#DeltaZ (Reco - True) [mm]");
0071         Z_resolution[i]->GetYaxis()->SetTitle("Entry");
0072     }
0073 
0074     for (int event_i = 0; event_i < tree_in -> GetEntries(); event_i++)
0075     {
0076         read_tree->LoadTree(event_i);
0077         read_tree->GetEntry(event_i);
0078         
0079         if (read_tree -> nclu_inner == -1)   {continue;}
0080         if (read_tree -> nclu_outer == -1)   {continue;}
0081         if (read_tree -> good_zvtx_tag != 1) {continue;}
0082 
0083         Z_resolution[ centrality_map[read_tree->Centrality_bin] ] -> Fill( read_tree->LB_Gaus_Mean_mean - read_tree->MC_true_zvtx );
0084         Z_resolution[ Z_resolution.size() - 1 ]                   -> Fill( read_tree->LB_Gaus_Mean_mean - read_tree->MC_true_zvtx );
0085         // cout<<"test : "<<event_i<<" read_tree->Centrality_bin "<<read_tree->Centrality_bin<<endl;
0086         // cout<<read_tree->MC_true_zvtx<<endl;
0087     }
0088 
0089     c1 -> Print(Form("%s/INTT_Z_resolution_centrality.pdf(", input_directory.c_str()));
0090     for (int i = 0; i < Z_resolution.size(); i++)
0091     {
0092         Z_resolution[i] -> SetMinimum(0);
0093         Z_resolution[i] -> Draw("hist");
0094         
0095         if (i == Z_resolution.size() - 1) 
0096         {
0097             Z_resolution[i] -> Fit(gaus_fit,"NQ","", Z_resolution[i]->GetStdDev() * -1, Z_resolution[i]->GetStdDev());
0098             gaus_fit -> SetRange(gaus_fit->GetParameter(1) - 1.5 * gaus_fit->GetParameter(2), gaus_fit->GetParameter(1) + 1.5 * gaus_fit->GetParameter(2));
0099         }
0100         else 
0101         {
0102             Z_resolution[i] -> Fit(gaus_fit,"NQ");
0103         }
0104 
0105         
0106         ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, Form("#it{#bf{sPHENIX INTT}} %s", "Simulation"));
0107         draw_text -> DrawLatex(0.21, 0.90, Form("Centrality : %s",centrality_region[i].c_str()));
0108         gaus_fit -> Draw("lsame");
0109 
0110         Z_resolution_centrality_gr -> SetPoint(i, i, gaus_fit->GetParameter(2));
0111 
0112         c1 -> Print(Form("%s/INTT_Z_resolution_centrality.pdf", input_directory.c_str()));
0113         c1 -> Clear();
0114     }
0115     c1 -> Print(Form("%s/INTT_Z_resolution_centrality.pdf)", input_directory.c_str()));
0116     c1 -> Clear();
0117 
0118     Z_resolution_centrality_gr -> Draw("ap");
0119     Z_resolution_centrality_gr -> GetXaxis() -> SetLimits(-1,11);
0120     ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, Form("#it{#bf{sPHENIX INTT}} %s", "Simulation"));
0121     c1 -> Print(Form("%s/Z_resolution_centrality_gr.pdf", input_directory.c_str()));
0122 
0123     for (int i = 0; i < Z_resolution_centrality_gr->GetN(); i++)
0124     {
0125         cout<<i<<" "<<Z_resolution_centrality_gr->GetPointY(i)<<endl;
0126     }
0127 }