From 36effa537392cfb47f544819831213a2dd29ff9e Mon Sep 17 00:00:00 2001 From: francescobrivio Date: Mon, 29 Apr 2024 18:32:07 +0200 Subject: [PATCH] add check on PATLeptonTimeLifeInfoProducer closestState valid state --- .../PatAlgos/plugins/PATLeptonTimeLifeInfoProducer.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/PhysicsTools/PatAlgos/plugins/PATLeptonTimeLifeInfoProducer.cc b/PhysicsTools/PatAlgos/plugins/PATLeptonTimeLifeInfoProducer.cc index 2e41063e3f298..9b8f4f8450254 100644 --- a/PhysicsTools/PatAlgos/plugins/PATLeptonTimeLifeInfoProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATLeptonTimeLifeInfoProducer.cc @@ -12,6 +12,7 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/Common/interface/ValueMap.h" #include "DataFormats/PatCandidates/interface/Electron.h" @@ -169,6 +170,14 @@ void PATLeptonTimeLifeInfoProducer::produceAndFillIPInfo(const T& lepton, AnalyticalImpactPointExtrapolator extrapolator(transTrack.field()); TrajectoryStateOnSurface closestState = extrapolator.extrapolate(transTrack.impactPointState(), RecoVertex::convertPos(pv.position())); + if (!closestState.isValid()) { + edm::LogError("PATLeptonTimeLifeInfoProducer") + << "closestState not valid! From:\n" + << "transTrack.impactPointState():\n" + << transTrack.impactPointState() << "RecoVertex::convertPos(pv.position()):\n" + << RecoVertex::convertPos(pv.position()); + return; + } GlobalPoint pca = closestState.globalPosition(); GlobalError pca_cov = closestState.cartesianError().position(); GlobalVector ip_vec = GlobalVector(pca.x() - pv.x(), pca.y() - pv.y(), pca.z() - pv.z());