Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:     JetMETCorrections/Algorithms
0004 // Class  :     JetCorrectorImplMakerBase
0005 //
0006 // Implementation:
0007 //     [Notes on implementation]
0008 //
0009 // Original Author:  Christopher Jones
0010 //         Created:  Fri, 29 Aug 2014 19:52:26 GMT
0011 //
0012 
0013 // system include files
0014 #include <vector>
0015 
0016 // user include files
0017 #include "JetMETCorrections/Algorithms/interface/JetCorrectorImplMakerBase.h"
0018 
0019 #include "FWCore/Framework/interface/EventSetup.h"
0020 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0021 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0022 
0023 #include "CondFormats/JetMETObjects/interface/JetCorrectorParameters.h"
0024 #include "JetMETCorrections/Objects/interface/JetCorrectionsRecord.h"
0025 
0026 //
0027 // constants, enums and typedefs
0028 //
0029 
0030 //
0031 // static data member definitions
0032 //
0033 
0034 //
0035 // constructors and destructor
0036 //
0037 JetCorrectorImplMakerBase::JetCorrectorImplMakerBase(edm::ParameterSet const& iPSet, edm::ConsumesCollector iC)
0038     : level_(iPSet.getParameter<std::string>("level")),
0039       algoToken_(iC.esConsumes(edm::ESInputTag("", iPSet.getParameter<std::string>("algorithm")))),
0040       cacheId_(0) {}
0041 
0042 // JetCorrectorImplMakerBase::JetCorrectorImplMakerBase(const JetCorrectorImplMakerBase& rhs)
0043 // {
0044 //    // do actual copying here;
0045 // }
0046 
0047 JetCorrectorImplMakerBase::~JetCorrectorImplMakerBase() {}
0048 
0049 //
0050 // member functions
0051 //
0052 
0053 std::shared_ptr<FactorizedJetCorrectorCalculator const> JetCorrectorImplMakerBase::getCalculator(
0054     edm::EventSetup const& iSetup, std::function<void(std::string const&)> iLevelCheck) {
0055   auto const& rec = iSetup.get<JetCorrectionsRecord>();
0056   if (cacheId_ != rec.cacheIdentifier()) {
0057     auto const& JetCorParColl = rec.get(algoToken_);
0058     auto const& parameters = JetCorParColl[level_];
0059 
0060     iLevelCheck(parameters.definitions().level());
0061     std::vector<JetCorrectorParameters> vParam;
0062     vParam.push_back(parameters);
0063     corrector_ = std::make_shared<FactorizedJetCorrectorCalculator>(vParam);
0064 
0065     cacheId_ = rec.cacheIdentifier();
0066   }
0067   return corrector_;
0068 }
0069 
0070 void JetCorrectorImplMakerBase::addToDescription(edm::ParameterSetDescription& iDescription) {
0071   iDescription.add<std::string>("level");
0072   iDescription.add<std::string>("algorithm");
0073 }