Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-06 04:13:48

0001 ////////////////////////////////////////////////////////////////////////////////
0002 //
0003 // L1FastjetCorrector
0004 // ------------------
0005 //
0006 //            08/09/2009 Philipp Schieferdecker <philipp.schieferdecker@cern.ch>
0007 ////////////////////////////////////////////////////////////////////////////////
0008 
0009 #include <memory>
0010 
0011 #include "CondFormats/JetMETObjects/interface/JetCorrectorParameters.h"
0012 #include "JetMETCorrections/Algorithms/interface/L1FastjetCorrectorImpl.h"
0013 #include "JetMETCorrections/Objects/interface/JetCorrectionsRecord.h"
0014 
0015 #include "FWCore/Utilities/interface/Exception.h"
0016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0017 #include "FWCore/Framework/interface/ConsumesCollector.h"
0018 #include "FWCore/Framework/interface/Event.h"
0019 #include "FWCore/Framework/interface/EventSetup.h"
0020 #include "FWCore/Framework/interface/ESHandle.h"
0021 
0022 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0023 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0024 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0025 #include "DataFormats/Common/interface/Handle.h"
0026 
0027 using namespace std;
0028 
0029 L1FastjetCorrectorImplMaker::L1FastjetCorrectorImplMaker(edm::ParameterSet const& fConfig,
0030                                                          edm::ConsumesCollector fCollector)
0031     : JetCorrectorImplMakerBase(fConfig, fCollector),
0032       rhoToken_(fCollector.consumes<double>(fConfig.getParameter<edm::InputTag>("srcRho"))) {}
0033 
0034 std::unique_ptr<reco::JetCorrectorImpl> L1FastjetCorrectorImplMaker::make(edm::Event const& fEvent,
0035                                                                           edm::EventSetup const& fSetup) {
0036   auto corrector = getCalculator(fSetup, [](const std::string& level) {
0037     if (level != "L1FastJet") {
0038       throw cms::Exception("L1FastjetCorrector") << " correction level: " << level << " is not L1FastJet";
0039     }
0040   });
0041 
0042   edm::Handle<double> hRho;
0043   fEvent.getByToken(rhoToken_, hRho);
0044   return std::make_unique<L1FastjetCorrectorImpl>(corrector, *hRho);
0045 }
0046 
0047 void L1FastjetCorrectorImplMaker::fillDescriptions(edm::ConfigurationDescriptions& iDescriptions) {
0048   edm::ParameterSetDescription desc;
0049   addToDescription(desc);
0050   desc.add<edm::InputTag>("srcRho");
0051   iDescriptions.addDefault(desc);
0052 }
0053 
0054 //______________________________________________________________________________
0055 ////////////////////////////////////////////////////////////////////////////////
0056 // implementation of member functions
0057 ////////////////////////////////////////////////////////////////////////////////
0058 
0059 //______________________________________________________________________________
0060 double L1FastjetCorrectorImpl::correction(const LorentzVector& fJet) const {
0061   throw cms::Exception("EventRequired") << "Wrong interface correction(LorentzVector), event required!";
0062   return 1.0;
0063 }
0064 
0065 //______________________________________________________________________________
0066 double L1FastjetCorrectorImpl::correction(const reco::Jet& fJet) const {
0067   FactorizedJetCorrectorCalculator::VariableValues values;
0068   values.setJetEta(fJet.eta());
0069   values.setJetPt(fJet.pt());
0070   values.setJetE(fJet.energy());
0071   values.setJetA(fJet.jetArea());
0072   values.setRho(rho_);
0073   return corrector_->getCorrection(values);
0074 }