CMS 3D CMS Logo

AnotherPrimaryVertexAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Validation/RecoVertex
4 // Class: AnotherPrimaryVertexAnalyzer
5 //
13 //
14 // Original Author: Andrea Venturi
15 // Created: Mon Oct 27 17:37:53 CET 2008
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
23 
24 #include <vector>
25 #include <map>
26 #include <limits>
27 #include <string>
28 
35 
37 
39 
43 
45 
46 //
47 // class decleration
48 //
49 
51 public:
54 
55 private:
56  void beginJob() override;
57  void analyze(const edm::Event&, const edm::EventSetup&) override;
58  void beginRun(const edm::Run&, const edm::EventSetup&) override;
59  void endRun(const edm::Run&, const edm::EventSetup&) override;
60  void endJob() override;
61 
62  // ----------member data ---------------------------
63 
66  bool _firstOnly;
67 
68  std::unique_ptr<PrescaleWeightProvider> _weightprov;
69 };
70 
71 //
72 // constants, enums and typedefs
73 //
74 
75 //
76 // static data member definitions
77 //
78 
79 //
80 // constructors and destructor
81 //
83  : _vhm(iConfig.getParameter<edm::ParameterSet>("vHistogramMakerPSet"), consumesCollector()),
84  _recoVertexCollectionToken(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("pvCollection"))),
85  _firstOnly(iConfig.getUntrackedParameter<bool>("firstOnly", false)),
86  _weightprov(
87  iConfig.getParameter<bool>("usePrescaleWeight")
89  iConfig.getParameter<edm::ParameterSet>("prescaleWeightProviderPSet"), consumesCollector(), *this)
90  : nullptr) {
91  //now do what ever initialization is needed
92 
93  //
94 
95  _vhm.book();
96 }
97 
99 
100 //
101 // member functions
102 //
103 
104 // ------------ method called to for each event ------------
106  // compute event weigth
107 
108  double weight = 1.;
109 
110  if (_weightprov)
111  weight = _weightprov->prescaleWeight(iEvent, iSetup);
112 
113  // get PV
114 
116  iEvent.getByToken(_recoVertexCollectionToken, pvcoll);
117 
118  if (_firstOnly) {
119  reco::VertexCollection firstpv;
120  if (!pvcoll->empty())
121  firstpv.push_back((*pvcoll)[0]);
122  _vhm.fill(iEvent, firstpv, weight);
123  } else {
124  _vhm.fill(iEvent, *pvcoll, weight);
125  }
126 }
127 
128 // ------------ method called once each job just before starting event loop ------------
130 
132  _vhm.beginRun(iRun);
133 
134  if (_weightprov)
135  _weightprov->initRun(iRun, iSetup);
136 }
137 
139 // ------------ method called once each job just after ending the event loop ------------
141 
142 //define this as a plug-in
AnotherPrimaryVertexAnalyzer::endRun
void endRun(const edm::Run &, const edm::EventSetup &) override
Definition: AnotherPrimaryVertexAnalyzer.cc:138
AnotherPrimaryVertexAnalyzer::_recoVertexCollectionToken
edm::EDGetTokenT< reco::VertexCollection > _recoVertexCollectionToken
Definition: AnotherPrimaryVertexAnalyzer.cc:65
electrons_cff.bool
bool
Definition: electrons_cff.py:393
funct::false
false
Definition: Factorize.h:29
VertexHistogramMaker::fill
void fill(const edm::Event &iEvent, const reco::VertexCollection &vertices, const double weight=1.)
Definition: VertexHistogramMaker.cc:440
edm::Run
Definition: Run.h:45
edm::EDGetTokenT< reco::VertexCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
AnotherPrimaryVertexAnalyzer
Definition: AnotherPrimaryVertexAnalyzer.cc:50
EDAnalyzer.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle< reco::VertexCollection >
AnotherPrimaryVertexAnalyzer::beginJob
void beginJob() override
Definition: AnotherPrimaryVertexAnalyzer.cc:129
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
AnotherPrimaryVertexAnalyzer::~AnotherPrimaryVertexAnalyzer
~AnotherPrimaryVertexAnalyzer() override
Definition: AnotherPrimaryVertexAnalyzer.cc:98
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PrescaleWeightProvider
This class takes a vector of HLT paths and returns a weight based on their HLT and L1 prescales....
Definition: PrescaleWeightProvider.h:47
Run.h
VertexHistogramMaker
Definition: VertexHistogramMaker.h:23
AnotherPrimaryVertexAnalyzer::AnotherPrimaryVertexAnalyzer
AnotherPrimaryVertexAnalyzer(const edm::ParameterSet &)
Definition: AnotherPrimaryVertexAnalyzer.cc:82
Vertex.h
AnotherPrimaryVertexAnalyzer::_firstOnly
bool _firstOnly
Definition: AnotherPrimaryVertexAnalyzer.cc:66
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
ParameterSet
Definition: Functions.h:16
iEvent
int iEvent
Definition: GenABIO.cc:224
VertexHistogramMaker::beginRun
void beginRun(const edm::Run &iRun)
Definition: VertexHistogramMaker.cc:257
PrescaleWeightProvider.h
edm::EventSetup
Definition: EventSetup.h:57
InputTag.h
AnotherPrimaryVertexAnalyzer::_vhm
VertexHistogramMaker _vhm
Definition: AnotherPrimaryVertexAnalyzer.cc:64
VertexFwd.h
AnotherPrimaryVertexAnalyzer::endJob
void endJob() override
Definition: AnotherPrimaryVertexAnalyzer.cc:140
Frameworkfwd.h
ConsumesCollector.h
AnotherPrimaryVertexAnalyzer::_weightprov
std::unique_ptr< PrescaleWeightProvider > _weightprov
Definition: AnotherPrimaryVertexAnalyzer.cc:68
ParameterSet.h
edm::Event
Definition: Event.h:73
VertexHistogramMaker::book
void book(const std::string dirname="")
Definition: VertexHistogramMaker.cc:48
AnotherPrimaryVertexAnalyzer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: AnotherPrimaryVertexAnalyzer.cc:105
AnotherPrimaryVertexAnalyzer::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: AnotherPrimaryVertexAnalyzer.cc:131
VertexHistogramMaker.h
weight
Definition: weight.py:1