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 // 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 
31 
35 
37 
39 
44 
45 //
46 // class decleration
47 //
48 
49 class BSvsPVAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::SharedResources> {
50 public:
51  explicit BSvsPVAnalyzer(const edm::ParameterSet&);
52  ~BSvsPVAnalyzer() override;
53 
54 private:
55  void beginJob() override;
56  void analyze(const edm::Event&, const edm::EventSetup&) override;
57  void beginRun(const edm::Run&, const edm::EventSetup&) override;
58  void endRun(const edm::Run&, const edm::EventSetup&) override;
59  void endJob() override;
60 
61  // ----------member data ---------------------------
62 
66  bool _firstOnly;
67 };
68 
69 //
70 // constants, enums and typedefs
71 //
72 
73 //
74 // static data member definitions
75 //
76 
77 //
78 // constructors and destructor
79 //
81  : _bspvhm(iConfig.getParameter<edm::ParameterSet>("bspvHistogramMakerPSet"), consumesCollector()),
82  _recoVertexCollectionToken(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("pvCollection"))),
83  _recoBeamSpotToken(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("bsCollection"))),
84  _firstOnly(iConfig.getUntrackedParameter<bool>("firstOnly", false)) {
85  //now do what ever initialization is needed
86  usesResource(TFileService::kSharedResource);
87  //
88 
89  _bspvhm.book();
90 }
91 
93  // do anything here that needs to be done at desctruction time
94  // (e.g. close files, deallocate resources etc.)
95 }
96 
97 //
98 // member functions
99 //
100 
101 // ------------ method called to for each event ------------
103  // get BS
104 
106  iEvent.getByToken(_recoBeamSpotToken, bs);
107 
108  // get PV
109 
111  iEvent.getByToken(_recoVertexCollectionToken, pvcoll);
112 
113  if (_firstOnly) {
114  reco::VertexCollection firstpv;
115  if (!pvcoll->empty())
116  firstpv.push_back((*pvcoll)[0]);
117  _bspvhm.fill(iEvent, firstpv, *bs);
118  } else {
119  _bspvhm.fill(iEvent, *pvcoll, *bs);
120  }
121 }
122 
123 // ------------ method called once each job just before starting event loop ------------
125 
126 void BSvsPVAnalyzer::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) { _bspvhm.beginRun(iRun.run()); }
127 
128 void BSvsPVAnalyzer::endRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {}
129 // ------------ method called once each job just after ending the event loop ------------
131 
132 //define this as a plug-in
BSvsPVAnalyzer::BSvsPVAnalyzer
BSvsPVAnalyzer(const edm::ParameterSet &)
Definition: BSvsPVAnalyzer.cc:80
electrons_cff.bool
bool
Definition: electrons_cff.py:366
EDAnalyzer.h
funct::false
false
Definition: Factorize.h:29
align::BeamSpot
Definition: StructureType.h:95
edm::Run
Definition: Run.h:45
BSvsPVAnalyzer::endRun
void endRun(const edm::Run &, const edm::EventSetup &) override
Definition: BSvsPVAnalyzer.cc:128
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:89285
BSvsPVHistogramMaker::beginRun
void beginRun(const unsigned int nrun)
Definition: BSvsPVHistogramMaker.cc:163
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
BSvsPVHistogramMaker::book
void book(const std::string dirname="")
Definition: BSvsPVHistogramMaker.cc:39
edm::Handle< reco::BeamSpot >
edm::RunBase::run
RunNumber_t run() const
Definition: RunBase.h:40
BSvsPVAnalyzer
Definition: BSvsPVAnalyzer.cc:49
MakerMacros.h
cms::cuda::bs
bs
Definition: HistoContainer.h:127
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
BeamSpot.h
BSvsPVHistogramMaker.h
Run.h
BSvsPVAnalyzer::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: BSvsPVAnalyzer.cc:126
Vertex.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
ParameterSet
Definition: Functions.h:16
BSvsPVHistogramMaker
Definition: BSvsPVHistogramMaker.h:24
BSvsPVAnalyzer::beginJob
void beginJob() override
Definition: BSvsPVAnalyzer.cc:124
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
BSvsPVAnalyzer::_recoBeamSpotToken
edm::EDGetTokenT< reco::BeamSpot > _recoBeamSpotToken
Definition: BSvsPVAnalyzer.cc:65
InputTag.h
BSvsPVHistogramMaker::fill
void fill(const unsigned int orbit, const int bx, const reco::VertexCollection &vertices, const reco::BeamSpot &bs)
Definition: BSvsPVHistogramMaker.cc:217
VertexFwd.h
Frameworkfwd.h
TFileService::kSharedResource
static const std::string kSharedResource
Definition: TFileService.h:76
BSvsPVAnalyzer::endJob
void endJob() override
Definition: BSvsPVAnalyzer.cc:130
BSvsPVAnalyzer::_bspvhm
BSvsPVHistogramMaker _bspvhm
Definition: BSvsPVAnalyzer.cc:63
BSvsPVAnalyzer::~BSvsPVAnalyzer
~BSvsPVAnalyzer() override
Definition: BSvsPVAnalyzer.cc:92
ParameterSet.h
edm::Event
Definition: Event.h:73
BSvsPVAnalyzer::_firstOnly
bool _firstOnly
Definition: BSvsPVAnalyzer.cc:66
BSvsPVAnalyzer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: BSvsPVAnalyzer.cc:102
BSvsPVAnalyzer::_recoVertexCollectionToken
edm::EDGetTokenT< reco::VertexCollection > _recoVertexCollectionToken
Definition: BSvsPVAnalyzer.cc:64