Skip to content

Commit c369b25

Browse files
committed
direct const access to ambiguousGsfTracks in GsfElectron
1 parent 84e7917 commit c369b25

File tree

5 files changed

+11
-19
lines changed

5 files changed

+11
-19
lines changed

CommonTools/Egamma/src/ConversionTools.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,8 @@ bool ConversionTools::matchesConversion(const reco::GsfElectron &ele,
6969
ele.reco::GsfElectron::closestCtfTrackRef().key() == it->key())
7070
return true;
7171
if (allowAmbiguousGsfMatch) {
72-
for (reco::GsfTrackRefVector::const_iterator tk = ele.ambiguousGsfTracksBegin();
73-
tk != ele.ambiguousGsfTracksEnd();
74-
++tk) {
75-
if (tk->isNonnull() && tk->id() == it->id() && tk->key() == it->key())
72+
for (auto const &tk : ele.ambiguousGsfTracks()) {
73+
if (tk.isNonnull() && tk.id() == it->id() && tk.key() == it->key())
7674
return true;
7775
}
7876
}

CommonTools/ParticleFlow/interface/ElectronIDPFCandidateSelectorDefinition.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,16 @@ namespace pf2pat {
8181

8282
int match = -1;
8383
// try first the non-ambiguous tracks
84-
for (reco::GsfElectronCollection::const_iterator it = electrons->begin(), ed = electrons->end(); it != ed;
85-
++it) {
84+
for (auto it = electrons->begin(), ed = electrons->end(); it != ed; ++it) {
8685
if (it->gsfTrack() == PfTk) {
8786
match = it - electrons->begin();
8887
break;
8988
}
9089
}
9190
// then the ambiguous ones
9291
if (match == -1) {
93-
for (reco::GsfElectronCollection::const_iterator it = electrons->begin(), ed = electrons->end(); it != ed;
94-
++it) {
95-
if (std::count(it->ambiguousGsfTracksBegin(), it->ambiguousGsfTracksEnd(), PfTk) > 0) {
92+
for (auto it = electrons->begin(), ed = electrons->end(); it != ed; ++it) {
93+
if (std::count(it->ambiguousGsfTracks().begin(), it->ambiguousGsfTracks().end(), PfTk) > 0) {
9694
match = it - electrons->begin();
9795
break;
9896
}

DataFormats/EgammaCandidates/interface/GsfElectron.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,8 +680,7 @@ namespace reco {
680680
bool passingPflowPreselection() const { return passPflowPreselection_; }
681681
bool ambiguous() const { return ambiguous_; }
682682
GsfTrackRefVector::size_type ambiguousGsfTracksSize() const { return ambiguousGsfTracks_.size(); }
683-
GsfTrackRefVector::const_iterator ambiguousGsfTracksBegin() const { return ambiguousGsfTracks_.begin(); }
684-
GsfTrackRefVector::const_iterator ambiguousGsfTracksEnd() const { return ambiguousGsfTracks_.end(); }
683+
auto const &ambiguousGsfTracks() const { return ambiguousGsfTracks_; }
685684

686685
// setters
687686
void setPassCutBasedPreselection(bool flag) { passCutBasedPreselection_ = flag; }

PhysicsTools/PatAlgos/plugins/PATElectronProducer.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,8 @@ void PATElectronProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe
383383
if (itElectron->gsfTrack() == i->gsfTrackRef()) {
384384
Matched = true;
385385
} else {
386-
for (reco::GsfTrackRefVector::const_iterator it = itElectron->ambiguousGsfTracksBegin();
387-
it != itElectron->ambiguousGsfTracksEnd();
388-
it++) {
389-
MatchedToAmbiguousGsfTrack |= (bool)(i->gsfTrackRef() == (*it));
386+
for (auto const& it : itElectron->ambiguousGsfTracks()) {
387+
MatchedToAmbiguousGsfTrack |= (bool)(i->gsfTrackRef() == it);
390388
}
391389
}
392390

RecoEgamma/EgammaPhotonProducers/src/ReducedEGProducer.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,7 @@ void ReducedEGProducer::produce(edm::Event& event, const edm::EventSetup& eventS
644644
}
645645

646646
// Save additional ambiguous gsf tracks in a map:
647-
for (auto igsf = gsfElectron.ambiguousGsfTracksBegin(); igsf != gsfElectron.ambiguousGsfTracksEnd(); ++igsf) {
648-
const reco::GsfTrackRef& ambigGsfTrack = *igsf;
647+
for (auto const& ambigGsfTrack : gsfElectron.ambiguousGsfTracks()) {
649648
if (!gsfTrackMap.count(ambigGsfTrack)) {
650649
gsfTracks.push_back(*ambigGsfTrack);
651650
gsfTrackMap[ambigGsfTrack] = gsfTracks.size() - 1;
@@ -863,8 +862,8 @@ void ReducedEGProducer::produce(edm::Event& event, const edm::EventSetup& eventS
863862
// Also in this loop let's relink ambiguous tracks
864863
std::vector<reco::GsfTrackRef> ambigTracksInThisElectron;
865864
// Here we loop over the ambiguous tracks and save them in a vector
866-
for (auto igsf = gsfElectron.ambiguousGsfTracksBegin(); igsf != gsfElectron.ambiguousGsfTracksEnd(); ++igsf) {
867-
ambigTracksInThisElectron.push_back(*igsf);
865+
for (auto const& igsf : gsfElectron.ambiguousGsfTracks()) {
866+
ambigTracksInThisElectron.push_back(igsf);
868867
}
869868

870869
// Now we need to clear them (they are the refs to original collection):

0 commit comments

Comments
 (0)