Skip to content

Commit

Permalink
Resolve issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunanda committed Nov 21, 2022
1 parent c59ff76 commit dda5b0b
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions RecoEgamma/EgammaElectronProducers/test/GEDValueMapAnalyzer.cc
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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<reco::PFCandidateCollection> pfCandToken_;
const edm::EDGetTokenT<edm::ValueMap<reco::GsfElectronRef> > electronToken_;
};

GEDValueMapAnalyzer::GEDValueMapAnalyzer(const edm::ParameterSet& iConfig) {
inputTagPFCandidates_ = iConfig.getParameter<edm::InputTag>("PFCandidates");
inputTagValueMapElectrons_ = iConfig.getParameter<edm::InputTag>("ElectronValueMap");
}
GEDValueMapAnalyzer::GEDValueMapAnalyzer(const edm::ParameterSet& iConfig)
: inputTagPFCandidates_(iConfig.getParameter<edm::InputTag>("PFCandidates")),
inputTagValueMapElectrons_(iConfig.getParameter<edm::InputTag>("ElectronValueMap")),
pfCandToken_(consumes<reco::PFCandidateCollection>(inputTagPFCandidates_)),
electronToken_(consumes<edm::ValueMap<reco::GsfElectronRef> >(inputTagValueMapElectrons_)) {}

void GEDValueMapAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& c) {
edm::Handle<reco::PFCandidateCollection> pfCandidatesH;
bool found = iEvent.getByLabel(inputTagPFCandidates_, pfCandidatesH);
if (!found) {
const edm::Handle<reco::PFCandidateCollection>& pfCandidatesH = iEvent.getHandle(pfCandToken_);
if (!pfCandidatesH.isValid()) {
std::ostringstream err;
err << " cannot get PFCandidates: " << inputTagPFCandidates_ << std::endl;
edm::LogError("PFIsoReader") << err.str();
Expand All @@ -37,11 +42,10 @@ void GEDValueMapAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetu

// Get the value maps

edm::Handle<edm::ValueMap<reco::GsfElectronRef> > electronValMapH;
found = iEvent.getByLabel(inputTagValueMapElectrons_, electronValMapH);
const edm::Handle<edm::ValueMap<reco::GsfElectronRef> > electronValMapH = iEvent.getHandle(electronToken_);
const edm::ValueMap<reco::GsfElectronRef>& 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) {
Expand All @@ -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();
}
}

Expand Down

0 comments on commit dda5b0b

Please sign in to comment.