Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce complexity of erasing elements from vectors in PATTauHybridProducer [14_0_X] #44295

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 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 @@ -385,16 +382,11 @@ void PATTauHybridProducer::fillTauFromJet(reco::PFTau& pfTau, const reco::JetBas
pfTau.setleadChargedHadrCand(pfGammas[0]);
pfTau.setleadCand(pfGammas[0]);
pfGammasSig.push_back(pfGammas[0]);
pfChs.erase(pfGammas.begin());
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