From b3542f076a68ea587b972962dc55522d8774e2c9 Mon Sep 17 00:00:00 2001 From: Nicola Amapane Date: Mon, 8 Jul 2024 09:57:52 +0200 Subject: [PATCH] Add a protection for pathologic cases in MuonBeamspotConstraintValueMapProducer --- .../MuonBeamspotConstraintValueMapProducer.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/RecoMuon/GlobalTrackingTools/plugins/MuonBeamspotConstraintValueMapProducer.cc b/RecoMuon/GlobalTrackingTools/plugins/MuonBeamspotConstraintValueMapProducer.cc index 2143380680af0..74459f475cb0c 100644 --- a/RecoMuon/GlobalTrackingTools/plugins/MuonBeamspotConstraintValueMapProducer.cc +++ b/RecoMuon/GlobalTrackingTools/plugins/MuonBeamspotConstraintValueMapProducer.cc @@ -14,6 +14,7 @@ #include "TrackingTools/TransientTrack/interface/TransientTrack.h" #include "RecoVertex/KalmanVertexFit/interface/SingleTrackVertexConstraint.h" #include "DataFormats/VertexReco/interface/Vertex.h" +#include "RecoVertex/VertexPrimitives/interface/VertexException.h" class MuonBeamspotConstraintValueMapProducer : public edm::global::EDProducer<> { public: @@ -86,13 +87,17 @@ class MuonBeamspotConstraintValueMapProducer : public edm::global::EDProducer<> auto pv = pvHandle->at(0); VertexState pvs = VertexState(GlobalPoint(Basic3DVector(pv.position())), GlobalError(pv.covariance())); - SingleTrackVertexConstraint::BTFtuple btft = stvc.constrain(ttkb->build(muon.muonBestTrack()), pvs); - if (std::get<0>(btft)) { - const reco::Track& trkBS = std::get<1>(btft).track(); - pts.push_back(trkBS.pt()); - ptErrs.push_back(trkBS.ptError()); - chi2s.push_back(std::get<2>(btft)); - tbd = false; + try { + SingleTrackVertexConstraint::BTFtuple btft = stvc.constrain(ttkb->build(muon.muonBestTrack()), pvs); + if (std::get<0>(btft)) { + const reco::Track& trkBS = std::get<1>(btft).track(); + pts.push_back(trkBS.pt()); + ptErrs.push_back(trkBS.ptError()); + chi2s.push_back(std::get<2>(btft)); + tbd = false; + } + } catch (const VertexException& exc) { + // Update failed; give up. } } }