From fc41fc48a7ba9f0c9a80f475d69427a9bf3cc149 Mon Sep 17 00:00:00 2001
From: Sergi Rodriguez <Sergi.Rodriguez@cern.ch>
Date: Wed, 14 Feb 2024 14:53:30 +0100
Subject: [PATCH] removing the TRTCalibTrackSelectionTool files and updating
 the JO

---
 .../python/TRTCalibrationMgrConfig.py         | 69 ++++----------
 .../TRT_CalibTools/ISelectionTool.h           | 45 ---------
 .../TRT_CalibTools/src/FillAlignTRTHits.h     |  2 +-
 .../src/TRTCalibTrackSelectionTool.cxx        | 91 -------------------
 .../src/TRTCalibTrackSelectionTool.h          | 61 -------------
 .../src/components/TRT_CalibTools_entries.cxx |  2 -
 .../python/TRT_ConditionsServicesConfig.py    | 23 ++---
 7 files changed, 25 insertions(+), 268 deletions(-)
 delete mode 100755 InnerDetector/InDetCalibTools/TRT_CalibTools/TRT_CalibTools/ISelectionTool.h
 delete mode 100755 InnerDetector/InDetCalibTools/TRT_CalibTools/src/TRTCalibTrackSelectionTool.cxx
 delete mode 100755 InnerDetector/InDetCalibTools/TRT_CalibTools/src/TRTCalibTrackSelectionTool.h

diff --git a/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/python/TRTCalibrationMgrConfig.py b/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/python/TRTCalibrationMgrConfig.py
index ce5246892570..13a8dba64ae9 100644
--- a/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/python/TRTCalibrationMgrConfig.py
+++ b/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/python/TRTCalibrationMgrConfig.py
@@ -5,18 +5,17 @@ Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 
 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
 from AthenaConfiguration.ComponentFactory import CompFactory
-from IOVDbSvc.IOVDbSvcConfig import addFolders
-from AthenaConfiguration.Enums import Format
+# from IOVDbSvc.IOVDbSvcConfig import addFolders
+# from AthenaConfiguration.Enums import Format
 
 
 # Tool to write a track-tuple with TRT hit info
 def FillAlignTrkInfoCfg(flags,name='FillAlignTrkInfo',**kwargs) :
     acc = ComponentAccumulator()
     
-    AlignTrkInfo = CompFactory.FillAlignTrkInfo()
-    
     from TrkConfig.TrkTrackSummaryToolConfig import InDetTrackSummaryToolCfg
-    AlignTrkInfo.TrackSummaryTool = acc.popToolsAndMerge(InDetTrackSummaryToolCfg(flags))
+    
+    kwargs.setdefault("TrackSummaryTool", acc.popToolsAndMerge(InDetTrackSummaryToolCfg(flags)))
     
     # if "TrackSummaryTool" not in kwargs:
     #     from TrkConfig.TrkTrackSummaryToolConfig import InDetTrackSummaryToolCfg
@@ -24,7 +23,7 @@ def FillAlignTrkInfoCfg(flags,name='FillAlignTrkInfo',**kwargs) :
     #     acc.addPublicTool(InDetTrackSummaryTool)
     # acc.setPrivateTools(acc.popToolsAndMerge(FillAlignTrkInfoCfg(flags, name, **kwargs)))
     
-    acc.setPrivateTools(AlignTrkInfo)
+    acc.setPrivateTools(CompFactory.FillAlignTrkInfo(name, **kwargs))
     return acc
 
 
@@ -33,16 +32,14 @@ def FillAlignTrkInfoCfg(flags,name='FillAlignTrkInfo',**kwargs) :
 def FillAlignTRTHitsCfg(flags,name='FillAlignTRTHits',**kwargs) :
     acc = ComponentAccumulator()
     
-    AlignTRTHits = CompFactory.FillAlignTRTHits(name, **kwargs)
-    
-    AlignTRTHits.minTimebinsOverThreshold = 0
+    kwargs.setdefault("minTimebinsOverThreshold", 0)
     
     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))
