From 0e5ec0da92f288dfa85e7da7a6101499ace34da5 Mon Sep 17 00:00:00 2001
From: scott snyder <snyder@bnl.gov>
Date: Wed, 24 Mar 2021 03:14:58 +0100
Subject: [PATCH] TrkEventTPCnv: Work around isSane() failue.

Just like for materialEffects, in some saved tracks the measurement
object also can trip isSane().  This happens, for example,
in the MuonCombineConfig unit test.  Work around by effectively bypassing
the isSane() test here in the same way we did for materialEffects.
---
 .../src/TrkTrack/TrackStateOnSurfaceCnv_p3.cxx   | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/Tracking/TrkEventCnv/TrkEventTPCnv/src/TrkTrack/TrackStateOnSurfaceCnv_p3.cxx b/Tracking/TrkEventCnv/TrkEventTPCnv/src/TrkTrack/TrackStateOnSurfaceCnv_p3.cxx
index ed3ec43f17d1..9eefdcc7bbcf 100644
--- a/Tracking/TrkEventCnv/TrkEventTPCnv/src/TrkTrack/TrackStateOnSurfaceCnv_p3.cxx
+++ b/Tracking/TrkEventCnv/TrkEventTPCnv/src/TrkTrack/TrackStateOnSurfaceCnv_p3.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //-----------------------------------------------------------------------------
@@ -32,17 +32,19 @@ persToTrans( const Trk::TrackStateOnSurface_p3 *persObj, Trk::TrackStateOnSurfac
   const Trk::MaterialEffectsBase* materialEffects = createTransFromPStore( &matBaseCnv, persObj->m_materialEffects, log );
 
   // There were some tracks saved that violate the isSane test in
-  // TrackStateOnSurface.  If we were to pass materialEffects to this ctor
-  // then we would trip that assertion.  However, we want to preserve
-  // the previous behavior of the tp converters, which did allow reading
-  // such tracks.  So defer setting the material pointer until
-  // after the checks,
-  *transObj = Trk::TrackStateOnSurface (meas,
+  // TrackStateOnSurface.  If we were to pass meas or materialEffects
+  // to this ctor then we would trip that assertion.  However,
+  // we want to preserve the previous behavior of the TP converters,
+  // which did allow reading  such tracks.  So defer setting these pointers
+  // until after the checks,
+  *transObj = Trk::TrackStateOnSurface (nullptr,
                                         trackParameters,
                                         fitQoS,
                                         nullptr,
                                         persObj->m_typeFlags);
+  transObj->m_measurementOnTrack = meas;
   transObj->m_materialEffectsOnTrack = materialEffects;
+  transObj->setFlags();
 }
 
 
-- 
GitLab