CMS 3D CMS Logo

BSvsPVAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Validation/RecoVertex
4 // Class: BSvsPVAnalyzer
5 //
13 //
14 // Original Author: Andrea Venturi
15 // Created: Mon Oct 27 17:37:53 CET 2008
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
24 
25 #include <vector>
26 #include <map>
27 #include <limits>
28 #include <string>
29 
32 
36 
38 
40 
45 
46 //
47 // class decleration
48 //
49 
51  public:
52  explicit BSvsPVAnalyzer(const edm::ParameterSet&);
53  ~BSvsPVAnalyzer() override;
54 
55 
56 private:
57  void beginJob() override ;
58  void analyze(const edm::Event&, const edm::EventSetup&) override;
59  void beginRun(const edm::Run&, const edm::EventSetup&) override;
60  void endRun(const edm::Run&, const edm::EventSetup&) override;
61  void endJob() override ;
62 
63  // ----------member data ---------------------------
64 
68  bool _firstOnly;
69 
70 };
71 
72 //
73 // constants, enums and typedefs
74 //
75 
76 //
77 // static data member definitions
78 //
79 
80 //
81 // constructors and destructor
82 //
84  : _bspvhm(iConfig.getParameter<edm::ParameterSet>("bspvHistogramMakerPSet"), consumesCollector())
85  , _recoVertexCollectionToken(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("pvCollection")))
86  , _recoBeamSpotToken(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("bsCollection")))
87  , _firstOnly(iConfig.getUntrackedParameter<bool>("firstOnly",false))
88 {
89  //now do what ever initialization is needed
90 
91  //
92 
93  _bspvhm.book();
94 
95 }
96 
97 
99 {
100 
101  // do anything here that needs to be done at desctruction time
102  // (e.g. close files, deallocate resources etc.)
103 
104 }
105 
106 
107 //
108 // member functions
109 //
110 
111 // ------------ method called to for each event ------------
112 void
114 {
115 
116  // get BS
117 
119  iEvent.getByToken(_recoBeamSpotToken,bs);
120 
121  // get PV
122 
124  iEvent.getByToken(_recoVertexCollectionToken,pvcoll);
125 
126  if(_firstOnly) {
127  reco::VertexCollection firstpv;
128  if(!pvcoll->empty()) firstpv.push_back((*pvcoll)[0]);
129  _bspvhm.fill(iEvent,firstpv,*bs);
130  }
131  else {
132  _bspvhm.fill(iEvent,*pvcoll,*bs);
133  }
134 }
135 
136 
137 // ------------ method called once each job just before starting event loop ------------
138 void
140 { }
141 
142 void
143 BSvsPVAnalyzer::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
144 
145  _bspvhm.beginRun(iRun.run());
146 
147 }
148 
149 void
150 BSvsPVAnalyzer::endRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
151 
152 }
153 // ------------ method called once each job just after ending the event loop ------------
154 void
156 }
157 
158 
159 //define this as a plug-in
void beginJob() override
void endRun(const edm::Run &, const edm::EventSetup &) override
RunNumber_t run() const
Definition: RunBase.h:40
~BSvsPVAnalyzer() override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void endJob() override
edm::EDGetTokenT< reco::VertexCollection > _recoVertexCollectionToken
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void beginRun(const edm::Run &, const edm::EventSetup &) override
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::EDGetTokenT< reco::BeamSpot > _recoBeamSpotToken
void book(const std::string dirname="")
BSvsPVHistogramMaker _bspvhm
fixed size matrix
HLT enums.
BSvsPVAnalyzer(const edm::ParameterSet &)
void beginRun(const unsigned int nrun)
void analyze(const edm::Event &, const edm::EventSetup &) override
void fill(const unsigned int orbit, const int bx, const reco::VertexCollection &vertices, const reco::BeamSpot &bs)
Definition: Run.h:45