From 58fb43e21a617cde0f665593d499df959c96cdfd Mon Sep 17 00:00:00 2001 From: Ben Jones Date: Tue, 14 Jul 2020 10:46:29 -0500 Subject: [PATCH 1/3] added esConsumes to modules in JetMETCorrections/Type1MET --- .../Type1MET/plugins/MultShiftMETcorrDBInputProducer.cc | 7 +++---- .../Type1MET/plugins/MultShiftMETcorrDBInputProducer.h | 4 ++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/JetMETCorrections/Type1MET/plugins/MultShiftMETcorrDBInputProducer.cc b/JetMETCorrections/Type1MET/plugins/MultShiftMETcorrDBInputProducer.cc index 9c4fdb2239d84..6f2ba4dfd49fc 100644 --- a/JetMETCorrections/Type1MET/plugins/MultShiftMETcorrDBInputProducer.cc +++ b/JetMETCorrections/Type1MET/plugins/MultShiftMETcorrDBInputProducer.cc @@ -2,9 +2,7 @@ #include "FWCore/Utilities/interface/Exception.h" #include "FWCore/Framework/interface/ESHandle.h" -#include "CondFormats/JetMETObjects/interface/MEtXYcorrectParameters.h" #include "CondFormats/JetMETObjects/interface/Utilities.h" -#include "JetMETCorrections/Objects/interface/MEtXYcorrectRecord.h" #include "DataFormats/METReco/interface/CorrMETData.h" #include "DataFormats/VertexReco/interface/Vertex.h" @@ -43,6 +41,8 @@ MultShiftMETcorrDBInputProducer::MultShiftMETcorrDBInputProducer(const edm::Para pflow_ = consumes>(cfg.getParameter("srcPFlow")); vertices_ = consumes>(cfg.getParameter("vertexCollection")); + mMEtXYcorParaColl_ = + esConsumes(edm::ESInputTag("", mPayloadName)); edm::InputTag srcWeights = cfg.getParameter("srcWeights"); if (!srcWeights.label().empty()) @@ -58,8 +58,7 @@ MultShiftMETcorrDBInputProducer::~MultShiftMETcorrDBInputProducer() {} void MultShiftMETcorrDBInputProducer::produce(edm::Event& evt, const edm::EventSetup& es) { // Get para.s from DB - edm::ESHandle MEtXYcorParaColl; - es.get().get(mPayloadName, MEtXYcorParaColl); + edm::ESHandle MEtXYcorParaColl = es.getHandle(mMEtXYcorParaColl_); // get the sections from Collection (pair of section and METCorr.Par class) std::vector keys; diff --git a/JetMETCorrections/Type1MET/plugins/MultShiftMETcorrDBInputProducer.h b/JetMETCorrections/Type1MET/plugins/MultShiftMETcorrDBInputProducer.h index 7b29450091f42..cbf75058423a8 100644 --- a/JetMETCorrections/Type1MET/plugins/MultShiftMETcorrDBInputProducer.h +++ b/JetMETCorrections/Type1MET/plugins/MultShiftMETcorrDBInputProducer.h @@ -18,12 +18,15 @@ #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" +#include "FWCore/Utilities/interface/ESGetToken.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "DataFormats/Common/interface/ValueMap.h" #include "DataFormats/METReco/interface/MET.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "CondFormats/JetMETObjects/interface/MEtXYcorrectParameters.h" +#include "JetMETCorrections/Objects/interface/MEtXYcorrectRecord.h" #include @@ -41,6 +44,7 @@ class MultShiftMETcorrDBInputProducer : public edm::stream::EDProducer<> { edm::EDGetTokenT> pflow_; edm::EDGetTokenT> vertices_; + edm::ESGetToken mMEtXYcorParaColl_; std::string moduleLabel_; std::string mPayloadName; std::string mSampleType; From 8b8f0e2bf26e85fac2de04ee88776ec1a6b9a518 Mon Sep 17 00:00:00 2001 From: Ben Jones Date: Tue, 14 Jul 2020 10:49:16 -0500 Subject: [PATCH 2/3] removed unnessecary argument of EventSetup --- .../interface/AddCorrectionsToGenericMET.h | 8 +-- .../interface/CorrectedMETProducerT.h | 72 +++++++------------ .../plugins/CorrectedCaloMETProducer.cc | 2 +- .../plugins/CorrectedPFMETProducer.cc | 2 +- .../plugins/CorrectedPatMETProducer.cc | 4 +- .../src/AddCorrectionsToGenericMET.cc | 22 ++---- .../Type1MET/src/METCorrectionAlgorithm.cc | 2 +- .../plugins/CorrectedPATMETProducer.cc | 2 +- 8 files changed, 44 insertions(+), 70 deletions(-) diff --git a/JetMETCorrections/Type1MET/interface/AddCorrectionsToGenericMET.h b/JetMETCorrections/Type1MET/interface/AddCorrectionsToGenericMET.h index 165c2267967be..fed507c9d8753 100644 --- a/JetMETCorrections/Type1MET/interface/AddCorrectionsToGenericMET.h +++ b/JetMETCorrections/Type1MET/interface/AddCorrectionsToGenericMET.h @@ -31,12 +31,12 @@ class AddCorrectionsToGenericMET { void setCorTokens(std::vector > const& corrTokens); - reco::MET getCorrectedMET(const reco::MET& srcMET, edm::Event& evt, const edm::EventSetup& es); - reco::PFMET getCorrectedPFMET(const reco::PFMET& srcMET, edm::Event& evt, const edm::EventSetup& es); - reco::CaloMET getCorrectedCaloMET(const reco::CaloMET& srcMET, edm::Event& evt, const edm::EventSetup& es); + reco::MET getCorrectedMET(const reco::MET& srcMET, edm::Event& evt); + reco::PFMET getCorrectedPFMET(const reco::PFMET& srcMET, edm::Event& evt); + reco::CaloMET getCorrectedCaloMET(const reco::CaloMET& srcMET, edm::Event& evt); private: - CorrMETData getCorrection(const reco::MET& srcMET, edm::Event& evt, const edm::EventSetup& es); + CorrMETData getCorrection(const reco::MET& srcMET, edm::Event& evt); std::vector > corrTokens_; reco::Candidate::LorentzVector constructP4From(const reco::MET& met, const CorrMETData& correction); diff --git a/JetMETCorrections/Type1MET/interface/CorrectedMETProducerT.h b/JetMETCorrections/Type1MET/interface/CorrectedMETProducerT.h index 6d7c315bbc335..298d28b228224 100644 --- a/JetMETCorrections/Type1MET/interface/CorrectedMETProducerT.h +++ b/JetMETCorrections/Type1MET/interface/CorrectedMETProducerT.h @@ -35,83 +35,68 @@ #include -namespace CorrectedMETProducer_namespace -{ +namespace CorrectedMETProducer_namespace { template - reco::Candidate::LorentzVector correctedP4(const T& rawMEt, const CorrMETData& correction) - { + reco::Candidate::LorentzVector correctedP4(const T& rawMEt, const CorrMETData& correction) { double correctedMEtPx = rawMEt.px() + correction.mex; double correctedMEtPy = rawMEt.py() + correction.mey; - double correctedMEtPt = sqrt(correctedMEtPx*correctedMEtPx + correctedMEtPy*correctedMEtPy); + double correctedMEtPt = sqrt(correctedMEtPx * correctedMEtPx + correctedMEtPy * correctedMEtPy); return reco::Candidate::LorentzVector(correctedMEtPx, correctedMEtPy, 0., correctedMEtPt); } template - double correctedSumEt(const T& rawMEt, const CorrMETData& correction) - { + double correctedSumEt(const T& rawMEt, const CorrMETData& correction) { return rawMEt.sumEt() + correction.sumet; } template - class CorrectedMETFactoryT - { - public: - - T operator()(const T&, const CorrMETData&) const - { - assert(0); // "place-holder" for template instantiations for concrete T types only, **not** to be called - } + class CorrectedMETFactoryT { + public: + T operator()(const T&, const CorrMETData&) const { + assert(0); // "place-holder" for template instantiations for concrete T types only, **not** to be called + } }; -} +} // namespace CorrectedMETProducer_namespace -template -class CorrectedMETProducerT : public edm::stream::EDProducer<> -{ +template +class CorrectedMETProducerT : public edm::stream::EDProducer<> { typedef std::vector METCollection; - public: - +public: explicit CorrectedMETProducerT(const edm::ParameterSet& cfg) - : moduleLabel_(cfg.getParameter("@module_label")), - algorithm_(0) - { + : moduleLabel_(cfg.getParameter("@module_label")), algorithm_(0) { token_ = consumes(cfg.getParameter("src")); algorithm_ = new METCorrectionAlgorithm(cfg, consumesCollector()); produces(""); } - ~CorrectedMETProducerT() - { - delete algorithm_; - } - + ~CorrectedMETProducerT() { delete algorithm_; } + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - desc.add("src",edm::InputTag("corrPfMetType1", "type1")); - descriptions.add(defaultModuleLabel >(),desc); + desc.add("src", edm::InputTag("corrPfMetType1", "type1")); + descriptions.add(defaultModuleLabel >(), desc); } - private: - - void produce(edm::Event& evt, const edm::EventSetup& es) - { +private: + void produce(edm::Event& evt, const edm::EventSetup& es) { std::unique_ptr correctedMEtCollection(new METCollection); edm::Handle rawMEtCollection; evt.getByToken(token_, rawMEtCollection); - for ( typename METCollection::const_iterator rawMEt = rawMEtCollection->begin(); - rawMEt != rawMEtCollection->end(); ++rawMEt ) { - CorrMETData correction = algorithm_->compMETCorrection(evt, es); + for (typename METCollection::const_iterator rawMEt = rawMEtCollection->begin(); rawMEt != rawMEtCollection->end(); + ++rawMEt) { + CorrMETData correction = algorithm_->compMETCorrection(evt); - static const CorrectedMETProducer_namespace::CorrectedMETFactoryT correctedMET_factory {}; + static const CorrectedMETProducer_namespace::CorrectedMETFactoryT correctedMET_factory{}; T correctedMEt = correctedMET_factory(*rawMEt, correction); correctedMEtCollection->push_back(correctedMEt); } - -//--- add collection of MET objects with Type 1 / Type 1 + 2 corrections applied to the event + + //--- add collection of MET objects with Type 1 / Type 1 + 2 corrections applied to the event evt.put(std::move(correctedMEtCollection)); } @@ -119,10 +104,7 @@ class CorrectedMETProducerT : public edm::stream::EDProducer<> edm::EDGetTokenT token_; - METCorrectionAlgorithm* algorithm_; // algorithm for computing Type 1 / Type 1 + 2 MET corrections + METCorrectionAlgorithm* algorithm_; // algorithm for computing Type 1 / Type 1 + 2 MET corrections }; #endif - - - diff --git a/JetMETCorrections/Type1MET/plugins/CorrectedCaloMETProducer.cc b/JetMETCorrections/Type1MET/plugins/CorrectedCaloMETProducer.cc index 7daa796c5aa9f..8c09fd024f24d 100644 --- a/JetMETCorrections/Type1MET/plugins/CorrectedCaloMETProducer.cc +++ b/JetMETCorrections/Type1MET/plugins/CorrectedCaloMETProducer.cc @@ -49,7 +49,7 @@ class CorrectedCaloMETProducer : public edm::stream::EDProducer<> { const reco::CaloMET& srcMET = (*srcMETCollection)[0]; - reco::CaloMET outMET = corrector.getCorrectedCaloMET(srcMET, evt, es); + reco::CaloMET outMET = corrector.getCorrectedCaloMET(srcMET, evt); std::unique_ptr product(new METCollection); product->push_back(outMET); diff --git a/JetMETCorrections/Type1MET/plugins/CorrectedPFMETProducer.cc b/JetMETCorrections/Type1MET/plugins/CorrectedPFMETProducer.cc index 878e79c0d8deb..8ddc4c295786c 100644 --- a/JetMETCorrections/Type1MET/plugins/CorrectedPFMETProducer.cc +++ b/JetMETCorrections/Type1MET/plugins/CorrectedPFMETProducer.cc @@ -62,7 +62,7 @@ class CorrectedPFMETProducer : public edm::stream::EDProducer<> { const reco::PFMET& srcMET = (*srcMETCollection)[0]; - reco::PFMET outMET = corrector.getCorrectedPFMET(srcMET, evt, es); + reco::PFMET outMET = corrector.getCorrectedPFMET(srcMET, evt); std::unique_ptr product(new METCollection); product->push_back(outMET); diff --git a/JetMETCorrections/Type1MET/plugins/CorrectedPatMETProducer.cc b/JetMETCorrections/Type1MET/plugins/CorrectedPatMETProducer.cc index 6655cf0eb595b..ca540b755b965 100644 --- a/JetMETCorrections/Type1MET/plugins/CorrectedPatMETProducer.cc +++ b/JetMETCorrections/Type1MET/plugins/CorrectedPatMETProducer.cc @@ -70,13 +70,13 @@ class CorrectedPatMETProducer : public edm::stream::EDProducer<> { //std::unique_ptr product(new patMETCollection); std::unique_ptr product(new patMETCollection); const reco::MET& srcMET = (*srcPatMETCollection)[0]; - pat::MET outMEtPat = corrector.getCorrectedMET(srcMET, evt, es); + pat::MET outMEtPat = corrector.getCorrectedMET(srcMET, evt); product->push_back(outMEtPat); evt.put(std::move(product)); } else { std::unique_ptr product(new pfMETCollection); const reco::PFMET& srcMET = (*srcPfMETCollection)[0]; - reco::PFMET outPfMEtReco = corrector.getCorrectedPFMET(srcMET, evt, es); + reco::PFMET outPfMEtReco = corrector.getCorrectedPFMET(srcMET, evt); product->push_back(outPfMEtReco); evt.put(std::move(product)); } diff --git a/JetMETCorrections/Type1MET/src/AddCorrectionsToGenericMET.cc b/JetMETCorrections/Type1MET/src/AddCorrectionsToGenericMET.cc index d100be4ca027a..b18896af805e7 100644 --- a/JetMETCorrections/Type1MET/src/AddCorrectionsToGenericMET.cc +++ b/JetMETCorrections/Type1MET/src/AddCorrectionsToGenericMET.cc @@ -12,9 +12,7 @@ reco::Candidate::LorentzVector AddCorrectionsToGenericMET::constructP4From(const return reco::Candidate::LorentzVector(px, py, 0., pt); } -CorrMETData AddCorrectionsToGenericMET::getCorrection(const reco::MET& srcMET, - edm::Event& evt, - const edm::EventSetup& es) { +CorrMETData AddCorrectionsToGenericMET::getCorrection(const reco::MET& srcMET, edm::Event& evt) { CorrMETData sumCor; edm::Handle corr; for (std::vector >::const_iterator corrToken = corrTokens_.begin(); @@ -27,20 +25,16 @@ CorrMETData AddCorrectionsToGenericMET::getCorrection(const reco::MET& srcMET, return sumCor; } -reco::MET AddCorrectionsToGenericMET::getCorrectedMET(const reco::MET& srcMET, - edm::Event& evt, - const edm::EventSetup& es) { - CorrMETData corr = getCorrection(srcMET, evt, es); +reco::MET AddCorrectionsToGenericMET::getCorrectedMET(const reco::MET& srcMET, edm::Event& evt) { + CorrMETData corr = getCorrection(srcMET, evt); reco::MET outMET(srcMET.sumEt() + corr.sumet, constructP4From(srcMET, corr), srcMET.vertex(), srcMET.isWeighted()); return outMET; } //specific flavors ================================ -reco::PFMET AddCorrectionsToGenericMET::getCorrectedPFMET(const reco::PFMET& srcMET, - edm::Event& evt, - const edm::EventSetup& es) { - CorrMETData corr = getCorrection(srcMET, evt, es); +reco::PFMET AddCorrectionsToGenericMET::getCorrectedPFMET(const reco::PFMET& srcMET, edm::Event& evt) { + CorrMETData corr = getCorrection(srcMET, evt); reco::PFMET outMET(srcMET.getSpecific(), srcMET.sumEt() + corr.sumet, constructP4From(srcMET, corr), @@ -50,10 +44,8 @@ reco::PFMET AddCorrectionsToGenericMET::getCorrectedPFMET(const reco::PFMET& src return outMET; } -reco::CaloMET AddCorrectionsToGenericMET::getCorrectedCaloMET(const reco::CaloMET& srcMET, - edm::Event& evt, - const edm::EventSetup& es) { - CorrMETData corr = getCorrection(srcMET, evt, es); +reco::CaloMET AddCorrectionsToGenericMET::getCorrectedCaloMET(const reco::CaloMET& srcMET, edm::Event& evt) { + CorrMETData corr = getCorrection(srcMET, evt); reco::CaloMET outMET( srcMET.getSpecific(), srcMET.sumEt() + corr.sumet, constructP4From(srcMET, corr), srcMET.vertex()); diff --git a/JetMETCorrections/Type1MET/src/METCorrectionAlgorithm.cc b/JetMETCorrections/Type1MET/src/METCorrectionAlgorithm.cc index ae8d0a4a8a970..701424db1b65b 100644 --- a/JetMETCorrections/Type1MET/src/METCorrectionAlgorithm.cc +++ b/JetMETCorrections/Type1MET/src/METCorrectionAlgorithm.cc @@ -68,7 +68,7 @@ METCorrectionAlgorithm::~METCorrectionAlgorithm() { } } -CorrMETData METCorrectionAlgorithm::compMETCorrection(edm::Event& evt, const edm::EventSetup& es) { +CorrMETData METCorrectionAlgorithm::compMETCorrection(edm::Event& evt) { CorrMETData metCorr; metCorr.mex = 0.; metCorr.mey = 0.; diff --git a/PhysicsTools/PatUtils/plugins/CorrectedPATMETProducer.cc b/PhysicsTools/PatUtils/plugins/CorrectedPATMETProducer.cc index ae9dc521d6ee4..7f763f60074db 100644 --- a/PhysicsTools/PatUtils/plugins/CorrectedPATMETProducer.cc +++ b/PhysicsTools/PatUtils/plugins/CorrectedPATMETProducer.cc @@ -52,7 +52,7 @@ class CorrectedPATMETProducer : public edm::stream::EDProducer<> { const pat::MET& srcMET = (*srcMETCollection)[0]; //dispatching to be sure we retrieve all the informations - reco::MET corrMET = corrector.getCorrectedMET(srcMET, evt, es); + reco::MET corrMET = corrector.getCorrectedMET(srcMET, evt); pat::MET outMET(corrMET, srcMET); auto product = std::make_unique(); From 994d7c382457c4932def33da9aca00f9a9987202 Mon Sep 17 00:00:00 2001 From: Ben Jones Date: Tue, 14 Jul 2020 11:12:18 -0500 Subject: [PATCH 3/3] changed h file to reflect removal of EventSetup Argument --- JetMETCorrections/Type1MET/interface/METCorrectionAlgorithm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JetMETCorrections/Type1MET/interface/METCorrectionAlgorithm.h b/JetMETCorrections/Type1MET/interface/METCorrectionAlgorithm.h index ebbe58b513c86..d65de5c4b3d43 100644 --- a/JetMETCorrections/Type1MET/interface/METCorrectionAlgorithm.h +++ b/JetMETCorrections/Type1MET/interface/METCorrectionAlgorithm.h @@ -34,7 +34,7 @@ class METCorrectionAlgorithm { explicit METCorrectionAlgorithm(const edm::ParameterSet&, edm::ConsumesCollector&& iConsumesCollector); ~METCorrectionAlgorithm(); - CorrMETData compMETCorrection(edm::Event&, const edm::EventSetup&); + CorrMETData compMETCorrection(edm::Event&); private: typedef std::vector vInputTag;