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 // $Id: BSvsPVAnalyzer.cc,v 1.1 2011/03/08 17:11:26 venturia Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
25 
26 #include <vector>
27 #include <map>
28 #include <limits>
29 #include <string>
30 
33 
37 
39 
41 
46 
47 //
48 // class decleration
49 //
50 
52  public:
53  explicit BSvsPVAnalyzer(const edm::ParameterSet&);
55 
56 
57 private:
58  virtual void beginJob() ;
59  virtual void analyze(const edm::Event&, const edm::EventSetup&);
60  virtual void beginRun(const edm::Run&, const edm::EventSetup&);
61  virtual void endRun(const edm::Run&, const edm::EventSetup&);
62  virtual void endJob() ;
63 
64  // ----------member data ---------------------------
65 
69  bool _firstOnly;
70 
71 };
72 
73 //
74 // constants, enums and typedefs
75 //
76 
77 //
78 // static data member definitions
79 //
80 
81 //
82 // constructors and destructor
83 //
85  _bspvhm(iConfig.getParameter<edm::ParameterSet>("bspvHistogramMakerPSet")),
86  _pvcollection(iConfig.getParameter<edm::InputTag>("pvCollection")),
87  _bscollection(iConfig.getParameter<edm::InputTag>("bsCollection")),
88  _firstOnly(iConfig.getUntrackedParameter<bool>("firstOnly",false))
89 {
90  //now do what ever initialization is needed
91 
92  //
93 
94  _bspvhm.book();
95 
96 }
97 
98 
100 {
101 
102  // do anything here that needs to be done at desctruction time
103  // (e.g. close files, deallocate resources etc.)
104 
105 }
106 
107 
108 //
109 // member functions
110 //
111 
112 // ------------ method called to for each event ------------
113 void
115 {
116  using namespace edm;
117 
118  // get BS
119 
121  iEvent.getByLabel(_bscollection,bs);
122 
123  // get PV
124 
126  iEvent.getByLabel(_pvcollection,pvcoll);
127 
128  if(_firstOnly) {
129  reco::VertexCollection firstpv;
130  if(pvcoll->size()) firstpv.push_back((*pvcoll)[0]);
131  _bspvhm.fill(iEvent,firstpv,*bs);
132  }
133  else {
134  _bspvhm.fill(iEvent,*pvcoll,*bs);
135  }
136 }
137 
138 
139 // ------------ method called once each job just before starting event loop ------------
140 void
142 { }
143 
144 void
145 BSvsPVAnalyzer::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
146 
147  _bspvhm.beginRun(iRun.run());
148 
149 }
150 
151 void
152 BSvsPVAnalyzer::endRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
153 
154 }
155 // ------------ method called once each job just after ending the event loop ------------
156 void
158 }
159 
160 
161 //define this as a plug-in
virtual void analyze(const edm::Event &, const edm::EventSetup &)
edm::InputTag _bscollection
RunNumber_t run() const
Definition: RunBase.h:42
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
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:243
virtual void endJob()
virtual void beginJob()
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
void book(const std::string dirname="")
edm::InputTag _pvcollection
virtual void endRun(const edm::Run &, const edm::EventSetup &)
BSvsPVHistogramMaker _bspvhm
BSvsPVAnalyzer(const edm::ParameterSet &)
void beginRun(const unsigned int nrun)
void fill(const unsigned int orbit, const int bx, const reco::VertexCollection &vertices, const reco::BeamSpot &bs)
Definition: Run.h:36