Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-08 08:16:02

0001 // -*- C++ -*-
0002 //
0003 // Package:    MultiplicityInvestigator
0004 // Class:      MultiplicityInvestigator
0005 //
0006 /**\class MultiplicityInvestigator MultiplicityInvestigator.cc myTKAnalyses/DigiInvestigator/src/MultiplicityInvestigator.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Andrea Venturi
0015 //         Created:  Mon Oct 27 17:37:53 CET 2008
0016 // $Id: MultiplicityInvestigator.cc,v 1.5 2012/02/15 11:13:25 venturia Exp $
0017 //
0018 //
0019 
0020 // system include files
0021 #include <memory>
0022 
0023 // user include files
0024 
0025 #include <vector>
0026 #include <map>
0027 #include <limits>
0028 
0029 #include "FWCore/Framework/interface/Frameworkfwd.h"
0030 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0031 #include "FWCore/Framework/interface/Event.h"
0032 #include "FWCore/Framework/interface/Run.h"
0033 #include "FWCore/Framework/interface/MakerMacros.h"
0034 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0035 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0036 #include "FWCore/Utilities/interface/InputTag.h"
0037 
0038 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0039 #include "DataFormats/VertexReco/interface/Vertex.h"
0040 
0041 #include "DPGAnalysis/SiStripTools/interface/DigiInvestigatorHistogramMaker.h"
0042 #include "DPGAnalysis/SiStripTools/interface/DigiVertexCorrHistogramMaker.h"
0043 #include "DPGAnalysis/SiStripTools/interface/DigiLumiCorrHistogramMaker.h"
0044 #include "DPGAnalysis/SiStripTools/interface/DigiPileupCorrHistogramMaker.h"
0045 #include "DPGAnalysis/SiStripTools/interface/DigiVtxPosCorrHistogramMaker.h"
0046 
0047 //
0048 // class decleration
0049 //
0050 
0051 class MultiplicityInvestigator : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
0052 public:
0053   explicit MultiplicityInvestigator(const edm::ParameterSet&);
0054   ~MultiplicityInvestigator() override;
0055 
0056 private:
0057   void beginJob() override;
0058   void analyze(const edm::Event&, const edm::EventSetup&) override;
0059   void beginRun(const edm::Run&, const edm::EventSetup&) override;
0060   void endRun(const edm::Run&, const edm::EventSetup&) override {}
0061   void endJob() override;
0062 
0063   // ----------member data ---------------------------
0064 
0065   const bool m_wantInvestHist;
0066   const bool m_wantVtxCorrHist;
0067   const bool m_wantLumiCorrHist;
0068   const bool m_wantPileupCorrHist;
0069   const bool m_wantVtxPosCorrHist;
0070   DigiInvestigatorHistogramMaker m_digiinvesthmevent;
0071   DigiVertexCorrHistogramMaker m_digivtxcorrhmevent;
0072   DigiLumiCorrHistogramMaker m_digilumicorrhmevent;
0073   DigiPileupCorrHistogramMaker m_digipileupcorrhmevent;
0074   DigiVtxPosCorrHistogramMaker m_digivtxposcorrhmevent;
0075 
0076   edm::EDGetTokenT<std::map<unsigned int, int> > m_multiplicityMapToken;
0077   edm::EDGetTokenT<reco::VertexCollection> m_vertexCollectionToken;
0078 };
0079 
0080 //
0081 // constants, enums and typedefs
0082 //
0083 
0084 //
0085 // static data member definitions
0086 //
0087 
0088 //
0089 // constructors and destructor
0090 //
0091 MultiplicityInvestigator::MultiplicityInvestigator(const edm::ParameterSet& iConfig)
0092     :  //  m_digiinvesthmevent(iConfig.getParameter<edm::ParameterSet>("digiInvestConfig")),
0093       m_wantInvestHist(iConfig.getParameter<bool>("wantInvestHist")),
0094       m_wantVtxCorrHist(iConfig.getParameter<bool>("wantVtxCorrHist")),
0095       m_wantLumiCorrHist(iConfig.getParameter<bool>("wantLumiCorrHist")),
0096       m_wantPileupCorrHist(iConfig.getParameter<bool>("wantPileupCorrHist")),
0097       m_wantVtxPosCorrHist(iConfig.getParameter<bool>("wantVtxPosCorrHist")),
0098       m_digiinvesthmevent(m_wantInvestHist ? DigiInvestigatorHistogramMaker(iConfig, consumesCollector())
0099                                            : DigiInvestigatorHistogramMaker(consumesCollector())),
0100       m_digivtxcorrhmevent(m_wantVtxCorrHist ? iConfig.getParameter<edm::ParameterSet>("digiVtxCorrConfig")
0101                                              : DigiVertexCorrHistogramMaker()),
0102       m_digilumicorrhmevent(
0103           m_wantLumiCorrHist ? DigiLumiCorrHistogramMaker(iConfig.getParameter<edm::ParameterSet>("digiLumiCorrConfig"),
0104                                                           consumesCollector())
0105                              : DigiLumiCorrHistogramMaker(consumesCollector())),
0106       m_digipileupcorrhmevent(
0107           m_wantPileupCorrHist
0108               ? DigiPileupCorrHistogramMaker(iConfig.getParameter<edm::ParameterSet>("digiPileupCorrConfig"),
0109                                              consumesCollector())
0110               : DigiPileupCorrHistogramMaker(consumesCollector())),
0111       m_digivtxposcorrhmevent(
0112           m_wantVtxPosCorrHist
0113               ? DigiVtxPosCorrHistogramMaker(iConfig.getParameter<edm::ParameterSet>("digiVtxPosCorrConfig"),
0114                                              consumesCollector())
0115               : DigiVtxPosCorrHistogramMaker(consumesCollector())),
0116       m_multiplicityMapToken(
0117           consumes<std::map<unsigned int, int> >(iConfig.getParameter<edm::InputTag>("multiplicityMap"))),
0118       m_vertexCollectionToken(
0119           mayConsume<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexCollection"))) {
0120   //now do what ever initialization is needed
0121 
0122   if (m_wantInvestHist) {
0123     m_digiinvesthmevent.book("EventProcs");
0124   }
0125   if (m_wantVtxCorrHist) {
0126     m_digivtxcorrhmevent.book("VtxCorr", consumesCollector());
0127   }
0128   if (m_wantLumiCorrHist) {
0129     m_digilumicorrhmevent.book("LumiCorr", consumesCollector());
0130   }
0131   if (m_wantPileupCorrHist) {
0132     m_digipileupcorrhmevent.book("PileupCorr");
0133   }
0134   if (m_wantVtxPosCorrHist) {
0135     m_digivtxposcorrhmevent.book("VtxPosCorr");
0136   }
0137 }
0138 
0139 MultiplicityInvestigator::~MultiplicityInvestigator() {
0140   // do anything here that needs to be done at desctruction time
0141   // (e.g. close files, deallocate resources etc.)
0142 }
0143 
0144 //
0145 // member functions
0146 //
0147 
0148 // ------------ method called to for each event  ------------
0149 void MultiplicityInvestigator::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0150   using namespace edm;
0151 
0152   Handle<std::map<unsigned int, int> > mults;
0153   iEvent.getByToken(m_multiplicityMapToken, mults);
0154 
0155   if (m_wantInvestHist)
0156     m_digiinvesthmevent.fill(iEvent, *mults);
0157   if (m_wantVtxCorrHist) {
0158     Handle<reco::VertexCollection> vertices;
0159     iEvent.getByToken(m_vertexCollectionToken, vertices);
0160 
0161     m_digivtxcorrhmevent.fill(iEvent, vertices->size(), *mults);
0162   }
0163 
0164   if (m_wantLumiCorrHist)
0165     m_digilumicorrhmevent.fill(iEvent, *mults);
0166   if (m_wantPileupCorrHist)
0167     m_digipileupcorrhmevent.fill(iEvent, *mults);
0168   if (m_wantVtxPosCorrHist)
0169     m_digivtxposcorrhmevent.fill(iEvent, *mults);
0170 }
0171 
0172 // ------------ method called once each job just before starting event loop  ------------
0173 void MultiplicityInvestigator::beginJob() {}
0174 
0175 void MultiplicityInvestigator::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
0176   m_digiinvesthmevent.beginRun(iRun);
0177   m_digivtxcorrhmevent.beginRun(iRun);
0178   m_digilumicorrhmevent.beginRun(iRun);
0179 }
0180 // ------------ method called once each job just after ending the event loop  ------------
0181 void MultiplicityInvestigator::endJob() {}
0182 //define this as a plug-in
0183 DEFINE_FWK_MODULE(MultiplicityInvestigator);