Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:21:38

0001 //
0002 // Original Author:  Fedor Ratnikov Dec 27, 2006
0003 //
0004 // Generic interface for JetCorrection services
0005 //
0006 
0007 #include "JetMETCorrections/Objects/interface/JetCorrector.h"
0008 
0009 #include "FWCore/Framework/interface/EventSetup.h"
0010 #include "JetMETCorrections/Objects/interface/JetCorrectionsRecord.h"
0011 #include "FWCore/Framework/interface/ESHandle.h"
0012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0013 
0014 double JetCorrector::correction(const reco::Jet& fJet, const edm::Event& fEvent, const edm::EventSetup& fSetup) const {
0015   if (eventRequired() && !refRequired()) {
0016     edm::LogError("Missing Jet Correction Method")
0017         << "Undefined Jet Correction method requiring event data is called" << std::endl;
0018     return 0;
0019   }
0020   return correction(fJet);
0021 }
0022 
0023 double JetCorrector::correction(const reco::Jet& fJet,
0024                                 const edm::RefToBase<reco::Jet>& fJetRef,
0025                                 const edm::Event& fEvent,
0026                                 const edm::EventSetup& fSetup) const {
0027   if (eventRequired() && refRequired()) {
0028     edm::LogError("Missing Jet Correction Method")
0029         << "Undefined Jet Correction method requiring event data and jet reference is called" << std::endl;
0030     return 0;
0031   }
0032   return correction(fJet);
0033 }
0034 
0035 double JetCorrector::correction(const reco::Jet& fJet,
0036                                 const edm::RefToBase<reco::Jet>& fJetRef,
0037                                 const edm::Event& fEvent,
0038                                 const edm::EventSetup& fSetup,
0039                                 LorentzVector& corrected) const {
0040   if (vectorialCorrection()) {
0041     edm::LogError("Missing Jet Correction Method")
0042         << "Undefined Jet (vectorial) correction method requiring event data is called" << std::endl;
0043     return 0;
0044   }
0045   return correction(fJet);
0046 }
0047 
0048 const JetCorrector* JetCorrector::getJetCorrector(const std::string& fName, const edm::EventSetup& fSetup) {
0049   const JetCorrectionsRecord& record = fSetup.get<JetCorrectionsRecord>();
0050   edm::ESHandle<JetCorrector> handle;
0051   record.get(fName, handle);
0052   return &*handle;
0053 }