+    kwargs.setdefault("TRTCalDbTool", acc.popToolsAndMerge(TRT_CalDbToolCfg(flags)))
+    kwargs.setdefault("TRTStrawSummaryTool", acc.popToolsAndMerge(TRT_StrawStatusSummaryToolCfg(flags)))
+    kwargs.setdefault("NeighbourSvc", acc.popToolsAndMerge(TRT_StrawNeighbourSvcCfg(flags)))
     
-    acc.setPrivateTools(AlignTRTHits)
+    acc.setPrivateTools(CompFactory.FillAlignTRTHits(name, **kwargs))
     
     # if "NeighbourSvc" not in kwargs:
         # from TRT_ConditionsServices.TRT_ConditionsServicesConfig import TRT_StrawNeighbourSvcCfg
@@ -134,18 +131,19 @@ def TRT_CalibrationMgrCfg(flags,name='TRT_CalibrationMgr',calibconstants='',**kw
     # Is this an accumulatiuon or a calibration job?
     kwargs.setdefault("DoCalibrate",False)
 
-    # NOTE 'TRTCalibrationMgr' object has no attribute 'TRT_CalDbTool' - it should be romeved
+    # NOTE 'TRTCalibrationMgr' object has no attribute 'TRT_CalDbTool' - it should be romeved from here
     # Needed tools (in addition to TRTCalibrator)
     # if "TRT_CalDbTool" not in kwargs:
     #     from TRT_ConditionsServices.TRT_ConditionsServicesConfig import TRT_CalDbToolCfg
     #     kwargs.setdefault("TRTCalDbTool", acc.popToolsAndMerge(TRT_CalDbToolCfg(flags)))
 
-    # NOTE 'TRTCalibrationMgr' object has no attribute 'TRTTrackSelectorTool'
+    # NOTE 'TRTCalibrationMgr' object has no attribute 'TRTTrackSelectorTool' - it should be romeved from here
     # if "InDetDetailedTrackSelectorTool" not in kwargs:    
     #     kwargs.setdefault("TRTTrackSelectorTool", acc.popToolsAndMerge(InDetDetailedTrackSelectorToolCfg(flags)))        
 
-    if "AlignTrackTools" not in kwargs:
-        kwargs.setdefault("AlignTrkTools", [acc.popToolsAndMerge(FillAlignTrkInfoCfg(flags)), acc.popToolsAndMerge(FillAlignTRTHitsCfg(flags))] )      
+
+    # FIXME - FillAlignTRTHitsCfg and FillAlignTrkInfoCfg functions should be moved to TRT_CalibTools (where the .cxx/.h are stored)
+    kwargs.setdefault("AlignTrkTools", [acc.popToolsAndMerge(FillAlignTrkInfoCfg(flags)), acc.popToolsAndMerge(FillAlignTRTHitsCfg(flags))] )      
            
     # SERGI - FitTool.cxx is empty?? why it is actually used? 
     # if "FitTools" not in kwargs:
@@ -153,9 +151,6 @@ def TRT_CalibrationMgrCfg(flags,name='TRT_CalibrationMgr',calibconstants='',**kw
 
     # Include analysis of DCS information                          
     # if flags.Input.Format is not Format.POOL :
-        # acc.merge(addFolders('DCS_OFL',"/TRT/DCS/HV/BARREL <cache>600</cache>"))
-        # acc.merge(addFolders('DCS_OFL',"/TRT/DCS/HV/ENDCAPA <cache>600</cache>"))                          
-        # acc.merge(addFolders('DCS_OFL',"/TRT/DCS/HV/ENDCAPC <cache>600</cache>"))
         # acc.merge(addFolders(flags, "/TRT/DCS/HV/BARREL" , "DCS_OFL", className="CondAttrListCollection"))
         # acc.merge(addFolders(flags, "/TRT/DCS/HV/ENDCAPA", "DCS_OFL", className="CondAttrListCollection"))                          
         # acc.merge(addFolders(flags, "/TRT/DCS/HV/ENDCAPC", "DCS_OFL", className="CondAttrListCollection"))
@@ -176,7 +171,7 @@ def TRT_CalibrationMgrCfg(flags,name='TRT_CalibrationMgr',calibconstants='',**kw
         acc.merge(TRTCondWriteCfg(flags,calibconstants))
 
     # add this algorithm to the configuration accumulator                       
-    acc.addEventAlgo(CompFactory.TRTCalibrationMgr(name,**kwargs))
+    acc.addEventAlgo(CompFactory.TRTCalibrationMgr(name, **kwargs))
 
     return acc
                           
@@ -207,32 +202,6 @@ def TRT_StrawStatusCfg(flags,name='InDet__TRT_StrawStatus',**kwargs) :
 
 
 
-# Sergi's new function
-def TRT_CalibrationCfg(flags, name="TRT_CalibrationCfg"):
-    acc = ComponentAccumulator()
-    
-    TRTCalibAlgo = CompFactory.TRTCalibrationMgr(name)
-    
-    # SERGI: IS this tool actually used in the TRTCalibrationMgr algo?
-    # from TRT_ConditionsServices.TRT_ConditionsServicesConfig import TRT_CalDbToolCfg
-    # CalDbTool = acc.popToolsAndMerge(TRT_CalDbToolCfg(flags))
-    
-    
-    if flags.Input.Format is not Format.POOL:
-        acc.merge(addFolders('DCS_OFL',"/TRT/DCS/HV/BARREL <cache>600</cache>"))
-        acc.merge(addFolders('DCS_OFL',"/TRT/DCS/HV/ENDCAPA <cache>600</cache>"))                          
-        acc.merge(addFolders('DCS_OFL',"/TRT/DCS/HV/ENDCAPC <cache>600</cache>"))
-    
-    # Defaults
-    # TRTCalibAlgo.DoRefit = True
-    # TRTCalibAlgo.DoCalibrate = False
-    # TRTCalibAlgo.WriteConstants = False
-    
-    acc.addEventAlgo(TRTCalibAlgo)
-
-    return acc
-
-
 if __name__ == '__main__':
     print("start running")
     from AthenaConfiguration.AllConfigFlags import initConfigFlags
@@ -248,11 +217,8 @@ if __name__ == '__main__':
     
     from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
     setupDetectorFlags(flags, ['ID'], toggle_geometry=True)
-
-    
     
     flags.fillFromArgs()
-    
     flags.lock()
     
     print("start running 1")
@@ -261,7 +227,6 @@ if __name__ == '__main__':
     from AthenaConfiguration.MainServicesConfig import MainServicesCfg
     acc = MainServicesCfg(flags)
     
-    
     from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg
     acc.merge(ByteStreamReadCfg(flags))
     
@@ -269,8 +234,6 @@ if __name__ == '__main__':
     acc.merge(InDetTrackRecoCfg(flags))
     
     acc.merge(TRT_CalibrationMgrCfg(flags))
-    # acc.merge(TRT_CalibrationCfg(flags))
-
     
     import sys
     sys.exit(not acc.run().isSuccess())
diff --git a/InnerDetector/InDetCalibTools/TRT_CalibTools/TRT_CalibTools/ISelectionTool.h b/InnerDetector/InDetCalibTools/TRT_CalibTools/TRT_CalibTools/ISelectionTool.h
deleted file mode 100755
index 9eab4a4278ab..000000000000
--- a/InnerDetector/InDetCalibTools/TRT_CalibTools/TRT_CalibTools/ISelectionTool.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
-*/
-
-#ifndef TRT_CALIBTOOLS__ISELECTIONTOOL_H
-#define TRT_CALIBTOOLS__ISELECTIONTOOL_H
-/********************************************************************
-
-NAME:     SelectionTool
-PACKAGE:  TRT_AlignTOOLS
-
-AUTHORS:  Jorgen Beck Hansen
-CREATED:  December 2005
-
-PURPOSE:  Track Selection Tool interface          
-
-********************************************************************/
-
-#include <vector>
-#include "GaudiKernel/IAlgTool.h"
-
-template < class InputClass >
-class ISelectionTool : virtual public IAlgTool {
-public:
-  
-  virtual bool isAccepted(const InputClass *element) const = 0;
-
-  bool operator() (const InputClass *element);
-  template < typename Collection >
-  void filterCollection(const Collection* inputCollection, std::vector< InputClass* >& output);
-};
-
-template<class InputClass>
-inline bool ISelectionTool<InputClass>::operator()(const InputClass *element) { return isAccepted(element);}
-
-template< class InputClass >
-template< typename Collection >
-inline void ISelectionTool<InputClass>::filterCollection(const Collection* inputCollection,
-						    std::vector< InputClass* >& output) {
-  for(typename Collection::const_iterator it=inputCollection->begin();
-      it != inputCollection->end(); ++it)
-    if (isAccepted(*it)) output.push_back(*it);
-}
-#endif // TRT_CALIBTOOLS__ISELECTIONTOOL_H
-
diff --git a/InnerDetector/InDetCalibTools/TRT_CalibTools/src/FillAlignTRTHits.h b/InnerDetector/InDetCalibTools/TRT_CalibTools/src/FillAlignTRTHits.h
index 65148df06b5b..40e37bf16ed1 100755
--- a/InnerDetector/InDetCalibTools/TRT_CalibTools/src/FillAlignTRTHits.h
+++ b/InnerDetector/InDetCalibTools/TRT_CalibTools/src/FillAlignTRTHits.h
@@ -66,7 +66,7 @@ private:
   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", ""};
+  ToolHandle<ITRT_StrawStatusSummaryTool> m_TRTStrawSummaryTool  {this, "TRTStrawSummaryTool", "InDetTRTStrawStatusSummaryTool", ""};
 
   Trk::IUpdator* m_updator; //!< updator for unbiased states
 
diff --git a/InnerDetector/InDetCalibTools/TRT_CalibTools/src/TRTCalibTrackSelectionTool.cxx b/InnerDetector/InDetCalibTools/TRT_CalibTools/src/TRTCalibTrackSelectionTool.cxx
deleted file mode 100755
index f455cfd16831..000000000000
--- a/InnerDetector/InDetCalibTools/TRT_CalibTools/src/TRTCalibTrackSelectionTool.cxx
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
-  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
-*/
-
-/********************************************************************
-
-********************************************************************/
-
-#include <cmath>
-
-#include "TRTCalibTrackSelectionTool.h"
-#include "TrkToolInterfaces/ITrackSummaryTool.h"
-#include "TrkTrackSummary/TrackSummary.h"
-#include "TrkParameters/TrackParameters.h"
-#include "CLHEP/Units/SystemOfUnits.h"
-#include "GaudiKernel/ListItem.h"
-
-TRTCalibTrackSelectionTool::TRTCalibTrackSelectionTool(const std::string& type, const std::string& name, const IInterface* parent) :
-  AthAlgTool(type, name, parent),
-  m_PtMin(0),
-  m_EtaMin(0),
-  m_EtaMax(0),
-  m_PhiOffset(0.),
-  m_DeltaPhi(3.3),
-  m_TrackSummaryTool("Trk::TrackSummaryTool/TrackSummaryTool"),
-  m_MinPixelHits(0),
-  m_MinSCTHits(0),
-  m_MinTRTHits(1) //20
-{
-  declareInterface< TRTCalibTrackSelectionTool >(this);
-  // declare tool parameters
-  declareProperty("PtMin",m_PtMin);
-  declareProperty("PhiOffset",m_PhiOffset);
-  declareProperty("DeltaPhi",m_DeltaPhi);
-  declareProperty("TrackSummaryTool",m_TrackSummaryTool);
-  declareProperty("EtaMin",m_EtaMin);
-  declareProperty("EtaMax",m_EtaMax);
-  declareProperty("MinTRTHits",m_MinTRTHits);
-  declareProperty("MinPixelHits",m_MinPixelHits);
-  declareProperty("MinSCTHits",m_MinSCTHits);
-}
-  
-StatusCode TRTCalibTrackSelectionTool::initialize()
-{
-  // get the ToolSvc
-
-  if (m_TrackSummaryTool.retrieve().isFailure()) {
-    msg(MSG::FATAL) << "Cannot get TrackSummaryTool" << endmsg;
-    return StatusCode::FAILURE;
-  }
-  // Print input properties
-  msg(MSG::INFO) << "Track selection:"
-      << "\n Pt > " << m_PtMin/CLHEP::GeV << " GeV"
-      << "\n |Phi - " << m_PhiOffset << "| < " << m_DeltaPhi
-      << "\n " << m_EtaMin << " < eta < " << m_EtaMax
-      << "\n number_of_PIXEL_hits >= " << m_MinPixelHits
-      << "\n number_of_SCT_hits >= " << m_MinSCTHits
-      << "\n number_of_TRT_hits >= " << m_MinTRTHits << endmsg;
-  return StatusCode::SUCCESS;
-}
-
-bool TRTCalibTrackSelectionTool::isAccepted(const Trk::Track* pTrack) const
-{
-  // selection for alignment quality tracks
-  const Trk::Perigee* mesp=(pTrack->perigeeParameters());
-  
-  if(!mesp) return false;
-  if (m_DeltaPhi>0 && std::abs(mesp->parameters()[Trk::phi]-m_PhiOffset) > m_DeltaPhi) return false;
-
-  float theta=mesp->parameters()[Trk::theta];
-  if(theta==0) theta=1.0e-24;
-  float ptinv = std::abs(mesp->parameters()[Trk::qOverP])/std::sin(theta);
-  if(m_PtMin>0 && ptinv > 1/m_PtMin) return false;
-  
-  float eta=-std::log(std::tan(theta/2));
-  if (m_EtaMin< m_EtaMax && (eta < m_EtaMin || eta > m_EtaMax) ) return false;
-
-  std::unique_ptr<const Trk::TrackSummary> summary = m_TrackSummaryTool->summary(*pTrack);
-  if(summary->get(Trk::numberOfTRTHits)<m_MinTRTHits) return false;
-  if(summary->get(Trk::numberOfPixelHits)<m_MinPixelHits) return false;
-  if(summary->get(Trk::numberOfSCTHits)<m_MinSCTHits) return false;
-  // All cuts passed...
-  if (msgLvl(MSG::DEBUG)) msg() << "Track passed selection:"
-      << "\n\t Pt = " << 1.0/ptinv
-      << "\n\t phi = " << mesp->parameters()[Trk::phi]
-      << "\n\t eta = " << eta
-      << "\n\t nPixel = " << summary->get(Trk::numberOfPixelHits)
-      << "\n\t nSCT = " << summary->get(Trk::numberOfSCTHits)
-      << "\n\t nTRT = " << summary->get(Trk::numberOfTRTHits) << endmsg;
-  return (true);
-}
diff --git a/InnerDetector/InDetCalibTools/TRT_CalibTools/src/TRTCalibTrackSelectionTool.h b/InnerDetector/InDetCalibTools/TRT_CalibTools/src/TRTCalibTrackSelectionTool.h
deleted file mode 100755
index 005338ab597b..000000000000
--- a/InnerDetector/InDetCalibTools/TRT_CalibTools/src/TRTCalibTrackSelectionTool.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
-*/
-
-#ifndef TRT_CALIBTOOLS__TRTCalibTrackSelectionTool_H
-#define TRT_CALIBTOOLS__TRTCalibTrackSelectionTool_H
-/********************************************************************
- 
-NAME:     TRTCalibTrackSelectionTool
-PACKAGE:  TRT_AlignTOOLS
- 
-AUTHORS:  Jorgen Beck Hansen
-CREATED:  December 2005
- 
-PURPOSE:  Tool to select Tracks to be used in alignment
- 
-********************************************************************/
-
-#include "TRT_CalibTools/ISelectionTool.h"
-#include "TrkTrack/Track.h"
-#include "AthenaBaseComps/AthAlgTool.h"
-#include "GaudiKernel/ToolHandle.h"
-
-namespace Trk {
-  class ITrackSummaryTool;
-}
-
-static const InterfaceID IID_ISelectionTool("TRTCalibTrackSelectionTool", 1, 0);
-
-class TRTCalibTrackSelectionTool :  virtual public ISelectionTool<Trk::Track>, public AthAlgTool {
-public:
-  TRTCalibTrackSelectionTool(const std::string& type, const std::string& name, const IInterface* parent);
-  
-  virtual ~TRTCalibTrackSelectionTool() {}
-  
-  virtual StatusCode initialize();
-
-  virtual bool isAccepted(const Trk::Track* element) const;
-
-  static const InterfaceID& interfaceID();
-
-private:
-  float m_PtMin;
-  float m_EtaMin;
-  float m_EtaMax;
-  float m_PhiOffset;
-  float m_DeltaPhi;
-  ToolHandle<Trk::ITrackSummaryTool> m_TrackSummaryTool;
-  int m_MinPixelHits;
-  int m_MinSCTHits;
-  int m_MinTRTHits;
-  
-};
-
-inline const InterfaceID& TRTCalibTrackSelectionTool::interfaceID()
-{ 
-        return IID_ISelectionTool; 
-}
-
-
-#endif //  TRT_CALIBTOOLS__TRTCalibTrackSelectionTool_H
diff --git a/InnerDetector/InDetCalibTools/TRT_CalibTools/src/components/TRT_CalibTools_entries.cxx b/InnerDetector/InDetCalibTools/TRT_CalibTools/src/components/TRT_CalibTools_entries.cxx
index 91d62970c2fc..d3a96332c3f7 100644
--- a/InnerDetector/InDetCalibTools/TRT_CalibTools/src/components/TRT_CalibTools_entries.cxx
+++ b/InnerDetector/InDetCalibTools/TRT_CalibTools/src/components/TRT_CalibTools_entries.cxx
@@ -1,13 +1,11 @@
 /*
   Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
-#include "../TRTCalibTrackSelectionTool.h"
 #include "../FillAlignTrkInfo.h"
 #include "../FillAlignTRTHits.h"
 #include "../TRTCalibrator.h"
 #include "../FitTool.h"
 
-DECLARE_COMPONENT( TRTCalibTrackSelectionTool )
 DECLARE_COMPONENT( FillAlignTrkInfo )
 DECLARE_COMPONENT( FillAlignTRTHits )
 DECLARE_COMPONENT( TRTCalibrator )
diff --git a/InnerDetector/InDetConditions/TRT_ConditionsServices/python/TRT_ConditionsServicesConfig.py b/InnerDetector/InDetConditions/TRT_ConditionsServices/python/TRT_ConditionsServicesConfig.py
index 33763e31a17c..9de372debed5 100644
--- a/InnerDetector/InDetConditions/TRT_ConditionsServices/python/TRT_ConditionsServicesConfig.py
+++ b/InnerDetector/InDetConditions/TRT_ConditionsServices/python/TRT_ConditionsServicesConfig.py
@@ -6,23 +6,17 @@ from IOVDbSvc.IOVDbSvcConfig import addFoldersSplitOnline
 
 
 @AccumulatorCache
-def TRT_CalDbToolCfg(flags, name="TRT_CalDbTool"):
+def TRT_CalDbToolCfg(flags, name="TRT_CalDbTool", **kwags):
     """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'))
+    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)
+    acc.setPrivateTools(CompFactory.TRT_CalDbTool(name, **kwags))
     return acc
 
 
@@ -39,11 +33,10 @@ def TRT_StrawStatusSummaryToolCfg(flags, name="TRT_StrawStatusSummaryTool", forc
         from TRT_ConditionsAlgs.TRT_ConditionsAlgsConfig import TRTStrawStatusCondAlgCfg
         acc.merge(TRTStrawStatusCondAlgCfg(flags))
 
-    tool = CompFactory.TRT_StrawStatusSummaryTool(name)
     
-    tool.isGEANT4 = flags.GeoModel.Align.LegacyConditionsAccess or forceLegacyAccess
+    kwargs.setdefault("isGEANT4", flags.GeoModel.Align.LegacyConditionsAccess or forceLegacyAccess)
 
-    acc.setPrivateTools(tool)
+    acc.setPrivateTools(CompFactory.TRT_StrawStatusSummaryTool(name, **kwargs))
     return acc
 
 def TRT_StrawNeighbourSvcCfg(flags, name="TRT_StrawNeighbourSvc"):
-- 
GitLab