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_(
201 lhcInfoLabel_(iConfig.getParameter<
std::
string>(
"lhcInfoLabel")),
202 outputFile_(iConfig.getParameter<
string>(
"outputFile")) {}
227 bool vertex_set =
false;
229 for (
auto it = hepMCEventAfterSmearing->vertices_begin(); it != hepMCEventAfterSmearing->vertices_end(); ++it) {
231 LogError(
"CTPPSProtonReconstructionSimulationValidator") <<
"Multiple vertices found.";
236 vtx = (*it)->position();
240 bool proton_45_set =
false;
241 bool proton_56_set =
false;
242 FourVector mom_45, mom_56;
244 for (
auto it = hepMCEventBeforeSmearing->particles_begin(); it != hepMCEventBeforeSmearing->particles_end(); ++it) {
245 const auto &
part = *it;
248 if (
part->pdg_id() != 2212)
251 if (
part->status() != 1)
257 const auto &mom =
part->momentum();
265 LogError(
"CTPPSProtonReconstructionSimulationValidator") <<
"Found multiple protons in sector 45.";
269 proton_45_set =
true;
274 LogError(
"CTPPSProtonReconstructionSimulationValidator") <<
"Found multiple protons in sector 56.";
278 proton_56_set =
true;
284 for (
const auto &
handle : {hRecoProtonsSingleRP, hRecoProtonsMultiRP}) {
285 for (
const auto &rec_pr : *
handle) {
289 unsigned int idx = 12345;
291 bool mom_set =
false;
296 mom_set = proton_45_set;
301 mom_set = proton_56_set;
308 unsigned int meth_idx = 1234;
325 bool time_set_45 =
false, time_set_56 =
false;
326 double time_45 = 0., time_56 = 0.;
327 for (
const auto &rec_pr : *hRecoProtonsMultiRP) {
337 time_45 = rec_pr.
time();
341 time_56 = rec_pr.
time();
345 if (time_set_45 && time_set_56)
354 const HepMC::FourVector &
vtx,
355 const HepMC::FourVector &mom,
357 const double p_nom = lhcInfo.
energy();
358 const double xi_simu = (p_nom - mom.rho()) / p_nom;
359 const double th_x_simu = mom.x() / mom.rho();
360 const double th_y_simu = mom.y() / mom.rho();
361 const double vtx_y_simu =
vtx.y();
362 const double th_simu =
sqrt(th_x_simu * th_x_simu + th_y_simu * th_y_simu);
365 const double xi_reco = rec_pr.
xi();
366 const double th_x_reco = rec_pr.
thetaX();
367 const double th_y_reco = rec_pr.
thetaY();
368 const double vtx_y_reco = rec_pr.
vertex().y() * 10.;
369 const double t_reco = -rec_pr.
t();
373 plt.h_xi_reco_vs_xi_simu->Fill(xi_simu, xi_reco);
374 plt.h_de_xi->Fill(xi_reco - xi_simu);
375 plt.p_de_xi_vs_xi_simu->Fill(xi_simu, xi_reco - xi_simu);
377 plt.h_de_th_x->Fill(th_x_reco - th_x_simu);
378 plt.p_de_th_x_vs_xi_simu->Fill(xi_simu, th_x_reco - th_x_simu);
380 plt.h_de_th_y->Fill(th_y_reco - th_y_simu);
381 plt.p_de_th_y_vs_xi_simu->Fill(xi_simu, th_y_reco - th_y_simu);
383 plt.h_de_vtx_y->Fill(vtx_y_reco - vtx_y_simu);
384 plt.p_de_vtx_y_vs_xi_simu->Fill(xi_simu, vtx_y_reco - vtx_y_simu);
386 plt.h_de_t->Fill(t_reco - t_simu);
387 plt.p_de_t_vs_xi_simu->Fill(xi_simu, t_reco - t_simu);
388 plt.p_de_t_vs_t_simu->Fill(t_simu, t_reco - t_simu);
394 auto f_out = std::make_unique<TFile>(
outputFile_.c_str(),
"recreate");
396 for (
const auto &mit :
plots_) {
397 const char *
method = (mit.first == 0) ?
"single rp" :
"multi rp";
398 TDirectory *d_method = f_out->mkdir(
method);
400 for (
const auto &eit : mit.second) {
401 gDirectory = d_method->mkdir(Form(
"%i", eit.first));
406 gDirectory = f_out->mkdir(
"double arm");