From dda5b0b2bad26d44572b996873c1f90827d73378 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Mon, 21 Nov 2022 03:55:09 +0100 Subject: [PATCH 1/2] Resolve issues --- .../test/GEDValueMapAnalyzer.cc | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/RecoEgamma/EgammaElectronProducers/test/GEDValueMapAnalyzer.cc b/RecoEgamma/EgammaElectronProducers/test/GEDValueMapAnalyzer.cc index d925f87cd31a9..79eb11a1e30d4 100644 --- a/RecoEgamma/EgammaElectronProducers/test/GEDValueMapAnalyzer.cc +++ b/RecoEgamma/EgammaElectronProducers/test/GEDValueMapAnalyzer.cc @@ -1,5 +1,6 @@ #include "FWCore/Framework/interface/Event.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -13,22 +14,26 @@ class GEDValueMapAnalyzer : public edm::one::EDAnalyzer<> { public: GEDValueMapAnalyzer(const edm::ParameterSet&); + ~GEDValueMapAnalyzer() override = default; + void analyze(const edm::Event& iEvent, const edm::EventSetup& c) override; private: - edm::InputTag inputTagValueMapElectrons_; - edm::InputTag inputTagPFCandidates_; + const edm::InputTag inputTagPFCandidates_; + const edm::InputTag inputTagValueMapElectrons_; + const edm::EDGetTokenT pfCandToken_; + const edm::EDGetTokenT > electronToken_; }; -GEDValueMapAnalyzer::GEDValueMapAnalyzer(const edm::ParameterSet& iConfig) { - inputTagPFCandidates_ = iConfig.getParameter("PFCandidates"); - inputTagValueMapElectrons_ = iConfig.getParameter("ElectronValueMap"); -} +GEDValueMapAnalyzer::GEDValueMapAnalyzer(const edm::ParameterSet& iConfig) + : inputTagPFCandidates_(iConfig.getParameter("PFCandidates")), + inputTagValueMapElectrons_(iConfig.getParameter("ElectronValueMap")), + pfCandToken_(consumes(inputTagPFCandidates_)), + electronToken_(consumes >(inputTagValueMapElectrons_)) {} void GEDValueMapAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& c) { - edm::Handle pfCandidatesH; - bool found = iEvent.getByLabel(inputTagPFCandidates_, pfCandidatesH); - if (!found) { + const edm::Handle& pfCandidatesH = iEvent.getHandle(pfCandToken_); + if (!pfCandidatesH.isValid()) { std::ostringstream err; err << " cannot get PFCandidates: " << inputTagPFCandidates_ << std::endl; edm::LogError("PFIsoReader") << err.str(); @@ -37,11 +42,10 @@ void GEDValueMapAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetu // Get the value maps - edm::Handle > electronValMapH; - found = iEvent.getByLabel(inputTagValueMapElectrons_, electronValMapH); + const edm::Handle > electronValMapH = iEvent.getHandle(electronToken_); const edm::ValueMap& myElectronValMap(*electronValMapH); - std::cout << " Read Electron Value Map " << myElectronValMap.size() << std::endl; + edm::LogVerbatim("GEDValueMapAnalyer") << " Read Electron Value Map " << myElectronValMap.size(); unsigned ncandidates = pfCandidatesH->size(); for (unsigned ic = 0; ic < ncandidates; ++ic) { @@ -55,11 +59,13 @@ void GEDValueMapAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetu reco::GsfElectronRef gsfRef = myElectronValMap[pfRef]; //basic check - std::cout << " Comparing GsfTrackRef from GsfElectron and PFCandidate "; + std::ostringstream st1; + st1 << " Comparing GsfTrackRef from GsfElectron and PFCandidate "; if (gsfRef->gsfTrack() == cand.gsfTrackRef()) - std::cout << " OK " << std::endl; + st1 << " OK "; else - std::cout << " Problem different Ref" << std::endl; + st1 << " Problem different Ref"; + edm::LogVerbatim("GEDValueMapAnalyer") << st1.str(); } } From 42c6239b8e30a327019610f6cf428018e7f6ef81 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Mon, 21 Nov 2022 04:07:07 +0100 Subject: [PATCH 2/2] Code check --- .../test/GEDValueMapAnalyzer.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/RecoEgamma/EgammaElectronProducers/test/GEDValueMapAnalyzer.cc b/RecoEgamma/EgammaElectronProducers/test/GEDValueMapAnalyzer.cc index 79eb11a1e30d4..4526215be0c1e 100644 --- a/RecoEgamma/EgammaElectronProducers/test/GEDValueMapAnalyzer.cc +++ b/RecoEgamma/EgammaElectronProducers/test/GEDValueMapAnalyzer.cc @@ -25,11 +25,11 @@ class GEDValueMapAnalyzer : public edm::one::EDAnalyzer<> { const edm::EDGetTokenT > electronToken_; }; -GEDValueMapAnalyzer::GEDValueMapAnalyzer(const edm::ParameterSet& iConfig) - : inputTagPFCandidates_(iConfig.getParameter("PFCandidates")), - inputTagValueMapElectrons_(iConfig.getParameter("ElectronValueMap")), - pfCandToken_(consumes(inputTagPFCandidates_)), - electronToken_(consumes >(inputTagValueMapElectrons_)) {} +GEDValueMapAnalyzer::GEDValueMapAnalyzer(const edm::ParameterSet& iConfig) + : inputTagPFCandidates_(iConfig.getParameter("PFCandidates")), + inputTagValueMapElectrons_(iConfig.getParameter("ElectronValueMap")), + pfCandToken_(consumes(inputTagPFCandidates_)), + electronToken_(consumes >(inputTagValueMapElectrons_)) {} void GEDValueMapAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& c) { const edm::Handle& pfCandidatesH = iEvent.getHandle(pfCandToken_);