00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
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
00065 Type1MET::~Type1MET() {}
00066
00067
00068 void Type1MET::produce( edm::Event& iEvent, const edm::EventSetup& iSetup )
00069 {
00070 using namespace edm;
00071
00072
00073 Handle<View<reco::Muon> > inputMuons;
00074 iEvent.getByLabel( "muons", inputMuons );
00075
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;
00086 iEvent.getByLabel( inputUncorMetLabel, inputUncorMet );
00087 std::auto_ptr<CaloMETCollection> output( new CaloMETCollection() );
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 );
00092 iEvent.put( output );
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;
00101 iEvent.getByLabel( inputUncorMetLabel, inputUncorMet );
00102 std::auto_ptr<METCollection> output( new METCollection() );
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 );
00107 iEvent.put( output );
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;
00116 iEvent.getByLabel( inputUncorMetLabel, inputUncorMet );
00117 std::auto_ptr<METCollection> output( new METCollection() );
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 );
00122 iEvent.put( output );
00123 }
00124 }
00125
00126
00127
00128 }
00129