From 9b8742ac4f18fa84d897288a8849436e96d8766a Mon Sep 17 00:00:00 2001
From: Christian Grefe <christian.grefe@cern.ch>
Date: Fri, 7 Feb 2020 17:29:19 +0100
Subject: [PATCH] Add missing explicit initialisation of TRT_ToT_dEdx

---
 .../preInclude.FastTRT_Digi.Validation.py     |  7 ++++
 .../InDetRecExample/python/TrackingCommon.py  | 36 ++++++++++---------
 .../share/ConfiguredLowBetaFinder.py          |  2 ++
 .../InDetLowBetaFinder/src/LowBetaAlg.cxx     |  2 +-
 4 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/InnerDetector/InDetDigitization/FastTRT_Digitization/share/preInclude.FastTRT_Digi.Validation.py b/InnerDetector/InDetDigitization/FastTRT_Digitization/share/preInclude.FastTRT_Digi.Validation.py
index 1613a0a6dc3..29dbc3c3a7a 100644
--- a/InnerDetector/InDetDigitization/FastTRT_Digitization/share/preInclude.FastTRT_Digi.Validation.py
+++ b/InnerDetector/InDetDigitization/FastTRT_Digitization/share/preInclude.FastTRT_Digi.Validation.py
@@ -21,10 +21,17 @@ InDetTRT_LocalOccupancy = InDet__TRT_LocalOccupancy( name = "InDet_TRT_LocalOccu
                                                      TRTStrawStatusSummaryTool = InDetTRTStrawStatusSummaryTool )
 ToolSvc += InDetTRT_LocalOccupancy
 
+from TRT_ElectronPidTools.TRT_ElectronPidToolsConf import TRT_ToT_dEdx
+InDetTRT_ToT_dEdx = TRT_ToT_dEdx( name = "InDet_TRT_ToT_dEdx",
+                                  TRTStrawSummaryTool = InDetTRTStrawStatusSummaryTool,
+                                  TRT_LocalOccupancyTool = InDetTRT_LocalOccupancy )                                      
+ToolSvc += InDetTRT_ToT_dEdx
+
 from TRT_ElectronPidTools.TRT_ElectronPidToolsConf import InDet__TRT_ElectronPidToolRun2
 InDetTRT_ElectronPidTool = InDet__TRT_ElectronPidToolRun2( name = "InDetTRT_ElectronPidTool",
                                                            TRT_LocalOccupancyTool = InDetTRT_LocalOccupancy,
                                                            TRTStrawSummaryTool       = InDetTRTStrawStatusSummaryTool,
+                                                           TRT_ToT_dEdx_Tool = InDetTrigTRT_ToT_dEdx,
                                                            isData = (globalflags.DataSource == 'data') )
 ToolSvc += InDetTRT_ElectronPidTool
 
diff --git a/InnerDetector/InDetExample/InDetRecExample/python/TrackingCommon.py b/InnerDetector/InDetExample/InDetRecExample/python/TrackingCommon.py
index 591e8726b9d..3651d2f3863 100644
--- a/InnerDetector/InDetExample/InDetRecExample/python/TrackingCommon.py
+++ b/InnerDetector/InDetExample/InDetRecExample/python/TrackingCommon.py
@@ -896,44 +896,46 @@ def getInDetTRT_LocalOccupancy(name ="InDet_TRT_LocalOccupancy", **kwargs) :
     return InDet__TRT_LocalOccupancy(name=the_name, **setDefaults( kwargs, isTrigger = False) )
 
 @makePublicTool
-def getInDetTRT_ElectronPidTool(name = "InDetTRT_ElectronPidTool", **kwargs) :
+def getInDetTRT_dEdxTool(name = "InDetTRT_dEdxTool", **kwargs) :
     the_name = makeName( name, kwargs)
     from AthenaCommon.DetFlags import DetFlags
     from InDetRecExample.InDetJobProperties import InDetFlags
-    if not DetFlags.haveRIO.TRT_on() or  InDetFlags.doSLHC() or  InDetFlags.doHighPileup() \
+    if not DetFlags.haveRIO.TRT_on() or InDetFlags.doSLHC() or InDetFlags.doHighPileup() \
             or  InDetFlags.useExistingTracksAsInput(): # TRT_RDOs (used by the TRT_LocalOccupancy tool) are not present in ESD
         return None
-
-    if 'TRTStrawSummaryTool' not in kwargs :
-        kwargs = setDefaults( kwargs, TRTStrawSummaryTool = getInDetTRTStrawStatusSummaryTool())
+    
+    from AthenaCommon.GlobalFlags import globalflags
+    kwargs = setDefaults( kwargs, TRT_dEdx_isData = (globalflags.DataSource == 'data'))
 
     if 'TRT_LocalOccupancyTool' not in kwargs :
         kwargs = setDefaults( kwargs, TRT_LocalOccupancyTool = getInDetTRT_LocalOccupancy())
 
-    from AthenaCommon.GlobalFlags import globalflags
-    kwargs = setDefaults( kwargs, isData = (globalflags.DataSource == 'data'))
-
-    from TRT_ElectronPidTools.TRT_ElectronPidToolsConf import InDet__TRT_ElectronPidToolRun2
-    return InDet__TRT_ElectronPidToolRun2(name = the_name, **kwargs)
+    from TRT_ElectronPidTools.TRT_ElectronPidToolsConf import TRT_ToT_dEdx
+    return TRT_ToT_dEdx(name = the_name, **kwargs)
 
 @makePublicTool
