CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/RecoMuon/MuonIsolation/plugins/MuPFIsoEmbedder.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    MuPFIsoEmbedder
00004 // Class:      MuPFIsoEmbedder
00005 // 
00013 //
00014 // Original Author:  Michail Bachtis,32 3-B16,+41227675567,
00015 //         Created:  Thu Jun  9 01:36:17 CEST 2011
00016 // $Id: MuPFIsoEmbedder.cc,v 1.1 2011/06/15 00:33:01 bachtis Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <memory>
00023 
00024 // user include files
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "FWCore/Framework/interface/EDProducer.h"
00027 
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/MakerMacros.h"
00030 
00031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00032 #include "RecoMuon/MuonIsolation/interface/MuPFIsoHelper.h"
00033 #include "DataFormats/MuonReco/interface/Muon.h"
00034 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00035 
00036 //
00037 // class declaration
00038 //
00039 
00040 class MuPFIsoEmbedder : public edm::EDProducer {
00041    public:
00042       explicit MuPFIsoEmbedder(const edm::ParameterSet&);
00043       ~MuPFIsoEmbedder();
00044 
00045       static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
00046 
00047    private:
00048       virtual void beginJob() ;
00049       virtual void produce(edm::Event&, const edm::EventSetup&);
00050       virtual void endJob() ;
00051       
00052       virtual void beginRun(edm::Run&, edm::EventSetup const&);
00053       virtual void endRun(edm::Run&, edm::EventSetup const&);
00054       virtual void beginLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&);
00055       virtual void endLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&);
00056 
00057 
00058       // ----------member data ---------------------------
00059   edm::InputTag muons_;
00060 
00061   MuPFIsoHelper *helper_;
00062 
00063 };
00064 
00065 
00066 
00067 
00068 //
00069 MuPFIsoEmbedder::MuPFIsoEmbedder(const edm::ParameterSet& iConfig):
00070   muons_(iConfig.getParameter<edm::InputTag>("src"))
00071 {
00072 
00073   helper_ = new MuPFIsoHelper(iConfig);
00074   produces<reco::MuonCollection>();
00075 }
00076 
00077 
00078 MuPFIsoEmbedder::~MuPFIsoEmbedder()
00079 {
00080  
00081    // do anything here that needs to be done at desctruction time
00082    // (e.g. close files, deallocate resources etc.)
00083 
00084 }
00085 
00086 
00087 //
00088 // member functions
00089 //
00090 
00091 // ------------ method called to produce the data  ------------
00092 void
00093 MuPFIsoEmbedder::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00094 {
00095    using namespace edm;
00096    using namespace reco;
00097 
00098 
00099    helper_->beginEvent(iEvent);
00100   
00101    edm::Handle<reco::MuonCollection > muons;
00102    iEvent.getByLabel(muons_,muons);
00103 
00104 
00105    std::auto_ptr<MuonCollection> out(new MuonCollection);
00106 
00107    for(unsigned int i=0;i<muons->size();++i) {
00108      MuonRef muonRef(muons,i);
00109      Muon muon = muons->at(i);
00110      helper_->embedPFIsolation(muon,muonRef);
00111      out->push_back(muon);
00112    }
00113 
00114    iEvent.put(out);
00115 }
00116 
00117 // ------------ method called once each job just before starting event loop  ------------
00118 void 
00119 MuPFIsoEmbedder::beginJob()
00120 {
00121 }
00122 
00123 // ------------ method called once each job just after ending the event loop  ------------
00124 void 
00125 MuPFIsoEmbedder::endJob() {
00126 }
00127 
00128 // ------------ method called when starting to processes a run  ------------
00129 void 
00130 MuPFIsoEmbedder::beginRun(edm::Run&, edm::EventSetup const&)
00131 {
00132 }
00133 
00134 // ------------ method called when ending the processing of a run  ------------
00135 void 
00136 MuPFIsoEmbedder::endRun(edm::Run&, edm::EventSetup const&)
00137 {
00138 }
00139 
00140 // ------------ method called when starting to processes a luminosity block  ------------
00141 void 
00142 MuPFIsoEmbedder::beginLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&)
00143 {
00144 }
00145 
00146 // ------------ method called when ending the processing of a luminosity block  ------------
00147 void 
00148 MuPFIsoEmbedder::endLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&)
00149 {
00150 }
00151 
00152 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
00153 void
00154 MuPFIsoEmbedder::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
00155   //The following says we do not know what parameters are allowed so do no validation
00156   // Please change this to state exactly what you do use, even if it is no parameters
00157   edm::ParameterSetDescription desc;
00158   desc.setUnknown();
00159   descriptions.addDefault(desc);
00160 }
00161 
00162 //define this as a plug-in
00163 DEFINE_FWK_MODULE(MuPFIsoEmbedder);