CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/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.5 2012/02/15 11:13:25 venturia 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&);
00060   virtual void beginRun(const edm::Run&, const edm::EventSetup&);
00061   virtual void endRun(const edm::Run&, const edm::EventSetup&);
00062   virtual void endJob() ;
00063 
00064       // ----------member data ---------------------------
00065 
00066   const bool m_wantInvestHist;
00067   const bool m_wantVtxCorrHist;
00068   const bool m_wantLumiCorrHist;
00069   const bool m_wantPileupCorrHist;
00070   DigiInvestigatorHistogramMaker m_digiinvesthmevent;
00071   DigiVertexCorrHistogramMaker m_digivtxcorrhmevent;
00072   DigiLumiCorrHistogramMaker m_digilumicorrhmevent;
00073   DigiPileupCorrHistogramMaker m_digipileupcorrhmevent;
00074 
00075   edm::InputTag m_multiplicityMap;
00076   edm::InputTag m_vertexCollection;
00077 
00078 };
00079 
00080 //
00081 // constants, enums and typedefs
00082 //
00083 
00084 //
00085 // static data member definitions
00086 //
00087 
00088 //
00089 // constructors and destructor
00090 //
00091 MultiplicityInvestigator::MultiplicityInvestigator(const edm::ParameterSet& iConfig):
00092   //  m_digiinvesthmevent(iConfig.getParameter<edm::ParameterSet>("digiInvestConfig")),  
00093   m_wantInvestHist(iConfig.getParameter<bool>("wantInvestHist")),
00094   m_wantVtxCorrHist(iConfig.getParameter<bool>("wantVtxCorrHist")),
00095   m_wantLumiCorrHist(iConfig.getParameter<bool>("wantLumiCorrHist")),
00096   m_wantPileupCorrHist(iConfig.getParameter<bool>("wantPileupCorrHist")),
00097   m_digiinvesthmevent(iConfig),
00098   m_digivtxcorrhmevent(iConfig.getParameter<edm::ParameterSet>("digiVtxCorrConfig")),
00099   m_digilumicorrhmevent(iConfig.getParameter<edm::ParameterSet>("digiLumiCorrConfig")),
00100   m_digipileupcorrhmevent(iConfig.getParameter<edm::ParameterSet>("digiPileupCorrConfig")),
00101   m_multiplicityMap(iConfig.getParameter<edm::InputTag>("multiplicityMap")),
00102   m_vertexCollection(iConfig.getParameter<edm::InputTag>("vertexCollection"))
00103 {
00104    //now do what ever initialization is needed
00105 
00106 
00107   if(m_wantInvestHist)  m_digiinvesthmevent.book("EventProcs");
00108   if(m_wantVtxCorrHist) m_digivtxcorrhmevent.book("VtxCorr");
00109   if(m_wantLumiCorrHist) m_digilumicorrhmevent.book("LumiCorr");
00110   if(m_wantPileupCorrHist) m_digipileupcorrhmevent.book("PileupCorr");
00111 
00112 }
00113 
00114 
00115 MultiplicityInvestigator::~MultiplicityInvestigator()
00116 {
00117  
00118    // do anything here that needs to be done at desctruction time
00119    // (e.g. close files, deallocate resources etc.)
00120 
00121 }
00122 
00123 
00124 //
00125 // member functions
00126 //
00127 
00128 // ------------ method called to for each event  ------------
00129 void
00130 MultiplicityInvestigator::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00131 {
00132   using namespace edm;
00133   
00134   Handle<std::map<unsigned int, int> > mults;
00135   iEvent.getByLabel(m_multiplicityMap,mults);
00136   
00137   if(m_wantInvestHist) m_digiinvesthmevent.fill(iEvent.orbitNumber(),*mults);
00138   
00139   if(m_wantVtxCorrHist) {
00140     Handle<reco::VertexCollection> vertices;
00141     iEvent.getByLabel(m_vertexCollection,vertices);
00142 
00143     m_digivtxcorrhmevent.fill(iEvent,vertices->size(),*mults);
00144   }
00145 
00146   if(m_wantLumiCorrHist) m_digilumicorrhmevent.fill(iEvent,*mults);
00147   if(m_wantPileupCorrHist) m_digipileupcorrhmevent.fill(iEvent,*mults);
00148 
00149 }
00150 
00151 
00152 // ------------ method called once each job just before starting event loop  ------------
00153 void 
00154 MultiplicityInvestigator::beginJob()
00155 {
00156 
00157 }
00158 
00159 void
00160 MultiplicityInvestigator::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
00161 
00162   m_digiinvesthmevent.beginRun(iRun.run());
00163   m_digivtxcorrhmevent.beginRun(iRun);
00164   m_digilumicorrhmevent.beginRun(iRun);
00165 
00166 }
00167 
00168 void
00169 MultiplicityInvestigator::endRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
00170 }
00171 // ------------ method called once each job just after ending the event loop  ------------
00172 void 
00173 MultiplicityInvestigator::endJob() {
00174 }
00175 //define this as a plug-in
00176 DEFINE_FWK_MODULE(MultiplicityInvestigator);