28 #include "TGraphErrors.h"
30 #include "CLHEP/Units/GlobalPhysicalConstants.h"
48 const HepMC::FourVector &
vtx,
49 const HepMC::FourVector &mom,
76 std::unique_ptr<TH1D>
h_de_t;
80 :
h_de_xi(new TH1D(
"",
";#xi_{reco} - #xi_{simu}", 100, 0., 0.)),
81 p_de_xi_vs_xi_simu(new TProfile(
"",
";#xi_{simu};#xi_{reco} - #xi_{simu}", 50, 0., 0.25)),
84 h_de_th_x(new TH1D(
"",
";#theta_{x,reco} - #theta_{x,simu}", 100, 0., 0.)),
85 p_de_th_x_vs_xi_simu(new TProfile(
"",
";#xi_{simu};#theta_{x,reco} - #theta_{x,simu}", 50, 0., 0.25)),
87 h_de_th_y(new TH1D(
"",
";#theta_{y,reco} - #theta_{y,simu}", 100, 0., 0.)),
88 p_de_th_y_vs_xi_simu(new TProfile(
"",
";#xi_{simu};#theta_{y,reco} - #theta_{y,simu}", 50, 0., 0.25)),
90 h_de_vtx_y(new TH1D(
"",
";vtx_{y,reco} - vtx_{y,simu} (mm)", 100, 0., 0.)),
91 p_de_vtx_y_vs_xi_simu(new TProfile(
"",
";#xi_{simu};vtx_{y,reco} - vtx_{y,simu} (mm)", 50, 0., 0.25)),
93 h_de_t(new TH1D(
"",
";t_{reco} - t_{simu}", 100, -1., +1.)),
94 p_de_t_vs_xi_simu(new TProfile(
"",
";xi_{simu};t_{reco} - t_{simu}", 50, 0., 0.25)),
95 p_de_t_vs_t_simu(new TProfile(
"",
";t_{simu};t_{reco} - t_{simu}", 20, 0., 5.)) {}
101 for (
int bi = 1; bi <=
p->GetNbinsX(); ++bi) {
102 double c =
p->GetBinCenter(bi);
103 double w =
p->GetBinWidth(bi);
105 double N =
p->GetBinEntries(bi);
106 double Sy =
p->GetBinContent(bi) *
N;
107 double Syy =
p->GetSumw2()->At(bi);
109 double si_sq = Syy /
N - Sy * Sy /
N /
N;
110 double si = (si_sq >= 0.) ?
sqrt(si_sq) : 0.;
111 double si_unc_sq = si_sq / 2. /
N;
112 double si_unc = (si_unc_sq >= 0.) ?
sqrt(si_unc_sq) : 0.;
114 int idx = gr_err.GetN();
115 gr_err.SetPoint(
idx,
c, si);
116 gr_err.SetPointError(
idx,
w / 2., si_unc);
148 std::map<unsigned int, std::map<unsigned int, PlotGroup>>
plots_;
155 :
h2_t_sh_vs_vtx_t(new TH2D(
"",
";vtx_t (mm);(t_56 + t_45)/2 (mm)", 100, -250., -250., 100, +250., +250.)),
156 h2_t_dh_vs_vtx_z(new TH2D(
"",
";vtx_z (mm);(t_56 - t_45)/2 (mm)", 100, -250., -250., 100, +250., +250.)),
158 h_t_dh_minus_vtx_z(new TH1D(
"",
";(t_56 - t_45)/2 - vtx_z (mm)", 100, -100., +100.)) {}
160 void fill(
double time_45,
double time_56,
double vtx_z,
double vtx_t) {
161 const double t_sum_half = (time_56 + time_45) / 2. * CLHEP::c_light;
162 const double t_dif_half = (time_56 - time_45) / 2. * CLHEP::c_light;
187 using namespace HepMC;
193 : tokenHepMCBeforeSmearing_(
195 tokenHepMCAfterSmearing_(
197 tokenRecoProtonsSingleRP_(
199 tokenRecoProtonsMultiRP_(
202 outputFile_(iConfig.getParameter<
string>(
"outputFile")) {}
226 bool vertex_set =
false;
228 for (
auto it = hepMCEventAfterSmearing->vertices_begin(); it != hepMCEventAfterSmearing->vertices_end(); ++it) {
230 LogError(
"CTPPSProtonReconstructionSimulationValidator") <<
"Multiple vertices found.";
235 vtx = (*it)->position();
239 bool proton_45_set =
false;
240 bool proton_56_set =
false;
241 FourVector mom_45, mom_56;
243 for (
auto it = hepMCEventBeforeSmearing->particles_begin(); it != hepMCEventBeforeSmearing->particles_end(); ++it) {
244 const auto &
part = *it;
247 if (
part->pdg_id() != 2212)
250 if (
part->status() != 1)
256 const auto &mom =
part->momentum();
264 LogError(
"CTPPSProtonReconstructionSimulationValidator") <<
"Found multiple protons in sector 45.";
268 proton_45_set =
true;
273 LogError(
"CTPPSProtonReconstructionSimulationValidator") <<
"Found multiple protons in sector 56.";
277 proton_56_set =
true;
283 for (
const auto &
handle : {hRecoProtonsSingleRP, hRecoProtonsMultiRP}) {
284 for (
const auto &rec_pr : *
handle) {
288 unsigned int idx = 12345;
290 bool mom_set =
false;
295 mom_set = proton_45_set;
300 mom_set = proton_56_set;
307 unsigned int meth_idx = 1234;
324 bool time_set_45 =
false, time_set_56 =
false;
325 double time_45 = 0., time_56 = 0.;
326 for (
const auto &rec_pr : *hRecoProtonsMultiRP) {
336 time_45 = rec_pr.
time();
340 time_56 = rec_pr.
time();
344 if (time_set_45 && time_set_56)
353 const HepMC::FourVector &
vtx,
354 const HepMC::FourVector &mom,
356 const double p_nom = lhcInfo.
energy();
357 const double xi_simu = (p_nom - mom.rho()) / p_nom;
358 const double th_x_simu = mom.x() / mom.rho();
359 const double th_y_simu = mom.y() / mom.rho();
360 const double vtx_y_simu =
vtx.y();
361 const double th_simu =
sqrt(th_x_simu * th_x_simu + th_y_simu * th_y_simu);
364 const double xi_reco = rec_pr.
xi();
365 const double th_x_reco = rec_pr.
thetaX();
366 const double th_y_reco = rec_pr.
thetaY();
367 const double vtx_y_reco = rec_pr.
vertex().y() * 10.;
368 const double t_reco = -rec_pr.
t();
372 plt.h_xi_reco_vs_xi_simu->Fill(xi_simu, xi_reco);
373 plt.h_de_xi->Fill(xi_reco - xi_simu);
374 plt.p_de_xi_vs_xi_simu->Fill(xi_simu, xi_reco - xi_simu);
376 plt.h_de_th_x->Fill(th_x_reco - th_x_simu);
377 plt.p_de_th_x_vs_xi_simu->Fill(xi_simu, th_x_reco - th_x_simu);
379 plt.h_de_th_y->Fill(th_y_reco - th_y_simu);
380 plt.p_de_th_y_vs_xi_simu->Fill(xi_simu, th_y_reco - th_y_simu);
382 plt.h_de_vtx_y->Fill(vtx_y_reco - vtx_y_simu);
383 plt.p_de_vtx_y_vs_xi_simu->Fill(xi_simu, vtx_y_reco - vtx_y_simu);
385 plt.h_de_t->Fill(t_reco - t_simu);
386 plt.p_de_t_vs_xi_simu->Fill(xi_simu, t_reco - t_simu);
387 plt.p_de_t_vs_t_simu->Fill(t_simu, t_reco - t_simu);
393 auto f_out = std::make_unique<TFile>(
outputFile_.c_str(),
"recreate");
395 for (
const auto &mit :
plots_) {
396 const char *
method = (mit.first == 0) ?
"single rp" :
"multi rp";
397 TDirectory *d_method = f_out->mkdir(
method);
399 for (
const auto &eit : mit.second) {
400 gDirectory = d_method->mkdir(Form(
"%i", eit.first));
405 gDirectory = f_out->mkdir(
"double arm");