From dbc2e2acff5ad173cd6d1ee0f9f253269f68e36c Mon Sep 17 00:00:00 2001
From: Sergi Rodriguez <Sergi.Rodriguez@cern.ch>
Date: Wed, 14 Feb 2024 11:41:00 +0100
Subject: [PATCH] updating python config and used classes

---
 .../TRT_CalibAlgs/TRTCalibrationMgr.h         |  5 +-
 .../python/TRTCalibrationMgrConfig.py         |  7 ++-
 .../TRT_CalibAlgs/src/TRTCalibrationMgr.cxx   |  6 +--
 .../TRT_CalibTools/src/FillAlignTRTHits.cxx   | 10 ++--
 .../TRT_CalibTools/src/FillAlignTRTHits.h     | 10 ++--
 .../python/TRT_ConditionsServicesConfig.py    | 46 +++++++++++--------
 6 files changed, 48 insertions(+), 36 deletions(-)

diff --git a/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/TRT_CalibAlgs/TRTCalibrationMgr.h b/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/TRT_CalibAlgs/TRTCalibrationMgr.h
index 2ae39b0305d9..0f103460c443 100755
--- a/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/TRT_CalibAlgs/TRTCalibrationMgr.h
+++ b/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/TRT_CalibAlgs/TRTCalibrationMgr.h
@@ -22,6 +22,8 @@
 #include "TRT_ConditionsData/StrawT0MultChanContainer.h"
 #include "CxxUtils/checker_macros.h"
 