-def getInDetTRT_dEdxTool(name = "InDetTRT_dEdxTool", **kwargs) :
+def getInDetTRT_ElectronPidTool(name = "InDetTRT_ElectronPidTool", **kwargs) :
     the_name = makeName( name, kwargs)
     from AthenaCommon.DetFlags import DetFlags
     from InDetRecExample.InDetJobProperties import InDetFlags
-    if not DetFlags.haveRIO.TRT_on() or InDetFlags.doSLHC() or InDetFlags.doHighPileup() \
+    if not DetFlags.haveRIO.TRT_on() or  InDetFlags.doSLHC() or  InDetFlags.doHighPileup() \
             or  InDetFlags.useExistingTracksAsInput(): # TRT_RDOs (used by the TRT_LocalOccupancy tool) are not present in ESD
         return None
-    
-    from AthenaCommon.GlobalFlags import globalflags
-    kwargs = setDefaults( kwargs, TRT_dEdx_isData = (globalflags.DataSource == 'data'))
+
+    if 'TRTStrawSummaryTool' not in kwargs :
+        kwargs = setDefaults( kwargs, TRTStrawSummaryTool = getInDetTRTStrawStatusSummaryTool())
 
     if 'TRT_LocalOccupancyTool' not in kwargs :
         kwargs = setDefaults( kwargs, TRT_LocalOccupancyTool = getInDetTRT_LocalOccupancy())
 
-    from TRT_ElectronPidTools.TRT_ElectronPidToolsConf import TRT_ToT_dEdx
-    return TRT_ToT_dEdx(name = the_name, **kwargs)
+    if 'TRT_ToT_dEdx_Tool' not in kwargs :
+        kwargs = setDefaults( kwargs, TRT_ToT_dEdx_Tool = getInDetTRT_dEdxTool())
+        
+    from AthenaCommon.GlobalFlags import globalflags
+    kwargs = setDefaults( kwargs, isData = (globalflags.DataSource == 'data'))
 
+    from TRT_ElectronPidTools.TRT_ElectronPidToolsConf import InDet__TRT_ElectronPidToolRun2
+    return InDet__TRT_ElectronPidToolRun2(name = the_name, **kwargs)
 
 @makePublicTool
 def getInDetSummaryHelper(name='InDetSummaryHelper',**kwargs) :
diff --git a/InnerDetector/InDetExample/InDetRecExample/share/ConfiguredLowBetaFinder.py b/InnerDetector/InDetExample/InDetRecExample/share/ConfiguredLowBetaFinder.py
index ef8590a90f8..aa1984b6bf2 100644
--- a/InnerDetector/InDetExample/InDetRecExample/share/ConfiguredLowBetaFinder.py
+++ b/InnerDetector/InDetExample/InDetRecExample/share/ConfiguredLowBetaFinder.py
@@ -12,6 +12,7 @@ class ConfiguredLowBetaFinder:
     def __init__(self, InputCollection=None, IsSimulation=False, unslimmed_tracks_container="CombinedInDetTracks"):
         from AthenaCommon.AlgSequence import AlgSequence
         topSequence = AlgSequence()
+        from InDetRecExample.TrackingCommon import getInDetTRT_dEdxTool
         from InDetLowBetaFinder.InDetLowBetaFinderConf import InDet__LowBetaAlg
         InDetLowBetaTrkAlgorithm = InDet__LowBetaAlg( name                   = "InDetLowBetaTrkAlgorithm",
                                                       MinimumTRThitsForIDpid = 5,
@@ -22,6 +23,7 @@ class ConfiguredLowBetaFinder:
                                                       CSMP_Rcorrection_One   = -3.0,
                                                       CSMP_Rcorrection_Two   = 0.0,
                                                       CSMP_TimingOffset      =  0.0,
+                                                      TRT_ToT_dEdx_Tool      = getInDetTRT_dEdxTool(),
                                                       MC_flag                = IsSimulation)
 
         topSequence += InDetLowBetaTrkAlgorithm
diff --git a/InnerDetector/InDetRecAlgs/InDetLowBetaFinder/src/LowBetaAlg.cxx b/InnerDetector/InDetRecAlgs/InDetLowBetaFinder/src/LowBetaAlg.cxx
index be3c2c9be1a..cb1db3a294b 100644
--- a/InnerDetector/InDetRecAlgs/InDetLowBetaFinder/src/LowBetaAlg.cxx
+++ b/InnerDetector/InDetRecAlgs/InDetLowBetaFinder/src/LowBetaAlg.cxx
@@ -45,7 +45,7 @@ namespace InDet
     m_trtconddbsvc("TRT_CalDbSvc",name),
     m_fieldServiceHandle("AtlasFieldSvc",name),
     m_TrtTool(0),
-    m_TRTdEdxTool("TRT_ToT_dEdx"),
+    m_TRTdEdxTool(),
     m_TrtToolsSuccess{},
     m_TrtToolInitSuccess{}
   {
-- 
GitLab