CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/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.1 2011/03/10 16:15:13 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 
00045 //
00046 // class decleration
00047 //
00048 
00049 class MultiplicityInvestigator : public edm::EDAnalyzer {
00050    public:
00051       explicit MultiplicityInvestigator(const edm::ParameterSet&);
00052       ~MultiplicityInvestigator();
00053 
00054 
00055 private:
00056   virtual void beginJob() ;
00057   virtual void analyze(const edm::Event&, const edm::EventSetup&);
00058   virtual void beginRun(const edm::Run&, const edm::EventSetup&);
00059   virtual void endRun(const edm::Run&, const edm::EventSetup&);
00060   virtual void endJob() ;
00061 
00062       // ----------member data ---------------------------
00063 
00064   const bool _wantVtxCorrHist;
00065   DigiInvestigatorHistogramMaker _digiinvesthmevent;
00066   DigiVertexCorrHistogramMaker _digivtxcorrhmevent;
00067 
00068   edm::InputTag _multiplicityMap;
00069   edm::InputTag _vertexCollection;
00070 
00071 };
00072 
00073 //
00074 // constants, enums and typedefs
00075 //
00076 
00077 //
00078 // static data member definitions
00079 //
00080 
00081 //
00082 // constructors and destructor
00083 //
00084 MultiplicityInvestigator::MultiplicityInvestigator(const edm::ParameterSet& iConfig):
00085   //  _digiinvesthmevent(iConfig.getParameter<edm::ParameterSet>("digiInvestConfig")),  
00086   _wantVtxCorrHist(iConfig.getParameter<bool>("wantVtxCorrHist")),
00087   _digiinvesthmevent(iConfig),
00088   _digivtxcorrhmevent(iConfig.getParameter<edm::ParameterSet>("digiVtxCorrConfig")),
00089   _multiplicityMap(iConfig.getParameter<edm::InputTag>("multiplicityMap")),
00090   _vertexCollection(iConfig.getParameter<edm::InputTag>("vertexCollection"))
00091 {
00092    //now do what ever initialization is needed
00093 
00094 
00095   _digiinvesthmevent.book("EventProcs");
00096   if(_wantVtxCorrHist) _digivtxcorrhmevent.book("VtxCorr");
00097 
00098 }
00099 
00100 
00101 MultiplicityInvestigator::~MultiplicityInvestigator()
00102 {
00103  
00104    // do anything here that needs to be done at desctruction time
00105    // (e.g. close files, deallocate resources etc.)
00106 
00107 }
00108 
00109 
00110 //
00111 // member functions
00112 //
00113 
00114 // ------------ method called to for each event  ------------
00115 void
00116 MultiplicityInvestigator::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00117 {
00118   using namespace edm;
00119   
00120   Handle<std::map<unsigned int, int> > mults;
00121   iEvent.getByLabel(_multiplicityMap,mults);
00122   
00123   _digiinvesthmevent.fill(iEvent.orbitNumber(),*mults);
00124   
00125   if(_wantVtxCorrHist) {
00126     Handle<reco::VertexCollection> vertices;
00127     iEvent.getByLabel(_vertexCollection,vertices);
00128 
00129     _digivtxcorrhmevent.fill(vertices->size(),*mults);
00130   }
00131 
00132 }
00133 
00134 
00135 // ------------ method called once each job just before starting event loop  ------------
00136 void 
00137 MultiplicityInvestigator::beginJob()
00138 {
00139 
00140 }
00141 
00142 void
00143 MultiplicityInvestigator::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
00144 
00145   _digiinvesthmevent.beginRun(iRun.run());
00146 
00147 }
00148 
00149 void
00150 MultiplicityInvestigator::endRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
00151 }
00152 // ------------ method called once each job just after ending the event loop  ------------
00153 void 
00154 MultiplicityInvestigator::endJob() {
00155 }
00156 //define this as a plug-in
00157 DEFINE_FWK_MODULE(MultiplicityInvestigator);