From 36e9c0cec9a7da6a3fd446a1798a19996a13a837 Mon Sep 17 00:00:00 2001 From: peruzzim Date: Sun, 20 Oct 2019 23:22:47 +0200 Subject: [PATCH] Fix wrong usage of associatedPackedPFCandidates vector in MuonFSRProducer --- .../MuonAssociators/plugins/MuonFSRProducer.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/MuonAnalysis/MuonAssociators/plugins/MuonFSRProducer.cc b/MuonAnalysis/MuonAssociators/plugins/MuonFSRProducer.cc index 1d08a04e54f8e..72fbc1f7065ee 100644 --- a/MuonAnalysis/MuonAssociators/plugins/MuonFSRProducer.cc +++ b/MuonAnalysis/MuonAssociators/plugins/MuonFSRProducer.cc @@ -142,17 +142,15 @@ void MuonFSRProducer::produce(edm::StreamID streamID, edm::Event& iEvent, const pat::PackedCandidateRef pfcandRef = pat::PackedCandidateRef(pfcands, iter_pf - pfcands->begin()); for (auto electrons_iter = electrons->begin(); electrons_iter != electrons->end(); ++electrons_iter) { - for (auto itr = electrons_iter->associatedPackedPFCandidates().begin(); - itr != electrons_iter->associatedPackedPFCandidates().end(); - ++itr) { - if (!itr->isAvailable()) + for (auto const& cand : electrons_iter->associatedPackedPFCandidates()) { + if (!cand.isAvailable()) continue; - if (itr->id() != pfcandRef.id()) + if (cand.id() != pfcandRef.id()) throw cms::Exception("Configuration") << "The electron associatedPackedPFCandidates item does not have " - << "the same ID of packed candidate collection used for cleaning the electron footprint: " << itr->id() + << "the same ID of packed candidate collection used for cleaning the electron footprint: " << cand.id() << " (" << pfcandRef.id() << ")\n"; - if (itr->key() == pfcandRef.key()) { + if (cand.key() == pfcandRef.key()) { skipPhoton = true; break; }