File indexing completed on 2025-08-06 08:12:20
0001 #include "CheckEvtXY.h"
0002
0003 CheckEvtXY::CheckEvtXY(
0004 string mother_folder_directory_in,
0005 string input_file_list_in,
0006 string out_folder_directory_in,
0007 std::pair<double, double> beam_origin_in,
0008 int NClus_cut_label_in,
0009 int unit_tag_in,
0010 string run_type_in
0011 )
0012 :
0013 mother_folder_directory(mother_folder_directory_in),
0014 input_file_list(input_file_list_in),
0015 out_folder_directory(out_folder_directory_in),
0016 beam_origin(beam_origin_in),
0017 NClus_cut_label(NClus_cut_label_in),
0018 unit_tag(unit_tag_in),
0019 run_type(run_type_in)
0020 {
0021 unit_correction = (unit_tag == 1) ? 0.1 : 1.;
0022 unit_text = (unit_tag == 1) ? "cm" : "mm";
0023 sPHENIX_suffix = (run_type == "MC") ? "Simulation" : "Work-in-progress";
0024
0025 beam_origin.first = beam_origin.first * unit_correction;
0026 beam_origin.second = beam_origin.second * unit_correction;
0027
0028 SetsPhenixStyle();
0029 Init();
0030 }
0031
0032 void CheckEvtXY::Init()
0033 {
0034
0035 data_in = new ReadEvtXY_Chain(mother_folder_directory, input_file_list);
0036 cout<<" data_in, number of entries: "<<data_in -> GetEntries()<<endl;
0037
0038
0039 data_in -> LoadTree(data_in -> GetEntries() - 1);
0040 data_in -> GetEntry(data_in -> GetEntries() - 1);
0041
0042 c1 = new TCanvas("c1", "c1", 950, 800);
0043
0044 cout<<"input beam_origin : "<<beam_origin.first<<", "<<beam_origin.second<<Form(" in unit : %s",unit_text.c_str())<<endl;;
0045
0046
0047 double window_half_width = 1.; window_half_width = window_half_width * unit_correction;
0048 double small_half_width = 0.75; small_half_width = small_half_width * unit_correction;
0049 double diff_half_width = 0.5; diff_half_width = diff_half_width * unit_correction;
0050
0051 vtxX_1D = new TH1F("","vtxX_1D", 100, -window_half_width + beam_origin.first, window_half_width + beam_origin.first);
0052 vtxX_1D -> SetStats(0);
0053 vtxX_1D -> GetXaxis() -> SetTitle(Form("Vertex X [%s]", unit_text.c_str()));
0054 vtxX_1D -> GetYaxis() -> SetTitle("Entry");
0055 vtxX_1D -> GetXaxis() -> SetNdivisions(505);
0056
0057 vtxY_1D = new TH1F("","vtxY_1D", 100, -window_half_width + beam_origin.second, window_half_width + beam_origin.second);
0058 vtxY_1D -> SetStats(0);
0059 vtxY_1D -> GetXaxis() -> SetTitle(Form("Vertex Y [%s]", unit_text.c_str()));
0060 vtxY_1D -> GetYaxis() -> SetTitle("Entry");
0061 vtxY_1D -> GetXaxis() -> SetNdivisions(505);
0062
0063 vtxX_eID_2D = new TH2F("","vtxX_eID_2D", 200, 0, int(data_in -> eID * 1.3), 200, vtxX_1D -> GetXaxis() -> GetXmin(), vtxX_1D -> GetXaxis() -> GetXmax());
0064 vtxX_eID_2D -> SetStats(0);
0065 vtxX_eID_2D -> GetXaxis() -> SetTitle("Event ID");
0066 vtxX_eID_2D -> GetYaxis() -> SetTitle(Form("Vertex X [%s]", unit_text.c_str()));
0067 vtxX_eID_2D -> GetXaxis() -> SetNdivisions(505);
0068
0069 vtxY_eID_2D = new TH2F("","vtxY_eID_2D", 200, 0, int(data_in -> eID * 1.3), 200, vtxY_1D -> GetXaxis() -> GetXmin(), vtxY_1D -> GetXaxis() -> GetXmax());
0070 vtxY_eID_2D -> SetStats(0);
0071 vtxY_eID_2D -> GetXaxis() -> SetTitle("Event ID");
0072 vtxY_eID_2D -> GetYaxis() -> SetTitle(Form("Vertex Y [%s]", unit_text.c_str()));
0073 vtxY_eID_2D -> GetXaxis() -> SetNdivisions(505);
0074
0075 vtxXY_2D = new TH2F("","vtxXY_2D", 100, -window_half_width + beam_origin.first, window_half_width + beam_origin.first, 100, -window_half_width + beam_origin.second, window_half_width + beam_origin.second);
0076
0077 vtxXY_2D -> GetXaxis() -> SetTitle(Form("X axis [%s]", unit_text.c_str()));
0078 vtxXY_2D -> GetYaxis() -> SetTitle(Form("Y axis [%s]", unit_text.c_str()));
0079 vtxXY_2D -> GetXaxis() -> SetNdivisions(505);
0080
0081
0082 vtxX_correlation = new TH2F("", Form("vtxX_correlation;True vertex X [%s];Reco. vertex X [%s]", unit_text.c_str(), unit_text.c_str()), 100, -small_half_width + beam_origin.first, small_half_width + beam_origin.first, 100, -small_half_width + beam_origin.first, small_half_width + beam_origin.first);
0083 vtxX_correlation -> GetXaxis() -> SetNdivisions(505);
0084
0085 vtxY_correlation = new TH2F("", Form("vtxY_correlation;True vertex Y [%s];Reco. vertex Y [%s]", unit_text.c_str(), unit_text.c_str()), 100, -small_half_width + beam_origin.second, small_half_width + beam_origin.second, 100, -small_half_width + beam_origin.second, small_half_width + beam_origin.second);
0086 vtxY_correlation -> GetXaxis() -> SetNdivisions(505);
0087
0088 vtxX_diff = new TH1F("",Form("vtxX_diff;#DeltaX (Reco. - True) [%s];Entry",unit_text.c_str()), 100, -diff_half_width, diff_half_width);
0089 vtxX_diff -> GetXaxis() -> SetNdivisions(505);
0090
0091 vtxY_diff = new TH1F("",Form("vtxY_diff;#DeltaY (Reco. - True) [%s];Entry",unit_text.c_str()), 100, -diff_half_width, diff_half_width);
0092 vtxY_diff -> GetXaxis() -> SetNdivisions(505);
0093
0094 vtxX_bco_graph = new TGraph();
0095 vtxX_bco_graph -> Set(0);
0096 vtxX_bco_graph -> GetXaxis() -> SetNdivisions(505);
0097
0098 vtxY_bco_graph = new TGraph();
0099 vtxY_bco_graph -> Set(0);
0100 vtxY_bco_graph -> GetXaxis() -> SetNdivisions(505);
0101
0102 ltx = new TLatex();
0103 ltx->SetNDC();
0104 ltx->SetTextSize(0.045);
0105 ltx->SetTextAlign(31);
0106
0107 ltx_warning = new TLatex();
0108 ltx_warning->SetNDC();
0109 ltx_warning->SetTextSize(0.04);
0110 ltx_warning->SetTextAlign(31);
0111 ltx_warning->SetTextColor(2);
0112 ltx_warning->SetTextAngle(35);
0113
0114 draw_text = new TLatex();
0115 draw_text -> SetNDC();
0116 draw_text -> SetTextSize(0.03);
0117
0118 gaus_fit_MC = new TF1("gaus_fit_MC",gaus_func,-10,10,4);
0119 gaus_fit_MC -> SetLineColor(2);
0120 gaus_fit_MC -> SetLineWidth(2);
0121 gaus_fit_MC -> SetNpx(1000);
0122
0123 pol1_fit = new TF1("pol1_fit", "pol1",-100,100);
0124 pol1_fit -> SetLineColor(2);
0125 pol1_fit -> SetLineWidth(2);
0126 }
0127
0128 void CheckEvtXY::Prepare_info()
0129 {
0130 for (int i = 0; i < data_in -> GetEntries(); i++)
0131 {
0132 data_in -> LoadTree(i);
0133 data_in -> GetEntry(i);
0134
0135 double reco_vtx_x = data_in -> reco_vtx_x -> at(0) * unit_correction;
0136 double reco_vtx_y = data_in -> reco_vtx_y -> at(0) * unit_correction;
0137 double true_vtx_x = data_in -> true_vtx_x * unit_correction;
0138 double true_vtx_y = data_in -> true_vtx_y * unit_correction;
0139
0140 vtxX_1D -> Fill(reco_vtx_x);
0141 vtxY_1D -> Fill(reco_vtx_y);
0142 vtxXY_2D -> Fill(reco_vtx_x, reco_vtx_y);
0143
0144 vtxX_bco_graph -> SetPoint(i, data_in -> bco_full, reco_vtx_x);
0145 vtxY_bco_graph -> SetPoint(i, data_in -> bco_full, reco_vtx_y);
0146
0147 vtxX_eID_2D -> Fill(data_in -> eID, reco_vtx_x);
0148 vtxY_eID_2D -> Fill(data_in -> eID, reco_vtx_y);
0149
0150 if (run_type == "MC")
0151 {
0152
0153 vtxX_correlation -> Fill(true_vtx_x, reco_vtx_x);
0154 vtxY_correlation -> Fill(true_vtx_y, reco_vtx_y);
0155 vtxX_diff -> Fill(reco_vtx_x - true_vtx_x);
0156 vtxY_diff -> Fill(reco_vtx_y - true_vtx_y);
0157 }
0158
0159 }
0160
0161 return;
0162 }
0163
0164 void CheckEvtXY::Print_plots()
0165 {
0166
0167 c1 -> cd();
0168 vtxX_1D -> Draw("hist");
0169 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, Form("#it{#bf{sPHENIX}} %s", sPHENIX_suffix.c_str()));
0170
0171
0172 gaus_fit_MC -> SetParameters(vtxX_1D -> GetBinContent( vtxX_1D -> GetMaximumBin() ), vtxX_1D -> GetBinCenter( vtxX_1D -> GetMaximumBin() ), 0.05 * unit_correction, 0);
0173 gaus_fit_MC -> SetParLimits(0,0,100000);
0174 gaus_fit_MC -> SetParLimits(2,0,10000);
0175 gaus_fit_MC -> SetParLimits(3,0,10000);
0176 vtxX_1D -> Fit(gaus_fit_MC, "N", "", vtxX_1D -> GetBinCenter( vtxX_1D -> GetMaximumBin() ) - (2 * vtxX_1D -> GetStdDev() ), vtxX_1D -> GetBinCenter( vtxX_1D -> GetMaximumBin() ) + (2 * vtxX_1D -> GetStdDev() ) );
0177 gaus_fit_MC -> SetRange( gaus_fit_MC->GetParameter(1) - double(gaus_fit_MC->GetParameter(2)) * 2.5, gaus_fit_MC->GetParameter(1) + double(gaus_fit_MC->GetParameter(2)) * 2.5 );
0178 gaus_fit_MC -> Draw("lsame");
0179
0180 draw_text -> DrawLatex(0.21, 0.84, Form("INTT NClus > %i", NClus_cut_label));
0181 draw_text -> DrawLatex(0.21, 0.80, Form("Gaus mean : %.5f %s",gaus_fit_MC -> GetParameter(1), unit_text.c_str()));
0182 draw_text -> DrawLatex(0.21, 0.76, Form("Gaus width : %.5f %s",fabs(gaus_fit_MC -> GetParameter(2)), unit_text.c_str()));
0183 c1 -> Print(Form("%s/vtxX_1D.pdf",out_folder_directory.c_str()));
0184 c1 -> Clear();
0185
0186
0187 c1 -> cd();
0188 vtxY_1D -> Draw("hist");
0189 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, Form("#it{#bf{sPHENIX}} %s", sPHENIX_suffix.c_str()));
0190
0191
0192 gaus_fit_MC -> SetParameters(vtxY_1D -> GetBinContent( vtxY_1D -> GetMaximumBin() ), vtxY_1D -> GetBinCenter( vtxY_1D -> GetMaximumBin() ), 0.05 * unit_correction, 0);
0193 gaus_fit_MC -> SetParLimits(0,0,100000);
0194 gaus_fit_MC -> SetParLimits(2,0,10000);
0195 gaus_fit_MC -> SetParLimits(3,0,10000);
0196 vtxY_1D -> Fit(gaus_fit_MC, "N", "", vtxY_1D -> GetBinCenter( vtxY_1D -> GetMaximumBin() ) - (2 * vtxY_1D -> GetStdDev() ), vtxY_1D -> GetBinCenter( vtxY_1D -> GetMaximumBin() ) + (2 * vtxY_1D -> GetStdDev() ) );
0197 gaus_fit_MC -> SetRange( gaus_fit_MC->GetParameter(1) - double(gaus_fit_MC->GetParameter(2)) * 2.5, gaus_fit_MC->GetParameter(1) + double(gaus_fit_MC->GetParameter(2)) * 2.5 );
0198 gaus_fit_MC -> Draw("lsame");
0199
0200 draw_text -> DrawLatex(0.21, 0.84, Form("INTT NClus > %i", NClus_cut_label));
0201 draw_text -> DrawLatex(0.21, 0.80, Form("Gaus mean : %.5f %s",gaus_fit_MC -> GetParameter(1), unit_text.c_str()));
0202 draw_text -> DrawLatex(0.21, 0.76, Form("Gaus width : %.5f %s",fabs(gaus_fit_MC -> GetParameter(2)), unit_text.c_str()));
0203 c1 -> Print(Form("%s/vtxY_1D.pdf",out_folder_directory.c_str()));
0204 c1 -> Clear();
0205
0206
0207 c1 -> cd();
0208 vtxXY_2D -> Draw("colz0");
0209 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, Form("#it{#bf{sPHENIX}} %s", sPHENIX_suffix.c_str()));
0210
0211 draw_text -> DrawLatex(0.21, 0.84, Form("INTT NClus > %i", NClus_cut_label));
0212 c1 -> Print(Form("%s/vtxXY_2D.pdf",out_folder_directory.c_str()));
0213 c1 -> Clear();
0214
0215
0216 c1 -> cd();
0217 vtxX_eID_2D -> Draw("colz0");
0218 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, Form("#it{#bf{sPHENIX}} %s", sPHENIX_suffix.c_str()));
0219
0220 draw_text -> DrawLatex(0.21, 0.84, Form("INTT NClus > %i", NClus_cut_label));
0221 c1 -> Print(Form("%s/vtxX_eID_2D.pdf",out_folder_directory.c_str()));
0222 c1 -> Clear();
0223
0224
0225 c1 -> cd();
0226 vtxY_eID_2D -> Draw("colz0");
0227 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, Form("#it{#bf{sPHENIX}} %s", sPHENIX_suffix.c_str()));
0228
0229 draw_text -> DrawLatex(0.21, 0.84, Form("INTT NClus > %i", NClus_cut_label));
0230 c1 -> Print(Form("%s/vtxY_eID_2D.pdf",out_folder_directory.c_str()));
0231 c1 -> Clear();
0232
0233
0234 c1 -> cd();
0235 vtxX_bco_graph -> SetMarkerStyle(20);
0236 vtxX_bco_graph -> SetMarkerSize(0.1);
0237 vtxX_bco_graph -> Draw("AP");
0238 vtxX_bco_graph -> GetXaxis() -> SetTitle("bco_full");
0239 vtxX_bco_graph -> GetYaxis() -> SetTitle(Form("Vertex X [%s]", unit_text.c_str()));
0240 vtxX_bco_graph -> GetYaxis() -> SetRangeUser(vtxX_1D->GetXaxis()->GetXmin(), vtxX_1D->GetXaxis()->GetXmax());
0241 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, Form("#it{#bf{sPHENIX}} %s", sPHENIX_suffix.c_str()));
0242
0243 draw_text -> DrawLatex(0.21, 0.84, Form("INTT NClus > %i", NClus_cut_label));
0244 c1 -> Print(Form("%s/vtxX_bco_graph.pdf",out_folder_directory.c_str()));
0245 c1 -> Clear();
0246
0247
0248 c1 -> cd();
0249 vtxY_bco_graph -> SetMarkerStyle(20);
0250 vtxY_bco_graph -> SetMarkerSize(0.1);
0251 vtxY_bco_graph -> Draw("AP");
0252 vtxY_bco_graph -> GetXaxis() -> SetTitle("bco_full");
0253 vtxY_bco_graph -> GetYaxis() -> SetTitle(Form("Vertex Y [%s]", unit_text.c_str()));
0254 vtxY_bco_graph -> GetYaxis() -> SetRangeUser(vtxY_1D->GetXaxis()->GetXmin(), vtxY_1D->GetXaxis()->GetXmax());
0255 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, Form("#it{#bf{sPHENIX}} %s", sPHENIX_suffix.c_str()));
0256
0257 draw_text -> DrawLatex(0.21, 0.84, Form("INTT NClus > %i", NClus_cut_label));
0258 c1 -> Print(Form("%s/vtxY_bco_graph.pdf",out_folder_directory.c_str()));
0259 c1 -> Clear();
0260
0261 if (run_type != "MC") {return;}
0262
0263
0264 c1 -> cd();
0265 vtxX_correlation -> Fit(pol1_fit, "NQ");
0266 vtxX_correlation -> Draw("colz0");
0267 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, Form("#it{#bf{sPHENIX}} %s", sPHENIX_suffix.c_str()));
0268 pol1_fit -> Draw("l same");
0269 draw_text -> DrawLatex(0.21, 0.84, Form("INTT NClus > %i", NClus_cut_label));
0270 draw_text -> DrawLatex(0.21, 0.80, Form("y = %.3f + %.3f", pol1_fit -> GetParameter(1), pol1_fit -> GetParameter(0)));
0271 c1 -> Print(Form("%s/vtxX_correlation.pdf",out_folder_directory.c_str()));
0272 c1 -> Clear();
0273
0274
0275 c1 -> cd();
0276 vtxY_correlation -> Fit(pol1_fit, "NQ");
0277 vtxY_correlation -> Draw("colz0");
0278 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, Form("#it{#bf{sPHENIX}} %s", sPHENIX_suffix.c_str()));
0279 pol1_fit -> Draw("l same");
0280 draw_text -> DrawLatex(0.21, 0.84, Form("INTT NClus > %i", NClus_cut_label));
0281 draw_text -> DrawLatex(0.21, 0.80, Form("y = %.3f + %.3f", pol1_fit -> GetParameter(1), pol1_fit -> GetParameter(0)));
0282 c1 -> Print(Form("%s/vtxY_correlation.pdf",out_folder_directory.c_str()));
0283 c1 -> Clear();
0284
0285
0286 c1 -> cd();
0287 vtxX_diff -> Draw("colz0");
0288 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, Form("#it{#bf{sPHENIX}} %s", sPHENIX_suffix.c_str()));
0289
0290 gaus_fit_MC -> SetParameters(vtxX_diff -> GetBinContent( vtxX_diff -> GetMaximumBin() ), vtxX_diff -> GetBinCenter( vtxX_diff -> GetMaximumBin() ), 0.05 * unit_correction, 0);
0291 gaus_fit_MC -> SetParLimits(0,0,100000);
0292 gaus_fit_MC -> SetParLimits(2,0,10000);
0293 gaus_fit_MC -> SetParLimits(3,0,10000);
0294 vtxX_diff -> Fit(gaus_fit_MC, "N", "", vtxX_diff -> GetBinCenter( vtxX_diff -> GetMaximumBin() ) - (1 * vtxX_diff -> GetStdDev() ), vtxX_diff -> GetBinCenter( vtxX_diff -> GetMaximumBin() ) + (1 * vtxX_diff -> GetStdDev() ) );
0295 gaus_fit_MC -> SetRange( gaus_fit_MC->GetParameter(1) - double(gaus_fit_MC->GetParameter(2)) * 2, gaus_fit_MC->GetParameter(1) + double(gaus_fit_MC->GetParameter(2)) * 2 );
0296 gaus_fit_MC -> Draw("lsame");
0297
0298 draw_text -> DrawLatex(0.21, 0.84, Form("INTT NClus > %i", NClus_cut_label));
0299 draw_text -> DrawLatex(0.21, 0.80, Form("Gaus mean : %.5f %s",gaus_fit_MC -> GetParameter(1), unit_text.c_str()));
0300 draw_text -> DrawLatex(0.21, 0.76, Form("Gaus width : %.5f %s",fabs(gaus_fit_MC -> GetParameter(2)), unit_text.c_str()));
0301 c1 -> Print(Form("%s/vtxX_diff.pdf",out_folder_directory.c_str()));
0302 c1 -> Clear();
0303
0304
0305 c1 -> cd();
0306 vtxY_diff -> Draw("colz0");
0307 ltx->DrawLatex(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, Form("#it{#bf{sPHENIX}} %s", sPHENIX_suffix.c_str()));
0308
0309 gaus_fit_MC -> SetParameters(vtxY_diff -> GetBinContent( vtxY_diff -> GetMaximumBin() ), vtxY_diff -> GetBinCenter( vtxY_diff -> GetMaximumBin() ), 0.05 * unit_correction, 0);
0310 gaus_fit_MC -> SetParLimits(0,0,100000);
0311 gaus_fit_MC -> SetParLimits(2,0,10000);
0312 gaus_fit_MC -> SetParLimits(3,0,10000);
0313 vtxY_diff -> Fit(gaus_fit_MC, "N", "", vtxY_diff -> GetBinCenter( vtxY_diff -> GetMaximumBin() ) - (1 * vtxY_diff -> GetStdDev() ), vtxY_diff -> GetBinCenter( vtxY_diff -> GetMaximumBin() ) + (1 * vtxY_diff -> GetStdDev() ) );
0314 gaus_fit_MC -> SetRange( gaus_fit_MC->GetParameter(1) - double(gaus_fit_MC->GetParameter(2)) * 2, gaus_fit_MC->GetParameter(1) + double(gaus_fit_MC->GetParameter(2)) * 2 );
0315 gaus_fit_MC -> Draw("lsame");
0316
0317 draw_text -> DrawLatex(0.21, 0.84, Form("INTT NClus > %i", NClus_cut_label));
0318 draw_text -> DrawLatex(0.21, 0.80, Form("Gaus mean : %.5f %s",gaus_fit_MC -> GetParameter(1), unit_text.c_str()));
0319 draw_text -> DrawLatex(0.21, 0.76, Form("Gaus width : %.5f %s",fabs(gaus_fit_MC -> GetParameter(2)), unit_text.c_str()));
0320 c1 -> Print(Form("%s/vtxY_diff.pdf",out_folder_directory.c_str()));
0321 c1 -> Clear();
0322
0323 return;
0324 }