CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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&);
54 
55 
56 private:
57  virtual void beginJob() ;
58  virtual void analyze(const edm::Event&, const edm::EventSetup&);
59  virtual void beginRun(const edm::Run&, const edm::EventSetup&);
60  virtual void endRun(const edm::Run&, const edm::EventSetup&);
61  virtual void endJob() ;
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->size()) 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
virtual void analyze(const edm::Event &, const edm::EventSetup &)
RunNumber_t run() const
Definition: RunBase.h:42
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::EDGetTokenT< reco::VertexCollection > _recoVertexCollectionToken
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:230
virtual void endJob()
virtual void beginJob()
edm::EDGetTokenT< reco::BeamSpot > _recoBeamSpotToken
void book(const std::string dirname="")
virtual void endRun(const edm::Run &, const edm::EventSetup &)
BSvsPVHistogramMaker _bspvhm
BSvsPVAnalyzer(const edm::ParameterSet &)
void beginRun(const unsigned int nrun)
volatile std::atomic< bool > shutdown_flag false
void fill(const unsigned int orbit, const int bx, const reco::VertexCollection &vertices, const reco::BeamSpot &bs)
Definition: Run.h:41