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 
50 class AnotherPrimaryVertexAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::SharedResources> {
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  usesResource(TFileService::kSharedResource);
93  //
94  _vhm.book();
95 }
96 
98 
99 //
100 // member functions
101 //
102 
103 // ------------ method called to for each event ------------
105  // compute event weigth
106 
107  double weight = 1.;
108 
109  if (_weightprov)
110  weight = _weightprov->prescaleWeight(iEvent, iSetup);
111 
112  // get PV
113 
115  iEvent.getByToken(_recoVertexCollectionToken, pvcoll);
116 
117  if (_firstOnly) {
118  reco::VertexCollection firstpv;
119  if (!pvcoll->empty())
120  firstpv.push_back((*pvcoll)[0]);
121  _vhm.fill(iEvent, firstpv, weight);
122  } else {
123  _vhm.fill(iEvent, *pvcoll, weight);
124  }
125 }
126 
127 // ------------ method called once each job just before starting event loop ------------
129 
131  _vhm.beginRun(iRun);
132 
133  if (_weightprov)
134  _weightprov->initRun(iRun, iSetup);
135 }
136 
138 // ------------ method called once each job just after ending the event loop ------------
140 
141 //define this as a plug-in
AnotherPrimaryVertexAnalyzer::endRun
void endRun(const edm::Run &, const edm::EventSetup &) override
Definition: AnotherPrimaryVertexAnalyzer.cc:137
AnotherPrimaryVertexAnalyzer::_recoVertexCollectionToken
edm::EDGetTokenT< reco::VertexCollection > _recoVertexCollectionToken
Definition: AnotherPrimaryVertexAnalyzer.cc:65
electrons_cff.bool
bool
Definition: electrons_cff.py:366
EDAnalyzer.h
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:89301
AnotherPrimaryVertexAnalyzer
Definition: AnotherPrimaryVertexAnalyzer.cc:50
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
edm::Handle< reco::VertexCollection >
AnotherPrimaryVertexAnalyzer::beginJob
void beginJob() override
Definition: AnotherPrimaryVertexAnalyzer.cc:128
AnotherPrimaryVertexAnalyzer::~AnotherPrimaryVertexAnalyzer
~AnotherPrimaryVertexAnalyzer() override
Definition: AnotherPrimaryVertexAnalyzer.cc:97
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
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:58
InputTag.h
AnotherPrimaryVertexAnalyzer::_vhm
VertexHistogramMaker _vhm
Definition: AnotherPrimaryVertexAnalyzer.cc:64
VertexFwd.h
AnotherPrimaryVertexAnalyzer::endJob
void endJob() override
Definition: AnotherPrimaryVertexAnalyzer.cc:139
Vertex.h
Frameworkfwd.h
l1t::VertexCollection
std::vector< Vertex > VertexCollection
Definition: Vertex.h:12
TFileService::kSharedResource
static const std::string kSharedResource
Definition: TFileService.h:76
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:104
AnotherPrimaryVertexAnalyzer::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: AnotherPrimaryVertexAnalyzer.cc:130
VertexHistogramMaker.h
weight
Definition: weight.py:1