CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/RecoMET/METProducers/src/MuonMET.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    MuonMET
00004 // Class:      MuonMET
00005 // 
00013 //
00014 // Created:  Wed Aug 29 2007
00015 //
00016 //
00017 
00018 
00019 // system include files
00020 #include <memory>
00021 
00022 #include <string.h>
00023 
00024 // user include files
00025 #include "RecoMET/METProducers/interface/MuonMET.h"
00026 
00027 #include "DataFormats/Common/interface/View.h"
00028 #include "DataFormats/METReco/interface/MET.h"
00029 #include "DataFormats/METReco/interface/METCollection.h"
00030 #include "DataFormats/METReco/interface/CaloMET.h"
00031 #include "DataFormats/METReco/interface/CaloMETCollection.h"
00032 #include "DataFormats/JetReco/interface/CaloJet.h"
00033 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00034 #include "DataFormats/RecoCandidate/interface/IsoDeposit.h"
00035 #include "DataFormats/RecoCandidate/interface/IsoDepositFwd.h"
00036 
00037 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00038 
00039 #include "DataFormats/MuonReco/interface/MuonMETCorrectionData.h"
00040 #include "FWCore/Framework/interface/MakerMacros.h"
00041 
00042 //using namespace std;
00043 
00044 namespace cms 
00045 {
00046   // PRODUCER CONSTRUCTORS ------------------------------------------
00047   MuonMET::MuonMET( const edm::ParameterSet& iConfig ) : alg_() 
00048   {
00049     metTypeInputTag_             = iConfig.getParameter<edm::InputTag>("metTypeInputTag");
00050     uncorMETInputTag_            = iConfig.getParameter<edm::InputTag>("uncorMETInputTag");
00051     muonsInputTag_               = iConfig.getParameter<edm::InputTag>("muonsInputTag");
00052     muonDepValueMap_             = iConfig.getParameter<edm::InputTag>("muonMETDepositValueMapInputTag");
00053 
00054     if( metTypeInputTag_.label() == "CaloMET" ) {
00055       produces<reco::CaloMETCollection>();
00056     } else 
00057       produces<reco::METCollection>();
00058     
00059   }
00060   MuonMET::MuonMET() : alg_() {}
00061   // PRODUCER DESTRUCTORS -------------------------------------------
00062   MuonMET::~MuonMET() {}
00063 
00064   // PRODUCER METHODS -----------------------------------------------
00065   void MuonMET::produce( edm::Event& iEvent, const edm::EventSetup& iSetup )
00066   {
00067     using namespace edm;
00068     
00069     //get the muons
00070     Handle<View<reco::Muon> > inputMuons;
00071     iEvent.getByLabel( muonsInputTag_, inputMuons );
00072 
00073     Handle<ValueMap<reco::MuonMETCorrectionData> > vm_muCorrData_h;
00074     
00075     iEvent.getByLabel( muonDepValueMap_, vm_muCorrData_h);
00076     
00077     if( metTypeInputTag_.label() == "CaloMET")
00078       {
00079         Handle<View<reco::CaloMET> > inputUncorMet;
00080         iEvent.getByLabel( uncorMETInputTag_, inputUncorMet  );     //Get Inputs
00081         std::auto_ptr<reco::CaloMETCollection> output( new reco::CaloMETCollection() );  //Create empty output
00082         
00083         alg_.run(*(inputMuons.product()), *(vm_muCorrData_h.product()),
00084                  *(inputUncorMet.product()), &*output);
00085         
00086         iEvent.put(output);                                        //Put output into Event
00087       }
00088     else
00089       {
00090         Handle<View<reco::MET> > inputUncorMet;                     //Define Inputs
00091         iEvent.getByLabel( uncorMETInputTag_,  inputUncorMet );     //Get Inputs
00092         std::auto_ptr<reco::METCollection> output( new reco::METCollection() );  //Create empty output
00093         
00094 
00095         alg_.run(*(inputMuons.product()), *(vm_muCorrData_h.product()),*(inputUncorMet.product()), &*output);
00096         iEvent.put(output);                                        //Put output into Event
00097       }
00098   }
00099 }//end namespace cms
00100 
00101 
00102