From bebb3523a565cacbd1b2df8fbfdd0ebb79d55d60 Mon Sep 17 00:00:00 2001
From: tstreble <thomas.strebler@cern.ch>
Date: Wed, 4 Dec 2024 19:54:29 +0100
Subject: [PATCH] Add protection against bad perigee in GlobalChi2Fitter
 (ATLASRECTS-8078)

---
 .../TrkGlobalChi2Fitter/src/GlobalChi2Fitter.cxx     | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/Tracking/TrkFitter/TrkGlobalChi2Fitter/src/GlobalChi2Fitter.cxx b/Tracking/TrkFitter/TrkGlobalChi2Fitter/src/GlobalChi2Fitter.cxx
index 3bbe33b76ff6..41f46ebc1dbf 100644
--- a/Tracking/TrkFitter/TrkGlobalChi2Fitter/src/GlobalChi2Fitter.cxx
+++ b/Tracking/TrkFitter/TrkGlobalChi2Fitter/src/GlobalChi2Fitter.cxx
@@ -7267,12 +7267,20 @@ namespace Trk {
        */
       double dist = (beg.trackParameters()->position() - end.trackParameters()->position()).norm();
 
+      bool zStartValid = std::abs(beg.trackParameters()->position().z())<10000.;
+      if(!zStartValid){
+	ATH_MSG_DEBUG("Pathological track parameter well outside of detector");
+	ATH_MSG_DEBUG("Propagator might have issue with this, skipping");
+	ATH_MSG_VERBOSE("dumping track parameters " << *(beg.trackParameters()));
+      }
+
       /*
        * Only proceed to count holes if we have seen a measurement before (this
        * may include the starting track state, if it is a measurement) and the
-       * distance between start and end is at least 2.5 millimeters.
+       * distance between start and end is at least 2.5 millimeters
+       * and the z position is valid
        */
-      if (seen_meas && dist >= 2.5) {
+      if (seen_meas && dist >= 2.5 && zStartValid) {
         /*
          * First, we retrieve the hole data stored in the beginning state. Note
          * that this may very well be non-extant, but it is possible for the
-- 
GitLab