CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MultiplicityInvestigator.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: MultiplicityInvestigator
4 // Class: MultiplicityInvestigator
5 //
13 //
14 // Original Author: Andrea Venturi
15 // Created: Mon Oct 27 17:37:53 CET 2008
16 // $Id: MultiplicityInvestigator.cc,v 1.5 2012/02/15 11:13:25 venturia Exp $
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 
37 
40 
46 
47 //
48 // class decleration
49 //
50 
52 public:
54  ~MultiplicityInvestigator() override;
55 
56 private:
57  void beginJob() override;
58  void analyze(const edm::Event&, const edm::EventSetup&) override;
59  void beginRun(const edm::Run&, const edm::EventSetup&) override;
60  void endJob() override;
61 
62  // ----------member data ---------------------------
63 
64  const bool m_wantInvestHist;
65  const bool m_wantVtxCorrHist;
66  const bool m_wantLumiCorrHist;
74 
77 };
78 
79 //
80 // constants, enums and typedefs
81 //
82 
83 //
84 // static data member definitions
85 //
86 
87 //
88 // constructors and destructor
89 //
91  : // m_digiinvesthmevent(iConfig.getParameter<edm::ParameterSet>("digiInvestConfig")),
92  m_wantInvestHist(iConfig.getParameter<bool>("wantInvestHist")),
93  m_wantVtxCorrHist(iConfig.getParameter<bool>("wantVtxCorrHist")),
94  m_wantLumiCorrHist(iConfig.getParameter<bool>("wantLumiCorrHist")),
95  m_wantPileupCorrHist(iConfig.getParameter<bool>("wantPileupCorrHist")),
96  m_wantVtxPosCorrHist(iConfig.getParameter<bool>("wantVtxPosCorrHist")),
97  m_digiinvesthmevent(m_wantInvestHist ? DigiInvestigatorHistogramMaker(iConfig, consumesCollector())
98  : DigiInvestigatorHistogramMaker(consumesCollector())),
99  m_digivtxcorrhmevent(m_wantVtxCorrHist ? iConfig.getParameter<edm::ParameterSet>("digiVtxCorrConfig")
101  m_digilumicorrhmevent(
102  m_wantLumiCorrHist ? DigiLumiCorrHistogramMaker(iConfig.getParameter<edm::ParameterSet>("digiLumiCorrConfig"),
103  consumesCollector())
104  : DigiLumiCorrHistogramMaker(consumesCollector())),
105  m_digipileupcorrhmevent(
106  m_wantPileupCorrHist
107  ? DigiPileupCorrHistogramMaker(iConfig.getParameter<edm::ParameterSet>("digiPileupCorrConfig"),
108  consumesCollector())
109  : DigiPileupCorrHistogramMaker(consumesCollector())),
110  m_digivtxposcorrhmevent(
111  m_wantVtxPosCorrHist
112  ? DigiVtxPosCorrHistogramMaker(iConfig.getParameter<edm::ParameterSet>("digiVtxPosCorrConfig"),
113  consumesCollector())
114  : DigiVtxPosCorrHistogramMaker(consumesCollector())),
115  m_multiplicityMapToken(
116  consumes<std::map<unsigned int, int> >(iConfig.getParameter<edm::InputTag>("multiplicityMap"))),
117  m_vertexCollectionToken(
118  mayConsume<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexCollection"))) {
119  //now do what ever initialization is needed
120 
121  if (m_wantInvestHist) {
122  m_digiinvesthmevent.book("EventProcs");
123  }
124  if (m_wantVtxCorrHist) {
126  }
127  if (m_wantLumiCorrHist) {
129  }
130  if (m_wantPileupCorrHist) {
131  m_digipileupcorrhmevent.book("PileupCorr");
132  }
133  if (m_wantVtxPosCorrHist) {
134  m_digivtxposcorrhmevent.book("VtxPosCorr");
135  }
136 }
137 
139  // do anything here that needs to be done at desctruction time
140  // (e.g. close files, deallocate resources etc.)
141 }
142 
143 //
144 // member functions
145 //
146 
147 // ------------ method called to for each event ------------
149  using namespace edm;
150 
152  iEvent.getByToken(m_multiplicityMapToken, mults);
153 
154  if (m_wantInvestHist)
155  m_digiinvesthmevent.fill(iEvent, *mults);
156  if (m_wantVtxCorrHist) {
158  iEvent.getByToken(m_vertexCollectionToken, vertices);
159 
160  m_digivtxcorrhmevent.fill(iEvent, vertices->size(), *mults);
161  }
162 
163  if (m_wantLumiCorrHist)
164  m_digilumicorrhmevent.fill(iEvent, *mults);
166  m_digipileupcorrhmevent.fill(iEvent, *mults);
168  m_digivtxposcorrhmevent.fill(iEvent, *mults);
169 }
170 
171 // ------------ method called once each job just before starting event loop ------------
173 
178 }
179 // ------------ method called once each job just after ending the event loop ------------
181 //define this as a plug-in
void book(const std::string dirname, const std::map< unsigned int, std::string > &labels)
DigiPileupCorrHistogramMaker m_digipileupcorrhmevent
void book(const std::string dirname, const std::map< unsigned int, std::string > &labels, edm::ConsumesCollector &&iC)
edm::EDGetTokenT< reco::VertexCollection > m_vertexCollectionToken
void fill(const edm::Event &iEvent, const std::map< unsigned int, int > &ndigi)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void book(const std::string dirname, const std::map< unsigned int, std::string > &labels)
std::vector< Vertex > VertexCollection
Definition: Vertex.h:12
DigiVtxPosCorrHistogramMaker m_digivtxposcorrhmevent
void fill(const edm::Event &iEvent, const std::map< unsigned int, int > &ndigi)
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< std::map< unsigned int, int > > m_multiplicityMapToken
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void fill(const edm::Event &iEvent, const std::map< unsigned int, int > &ndigi)
void analyze(const edm::Event &, const edm::EventSetup &) override
void book(const std::string dirname, const std::map< unsigned int, std::string > &labels, edm::ConsumesCollector &&iC)
void beginRun(const edm::Run &, const edm::EventSetup &) override
void fill(const edm::Event &iEvent, const std::map< unsigned int, int > &ndigi)
void fill(const edm::Event &iEvent, const unsigned int nvtx, const std::map< unsigned int, int > &ndigi)
DigiLumiCorrHistogramMaker m_digilumicorrhmevent
MultiplicityInvestigator(const edm::ParameterSet &)
DigiVertexCorrHistogramMaker m_digivtxcorrhmevent
void book(const std::string dirname, const std::map< unsigned int, std::string > &labels)
DigiInvestigatorHistogramMaker m_digiinvesthmevent
Definition: Run.h:45
void beginRun(const edm::Run &iRun)