+#include "TRT_CalibTools/IFillAlignTrkInfo.h"
+
 
 namespace TRT{
   class TrackInfo;
@@ -31,7 +33,6 @@ namespace Trk{
  class ITrackSelectorTool;
  class ITrackFitter;
 }
-class IFillAlignTrkInfo;
 class IAccumulator;
 class IFitTool;
 
@@ -78,7 +79,7 @@ public:
 private:
 
     // Tools for the algorithm
-    ToolHandleArray<IFillAlignTrkInfo> m_TrackInfoTools ;
+    ToolHandleArray<IFillAlignTrkInfo> m_TrackInfoTools {this, "AlignTrkTools", {}, ""};
     PublicToolHandleArray<ITRTCalibrator> m_TRTCalibTools {this, "TRTCalibrator", {}, ""};
     ToolHandleArray<IFitTool> m_FitTools;
     ToolHandle<Trk::ITrackFitter> m_trackFitter;
diff --git a/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/python/TRTCalibrationMgrConfig.py b/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/python/TRTCalibrationMgrConfig.py
index 2c9f5df1681c..ce5246892570 100644
--- a/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/python/TRTCalibrationMgrConfig.py
+++ b/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/python/TRTCalibrationMgrConfig.py
@@ -37,11 +37,10 @@ def FillAlignTRTHitsCfg(flags,name='FillAlignTRTHits',**kwargs) :
     
     AlignTRTHits.minTimebinsOverThreshold = 0
     
-    from TRT_ConditionsServices.TRT_ConditionsServicesConfig import TRT_CalDbToolCfg
-    AlignTRTHits.TRTCalDbTool = acc.popToolsAndMerge(TRT_CalDbToolCfg(flags))
-    
-    from TRT_ConditionsServices.TRT_ConditionsServicesConfig import TRT_StrawStatusSummaryToolCfg
+    from TRT_ConditionsServices.TRT_ConditionsServicesConfig import TRT_CalDbToolCfg, TRT_StrawStatusSummaryToolCfg, TRT_StrawNeighbourSvcCfg
+    AlignTRTHits.TRTCalDbTool        = acc.popToolsAndMerge(TRT_CalDbToolCfg(flags))
     AlignTRTHits.TRTStrawSummaryTool = acc.popToolsAndMerge(TRT_StrawStatusSummaryToolCfg(flags))
+    AlignTRTHits.NeighbourSvc        = acc.popToolsAndMerge(TRT_StrawNeighbourSvcCfg(flags))
     
     acc.setPrivateTools(AlignTRTHits)
     
diff --git a/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/src/TRTCalibrationMgr.cxx b/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/src/TRTCalibrationMgr.cxx
index d54e9d7a0e7e..9e582ad9762e 100644
--- a/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/src/TRTCalibrationMgr.cxx
+++ b/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/src/TRTCalibrationMgr.cxx
@@ -27,7 +27,7 @@
 
 TRTCalibrationMgr::TRTCalibrationMgr(const std::string& name, ISvcLocator* pSvcLocator) :
 	AthAlgorithm   (name, pSvcLocator),
-	m_TrackInfoTools(),
+	// m_TrackInfoTools(),
 	m_FitTools(),
 	m_trackFitter("Trk::KalmanFitter/TrkKalmanFitter"),
     m_trackSelector("InDet::InDetTrackSelectorTool/InDetTrackSelectorTool"),
@@ -36,12 +36,12 @@ TRTCalibrationMgr::TRTCalibrationMgr(const std::string& name, ISvcLocator* pSvcL
     m_par_rtcontainerkey("/TRT/Calib/RT"),
     m_par_t0containerkey("/TRT/Calib/T0")
 {
-	m_TrackInfoTools.push_back("FillAlignTrkInfo");
+	// m_TrackInfoTools.push_back("FillAlignTrkInfo");
 	m_TRTCalibTools.push_back("TRTCalibrator");
 	m_FitTools.push_back("FitTool");
 	// declare algorithm parameters
 	declareProperty("StreamTool", m_streamer);
-	declareProperty("AlignTrkTools",m_TrackInfoTools);
+	// declareProperty("AlignTrkTools",m_TrackInfoTools);
 	declareProperty("FitTools",m_FitTools);
 	declareProperty("Max_ntrk",m_max_ntrk);
 	declareProperty("TrackFitter", m_trackFitter);
diff --git a/InnerDetector/InDetCalibTools/TRT_CalibTools/src/FillAlignTRTHits.cxx b/InnerDetector/InDetCalibTools/TRT_CalibTools/src/FillAlignTRTHits.cxx
index 0ba7768be1d1..60d2bc67be68 100755
--- a/InnerDetector/InDetCalibTools/TRT_CalibTools/src/FillAlignTRTHits.cxx
+++ b/InnerDetector/InDetCalibTools/TRT_CalibTools/src/FillAlignTRTHits.cxx
@@ -41,8 +41,8 @@ FillAlignTRTHits::FillAlignTRTHits(const std::string& type, const std::string& n
 	AthAlgTool(type, name, parent),
 	m_DetID(nullptr), m_TRTID(nullptr),
 	// m_trtcaldbTool("ITRT_CalDbTool", this),
-	m_neighbourSvc("ITRT_StrawNeighbourSvc", name),
-	m_TRTStrawSummaryTool("InDetTRTStrawStatusSummaryTool",this),
+	// m_neighbourSvc("ITRT_StrawNeighbourSvc", name),
+	// m_TRTStrawSummaryTool("InDetTRTStrawStatusSummaryTool",this),
 	m_updator(nullptr),
 	m_maxDistance(2.8),
 	m_maxTimeResidual(150),
@@ -56,13 +56,13 @@ FillAlignTRTHits::FillAlignTRTHits(const std::string& type, const std::string& n
 {
 	declareInterface<IFillAlignTrkInfo>(this);
 	// declareProperty("TRTCalDbTool",m_trtcaldbTool);
-	declareProperty("NeighbourSvc",m_neighbourSvc);
+	// declareProperty("NeighbourSvc",m_neighbourSvc);
 	declareProperty("maxDistance",m_maxDistance) ;
 	declareProperty("maxTimeResidual",m_maxTimeResidual) ;
 	declareProperty("minTimebinsOverThreshold",m_minTimebinsOverThreshold) ;
 	declareProperty("maxTrackChisquarePerDof",m_maxTrackChisquarePerDof) ;
 	declareProperty("DoMCCosmicTimeShift",m_DoMCCosmicTimeShift);
-	declareProperty("TRTStrawSummaryTool",  m_TRTStrawSummaryTool);
+	// declareProperty("TRTStrawSummaryTool",  m_TRTStrawSummaryTool);
 }
 
 StatusCode FillAlignTRTHits::initialize(){
@@ -75,6 +75,8 @@ StatusCode FillAlignTRTHits::initialize(){
 		msg(MSG::FATAL) << "Problem retrieving TRTID helper" << endmsg;
 		return StatusCode::FAILURE;
 	}
+
+    std::cout<< m_trtcaldbTool<< std::endl;
 	if(m_trtcaldbTool.retrieve().isFailure()) {
 		msg(MSG::FATAL) << "Could not get TRT_CalDbTool !" << endmsg;
 		return StatusCode::FAILURE;
diff --git a/InnerDetector/InDetCalibTools/TRT_CalibTools/src/FillAlignTRTHits.h b/InnerDetector/InDetCalibTools/TRT_CalibTools/src/FillAlignTRTHits.h
index 84532ea488cb..65148df06b5b 100755
--- a/InnerDetector/InDetCalibTools/TRT_CalibTools/src/FillAlignTRTHits.h
+++ b/InnerDetector/InDetCalibTools/TRT_CalibTools/src/FillAlignTRTHits.h
@@ -62,11 +62,11 @@ private:
   const AtlasDetectorID* m_DetID;
   const TRT_ID* m_TRTID;
 
-  ToolHandle< ITRT_DriftFunctionTool > m_driftFunctionTool{this, "TRTDriftFunctionTool", "TRT_DriftFunctionTool", "Drift function tool name"};
-  ToolHandle<Trk::IUpdator> m_updatorHandle{this, "UpdatorTool", "Trk::KalmanUpdator/TrkKalmanUpdator", "Measurement updator to calculate unbiased track states"};
-  ToolHandle<ITRT_CalDbTool> m_trtcaldbTool {this, "TRTCalDbTool", "ITRT_CalDbTool", "Access to the folder of the calibration constants"}; 
-  ServiceHandle<ITRT_StrawNeighbourSvc> m_neighbourSvc ;
-  ToolHandle<ITRT_StrawStatusSummaryTool> m_TRTStrawSummaryTool; //!< The ConditionsSummaryTool
+  ToolHandle< ITRT_DriftFunctionTool > m_driftFunctionTool {this, "TRTDriftFunctionTool", "TRT_DriftFunctionTool", "Drift function tool name"};
+  ToolHandle<Trk::IUpdator> m_updatorHandle {this, "UpdatorTool" , "Trk::KalmanUpdator/TrkKalmanUpdator", "Measurement updator to calculate unbiased track states"};
+  ToolHandle<ITRT_CalDbTool> m_trtcaldbTool {this, "TRTCalDbTool", "CalDbTool", "Access to the folder of the calibration constants"}; 
+  ServiceHandle<ITRT_StrawNeighbourSvc> m_neighbourSvc {this, "NeighbourSvc", "NeighbourSvc", ""};
+  ToolHandle<ITRT_StrawStatusSummaryTool> m_TRTStrawSummaryTool  {this, "TRTStrawSummaryTool", "TRTStrawSummary", ""};
 
   Trk::IUpdator* m_updator; //!< updator for unbiased states
 
diff --git a/InnerDetector/InDetConditions/TRT_ConditionsServices/python/TRT_ConditionsServicesConfig.py b/InnerDetector/InDetConditions/TRT_ConditionsServices/python/TRT_ConditionsServicesConfig.py
index 51ccad4c6381..33763e31a17c 100644
--- a/InnerDetector/InDetConditions/TRT_ConditionsServices/python/TRT_ConditionsServicesConfig.py
+++ b/InnerDetector/InDetConditions/TRT_ConditionsServices/python/TRT_ConditionsServicesConfig.py
@@ -6,6 +6,26 @@ from IOVDbSvc.IOVDbSvcConfig import addFoldersSplitOnline
 
 
 @AccumulatorCache
+def TRT_CalDbToolCfg(flags, name="TRT_CalDbTool"):
+    """Return a ComponentAccumulator for TRT_CalDbTool"""
+    from IOVDbSvc.IOVDbSvcConfig import addFoldersSplitOnline
+    acc = ComponentAccumulator()
+    
+    acc.merge(addFoldersSplitOnline(flags, "TRT", "/TRT/Onl/Calib/RT", "/TRT/Calib/RT",
+                                    className="TRTCond::RtRelationMultChanContainer"))
+    acc.merge(addFoldersSplitOnline(flags, "TRT", "/TRT/Onl/Calib/T0", "/TRT/Calib/T0",
+                                    className='TRTCond::StrawT0MultChanContainer'))
+    acc.merge(addFoldersSplitOnline(flags, "TRT", "/TRT/Onl/Calib/errors2d", "/TRT/Calib/errors2d",
+                                    className="TRTCond::RtRelationMultChanContainer"))
+    acc.merge(addFoldersSplitOnline(flags, "TRT", "/TRT/Onl/Calib/slopes", "/TRT/Calib/slopes",
+                                    className='TRTCond::RtRelationMultChanContainer'))
+    
+    tool = CompFactory.TRT_CalDbTool(name)
+
+    acc.setPrivateTools(tool)
+    return acc
+
+
 def TRT_StrawStatusSummaryToolCfg(flags, name="TRT_StrawStatusSummaryTool", forceLegacyAccess=False, **kwargs):
     """Return a ComponentAccumulator for TRT_StrawStatusSummaryTool"""
     acc = ComponentAccumulator()
@@ -19,32 +39,22 @@ def TRT_StrawStatusSummaryToolCfg(flags, name="TRT_StrawStatusSummaryTool", forc
         from TRT_ConditionsAlgs.TRT_ConditionsAlgsConfig import TRTStrawStatusCondAlgCfg
         acc.merge(TRTStrawStatusCondAlgCfg(flags))
 
-    StrawStatusSummaryTool = CompFactory.TRT_StrawStatusSummaryTool(name, **kwargs)
+    tool = CompFactory.TRT_StrawStatusSummaryTool(name)
     
-    StrawStatusSummaryTool.isGEANT4 = flags.GeoModel.Align.LegacyConditionsAccess or forceLegacyAccess
+    tool.isGEANT4 = flags.GeoModel.Align.LegacyConditionsAccess or forceLegacyAccess
 
-    acc.setPrivateTools(StrawStatusSummaryTool)
+    acc.setPrivateTools(tool)
     return acc
 
-
-def TRT_CalDbToolCfg(flags, name="TRT_CalDbTool"):
-    """Return a ComponentAccumulator for TRT_CalDbTool"""
-    from IOVDbSvc.IOVDbSvcConfig import addFoldersSplitOnline
+def TRT_StrawNeighbourSvcCfg(flags, name="TRT_StrawNeighbourSvc"):
     acc = ComponentAccumulator()
     
-    acc.merge(addFoldersSplitOnline(flags, "TRT", "/TRT/Onl/Calib/RT", "/TRT/Calib/RT",
-                                    className="TRTCond::RtRelationMultChanContainer"))
-    acc.merge(addFoldersSplitOnline(flags, "TRT", "/TRT/Onl/Calib/T0", "/TRT/Calib/T0",
-                                    className='TRTCond::StrawT0MultChanContainer'))
-    acc.merge(addFoldersSplitOnline(flags, "TRT", "/TRT/Onl/Calib/errors2d", "/TRT/Calib/errors2d",
-                                    className="TRTCond::RtRelationMultChanContainer"))
-    acc.merge(addFoldersSplitOnline(flags, "TRT", "/TRT/Onl/Calib/slopes", "/TRT/Calib/slopes",
-                                    className='TRTCond::RtRelationMultChanContainer'))
+    svc = CompFactory.TRT_StrawNeighbourSvc(name)
     
-    tool = CompFactory.TRT_CalDbTool(name)
-
-    acc.setPrivateTools(tool)
+    acc.addService(svc)
     return acc
+    
+
 
 
 def TRT_MCCalDbToolCfg(flags, name="TRT_CalDbTool2", **kwargs):
-- 
GitLab