CMS 3D CMS Logo

CTPPSDirectProtonSimulationValidator.cc
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * This is a part of CTPPS validation software
4  * Authors:
5  * Jan Kašpar
6  * Laurent Forthomme
7  *
8  ****************************************************************************/
9 
12 
15 
17 
21 
22 #include "TFile.h"
23 #include "TH1D.h"
24 #include "TH2D.h"
25 
26 #include <map>
27 
28 //----------------------------------------------------------------------------------------------------
29 
31 public:
33 
34 private:
35  void beginJob() override {}
36  void analyze(const edm::Event&, const edm::EventSetup&) override;
37  void endJob() override;
38 
41 
43 
44  struct RPPlots {
45  std::unique_ptr<TH2D> h2_xr_vs_xs, h2_yr_vs_ys;
46  std::unique_ptr<TH1D> h_de_x, h_de_y;
47 
48  RPPlots()
49  : h2_xr_vs_xs(new TH2D("", ";x_simu (mm);x_reco (mm)", 100, -10., +10., 100, -10, +10.)),
50  h2_yr_vs_ys(new TH2D("", "y_simu (mm);y_reco (mm)", 100, -10., +10., 100, -10, +10.)),
51  h_de_x(new TH1D("", ";x (mm)", 200, -100E-3, +100E-3)),
52  h_de_y(new TH1D("", ";y (mm)", 200, -100E-3, +100E-3)) {}
53 
54  void fill(double simu_x, double simu_y, double reco_x, double reco_y) {
55  h2_xr_vs_xs->Fill(simu_x, reco_x);
56  h2_yr_vs_ys->Fill(simu_y, reco_y);
57 
58  h_de_x->Fill(reco_x - simu_x);
59  h_de_y->Fill(reco_y - simu_y);
60  }
61 
62  void write() const {
63  h2_xr_vs_xs->Write("h2_xr_vs_xs");
64  h2_yr_vs_ys->Write("h2_yr_vs_ys");
65  h_de_x->Write("h_de_x");
66  h_de_y->Write("h_de_y");
67  }
68  };
69 
70  std::map<unsigned int, RPPlots> rpPlots_;
71 };
72 
73 //----------------------------------------------------------------------------------------------------
74 
76  : simuTracksToken_(consumes<CTPPSLocalTrackLiteCollection>(iConfig.getParameter<edm::InputTag>("simuTracksTag"))),
77  recoTracksToken_(consumes<CTPPSLocalTrackLiteCollection>(iConfig.getParameter<edm::InputTag>("recoTracksTag"))),
78  outputFile_(iConfig.getParameter<std::string>("outputFile")) {}
79 
80 //----------------------------------------------------------------------------------------------------
81 
83  // get input
85  iEvent.getByToken(simuTracksToken_, simuTracks);
86 
88  iEvent.getByToken(recoTracksToken_, recoTracks);
89 
90  // process tracks
91  for (const auto& simuTrack : *simuTracks) {
92  const CTPPSDetId rpId(simuTrack.rpId());
93  for (const auto& recoTrack : *recoTracks) {
94  if (simuTrack.rpId() == recoTrack.rpId()) {
95  unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp();
96  rpPlots_[rpDecId].fill(simuTrack.x(), simuTrack.y(), recoTrack.x(), recoTrack.y());
97  }
98  }
99  }
100 }
101 
102 //----------------------------------------------------------------------------------------------------
103 
105  auto f_out = std::make_unique<TFile>(outputFile_.c_str(), "recreate");
106 
107  for (const auto& it : rpPlots_) {
108  gDirectory = f_out->mkdir(Form("RP %u", it.first));
109  it.second.write();
110  }
111 }
112 
113 //----------------------------------------------------------------------------------------------------
114 
CTPPSDirectProtonSimulationValidator::simuTracksToken_
edm::EDGetTokenT< CTPPSLocalTrackLiteCollection > simuTracksToken_
Definition: CTPPSDirectProtonSimulationValidator.cc:44
CTPPSLocalTrackLiteCollection
std::vector< CTPPSLocalTrackLite > CTPPSLocalTrackLiteCollection
Collection of CTPPSLocalTrackLite objects.
Definition: CTPPSLocalTrackLiteFwd.h:18
EDAnalyzer.h
CTPPSDirectProtonSimulationValidator::RPPlots::h2_yr_vs_ys
std::unique_ptr< TH2D > h2_yr_vs_ys
Definition: CTPPSDirectProtonSimulationValidator.cc:50
CTPPSDirectProtonSimulationValidator::rpPlots_
std::map< unsigned int, RPPlots > rpPlots_
Definition: CTPPSDirectProtonSimulationValidator.cc:75
CTPPSDirectProtonSimulationValidator::RPPlots::h_de_y
std::unique_ptr< TH1D > h_de_y
Definition: CTPPSDirectProtonSimulationValidator.cc:51
edm::EDGetTokenT< CTPPSLocalTrackLiteCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
CTPPSDirectProtonSimulationValidator::RPPlots::h2_xr_vs_xs
std::unique_ptr< TH2D > h2_xr_vs_xs
Definition: CTPPSDirectProtonSimulationValidator.cc:50
CTPPSLocalTrackLite.h
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
edm::Handle
Definition: AssociativeIterator.h:50
CTPPSDirectProtonSimulationValidator::CTPPSDirectProtonSimulationValidator
CTPPSDirectProtonSimulationValidator(const edm::ParameterSet &)
Definition: CTPPSDirectProtonSimulationValidator.cc:74
CTPPSDirectProtonSimulationValidator::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: CTPPSDirectProtonSimulationValidator.cc:81
MakerMacros.h
CTPPSDirectProtonSimulationValidator::endJob
void endJob() override
Definition: CTPPSDirectProtonSimulationValidator.cc:103
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
CTPPSDirectProtonSimulationValidator::outputFile_
std::string outputFile_
Definition: CTPPSDirectProtonSimulationValidator.cc:47
CTPPSDirectProtonSimulationValidator::recoTracksToken_
edm::EDGetTokenT< CTPPSLocalTrackLiteCollection > recoTracksToken_
Definition: CTPPSDirectProtonSimulationValidator.cc:45
CTPPSDirectProtonSimulationValidator::RPPlots::RPPlots
RPPlots()
Definition: CTPPSDirectProtonSimulationValidator.cc:53
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
CTPPSDirectProtonSimulationValidator::beginJob
void beginJob() override
Definition: CTPPSDirectProtonSimulationValidator.cc:40
CTPPSDetId
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:31
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
CTPPSDirectProtonSimulationValidator::RPPlots::fill
void fill(double simu_x, double simu_y, double reco_x, double reco_y)
Definition: CTPPSDirectProtonSimulationValidator.cc:59
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
profile_2016_postTS2_cff.rpId
rpId
Definition: profile_2016_postTS2_cff.py:21
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
CTPPSLocalTrackLiteFwd.h
CTPPSDetId.h
CTPPSDirectProtonSimulationValidator::RPPlots::h_de_x
std::unique_ptr< TH1D > h_de_x
Definition: CTPPSDirectProtonSimulationValidator.cc:51
ParameterSet.h
CTPPSDirectProtonSimulationValidator::RPPlots::write
void write() const
Definition: CTPPSDirectProtonSimulationValidator.cc:67
edm::Event
Definition: Event.h:73
CTPPSDirectProtonSimulationValidator
Definition: CTPPSDirectProtonSimulationValidator.cc:29
CTPPSDirectProtonSimulationValidator::RPPlots
Definition: CTPPSDirectProtonSimulationValidator.cc:49