From c1f602fc39aed6f4e4c7bc6ea70b46bbe98b4c6e Mon Sep 17 00:00:00 2001
From: Maksim Penzin <penzin.maksim@gmail.com>
Date: Tue, 1 Sep 2020 10:36:11 +0200
Subject: [PATCH] Private tools

---
 .../src/CalibCscStripFitter.cxx               |  8 +---
 .../src/CalibCscStripFitter.h                 |  6 ++-
 .../src/CscBipolarStripFitter.cxx             | 15 ++------
 .../src/CscBipolarStripFitter.h               |  6 ++-
 .../src/CscClusterUtilTool.cxx                | 20 ++--------
 .../src/CscClusterUtilTool.h                  | 13 ++++++-
 .../CscPeakThresholdClusterBuilderTool.cxx    | 28 ++------------
 .../src/CscPeakThresholdClusterBuilderTool.h  | 26 ++++++++++---
 .../src/CscSplitClusterFitter.cxx             | 21 +++--------
 .../src/CscSplitClusterFitter.h               | 12 +++++-
 .../src/CscThresholdClusterBuilder.cxx        | 10 +----
 .../src/CscThresholdClusterBuilder.h          |  8 +++-
 .../src/CscThresholdClusterBuilderTool.cxx    | 37 +++----------------
 .../src/CscThresholdClusterBuilderTool.h      | 32 +++++++++++++---
 .../src/QratCscClusterFitter.cxx              |  5 +--
 .../src/QratCscClusterFitter.h                |  6 ++-
 .../src/SimpleCscClusterFitter.cxx            |  4 +-
 .../src/SimpleCscClusterFitter.h              |  6 ++-
 .../src/MuonClusterizationAlg.cxx             |  3 +-
 .../src/MuonClusterizationAlg.h               |  6 ++-
 .../MuonTGMeasAssocAlg/MuonTGMeasAssocAlg.h   | 12 +++++-
 .../src/MuonTGMeasAssocAlg.cxx                |  5 +--
 22 files changed, 138 insertions(+), 151 deletions(-)

diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CalibCscStripFitter.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CalibCscStripFitter.cxx
index 9a8951b2dd71..c6d8553fd6c3 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CalibCscStripFitter.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CalibCscStripFitter.cxx
@@ -16,13 +16,12 @@ typedef ICscStripFitter::ChargeList ChargeList;
 //**********************************************************************
 
 CalibCscStripFitter::CalibCscStripFitter(std::string type, std::string aname, const IInterface* parent)
