Skip to content

Commit

Permalink
Reduced complexity of erasing vector elements in PATTauHybridProducer
Browse files Browse the repository at this point in the history
Erase elements of candidate vectors with remove_if instead of looping over the vectors to reduce complexity
  • Loading branch information
mbluj committed Mar 4, 2024
1 parent 5584911 commit 6f6f634
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions PhysicsTools/PatAlgos/plugins/PATTauHybridProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,10 @@ void PATTauHybridProducer::fillTauFromJet(reco::PFTau& pfTau, const reco::JetBas
}
}
// Clean isolation candidates from low-pt and leptonic ones
for (CandPtrs::iterator it = pfChs.begin(); it != pfChs.end();) {
if ((*it)->pt() < 0.5 || std::abs((*it)->pdgId()) != 211) {
it = pfChs.erase(it);
} else {
++it;
}
}
pfChs.erase(std::remove_if(pfChs.begin(),
pfChs.end(),
[](auto const& cand) { return cand->pt() < 0.5 || std::abs(cand->pdgId()) != 211; }),
pfChs.end());
// Set charged candidates
pfTau.setsignalChargedHadrCands(pfChsSig);
pfTau.setisolationChargedHadrCands(pfChs);
Expand All @@ -388,13 +385,8 @@ void PATTauHybridProducer::fillTauFromJet(reco::PFTau& pfTau, const reco::JetBas
pfGammas.erase(pfGammas.begin());
}
// Clean gamma candidates from low-pt ones
for (CandPtrs::iterator it = pfGammas.begin(); it != pfGammas.end();) {
if ((*it)->pt() < 0.5) {
it = pfGammas.erase(it);
} else {
++it;
}
}
pfGammas.erase(std::remove_if(pfGammas.begin(), pfGammas.end(), [](auto const& cand) { return cand->pt() < 0.5; }),
pfGammas.end());
// if decay mode with pi0s is expected look for signal gamma candidates
// within eta-phi strips around leading track
if (pfTau.decayMode() % 5 != 0 && pfTau.leadChargedHadrCand().isNonnull()) {
Expand Down

0 comments on commit 6f6f634

Please sign in to comment.