diff --git a/JetMETCorrections/Modules/interface/CorrectedJetProducer.h b/JetMETCorrections/Modules/interface/CorrectedJetProducer.h index a74425f9505bd..6be95e6dc1fd4 100644 --- a/JetMETCorrections/Modules/interface/CorrectedJetProducer.h +++ b/JetMETCorrections/Modules/interface/CorrectedJetProducer.h @@ -9,7 +9,7 @@ #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/Common/interface/Ref.h" #include "DataFormats/Common/interface/RefToBase.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Utilities/interface/InputTag.h" @@ -25,19 +25,17 @@ namespace edm namespace reco { template - class CorrectedJetProducer : public edm::EDProducer + class CorrectedJetProducer : public edm::global::EDProducer<> { public: typedef std::vector JetCollection; explicit CorrectedJetProducer (const edm::ParameterSet& fParameters); virtual ~CorrectedJetProducer () {} - virtual void produce(edm::Event&, const edm::EventSetup&); + virtual void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; private: - edm::EDGetTokenT mInput; - std::vector > mCorrectorTokens; - // cache - std::vector mCorrectors; - bool mVerbose; + const edm::EDGetTokenT mInput; + const std::vector > mCorrectorTokens; + const bool mVerbose; }; } @@ -49,7 +47,6 @@ namespace reco { CorrectedJetProducer::CorrectedJetProducer(const edm::ParameterSet& fConfig) : mInput(consumes(fConfig.getParameter ("src"))) , mCorrectorTokens(edm::vector_transform(fConfig.getParameter >("correctors"), [this](edm::InputTag const & tag){return consumes(tag);})) - , mCorrectors(mCorrectorTokens.size(), 0) , mVerbose (fConfig.getUntrackedParameter ("verbose", false)) { std::string alias = fConfig.getUntrackedParameter ("alias", ""); @@ -60,15 +57,17 @@ namespace reco { } template - void CorrectedJetProducer::produce(edm::Event& fEvent, - const edm::EventSetup& fSetup) + void CorrectedJetProducer::produce(edm::StreamID, edm::Event& fEvent, const edm::EventSetup& fSetup) const { + // FIXME - use something more efficient instead of an std::vector + std::vector correctors(mCorrectorTokens.size(), nullptr); + // look for correctors for (unsigned i = 0; i < mCorrectorTokens.size(); i++) { edm::Handle handle; fEvent.getByToken (mCorrectorTokens [i], handle); - mCorrectors [i] = &*handle; + correctors[i] = handle.product(); } edm::Handle jets; //Define Inputs fEvent.getByToken (mInput, jets); //Get Inputs @@ -83,15 +82,15 @@ namespace reco { if (mVerbose) std::cout<<"CorrectedJetProducer::produce-> original jet: " <print()<vectorialCorrection()) ) { + if ( !(correctors[i]->vectorialCorrection()) ) { // Scalar correction double scale = 1.; - if (!(mCorrectors[i]->refRequired())) - scale = mCorrectors[i]->correction (*referenceJet); + if (!(correctors[i]->refRequired())) + scale = correctors[i]->correction (*referenceJet); else - scale = mCorrectors[i]->correction (*referenceJet,jetRef); + scale = correctors[i]->correction (*referenceJet,jetRef); if (mVerbose) std::cout<<"CorrectedJetProducer::produce-> Corrector # " <correction (*referenceJet, jetRef, corrected); + double scale = correctors[i]->correction (*referenceJet, jetRef, corrected); if (mVerbose) std::cout<<"CorrectedJetProducer::produce-> Corrector # " <