CMS 3D CMS Logo

CTPPSProtonReconstructionPlotter.cc
Go to the documentation of this file.
1 /****************************************************************************
2 * Authors:
3 * Jan Kašpar (jan.kaspar@gmail.com)
4 ****************************************************************************/
5 
14 
16 
20 
21 #include "TFile.h"
22 #include "TGraphErrors.h"
23 #include "TH1D.h"
24 #include "TH2D.h"
25 #include "TProfile.h"
26 
27 //----------------------------------------------------------------------------------------------------
28 
30 {
31  public:
34 
35  private:
36  void analyze(const edm::Event&, const edm::EventSetup&) override;
37 
38  void endJob() override;
39 
43 
44  unsigned int rpId_45_N_, rpId_45_F_;
45  unsigned int rpId_56_N_, rpId_56_F_;
46 
48 
49  signed int maxNonEmptyEvents_;
50 
51  static void profileToRMSGraph(TProfile *p, TGraphErrors *g)
52  {
53  for (int bi = 1; bi <= p->GetNbinsX(); ++bi)
54  {
55  double c = p->GetBinCenter(bi);
56 
57  double N = p->GetBinEntries(bi);
58  double Sy = p->GetBinContent(bi) * N;
59  double Syy = p->GetSumw2()->At(bi);
60 
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; // Gaussian approximation
64  double si_unc = (si_unc_sq >= 0.) ? sqrt(si_unc_sq) : 0.;
65 
66  int idx = g->GetN();
67  g->SetPoint(idx, c, si);
68  g->SetPointError(idx, 0., si_unc);
69  }
70  }
71 
73  {
74  std::unique_ptr<TH1D> h_xi;
75  std::unique_ptr<TH2D> h2_th_y_vs_xi;
76  std::unique_ptr<TProfile> p_th_y_vs_xi;
77 
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))
82  {}
83 
84  void fill(const reco::ForwardProton &p)
85  {
86  if (p.validFit()) {
87  h_xi->Fill(p.xi());
88 
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);
92  }
93  }
94 
95  void write() const
96  {
97  h_xi->Write("h_xi");
98 
99  h2_th_y_vs_xi->Write("h2_th_y_vs_xi");
100  p_th_y_vs_xi->Write("p_th_y_vs_xi");
101  }
102  };
103 
104  std::map<unsigned int, SingleRPPlots> singleRPPlots_;
105 
107  {
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;
109  std::unique_ptr<TH1D> h_t_xi_range1, h_t_xi_range2, h_t_xi_range3;
110  std::unique_ptr<TH1D> h_n_tracking_RPs, h_n_timing_RPs;
111  std::unique_ptr<TH2D> h2_th_x_vs_xi, h2_th_y_vs_xi, h2_vtx_y_vs_xi, h2_t_vs_xi;
112  std::unique_ptr<TProfile> p_th_x_vs_xi, p_th_y_vs_xi, p_vtx_y_vs_xi;
113 
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))
129  {
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;
134  t += de_t;
135  }
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()));
142  }
143 
145  {
146  if (!p.validFit())
147  return;
148 
149  unsigned int n_tracking_RPs=0, n_timing_RPs=0;
150  for (const auto &tr : p.contributingLocalTracks())
151  {
152  CTPPSDetId detId(tr->getRPId());
153  if (detId.subdetId() == CTPPSDetId::sdTrackingStrip || detId.subdetId() == CTPPSDetId::sdTrackingPixel)
154  n_tracking_RPs++;
155  if (detId.subdetId() == CTPPSDetId::sdTimingDiamond || detId.subdetId() == CTPPSDetId::sdTimingFastSilicon)
156  n_timing_RPs++;
157  }
158 
159  const double th_x = p.thetaX();
160  const double th_y = p.thetaY();
161  const double mt = - p.t();
162 
163  h_chi_sq->Fill(p.chi2());
164  if (p.ndof() > 0)
165  h_chi_sq_norm->Fill(p.normalizedChi2());
166 
167  h_n_tracking_RPs->Fill(n_tracking_RPs);
168  h_n_timing_RPs->Fill(n_timing_RPs);
169 
170  h_xi->Fill(p.xi());
171 
172  h_th_x->Fill(th_x);
173  h_th_y->Fill(th_y);
174 
175  h_vtx_y->Fill(p.vertex().y());
176 
177  h_t_unif->Fill(mt);
178  h_t->Fill(mt);
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);
182 
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);
187 
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());
191  }
192 
193  void write() const
194  {
195  h_chi_sq->Write("h_chi_sq");
196  h_chi_sq_norm->Write("h_chi_sq_norm");
197 
198  h_n_tracking_RPs->Write("h_n_tracking_RPs");
199  h_n_timing_RPs->Write("h_n_timing_RPs");
200 
201  h_xi->Write("h_xi");
202 
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>();
207  profileToRMSGraph(p_th_x_vs_xi.get(), g_th_x_RMS_vs_xi.get());
208  g_th_x_RMS_vs_xi->Write("g_th_x_RMS_vs_xi");
209 
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>();
214  profileToRMSGraph(p_th_y_vs_xi.get(), g_th_y_RMS_vs_xi.get());
215  g_th_y_RMS_vs_xi->Write("g_th_y_RMS_vs_xi");
216 
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>();
221  profileToRMSGraph(p_vtx_y_vs_xi.get(), g_vtx_y_RMS_vs_xi.get());
222  g_vtx_y_RMS_vs_xi->Write("g_vtx_y_RMS_vs_xi");
223 
224  h_t->Scale(1., "width");
225 
226  h_t_unif->Write("h_t_unif");
227  h_t->Write("h_t");
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");
231 
232  h2_t_vs_xi->Write("h2_t_vs_xi");
233  }
234  };
235 
236  std::map<unsigned int, MultiRPPlots> multiRPPlots_;
237 
239  {
240  std::unique_ptr<TH2D> h2_xi_mu_vs_xi_si;
241  std::unique_ptr<TH1D> h_xi_diff_mu_si, h_xi_diff_si_mu;
242 
243  std::unique_ptr<TH2D> h2_xi_diff_si_mu_vs_xi_mu;
244  std::unique_ptr<TProfile> p_xi_diff_si_mu_vs_xi_mu;
245 
246  std::unique_ptr<TH2D> h2_th_y_mu_vs_th_y_si;
247 
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))
255  {}
256 
257  void fill(const reco::ForwardProton &p_single, const reco::ForwardProton &p_multi)
258  {
259  if (p_single.validFit() && p_multi.validFit()) {
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());
263 
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());
266 
267  const double th_y_si = p_single.thetaY();
268  const double th_y_mu = p_multi.thetaY();
269 
270  h2_th_y_mu_vs_th_y_si->Fill(th_y_si, th_y_mu);
271  }
272  }
273 
274  void write() const
275  {
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");
279 
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");
282 
283  h2_th_y_mu_vs_th_y_si->Write("h2_th_y_mu_vs_th_y_si");
284  }
285  };
286 
287  std::map<unsigned int, SingleMultiCorrelationPlots> singleMultiCorrelationPlots_;
288 
290  {
291  std::unique_ptr<TH1D> h_xi_si_diffNF;
292  std::unique_ptr<TProfile> p_xi_si_diffNF_vs_xi_mu;
293 
294  std::unique_ptr<TH1D> h_th_y_si_diffNF;
295  std::unique_ptr<TProfile> p_th_y_si_diffNF_vs_xi_mu;
296 
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))
302  {}
303 
304  void fill(const reco::ForwardProton &p_s_N, const reco::ForwardProton &p_s_F, const reco::ForwardProton &p_m)
305  {
306  if (!p_s_N.validFit() || !p_s_F.validFit() || !p_m.validFit())
307  return;
308 
309  const double th_y_s_N = p_s_N.thetaY();
310  const double th_y_s_F = p_s_F.thetaY();
311 
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());
314 
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);
317  }
318 
319  void write() const
320  {
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");
323 
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");
326  }
327  };
328 
329  std::map<unsigned int, ArmCorrelationPlots> armCorrelationPlots_;
330 
331  std::unique_ptr<TProfile> p_x_L_diffNF_vs_x_L_N_, p_x_R_diffNF_vs_x_R_N_;
332  std::unique_ptr<TProfile> p_y_L_diffNF_vs_y_L_N_, p_y_R_diffNF_vs_y_R_N_;
333 
335 };
336 
337 //----------------------------------------------------------------------------------------------------
338 
339 using namespace std;
340 using namespace edm;
341 
342 //----------------------------------------------------------------------------------------------------
343 
345  tokenTracks_ (consumes<CTPPSLocalTrackLiteCollection>(ps.getParameter<edm::InputTag>("tagTracks"))),
346  tokenRecoProtonsSingleRP_(consumes<reco::ForwardProtonCollection>(ps.getParameter<InputTag>("tagRecoProtonsSingleRP"))),
347  tokenRecoProtonsMultiRP_ (consumes<reco::ForwardProtonCollection>(ps.getParameter<InputTag>("tagRecoProtonsMultiRP"))),
348 
349  rpId_45_N_(ps.getParameter<unsigned int>("rpId_45_N")),
350  rpId_45_F_(ps.getParameter<unsigned int>("rpId_45_F")),
351  rpId_56_N_(ps.getParameter<unsigned int>("rpId_56_N")),
352  rpId_56_F_(ps.getParameter<unsigned int>("rpId_56_F")),
353 
354  outputFile_(ps.getParameter<string>("outputFile")),
355  maxNonEmptyEvents_(ps.getUntrackedParameter<signed int>("maxNonEmptyEvents", -1)),
356 
357  p_x_L_diffNF_vs_x_L_N_(new TProfile("p_x_L_diffNF_vs_x_L_N", ";x_{LN};x_{LF} - x_{LN}", 100, 0., +20.)),
358  p_x_R_diffNF_vs_x_R_N_(new TProfile("p_x_R_diffNF_vs_x_R_N", ";x_{RN};x_{RF} - x_{RN}", 100, 0., +20.)),
359 
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.)),
362 
364 {}
365 
366 //----------------------------------------------------------------------------------------------------
367 
369 {
370  // get input
372  event.getByToken(tokenTracks_, hTracks);
373 
374  Handle<reco::ForwardProtonCollection> hRecoProtonsSingleRP;
375  event.getByToken(tokenRecoProtonsSingleRP_, hRecoProtonsSingleRP);
376 
377  Handle<reco::ForwardProtonCollection> hRecoProtonsMultiRP;
378  event.getByToken(tokenRecoProtonsMultiRP_, hRecoProtonsMultiRP);
379 
380  if (!hRecoProtonsSingleRP->empty())
382 
384  throw cms::Exception("CTPPSProtonReconstructionPlotter") << "Number of non empty events reached maximum.";
385 
386  // track plots
387  const CTPPSLocalTrackLite *tr_L_N = nullptr;
388  const CTPPSLocalTrackLite *tr_L_F = nullptr;
389  const CTPPSLocalTrackLite *tr_R_N = nullptr;
390  const CTPPSLocalTrackLite *tr_R_F = nullptr;
391 
392  for (const auto &tr : *hTracks)
393  {
394  CTPPSDetId rpId(tr.getRPId());
395  unsigned int decRPId = rpId.arm()*100 + rpId.station()*10 + rpId.rp();
396 
397  if (decRPId == rpId_45_N_) tr_L_N = &tr;
398  if (decRPId == rpId_45_F_) tr_L_F = &tr;
399  if (decRPId == rpId_56_N_) tr_R_N = &tr;
400  if (decRPId == rpId_56_F_) tr_R_F = &tr;
401  }
402 
403  if (tr_L_N && tr_L_F)
404  {
405  p_x_L_diffNF_vs_x_L_N_->Fill(tr_L_N->getX(), tr_L_F->getX() - tr_L_N->getX());
406  p_y_L_diffNF_vs_y_L_N_->Fill(tr_L_N->getY(), tr_L_F->getY() - tr_L_N->getY());
407  }
408 
409  if (tr_R_N && tr_R_F)
410  {
411  p_x_R_diffNF_vs_x_R_N_->Fill(tr_R_N->getX(), tr_R_F->getX() - tr_R_N->getX());
412  p_y_R_diffNF_vs_y_R_N_->Fill(tr_R_N->getY(), tr_R_F->getY() - tr_R_N->getY());
413  }
414 
415  // make single-RP-reco plots
416  for (const auto &proton : *hRecoProtonsSingleRP)
417  {
418  CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->getRPId());
419  unsigned int decRPId = rpId.arm()*100 + rpId.station()*10 + rpId.rp();
420  singleRPPlots_[decRPId].fill(proton);
421  }
422 
423  // make multi-RP-reco plots
424  for (const auto &proton : *hRecoProtonsMultiRP)
425  {
426  CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->getRPId());
427  unsigned int armId = rpId.arm();
428  multiRPPlots_[armId].fill(proton);
429  }
430 
431  // make correlation plots
432  for (const auto &proton_s : *hRecoProtonsSingleRP)
433  {
434  for (const auto &proton_m : *hRecoProtonsMultiRP)
435  {
436  // only compare object from the same arm
437  CTPPSDetId rpId_s((*proton_s.contributingLocalTracks().begin())->getRPId());
438  CTPPSDetId rpId_m((*proton_m.contributingLocalTracks().begin())->getRPId());
439 
440  if (rpId_s.arm() != rpId_m.arm())
441  continue;
442 
443  // build index
444  const unsigned int idx = rpId_s.arm()*1000 + rpId_s.station()*100 + rpId_s.rp()*10 + rpId_m.arm();
445 
446  // fill plots
447  singleMultiCorrelationPlots_[idx].fill(proton_s, proton_m);
448  }
449  }
450 
451  // arm correlation plots
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;
454 
455  for (const auto &proton : *hRecoProtonsSingleRP)
456  {
457  CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->getRPId());
458  const unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp();
459 
460  if (rpDecId == rpId_45_N_) p_arm0_s_N = &proton;
461  if (rpDecId == rpId_45_F_) p_arm0_s_F = &proton;
462 
463  if (rpDecId == rpId_56_N_) p_arm1_s_N = &proton;
464  if (rpDecId == rpId_56_F_) p_arm1_s_F = &proton;
465  }
466 
467  for (const auto & proton : *hRecoProtonsMultiRP)
468  {
469  CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->getRPId());
470  const unsigned int arm = rpId.arm();
471 
472  if (arm == 0) p_arm0_m = &proton;
473  if (arm == 1) p_arm1_m = &proton;
474  }
475 
476  if (p_arm0_s_N && p_arm0_s_F && p_arm0_m)
477  armCorrelationPlots_[0].fill(*p_arm0_s_N, *p_arm0_s_F, *p_arm0_m);
478 
479  if (p_arm1_s_N && p_arm1_s_F && p_arm1_m)
480  armCorrelationPlots_[1].fill(*p_arm1_s_N, *p_arm1_s_F, *p_arm1_m);
481 }
482 
483 //----------------------------------------------------------------------------------------------------
484 
486 {
487  LogInfo("CTPPSProtonReconstructionPlotter") << "n_non_empty_events = " << n_non_empty_events_;
488 
489  auto f_out = std::make_unique<TFile>(outputFile_.c_str(), "recreate");
490 
491  p_x_L_diffNF_vs_x_L_N_->Write();
492  p_x_R_diffNF_vs_x_R_N_->Write();
493 
494  p_y_L_diffNF_vs_y_L_N_->Write();
495  p_y_R_diffNF_vs_y_R_N_->Write();
496 
497  TDirectory *d_singleRPPlots = f_out->mkdir("singleRPPlots");
498  for (const auto& it : singleRPPlots_) {
499  gDirectory = d_singleRPPlots->mkdir(Form("rp%u", it.first));
500  it.second.write();
501  }
502 
503  TDirectory *d_multiRPPlots = f_out->mkdir("multiRPPlots");
504  for (const auto& it : multiRPPlots_) {
505  gDirectory = d_multiRPPlots->mkdir(Form("arm%u", it.first));
506  it.second.write();
507  }
508 
509  TDirectory *d_singleMultiCorrelationPlots = f_out->mkdir("singleMultiCorrelationPlots");
510  for (const auto& it : singleMultiCorrelationPlots_) {
511  unsigned int si_rp = it.first / 10;
512  unsigned int mu_arm = it.first % 10;
513 
514  gDirectory = d_singleMultiCorrelationPlots->mkdir(Form("si_rp%u_mu_arm%u", si_rp, mu_arm));
515  it.second.write();
516  }
517 
518  TDirectory *d_armCorrelationPlots = f_out->mkdir("armCorrelationPlots");
519  for (const auto& it : armCorrelationPlots_) {
520  gDirectory = d_armCorrelationPlots->mkdir(Form("arm%u", it.first));
521  it.second.write();
522  }
523 }
524 
525 //----------------------------------------------------------------------------------------------------
526 
528 
const Point & vertex() const
fitted vertex position
Definition: ForwardProton.h:46
static void profileToRMSGraph(TProfile *p, TGraphErrors *g)
std::map< unsigned int, MultiRPPlots > multiRPPlots_
edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsSingleRP_
std::map< unsigned int, SingleRPPlots > singleRPPlots_
Local (=single RP) track with essential information only.
void analyze(const edm::Event &, const edm::EventSetup &) override
float t() const
four-momentum transfer squared, in GeV^2
edm::EDGetTokenT< CTPPSLocalTrackLiteCollection > tokenTracks_
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
Definition: Activities.doc:4
float chi2() const
chi-squared of the fit
Definition: ForwardProton.h:67
float thetaX() const
vertical scattering angle, in rad
Definition: ForwardProton.h:78
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
T sqrt(T t)
Definition: SSEVec.h:18
float normalizedChi2() const
chi-squared divided by ndof (or chi-squared * 1e6 if ndof is zero)
Definition: ForwardProton.h:71
float xi() const
longitudinal fractional momentum loss
Definition: ForwardProton.h:76
float getY() const
returns the vertical track position
uint32_t arm() const
Definition: CTPPSDetId.h:51
const CTPPSLocalTrackLiteRefVector & contributingLocalTracks() const
list of RP tracks that contributed to this global track
std::map< unsigned int, ArmCorrelationPlots > armCorrelationPlots_
bool validFit() const
flag for the fit validity
#define N
Definition: blowfish.cc:9
std::vector< CTPPSLocalTrackLite > CTPPSLocalTrackLiteCollection
Collection of CTPPSLocalTrackLite objects.
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
fixed size matrix
HLT enums.
CTPPSProtonReconstructionPlotter(const edm::ParameterSet &)
std::map< unsigned int, SingleMultiCorrelationPlots > singleMultiCorrelationPlots_
float thetaY() const
horizontal scattering angle, in rad
Definition: ForwardProton.h:80
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_
Definition: event.py:1
unsigned int ndof() const
number of degrees of freedom for the track fit
Definition: ForwardProton.h:69