From 3ffaafeb41405a0fea195435188d5699ce3399a8 Mon Sep 17 00:00:00 2001
From: Salvador Marti I Garcia <salvador.marti@cern.ch>
Date: Tue, 9 Jan 2024 13:11:32 +0100
Subject: [PATCH 1/2] IDPerfMonZmumu: initialize track refit only when
 necessary

---
 .../src/IDPerfMonZmumu.cxx                    | 49 ++++++++++---------
 1 file changed, 25 insertions(+), 24 deletions(-)

diff --git a/InnerDetector/InDetMonitoring/InDetPerformanceMonitoring/src/IDPerfMonZmumu.cxx b/InnerDetector/InDetMonitoring/InDetPerformanceMonitoring/src/IDPerfMonZmumu.cxx
index ba5d26005be5..95ce7147170b 100755
--- a/InnerDetector/InDetMonitoring/InDetPerformanceMonitoring/src/IDPerfMonZmumu.cxx
+++ b/InnerDetector/InDetMonitoring/InDetPerformanceMonitoring/src/IDPerfMonZmumu.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 //==================================================================================
@@ -182,31 +182,32 @@ StatusCode IDPerfMonZmumu::initialize()
       }
   }
 
-  // Retrieve fitter
-  if (m_TrackRefitter1.retrieve().isSuccess()) {
-    ATH_MSG_INFO("Retrieved tool m_TrackRefitter1: " << m_TrackRefitter1 << " SUCCESS ");
-  } 
-  else {
-    ATH_MSG_FATAL("Unable to retrieve m_TrackRefitter1 " << m_TrackRefitter1 << " FAILURE ");
-    return StatusCode::FAILURE;
-  }
-
-  // Retrieve the second fitter
-  if (m_TrackRefitter2.retrieve().isSuccess()) {
-    ATH_MSG_INFO("Retrieved tool m_TrackRefitter2: " << m_TrackRefitter2 << " SUCCESS ");
-  } 
-  else {
-    ATH_MSG_FATAL("Unable to retrieve m_TrackRefitter2 " << m_TrackRefitter2 << " FAILURE ");
-    return StatusCode::FAILURE;
-  }
+  // Retrieve Track fitter and track to vertex
+  if (m_doRefit) { // only if track refit is requested
+    if (m_TrackRefitter1.retrieve().isSuccess()) {
+      ATH_MSG_INFO("Retrieved tool m_TrackRefitter1: " << m_TrackRefitter1 << " SUCCESS ");
+    } 
+    else {
+      ATH_MSG_FATAL("Unable to retrieve m_TrackRefitter1 " << m_TrackRefitter1 << " FAILURE ");
+      return StatusCode::FAILURE;
+    }
 
+    // Retrieve the second fitter
+    if (m_TrackRefitter2.retrieve().isSuccess()) {
+      ATH_MSG_INFO("Retrieved tool m_TrackRefitter2: " << m_TrackRefitter2 << " SUCCESS ");
+    } 
+    else {
+      ATH_MSG_FATAL("Unable to retrieve m_TrackRefitter2 " << m_TrackRefitter2 << " FAILURE ");
+      return StatusCode::FAILURE;
+    }
 
-  if (m_trackToVertexTool.retrieve().isSuccess()) {
-    ATH_MSG_INFO("Retrieved tool m_trackToVertexTool " << m_trackToVertexTool << " SUCCESS ");
-  } 
-  else {
-    ATH_MSG_FATAL("Unable to retrieve m_trackToVertexTool " << m_trackToVertexTool << " FAILURE ");
-    return StatusCode::FAILURE;
+    if (m_trackToVertexTool.retrieve().isSuccess()) {
+      ATH_MSG_INFO("Retrieved tool m_trackToVertexTool " << m_trackToVertexTool << " SUCCESS ");
+    } 
+    else {
+      ATH_MSG_FATAL("Unable to retrieve m_trackToVertexTool " << m_trackToVertexTool << " FAILURE ");
+      return StatusCode::FAILURE;
+    }
   }
 
   if(m_useTrackSelectionTool){
-- 
GitLab


From 3afc70a2cf270491e742934e2cae03b24831c859 Mon Sep 17 00:00:00 2001
From: Salvador Marti I Garcia <salvador.marti@cern.ch>
Date: Tue, 9 Jan 2024 13:20:26 +0100
Subject: [PATCH 2/2] IDPerfMonZmumu: initialize extrapolator only when
 necessary

---
 .../InDetPerformanceMonitoring/src/IDPerfMonZmumu.cxx           | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/InnerDetector/InDetMonitoring/InDetPerformanceMonitoring/src/IDPerfMonZmumu.cxx b/InnerDetector/InDetMonitoring/InDetPerformanceMonitoring/src/IDPerfMonZmumu.cxx
index 95ce7147170b..57fce31c1794 100755
--- a/InnerDetector/InDetMonitoring/InDetPerformanceMonitoring/src/IDPerfMonZmumu.cxx
+++ b/InnerDetector/InDetMonitoring/InDetPerformanceMonitoring/src/IDPerfMonZmumu.cxx
@@ -232,7 +232,7 @@ StatusCode IDPerfMonZmumu::initialize()
 
   ATH_CHECK (m_EventInfoKey.initialize());   // initializing the eventInfo "accessor"
 
-  ATH_CHECK (m_extrapolator.retrieve());
+  if (m_isMC) ATH_CHECK (m_extrapolator.retrieve()); // this is only used for the truth particles
   
   ATH_CHECK (m_vertexKey.initialize());
   
-- 
GitLab