22 #include "TGraphErrors.h" 53 for (
int bi = 1; bi <= p->GetNbinsX(); ++bi)
55 double c = p->GetBinCenter(bi);
57 double N = p->GetBinEntries(bi);
58 double Sy = p->GetBinContent(bi) *
N;
59 double Syy = p->GetSumw2()->At(bi);
61 double si_sq = Syy/N - Sy*Sy/N/
N;
62 double si = (si_sq >= 0.) ?
sqrt(si_sq) : 0.;
63 double si_unc_sq = si_sq / 2. /
N;
64 double si_unc = (si_unc_sq >= 0.) ?
sqrt(si_unc_sq) : 0.;
67 g->SetPoint(idx, c, si);
68 g->SetPointError(idx, 0., si_unc);
74 std::unique_ptr<TH1D>
h_xi;
79 h_xi(new TH1D(
"",
";#xi", 100, 0., 0.3)),
80 h2_th_y_vs_xi(new TH2D(
"",
";#xi;#theta_{y} (rad)", 100, 0., 0.3, 100, -500E-6, +500E-6)),
81 p_th_y_vs_xi(new TProfile(
"",
";#xi;#theta_{y} (rad)", 100, 0., 0.3))
89 const double th_y = p.
thetaY();
90 h2_th_y_vs_xi->Fill(p.
xi(), th_y);
91 p_th_y_vs_xi->Fill(p.
xi(), th_y);
99 h2_th_y_vs_xi->Write(
"h2_th_y_vs_xi");
100 p_th_y_vs_xi->Write(
"p_th_y_vs_xi");
108 std::unique_ptr<TH1D>
h_xi, h_th_x, h_th_y, h_vtx_y, h_t_unif, h_t, h_chi_sq, h_chi_sq_norm;
115 h_xi(new TH1D(
"",
";#xi", 100, 0., 0.3)),
116 h_th_x(new TH1D(
"",
";#theta_{x} (rad)", 100, -500E-6, +500E-6)),
117 h_th_y(new TH1D(
"",
";#theta_{y} (rad)", 100, -500E-6, +500E-6)),
118 h_vtx_y(new TH1D(
"",
";vtx_{y} (cm)", 100, -2., +2.)),
119 h_chi_sq(new TH1D(
"",
";#chi^{2}", 100, 0., 0.)),
120 h_chi_sq_norm(new TH1D(
"",
";#chi^{2}/ndf", 100, 0., 5.)),
121 h_n_tracking_RPs(new TH1D(
"",
";n of tracking RPs", 4, -0.5, +3.5)),
122 h_n_timing_RPs(new TH1D(
"",
";n of timing RPs", 4, -0.5, +3.5)),
123 h2_th_x_vs_xi(new TH2D(
"",
";#xi;#theta_{x} (rad)", 100, 0., 0.3, 100, -500E-6, +500E-6)),
124 h2_th_y_vs_xi(new TH2D(
"",
";#xi;#theta_{y} (rad)", 100, 0., 0.3, 100, -500E-6, +500E-6)),
125 h2_vtx_y_vs_xi(new TH2D(
"",
";#xi;vtx_{y} (cm)", 100, 0., 0.3, 100, -500E-3, +500E-3)),
126 p_th_x_vs_xi(new TProfile(
"",
";#xi;#theta_{x} (rad)", 100, 0., 0.3)),
127 p_th_y_vs_xi(new TProfile(
"",
";#xi;#theta_{y} (rad)", 100, 0., 0.3)),
128 p_vtx_y_vs_xi(new TProfile(
"",
";#xi;vtx_{y} (cm)", 100, 0., 0.3))
130 std::vector<double> v_t_bin_edges;
131 for (
double t = 0;
t <= 5.; ) {
132 v_t_bin_edges.push_back(
t);
133 const double de_t = 0.05 + 0.09 *
t + 0.02 *
t*
t;
136 h_t_unif.reset(
new TH1D(
"",
";|t| (GeV^2)", 100, 0., 5.));
137 h_t.reset(
new TH1D(
"",
";|t| (GeV^2)", v_t_bin_edges.size() - 1, v_t_bin_edges.data()));
138 h_t_xi_range1.reset(
new TH1D(
"",
";|t| (GeV^2)", v_t_bin_edges.size() - 1, v_t_bin_edges.data()));
139 h_t_xi_range2.reset(
new TH1D(
"",
";|t| (GeV^2)", v_t_bin_edges.size() - 1, v_t_bin_edges.data()));
140 h_t_xi_range3.reset(
new TH1D(
"",
";|t| (GeV^2)", v_t_bin_edges.size() - 1, v_t_bin_edges.data()));
141 h2_t_vs_xi.reset(
new TH2D(
"",
";#xi;|t| (GeV^2)", 100, 0., 0.3, v_t_bin_edges.size() - 1, v_t_bin_edges.data()));
149 unsigned int n_tracking_RPs=0, n_timing_RPs=0;
159 const double th_x = p.
thetaX();
160 const double th_y = p.
thetaY();
161 const double mt = - p.
t();
163 h_chi_sq->Fill(p.
chi2());
167 h_n_tracking_RPs->Fill(n_tracking_RPs);
168 h_n_timing_RPs->Fill(n_timing_RPs);
175 h_vtx_y->Fill(p.
vertex().y());
179 if (p.
xi() > 0.04 && p.
xi() < 0.07) h_t_xi_range1->Fill(mt);
180 if (p.
xi() > 0.07 && p.
xi() < 0.10) h_t_xi_range2->Fill(mt);
181 if (p.
xi() > 0.10 && p.
xi() < 0.13) h_t_xi_range3->Fill(mt);
183 h2_th_x_vs_xi->Fill(p.
xi(), th_x);
184 h2_th_y_vs_xi->Fill(p.
xi(), th_y);
185 h2_vtx_y_vs_xi->Fill(p.
xi(), p.
vertex().y());
186 h2_t_vs_xi->Fill(p.
xi(),
mt);
188 p_th_x_vs_xi->Fill(p.
xi(), th_x);
189 p_th_y_vs_xi->Fill(p.
xi(), th_y);
190 p_vtx_y_vs_xi->Fill(p.
xi(), p.
vertex().y());
195 h_chi_sq->Write(
"h_chi_sq");
196 h_chi_sq_norm->Write(
"h_chi_sq_norm");
198 h_n_tracking_RPs->Write(
"h_n_tracking_RPs");
199 h_n_timing_RPs->Write(
"h_n_timing_RPs");
203 h_th_x->Write(
"h_th_x");
204 h2_th_x_vs_xi->Write(
"h2_th_x_vs_xi");
205 p_th_x_vs_xi->Write(
"p_th_x_vs_xi");
206 auto g_th_x_RMS_vs_xi = std::make_unique<TGraphErrors>();
208 g_th_x_RMS_vs_xi->Write(
"g_th_x_RMS_vs_xi");
210 h_th_y->Write(
"h_th_y");
211 h2_th_y_vs_xi->Write(
"h2_th_y_vs_xi");
212 p_th_y_vs_xi->Write(
"p_th_y_vs_xi");
213 auto g_th_y_RMS_vs_xi = std::make_unique<TGraphErrors>();
215 g_th_y_RMS_vs_xi->Write(
"g_th_y_RMS_vs_xi");
217 h_vtx_y->Write(
"h_vtx_y");
218 h2_vtx_y_vs_xi->Write(
"h2_vtx_y_vs_xi");
219 p_vtx_y_vs_xi->Write(
"p_vtx_y_vs_xi");
220 auto g_vtx_y_RMS_vs_xi = std::make_unique<TGraphErrors>();
222 g_vtx_y_RMS_vs_xi->Write(
"g_vtx_y_RMS_vs_xi");
224 h_t->Scale(1.,
"width");
226 h_t_unif->Write(
"h_t_unif");
228 h_t_xi_range1->Write(
"h_t_xi_range1");
229 h_t_xi_range2->Write(
"h_t_xi_range2");
230 h_t_xi_range3->Write(
"h_t_xi_range3");
232 h2_t_vs_xi->Write(
"h2_t_vs_xi");
249 h2_xi_mu_vs_xi_si(new TH2D(
"",
";#xi_{single};#xi_{multi}", 100, 0., 0.3, 100, 0., 0.3)),
250 h_xi_diff_mu_si(new TH1D(
"",
";#xi_{multi} - #xi_{single}", 100, -0.1, +0.1)),
251 h_xi_diff_si_mu(new TH1D(
"",
";#xi_{single} - #xi_{multi}", 100, -0.1, +0.1)),
252 h2_xi_diff_si_mu_vs_xi_mu(new TH2D(
"",
";#xi_{multi};#xi_{single} - #xi_{multi}", 100, 0., 0.3, 100, -0.10, 0.10)),
253 p_xi_diff_si_mu_vs_xi_mu(new TProfile(
"",
";#xi_{multi};#xi_{single} - #xi_{multi}", 100, 0., 0.3)),
254 h2_th_y_mu_vs_th_y_si(new TH2D(
"",
";#theta^{*}_{y,si};#theta^{*}_{y,mu}", 100, -500E-6, +500E-6, 100, -500E-6, +500E-6))
260 h2_xi_mu_vs_xi_si->Fill(p_single.
xi(), p_multi.
xi());
261 h_xi_diff_mu_si->Fill(p_multi.
xi() - p_single.
xi());
262 h_xi_diff_si_mu->Fill(p_single.
xi() - p_multi.
xi());
264 h2_xi_diff_si_mu_vs_xi_mu->Fill(p_multi.
xi(), p_single.
xi() - p_multi.
xi());
265 p_xi_diff_si_mu_vs_xi_mu->Fill(p_multi.
xi(), p_single.
xi() - p_multi.
xi());
267 const double th_y_si = p_single.
thetaY();
268 const double th_y_mu = p_multi.
thetaY();
270 h2_th_y_mu_vs_th_y_si->Fill(th_y_si, th_y_mu);
276 h2_xi_mu_vs_xi_si->Write(
"h2_xi_mu_vs_xi_si");
277 h_xi_diff_mu_si->Write(
"h_xi_diff_mu_si");
278 h_xi_diff_si_mu->Write(
"h_xi_diff_si_mu");
280 h2_xi_diff_si_mu_vs_xi_mu->Write(
"h2_xi_diff_si_mu_vs_xi_mu");
281 p_xi_diff_si_mu_vs_xi_mu->Write(
"p_xi_diff_si_mu_vs_xi_mu");
283 h2_th_y_mu_vs_th_y_si->Write(
"h2_th_y_mu_vs_th_y_si");
298 h_xi_si_diffNF(new TH1D(
"",
";#xi_{sF} - #xi_{sN}", 100, -0.02, +0.02)),
299 p_xi_si_diffNF_vs_xi_mu(new TProfile(
"",
";#xi_{m};#xi_{sF} - #xi_{sN}", 100, 0., 0.3)),
300 h_th_y_si_diffNF(new TH1D(
"",
";#theta_{y,sF} - #theta_{y,sN}", 100, -100E-6, +100E-6)),
301 p_th_y_si_diffNF_vs_xi_mu(new TProfile(
"",
";#xi_{m};#theta_{y,sF} - #theta_{y,sN}", 100, 0., 0.3))
309 const double th_y_s_N = p_s_N.
thetaY();
310 const double th_y_s_F = p_s_F.
thetaY();
312 h_xi_si_diffNF->Fill(p_s_F.
xi() - p_s_N.
xi());
313 p_xi_si_diffNF_vs_xi_mu->Fill(p_m.
xi(), p_s_F.
xi() - p_s_N.
xi());
315 h_th_y_si_diffNF->Fill(th_y_s_F - th_y_s_N);
316 p_th_y_si_diffNF_vs_xi_mu->Fill(p_m.
xi(), th_y_s_F - th_y_s_N);
321 h_xi_si_diffNF->Write(
"h_xi_si_diffNF");
322 p_xi_si_diffNF_vs_xi_mu->Write(
"p_xi_si_diffNF_vs_xi_mu");
324 h_th_y_si_diffNF->Write(
"h_th_y_si_diffNF");
325 p_th_y_si_diffNF_vs_xi_mu->Write(
"p_th_y_si_diffNF_vs_xi_mu");
360 p_y_L_diffNF_vs_y_L_N_(new TProfile(
"p_y_L_diffNF_vs_y_L_N",
";y_{LN};y_{LF} - y_{LN}", 100, -20., +20.)),
361 p_y_R_diffNF_vs_y_R_N_(new TProfile(
"p_y_R_diffNF_vs_y_R_N",
";y_{RN};y_{RF} - y_{RN}", 100, -20., +20.)),
380 if (!hRecoProtonsSingleRP->empty())
384 throw cms::Exception(
"CTPPSProtonReconstructionPlotter") <<
"Number of non empty events reached maximum.";
392 for (
const auto &tr : *hTracks)
395 unsigned int decRPId = rpId.
arm()*100 + rpId.station()*10 + rpId.rp();
403 if (tr_L_N && tr_L_F)
409 if (tr_R_N && tr_R_F)
416 for (
const auto &proton : *hRecoProtonsSingleRP)
418 CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->getRPId());
419 unsigned int decRPId = rpId.
arm()*100 + rpId.station()*10 + rpId.rp();
424 for (
const auto &proton : *hRecoProtonsMultiRP)
426 CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->getRPId());
427 unsigned int armId = rpId.
arm();
432 for (
const auto &proton_s : *hRecoProtonsSingleRP)
434 for (
const auto &proton_m : *hRecoProtonsMultiRP)
437 CTPPSDetId rpId_s((*proton_s.contributingLocalTracks().begin())->getRPId());
438 CTPPSDetId rpId_m((*proton_m.contributingLocalTracks().begin())->getRPId());
440 if (rpId_s.arm() != rpId_m.arm())
444 const unsigned int idx = rpId_s.arm()*1000 + rpId_s.station()*100 + rpId_s.rp()*10 + rpId_m.arm();
452 const reco::ForwardProton *p_arm0_s_N =
nullptr, *p_arm0_s_F =
nullptr, *p_arm0_m =
nullptr;
453 const reco::ForwardProton *p_arm1_s_N =
nullptr, *p_arm1_s_F =
nullptr, *p_arm1_m =
nullptr;
455 for (
const auto &proton : *hRecoProtonsSingleRP)
457 CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->getRPId());
458 const unsigned int rpDecId = rpId.
arm()*100 + rpId.station()*10 + rpId.rp();
460 if (rpDecId ==
rpId_45_N_) p_arm0_s_N = &proton;
461 if (rpDecId ==
rpId_45_F_) p_arm0_s_F = &proton;
463 if (rpDecId ==
rpId_56_N_) p_arm1_s_N = &proton;
464 if (rpDecId ==
rpId_56_F_) p_arm1_s_F = &proton;
467 for (
const auto & proton : *hRecoProtonsMultiRP)
469 CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->getRPId());
470 const unsigned int arm = rpId.
arm();
472 if (arm == 0) p_arm0_m = &proton;
473 if (arm == 1) p_arm1_m = &proton;
476 if (p_arm0_s_N && p_arm0_s_F && p_arm0_m)
479 if (p_arm1_s_N && p_arm1_s_F && p_arm1_m)
489 auto f_out = std::make_unique<TFile>(
outputFile_.c_str(),
"recreate");
497 TDirectory *d_singleRPPlots = f_out->mkdir(
"singleRPPlots");
499 gDirectory = d_singleRPPlots->mkdir(Form(
"rp%u", it.first));
503 TDirectory *d_multiRPPlots = f_out->mkdir(
"multiRPPlots");
505 gDirectory = d_multiRPPlots->mkdir(Form(
"arm%u", it.first));
509 TDirectory *d_singleMultiCorrelationPlots = f_out->mkdir(
"singleMultiCorrelationPlots");
511 unsigned int si_rp = it.first / 10;
512 unsigned int mu_arm = it.first % 10;
514 gDirectory = d_singleMultiCorrelationPlots->mkdir(Form(
"si_rp%u_mu_arm%u", si_rp, mu_arm));
518 TDirectory *d_armCorrelationPlots = f_out->mkdir(
"armCorrelationPlots");
520 gDirectory = d_armCorrelationPlots->mkdir(Form(
"arm%u", it.first));
const Point & vertex() const
fitted vertex position
static void profileToRMSGraph(TProfile *p, TGraphErrors *g)
std::unique_ptr< TH1D > h_th_y_si_diffNF
void fill(const reco::ForwardProton &p)
std::map< unsigned int, MultiRPPlots > multiRPPlots_
edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsSingleRP_
std::unique_ptr< TH2D > h2_xi_mu_vs_xi_si
std::unique_ptr< TProfile > p_y_R_diffNF_vs_y_R_N_
std::unique_ptr< TProfile > p_x_R_diffNF_vs_x_R_N_
std::map< unsigned int, SingleRPPlots > singleRPPlots_
Local (=single RP) track with essential information only.
std::unique_ptr< TH1D > h_xi_si_diffNF
std::unique_ptr< TH1D > h_xi_diff_si_mu
void analyze(const edm::Event &, const edm::EventSetup &) override
signed int n_non_empty_events_
std::unique_ptr< TProfile > p_y_L_diffNF_vs_y_L_N_
float t() const
four-momentum transfer squared, in GeV^2
edm::EDGetTokenT< CTPPSLocalTrackLiteCollection > tokenTracks_
std::unique_ptr< TH2D > h2_th_y_vs_xi
std::unique_ptr< TProfile > p_th_y_si_diffNF_vs_xi_mu
void fill(const reco::ForwardProton &p_single, const reco::ForwardProton &p_multi)
float getX() const
returns the horizontal track position
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
float chi2() const
chi-squared of the fit
float thetaX() const
vertical scattering angle, in rad
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void fill(const reco::ForwardProton &p)
std::unique_ptr< TH1D > h_t_xi_range3
#define DEFINE_FWK_MODULE(type)
std::unique_ptr< TH1D > h_xi
std::unique_ptr< TProfile > p_vtx_y_vs_xi
std::unique_ptr< TH2D > h2_xi_diff_si_mu_vs_xi_mu
std::unique_ptr< TH1D > h_n_tracking_RPs
std::unique_ptr< TProfile > p_th_y_vs_xi
float normalizedChi2() const
chi-squared divided by ndof (or chi-squared * 1e6 if ndof is zero)
float xi() const
longitudinal fractional momentum loss
float getY() const
returns the vertical track position
const CTPPSLocalTrackLiteRefVector & contributingLocalTracks() const
list of RP tracks that contributed to this global track
std::unique_ptr< TH2D > h2_th_y_mu_vs_th_y_si
std::map< unsigned int, ArmCorrelationPlots > armCorrelationPlots_
SingleMultiCorrelationPlots()
bool validFit() const
flag for the fit validity
std::unique_ptr< TProfile > p_xi_diff_si_mu_vs_xi_mu
std::vector< CTPPSLocalTrackLite > CTPPSLocalTrackLiteCollection
Collection of CTPPSLocalTrackLite objects.
std::unique_ptr< TH2D > h2_vtx_y_vs_xi
~CTPPSProtonReconstructionPlotter() override
Base class for CTPPS detector IDs.
signed int maxNonEmptyEvents_
CTPPSProtonReconstructionPlotter(const edm::ParameterSet &)
std::unique_ptr< TH1D > h_xi
std::map< unsigned int, SingleMultiCorrelationPlots > singleMultiCorrelationPlots_
float thetaY() const
horizontal scattering angle, in rad
std::vector< ForwardProton > ForwardProtonCollection
Collection of ForwardProton objects.
void fill(const reco::ForwardProton &p_s_N, const reco::ForwardProton &p_s_F, const reco::ForwardProton &p_m)
edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsMultiRP_
std::unique_ptr< TProfile > p_x_L_diffNF_vs_x_L_N_
std::unique_ptr< TProfile > p_xi_si_diffNF_vs_xi_mu
unsigned int ndof() const
number of degrees of freedom for the track fit