diff --git a/RecoBTag/SecondaryVertex/plugins/TemplatedSecondaryVertexProducer.cc b/RecoBTag/SecondaryVertex/plugins/TemplatedSecondaryVertexProducer.cc index 83d297f69d521..b0d5e97258142 100644 --- a/RecoBTag/SecondaryVertex/plugins/TemplatedSecondaryVertexProducer.cc +++ b/RecoBTag/SecondaryVertex/plugins/TemplatedSecondaryVertexProducer.cc @@ -389,7 +389,7 @@ void TemplatedSecondaryVertexProducer::produce(edm::Event &event, con std::vector >::const_iterator m; for (m = constituents.begin(); m != constituents.end(); ++m) { reco::CandidatePtr constit = *m; - if (constit->pt() == 0) { + if (constit.isNull() || constit->pt() <= std::numeric_limits::epsilon()) { edm::LogWarning("NullTransverseMomentum") << "dropping input candidate with pt=0"; continue; } @@ -399,8 +399,10 @@ void TemplatedSecondaryVertexProducer::produce(edm::Event &event, con << "TemplatedSecondaryVertexProducer: No weights (e.g. PUPPI) given for weighted jet collection" << std::endl; float w = (*weightsHandle)[constit]; - fjInputs.push_back( - fastjet::PseudoJet(constit->px() * w, constit->py() * w, constit->pz() * w, constit->energy() * w)); + if (w > 0) { + fjInputs.push_back( + fastjet::PseudoJet(constit->px() * w, constit->py() * w, constit->pz() * w, constit->energy() * w)); + } } else { fjInputs.push_back(fastjet::PseudoJet(constit->px(), constit->py(), constit->pz(), constit->energy())); } @@ -413,7 +415,7 @@ void TemplatedSecondaryVertexProducer::produce(edm::Event &event, con std::vector >::const_iterator m; for (m = constituents.begin(); m != constituents.end(); ++m) { reco::CandidatePtr constit = *m; - if (constit->pt() == 0) { + if (constit.isNull() || constit->pt() <= std::numeric_limits::epsilon()) { edm::LogWarning("NullTransverseMomentum") << "dropping input candidate with pt=0"; continue; } @@ -423,8 +425,10 @@ void TemplatedSecondaryVertexProducer::produce(edm::Event &event, con << "TemplatedSecondaryVertexProducer: No weights (e.g. PUPPI) given for weighted jet collection" << std::endl; float w = (*weightsHandle)[constit]; - fjInputs.push_back( - fastjet::PseudoJet(constit->px() * w, constit->py() * w, constit->pz() * w, constit->energy() * w)); + if (w > 0) { + fjInputs.push_back( + fastjet::PseudoJet(constit->px() * w, constit->py() * w, constit->pz() * w, constit->energy() * w)); + } } else { fjInputs.push_back(fastjet::PseudoJet(constit->px(), constit->py(), constit->pz(), constit->energy())); }