Skip to content

Commit

Permalink
Merge pull request #40088 from laurenhay/preventNjettinessFailBTag_fr…
Browse files Browse the repository at this point in the history
…om12410patch3

Protect against particles with zero weight and pt being given as input to njettiness BACKPORT
  • Loading branch information
cmsbuild authored Nov 17, 2022
2 parents faf7fb7 + be4b045 commit 3539833
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions RecoBTag/SecondaryVertex/plugins/BoostedDoubleSVProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,8 @@ void BoostedDoubleSVProducer::calcNsubjettiness(const reco::JetBaseRef& jet,
// loop over subjet constituents and push them in the vector of FastJet constituents
for (size_t i = 0; i < daughter->numberOfDaughters(); ++i) {
const reco::CandidatePtr& constit = subjet->daughterPtr(i);

if (constit.isNonnull()) {
// Check if any values were nan or inf
if (constit.isNonnull() && constit->pt() > std::numeric_limits<double>::epsilon() ) {
// Check if any values were nan or inf
float valcheck = constit->px() + constit->py() + constit->pz() + constit->energy();
if (edm::isNotFinite(valcheck)) {
edm::LogWarning("FaultyJetConstituent")
Expand All @@ -679,10 +678,12 @@ void BoostedDoubleSVProducer::calcNsubjettiness(const reco::JetBaseRef& jet,
<< "BoostedDoubleSVProducer: No weights (e.g. PUPPI) given for weighted jet collection"
<< std::endl;
}
fjParticles.push_back(
fastjet::PseudoJet(constit->px() * w, constit->py() * w, constit->pz() * w, constit->energy() * w));
} else
fjParticles.push_back(fastjet::PseudoJet(constit->px(), constit->py(), constit->pz(), constit->energy()));
if ( w > 0 ) {
fjParticles.push_back(fastjet::PseudoJet(constit->px() * w, constit->py() * w, constit->pz() * w, constit->energy() * w));
}
} else {
fjParticles.push_back(fastjet::PseudoJet(constit->px(), constit->py(), constit->pz(), constit->energy()));
}
} else
edm::LogWarning("MissingJetConstituent")
<< "Jet constituent required for N-subjettiness computation is missing!";
Expand All @@ -703,10 +704,12 @@ void BoostedDoubleSVProducer::calcNsubjettiness(const reco::JetBaseRef& jet,
throw cms::Exception("MissingConstituentWeight")
<< "BoostedDoubleSVProducer: No weights (e.g. PUPPI) given for weighted jet collection" << std::endl;
}
fjParticles.push_back(
fastjet::PseudoJet(daughter->px() * w, daughter->py() * w, daughter->pz() * w, daughter->energy() * w));
} else
if ( w > 0 && daughter->pt() > std::numeric_limits<double>::epsilon() ) {
fjParticles.push_back(fastjet::PseudoJet(daughter->px() * w, daughter->py() * w, daughter->pz() * w, daughter->energy() * w));
}
} else {
fjParticles.push_back(fastjet::PseudoJet(daughter->px(), daughter->py(), daughter->pz(), daughter->energy()));
}
}
} else
edm::LogWarning("MissingJetConstituent") << "Jet constituent required for N-subjettiness computation is missing!";
Expand Down

0 comments on commit 3539833

Please sign in to comment.