CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/JetMETCorrections/Type1MET/src/Type1MET.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    Type1MET
00004 // Class:      Type1MET
00005 // 
00013 //
00014 // Original Author:  Oct 12 08:23
00015 //         Created:  Wed Oct 12 12:16:04 CDT 2005
00016 // $Id: Type1MET.cc,v 1.21 2010/09/15 16:01:21 lacroix Exp $
00017 //
00018 //
00019 
00020 
00021 // user include files
00022 #include "JetMETCorrections/Type1MET/interface/Type1MET.h"
00023 
00024 #include "DataFormats/Common/interface/View.h"
00025 #include "DataFormats/METReco/interface/MET.h"
00026 #include "DataFormats/METReco/interface/METCollection.h"
00027 #include "DataFormats/METReco/interface/PFMETCollection.h"
00028 #include "DataFormats/METReco/interface/CaloMET.h"
00029 #include "DataFormats/METReco/interface/CaloMETCollection.h"
00030 #include "DataFormats/JetReco/interface/CaloJet.h"
00031 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00032 #include "JetMETCorrections/Objects/interface/JetCorrector.h"
00033 #include "DataFormats/JetReco/interface/PFJetCollection.h"
00034 #include "DataFormats/PatCandidates/interface/Jet.h"
00035 
00036 #include "DataFormats/MuonReco/interface/MuonMETCorrectionData.h"
00037 
00038 
00039 using namespace reco;
00040 
00041 namespace cms 
00042 {
00043   // PRODUCER CONSTRUCTORS ------------------------------------------
00044   Type1MET::Type1MET( const edm::ParameterSet& iConfig ) : alg_() 
00045   {
00046     metType             = iConfig.getParameter<std::string>("metType");
00047     
00048     inputUncorMetLabel  = iConfig.getParameter<std::string>("inputUncorMetLabel");
00049     inputUncorJetsLabel = iConfig.getParameter<std::string>("inputUncorJetsLabel");
00050     correctorLabel   = iConfig.getParameter<std::string>("corrector");
00051     jetPTthreshold      = iConfig.getParameter<double>("jetPTthreshold");
00052     jetEMfracLimit      = iConfig.getParameter<double>("jetEMfracLimit");
00053     UscaleA      = iConfig.getParameter<double>("UscaleA");
00054     UscaleB      = iConfig.getParameter<double>("UscaleB");
00055     UscaleC      = iConfig.getParameter<double>("UscaleC");
00056     useTypeII      = iConfig.getParameter<bool>("useTypeII");
00057     hasMuonsCorr   = iConfig.getParameter<bool>("hasMuonsCorr");
00058     if( metType == "CaloMET" )
00059       produces<CaloMETCollection>();
00060     else
00061       produces<METCollection>();
00062   }
00063   Type1MET::Type1MET() : alg_() {}
00064   // PRODUCER DESTRUCTORS -------------------------------------------
00065   Type1MET::~Type1MET() {}
00066 
00067   // PRODUCER METHODS -----------------------------------------------
00068   void Type1MET::produce( edm::Event& iEvent, const edm::EventSetup& iSetup )
00069   {
00070     using namespace edm;
00071 
00072 // Remove lable from the code
00073        Handle<View<reco::Muon> > inputMuons;
00074        iEvent.getByLabel( "muons", inputMuons );
00075 // Remove lable from the code
00076        Handle<ValueMap<reco::MuonMETCorrectionData> > vm_muCorrData_h;
00077        iEvent.getByLabel( "muonMETValueMapProducer","muCorrData", vm_muCorrData_h);
00078 
00079     if( metType == "CaloMET")
00080       {
00081     Handle<CaloJetCollection> inputUncorJets;
00082     iEvent.getByLabel( inputUncorJetsLabel, inputUncorJets );
00083     const JetCorrector* corrector = JetCorrector::getJetCorrector (correctorLabel, iSetup);
00084 
00085         Handle<CaloMETCollection> inputUncorMet;                     //Define Inputs
00086         iEvent.getByLabel( inputUncorMetLabel,  inputUncorMet );     //Get Inputs
00087         std::auto_ptr<CaloMETCollection> output( new CaloMETCollection() );  //Create empty output
00088         alg_.run( *(inputUncorMet.product()), *corrector, *(inputUncorJets.product()), 
00089                   jetPTthreshold, jetEMfracLimit, UscaleA, UscaleB, UscaleC, useTypeII, hasMuonsCorr,
00090                   *(inputMuons.product()), *(vm_muCorrData_h.product()),
00091                   &*output );                                         //Invoke the algorithm
00092         iEvent.put( output );                                        //Put output into Event
00093       }
00094     else if (metType == "PFMET")
00095       {
00096       Handle<PFJetCollection> inputUncorJets;
00097       iEvent.getByLabel( inputUncorJetsLabel, inputUncorJets );
00098       const JetCorrector* corrector = JetCorrector::getJetCorrector (correctorLabel, iSetup);
00099 
00100         Handle<PFMETCollection> inputUncorMet;                     //Define Inputs
00101         iEvent.getByLabel( inputUncorMetLabel,  inputUncorMet );     //Get Inputs
00102         std::auto_ptr<METCollection> output( new METCollection() );  //Create empty output
00103         alg_.run( *(inputUncorMet.product()), *corrector, *(inputUncorJets.product()), 
00104                   jetPTthreshold, jetEMfracLimit, UscaleA, UscaleB, UscaleC, useTypeII, hasMuonsCorr,
00105                   *(inputMuons.product()), *(vm_muCorrData_h.product()),
00106                   &*output );                                         //Invoke the algorithm
00107         iEvent.put( output );                                        //Put output into Event
00108       }
00109     else
00110       {
00111         Handle<pat::JetCollection> inputUncorJets;
00112       iEvent.getByLabel( inputUncorJetsLabel, inputUncorJets );
00113       const JetCorrector* corrector = JetCorrector::getJetCorrector (correctorLabel, iSetup);
00114 
00115         Handle<PFMETCollection> inputUncorMet;                     //Define Inputs
00116         iEvent.getByLabel( inputUncorMetLabel,  inputUncorMet );     //Get Inputs
00117         std::auto_ptr<METCollection> output( new METCollection() );  //Create empty output
00118         alg_.run( *(inputUncorMet.product()), *corrector, *(inputUncorJets.product()), 
00119                   jetPTthreshold, jetEMfracLimit, UscaleA, UscaleB, UscaleC, useTypeII, hasMuonsCorr,
00120                   *(inputMuons.product()), *(vm_muCorrData_h.product()),
00121                   &*output );                                         //Invoke the algorithm
00122         iEvent.put( output );                                        //Put output into Event
00123       }
00124   }
00125 
00126   //  DEFINE_FWK_MODULE(Type1MET);  //define this as a plug-in
00127 
00128 }//end namespace cms
00129