CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/DPGAnalysis/SiStripTools/plugins/MultiplicityInvestigator.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    MultiplicityInvestigator
00004 // Class:      MultiplicityInvestigator
00005 // 
00013 //
00014 // Original Author:  Andrea Venturi
00015 //         Created:  Mon Oct 27 17:37:53 CET 2008
00016 // $Id: MultiplicityInvestigator.cc,v 1.6 2013/02/27 19:49:46 wmtan Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <memory>
00023 
00024 // user include files
00025 
00026 #include <vector>
00027 #include <map>
00028 #include <limits>
00029 
00030 #include "FWCore/Framework/interface/Frameworkfwd.h"
00031 #include "FWCore/Framework/interface/EDAnalyzer.h"
00032 #include "FWCore/Framework/interface/Event.h"
00033 #include "FWCore/Framework/interface/Run.h"
00034 #include "FWCore/Framework/interface/MakerMacros.h"
00035 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00036 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00037 #include "FWCore/Utilities/interface/InputTag.h"
00038 
00039 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00040 #include "DataFormats/VertexReco/interface/Vertex.h"
00041 
00042 #include "DPGAnalysis/SiStripTools/interface/DigiInvestigatorHistogramMaker.h"
00043 #include "DPGAnalysis/SiStripTools/interface/DigiVertexCorrHistogramMaker.h"
00044 #include "DPGAnalysis/SiStripTools/interface/DigiLumiCorrHistogramMaker.h"
00045 #include "DPGAnalysis/SiStripTools/interface/DigiPileupCorrHistogramMaker.h"
00046 
00047 //
00048 // class decleration
00049 //
00050 
00051 class MultiplicityInvestigator : public edm::EDAnalyzer {
00052    public:
00053       explicit MultiplicityInvestigator(const edm::ParameterSet&);
00054       ~MultiplicityInvestigator();
00055 
00056 
00057 private:
00058   virtual void beginJob() ;
00059   virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
00060   virtual void beginRun(const edm::Run&, const edm::EventSetup&) override;
00061   virtual void endJob() ;
00062 
00063       // ----------member data ---------------------------
00064 
00065   const bool m_wantInvestHist;
00066   const bool m_wantVtxCorrHist;
00067   const bool m_wantLumiCorrHist;
00068   const bool m_wantPileupCorrHist;
00069   DigiInvestigatorHistogramMaker m_digiinvesthmevent;
00070   DigiVertexCorrHistogramMaker m_digivtxcorrhmevent;
00071   DigiLumiCorrHistogramMaker m_digilumicorrhmevent;
00072   DigiPileupCorrHistogramMaker m_digipileupcorrhmevent;
00073 
00074   edm::InputTag m_multiplicityMap;
00075   edm::InputTag m_vertexCollection;
00076 
00077 };
00078 
00079 //
00080 // constants, enums and typedefs
00081 //
00082 
00083 //
00084 // static data member definitions
00085 //
00086 
00087 //
00088 // constructors and destructor
00089 //
00090 MultiplicityInvestigator::MultiplicityInvestigator(const edm::ParameterSet& iConfig):
00091   //  m_digiinvesthmevent(iConfig.getParameter<edm::ParameterSet>("digiInvestConfig")),  
00092   m_wantInvestHist(iConfig.getParameter<bool>("wantInvestHist")),
00093   m_wantVtxCorrHist(iConfig.getParameter<bool>("wantVtxCorrHist")),
00094   m_wantLumiCorrHist(iConfig.getParameter<bool>("wantLumiCorrHist")),
00095   m_wantPileupCorrHist(iConfig.getParameter<bool>("wantPileupCorrHist")),
00096   m_digiinvesthmevent(iConfig),
00097   m_digivtxcorrhmevent(iConfig.getParameter<edm::ParameterSet>("digiVtxCorrConfig")),
00098   m_digilumicorrhmevent(iConfig.getParameter<edm::ParameterSet>("digiLumiCorrConfig")),
00099   m_digipileupcorrhmevent(iConfig.getParameter<edm::ParameterSet>("digiPileupCorrConfig")),
00100   m_multiplicityMap(iConfig.getParameter<edm::InputTag>("multiplicityMap")),
00101   m_vertexCollection(iConfig.getParameter<edm::InputTag>("vertexCollection"))
00102 {
00103    //now do what ever initialization is needed
00104 
00105 
00106   if(m_wantInvestHist)  m_digiinvesthmevent.book("EventProcs");
00107   if(m_wantVtxCorrHist) m_digivtxcorrhmevent.book("VtxCorr");
00108   if(m_wantLumiCorrHist) m_digilumicorrhmevent.book("LumiCorr");
00109   if(m_wantPileupCorrHist) m_digipileupcorrhmevent.book("PileupCorr");
00110 
00111 }
00112 
00113 
00114 MultiplicityInvestigator::~MultiplicityInvestigator()
00115 {
00116  
00117    // do anything here that needs to be done at desctruction time
00118    // (e.g. close files, deallocate resources etc.)
00119 
00120 }
00121 
00122 
00123 //
00124 // member functions
00125 //
00126 
00127 // ------------ method called to for each event  ------------
00128 void
00129 MultiplicityInvestigator::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00130 {
00131   using namespace edm;
00132   
00133   Handle<std::map<unsigned int, int> > mults;
00134   iEvent.getByLabel(m_multiplicityMap,mults);
00135   
00136   if(m_wantInvestHist) m_digiinvesthmevent.fill(iEvent.orbitNumber(),*mults);
00137   
00138   if(m_wantVtxCorrHist) {
00139     Handle<reco::VertexCollection> vertices;
00140     iEvent.getByLabel(m_vertexCollection,vertices);
00141 
00142     m_digivtxcorrhmevent.fill(iEvent,vertices->size(),*mults);
00143   }
00144 
00145   if(m_wantLumiCorrHist) m_digilumicorrhmevent.fill(iEvent,*mults);
00146   if(m_wantPileupCorrHist) m_digipileupcorrhmevent.fill(iEvent,*mults);
00147 
00148 }
00149 
00150 
00151 // ------------ method called once each job just before starting event loop  ------------
00152 void 
00153 MultiplicityInvestigator::beginJob()
00154 {
00155 
00156 }
00157 
00158 void
00159 MultiplicityInvestigator::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
00160 
00161   m_digiinvesthmevent.beginRun(iRun.run());
00162   m_digivtxcorrhmevent.beginRun(iRun);
00163   m_digilumicorrhmevent.beginRun(iRun);
00164 
00165 }
00166 // ------------ method called once each job just after ending the event loop  ------------
00167 void 
00168 MultiplicityInvestigator::endJob() {
00169 }
00170 //define this as a plug-in
00171 DEFINE_FWK_MODULE(MultiplicityInvestigator);