-    : AthAlgTool(type, aname, parent), m_noiseOption(rms), m_cscCalibTool("CscCalibTool/CscCalibTool", this)
+    : AthAlgTool(type, aname, parent), m_noiseOption(rms)
 {
     declareInterface<ICscStripFitter>(this);
     declareProperty("timeError", m_terr = 5.0);
     declareProperty("failTimeError", m_terr_fail = 50.0);
     declareProperty("chargeCalibrationError", m_qerrprop = 0.000);
-    declareProperty("cscCalibTool", m_cscCalibTool);
     declareProperty("noiseOption", m_noiseOptionStr = "f001");
     declareProperty("doCorrection", m_doCorrection = true);
     declareProperty("chargeErrorScaler", m_chargeErrorScaler = 1.0);
@@ -57,10 +56,7 @@ CalibCscStripFitter::initialize()
 
     //  ATH_MSG_DEBUG ( " (failed) Charge error is noise(DB)*1.03588 = 4300 " << m_errorScaler );
     /** CSC calibratin tool for the Condtiions Data base access */
-    if (m_cscCalibTool.retrieve().isFailure()) {
-        ATH_MSG_ERROR("Can't get handle on CSC calibration tools");
-        return StatusCode::RECOVERABLE;
-    }
+    ATH_CHECK_RECOVERABLE(m_cscCalibTool.retrieve());
 
     // Retrieve the detector descriptor.
     ATH_CHECK(m_idHelperSvc.retrieve());
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CalibCscStripFitter.h b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CalibCscStripFitter.h
index 0ecab23df312..e6d8d43ba96c 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CalibCscStripFitter.h
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CalibCscStripFitter.h
@@ -61,7 +61,11 @@ class CalibCscStripFitter : virtual public ICscStripFitter, public AthAlgTool {
         "Muon::MuonIdHelperSvc/MuonIdHelperSvc",
     };
 
-    ToolHandle<ICscCalibTool> m_cscCalibTool;
+    ToolHandle<ICscCalibTool> m_cscCalibTool{
+        this,
+        "cscCalibTool",
+        "CscCalibTool/CscCalibTool",
+    };
 };
 
 #endif
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscBipolarStripFitter.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscBipolarStripFitter.cxx
index 13f69995e5c4..d8ce1fb2dc60 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscBipolarStripFitter.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscBipolarStripFitter.cxx
@@ -31,7 +31,6 @@ CscBipolarStripFitter::CscBipolarStripFitter(string type, string aname, const II
     : AthAlgTool(type, aname, parent),
       m_pmuon_detmgr(0),
       m_phelper(0),
-      m_cscCalibTool(""),
       m_n(0),
       m_n2(0),
       m_zmax(0),
@@ -47,7 +46,6 @@ CscBipolarStripFitter::CscBipolarStripFitter(string type, string aname, const II
     declareProperty("failChargeError", m_qerr_fail = 5000.0);
     declareProperty("failTimeError", m_terr_fail = 50.0);
     declareProperty("chargeCalibrationError", m_qerrprop = 0.002);
-    declareProperty("cscCalibTool", m_cscCalibTool);
 }
 
 //**********************************************************************
@@ -70,18 +68,13 @@ CscBipolarStripFitter::initialize()
     ATH_MSG_DEBUG("  Charge calibration error: " << m_qerrprop);
 
     /** CSC calibratin tool for the Condtiions Data base access */
-    if (m_cscCalibTool.retrieve().isFailure()) {
-        ATH_MSG_ERROR("Can't get handle on CSC calibration tools");
-        return StatusCode::RECOVERABLE;
-    }
+    ATH_CHECK_RECOVERABLE(m_cscCalibTool.retrieve());
+
     // Retrieve the detector descriptor.
-    if (detStore()->retrieve(m_pmuon_detmgr).isFailure()) {
-        ATH_MSG_ERROR(" Cannot retrieve MuonGeoModel ");
-        return StatusCode::RECOVERABLE;
-    }
+    ATH_CHECK_RECOVERABLE(detStore()->retrieve(m_pmuon_detmgr));
     ATH_MSG_DEBUG("Retrieved geometry.");
-    m_phelper = m_pmuon_detmgr->cscIdHelper();
 
+    m_phelper = m_pmuon_detmgr->cscIdHelper();
 
     m_n          = m_cscCalibTool->getNumberOfIntegration();   // 12.;
     m_n2         = m_cscCalibTool->getNumberOfIntegration2();  // 11.66;
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscBipolarStripFitter.h b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscBipolarStripFitter.h
index 5e24b8c135ad..0b2a1c2d1ffc 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscBipolarStripFitter.h
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscBipolarStripFitter.h
@@ -60,7 +60,11 @@ class CscBipolarStripFitter : virtual public ICscStripFitter, public AthAlgTool
     const CscIdHelper *                m_phelper;
 
     // Calibration tool.
-    ToolHandle<ICscCalibTool> m_cscCalibTool;
+    ToolHandle<ICscCalibTool> m_cscCalibTool{
+        this,
+        "cscCalibTool",
+        "",
+    };
 
     double FindInitValues(double *x, double *initValues, int *maxsample) const;
     double FindPow(double z) const;
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscClusterUtilTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscClusterUtilTool.cxx
index 571900b8c903..96a36efbb86a 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscClusterUtilTool.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscClusterUtilTool.cxx
@@ -29,13 +29,9 @@ CscClusterUtilTool::CscClusterUtilTool(string type, string aname, const IInterfa
     : AthAlgTool(type, aname, parent),
       m_pmuon_detmgr(0),
       m_phelper(0),
-      m_stripFitter("CalibCscStripFitter/CalibCscStripFitter", this),
-      m_precClusterFitter("QratCscClusterFitter/QratCscClusterFitter", this),
       m_cscStripLocation("CSC_Measurements")
 {
     declareInterface<ICscClusterUtilTool>(this);
-    declareProperty("strip_fitter", m_stripFitter);
-    declareProperty("precision_fitter", m_precClusterFitter);
     declareProperty("CscStripPrepDataLocation", m_cscStripLocation);
 }
 
@@ -55,28 +51,18 @@ CscClusterUtilTool::initialize()
     ATH_MSG_DEBUG("  CscStripPrepDataLocation is " << m_cscStripLocation.key());
 
     // Retrieve the strip fitting tool.
-    if (m_stripFitter.retrieve().isFailure()) {
-        ATH_MSG_FATAL("Unable to retrieve strip fitting tool " << m_stripFitter);
-        return StatusCode::FAILURE;
-    }
+    ATH_CHECK(m_stripFitter.retrieve());
     ATH_MSG_DEBUG("Retrieved strip fitting tool " << m_stripFitter);
 
     // Retrieve the precision cluster fitting tool.
-    if (m_precClusterFitter.retrieve().isFailure()) {
-        ATH_MSG_FATAL("Unable to retrieve CSC precision cluster fitting tool " << m_precClusterFitter->name());
-        return StatusCode::FAILURE;
-    }
+    ATH_CHECK(m_precClusterFitter.retrieve());
     ATH_MSG_DEBUG("Retrieved CSC precision cluster fitting tool");
 
     // Retrieve the detector descriptor.
-    if (detStore()->retrieve(m_pmuon_detmgr).isFailure()) {
-        ATH_MSG_ERROR(" Cannot retrieve MuonGeoModel ");
-        return StatusCode::RECOVERABLE;
-    }
+    ATH_CHECK_RECOVERABLE(detStore()->retrieve(m_pmuon_detmgr));
     ATH_MSG_DEBUG("Retrieved geometry.");
     m_phelper = m_pmuon_detmgr->cscIdHelper();
 
-
     return StatusCode::SUCCESS;
 }
 
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscClusterUtilTool.h b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscClusterUtilTool.h
index 0eb7ff03730c..5df430ed5a18 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscClusterUtilTool.h
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscClusterUtilTool.h
@@ -62,8 +62,17 @@ class CscClusterUtilTool : virtual public ICscClusterUtilTool, public AthAlgTool
     const CscIdHelper*                 m_phelper;
 
     // Strip fitter.
-    ToolHandle<ICscStripFitter>                        m_stripFitter;
-    ToolHandle<ICscClusterFitter>                      m_precClusterFitter;
+    ToolHandle<ICscStripFitter> m_stripFitter{
+        this,
+        "strip_fitter",
+        "CalibCscStripFitter/CalibCscStripFitter",
+    };
+    ToolHandle<ICscClusterFitter> m_precClusterFitter{
+        this,
+        "precision_fitter",
+        "QratCscClusterFitter/QratCscClusterFitter",
+    };
+
     SG::ReadHandleKey<Muon::CscStripPrepDataContainer> m_cscStripLocation;
 };
 
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscPeakThresholdClusterBuilderTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscPeakThresholdClusterBuilderTool.cxx
index 84313668cb5a..37d27d2bb945 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscPeakThresholdClusterBuilderTool.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscPeakThresholdClusterBuilderTool.cxx
@@ -74,10 +74,6 @@ CscPeakThresholdClusterBuilderTool::CscPeakThresholdClusterBuilderTool(const std
     : AthAlgTool(type, aname, parent),
       m_digit_key("CSC_Measurements"),
       m_cluster_handle("CSC_Clusters"),
-      m_pstrip_fitter("CalibCscStripFitter/CalibCscStripFitter"),
-      m_pfitter_def("SimpleCscClusterFitter/SimpleCscClusterFitter"),
-      m_pfitter_prec("QratCscClusterFitter/QratCscClusterFitter"),
-      m_pfitter_split("CscSplitClusterFitter/CscSplitClusterFitter"),
       m_fullEventDone(false)
 {
 
@@ -89,10 +85,6 @@ CscPeakThresholdClusterBuilderTool::CscPeakThresholdClusterBuilderTool(const std
     declareProperty("q3sum_threshold_phi", m_q3sum_threshold_phi = 33000.0);
     declareProperty("digit_key", m_digit_key);
     declareProperty("cluster_key", m_cluster_handle);
-    declareProperty("strip_fitter", m_pstrip_fitter);
-    declareProperty("default_fitter", m_pfitter_def);
-    declareProperty("precision_fitter", m_pfitter_prec);
-    declareProperty("split_fitter", m_pfitter_split);
 }
 
 //******************************************************************************
@@ -120,31 +112,19 @@ CscPeakThresholdClusterBuilderTool::initialize()
     ATH_MSG_DEBUG("  Output cluster key is " << m_cluster_handle.key());
 
     // Retrieve the strip fitting tool.
-    if (m_pstrip_fitter.retrieve().isFailure()) {
-        ATH_MSG_FATAL("Unable to retrieve strip fitting tool " << m_pstrip_fitter);
-        return StatusCode::FAILURE;
-    }
+    ATH_CHECK(m_pstrip_fitter.retrieve());
     ATH_MSG_DEBUG("Retrieved strip fitting tool " << m_pstrip_fitter);
 
     // Retrieve the default cluster fitting tool.
-    if (m_pfitter_def.retrieve().isFailure()) {
-        ATH_MSG_FATAL("Unable to retrieve CSC default cluster fitting tool " << m_pfitter_def->name());
-        return StatusCode::FAILURE;
-    }
+    ATH_CHECK(m_pfitter_def.retrieve());
     ATH_MSG_DEBUG("Retrieved CSC default cluster fitting tool");
 
     // Retrieve the precision cluster fitting tool.
-    if (m_pfitter_prec.retrieve().isFailure()) {
-        ATH_MSG_FATAL("Unable to retrieve CSC precision cluster fitting tool " << m_pfitter_prec->name());
-        return StatusCode::FAILURE;
-    }
+    ATH_CHECK(m_pfitter_prec.retrieve());
     ATH_MSG_DEBUG("Retrieved CSC precision cluster fitting tool");
 
     // Retrieve the split cluster fitting tool.
-    if (m_pfitter_split.retrieve().isFailure()) {
-        ATH_MSG_FATAL("Unable to retrieve CSC split cluster fitting tool " << m_pfitter_split->name());
-        return StatusCode::FAILURE;
-    }
+    ATH_CHECK(m_pfitter_split.retrieve());
     ATH_MSG_DEBUG("Retrieved CSC split cluster fitting tool");
 
     // retrieve MuonDetectorManager from the conditions store
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscPeakThresholdClusterBuilderTool.h b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscPeakThresholdClusterBuilderTool.h
index db7c77350abb..89a41d35aa6a 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscPeakThresholdClusterBuilderTool.h
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscPeakThresholdClusterBuilderTool.h
@@ -55,13 +55,13 @@
 // Algorithm to construct CSC clusters from digits.
 
 #include "AthenaBaseComps/AthAlgTool.h"
-#include "CscClusterization/ICscClusterBuilder.h"
 #include "CscClusterization/ICscClusterFitter.h"
 #include "CscClusterization/ICscStripFitter.h"
 #include "GaudiKernel/ToolHandle.h"
 #include "MuonIdHelpers/IMuonIdHelperSvc.h"
 #include "MuonPrepRawData/MuonPrepDataContainer.h"
 #include "MuonReadoutGeometry/MuonDetectorManager.h"
+#include "CscClusterization/ICscClusterBuilder.h"
 
 namespace Muon {
 class CscPrepData;
@@ -114,12 +114,28 @@ class CscPeakThresholdClusterBuilderTool : virtual public ICscClusterBuilder, pu
     SG::WriteHandle<Muon::CscPrepDataContainer>        m_cluster_handle;  // SG key for output clusters
 
     // Strip fitter.
-    ToolHandle<ICscStripFitter> m_pstrip_fitter;
+    ToolHandle<ICscStripFitter> m_pstrip_fitter{
+        this,
+        "strip_fitter",
+        "CalibCscStripFitter/CalibCscStripFitter",
+    };
 
     // Cluster fitters.
-    ToolHandle<ICscClusterFitter> m_pfitter_def;
-    ToolHandle<ICscClusterFitter> m_pfitter_prec;
-    ToolHandle<ICscClusterFitter> m_pfitter_split;
+    ToolHandle<ICscClusterFitter> m_pfitter_def{
+        this,
+        "default_fitter",
+        "SimpleCscClusterFitter/SimpleCscClusterFitter",
+    };
+    ToolHandle<ICscClusterFitter> m_pfitter_prec{
+        this,
+        "precision_fitter",
+        "QratCscClusterFitter/QratCscClusterFitter",
+    };
+    ToolHandle<ICscClusterFitter> m_pfitter_split{
+        this,
+        "split_fitter",
+        "CscSplitClusterFitter/CscSplitClusterFitter",
+    };
 
     ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{
         this,
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscSplitClusterFitter.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscSplitClusterFitter.cxx
index 0395a5b015d4..2e1f0fdb9e3b 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscSplitClusterFitter.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscSplitClusterFitter.cxx
@@ -27,13 +27,9 @@ enum CscPlane { CSS_ETA, CSL_ETA, CSS_PHI, CSL_PHI, UNKNOWN_PLANE };
 //******************************************************************************
 
 CscSplitClusterFitter::CscSplitClusterFitter(std::string type, std::string aname, const IInterface* parent)
-    : AthAlgTool(type, aname, parent),
-      m_pfitter_def("SimpleCscClusterFitter/SimpleCscClusterFitter"),
-      m_pfitter_prec("QratCscClusterFitter/QratCscClusterFitter")
+    : AthAlgTool(type, aname, parent)
 {
     declareInterface<ICscClusterFitter>(this);
-    declareProperty("default_fitter", m_pfitter_def);
-    declareProperty("precision_fitter", m_pfitter_prec);
     declareProperty("min_dist", m_min_dist = 2);         // Minimum distance between peaks and valley
     declareProperty("max_qratio", m_max_qratio = 0.15);  // Maximum charge ratio between peak strip and valley strip
 }
@@ -48,19 +44,13 @@ CscSplitClusterFitter::initialize()
     ATH_CHECK(m_idHelperSvc.retrieve());
 
     // Retrieve the default cluster fitting tool.
-    if (m_pfitter_def.retrieve().isFailure()) {
-        ATH_MSG_ERROR("Unable to retrieve Csc default cluster fitting tool "
-                      << name() << ": unable to retrieve cluster fitter " << m_pfitter_def);
-        return StatusCode::RECOVERABLE;
-    }
+    ATH_CHECK_RECOVERABLE(m_pfitter_def.retrieve());
+
     ATH_MSG_DEBUG("CscClusterization " << name() << ": retrieved " << m_pfitter_def);
 
     // Retrieve the precision cluster fitting tool.
-    if (m_pfitter_prec.retrieve().isFailure()) {
-        ATH_MSG_ERROR("Unable to retrieve Csc default cluster fitting tool "
-                      << name() << ": unable to retrieve cluster fitter " << m_pfitter_prec);
-        return StatusCode::RECOVERABLE;
-    }
+    ATH_CHECK_RECOVERABLE(m_pfitter_prec.retrieve());
+
     ATH_MSG_DEBUG("CscClusterization " << name() << ": retrieved " << m_pfitter_prec);
 
     ATH_MSG_DEBUG("Properties for " << name() << ":");
@@ -76,7 +66,6 @@ CscSplitClusterFitter::initialize()
 Results
 CscSplitClusterFitter::fit(const StripFitList& sfits) const
 {
-
     Results results;
     // Check input has at least three strips.
     unsigned int nstrip = sfits.size();
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscSplitClusterFitter.h b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscSplitClusterFitter.h
index c0d4ebfa6cef..3309177df31f 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscSplitClusterFitter.h
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscSplitClusterFitter.h
@@ -49,8 +49,16 @@ class CscSplitClusterFitter : virtual public ICscClusterFitter, public AthAlgToo
     };
 
     // Cluster fitters.
-    ToolHandle<ICscClusterFitter> m_pfitter_def;
-    ToolHandle<ICscClusterFitter> m_pfitter_prec;
+    ToolHandle<ICscClusterFitter> m_pfitter_def{
+        this,
+        "default_fitter",
+        "SimpleCscClusterFitter/SimpleCscClusterFitter",
+    };
+    ToolHandle<ICscClusterFitter> m_pfitter_prec{
+        this,
+        "precision_fitter",
+        "QratCscClusterFitter/QratCscClusterFitter",
+    };
 };
 
 #endif
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscThresholdClusterBuilder.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscThresholdClusterBuilder.cxx
index 1f89eb098565..91834f31e07b 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscThresholdClusterBuilder.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscThresholdClusterBuilder.cxx
@@ -15,11 +15,8 @@ using std::vector;
 
 //******************************************************************************
 CscThresholdClusterBuilder::CscThresholdClusterBuilder(const std::string& aname, ISvcLocator* pSvcLocator)
-    : AthAlgorithm(aname, pSvcLocator),
-      m_cluster_builder("CscThresholdClusterBuilderTool/CscThresholdClusterBuilderTool")
+    : AthAlgorithm(aname, pSvcLocator)
 {
-
-    declareProperty("cluster_builder", m_cluster_builder);
 }
 
 //******************************************************************************
@@ -37,10 +34,7 @@ CscThresholdClusterBuilder::initialize()
     ATH_MSG_DEBUG("Initializing " << name());
 
     // Retrieve the strip fitting tool.
-    if (m_cluster_builder.retrieve().isFailure()) {
-        ATH_MSG_ERROR("Unable to retrieve strip fitting tool " << m_cluster_builder);
-        return StatusCode::FAILURE;
-    }
+    ATH_CHECK(m_cluster_builder.retrieve());
 
     ATH_MSG_DEBUG("Retrieved strip fitting tool " << m_cluster_builder);
     return StatusCode::SUCCESS;
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscThresholdClusterBuilder.h b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscThresholdClusterBuilder.h
index 454449db2b98..e24e0c45ccb8 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscThresholdClusterBuilder.h
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscThresholdClusterBuilder.h
@@ -55,11 +55,11 @@
 // Algorithm to construct CSC clusters from digits.
 
 #include "AthenaBaseComps/AthAlgorithm.h"
-#include "CscClusterization/ICscClusterBuilder.h"
 #include "CscClusterization/ICscClusterFitter.h"
 #include "CscClusterization/ICscStripFitter.h"
 #include "GaudiKernel/ToolHandle.h"
 #include "MuonPrepRawData/MuonPrepDataContainer.h"
+#include "CscClusterization/ICscClusterBuilder.h"
 
 namespace MuonGM {
 class MuonDetectorManager;
@@ -92,7 +92,11 @@ class CscThresholdClusterBuilder : public AthAlgorithm {
 
   private:  // data
     // Strip fitter.
-    ToolHandle<ICscClusterBuilder> m_cluster_builder;
+    ToolHandle<ICscClusterBuilder> m_cluster_builder{
+        this,
+        "cluster_builder",
+        "CscThresholdClusterBuilderTool/CscThresholdClusterBuilderTool",
+    };
 };
 
 #endif
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscThresholdClusterBuilderTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscThresholdClusterBuilderTool.cxx
index 9766b053122d..ffd848acb639 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscThresholdClusterBuilderTool.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscThresholdClusterBuilderTool.cxx
@@ -78,14 +78,8 @@ CscThresholdClusterBuilderTool::CscThresholdClusterBuilderTool(const std::string
       m_noiseOption(rms),
       m_digit_key("CSC_Measurements"),
       m_pclusters("CSC_Clusters"),
-      m_cscCalibTool("CscCalibTool/CscCalibTool"),
-      m_pstrip_fitter("CalibCscStripFitter/CalibCscStripFitter"),
-      m_pfitter_def("SimpleCscClusterFitter/SimpleCscClusterFitter"),
-      m_pfitter_prec("QratCscClusterFitter/QratCscClusterFitter"),
-      m_pfitter_split("CscSplitClusterFitter/CscSplitClusterFitter"),
       m_fullEventDone(false)
 {
-
     declareInterface<ICscClusterBuilder>(this);
 
     declareProperty("threshold", m_threshold = 20000.0);
@@ -93,11 +87,6 @@ CscThresholdClusterBuilderTool::CscThresholdClusterBuilderTool(const std::string
     declareProperty("noiseOption", m_noiseOptionStr = "f001");
     declareProperty("digit_key", m_digit_key);
     declareProperty("cluster_key", m_pclusters);
-    declareProperty("cscCalibTool", m_cscCalibTool);
-    declareProperty("strip_fitter", m_pstrip_fitter);
-    declareProperty("default_fitter", m_pfitter_def);
-    declareProperty("precision_fitter", m_pfitter_prec);
-    declareProperty("split_fitter", m_pfitter_split);
     declareProperty("makeNarrowClusterThreeStrips", m_makeNarrowClusterThreeStrips = true);
 }
 
@@ -112,7 +101,6 @@ CscThresholdClusterBuilderTool::~CscThresholdClusterBuilderTool() {}
 StatusCode
 CscThresholdClusterBuilderTool::initialize()
 {
-
     // Display algorithm properties.
     ATH_MSG_DEBUG("Properties for " << name() << ":");
     ATH_MSG_DEBUG("  Strip threshold is Max( " << m_threshold << ", " << m_kFactor
@@ -139,37 +127,22 @@ CscThresholdClusterBuilderTool::initialize()
     ATH_MSG_DEBUG("  Output cluster key is " << m_pclusters.key());
 
     // CSC calibratin tool for the Condtiions Data base access //
-    if (m_cscCalibTool.retrieve().isFailure()) {
-        ATH_MSG_ERROR("Can't get handle on CSC calibration tools");
-        return StatusCode::RECOVERABLE;
-    }
+    ATH_CHECK_RECOVERABLE(m_cscCalibTool.retrieve());
 
     // Retrieve the strip fitting tool.
-    if (m_pstrip_fitter.retrieve().isFailure()) {
-        ATH_MSG_ERROR("Unable to retrieve strip fitting tool " << m_pstrip_fitter);
-        return StatusCode::RECOVERABLE;
-    }
+    ATH_CHECK_RECOVERABLE(m_pstrip_fitter.retrieve());
     ATH_MSG_DEBUG("Retrieved strip fitting tool " << m_pstrip_fitter);
 
     // Retrieve the default cluster fitting tool.
-    if (m_pfitter_def.retrieve().isFailure()) {
-        ATH_MSG_ERROR("Unable to retrieve CSC default cluster fitting tool " << m_pfitter_def->name());
-        return StatusCode::RECOVERABLE;
-    }
+    ATH_CHECK_RECOVERABLE(m_pfitter_def.retrieve());
     ATH_MSG_DEBUG("Retrieved CSC default cluster fitting tool");
 
     // Retrieve the precision cluster fitting tool.
-    if (m_pfitter_prec.retrieve().isFailure()) {
-        ATH_MSG_ERROR("Unable to retrieve CSC precision cluster fitting tool " << m_pfitter_prec->name());
-        return StatusCode::RECOVERABLE;
-    }
+    ATH_CHECK_RECOVERABLE(m_pfitter_prec.retrieve());
     ATH_MSG_DEBUG("Retrieved CSC precision cluster fitting tool");
 
     // Retrieve the split cluster fitting tool.
-    if (m_pfitter_split.retrieve().isFailure()) {
-        ATH_MSG_ERROR("Unable to retrieve CSC split cluster fitting tool " << m_pfitter_split->name());
-        return StatusCode::RECOVERABLE;
-    }
+    ATH_CHECK_RECOVERABLE(m_pfitter_split.retrieve());
     ATH_MSG_DEBUG("Retrieved CSC split cluster fitting tool");
 
     // retrieve MuonDetectorManager from the conditions store
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscThresholdClusterBuilderTool.h b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscThresholdClusterBuilderTool.h
index 8a34695e763b..2e8ab9920ae3 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscThresholdClusterBuilderTool.h
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/CscThresholdClusterBuilderTool.h
@@ -55,13 +55,13 @@
 // Algorithm to construct CSC clusters from digits.
 
 #include "AthenaBaseComps/AthAlgTool.h"
-#include "CscClusterization/ICscClusterBuilder.h"
 #include "GaudiKernel/ToolHandle.h"
 #include "MuonIdHelpers/IMuonIdHelperSvc.h"
 #include "MuonPrepRawData/CscPrepDataContainer.h"
 #include "MuonPrepRawData/CscStripPrepDataContainer.h"
 #include "MuonPrepRawData/MuonPrepDataContainer.h"
 #include "MuonReadoutGeometry/MuonDetectorManager.h"
+#include "CscClusterization/ICscClusterBuilder.h"
 
 class ICscCalibTool;
 class ICscStripFitter;
@@ -123,15 +123,35 @@ class CscThresholdClusterBuilderTool : virtual public ICscClusterBuilder, public
     SG::WriteHandleKey<Muon::CscPrepDataContainer>     m_pclusters;  // SG key for output clusters
 
     // Calibration tool.
-    ToolHandle<ICscCalibTool> m_cscCalibTool;
+    ToolHandle<ICscCalibTool> m_cscCalibTool{
+        this,
+        "cscCalibTool",
+        "CscCalibTool/CscCalibTool",
+    };
 
     // Strip fitter.
-    ToolHandle<ICscStripFitter> m_pstrip_fitter;
+    ToolHandle<ICscStripFitter> m_pstrip_fitter{
+        this,
+        "strip_fitter",
+        "CalibCscStripFitter/CalibCscStripFitter",
+    };
 
     // Cluster fitters.
-    ToolHandle<ICscClusterFitter> m_pfitter_def;
-    ToolHandle<ICscClusterFitter> m_pfitter_prec;
-    ToolHandle<ICscClusterFitter> m_pfitter_split;
+    ToolHandle<ICscClusterFitter> m_pfitter_def{
+        this,
+        "default_fitter",
+        "SimpleCscClusterFitter/SimpleCscClusterFitter",
+    };
+    ToolHandle<ICscClusterFitter> m_pfitter_prec{
+        this,
+        "precision_fitter",
+        "QratCscClusterFitter/QratCscClusterFitter",
+    };
+    ToolHandle<ICscClusterFitter> m_pfitter_split{
+        this,
+        "split_fitter",
+        "CscSplitClusterFitter/CscSplitClusterFitter",
+    };
 
     ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{
         this,
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/QratCscClusterFitter.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/QratCscClusterFitter.cxx
index 3010bb8df977..ca448b9eb84f 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/QratCscClusterFitter.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/QratCscClusterFitter.cxx
@@ -226,7 +226,7 @@ qrat_atanh(const double a, const double b, double c, const double x0, double qra
 //****************************************************************************
 
 QratCscClusterFitter::QratCscClusterFitter(std::string type, std::string aname, const IInterface* parent)
-    : AthAlgTool(type, aname, parent), m_alignmentTool("CscAlignmentTool/CscAlignmentTool", this)
+    : AthAlgTool(type, aname, parent)
 {
     declareInterface<ICscClusterFitter>(this);
     m_max_width.push_back(5);                   // CSS eta
@@ -266,8 +266,6 @@ QratCscClusterFitter::QratCscClusterFitter(std::string type, std::string aname,
     declareProperty("atanh_x0_csl_eta", m_atanh_x0_csl_eta = 0.6615);
 
     declareProperty("dposmin", m_dposmin = 0.082);
-
-    declareProperty("CscAlignmentTool", m_alignmentTool);
 }
 
 //**********************************************************************
@@ -289,7 +287,6 @@ QratCscClusterFitter::initialize()
         ATH_MSG_DEBUG(name() << ": retrieved " << m_alignmentTool);
     }
 
-
     ATH_MSG_DEBUG("Properties for " << name() << ":");
     ATH_MSG_DEBUG("       Eta position option: " << m_posopt_eta);
     ATH_MSG_DEBUG("       Phi position option: " << m_posopt_phi);
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/QratCscClusterFitter.h b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/QratCscClusterFitter.h
index 14aaca0a6d18..01fd5118f304 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/QratCscClusterFitter.h
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/QratCscClusterFitter.h
@@ -86,6 +86,10 @@ class QratCscClusterFitter : virtual public ICscClusterFitter, public AthAlgTool
         "Muon::MuonIdHelperSvc/MuonIdHelperSvc",
     };
 
-    ToolHandle<ICscAlignmentTool> m_alignmentTool;
+    ToolHandle<ICscAlignmentTool> m_alignmentTool{
+        this,
+        "CscAlignmentTool",
+        "CscAlignmentTool/CscAlignmentTool",
+    };
 };
 #endif
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/SimpleCscClusterFitter.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/SimpleCscClusterFitter.cxx
index f07311045537..09c175ef1a07 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/SimpleCscClusterFitter.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/SimpleCscClusterFitter.cxx
@@ -24,7 +24,7 @@ enum CscStation { UNKNOWN_STATION, CSS, CSL };
 enum CscPlane { CSS_R, CSL_R, CSS_PHI, CSL_PHI, UNKNOWN_PLANE };
 
 SimpleCscClusterFitter::SimpleCscClusterFitter(std::string type, std::string aname, const IInterface* parent)
-    : AthAlgTool(type, aname, parent), m_alignmentTool("CscAlignmentTool/CscAlignmentTool", this)
+    : AthAlgTool(type, aname, parent)
 {
     declareInterface<ICscClusterFitter>(this);
     declareProperty("position_option", m_option = "MEAN", "Cluster fitting option: MEAN, PEAK, CENTROID");
@@ -32,8 +32,6 @@ SimpleCscClusterFitter::SimpleCscClusterFitter(std::string type, std::string ana
     declareProperty("use_peakthreshold", m_use_peakthreshold = false);
     declareProperty("defaultErrorScaler_eta", m_defaultErrorScaler_eta = 1.0);
     declareProperty("defaultErrorScaler_phi", m_defaultErrorScaler_phi = 1.0);
-
-    declareProperty("CscAlignmentTool", m_alignmentTool);
 }
 
 //**********************************************************************
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/SimpleCscClusterFitter.h b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/SimpleCscClusterFitter.h
index 7585a5525794..bcffb8c22a26 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/SimpleCscClusterFitter.h
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/CscClusterization/src/SimpleCscClusterFitter.h
@@ -55,6 +55,10 @@ class SimpleCscClusterFitter : virtual public ICscClusterFitter, public AthAlgTo
     SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey{
         this, "DetectorManagerKey", "MuonDetectorManager", "Key of input MuonDetectorManager condition data"};
 
-    ToolHandle<ICscAlignmentTool> m_alignmentTool;
+    ToolHandle<ICscAlignmentTool> m_alignmentTool{
+        this,
+        "CscAlignmentTool",
+        "CscAlignmentTool/CscAlignmentTool",
+    };
 };
 #endif
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationAlg.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationAlg.cxx
index f5d4bb07b196..abbe64e4e663 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationAlg.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationAlg.cxx
@@ -9,13 +9,12 @@
 using namespace Muon;
 
 MuonClusterizationAlg::MuonClusterizationAlg(const std::string& name, ISvcLocator* pSvcLocator)
-    : AthAlgorithm(name, pSvcLocator), m_clusterTool("Muon::MuonClusterizationTool/MuonClusterizationTool")
+    : AthAlgorithm(name, pSvcLocator)
 {
     declareProperty("TgcPrepDataContainer", m_tgcPrdLocationInput = "TGC_Measurements");
     declareProperty("TgcPrepDataContainerOutput", m_tgcPrdLocationOutput = "TGC_Clusters");
     declareProperty("RpcPrepDataContainer", m_rpcPrdLocationInput = "RPC_Measurements");
     declareProperty("RpcPrepDataContainerOutput", m_rpcPrdLocationOutput = "RPC_Clusters");
-    declareProperty("ClusterTool", m_clusterTool);
 }
 
 StatusCode
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationAlg.h b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationAlg.h
index b23e649d94cd..da2fbdf0f857 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationAlg.h
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationAlg.h
@@ -28,7 +28,11 @@ class MuonClusterizationAlg : public AthAlgorithm {
     std::string m_rpcPrdLocationInput;   //!< Location of input RpcPrepData
     std::string m_rpcPrdLocationOutput;  //!< Location of output RpcPrepData
 
-    ToolHandle<Muon::IMuonClusterizationTool> m_clusterTool;  //!< clustering Tool
+    ToolHandle<Muon::IMuonClusterizationTool> m_clusterTool{
+        this,
+        "ClusterTool",
+        "Muon::MuonClusterizationTool/MuonClusterizationTool",
+    };  //!< clustering Tool
 };
 
 #endif
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonTGMeasAssocAlg/MuonTGMeasAssocAlg/MuonTGMeasAssocAlg.h b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonTGMeasAssocAlg/MuonTGMeasAssocAlg/MuonTGMeasAssocAlg.h
index 7af26afb5d2e..a81ab5b69b83 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonTGMeasAssocAlg/MuonTGMeasAssocAlg/MuonTGMeasAssocAlg.h
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonTGMeasAssocAlg/MuonTGMeasAssocAlg/MuonTGMeasAssocAlg.h
@@ -88,7 +88,16 @@ class MuonTGMeasAssocAlg : public AthAlgorithm {
     mutable const Trk::TrackingGeometry* m_trackingGeometry;
     std::string                          m_trackingGeometryName;
 
-    ToolHandle<Muon::IMuonTGMeasTool> m_muonTgTool;
+    ToolHandle<Muon::IMuonTGMeasTool> m_muonTgTool{
+        this,
+        "MuonTGMeasurementTool",
+        "Muon::MuonTGMeasurementTool/MuonTGMeasurementTool",
+    };
+    ToolHandle<Trk::IExtrapolator> m_extrapolator{
+        this,
+        "Extrapolator",
+        "Trk::Extrapolator/Extrapolator",
+    };
 
     ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{this, "MuonIdHelperSvc",
                                                         "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
@@ -112,7 +121,6 @@ class MuonTGMeasAssocAlg : public AthAlgorithm {
     mutable std::vector<PairOfLayerPrd*>* m_tgcHits;
     mutable MuonTGHits*                   m_allHits;
     mutable MuonTGSegments*               m_allSegments;
-    ToolHandle<Trk::IExtrapolator>        m_extrapolator;
     mutable std::map<Identifier, std::pair<const MuonGM::MuonStation*, const Trk::DetachedTrackingVolume*> >
         m_stationMap;
     mutable std::vector<std::pair<Identifier, Amg::Transform3D> >
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonTGMeasAssocAlg/src/MuonTGMeasAssocAlg.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonTGMeasAssocAlg/src/MuonTGMeasAssocAlg.cxx
index 133a0f63fe21..7ab0b681e417 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonTGMeasAssocAlg/src/MuonTGMeasAssocAlg.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonTGMeasAssocAlg/src/MuonTGMeasAssocAlg.cxx
@@ -42,7 +42,6 @@ Muon::MuonTGMeasAssocAlg::MuonTGMeasAssocAlg(const std::string& name, ISvcLocato
       m_allowGeomAssoc(true),
       m_trackingGeometry(0),
       m_trackingGeometryName("AtlasTrackingGeometry"),
-      m_muonTgTool("Muon::MuonTGMeasurementTool/MuonTGMeasurementTool"),
       m_inputSegmentCollectionMoore("MooreSegments"),
       m_inputSegmentCollectionMoMu("MuonSegments_MoMu"),
       m_inputSegmentCollectionMBoy("ConvertedMBoySegments"),
@@ -56,11 +55,9 @@ Muon::MuonTGMeasAssocAlg::MuonTGMeasAssocAlg(const std::string& name, ISvcLocato
       m_cscHits(0),
       m_tgcHits(0),
       m_allHits(0),
-      m_allSegments(0),
-      m_extrapolator("Trk::Extrapolator/Extrapolator")
+      m_allSegments(0)
 {
     declareProperty("TrackingGeometry", m_trackingGeometryName);
-    declareProperty("Extrapolator", m_extrapolator);
     declareProperty("ProcessMdtHits", m_mdtIn);
     declareProperty("ProcessRpcHits", m_rpcIn);
     declareProperty("ProcessCscHits", m_cscIn);
-- 
GitLab