From 9a2e40f3b4287f336900df6c0bc84410760877d6 Mon Sep 17 00:00:00 2001 From: francescobrivio Date: Mon, 29 Apr 2024 18:32:07 +0200 Subject: [PATCH 1/2] 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()); From e2dd018e1a453ad1b0ba1f634a2382190202d9f7 Mon Sep 17 00:00:00 2001 From: francescobrivio Date: Tue, 30 Apr 2024 12:28:18 +0200 Subject: [PATCH 2/2] Propagate downstream the valid state check in PATLeptonTimeLifeInfoProducer --- .../PatAlgos/plugins/PATLeptonTimeLifeInfoProducer.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/PATLeptonTimeLifeInfoProducer.cc b/PhysicsTools/PatAlgos/plugins/PATLeptonTimeLifeInfoProducer.cc index 9b8f4f8450254..978aa180c3252 100644 --- a/PhysicsTools/PatAlgos/plugins/PATLeptonTimeLifeInfoProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATLeptonTimeLifeInfoProducer.cc @@ -162,9 +162,6 @@ void PATLeptonTimeLifeInfoProducer::produceAndFillIPInfo(const T& lepton, TrackTimeLifeInfo& info) { const reco::Track* track = getTrack(lepton); if (track != nullptr) { - info.setTrack(track); - info.setBField_z(transTrackBuilder.field()->inInverseGeV(GlobalPoint(track->vx(), track->vy(), track->vz())).z()); - // Extrapolate track to the point closest to PV reco::TransientTrack transTrack = transTrackBuilder.build(track); AnalyticalImpactPointExtrapolator extrapolator(transTrack.field()); @@ -187,7 +184,9 @@ void PATLeptonTimeLifeInfoProducer::produceAndFillIPInfo(const T& lepton, if (ip_vec.dot(GlobalVector(lepton.px(), lepton.py(), lepton.pz())) < 0) ip_mes = Measurement1D(-1. * ip_mes.value(), ip_mes.error()); - // Store PCA info + // Store Track and PCA info + info.setTrack(track); + info.setBField_z(transTrackBuilder.field()->inInverseGeV(GlobalPoint(track->vx(), track->vy(), track->vz())).z()); info.setPCA(pca, pca_cov); info.setIP(ip_vec, ip_cov); info.setIPLength(ip_mes);