From 9deb5000b6c80eca9219c588434bdd1914ac37ea Mon Sep 17 00:00:00 2001
From: John Baines <john.baines@cern.ch>
Date: Fri, 23 Feb 2018 18:36:27 +0100
Subject: [PATCH] disable unused ToolHandles in FTK instance

Former-commit-id: 71063ad6e7183ec73dd4a9c5cb3424fe9c75b76c
---
 .../python/TrigFastTrackFinder_Config.py      | 17 +++++++------
 .../src/TrigFastTrackFinder.cxx               | 25 +++++++++++++------
 2 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/Trigger/TrigAlgorithms/TrigFastTrackFinder/python/TrigFastTrackFinder_Config.py b/Trigger/TrigAlgorithms/TrigFastTrackFinder/python/TrigFastTrackFinder_Config.py
index ae09a7de2e6..ce8b28eb739 100755
--- a/Trigger/TrigAlgorithms/TrigFastTrackFinder/python/TrigFastTrackFinder_Config.py
+++ b/Trigger/TrigAlgorithms/TrigFastTrackFinder/python/TrigFastTrackFinder_Config.py
@@ -408,6 +408,16 @@ class TrigFastTrackFinderBase(TrigFastTrackFinder):
                                 TrigFastTrackFinder_OnlineMonitoring("TrigFastTrackFinder_OnlineMonitoring", self.doResMon),
                                 timeHist ]
 
+
+        from TrigInDetConf.TrigInDetRecCommonTools import InDetTrigFastTrackSummaryTool
+        self.TrackSummaryTool = InDetTrigFastTrackSummaryTool
+
+        if self.doResMon:
+            from TrigInDetTrackFitter.TrigInDetTrackFitterConf import TrigL2ResidualCalculator
+            resCalc = TrigL2ResidualCalculator(OfflineClusters=False)
+            ToolSvc += resCalc
+            self.TrigL2ResidualCalculator = resCalc
+
         if type=="FTK" or type=="FTKRefit":
           from TrigFTK_RecExample.TrigFTKLoadTools import theFTK_DataProviderSvc
           self.FTK_DataProviderSvc = theFTK_DataProviderSvc
@@ -527,17 +537,10 @@ class TrigFastTrackFinderBase(TrigFastTrackFinder):
           TrackMaker_FTF.InputClusterContainerName = ""
           TrackMaker_FTF.InputHadClusterContainerName = ""
           
-          from TrigInDetConf.TrigInDetRecCommonTools import InDetTrigFastTrackSummaryTool
-          self.TrackSummaryTool = InDetTrigFastTrackSummaryTool
-
           if remapped_type == "tauCore":
             from TrigInDetConf.TrigInDetRecCommonTools import InDetTrigTrackSummaryToolWithHoleSearch
             self.TrackSummaryTool = InDetTrigTrackSummaryToolWithHoleSearch
 
-          from TrigInDetTrackFitter.TrigInDetTrackFitterConf import TrigL2ResidualCalculator
-          resCalc = TrigL2ResidualCalculator(OfflineClusters=False)
-          ToolSvc += resCalc
-          self.TrigL2ResidualCalculator = resCalc
           self.doCloneRemoval = InDetTrigSliceSettings[('doCloneRemoval',remapped_type)]
 
 
diff --git a/Trigger/TrigAlgorithms/TrigFastTrackFinder/src/TrigFastTrackFinder.cxx b/Trigger/TrigAlgorithms/TrigFastTrackFinder/src/TrigFastTrackFinder.cxx
index 871657b172b..72e01c92456 100644
--- a/Trigger/TrigAlgorithms/TrigFastTrackFinder/src/TrigFastTrackFinder.cxx
+++ b/Trigger/TrigAlgorithms/TrigFastTrackFinder/src/TrigFastTrackFinder.cxx
@@ -283,7 +283,7 @@ HLT::ErrorCode TrigFastTrackFinder::hltInitialize() {
     m_CombTrackingTimer         = addTimer("CmbTrack","CmbTrack_nTr");
     m_TrackFitterTimer          = addTimer("TrackFitter","TrackFitter_nTracks");
   }
-
+  
   if(m_ftkMode) {
     StatusCode sc= m_ftkDataProviderSvc.retrieve();
     if(sc.isFailure()) {
@@ -292,13 +292,15 @@ HLT::ErrorCode TrigFastTrackFinder::hltInitialize() {
     } else {
       ATH_MSG_INFO("Configured to retrieve FTK tracks from " << m_ftkDataProviderSvcName);
     }
+    m_numberingTool.disable();
+    m_spacePointTool.disable();
+    m_TrigL2SpacePointTruthTool.disable();
+    m_trackMaker.disable();   
+    m_trigInDetTrackFitter.disable();
+    m_trigZFinder.disable();
+
   } else {
 
-    StatusCode sc= m_trackSummaryTool.retrieve();
-    if(sc.isFailure()) {
-      ATH_MSG_ERROR("unable to locate track summary tool");
-      return HLT::BAD_JOB_SETUP;
-    }
     
     ATH_MSG_DEBUG(" TrigFastTrackFinder : MinHits set to " << m_minHits);
     
@@ -310,7 +312,7 @@ HLT::ErrorCode TrigFastTrackFinder::hltInitialize() {
       }
     }
     
-    sc=m_numberingTool.retrieve(); 
+    StatusCode sc=m_numberingTool.retrieve(); 
     if(sc.isFailure()) { 
       ATH_MSG_ERROR("Could not retrieve "<<m_numberingTool); 
       return HLT::BAD_JOB_SETUP;
@@ -354,13 +356,22 @@ HLT::ErrorCode TrigFastTrackFinder::hltInitialize() {
         ATH_MSG_INFO("Configured to retrieve FTK tracks from " << m_ftkDataProviderSvcName);
       }
     }
+  }
 
+  StatusCode sc= m_trackSummaryTool.retrieve();
+  if(sc.isFailure()) {
+    ATH_MSG_ERROR("unable to locate track summary tool");
+    return HLT::BAD_JOB_SETUP;
+  }
 
+  if (m_doResMonitoring) {
     sc = m_trigL2ResidualCalculator.retrieve();
     if ( sc.isFailure() ) {
       msg() << MSG::FATAL <<"Unable to locate Residual calculator tool " << m_trigL2ResidualCalculator << endmsg;
       return HLT::BAD_JOB_SETUP;
     }
+  } else {
+    m_trigL2ResidualCalculator.disable();
   }
 
   //Get ID helper
-- 
GitLab