CMS 3D CMS Logo

CTPPSProtonReconstructionDiffPlotter.cc
Go to the documentation of this file.
1 /****************************************************************************
2 * Authors:
3 * Jan Kašpar (jan.kaspar@gmail.com)
4 ****************************************************************************/
5 
6 // TODO: clean
15 
17 
21 
24 
25 #include "TFile.h"
26 #include "TGraphErrors.h"
27 #include "TH1D.h"
28 #include "TH2D.h"
29 #include "TProfile.h"
30 
31 //----------------------------------------------------------------------------------------------------
32 
34 public:
37 
38 private:
39  void analyze(const edm::Event &, const edm::EventSetup &) override;
40 
41  void endJob() override;
42 
45 
47 
48  std::unique_ptr<TH1D> h_de_xi, h_de_th_x, h_de_th_y, h_de_vtx_y;
49 };
50 
51 //----------------------------------------------------------------------------------------------------
52 
53 using namespace std;
54 using namespace edm;
55 
56 //----------------------------------------------------------------------------------------------------
57 
59  : tokenRecoProtonsRef_(consumes<reco::ForwardProtonCollection>(ps.getParameter<InputTag>("tagRecoProtonsRef"))),
60  tokenRecoProtonsTest_(consumes<reco::ForwardProtonCollection>(ps.getParameter<InputTag>("tagRecoProtonsTest"))),
61 
62  outputFile_(ps.getParameter<string>("outputFile")),
63 
64  h_de_xi(new TH1D("", ";#Delta#xi", 200, -0.01, +0.01)),
65  h_de_th_x(new TH1D("", ";#Delta#theta_{x}", 200, -100E-6, +100E-6)),
66  h_de_th_y(new TH1D("", ";#Delta#theta_{y}", 200, -100E-6, +100E-6)),
67  h_de_vtx_y(new TH1D("", ";#Deltay^{*} (cm)", 200, -0.01, +0.01)) {}
68 
69 //----------------------------------------------------------------------------------------------------
70 
72  // get input
74  event.getByToken(tokenRecoProtonsRef_, hRecoProtonsRef);
75 
77  event.getByToken(tokenRecoProtonsTest_, hRecoProtonsTest);
78 
79  if (hRecoProtonsRef->size() != hRecoProtonsTest->size()) {
80  edm::LogWarning("CTPPSProtonReconstructionDiffPlotter::analyze")
81  << "Different number of Ref and Test protons. Skipping event.";
82  return;
83  }
84 
85  for (unsigned int i = 0; i < hRecoProtonsRef->size(); ++i) {
86  const auto &pr_ref = hRecoProtonsRef->at(i);
87  const auto &pr_test = hRecoProtonsTest->at(i);
88 
89  if (!pr_ref.validFit() || !pr_test.validFit())
90  continue;
91 
92  h_de_xi->Fill(pr_test.xi() - pr_ref.xi());
93  h_de_th_x->Fill(pr_test.thetaX() - pr_ref.thetaX());
94  h_de_th_y->Fill(pr_test.thetaY() - pr_ref.thetaY());
95  h_de_vtx_y->Fill(pr_test.vy() - pr_ref.vy());
96  }
97 }
98 
99 //----------------------------------------------------------------------------------------------------
100 
102  auto f_out = std::make_unique<TFile>(outputFile_.c_str(), "recreate");
103 
104  h_de_xi->Write("h_de_xi");
105  h_de_th_x->Write("h_de_th_x");
106  h_de_th_y->Write("h_de_th_y");
107  h_de_vtx_y->Write("h_de_vtx_y");
108 }
109 
110 //----------------------------------------------------------------------------------------------------
111 
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsTest_
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsRef_
fixed size matrix
HLT enums.
std::vector< ForwardProton > ForwardProtonCollection
Collection of ForwardProton objects.
Log< level::Warning, false > LogWarning
Definition: event.py:1