From 5df68bca4add0c10f1654c9b2e27ca056c982b33 Mon Sep 17 00:00:00 2001
From: Johannes Junggeburth <johannes.josef.junggeburth@cern.ch>
Date: Fri, 17 May 2024 09:43:47 +0200
Subject: [PATCH] Debug message

Simpliyfy hit clustering

Simplify the Tgc clustering

Clean up more unused tools

Clean uo

Remove includes

Delete Mdt hit clustering
---
 .../python/MuonSegmentFindingConfig.py        |  30 --
 .../MuonClusterization/CMakeLists.txt         |   4 -
 .../MuonClusterization/HitClustering.h        | 174 ------
 .../IMuonClusterizationTool.h                 |  31 --
 .../MuonClusterization/MdtHitClustering.h     | 127 -----
 .../MuonClusterization/TgcHitClustering.h     | 157 ++----
 .../MuonClusterization/src/HitClustering.cxx  | 272 ----------
 .../src/MdtHitClustering.cxx                  | 273 ----------
 .../src/MuonClusterizationAlg.cxx             |  55 --
 .../src/MuonClusterizationAlg.h               |  38 --
 .../src/MuonClusterizationTool.cxx            | 164 ------
 .../src/MuonClusterizationTool.h              |  49 --
 .../src/TgcHitClustering.cxx                  | 347 +++---------
 .../components/MuonClusterization_entries.cxx |   8 -
 .../MuonLayerHoughTool.h                      |  10 +-
 .../src/MuonLayerHoughTool.cxx                | 106 ++--
 .../IMuonCombiTrackMaker.h                    |  45 --
 .../src/MuonSegmentFinderAlg.cxx              |  25 +-
 .../src/MuonSegmentFinderAlg.h                |  48 +-
 .../src/DCMathSegmentMaker.cxx                |   1 +
 .../ATLAS_CHECK_THREAD_SAFETY                 |   1 -
 .../CMakeLists.txt                            |  17 -
 .../src/MuonClusterSegmentFinder.cxx          | 509 ------------------
 .../src/MuonClusterSegmentFinder.h            | 202 -------
 .../MuonClusterSegmentMakerTools_entries.cxx  |   5 -
 .../src/MuonLayerSegmentFinderTool.cxx        |  12 +-
 .../src/MuonLayerSegmentFinderTool.h          |   3 +-
 .../IMuonClusterSegmentFinder.h               |  54 --
 .../IMuonPatternSegmentMaker.h                |  54 --
 .../src/MuonRecoValidationTool.cxx            |   2 +-
 .../src/MuonInDetToMuonSystemExtensionAlg.cxx |   2 +-
 .../src/MuonStauRecoTool.cxx                  |   8 +-
 32 files changed, 195 insertions(+), 2638 deletions(-)
 delete mode 100644 MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/MuonClusterization/HitClustering.h
 delete mode 100644 MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/MuonClusterization/IMuonClusterizationTool.h
 delete mode 100644 MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/MuonClusterization/MdtHitClustering.h
 delete mode 100644 MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/HitClustering.cxx
 delete mode 100644 MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MdtHitClustering.cxx
 delete mode 100644 MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationAlg.cxx
 delete mode 100644 MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationAlg.h
 delete mode 100644 MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationTool.cxx
 delete mode 100644 MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationTool.h
 delete mode 100644 MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/components/MuonClusterization_entries.cxx
 delete mode 100644 MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/MuonRecToolInterfaces/IMuonCombiTrackMaker.h
 delete mode 100644 MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/ATLAS_CHECK_THREAD_SAFETY
 delete mode 100644 MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/CMakeLists.txt
 delete mode 100644 MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/MuonClusterSegmentFinder.cxx
 delete mode 100644 MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/MuonClusterSegmentFinder.h
 delete mode 100644 MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/components/MuonClusterSegmentMakerTools_entries.cxx
 delete mode 100644 MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinder.h
 delete mode 100644 MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonPatternSegmentMaker.h

diff --git a/MuonSpectrometer/MuonConfig/python/MuonSegmentFindingConfig.py b/MuonSpectrometer/MuonConfig/python/MuonSegmentFindingConfig.py
index cbeb2459bad3..cc8ea3d7fc8f 100644
--- a/MuonSpectrometer/MuonConfig/python/MuonSegmentFindingConfig.py
+++ b/MuonSpectrometer/MuonConfig/python/MuonSegmentFindingConfig.py
@@ -395,32 +395,6 @@ def MuonPRDSelectionToolCfg( flags, name="MuonPRDSelectionTool", **kwargs):
     result.setPrivateTools(the_tool)
     return result
 
-def MuonClusterSegmentFinderCfg(flags, name = " MuonClusterSegmentFinder", **kwargs):
-    from MuonConfig.MuonRecToolsConfig import MuonTrackToSegmentToolCfg
-    from MuonConfig.MuonRIO_OnTrackCreatorToolConfig import MuonClusterOnTrackCreatorCfg
-
-    result=ComponentAccumulator()
-
-    # Won't explicitly configure MuonIdHelperSvc
-    edm_printer = result.popToolsAndMerge(MuonEDMPrinterToolCfg(flags) )
-    kwargs.setdefault("MuonEDMPrinterTool", edm_printer)
-    # Won't explicitly configure MuonLayerHashProviderTool
-    kwargs.setdefault("MuonPRDSelectionTool", result.popToolsAndMerge( MuonPRDSelectionToolCfg(flags) ) )
-    kwargs.setdefault('MdtSegmentMaker', result.popToolsAndMerge( DCMathSegmentMakerCfg(flags,name="DCMathSegmentMaker") ) ) 
-    # Won't explicitly configure MuonClusterizationTool
-    kwargs.setdefault("MuonClusterOnTrackCreator", result.popToolsAndMerge(MuonClusterOnTrackCreatorCfg(flags)) )
-    kwargs.setdefault("TrackToSegmentTool", result.popToolsAndMerge( MuonTrackToSegmentToolCfg(flags) ) )
-    kwargs.setdefault('SLFitter', result.popToolsAndMerge( MCTBSLFitterCfg(flags) ) ) 
-    kwargs.setdefault('AmbiguityProcessor', result.popToolsAndMerge( MuonAmbiProcessorCfg(flags) ) ) 
-    kwargs.setdefault('TrackCleaner', result.popToolsAndMerge( MuonTrackCleanerCfg(flags) ) ) 
-    kwargs.setdefault('MuonSegmentOverlapRemovalTool', CompFactory.Muon.MuonSegmentOverlapRemovalTool(Printer=edm_printer)) 
-    
-    # Won't explicitly configure MuonSegmentOverlapRemovalTool (though it possibly needs it)
-
-    from MuonConfig.MuonRecToolsConfig import MuonTrackToSegmentToolCfg
-    kwargs.setdefault( "TrackToSegmentTool", result.popToolsAndMerge(MuonTrackToSegmentToolCfg(flags)))
-    result.setPrivateTools(CompFactory.Muon.MuonClusterSegmentFinder(name, **kwargs))
-    return result
 
 def MuonLayerHoughToolCfg(flags, name = "MuonLayerHoughTool" , **kwargs):
     result = ComponentAccumulator()
@@ -486,8 +460,6 @@ def MuonPatternCalibrationCfg(flags, name="MuonPatternCalibration", **kwargs):
 def MuonSegmentFinderNCBAlgCfg(flags, name="MuonSegmentMaker_NCB", **kwargs):
     from MuonConfig.MuonRIO_OnTrackCreatorToolConfig import MuonClusterOnTrackCreatorCfg
     result = ComponentAccumulator()
-    ### Only use the TGC measurements from the  current bunch crossing
-    kwargs.setdefault("TGC_PRDs", "TGC_Measurements")
     kwargs.setdefault("doStgcSegments", flags.Detector.EnablesTGC)
     kwargs.setdefault("doMMSegments", flags.Detector.EnableMM)
     kwargs.setdefault("doMdtSegments", False)
@@ -544,7 +516,6 @@ def MuonSegmentFinderAlgCfg(flags, name="MuonSegmentMaker", **kwargs):
     kwargs.setdefault('MuonPatternCalibration', result.popToolsAndMerge( MuonPatternCalibrationCfg(flags) ) )   
     segment_maker = result.getPrimaryAndMerge(DCMathSegmentMakerCfg(flags,name="DCMathSegmentMaker"))
     kwargs.setdefault('SegmentMaker', segment_maker)
-    kwargs.setdefault("MuonClusterSegmentFinder", result.popToolsAndMerge(MuonClusterSegmentFinderCfg(flags, name = "MuonClusterSegmentFinder")))
     # Not yet configuring MuonSegmentOverlapRemovalTool
     
     if flags.Detector.EnableMM or flags.Detector.EnablesTGC:
@@ -569,7 +540,6 @@ def MuonSegmentFinderAlgCfg(flags, name="MuonSegmentMaker", **kwargs):
     kwargs.setdefault("doMMSegments", flags.Detector.EnableMM)
 
     kwargs.setdefault("SegmentCollectionName",  "TrackMuonSegments" if flags.Muon.segmentOrigin != "TruthTracking" else "ThirdChainSegments")
-    kwargs.setdefault('TGC_PRDs', 'TGC_MeasurementsAllBCs' if not flags.Muon.useTGCPriorNextBC else 'TGC_Measurements')
 
     the_alg = CompFactory.MuonSegmentFinderAlg( name, **kwargs)                                               
     result.addEventAlgo(the_alg)
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/CMakeLists.txt b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/CMakeLists.txt
index 54d7e73727ca..56acd620a2ee 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/CMakeLists.txt
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/CMakeLists.txt
@@ -12,7 +12,3 @@ atlas_add_library( MuonClusterizationLib
                    LINK_LIBRARIES GeoPrimitives Identifier GaudiKernel MuonReadoutGeometry MuonPrepRawData MuonIdHelpersLib
                    PRIVATE_LINK_LIBRARIES AthenaBaseComps EventPrimitives )
 
-atlas_add_component( MuonClusterization
-                     src/components/*.cxx
-                     LINK_LIBRARIES GeoPrimitives Identifier GaudiKernel MuonReadoutGeometry MuonIdHelpersLib MuonPrepRawData AthenaBaseComps EventPrimitives MuonClusterizationLib )
-
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/MuonClusterization/HitClustering.h b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/MuonClusterization/HitClustering.h
deleted file mode 100644
index 7d570d0f7bb8..000000000000
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/MuonClusterization/HitClustering.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
-  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
-*/
-
-#ifndef TGCHITCLUSTERING_H
-#define TGCHITCLUSTERING_H
-
-#include <vector>
-#include "MuonPrepRawData/MuonPrepDataContainer.h"
-#include "MuonPrepRawData/MuonCluster.h"
-#include "MuonReadoutGeometry/MuonClusterReadoutElement.h"
-#include "GeoPrimitives/GeoPrimitives.h"
-
-#include "Identifier/Identifier.h"
-#include "MuonIdHelpers/MuonIdHelper.h"
-
-namespace Muon {
-
-  struct ClusterObj {    
-    ClusterObj() : ngasgap1(0),ngasgap2(0),ngasgap3(0) {}    
-
-    void add( const MuonCluster* prd, int gasgap ) { 
-      if( gasgap == 1 )      ++ngasgap1;
-      else if( gasgap == 2 ) ++ngasgap2;
-      else                   ++ngasgap3;
-      hitList.push_back( prd ); 
-    }
-
-
-    bool addSecond( const MuonCluster* prd, int gasgap ) { 
-      std::vector< const MuonCluster* >::iterator it = hitList.begin(); 
-      std::vector< const MuonCluster* >::iterator it_end = hitList.end(); 
-    
-      const RpcPrepData* rp_prd =dynamic_cast<const RpcPrepData*>(prd);
-      if(!rp_prd) return true;//If cast fails then the iterator is not an RpcPrepDataObject return as if it was a tgcPerpDataObject
-
-      for( ;it!=it_end;++it ){ 
-	const RpcPrepData* rp_it =dynamic_cast<const RpcPrepData*>(*it); 
-	if(!rp_it) return true;//If the iterator is an RpcPrepDataObject continue
-	if( rp_it->identify() != prd->identify() ) continue;
-	if( fabs( rp_it->time() - 12.5) > fabs( rp_prd->time() - 12.5 ) ){
-	  return true;
-	}     
-      }
-      add(prd,gasgap); 
-      return false;
-    }
-
-
-    void merge( ClusterObj& cluster ) {
-      hitList.insert(hitList.end(),cluster.hitList.begin(),cluster.hitList.end());
-      ngasgap1 += cluster.ngasgap1;
-      ngasgap2 += cluster.ngasgap2;
-      ngasgap3 += cluster.ngasgap3;
-      cluster.ngasgap1 = 0;
-      cluster.ngasgap2 = 0;
-      cluster.ngasgap3 = 0;
-      cluster.hitList.clear();
-    }
-      
-    bool active() const { return !hitList.empty(); }
-    
-    int layers() const {
-      if( hitList.empty() ) return 0;
-      int nl = 0;
-      if( ngasgap1 > 0 ) ++nl;
-      if( ngasgap2 > 0 ) ++nl;
-      if( ngasgap3 > 0 ) ++nl;
-      return nl;
-    }
-
-    int ngasgap1;
-    int ngasgap2;
-    int ngasgap3;
-    std::vector<const MuonCluster*> hitList;
-  };
-
-  struct ClusterObj3D {
-    ClusterObj3D( const ClusterObj& etaC, const ClusterObj& phiC )  : etaCluster(etaC), phiCluster(phiC) {}
-
-    ClusterObj etaCluster;
-    ClusterObj phiCluster;
-
-    Amg::Vector3D p11;
-    Amg::Vector3D p12;
-    Amg::Vector3D p21;
-    Amg::Vector3D p22;
-  };
-
-  struct SortClusterObjs {
-    bool operator()(const ClusterObj& cl1,const ClusterObj& cl2 ) const {
-      if( cl1.layers() > cl2.layers() ) return true;
-      else if( cl1.layers() < cl2.layers() ) return false;
-      return cl1.hitList.size() < cl2.hitList.size();
-    }
-  };
-
-  struct SortHitList {
-    bool operator()(const MuonCluster* h1,const MuonCluster* h2 ) const {
-      return h1->localPosition().x() < h2->localPosition().x();
-    }
-  };
-
-  struct HitClusteringObj {
-
-    struct Id {
-      Id( int g, int c ) : gp(g),ch(c) {}
-      int gp;
-      int ch;
-    };
-
-    struct Triplet {
-      Triplet() : first(-1),second(-1),third(-1) {}
-      int first;
-      int second;
-      int third;
-      int sum() const { return first+second+third; }
-    };
-
-    struct Data
-    {
-      std::vector<ClusterObj>   clustersEta;
-      std::vector<ClusterObj>   clustersPhi;
-    };
-
-
-
-    HitClusteringObj( const MuonIdHelper& muonIdHelper,
-                      bool combinedGasGaps,
-                      bool debug = false) : 
-      m_muonIdHelper(&muonIdHelper),
-      m_debug(debug),m_combinedGasGaps(combinedGasGaps)
-    {}
-
-    
-    bool cluster( const std::vector<const MuonCluster*>& col,
-                  std::vector<ClusterObj>& clustersEta,
-                  std::vector<ClusterObj>& clustersPhi) const;
-
-    bool cluster( const std::vector<const TgcPrepData*>& col,
-                  std::vector<ClusterObj>& clustersEta,
-                  std::vector<ClusterObj>& clustersPhi) const
-    {
-      std::vector<const MuonCluster*> prds;      
-      for(unsigned int i=0; i < col.size(); i++){
-	prds.push_back(col.at(i));
-      }
-      return cluster( prds, clustersEta, clustersPhi );
-    };
-
-
-    std::vector<ClusterObj3D>
-    buildClusters3D(const std::vector<ClusterObj>& clustersEta,
-                    const std::vector<ClusterObj>& clustersPhi) const;
-
-    void dump(const std::vector<ClusterObj>& clustersEta,
-              const std::vector<ClusterObj>& clustersPhi) const;
-
-    const ClusterObj* bestCluster(const std::vector<ClusterObj>& clusters) const {
-      if( clusters.empty() ) return nullptr;
-      return &clusters.front();
-    }
-
-    static void findBest(std::vector<ClusterObj>& clustersEta,
-                  std::vector<ClusterObj>& clustersPhi) ;
-
-  private:
-    const MuonIdHelper*       m_muonIdHelper;
-    bool m_debug;
-    bool m_combinedGasGaps;
-  };
-
-}
-#endif
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/MuonClusterization/IMuonClusterizationTool.h b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/MuonClusterization/IMuonClusterizationTool.h
deleted file mode 100644
index 3872ce405511..000000000000
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/MuonClusterization/IMuonClusterizationTool.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-#ifndef IMUONCLUSTERIZATIONTOOL_H
-#define IMUONCLUSTERIZATIONTOOL_H
-
-#include "GaudiKernel/IAlgTool.h"
-#include "MuonPrepRawData/MuonPrepDataContainer.h"
-
-static const InterfaceID IID_IMuonClusterizationTool ("Muon::IMuonClusterizationTool",1,0);
-
-namespace Muon {
-
-
-  class IMuonClusterizationTool : virtual public IAlgTool
-  {
-  public:
-    virtual Muon::TgcPrepDataContainer*  cluster( const Muon::TgcPrepDataContainer& prdContainer ) const = 0;
-    virtual Muon::TgcPrepDataCollection* cluster( const Muon::TgcPrepDataCollection& col ) const = 0;
-
-    virtual Muon::RpcPrepDataContainer*  cluster( const Muon::RpcPrepDataContainer& prdContainer ) const = 0;
-    virtual Muon::RpcPrepDataCollection* cluster( const Muon::RpcPrepDataCollection& col ) const = 0;
-
-    /** access to tool interface */
-    static const InterfaceID& interfaceID() { return IID_IMuonClusterizationTool; }
-
-  };
-}
-
-#endif 
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/MuonClusterization/MdtHitClustering.h b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/MuonClusterization/MdtHitClustering.h
deleted file mode 100644
index 996cfa02457b..000000000000
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/MuonClusterization/MdtHitClustering.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-#ifndef MDTHITCLUSTERING_H
-#define MDTHITCLUSTERING_H
-
-#include <vector>
-#include <algorithm>
-#include "MuonPrepRawData/MuonPrepDataContainer.h"
-#include "MuonPrepRawData/MdtPrepData.h"
-
-#include "Identifier/Identifier.h"
-
-class MdtIdHelper;
-namespace MuonGM {
-  class MuonDetectorManager;
-  class MdtReadoutElement;
-}
-
-namespace Muon {
-  
-  class MdtPrepData;
-  
-  struct MdtCluster {
-    
-    typedef std::vector< const MdtPrepData* > HitList;
-    typedef HitList::iterator                 HitIt;
-    typedef HitList::const_iterator           HitCit;
-    MdtCluster() {}
-    
-    void add( const MdtPrepData* prd ) { hitList.push_back(prd); }
-    void addSecond( const MdtPrepData* prd ) { 
-      HitIt it = hitList.begin();
-      HitIt it_end = hitList.end();
-      for( ;it!=it_end;++it ){
-	if( (*it)->identify() != prd->identify() ) continue;
-
-	// selected on of the two
-	if( (*it)->status() == MdtStatusDriftTime ) {
-	  if( prd->status() == MdtStatusDriftTime ) {
-	    //std::cout << " found two hits inside the drift time spectrum!! " << prd->tdc() << " " << (*it)->tdc() << std::endl;
-	    if( prd->tdc() < (*it)->tdc() ) *it = prd;
-	  }
-	}else if( prd->status() == MdtStatusDriftTime ){
-	  // replace PRD
-	  *it = prd;
-	}
- 	return;
-      }
-      std::cout << "could not find duplicate prd " << std::endl;
-      add(prd);
-    }
-    void merge( MdtCluster& cluster ) {
-      hitList.insert(hitList.end(),cluster.hitList.begin(),cluster.hitList.end());
-      cluster.hitList.clear();
-    }
-    
-    bool active() const { return !hitList.empty(); }
-
-    void isolation( int& all, int& inTime, int& inTimeAndBefore ) const {
-      all = hitList.size();
-      inTime = 0;
-      inTimeAndBefore = 0;
-      HitCit it = hitList.begin();
-      HitCit it_end = hitList.end();
-      for( ;it!=it_end;++it ){
-	if( (*it)->adc() > 50 ){
-	  if( (*it)->status() == Muon::MdtStatusDriftTime ) {
-	    ++inTime;
-	    ++inTimeAndBefore;
-	  }else if( (*it)->status() == Muon::MdtStatusBeforeSpectrum ) {
-	    ++inTimeAndBefore;	    
-	  }
-	}
-      }
-    }
-    
-    HitList hitList;
-  };
-  
-  struct MdtHitClustering {
-
-    struct Id {
-      Id( int l, int t ) : lay(l),tube(t) {}
-      int lay;
-      int tube;
-    };
-
-    typedef std::vector< std::vector<int> > HitPattern;
-
-    MdtHitClustering( const MdtIdHelper& mdtIdHelper, const MuonGM::MuonDetectorManager& detMgr ) : 
-      m_mdtIdHelper(&mdtIdHelper), m_detMgr(&detMgr), detEl1(0), detEl2(0), nlay(0), ntube1(0), ntube2(0), nml(0), debug(false)
-    {
-
-    }
-
-    bool init( const Identifier& chid );
-
-    void neighbouringTubes( const Id& id, std::vector<Id>& neighbours ) const;
-
-    bool cluster( const MdtPrepDataCollection& col );
-
-    void dump() const;
-
-    void layers( const MdtCluster& cl, int& all, int& inTime, int& inTimeAndBefore ) const;
-
-    const MdtIdHelper* m_mdtIdHelper;
-    const MuonGM::MuonDetectorManager* m_detMgr; // cannot use ReadCondHandleKey since no athena component
-    const MuonGM::MdtReadoutElement* detEl1;
-    const MuonGM::MdtReadoutElement* detEl2;
-    unsigned int nlay;
-    unsigned int ntube1;
-    unsigned int ntube2;
-    unsigned int nml;
-    HitPattern hitPattern;
-
-    std::vector< MdtCluster > clusters;
-    std::vector<int> staggeringCorrection;    
-    bool debug;
-  };
-
-}
-
-
-
-#endif
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/MuonClusterization/TgcHitClustering.h b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/MuonClusterization/TgcHitClustering.h
index 8f5682493d0a..eaa08493ac1d 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/MuonClusterization/TgcHitClustering.h
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/MuonClusterization/TgcHitClustering.h
@@ -16,139 +16,58 @@
 
 namespace Muon {
 
-  class TgcClusterObj {
-  public:
-    
-    typedef std::vector< const TgcPrepData* > HitList;
-    typedef HitList::iterator                 HitIt;
-    typedef HitList::const_iterator           HitCit;
-    TgcClusterObj() : ngasgap1(0),ngasgap2(0),ngasgap3(0) {}
-    
-    void add( const TgcPrepData* prd, int gasgap ) { 
-      if( gasgap == 1 )      ++ngasgap1;
-      else if( gasgap == 2 ) ++ngasgap2;
-      else                   ++ngasgap3;
-      hitList.push_back( prd ); 
-    }
-
-    void addSecond( const TgcPrepData* /*prd*/, int /*gasgap*/ ) { 
-      return;
-      /* 	HitIt it = hitList.begin(); */
-      /* 	HitIt it_end = hitList.end(); */
-      /* 	for( ;it!=it_end;++it ){ */
-      /* 	  if( (*it)->identify() != prd->identify() ) continue; */
-      /* 	} */
-      /* 	std::cout << "could not find duplicate prd " << std::endl; */
-      /* 	add(prd); */
-    }
-
-    void merge( TgcClusterObj& cluster ) {
-      hitList.insert(hitList.end(),cluster.hitList.begin(),cluster.hitList.end());
-      ngasgap1 += cluster.ngasgap1;
-      ngasgap2 += cluster.ngasgap2;
-      ngasgap3 += cluster.ngasgap3;
-      cluster.ngasgap1 = 0;
-      cluster.ngasgap2 = 0;
-      cluster.ngasgap3 = 0;
-      cluster.hitList.clear();
-    }
-      
-    bool active() const { return !hitList.empty(); }
-    
-    int layers() const {
-      if( hitList.empty() ) return 0;
-      int nl = 0;
-      if( ngasgap1 > 0 ) ++nl;
-      if( ngasgap2 > 0 ) ++nl;
-      if( ngasgap3 > 0 ) ++nl;
-      return nl;
-    }
-
-    int ngasgap1;
-    int ngasgap2;
-    int ngasgap3;
-    HitList hitList;
-  };
-
   class TgcClusterObj3D {
-  public:
-    TgcClusterObj3D( const TgcClusterObj& etaC, const TgcClusterObj& phiC )  : etaCluster(etaC), phiCluster(phiC) {}
-
-    TgcClusterObj etaCluster;
-    TgcClusterObj phiCluster;
-
-    Amg::Vector3D p11;
-    Amg::Vector3D p12;
-    Amg::Vector3D p21;
-    Amg::Vector3D p22;
-  };
-
-  struct SortTgcClusterObjs {
-    bool operator()(const TgcClusterObj& cl1,const TgcClusterObj& cl2 ) const {
-      if( cl1.layers() > cl2.layers() ) return true;
-      else if( cl1.layers() < cl2.layers() ) return false;
-      return cl1.hitList.size() < cl2.hitList.size();
-    }
-  };
-
-  struct SortTgcHitList {
-    bool operator()(const TgcPrepData* h1,const TgcPrepData* h2 ) const {
-      return h1->localPosition().x() < h2->localPosition().x();
-    }
+    public:
+        
+        using HitList =  std::vector< const TgcPrepData* >;
+
+        TgcClusterObj3D( const HitList& etaC, const HitList& phiC )  : 
+            etaCluster(etaC), phiCluster(phiC) {}
+        HitList etaCluster{};
+        HitList phiCluster{};
+
+        /// Representation of the four edge points
+        enum class Edge : uint8_t{
+            LowEtaLowPhi = 0,
+            LowEtaHighPhi,
+            HighEtaLowPhi,
+            HighEtaHighPhi
+        };
+        Amg::Vector3D& getEdge(const Edge e) {
+            return m_edgePoints[static_cast<unsigned>(e)];
+        }
+        const Amg::Vector3D& getEdge(const Edge e) const {
+            return m_edgePoints[static_cast<unsigned>(e)];
+        }
+
+      private:
+        std::array<Amg::Vector3D, 4> m_edgePoints{make_array<Amg::Vector3D, 4>(Amg::Vector3D::Zero())};
   };
 
   struct TgcHitClusteringObj {
 
-    struct Id {
-      Id( int g, int c ) : gp(g),ch(c) {}
-      int gp;
-      int ch;
-    };
-
-    struct Triplet {
-      Triplet() : first(-1),second(-1),third(-1) {}
-      int first;
-      int second;
-      int third;
-      int sum() const { return first+second+third; }
-    };
-    typedef std::vector< Triplet > HitClustering;
+    using HitList =  TgcClusterObj3D::HitList;
 
     TgcHitClusteringObj( const TgcIdHelper* tgcIdHelp ) :
-      m_tgcIdHelper(tgcIdHelp),bunchIdBestEta(-99),bunchIdBestPhi(-99),
-      ngasgaps(-99),debug(false),combinedGasGaps(true)
-    {}
-
+        m_tgcIdHelper(tgcIdHelp) {}
     
-    bool cluster( const std::vector<const TgcPrepData*>& col );
+    bool cluster(const HitList& col );
+    bool cluster(HitList& filteredHits,
+                std::vector<HitList>& finalClusts);
 
     bool buildClusters3D();
 
     void dump() const;
 
-    const TgcClusterObj* bestEtaCluster() const {
-      if( clustersEta.empty() ) return 0;
-      return &clustersEta.front();
-    }
-
-    const TgcClusterObj* bestPhiCluster() const {
-      if( clustersPhi.empty() ) return 0;
-      return &clustersPhi.front();
-    }
+    const HitList& bestEtaCluster() const;
+    const HitList& bestPhiCluster() const;
  
-    void findBest();
-
-    const TgcIdHelper*        m_tgcIdHelper;
-    std::vector<Triplet>      channelsEta;
-    std::vector<Triplet>      channelsPhi;
-    std::vector<TgcClusterObj>   clustersEta;
-    std::vector<TgcClusterObj>   clustersPhi;
-    std::vector<TgcClusterObj3D> clusters3D;
-    int bunchIdBestEta;
-    int bunchIdBestPhi;
-    int ngasgaps;
-    bool debug;
-    bool combinedGasGaps;
+   
+    const TgcIdHelper*        m_tgcIdHelper{nullptr};
+    std::vector<HitList>   clustersEta{};
+    std::vector<HitList>   clustersPhi{};
+    std::vector<TgcClusterObj3D> clusters3D{};
+
   };
 
 }
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/HitClustering.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/HitClustering.cxx
deleted file mode 100644
index e2ac786ddb1a..000000000000
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/HitClustering.cxx
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
-  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
-*/
-
-#include "MuonClusterization/HitClustering.h"
-
-
-namespace Muon {
-
-  bool HitClusteringObj::cluster( const std::vector<const MuonCluster*>& col,
-                                  std::vector<ClusterObj>& clustersEta,
-                                  std::vector<ClusterObj>& clustersPhi) const {
-    if( col.empty() ) return false;
-
-    std::vector<const MuonCluster*>::const_iterator cit_begin = col.begin();
-    std::vector<const MuonCluster*>::const_iterator cit_end = col.end();
-    if( cit_begin == cit_end ) return false;
-    std::vector<const MuonCluster*>::const_iterator cit = cit_begin;
-    const Muon::MuonCluster* prd_first = *cit;
-    if( !prd_first ) return false;
-
-    const MuonGM::MuonClusterReadoutElement*  detEl = prd_first->detectorElement();
-    const Identifier& id_first = prd_first->identify();
-    if( !detEl ) return false;
-    int ngasgaps = detEl->numberOfLayers(detEl->measuresPhi(id_first));
-
-    if( m_debug ) std::cout << " performing clustering " << col.size() << " gasgaps " << ngasgaps << std::endl;
-
-    std::vector<Triplet>      channelsEta;
-    std::vector<Triplet>      channelsPhi;
-
-    clustersEta.clear();
-    clustersPhi.clear();
-
-    //    std::cout << "channel check " << m_muonIdHelper->channelMax(id_first) << std::endl;
-    channelsEta.resize(1340);//m_muonIdHelper->channelMax(id_first)+2); // Need better way to find max number of channels
-    channelsPhi.resize(1340);//m_muonIdHelper->channelMax(id_first)+2);
-    std::vector<Triplet>* channelsPtr = nullptr;
-    for( ; cit!=cit_end;++cit ) {
-      const Muon::MuonCluster* prd = *cit;
-      if( !prd ) continue;
-
-      const Identifier& id = prd->identify();
-      bool measuresPhi = m_muonIdHelper->measuresPhi(id); // like measuresPhi()
-      std::vector<ClusterObj>& clusters = measuresPhi ? clustersPhi : clustersEta;
-      int channel = m_muonIdHelper->channel(id); // between 1 and 135!
-      int gasgap = m_muonIdHelper->gasGap(id);
-	
-      if(measuresPhi) channelsPtr = &channelsPhi;
-      else            channelsPtr = &channelsEta;
-      if( channel >= (int)channelsPtr->size() ){
-	//ATH_MSG_WARNING("index channels out of range: " << channel << " max " << channelsPtr->size());
-	continue;
-      }
-      Triplet& triplet = (*channelsPtr)[channel];
-
-      // first treat the case of a second hit in the same tube
-      int channelClusterNumber = gasgap==1 ? triplet.first : (gasgap==2 ? triplet.second : triplet.third );
-      if( channelClusterNumber != -1 ){
-	if( m_debug ){
-	  std::cout << " secondary hit " << channel << "  " << gasgap;
-	  if( measuresPhi ) std::cout << " phi " << channelClusterNumber << std::endl;
-	  else              std::cout << " eta " << channelClusterNumber << std::endl;
-	}
-	ClusterObj& cluster = clusters[channelClusterNumber];
-	cluster.addSecond(prd,gasgap);
-      }else{
-	
-	std::vector<Id> neighbours;
-	if( channel != 0 )                         neighbours.emplace_back(gasgap,channel-1 );
-	if( channel < (int)channelsPtr->size()-1 ) neighbours.emplace_back(gasgap,channel+1 );
-
-	if( m_combinedGasGaps ){
-	  if( gasgap != 1 ){
-	    neighbours.emplace_back(1,channel );
-	    if( channel != 0 )                         neighbours.emplace_back(1,channel-1 );
-	    if( channel < (int)channelsPtr->size()-1 ) neighbours.emplace_back(1,channel+1 );
-	  }
-	  
-	  if( gasgap != 2 ) {
-	    neighbours.emplace_back(2,channel );
-	    if( channel != 0 )                         neighbours.emplace_back(2,channel-1 );
-	    if( channel < (int)channelsPtr->size()-1 ) neighbours.emplace_back(2,channel+1 );
-	  }
-	  
-	  if( ngasgaps == 3 && gasgap != 3 ){
-	    neighbours.emplace_back(3,channel );
-	    if( channel != 0 )                         neighbours.emplace_back(3,channel-1 );
-	    if( channel < (int)channelsPtr->size()-1 ) neighbours.emplace_back(3,channel+1 );
-	  }
-	}
-
-	if( m_debug ) {
-	  std::cout << " new hit " << channel << "  " << gasgap;
-	  if( measuresPhi ) std::cout << " phi " << " neighbours " << neighbours.size() << std::endl;
-	  else              std::cout << " eta " << " neighbours " << neighbours.size() << std::endl;
-	}
-	std::vector<Id>::iterator nit = neighbours.begin();
-	std::vector<Id>::iterator nit_end = neighbours.end();
-	ClusterObj* currentCluster = nullptr;
-	int currentClusterId = -1;
-	for( ;nit!=nit_end;++nit ){
-
-	  Triplet& trip = (*channelsPtr)[nit->ch];
-	  
-	  int clusterNumber = nit->gp==1 ? trip.first : nit->gp==2 ? trip.second : trip.third;
-	  if( clusterNumber == -1 ) continue;
-	  if( m_debug ) std::cout << "    new neighbour " << nit->gp << "  " << nit->ch << " clusterid " << clusterNumber;
-	  
-	  ClusterObj& cluster = clusters[clusterNumber];
-	  
-	  // if the hit is unassigned add it to the cluster
-	  if( currentCluster == nullptr ){
-	    cluster.add(prd,gasgap);
-	    currentCluster = &cluster;
-	    if( gasgap==1 )      triplet.first  = clusterNumber;
-	    else if( gasgap==2 ) triplet.second = clusterNumber;
-	    else                 triplet.third  = clusterNumber;
-	    currentClusterId = clusterNumber;
-	    if( m_debug ) std::cout << " adding hit " << std::endl;
-	  }else if( clusterNumber != currentClusterId ){
-	    // the hit is already assigned to a cluster, merge the two clusters
-	    // first update hitPattern
-	    std::vector<const MuonCluster*>::const_iterator h= cluster.hitList.begin();
-	    std::vector<const MuonCluster*>::const_iterator  h_end = cluster.hitList.end();
-	    for( ;h!=h_end;++h ) {
-	      const Identifier& cid = (*h)->identify();
-	      int ch = m_muonIdHelper->channel(cid);
-	      int gp = m_muonIdHelper->gasGap(cid);
-	      Triplet& trip = (*channelsPtr)[ch];
-	      if( gp==1 )      trip.first  = currentClusterId;
-	      else if( gp==2 ) trip.second = currentClusterId;
-	      else             trip.third  = currentClusterId;
-	    }
-	    if( m_debug ) std::cout << " cluster overlap, merging clusters " << std::endl;
-	    currentCluster->merge(cluster);
-	  }else{
-	    if( m_debug ) std::cout << " cluster overlap, same cluster " << std::endl;
-	  }
-	}
-	// now check whether the hit was already assigned to a cluster, if not create a new cluster
-	if( currentCluster == nullptr ){
-	  if( m_debug ) std::cout << " no neighbouring hits, creating new cluster " << clusters.size() << std::endl;
-	  ClusterObj cl;
-	  cl.add(prd,gasgap);
-	  Triplet& trip = (*channelsPtr)[channel];
-	  if( gasgap==1 )      trip.first  = clusters.size();
-	  else if( gasgap==2 ) trip.second = clusters.size();
-	  else                 trip.third  = clusters.size();
-	  clusters.push_back(cl);
-	}
-      }
-    }
-    findBest(clustersEta, clustersPhi);
-    if( m_debug ) dump(clustersEta, clustersPhi);
-    return true;
-  }
-
-
-  void HitClusteringObj::dump(const std::vector<ClusterObj>& clustersEta,
-                              const std::vector<ClusterObj>& clustersPhi) const {
-
-    int clid = -1;
-    std::vector<ClusterObj>::const_iterator cit = clustersEta.begin();
-    std::vector<ClusterObj>::const_iterator cit_end = clustersEta.end();
-    for( ;cit!=cit_end;++cit ){
-      ++clid;
-      if( !cit->active() ) continue;
-      std::cout << " new cluster " << clid << "  size " << cit->hitList.size() << std::endl;
-      std::vector< const MuonCluster* >::const_iterator hit = cit->hitList.begin();
-      std::vector< const MuonCluster* >::const_iterator hit_end = cit->hitList.end();
-      for( ;hit!=hit_end;++hit ){	
-	const Muon::MuonCluster& prd = **hit;
-	const Identifier& id = prd.identify();
-	std::cout << "   hit " << m_muonIdHelper->gasGap(id) << " " << m_muonIdHelper->channel(id)-1;
-	bool measuresPhi = m_muonIdHelper->measuresPhi(id); 
-	if(measuresPhi) std::cout << " phi" << std::endl;
-	else            std::cout << " eta" << std::endl;
-      }
-    }
-    cit = clustersPhi.begin();
-    cit_end = clustersPhi.end();
-    for( ;cit!=cit_end;++cit ){
-      ++clid;
-      if( !cit->active() ) continue;
-      std::cout << " new cluster " << clid << "  size " << cit->hitList.size() << std::endl;
-      std::vector< const MuonCluster* >::const_iterator hit = cit->hitList.begin();
-      std::vector< const MuonCluster* >::const_iterator hit_end = cit->hitList.end();
-      for( ;hit!=hit_end;++hit ){	
-	const Muon::MuonCluster& prd = **hit;
-	const Identifier& id = prd.identify();
-	std::cout << "   hit " << m_muonIdHelper->gasGap(id) << " " << m_muonIdHelper->channel(id)-1;
-	bool measuresPhi = m_muonIdHelper->measuresPhi(id); 
-	if(measuresPhi) std::cout << " phi" << std::endl;
-	else            std::cout << " eta" << std::endl;
-      }
-    }
-  }
-
-  void HitClusteringObj::findBest(std::vector<ClusterObj>& clustersEta,
-                                  std::vector<ClusterObj>& clustersPhi) {
-    std::vector<ClusterObj>::iterator it = clustersEta.begin();
-    std::vector<ClusterObj>::iterator it_end = clustersEta.end();
-    std::stable_sort(it,it_end,SortClusterObjs());
-    it = clustersPhi.begin();
-    it_end = clustersPhi.end();
-    std::stable_sort(it,it_end,SortClusterObjs());
-  }
-
-  std::vector<ClusterObj3D>
-  HitClusteringObj::buildClusters3D(const std::vector<ClusterObj>& clustersEta,
-                                    const std::vector<ClusterObj>& clustersPhi) const {
-    
-    std::vector<ClusterObj3D> clusters3D;
-
-    if( clustersPhi.empty() || clustersEta.empty() ) return clusters3D;
-    if( !bestCluster(clustersEta) || !bestCluster(clustersEta)->active() ) return clusters3D;
-    
-    const MuonCluster* etaHit = bestCluster(clustersEta)->hitList.front(); 
-    if( !etaHit ) return clusters3D;
-
-    const MuonGM::TgcReadoutElement* detEl = dynamic_cast<const MuonGM::TgcReadoutElement*>(etaHit->detectorElement());
-    if( !detEl ) return clusters3D;
-
-    // now loop over eta and phi clusters and form space points
-    if( m_debug ) std::cout << " eta clusters " << clustersEta.size() << " phi clusters " << clustersPhi.size() << std::endl;
-    for (const ClusterObj& cl_eta : clustersEta) {
-      if( !cl_eta.active() ) continue;
-
-      const MuonCluster* firstEta = cl_eta.hitList.front();
-      const MuonCluster* lastEta = cl_eta.hitList.back();
-
-      for (const ClusterObj& cl_phi : clustersPhi) {
-	if( !cl_phi.active() ) continue;
-
-	const MuonCluster* firstPhi = cl_phi.hitList.front();
-	const MuonCluster* lastPhi = cl_phi.hitList.back();
-
-	ClusterObj3D cl3D(cl_eta,cl_phi);
-	detEl->spacePointPosition( firstPhi->identify(),firstEta->identify(),cl3D.p11 );
-	if( lastPhi != firstPhi ) detEl->spacePointPosition( lastPhi->identify(),firstEta->identify(),cl3D.p12 );
-	else                      cl3D.p12 = cl3D.p11;
-	if( lastEta != firstEta ) {
-	  detEl->spacePointPosition( firstPhi->identify(),lastEta->identify(),cl3D.p21 );
-	  if( lastPhi != firstPhi ) detEl->spacePointPosition( lastPhi->identify(),lastEta->identify(),cl3D.p22 );
-	  else                      cl3D.p22 = cl3D.p21;
-	}else{
-	  cl3D.p22 = cl3D.p12;
-	  cl3D.p21 = cl3D.p11;
-	}
-	clusters3D.push_back(cl3D);
-      }
-    }
-    
-    if( m_debug && !clusters3D.empty() ){
-      std::cout << " 3D clusters " << clusters3D.size() << std::endl;
-      std::vector<ClusterObj3D>::iterator it = clusters3D.begin();
-      std::vector<ClusterObj3D>::iterator it_end = clusters3D.end();
-      for( ;it!=it_end;++it ){
-// 	std::cout << " eta cluster " << it->etaCluster->hitList.size() << " phi cluster " << it->phiCluster->hitList.size()
-// 		  << " position " << it->p11 << std::endl;
-	std::cout << " eta cluster " << it->etaCluster.hitList.size() << " phi cluster " << it->phiCluster.hitList.size()
-		  << " position " << it->p11 << std::endl;
-      }
-    }
-
-    return clusters3D;
-  }
-
- 
-
-}
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MdtHitClustering.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MdtHitClustering.cxx
deleted file mode 100644
index ea8ee139448a..000000000000
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MdtHitClustering.cxx
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
-  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
-*/
-
-#include "MuonClusterization/MdtHitClustering.h"
-#include "MuonPrepRawData/MuonPrepDataContainer.h"
-#include "MuonPrepRawData/MdtPrepData.h"
-#include "MuonReadoutGeometry/MuonDetectorManager.h"
-#include "MuonReadoutGeometry/MdtReadoutElement.h"
-
-#include "Identifier/Identifier.h"
-#include "MuonIdHelpers/MdtIdHelper.h"
-
-#include "MuonPrepRawData/MdtDriftCircleStatus.h"
-#include "GeoPrimitives/GeoPrimitives.h"
-
-namespace Muon {
-
-  bool MdtHitClustering::init( const Identifier& chid ) {
-    hitPattern.clear();
-    clusters.clear();
-
-    detEl1 = nullptr;
-    detEl2 = nullptr;
-    // number of layers and tubes
-    nlay = 0;
-    ntube1 = 0;
-    ntube2 = 0;
-    
-    // number of multilayers in chamber
-    nml = 0;
-
-    int eta =  m_mdtIdHelper->stationEta(chid);
-    int phi = m_mdtIdHelper->stationPhi(chid);
-    int name = m_mdtIdHelper->stationName(chid);
-    
-    // get detEL for first ml (always there)
-    detEl1 = m_detMgr->getMdtReadoutElement( m_mdtIdHelper->channelID( name,eta,phi,1,1,1 ) );
-    if( !detEl1 ) return false;
-    detEl2 = nullptr;
-    // number of layers and tubes
-    nlay = detEl1->getNLayers();
-    ntube1 = detEl1->getNtubesperlayer();    
-    ntube2 = 0;
-    
-    // number of multilayers in chamber
-    nml = detEl1->nMDTinStation();
-    
-    // treament of chambers with two ml
-    if( nml == 2 ){
-      Identifier firstIdml1 = m_mdtIdHelper->channelID( name,eta,phi,2,1,1 );
-      detEl2 = m_detMgr->getMdtReadoutElement( firstIdml1 ); 
-      ntube2 = detEl2->getNtubesperlayer();
-    }
-    
-    // here we are going to calculate the staggering lay out of the MDT chamber 
-    // by comparing the difference of local positions of the first and second tube in the first layer
-    // with the position of the first tube in the second layer
-    Amg::Transform3D gToStation = detEl1->GlobalToAmdbLRSTransform();
-    Identifier idml0lay0tube0  = m_mdtIdHelper->channelID( name,eta,phi,1,1,1 );
-    Amg::Vector3D posMl0lay0tube0 = gToStation*(detEl1->surface( idml0lay0tube0 ).center());    
-    Identifier idml0lay0tube1  = m_mdtIdHelper->channelID( name,eta,phi,1,1,2 );
-    Amg::Vector3D posMl0lay0tube1 = gToStation*(detEl1->surface( idml0lay0tube1 ).center());    
-    Identifier idml0lay1tube0  = m_mdtIdHelper->channelID( name,eta,phi,1,2,1 );
-    Amg::Vector3D posMl0lay1tube0 = gToStation*(detEl1->surface( idml0lay1tube0 ).center());    
-    bool posStagCor = true;
-    if( (posMl0lay0tube1.y()-posMl0lay0tube0.y())*(posMl0lay1tube0.y()-posMl0lay0tube0.y()) < 0  ) posStagCor = false;
-    
-    /*
-    1 0  -1   0->0    1->0,1   -> stag = -1
-   1 0   -1   0->0,1  1->1,2   -> stag = 0
-
-   1 0   -1   0->0,1  1->1,2   -> stag = 0
-    1 0   1   0->0    1->0,1   -> stag = -1 
-
-   0 1    1   0->0    1->0,1   -> stag = -1
-    0 1   1   0->0,1  1->1,2   -> stag = 0
-
-    0 1   1   0->0,1  1->1,2   -> stag = 0
-   0 1   -1   0->0    1->0,1   -> stag = -1
-    */
-
-
-    hitPattern.resize(nml*nlay);
-    staggeringCorrection.resize(nml*nlay,0);
-
-    for( unsigned int i=0;i<staggeringCorrection.size();++i ) {
-      unsigned int corlay = i;
-      if( corlay >= nlay ) corlay-=nlay;
-      if( posStagCor ){
-	if( nlay == 4 && i >= nlay ){
-	  if( corlay%2==1 ) staggeringCorrection[i] = 0;
-	  else              staggeringCorrection[i] = -1;
-	}else{
-	  if( corlay%2==1 ) staggeringCorrection[i] = -1;
-	  else              staggeringCorrection[i] = 0;
-	}
-      }else{
-	if( nlay == 4 && i >= nlay ){
-	  if( corlay%2==1 ) staggeringCorrection[i] = -1;
-	  else              staggeringCorrection[i] = 0;
-	}else{
-	  if( corlay%2==1 ) staggeringCorrection[i] = 0;
-	  else              staggeringCorrection[i] = -1;
-	}
-      }
-    }
-    unsigned int nl = 0;
-    std::vector< std::vector<int> >::iterator tit = hitPattern.begin();
-    std::vector< std::vector<int> >::iterator tit_end = hitPattern.end();
-    for( ;tit!=tit_end;++tit,++nl) {
-      if( nl < nlay ) tit->resize(ntube1,-1);
-      else            tit->resize(ntube2,-1);
-    }
-    return true;
-  }
-
-  void MdtHitClustering::neighbouringTubes( const Id& id, std::vector<Id>& neighbours ) const {
-    neighbours.clear();
-    int ntubes = id.lay < (int)nlay ? ntube1 : ntube2;
-    // first add neighbours in the same layer
-    if( id.tube-1 >= 0 )     neighbours.emplace_back(id.lay,id.tube-1 );
-    if( id.tube+1 < ntubes ) neighbours.emplace_back(id.lay,id.tube+1 );
-
-    // now add layer below
-    if( id.lay > 0 && id.lay != (int)nlay ){
-      int prevLay = id.lay-1;
-      int nb1 = id.tube + staggeringCorrection[prevLay];
-      int nb2 = nb1 + 1;
-      if( nb1 >= 0 )     neighbours.emplace_back(prevLay,nb1 );
-      if( nb2 < ntubes ) neighbours.emplace_back(prevLay,nb2 );
-    }
-    unsigned int nextLay = id.lay+1;
-    if( nextLay != nlay && nextLay < 2*nlay ){
-      int nb1 = id.tube + staggeringCorrection[nextLay];
-      int nb2 = nb1 + 1;
-      if( nb1 >= 0 ) neighbours.emplace_back(nextLay,nb1 );
-      if( nb2 < ntubes ) neighbours.emplace_back(nextLay,nb2 );
-    }
-  }
-
-  void MdtHitClustering::layers( const MdtCluster& cl, int& all, int& inTime, int& inTimeAndBefore ) const {
-    std::set<int> lays;
-    std::set<int> laysInTime;
-    std::set<int> laysInTimeAndBefore;
-    for( MdtCluster::HitCit clit=cl.hitList.begin();clit!=cl.hitList.end();++clit ){
-      int layer = m_mdtIdHelper->tubeLayer( (*clit)->identify());
-      lays.insert(layer);
-      if( (*clit)->adc() > 50 ){
-	if( (*clit)->status() == Muon::MdtStatusDriftTime ) {
-	  laysInTime.insert(layer);
-	  laysInTimeAndBefore.insert(layer);
-	}else if( (*clit)->status() == Muon::MdtStatusBeforeSpectrum ) {
-	  laysInTimeAndBefore.insert(layer);
-	}
-      }
-    }
-    all = lays.size();
-    inTime = laysInTime.size();
-    inTimeAndBefore = laysInTimeAndBefore.size();
-  }
-
-  bool MdtHitClustering::cluster( const MdtPrepDataCollection& col ){
-      
-    if( col.empty() ) return true;
-    MdtPrepDataCollection::const_iterator cit_begin = col.begin();
-    MdtPrepDataCollection::const_iterator cit_end = col.end();
-    const Identifier& chid = (*cit_begin)->identify();
-    init(chid);
-    
-    if( debug ) std::cout << " handling chamber " << col.size() << std::endl;
-    std::vector<Id> neighbours;
-    std::vector<Id>::iterator nit,nit_end;
-    MdtPrepDataCollection::const_iterator cit = cit_begin;   
-    for( ; cit!=cit_end;++cit ) {
-      const MdtPrepData* mdt = (*cit);
-      
-      const Identifier& ida = mdt->identify();
-      int tube = m_mdtIdHelper->tube(ida)-1;
-      int lay  = m_mdtIdHelper->tubeLayer(ida)-1;
-      int ml   = m_mdtIdHelper->multilayer(ida)-1;
-      if( ml == 1 )  lay += nlay;
-	
-      // first treat the case of a second hit in the same tube
-      int tubeClusterNumber = hitPattern[lay][tube];
-      if( tubeClusterNumber != -1 ){
-	if( debug ) std::cout << " second hit " << lay << "  " << tube << " clusterid " << tubeClusterNumber << std::endl;
-	MdtCluster& cluster = clusters[tubeClusterNumber];
-	cluster.addSecond(mdt);
-      }else{
-
-	Id id(lay,tube);
-	neighbouringTubes(id,neighbours);
-	if( debug ) std::cout << " new tube " << id.lay << "  " << id.tube << " neighbours " << neighbours.size() << std::endl;
-	nit = neighbours.begin();
-	nit_end = neighbours.end();
-	MdtCluster* currentCluster = nullptr;
-	int currentClusterId = -1;
-	for( ;nit!=nit_end;++nit ){
-	  
-	  int clusterNumber = hitPattern[nit->lay][nit->tube];
-	  if( clusterNumber == -1 ) continue;
-	  if( debug ) std::cout << "   new neighbour " << nit->lay << "  " << nit->tube << " clusterid " << clusterNumber;
-	  
-	  MdtCluster& cluster = clusters[clusterNumber];
-	  
-	  // if the hit is unassigned add it to the cluster
-	  if( currentCluster == nullptr ){
-	    cluster.add(mdt);
-	    currentCluster = &cluster;
-	    hitPattern[lay][tube] = clusterNumber;
-	    currentClusterId = clusterNumber;
-	    if( debug ) std::cout << " adding hit " << std::endl;
-	  }else if( clusterNumber != currentClusterId ){
-	    // the hit is already assigned to a cluster, merge the two clusters
-	    // first update hitPattern
-	    MdtCluster::HitIt h = cluster.hitList.begin();
-	    MdtCluster::HitIt h_end = cluster.hitList.end();
-	    for( ;h!=h_end;++h ) {
-	      const Identifier& cid = (*h)->identify();
-	      int ctube = m_mdtIdHelper->tube(cid)-1;
-	      int clay  = m_mdtIdHelper->tubeLayer(cid)-1;
-	      int cml   = m_mdtIdHelper->multilayer(cid)-1;
-	      if( cml == 1 )  clay += nlay;
-	      hitPattern[clay][ctube] = currentClusterId;
-	    }
-	    if( debug ) std::cout << " cluster overlap, merging clusters " << std::endl;
-	    currentCluster->merge(cluster);
-	  }else{
-	    if( debug ) std::cout << " cluster overlap, same cluster " << std::endl;
-	  }
-	}
-	// now check whether the hit was already assigned to a cluster, if not create a new cluster
-	if( currentCluster == nullptr ){
-	  if( debug ) std::cout << " no neighbouring hits, creating new cluster " << clusters.size() << std::endl;
-	  MdtCluster cl;
-	  cl.hitList.push_back(mdt);
-	  hitPattern[lay][tube] = clusters.size();
-	  clusters.push_back(cl);
-	}
-      }
-    }
-    
-    if( debug ) dump();
-
-    return true;
-  }
-
-  void MdtHitClustering::dump() const {
-    std::cout << " dumping chamber hit map " << std::endl<< std::endl; 
-    for( unsigned int nl=0;nl<hitPattern.size();++nl) {
-      if( nl == nlay ) std::cout << std::endl << std::endl; 
-	
-      if( staggeringCorrection[nl] == -1 ) std::cout << " "; 
-      for( unsigned int nt = 0;nt<hitPattern[nl].size();++nt ) std::cout << " " << std::setw(2) << hitPattern[nl][nt]+1;
-      std::cout << std::endl << std::endl; 
-    }
-//     std::cout << " clusters " << clusters.size() << std::endl;
-//     std::vector< MdtCluster >::const_iterator cit = clusters.begin();
-//     std::vector< MdtCluster >::const_iterator cit_end = clusters.end();
-//     for( ;cit!=cit_end;++cit ){
-//       if( !cit->active() ) continue;
-//       std::cout << " cluster " << cit->hitList.size() << std::endl;
-//       for( MdtCluster::HitCit clit=cit->hitList.begin();clit!=cit->hitList.end();++clit ){
-// 	std::cout << " ml " << m_mdtIdHelper->multilayer( (*clit)->identify())-1
-// 		  << " lay " << m_mdtIdHelper->tubeLayer( (*clit)->identify())-1
-// 		  << " tube " << m_mdtIdHelper->tube( (*clit)->identify())-1 << std::endl;
-//       }
-//     }
-  }
-
-}
-
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationAlg.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationAlg.cxx
deleted file mode 100644
index abbe64e4e663..000000000000
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationAlg.cxx
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
-*/
-
-#include "MuonClusterizationAlg.h"
-
-#include "MuonPrepRawData/MuonPrepDataContainer.h"
-
-using namespace Muon;
-
-MuonClusterizationAlg::MuonClusterizationAlg(const std::string& name, ISvcLocator* pSvcLocator)
-    : 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");
-}
-
-StatusCode
-MuonClusterizationAlg::initialize()
-{
-    ATH_CHECK(m_clusterTool.retrieve());
-    return StatusCode::SUCCESS;
-}
-
-StatusCode
-MuonClusterizationAlg::execute()
-{
-    const TgcPrepDataContainer* tgcContainer = nullptr;
-    if (evtStore()->retrieve(tgcContainer, m_tgcPrdLocationInput).isFailure()) {
-        ATH_MSG_WARNING("Could not find TgcPrepDataContainer at " << m_tgcPrdLocationInput);
-        return StatusCode::RECOVERABLE;
-    }
-
-    const TgcPrepDataContainer* tgcContainerCluster = m_clusterTool->cluster(*tgcContainer);
-    if (evtStore()->record(tgcContainerCluster, m_tgcPrdLocationOutput).isFailure()) {
-        ATH_MSG_WARNING("Could not record TgcPrepDataContainer at " << m_tgcPrdLocationOutput);
-        return StatusCode::RECOVERABLE;
-    }
-
-    const RpcPrepDataContainer* rpcContainer = nullptr;
-    if (evtStore()->retrieve(rpcContainer, m_rpcPrdLocationInput).isFailure()) {
-        ATH_MSG_WARNING("Could not find RpcPrepDataContainer at " << m_rpcPrdLocationInput);
-        return StatusCode::RECOVERABLE;
-    }
-
-    const RpcPrepDataContainer* rpcContainerCluster = m_clusterTool->cluster(*rpcContainer);
-    if (evtStore()->record(rpcContainerCluster, m_rpcPrdLocationOutput).isFailure()) {
-        ATH_MSG_WARNING("Could not record RpcPrepDataContainer at " << m_rpcPrdLocationOutput);
-        return StatusCode::RECOVERABLE;
-    }
-
-    return StatusCode::SUCCESS;
-}
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationAlg.h b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationAlg.h
deleted file mode 100644
index da2fbdf0f857..000000000000
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationAlg.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
-*/
-
-#ifndef MUONCLUSTERIZATIONALG_H
-#define MUONCLUSTERIZATIONALG_H
-
-#include <string>
-
-#include "AthenaBaseComps/AthAlgorithm.h"
-#include "GaudiKernel/ToolHandle.h"
-#include "MuonClusterization/IMuonClusterizationTool.h"
-
-class MuonClusterizationAlg : public AthAlgorithm {
-  public:
-    MuonClusterizationAlg(const std::string& name, ISvcLocator* pSvcLocator);
-
-  public:
-    virtual ~MuonClusterizationAlg() = default;
-
-    virtual StatusCode initialize();
-    virtual StatusCode execute();
-
-  private:
-    std::string m_tgcPrdLocationInput;   //!< Location of input TgcPrepData
-    std::string m_tgcPrdLocationOutput;  //!< Location of output TgcPrepData
-
-    std::string m_rpcPrdLocationInput;   //!< Location of input RpcPrepData
-    std::string m_rpcPrdLocationOutput;  //!< Location of output RpcPrepData
-
-    ToolHandle<Muon::IMuonClusterizationTool> m_clusterTool{
-        this,
-        "ClusterTool",
-        "Muon::MuonClusterizationTool/MuonClusterizationTool",
-    };  //!< clustering Tool
-};
-
-#endif
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationTool.cxx
deleted file mode 100644
index 49fde722bdec..000000000000
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationTool.cxx
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
-  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
-*/
-
-#include "MuonClusterizationTool.h"
-
-#include "GeoPrimitives/GeoPrimitives.h"
-#include "EventPrimitives/EventPrimitives.h"
-
-namespace Muon {
-
-  MuonClusterizationTool::MuonClusterizationTool(const std::string& t,const std::string& n, const IInterface* p) :
-      AthAlgTool(t,n,p),
-      m_tgcClustering(nullptr),
-      m_rpcClustering(nullptr)
-  {
-    declareInterface<IMuonClusterizationTool>(this);
-    declareProperty("CombineGasGaps", m_combineGasGaps = true);
-  } 
-
-  StatusCode MuonClusterizationTool::initialize()
-  {
-    ATH_CHECK(m_idHelperSvc.retrieve());
-    m_tgcClustering = new HitClusteringObj(m_idHelperSvc->tgcIdHelper(),
-                                           m_combineGasGaps);
-    m_rpcClustering = new HitClusteringObj(m_idHelperSvc->rpcIdHelper(),
-                                           m_combineGasGaps);
-    return StatusCode::SUCCESS; 
-  }
-
-  StatusCode MuonClusterizationTool::finalize()
-  {
-    delete m_tgcClustering;
-    delete m_rpcClustering;
-    return StatusCode::SUCCESS;
-  }
-
-  TgcPrepDataContainer* MuonClusterizationTool::cluster( const TgcPrepDataContainer& prdContainer ) const {
-  
-    TgcPrepDataContainer* clusteredContainer = new TgcPrepDataContainer(m_idHelperSvc->tgcIdHelper().module_hash_max());
-    // loop over Tgc collections in container
-    TgcPrepDataContainer::const_iterator cit = prdContainer.begin();
-    TgcPrepDataContainer::const_iterator cit_end = prdContainer.end();
-    for( ;cit!=cit_end;++cit ){
-      if( !*cit || (*cit)->empty() ) continue;
-      const TgcPrepDataCollection& col = **cit;
-      TgcPrepDataCollection* clusteredCol = cluster(col);
-      if( clusteredCol ) clusteredContainer->addCollection(clusteredCol, col.identifyHash() ).ignore();
-    }
-    return clusteredContainer;
-  }
-
-  TgcPrepDataCollection* MuonClusterizationTool::cluster( const TgcPrepDataCollection& col ) const {
-    if( col.empty() ) return nullptr;
-    TgcPrepDataCollection* collection = new TgcPrepDataCollection(col.identifyHash());
-    collection->setIdentifier(col.identify());
-    ATH_MSG_INFO("Performing clustering in " << m_idHelperSvc->toString(col.identify()) );
-    std::vector<const MuonCluster*> prds;
-    prds.insert(prds.end(),col.begin(),col.end());
-    std::vector<ClusterObj> clustersEta;
-    std::vector<ClusterObj> clustersPhi;
-    m_tgcClustering->cluster( prds, clustersEta, clustersPhi );
-    addClusters(clustersEta,collection);
-    addClusters(clustersPhi,collection);
-    ATH_MSG_INFO("  input size " << col.size() << " output size " << collection->size());
-
-    return collection;
-  }
-
-  void MuonClusterizationTool::addClusters( const std::vector<ClusterObj>& clusters, TgcPrepDataCollection* collection ) {
-    std::vector<ClusterObj>::const_iterator cit = clusters.begin();
-    std::vector<ClusterObj>::const_iterator cit_end = clusters.end();
-    for( ;cit!=cit_end;++cit ){
-
-      // ignore non-active clusters
-      const ClusterObj& cl = *cit;
-      if( !cl.active() ) continue;
-      const TgcPrepData* first = static_cast<const TgcPrepData*>(cl.hitList.front());
-      if( !first ) continue;
-
-      // copy identifiers of contained prds
-      std::vector<Identifier> rdoList;
-      rdoList.reserve(cl.hitList.size());
-      std::vector< const MuonCluster*>::const_iterator hit = cl.hitList.begin();
-      std::vector< const MuonCluster*>::const_iterator hit_end = cl.hitList.end();
-      for( ;hit!=hit_end;++hit ) rdoList.push_back((*hit)->identify());
-
-      // create new PRD object
-      TgcPrepData* prd = new TgcPrepData( first->identify(), first->collectionHash(), 
-					  first->localPosition(),
-					  rdoList, 
-					  Amg::MatrixX( first->localCovariance()),
-					  first->detectorElement());
-      //TgcPrepData::BC_CURRENT); add bc id
-      collection->push_back(prd);
-    }
-  }
-
-
-  RpcPrepDataContainer* MuonClusterizationTool::cluster( const RpcPrepDataContainer& prdContainer ) const {
-  
-    RpcPrepDataContainer* clusteredContainer = new RpcPrepDataContainer(m_idHelperSvc->rpcIdHelper().module_hash_max());
-    // loop over Rpc collections in container
-    RpcPrepDataContainer::const_iterator cit = prdContainer.begin();
-    RpcPrepDataContainer::const_iterator cit_end = prdContainer.end();
-    for( ;cit!=cit_end;++cit ){
-      if( !*cit || (*cit)->empty() ) continue;
-      const RpcPrepDataCollection& col = **cit;
-      RpcPrepDataCollection* clusteredCol = cluster(col);
-      if( clusteredCol ) clusteredContainer->addCollection(clusteredCol, col.identifyHash() ).ignore();
-    }
-    return clusteredContainer;
-  }
-
-  RpcPrepDataCollection* MuonClusterizationTool::cluster( const RpcPrepDataCollection& col ) const {
-    if( col.empty() ) return nullptr;
-    RpcPrepDataCollection* collection = new RpcPrepDataCollection(col.identifyHash());
-    collection->setIdentifier(col.identify());
-    ATH_MSG_INFO("Performing clustering in " << m_idHelperSvc->toString(col.identify()) );
-    std::vector<const MuonCluster*> prds;
-    prds.insert(prds.end(),col.begin(),col.end());
-    std::vector<ClusterObj> clustersEta;
-    std::vector<ClusterObj> clustersPhi;
-    m_rpcClustering->cluster( prds, clustersEta, clustersPhi );
-    addClusters(clustersEta,collection);
-    addClusters(clustersPhi,collection);
-    ATH_MSG_INFO("  input size " << col.size() << " output size " << collection->size());
-   
-    return collection;
-  }
-
-  void MuonClusterizationTool::addClusters( const std::vector<ClusterObj>& clusters, RpcPrepDataCollection* collection ) {
-    std::vector<ClusterObj>::const_iterator cit = clusters.begin();
-    std::vector<ClusterObj>::const_iterator cit_end = clusters.end();
-    for( ;cit!=cit_end;++cit ){
-
-      // ignore non-active clusters
-      const ClusterObj& cl = *cit;
-      if( !cl.active() ) continue;
-      const RpcPrepData* first = static_cast<const RpcPrepData*>(cl.hitList.front());
-      if( !first ) continue;
-
-      // copy identifiers of contained prds
-      std::vector<Identifier> rdoList;
-      rdoList.reserve(cl.hitList.size());
-      std::vector< const MuonCluster*>::const_iterator hit = cl.hitList.begin();
-      std::vector< const MuonCluster*>::const_iterator hit_end = cl.hitList.end();
-      for( ;hit!=hit_end;++hit ) rdoList.push_back((*hit)->identify());
-
-      // create new PRD object
-      RpcPrepData* prd = new RpcPrepData( first->identify(), first->collectionHash(), 
-					  first->localPosition(),
-					  rdoList, 
-					  Amg::MatrixX(first->localCovariance() ),
-					  first->detectorElement(),
-					  first->time(),
-					  first->triggerInfo(),
-					  first->ambiguityFlag());
-      //RpcPrepData::BC_CURRENT); add bc id
-      collection->push_back(prd);
-    }
-  }
-
-}
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationTool.h b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationTool.h
deleted file mode 100644
index 2c3e813ab416..000000000000
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/MuonClusterizationTool.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
-*/
-
-#ifndef MUONCLUSTERIZATIONTOOL_H
-#define MUONCLUSTERIZATIONTOOL_H
-
-
-#include "MuonClusterization/IMuonClusterizationTool.h"
-#include "AthenaBaseComps/AthAlgTool.h"
-#include "GaudiKernel/ServiceHandle.h"
-
-#include "MuonIdHelpers/IMuonIdHelperSvc.h"
-#include "MuonPrepRawData/MuonPrepDataContainer.h"
-#include "MuonClusterization/HitClustering.h"
-#include "MuonClusterization/RpcHitClustering.h"
-
-#include <string>
-
-namespace Muon{ 
-
-  class MuonClusterizationTool : virtual public IMuonClusterizationTool, public AthAlgTool
-  {
-  public:
-    MuonClusterizationTool(const std::string& t, const std::string& n, const IInterface* p);
-    virtual ~MuonClusterizationTool()=default;
-
-    virtual StatusCode initialize();
-    virtual StatusCode finalize();
-
-    Muon::TgcPrepDataContainer*  cluster( const Muon::TgcPrepDataContainer& prdContainer ) const ;
-    Muon::TgcPrepDataCollection* cluster( const Muon::TgcPrepDataCollection& col ) const ;
-
-    Muon::RpcPrepDataContainer*  cluster( const Muon::RpcPrepDataContainer& prdContainer ) const;
-    Muon::RpcPrepDataCollection* cluster( const Muon::RpcPrepDataCollection& col ) const;
-
-  private:
-    static void addClusters( const std::vector<Muon::ClusterObj>& clusters, Muon::TgcPrepDataCollection* collection ) ;
-    static void addClusters( const std::vector<Muon::ClusterObj>& clusters, Muon::RpcPrepDataCollection* collection ) ;
-
-    ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
-
-    Muon::HitClusteringObj* m_tgcClustering;
-    Muon::HitClusteringObj* m_rpcClustering;
-    bool m_combineGasGaps;
-  };
-}
-
-#endif 
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/TgcHitClustering.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/TgcHitClustering.cxx
index 6d05b94057e0..fcdeaa3512ca 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/TgcHitClustering.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/TgcHitClustering.cxx
@@ -1,290 +1,109 @@
 /*
-  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "MuonClusterization/TgcHitClustering.h"
-
+namespace{
+   using HitList = Muon::TgcHitClusteringObj::HitList;
+   static const HitList dummy{};
+}
 
 namespace Muon {
-
-  bool TgcHitClusteringObj::cluster( const std::vector<const TgcPrepData*>& col ){
-    
-    if( col.empty() ) return false;
-
-    std::vector<const TgcPrepData*>::const_iterator cit_begin = col.begin();
-    std::vector<const TgcPrepData*>::const_iterator cit_end = col.end();
-    if( cit_begin == cit_end ) return false;
-    std::vector<const TgcPrepData*>::const_iterator cit = cit_begin;
-    const Muon::TgcPrepData* prd_first = *cit;
-    if( !prd_first ) return false;
-    const MuonGM::TgcReadoutElement* detEl = prd_first->detectorElement();
-    if( !detEl ) return false;
-    ngasgaps = detEl->Ngasgaps();
-    if( debug ) std::cout << " performing clustering " << col.size() << " gasgaps " << ngasgaps << std::endl;
-
-    clustersEta.clear();
-    clustersPhi.clear();
-    channelsEta.clear();
-    channelsPhi.clear();
-    channelsEta.resize(TgcIdHelper::channelMax()+2);
-    channelsPhi.resize(TgcIdHelper::channelMax()+2);
-    std::vector<Triplet>* channelsPtr = nullptr;
-    for( ; cit!=cit_end;++cit ) {
-      const Muon::TgcPrepData* prd = *cit;
-      if( !prd ) continue;
-
-      const Identifier& id = prd->identify();
-      bool measuresPhi = m_tgcIdHelper->isStrip(id); // like measuresPhi()
-      std::vector<TgcClusterObj>& clusters = measuresPhi ? clustersPhi : clustersEta;
-      int channel = m_tgcIdHelper->channel(id); // between 1 and 135!
-      int gasgap = m_tgcIdHelper->gasGap(id);
-	
-      if(measuresPhi) channelsPtr = &channelsPhi;
-      else            channelsPtr = &channelsEta;
-      if( channel >= (int)channelsPtr->size() ){
-	//ATH_MSG_WARNING("index channels out of range: " << channel << " max " << channelsPtr->size());
-	continue;
-      }
-      Triplet& triplet = (*channelsPtr)[channel];
-
-      // first treat the case of a second hit in the same tube
-      int channelClusterNumber = gasgap==1 ? triplet.first : (gasgap==2 ? triplet.second : triplet.third );
-      if( channelClusterNumber != -1 ){
-	if( debug ){
-	  std::cout << " secondary hit " << channel << "  " << gasgap;
-	  if( measuresPhi ) std::cout << " phi " << channelClusterNumber << std::endl;
-	  else              std::cout << " eta " << channelClusterNumber << std::endl;
-	}
-	TgcClusterObj& cluster = clusters[channelClusterNumber];
-	cluster.addSecond(prd,gasgap);
-      }else{
-	
-	std::vector<Id> neighbours;
-	if( channel != 0 )                         neighbours.emplace_back(gasgap,channel-1 );
-	if( channel < (int)channelsPtr->size()-1 ) neighbours.emplace_back(gasgap,channel+1 );
-
-	if( combinedGasGaps ){
-	  if( gasgap != 1 ){
-	    neighbours.emplace_back(1,channel );
-	    if( channel != 0 )                         neighbours.emplace_back(1,channel-1 );
-	    if( channel < (int)channelsPtr->size()-1 ) neighbours.emplace_back(1,channel+1 );
-	  }
-	  
-	  if( gasgap != 2 ) {
-	    neighbours.emplace_back(2,channel );
-	    if( channel != 0 )                         neighbours.emplace_back(2,channel-1 );
-	    if( channel < (int)channelsPtr->size()-1 ) neighbours.emplace_back(2,channel+1 );
-	  }
-	  
-	  if( ngasgaps == 3 && gasgap != 3 ){
-	    neighbours.emplace_back(3,channel );
-	    if( channel != 0 )                         neighbours.emplace_back(3,channel-1 );
-	    if( channel < (int)channelsPtr->size()-1 ) neighbours.emplace_back(3,channel+1 );
-	  }
-	}
-
-	if( debug ) {
-	  std::cout << " new hit " << channel << "  " << gasgap;
-	  if( measuresPhi ) std::cout << " phi " << " neighbours " << neighbours.size() << std::endl;
-	  else              std::cout << " eta " << " neighbours " << neighbours.size() << std::endl;
-	}
-	std::vector<Id>::iterator nit = neighbours.begin();
-	std::vector<Id>::iterator nit_end = neighbours.end();
-	TgcClusterObj* currentCluster = nullptr;
-	int currentClusterId = -1;
-	for( ;nit!=nit_end;++nit ){
-
-	  Triplet& trip = (*channelsPtr)[nit->ch];
-	  
-	  int clusterNumber = nit->gp==1 ? trip.first : nit->gp==2 ? trip.second : trip.third;
-	  if( clusterNumber == -1 ) continue;
-	  if( debug ) std::cout << "    new neighbour " << nit->gp << "  " << nit->ch << " clusterid " << clusterNumber;
-	  
-	  TgcClusterObj& cluster = clusters[clusterNumber];
-	  
-	  // if the hit is unassigned add it to the cluster
-	  if( currentCluster == nullptr ){
-	    cluster.add(prd,gasgap);
-	    currentCluster = &cluster;
-	    if( gasgap==1 )      triplet.first  = clusterNumber;
-	    else if( gasgap==2 ) triplet.second = clusterNumber;
-	    else                 triplet.third  = clusterNumber;
-	    currentClusterId = clusterNumber;
-	    if( debug ) std::cout << " adding hit " << std::endl;
-	  }else if( clusterNumber != currentClusterId ){
-	    // the hit is already assigned to a cluster, merge the two clusters
-	    // first update hitPattern
-	    TgcClusterObj::HitIt h = cluster.hitList.begin();
-	    TgcClusterObj::HitIt h_end = cluster.hitList.end();
-	    for( ;h!=h_end;++h ) {
-	      const Identifier& cid = (*h)->identify();
-	      int ch = m_tgcIdHelper->channel(cid);
-	      int gp = m_tgcIdHelper->gasGap(cid);
-	      Triplet& trip = (*channelsPtr)[ch];
-	      if( gp==1 )      trip.first  = currentClusterId;
-	      else if( gp==2 ) trip.second = currentClusterId;
-	      else             trip.third  = currentClusterId;
-	    }
-	    if( debug ) std::cout << " cluster overlap, merging clusters " << std::endl;
-	    currentCluster->merge(cluster);
-	  }else{
-	    if( debug ) std::cout << " cluster overlap, same cluster " << std::endl;
-	  }
-	}
-	// now check whether the hit was already assigned to a cluster, if not create a new cluster
-	if( currentCluster == nullptr ){
-	  if( debug ) std::cout << " no neighbouring hits, creating new cluster " << clusters.size() << std::endl;
-	  TgcClusterObj cl;
-	  cl.add(prd,gasgap);
-	  Triplet& trip = (*channelsPtr)[channel];
-	  if( gasgap==1 )      trip.first  = clusters.size();
-	  else if( gasgap==2 ) trip.second = clusters.size();
-	  else                 trip.third  = clusters.size();
-	  clusters.push_back(cl);
-	}
-      }
+    const HitList& TgcHitClusteringObj::bestEtaCluster() const {      
+        return clustersEta.size() ? clustersEta.front() : dummy;
     }
-    findBest();
-    if( debug ) dump();
-    return true;
-  }
-
-
-  void TgcHitClusteringObj::dump() const {
- //    std::cout << " dumping eta chamber hit map: number of gasgaps " << ngasgaps << std::endl << std::endl; 
-//     if( ngasgaps == 3 )
-//       for( unsigned int nl=0;nl<channelsEta.size();++nl) 
-// 	if( channelsEta[nl].third == -1 ) std::cout << " .";
-// 	else std::cout << " " << std::setw(2) << channelsEta[nl].third; 
-
-//     for( unsigned int nl=0;nl<channelsEta.size();++nl) 
-//       if( channelsEta[nl].second == -1 ) std::cout << " .";
-//       else std::cout << " " << std::setw(2) << channelsEta[nl].second; 
-
-//     std::cout << std::endl << std::endl; 
-//     for( unsigned int nl=0;nl<channelsEta.size();++nl) 
-//       if( channelsEta[nl].first == -1 ) std::cout << " .";
-//       else std::cout << " " << std::setw(2) << channelsEta[nl].first; 
-//     std::cout << std::endl << std::endl; 
- 
-//     std::cout << " dumping phi chamber hit map " << std::endl << std::endl; 
-//     for( unsigned int nl=0;nl<channelsPhi.size();++nl) 
-//       if( channelsPhi[nl].second == -1 ) std::cout << " .";
-//       else std::cout << " " << std::setw(2) << channelsPhi[nl].second; 
-//     std::cout << std::endl << std::endl; 
-//     for( unsigned int nl=0;nl<channelsPhi.size();++nl) 
-//       if( channelsPhi[nl].first == -1 ) std::cout << " .";
-//       else std::cout << " " << std::setw(2) << channelsPhi[nl].first; 
-//     std::cout << std::endl << std::endl; 
-    int clid = -1;
-    std::vector<TgcClusterObj>::const_iterator cit = clustersEta.begin();
-    std::vector<TgcClusterObj>::const_iterator cit_end = clustersEta.end();
-    for( ;cit!=cit_end;++cit ){
-      ++clid;
-      if( !cit->active() ) continue;
-      std::cout << " new cluster " << clid << "  size " << cit->hitList.size() << std::endl;
-      TgcClusterObj::HitCit hit = cit->hitList.begin();
-      TgcClusterObj::HitCit hit_end = cit->hitList.end();
-      for( ;hit!=hit_end;++hit ){	
-	const Muon::TgcPrepData& prd = **hit;
-	const Identifier& id = prd.identify();
-	std::cout << "   hit " << m_tgcIdHelper->gasGap(id) << " " << m_tgcIdHelper->channel(id)-1;
-	bool measuresPhi = m_tgcIdHelper->isStrip(id);
-	if(measuresPhi) std::cout << " phi" << std::endl;
-	else            std::cout << " eta" << std::endl;
-      }
+    const HitList& TgcHitClusteringObj::bestPhiCluster() const {      
+        return clustersPhi.size() ? clustersPhi.front() : dummy;
     }
-    cit = clustersPhi.begin();
-    cit_end = clustersPhi.end();
-    for( ;cit!=cit_end;++cit ){
-      ++clid;
-      if( !cit->active() ) continue;
-      std::cout << " new cluster " << clid << "  size " << cit->hitList.size() << std::endl;
-      TgcClusterObj::HitCit hit = cit->hitList.begin();
-      TgcClusterObj::HitCit hit_end = cit->hitList.end();
-      for( ;hit!=hit_end;++hit ){	
-	const Muon::TgcPrepData& prd = **hit;
-	const Identifier& id = prd.identify();
-	std::cout << "   hit " << m_tgcIdHelper->gasGap(id) << " " << m_tgcIdHelper->channel(id)-1;
-	bool measuresPhi = m_tgcIdHelper->isStrip(id);
-	if(measuresPhi) std::cout << " phi" << std::endl;
-	else            std::cout << " eta" << std::endl;
+    bool TgcHitClusteringObj::cluster(HitList& filteredHits,
+                                      std::vector<HitList>& finalClusts) {
+      if (filteredHits.empty()) return false;
+      finalClusts.reserve(filteredHits.size());
+      std::sort(filteredHits.begin(), filteredHits.end(), 
+                [this](const TgcPrepData* h1,const TgcPrepData* h2) {
+                  const int gap1{m_tgcIdHelper->gasGap(h1->identify())}, gap2{m_tgcIdHelper->gasGap(h2->identify())};
+                  if (gap1 != gap2) return gap1 < gap2;
+                  return m_tgcIdHelper->channel(h1->identify()) < m_tgcIdHelper->channel(h2->identify());
+                });
+      
+      for (const TgcPrepData* prd : filteredHits) {
+          /// Create new clusters if the cluster is more separated by more than one channel or if the gas gaps don't match
+          if (finalClusts.empty() || 
+              m_tgcIdHelper->channel(finalClusts.back().back()->identify()) +1 != m_tgcIdHelper->channel(prd->identify()) ||
+              m_tgcIdHelper->gasGap(finalClusts.back().back()->identify()) != m_tgcIdHelper->gasGap(prd->identify())) {
+              finalClusts.emplace_back();
+          }  
+          finalClusts.back().push_back(prd);
       }
-    }
+      std::stable_sort(finalClusts.begin(),finalClusts.end(), 
+                       []( const HitList& a, const HitList& b){
+                            return a.size() < b.size();
+                       });
+      return true;
   }
 
-  void TgcHitClusteringObj::findBest() {
-    std::vector<TgcClusterObj>::iterator it = clustersEta.begin();
-    std::vector<TgcClusterObj>::iterator it_end = clustersEta.end();
-    std::stable_sort(it,it_end,SortTgcClusterObjs());
-    it = clustersPhi.begin();
-    it_end = clustersPhi.end();
-    std::stable_sort(it,it_end,SortTgcClusterObjs());
-  }
+  bool TgcHitClusteringObj::cluster( const std::vector<const TgcPrepData*>& col ){
+    
 
+    std::vector<const TgcPrepData*> etaHits{}, phiHits{};
+    etaHits.reserve(col.size());
+    phiHits.reserve(col.size());
+    
+    /// Split the hits in eta  & phi
+    std::copy_if(col.begin(),col.end(), std::back_inserter(etaHits), [this](const TgcPrepData* prd) {
+        return !m_tgcIdHelper->measuresPhi(prd->identify());
+    });
+    std::copy_if(col.begin(),col.end(), std::back_inserter(phiHits), [this](const TgcPrepData* prd){
+        return m_tgcIdHelper->measuresPhi(prd->identify());
+    });
+
+    if (!cluster(etaHits, clustersEta)) return false;
+    if (!cluster(phiHits, clustersPhi)) return false;
+    
+    return true;
+  }
   bool TgcHitClusteringObj::buildClusters3D() {
     
-    clusters3D.clear();
-
     if( clustersPhi.empty() || clustersEta.empty() ) return false;
-    if( !bestEtaCluster() || !bestEtaCluster()->active() ) return false;
     
-    const TgcPrepData* etaHit = bestEtaCluster()->hitList.front(); 
-    if( !etaHit ) return false;
+    const TgcPrepData* etaHit = bestEtaCluster().front(); 
 
-    const MuonGM::TgcReadoutElement* detEl = dynamic_cast<const MuonGM::TgcReadoutElement*>(etaHit->detectorElement());
-    if( !detEl ) return false;
+    const MuonGM::TgcReadoutElement* detEl = etaHit->detectorElement();
 
     // now loop over eta and phi clusters and form space points
-    if( debug ) std::cout << " eta clusters " << clustersEta.size() << " phi clusters " << clustersPhi.size() << std::endl;
-    std::vector< TgcClusterObj >::iterator eit = clustersEta.begin();
-    std::vector< TgcClusterObj >::iterator eit_end = clustersEta.end();
-    for( ;eit!=eit_end;++eit ){
-      
-      if( !eit->active() ) continue;
+    for(HitList& eit : clustersEta) {      
 
-      const TgcPrepData* firstEta = eit->hitList.front();
-      const TgcPrepData* lastEta = eit->hitList.back();
+        const TgcPrepData* firstEta = eit.front();
+        const TgcPrepData* lastEta = eit.back();
       
-      std::vector< TgcClusterObj >::iterator pit = clustersPhi.begin();
-      std::vector< TgcClusterObj >::iterator pit_end = clustersPhi.end();
-      for( ;pit!=pit_end;++pit ){
-
-	if( !pit->active() ) continue;
-
-	const TgcPrepData* firstPhi = pit->hitList.front();
-	const TgcPrepData* lastPhi = pit->hitList.back();
-
-	TgcClusterObj3D cl3D(*eit,*pit);
-// 	cl3D.etaCluster = &*eit;
-// 	cl3D.phiCluster = &*pit;
-	detEl->spacePointPosition( firstPhi->identify(),firstEta->identify(),cl3D.p11 );
-	if( lastPhi != firstPhi ) detEl->spacePointPosition( lastPhi->identify(),firstEta->identify(),cl3D.p12 );
-	else                      cl3D.p12 = cl3D.p11;
-	if( lastEta != firstEta ) {
-	  detEl->spacePointPosition( firstPhi->identify(),lastEta->identify(),cl3D.p21 );
-	  if( lastPhi != firstPhi ) detEl->spacePointPosition( lastPhi->identify(),lastEta->identify(),cl3D.p22 );
-	  else                      cl3D.p22 = cl3D.p21;
-	}else{
-	  cl3D.p22 = cl3D.p12;
-	  cl3D.p21 = cl3D.p11;
-	}
-	clusters3D.push_back(cl3D);
+        for(HitList& pit : clustersPhi) {
+
+          const TgcPrepData* firstPhi = pit.front();
+          const TgcPrepData* lastPhi = pit.back();
+
+          TgcClusterObj3D cl3D{eit, pit};
+          using Edge = TgcClusterObj3D::Edge;
+
+          detEl->spacePointPosition( firstPhi->identify(), firstEta->identify(), cl3D.getEdge(Edge::LowEtaLowPhi) );
+          if( lastPhi != firstPhi ) { 
+            detEl->spacePointPosition( lastPhi->identify(), firstEta->identify(), cl3D.getEdge(Edge::LowEtaHighPhi)); 
+          } else {
+            cl3D.getEdge(Edge::LowEtaHighPhi) = cl3D.getEdge(Edge::LowEtaLowPhi);
+          }
+          if( lastEta != firstEta ) {
+            detEl->spacePointPosition( firstPhi->identify(),lastEta->identify(),  cl3D.getEdge(Edge::HighEtaLowPhi) );
+            if( lastPhi != firstPhi ) { 
+              detEl->spacePointPosition( lastPhi->identify(),lastEta->identify(), cl3D.getEdge(Edge::HighEtaHighPhi) ); 
+            } else { 
+              cl3D.getEdge(Edge::HighEtaHighPhi) = cl3D.getEdge(Edge::HighEtaLowPhi);
+            }
+          }else{
+            cl3D.getEdge(Edge::HighEtaLowPhi) = cl3D.getEdge(Edge::LowEtaLowPhi);
+            cl3D.getEdge(Edge::HighEtaHighPhi) = cl3D.getEdge(Edge::LowEtaHighPhi);
+          }
+          clusters3D.push_back(std::move(cl3D));
       }
     }
-    
-    if( debug && !clusters3D.empty() ){
-      std::cout << " 3D clusters " << clusters3D.size() << std::endl;
-      std::vector<TgcClusterObj3D>::iterator it = clusters3D.begin();
-      std::vector<TgcClusterObj3D>::iterator it_end = clusters3D.end();
-      for( ;it!=it_end;++it ){
-// 	std::cout << " eta cluster " << it->etaCluster->hitList.size() << " phi cluster " << it->phiCluster->hitList.size()
-// 		  << " position " << it->p11 << std::endl;
-	std::cout << " eta cluster " << it->etaCluster.hitList.size() << " phi cluster " << it->phiCluster.hitList.size()
-		  << " position " << it->p11 << std::endl;
-      }
-    }
-
     return true;
   }
 
diff --git a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/components/MuonClusterization_entries.cxx b/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/components/MuonClusterization_entries.cxx
deleted file mode 100644
index 6a372015422b..000000000000
--- a/MuonSpectrometer/MuonReconstruction/MuonDataPrep/MuonClusterization/src/components/MuonClusterization_entries.cxx
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "../MuonClusterizationAlg.h"
-#include "../MuonClusterizationTool.h"
-
-using namespace Muon;
-
-DECLARE_COMPONENT( MuonClusterizationAlg )
-DECLARE_COMPONENT( MuonClusterizationTool )
-
diff --git a/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/MuonHoughPatternTools/MuonLayerHoughTool.h b/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/MuonHoughPatternTools/MuonLayerHoughTool.h
index 02fd92d5b6f9..cbca919f2966 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/MuonHoughPatternTools/MuonLayerHoughTool.h
+++ b/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/MuonHoughPatternTools/MuonLayerHoughTool.h
@@ -110,13 +110,15 @@ namespace Muon {
             const MuonSegmentCombinationCollection*, const EventContext& ctx) const override;
 
     private:
+        using TgcEdge = TgcClusterObj3D::Edge;
+
         void getSectors(const Amg::Vector3D& pos, std::vector<int>& sectors) const;
         void getSectors(const TgcClusterObj3D& tgc, std::vector<int>& sectors) const;
 
         double rCor(const Amg::Vector3D& pos, const Identifier& id) const;
         double rCor(const MuonCluster& rpc) const;
         double rCor(const MdtPrepData& mdt) const;
-        double rCor(const TgcClusterObj3D& tgc, int val, int sector) const;
+        double rCor(const TgcClusterObj3D& tgc, const TgcEdge val, int sector) const;
 
         int sublay(const Identifier& id, float z = 0) const;  // the z value is only used for the tgcs
 
@@ -216,7 +218,7 @@ namespace Muon {
     };
 
     inline void MuonLayerHoughTool::getSectors(const TgcClusterObj3D& tgc, std::vector<int>& sectors) const {
-        return getSectors(tgc.p11, sectors);
+        getSectors(tgc.getEdge(TgcEdge::LowEtaLowPhi), sectors);
     }
 
     inline void MuonLayerHoughTool::getSectors(const Amg::Vector3D& pos, std::vector<int>& sectors) const {
@@ -231,8 +233,8 @@ namespace Muon {
 
     inline double MuonLayerHoughTool::rCor(const MdtPrepData& mm) const { return rCor(mm.globalPosition(), mm.identify()); }
 
-    inline double MuonLayerHoughTool::rCor(const TgcClusterObj3D& tgc, int val, int sector) const {
-        const Amg::Vector3D& pos = val == 1 ? tgc.p11 : (val == 2 ? tgc.p12 : (val == 3 ? tgc.p21 : tgc.p22));
+    inline double MuonLayerHoughTool::rCor(const TgcClusterObj3D& tgc, const TgcEdge val, int sector) const {
+        const Amg::Vector3D& pos{tgc.getEdge(val)};
         return m_sectorMapping.transformRToSector(pos.perp(), pos.phi(), sector);
     }
 
diff --git a/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/src/MuonLayerHoughTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/src/MuonLayerHoughTool.cxx
index 0c9bff2ff5be..e09e5585e017 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/src/MuonLayerHoughTool.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonPatternFinders/MuonPatternFinderTools/MuonHoughPatternTools/src/MuonLayerHoughTool.cxx
@@ -636,7 +636,7 @@ namespace Muon {
             for (auto ehit = maximum->hits.begin(); ehit != maximum->hits.end(); ++ehit) {
                 const MuonHough::Hit& etaHit = **ehit;
                 if (etaHit.tgc) {
-                    if (!etaHit.tgc->phiCluster.hitList.empty()) tgcClusters.insert(etaHit.tgc);
+                    if (!etaHit.tgc->phiCluster.empty()) tgcClusters.insert(etaHit.tgc);
                 } else if (etaHit.prd) {
                     triggerLayers.insert(m_idHelperSvc->gasGapId(etaHit.prd->identify()));
                 }
@@ -699,10 +699,10 @@ namespace Muon {
                 // case 1: phiHit measured in TGC -> get phiHits from phiCluster
                 // case 2: phiHit is prepared raw data -> use phiHit to extend the triggerLayersPhinMinMax map
                 if (phiHit->tgc) {
-                    if (phiHit->tgc->phiCluster.hitList.empty())
+                    if (phiHit->tgc->phiCluster.empty())
                         ATH_MSG_WARNING(" TGC 3D cluster without phi hits ");
                     else
-                        tgcClusters[m_idHelperSvc->stationIndex(phiHit->tgc->phiCluster.hitList.front()->identify())].insert(phiHit->tgc);
+                        tgcClusters[m_idHelperSvc->stationIndex(phiHit->tgc->phiCluster.front()->identify())].insert(phiHit->tgc);
                 } else if (phiHit->prd) {
                     Identifier gpId = m_idHelperSvc->gasGapId(phiHit->prd->identify());
                     auto mit = triggerLayersPhiMinMax.find(gpId);
@@ -728,8 +728,8 @@ namespace Muon {
                     std::set<const TgcClusterObj3D*>::const_iterator ttit = stit->second.begin();
                     std::set<const TgcClusterObj3D*>::const_iterator ttit_end = stit->second.end();
                     for (; ttit != ttit_end; ++ttit) {
-                        ATH_MSG_VERBOSE("  " << m_idHelperSvc->toString((*ttit)->phiCluster.hitList.front()->identify()) << "  nhits "
-                                             << (*ttit)->phiCluster.hitList.size());
+                        ATH_MSG_VERBOSE("  " << m_idHelperSvc->toString((*ttit)->phiCluster.front()->identify()) << "  nhits "
+                                             << (*ttit)->phiCluster.size());
                     }
                 }
             }
@@ -748,7 +748,7 @@ namespace Muon {
                 // loop over eta hits
                 for (const auto& etaHit : road_max->hits) {
                     if (etaHit->tgc) {
-                        if (etaHit->tgc->etaCluster.hitList.empty())
+                        if (etaHit->tgc->etaCluster.empty())
                             ATH_MSG_WARNING(" TGC 3D cluster without eta hits ");
                         else {
                             if (tgcClusters[stIndex].count(etaHit->tgc)) {
@@ -871,7 +871,7 @@ namespace Muon {
                             for (auto& hit : maxi->hits) {
                                 if (hit->debugInfo()) {
                                     hit->debugInfo()->phn = maxi2->max;
-                                    Identifier id = hit->tgc ? hit->tgc->etaCluster.hitList.front()->identify() : hit->prd->identify();
+                                    Identifier id = hit->tgc ? hit->tgc->etaCluster.front()->identify() : hit->prd->identify();
                                     ATH_MSG_VERBOSE(" " << m_idHelperSvc->toString(id) << " setphn " << hit->debugInfo()->phn);
                                 }
                             }
@@ -908,10 +908,10 @@ namespace Muon {
             // loop over hits
             for (const auto& phiHit : phiMaximum->hits) {
                 if (phiHit->tgc) {
-                    if (phiHit->tgc->phiCluster.hitList.empty())
+                    if (phiHit->tgc->phiCluster.empty())
                         ATH_MSG_WARNING(" TGC 3D cluster without phi hits ");
                     else
-                        tgcClusters[m_idHelperSvc->stationIndex(phiHit->tgc->phiCluster.hitList.front()->identify())].insert(phiHit->tgc);
+                        tgcClusters[m_idHelperSvc->stationIndex(phiHit->tgc->phiCluster.front()->identify())].insert(phiHit->tgc);
                 } else if (phiHit->prd) {
                     Identifier colId = phiHit->prd->identify();
                     Identifier layId = m_idHelperSvc->gasGapId(colId);
@@ -928,8 +928,8 @@ namespace Muon {
                     std::set<const TgcClusterObj3D*>::const_iterator ttit = stit->second.begin();
                     std::set<const TgcClusterObj3D*>::const_iterator ttit_end = stit->second.end();
                     for (; ttit != ttit_end; ++ttit) {
-                        ATH_MSG_VERBOSE("  " << m_idHelperSvc->toString((*ttit)->phiCluster.hitList.front()->identify()) << "  nhits "
-                                             << (*ttit)->phiCluster.hitList.size());
+                        ATH_MSG_VERBOSE("  " << m_idHelperSvc->toString((*ttit)->phiCluster.front()->identify()) << "  nhits "
+                                             << (*ttit)->phiCluster.size());
                     }
                 }
             }
@@ -972,13 +972,9 @@ namespace Muon {
                     // loop over hits
                     for (const auto& etaHit : maximum->hits) {
                         if (etaHit->tgc) {
-                            if (etaHit->tgc->etaCluster.hitList.empty())
-                                ATH_MSG_WARNING(" TGC 3D cluster without eta hits ");
-                            else {
-                                if (tgcClusters[stIndex].count(etaHit->tgc))
-                                    ++ntgcOverlaps;
+                            if (tgcClusters[stIndex].count(etaHit->tgc))
+                                ++ntgcOverlaps;
                                
-                            }
                         } else if (etaHit->prd) {
                             Identifier layId = m_idHelperSvc->gasGapId(etaHit->prd->identify());
                             ATH_MSG_VERBOSE(" eta layer hit " << m_idHelperSvc->toString(layId));
@@ -1104,8 +1100,8 @@ namespace Muon {
                 // loop over hits in maximum and add them to the hit list
                 for (const auto& hit : max->hits) {
                     if (hit->tgc) {
-                        const Identifier chId = m_idHelperSvc->chamberId(hit->tgc->etaCluster.hitList.front()->identify());
-                        prdsPerChamber[chId].insert(hit->tgc->etaCluster.hitList.begin(), hit->tgc->etaCluster.hitList.end());
+                        const Identifier chId = m_idHelperSvc->chamberId(hit->tgc->etaCluster.front()->identify());
+                        prdsPerChamber[chId].insert(hit->tgc->etaCluster.begin(), hit->tgc->etaCluster.end());
                     } else if (hit->prd) {
                         const Identifier chId = m_idHelperSvc->chamberId(hit->prd->identify());
                         prdsPerChamber[chId].insert(hit->prd);
@@ -1156,8 +1152,8 @@ namespace Muon {
             // loop over hits
             for (const auto& hit : pit->first->hits) {
                 if (hit->tgc) {
-                    const Identifier chId = m_idHelperSvc->chamberId(hit->tgc->phiCluster.hitList.front()->identify());
-                    phiHitsPerChamber[chId].insert(hit->tgc->phiCluster.hitList.begin(), hit->tgc->phiCluster.hitList.end());
+                    const Identifier chId = m_idHelperSvc->chamberId(hit->tgc->phiCluster.front()->identify());
+                    phiHitsPerChamber[chId].insert(hit->tgc->phiCluster.begin(), hit->tgc->phiCluster.end());
                 } else if (hit->prd) {
                     const Identifier chId = m_idHelperSvc->chamberId(hit->prd->identify());
                     phiHitsPerChamber[chId].insert(hit->prd);
@@ -1191,8 +1187,8 @@ namespace Muon {
                 for (const auto& hit : max->hits) {
                     Identifier chId;
                     if (hit->tgc) {
-                        chId = m_idHelperSvc->chamberId(hit->tgc->etaCluster.hitList.front()->identify());
-                        prdsPerChamber[chId].insert(hit->tgc->etaCluster.hitList.begin(), hit->tgc->etaCluster.hitList.end());
+                        chId = m_idHelperSvc->chamberId(hit->tgc->etaCluster.front()->identify());
+                        prdsPerChamber[chId].insert(hit->tgc->etaCluster.begin(), hit->tgc->etaCluster.end());
                     } else if (hit->prd) {
                         chId = m_idHelperSvc->chamberId(hit->prd->identify());
                         prdsPerChamber[chId].insert(hit->prd);
@@ -1210,7 +1206,7 @@ namespace Muon {
                         if (max->hough)
                             refPlane = max->hough->m_descriptor.referencePosition;
                         else if (hit->tgc)
-                            refPlane = hit->tgc->p11.z();
+                            refPlane = hit->tgc->getEdge(TgcEdge::LowEtaLowPhi).z();
                         else if (isBarrel)
                             refPlane = hit->prd->detectorElement()->surface(hit->prd->identify()).center().perp();
                         else
@@ -1314,7 +1310,7 @@ namespace Muon {
         if (hits.empty()) return false;
 
         if (hough.m_descriptor.chIndex < 0 || hough.m_descriptor.chIndex >= Muon::MuonStationIndex::ChIndexMax) {
-            Identifier id = hits.front()->tgc ? hits.front()->tgc->etaCluster.hitList.front()->identify() : hits.front()->prd->identify();
+            Identifier id = hits.front()->tgc ? hits.front()->tgc->etaCluster.front()->identify() : hits.front()->prd->identify();
             ATH_MSG_WARNING("Bad ChIndex " << m_idHelperSvc->toString(id) << "  " << hough.m_descriptor.chIndex);
             return false;
         }
@@ -1324,7 +1320,7 @@ namespace Muon {
         if (m_debugHough) hough.setDebug(true);
         hough.fillLayer2(hits);
 
-        Identifier id_hit = hits.front()->tgc ? hits.front()->tgc->etaCluster.hitList.front()->identify() : hits.front()->prd->identify();
+	Identifier id_hit = hits.front()->tgc ? hits.front()->tgc->etaCluster.front()->identify() : hits.front()->prd->identify();
         MuonHough::MuonLayerHoughSelector selectorLoose;
         MuonHough::MuonLayerHoughSelector selector;
 
@@ -1354,8 +1350,8 @@ namespace Muon {
                 const unsigned int nHitsInMaximum = maximum.hits.size();
                 for (unsigned int i = 0; i < nHitsInMaximum; ++i) {
                     MuonHough::Hit& hit = *(maximum.hits[i]);
-                    Identifier id = hit.tgc ? hit.tgc->etaCluster.hitList.front()->identify() : hit.prd->identify();
-                    int nhits = hit.tgc ? hit.tgc->etaCluster.hitList.size() : 1;
+                    Identifier id = hit.tgc ? hit.tgc->etaCluster.front()->identify() : hit.prd->identify();
+                    int nhits = hit.tgc ? hit.tgc->etaCluster.size() : 1;
 
                     nmdt += m_idHelperSvc->isMdt(id);
                     nstgc  += m_idHelperSvc->issTgc(id);
@@ -1402,9 +1398,9 @@ namespace Muon {
                 const unsigned int nHitsInMaximum = maximum.hits.size();
                 for (unsigned int i = 0; i < nHitsInMaximum; ++i) {
                     MuonHough::PhiHit& hit = *(maximum.hits[i]);
-                    Identifier id = hit.tgc ? hit.tgc->phiCluster.hitList.front()->identify() : hit.prd->identify();
+                    Identifier id = hit.tgc ? hit.tgc->phiCluster.front()->identify() : hit.prd->identify();
 
-                    int nhits = hit.tgc ? hit.tgc->phiCluster.hitList.size() : 1;
+                    int nhits = hit.tgc ? hit.tgc->phiCluster.size() : 1;
                     ATH_MSG_VERBOSE("findMaxima(Phi) phiHit " << m_idHelperSvc->toString(id) << " hits " << nhits);
                 }
 
@@ -1823,7 +1819,7 @@ namespace Muon {
             }
             return;
         }
-        if (!clustering.bestEtaCluster() || clustering.bestEtaCluster()->hitList.empty() || !clustering.bestEtaCluster()->hitList.front()) {
+        if (clustering.bestEtaCluster().empty()) {
             ATH_MSG_DEBUG("TgcHitClusteringObj, no eta cluster selected! ");
             if (msgLvl(MSG::DEBUG)) {
                 for (const TgcPrepData* prd : prds) { ATH_MSG_DEBUG("   " << m_idHelperSvc->toString(prd->identify())); }
@@ -1838,21 +1834,17 @@ namespace Muon {
             if (sectors[si] != sector) continue;
 
             for (const TgcClusterObj3D& cl : clustering.clusters3D) {
-                if (cl.etaCluster.hitList.empty()) {
-                    ATH_MSG_WARNING("Incomplete TgcClusterObj3D in chamber " << m_idHelperSvc->toString(chid));
-                    continue;
-                }
-                const Identifier id = cl.etaCluster.hitList.front()->identify();
-
-                double x = cl.p11.z();
-                double y11 = rCor(cl, 1, sector);
-                double y12 = rCor(cl, 2, sector);
-                double y21 = rCor(cl, 3, sector);
-                double y22 = rCor(cl, 4, sector);
-                double phi11 = cl.p11.phi();
-                double phi12 = cl.p12.phi();
-                double phi21 = cl.p21.phi();
-                double phi22 = cl.p22.phi();
+                const Identifier id = cl.etaCluster.front()->identify();
+
+                double x = cl.getEdge(TgcEdge::LowEtaLowPhi).z();
+                double y11 = rCor(cl, TgcEdge::LowEtaLowPhi, sector);
+                double y12 = rCor(cl, TgcEdge::LowEtaHighPhi, sector);
+                double y21 = rCor(cl, TgcEdge::LowEtaLowPhi, sector);
+                double y22 = rCor(cl, TgcEdge::HighEtaHighPhi, sector);
+                double phi11 = cl.getEdge(TgcEdge::LowEtaLowPhi).phi();
+                double phi12 = cl.getEdge(TgcEdge::LowEtaHighPhi).phi();
+                double phi21 = cl.getEdge(TgcEdge::LowEtaLowPhi).phi();
+                double phi22 = cl.getEdge(TgcEdge::HighEtaHighPhi).phi();
                 double ymin = std::min(std::min(y11, y12), std::min(y21, y22));
                 double ymax = std::max(std::max(y11, y12), std::max(y21, y22));
                 double phimin = std::min(std::min(phi11, phi12), std::min(phi21, phi22));
@@ -1860,23 +1852,27 @@ namespace Muon {
                 double phi1 = phimin;  // phiCor(phimin,sector);
                 double phi2 = phimax;  // phiCor(phimax,sector);
                 int sublayer = sublay(id, x);
+                ATH_MSG_VERBOSE("Cluster "<<m_idHelperSvc->toString(id)<<" x: "<<x<<", y11: "<<y11
+                             <<", y12: "<<y12<<", y21: "<<y21<<", y22: "<<y22<<", phi11: "<<phi11<<", "
+                             <<"phi12: "<<phi12<<", phi21: "<<phi21<<", phi22: "<<phi22<<" ymin: "<<ymin<<", ymax: "<<ymax
+                             <<", phimin: "<<phimin<<", phimax: "<<phimax);
 
                 MuonHough::HitDebugInfo* debug = new MuonHough::HitDebugInfo(technology, sector, region, layer, sublayer);
-                debug->clusterSize = cl.etaCluster.hitList.size();
-                debug->clusterLayers = cl.etaCluster.layers();
-                debug->isEtaPhi = cl.phiCluster.layers();
-                debug->time = cl.etaCluster.hitList.front()->getBcBitMap();
+                debug->clusterSize = cl.etaCluster.size();
+                debug->clusterLayers = 2;
+                debug->isEtaPhi = true;
+                debug->time = cl.etaCluster.front()->getBcBitMap();
                 std::map<unsigned int, unsigned int>::const_iterator pos = m_techToTruthNameIdx.find(technology);
                 if (pos != m_techToTruthNameIdx.end()) { matchTruth(truthHits, *truthCollections[pos->second], id, *debug); }
 
                 MuonHough::HitDebugInfo* phiDebug = new MuonHough::HitDebugInfo(*debug);
-                phiDebug->clusterSize = cl.phiCluster.hitList.size();
-                phiDebug->clusterLayers = cl.phiCluster.layers();
-                phiDebug->isEtaPhi = cl.etaCluster.layers();
+                phiDebug->clusterSize = cl.phiCluster.size();
+                phiDebug->clusterLayers = 1;
+                phiDebug->isEtaPhi = true;
 
-                std::unique_ptr<MuonHough::Hit> hit = std::make_unique<MuonHough::Hit>(sublayer, x, ymin, ymax, 2 * cl.etaCluster.layers(), debug, nullptr, &cl);
+                std::unique_ptr<MuonHough::Hit> hit = std::make_unique<MuonHough::Hit>(sublayer, x, ymin, ymax, 2, debug, nullptr, &cl);
                 std::unique_ptr<MuonHough::PhiHit> phiHit =
-                    std::make_unique<MuonHough::PhiHit>(sublayer, y11, phi1, phi2, 2 * cl.phiCluster.layers(), phiDebug, nullptr, &cl);
+                    std::make_unique<MuonHough::PhiHit>(sublayer, y11, phi1, phi2, 2, phiDebug, nullptr, &cl);
                 hits.emplace_back(std::move(hit));
                 phiHits.emplace_back(std::move(phiHit));
             }
diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/MuonRecToolInterfaces/IMuonCombiTrackMaker.h b/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/MuonRecToolInterfaces/IMuonCombiTrackMaker.h
deleted file mode 100644
index d17bde6b6490..000000000000
--- a/MuonSpectrometer/MuonReconstruction/MuonRecTools/MuonRecToolInterfaces/MuonRecToolInterfaces/IMuonCombiTrackMaker.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-#ifndef MUON_IMUONCOMBITRACKMAKER_H
-#define MUON_IMUONCOMBITRACKMAKER_H
-
-#include <vector>
-
-#include "GaudiKernel/IAlgTool.h"
-#include "MuonSegment/MuonSegmentCombinationCollection.h"
-#include "TrkTrack/TrackCollection.h"
-
-static const InterfaceID IID_IMuonCombiTrackMaker("Muon::IMuonCombiTrackMaker", 1, 0);
-
-namespace Trk {
-    class Track;
-}
-
-namespace Muon {
-
-    /** @brief The IMuonSegmentMaker is a pure virtual interface for tools to find tracks starting from MuonSegmentCombinations  */
-    class IMuonCombiTrackMaker : virtual public IAlgTool {
-    public:
-        /** access to tool interface */
-        static const InterfaceID& interfaceID();
-
-        /** @brief find tracks starting from a MuonSegmentCombination
-            @param combi a reference to a MuonSegmentCombination
-            @return a pointer to a vector of tracks, the ownership of the tracks is passed to the client calling the tool.
-        */
-        virtual std::vector<Trk::Track*>* find(const MuonSegmentCombination& combi) const = 0;
-
-        /** @brief find tracks starting from a MuonSegmentCombinationCollection
-            @param combiCol a reference to a MuonSegmentCombinationCollection
-            @return a pointer to a vector of tracks, the ownership of the tracks is passed to the client calling the tool.
-        */
-        virtual TrackCollection* find(const MuonSegmentCombinationCollection& combiCol) const = 0;
-    };
-
-    inline const InterfaceID& IMuonCombiTrackMaker::interfaceID() { return IID_IMuonCombiTrackMaker; }
-
-}  // namespace Muon
-
-#endif
diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.cxx
index 6c97bc40cd79..8eddbfb89892 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.cxx
@@ -29,7 +29,7 @@ StatusCode MuonSegmentFinderAlg::initialize() {
     /// MDT segments
     ATH_CHECK(m_patternCalibration.retrieve(DisableTool{!m_runMdtSegments}));
     ATH_CHECK(m_segmentMaker.retrieve(DisableTool{!m_runMdtSegments}));
-    ATH_CHECK(m_clusterSegMaker.retrieve(DisableTool{!m_doTGCClust && !m_doRPCClust}));
+
     
     const bool doNSW = m_doSTgcSegments || m_doMMSegments;
     ATH_CHECK(m_clusterCreator.retrieve(DisableTool{!doNSW}));
@@ -41,13 +41,7 @@ StatusCode MuonSegmentFinderAlg::initialize() {
     /// Initialize the alignment container in the NSW
     ATH_CHECK(m_segmentNSWCollectionKey.initialize(doNSW && !m_segmentNSWCollectionKey.empty()));
     ATH_CHECK(m_cscPrdsKey.initialize(!m_cscPrdsKey.empty()));  // check for layouts without CSCs
-    ATH_CHECK(m_mdtPrdsKey.initialize(m_doTGCClust || m_doRPCClust));
-    ATH_CHECK(m_rpcPrdsKey.initialize(m_doRPCClust));
-    ATH_CHECK(m_tgcPrdsKey.initialize(m_doTGCClust));
     ATH_CHECK(m_patternCollKey.initialize());
-    ATH_CHECK(m_tgcTruth.initialize(m_doClusterTruth));
-    ATH_CHECK(m_rpcTruth.initialize(m_doClusterTruth));
-
     return StatusCode::SUCCESS;
 }
 
@@ -87,23 +81,6 @@ StatusCode MuonSegmentFinderAlg::execute(const EventContext& ctx) const {
                
     }  // end loop on pattern combinations
 
-    // do cluster based segment finding
-    if (m_doTGCClust || m_doRPCClust) {
-        const Muon::MdtPrepDataContainer* mdtPrds{nullptr};
-        const PRD_MultiTruthCollection* tgcTruthColl{nullptr};
-        const PRD_MultiTruthCollection* rpcTruthColl{nullptr};
-        const Muon::TgcPrepDataContainer* tgcPrdCont{nullptr};
-        const Muon::RpcPrepDataContainer* rpcPrdCont{nullptr};
-        ATH_CHECK(loadFromStoreGate(ctx, m_rpcPrdsKey, rpcPrdCont));
-        ATH_CHECK(loadFromStoreGate(ctx, m_tgcPrdsKey, tgcPrdCont));
-        ATH_CHECK(loadFromStoreGate(ctx,m_mdtPrdsKey, mdtPrds));
-        ATH_CHECK(loadFromStoreGate(ctx,m_tgcTruth, tgcTruthColl));
-        ATH_CHECK(loadFromStoreGate(ctx,m_rpcTruth, rpcTruthColl));
-       
-        m_clusterSegMaker->getClusterSegments(mdtPrds, rpcPrdCont, tgcPrdCont, tgcTruthColl,
-                                              rpcTruthColl, segmentContainer.get());
-    }
-
     m_segmentOverlapRemovalTool->removeDuplicates(*segmentContainer);
 
     std::unique_ptr<MuonSegmentCombinationCollection> csc4dSegmentCombinations{};
diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.h
index 1c29fa2a4cee..bc6b54818920 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.h
+++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef MOOSEGMENTFINDERS_MUOSEGMENTFINDERALGS_H
@@ -7,25 +7,17 @@
 
 #include "AthenaBaseComps/AthReentrantAlgorithm.h"
 #include "CscSegmentMakers/ICscSegmentFinder.h"
-#include "GaudiKernel/ServiceHandle.h"
-#include "GaudiKernel/ToolHandle.h"
 #include "MuonIdHelpers/IMuonIdHelperSvc.h"
 #include "MuonPattern/MuonPatternChamberIntersect.h"
-#include "MuonPrepRawData/CscPrepDataCollection.h"
-#include "MuonPrepRawData/MdtPrepDataCollection.h"
-#include "MuonPrepRawData/RpcPrepDataCollection.h"
-#include "MuonPrepRawData/TgcPrepDataCollection.h"
 #include "MuonRecHelperTools/MuonEDMPrinterTool.h"
 #include "MuonRecToolInterfaces/IMuonClusterOnTrackCreator.h"
 #include "MuonRecToolInterfaces/IMuonSegmentMaker.h"
 #include "MuonSegment/MuonSegmentCombinationCollection.h"
-#include "MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinder.h"
 #include "MuonSegmentMakerToolInterfaces/IMuonSegmentSelectionTool.h"
 #include "MuonSegmentMakerToolInterfaces/IMuonNSWSegmentFinderTool.h"
 #include "MuonSegmentMakerToolInterfaces/IMuonPatternCalibration.h"
 #include "MuonSegmentMakerToolInterfaces/IMuonSegmentOverlapRemovalTool.h"
 #include "TrkSegment/SegmentCollection.h"
-#include "TrkTruthData/PRD_MultiTruthCollection.h"
 
 class MuonSegmentFinderAlg : public AthReentrantAlgorithm {
 public:
@@ -58,11 +50,6 @@ private:
         "SegmentMaker",
         "Muon::DCMathSegmentMaker/DCMathSegmentMaker",
     };
-    ToolHandle<Muon::IMuonClusterSegmentFinder> m_clusterSegMaker{
-        this,
-        "MuonClusterSegmentFinder",
-        "Muon::MuonClusterSegmentFinder/MuonClusterSegmentFinder",
-    };
     ToolHandle<Muon::IMuonSegmentOverlapRemovalTool> m_segmentOverlapRemovalTool{
         this,
         "MuonSegmentOverlapRemovalTool",
@@ -111,42 +98,12 @@ private:
         "CSC_Clusters",
         "CSC PRDs",
     };
-    SG::ReadHandleKey<Muon::MdtPrepDataContainer> m_mdtPrdsKey{
-        this,
-        "MDT_PRDs",
-        "MDT_DriftCircles",
-        "MDT PRDs",
-    };
-    SG::ReadHandleKey<Muon::RpcPrepDataContainer> m_rpcPrdsKey{
-        this,
-        "RPC_PRDs",
-        "RPC_Measurements",
-        "RPC PRDs",
-    };
-    SG::ReadHandleKey<Muon::TgcPrepDataContainer> m_tgcPrdsKey{
-        this,
-        "TGC_PRDs",
-        "TGC_Measurements",
-        "TGC PRDs",
-    };
     SG::ReadHandleKey<MuonPatternCombinationCollection> m_patternCollKey{
         this,
         "MuonLayerHoughCombisKey",
         "MuonLayerHoughCombis",
         "Hough combinations",
     };
-    SG::ReadHandleKey<PRD_MultiTruthCollection> m_tgcTruth{
-        this,
-        "TGCTruth",
-        "TGC_TruthMap",
-        "TGC PRD Multi-truth Collection",
-    };
-    SG::ReadHandleKey<PRD_MultiTruthCollection> m_rpcTruth{
-        this,
-        "RPCTruth",
-        "RPC_TruthMap",
-        "RPC PRD Multi-truth Collection",
-    };
 
     StatusCode createSegmentsWithMDTs(const EventContext& ctx, const Muon::MuonPatternCombination* patt, Trk::SegmentCollection* segs) const;
     
@@ -165,9 +122,6 @@ private:
 
 
     Gaudi::Property<bool> m_printSummary{this, "PrintSummary", false};
-    Gaudi::Property<bool> m_doTGCClust{this, "doTGCClust", false, "selection flags for cluster based segment finding"};
-    Gaudi::Property<bool> m_doRPCClust{this, "doRPCClust", false, "selection flags for cluster based segment finding"};
-    Gaudi::Property<bool> m_doClusterTruth{this, "doClusterTruth", false, "selection flags for cluster based segment finding"};
 
     /// Run segment finding with eta / phi determination
     Gaudi::Property<bool> m_doFullFinder{this, "FullFinder", true}; 
diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/DCMathSegmentMaker.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/DCMathSegmentMaker.cxx
index 95d8732b1cb4..281c86d09f24 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/DCMathSegmentMaker.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/DCMathSegmentMaker.cxx
@@ -935,6 +935,7 @@ namespace Muon {
             ATH_MSG_WARNING(" Unphysical error assigned for gasgap " << m_idHelperSvc->toString(gasGapId));
             error = 1.;
         }
+        ATH_MSG_VERBOSE("New space point for "<<m_idHelperSvc->toStringGasGap(gasGapId)<<" at ("<<lpx<<","<<lpy<<")");
         return Cluster2D(detElId, gasGapId, Amg::Vector2D(lpx, lpy), error, etaHit, phiHit);
     }
 
diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/ATLAS_CHECK_THREAD_SAFETY b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/ATLAS_CHECK_THREAD_SAFETY
deleted file mode 100644
index 42cada0cc38f..000000000000
--- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/ATLAS_CHECK_THREAD_SAFETY
+++ /dev/null
@@ -1 +0,0 @@
-MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools
diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/CMakeLists.txt b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/CMakeLists.txt
deleted file mode 100644
index e2537f4818fa..000000000000
--- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-################################################################################
-# Package: MuonClusterSegmentMakerTools
-################################################################################
-
-# Declare the package name:
-atlas_subdir( MuonClusterSegmentMakerTools )
-
-# External dependencies:
-find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread )
-
-# Component(s) in the package:
-atlas_add_component( MuonClusterSegmentMakerTools
-                     src/*.cxx
-                     src/components/*.cxx
-                     INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} 
-                     LINK_LIBRARIES ${ROOT_LIBRARIES} AtlasHepMCLib GaudiKernel AthenaBaseComps MuonPrepRawDataProviderToolsLib MuonDetDescrUtils MuonIdHelpersLib MuonPrepRawData MuonRIO_OnTrack MuonSegment MuonRecHelperToolsLib MuonRecToolInterfaces MuonLinearSegmentMakerUtilities MuonSegmentMakerUtils TrkParameters TrkTrack TrkTruthData TrkFitterInterfaces TrkToolInterfaces MuonSegmentMakerToolInterfaces )
-
diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/MuonClusterSegmentFinder.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/MuonClusterSegmentFinder.cxx
deleted file mode 100644
index d2c6f4d34881..000000000000
--- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/MuonClusterSegmentFinder.cxx
+++ /dev/null
@@ -1,509 +0,0 @@
-/*
-  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
-*/
-
-#include "MuonClusterSegmentFinder.h"
-
-#include "AtlasHepMC/GenEvent.h"
-#include "GaudiKernel/ConcurrencyFlags.h"
-#include "MuonLinearSegmentMakerUtilities/ClusterAnalysis.h"
-#include "MuonPrepRawData/MdtPrepDataCollection.h"
-#include "MuonRIO_OnTrack/MdtDriftCircleOnTrack.h"
-#include "MuonRIO_OnTrack/MuonClusterOnTrack.h"
-#include "TFile.h"
-#include "TTree.h"
-
-namespace {
-    bool sortfunctionMB(const Trk::MeasurementBase* i, const Trk::MeasurementBase* j) {
-        return (std::abs(i->globalPosition().z()) < std::abs(j->globalPosition().z()));
-    }
-
-}  // namespace
-namespace Muon {
-
-    MuonClusterSegmentFinder::MuonClusterSegmentFinder(const std::string& type, const std::string& name, const IInterface* parent) :
-        AthAlgTool(type, name, parent) {
-        declareInterface<IMuonClusterSegmentFinder>(this);
-        declareProperty("DoNtuple", m_doNtuple = false);
-    }
-
-    StatusCode MuonClusterSegmentFinder::finalize() {
-        if (m_doNtuple) {
-            TDirectory* cdir = gDirectory;
-            m_tree->m_file->cd();
-            m_tree->m_tree->Write();
-            m_tree->m_file->Write();
-            m_tree->m_file->Close();
-            delete m_tree->m_ntuple;
-            gDirectory = cdir;
-        }
-        return StatusCode::SUCCESS;
-    }
-
-    StatusCode MuonClusterSegmentFinder::initialize() {
-        ATH_CHECK(m_idHelperSvc.retrieve());
-        ATH_CHECK(m_printer.retrieve());
-        ATH_CHECK(m_layerHashProvider.retrieve());
-        ATH_CHECK(m_muonPRDSelectionTool.retrieve());
-        ATH_CHECK(m_segmentMaker.retrieve());
-        ATH_CHECK(m_clusterTool.retrieve());
-        ATH_CHECK(m_clusterCreator.retrieve());
-        ATH_CHECK(m_trackToSegmentTool.retrieve());
-        ATH_CHECK(m_slTrackFitter.retrieve());
-        ATH_CHECK(m_ambiguityProcessor.retrieve());
-        ATH_CHECK(m_edmHelperSvc.retrieve());
-        ATH_CHECK(m_trackCleaner.retrieve());
-        ATH_CHECK(m_segmentOverlapRemovalTool.retrieve());
-
-        /// Ensure that the n-tuple is only written in the single thread mode
-        m_doNtuple &= Gaudi::Concurrency::ConcurrencyFlags::numThreads() <= 1;
-        if (m_doNtuple) {
-            TDirectory* cdir = gDirectory;
-            m_tree = std::make_unique<Tree>();
-            m_tree->m_file = new TFile("ClusterNtuple.root", "RECREATE");
-            m_tree->m_tree = new TTree("clusters", "clusters");
-            m_tree->m_ntuple = new ClusterSeg::ClusterNtuple();
-            m_tree->m_ntuple->initForWrite(*m_tree->m_tree);
-            gDirectory = cdir;
-        }
-
-        return StatusCode::SUCCESS;
-    }
-
-    bool MuonClusterSegmentFinder::matchTruth(const PRD_MultiTruthCollection& truthCol, const Identifier& id, int& bcode) const {
-        typedef PRD_MultiTruthCollection::const_iterator iprdt;
-        std::pair<iprdt, iprdt> range = truthCol.equal_range(id);
-        // Loop over particles contributing to this cluster
-        for (iprdt i = range.first; i != range.second; ++i) {
-            if (!i->second.isValid()) {
-                ATH_MSG_INFO("Unexpected invalid HepMcParticleLink in PRD_MultiTruthCollection");
-            } else {
-                const HepMcParticleLink& link = i->second;
-                if (link.cptr()) {
-                    if (std::abs(link.cptr()->pdg_id()) == 13) {
-                        bcode = link.barcode();
-                        return true;
-                    }
-                }
-            }
-        }
-        return false;
-    }
-
-    void MuonClusterSegmentFinder::getClusterSegments(const Muon::MdtPrepDataContainer* mdtPrdCont,
-                                                      std::vector<const Muon::TgcPrepDataCollection*>* tgcCols,
-                                                      std::vector<const Muon::RpcPrepDataCollection*>* rpcCols,
-                                                      const PRD_MultiTruthCollection* tgcTruthColl,
-                                                      const PRD_MultiTruthCollection* rpcTruthColl, Trk::SegmentCollection* segColl) const {
-        if (tgcCols) {
-            Muon::TgcPrepDataContainer* clusterPRD = new Muon::TgcPrepDataContainer(m_idHelperSvc->tgcIdHelper().module_hash_max());
-            for (const auto *const tgcCol : *tgcCols) {
-                Muon::TgcPrepDataCollection* clusteredCol = m_clusterTool->cluster(*tgcCol);
-                if (clusteredCol) clusterPRD->addCollection(clusteredCol, tgcCol->identifyHash()).ignore();
-            }
-            std::vector<const Muon::TgcPrepDataCollection*> theTGCs;
-            std::transform(clusterPRD->begin(), clusterPRD->end(), std::back_inserter(theTGCs), [](auto* c){return c;});
-            
-            findSegments(theTGCs, mdtPrdCont, segColl, tgcTruthColl);
-        }  // end if TGC
-
-        if (rpcCols) {
-            Muon::RpcPrepDataContainer* clusterPRD = new Muon::RpcPrepDataContainer(m_idHelperSvc->rpcIdHelper().module_hash_max());
-            for (const auto *const rpcCol : *rpcCols) {
-                Muon::RpcPrepDataCollection* clusteredCol = m_clusterTool->cluster(*rpcCol);
-                if (clusteredCol) clusterPRD->addCollection(clusteredCol, rpcCol->identifyHash()).ignore();
-            }
-            std::vector<const Muon::RpcPrepDataCollection*> theRPCs;
-            std::transform(clusterPRD->begin(), clusterPRD->end(), std::back_inserter(theRPCs), [](auto* c){return c;});
-            
-            findSegments(theRPCs, mdtPrdCont, segColl, rpcTruthColl);
-        }  // end if RPC
-    }
-
-    void MuonClusterSegmentFinder::getClusterSegments(const Muon::MdtPrepDataContainer* mdtPrdCont,
-                                                      const Muon::RpcPrepDataContainer* rpcPrdCont,
-                                                      const Muon::TgcPrepDataContainer* tgcPrdCont,
-                                                      const PRD_MultiTruthCollection* tgcTruthColl,
-                                                      const PRD_MultiTruthCollection* rpcTruthColl, Trk::SegmentCollection* segColl) const {
-        if (tgcPrdCont) {
-            Muon::TgcPrepDataContainer* clusterPRD = m_clusterTool->cluster(*tgcPrdCont);
-            std::vector<const Muon::TgcPrepDataCollection*> theTGCs;
-            std::transform(clusterPRD->begin(), clusterPRD->end(), std::back_inserter(theTGCs), [](auto* c){return c;});
-            findSegments(theTGCs, mdtPrdCont, segColl, tgcTruthColl);
-        }  // end if TGC
-
-        if (rpcPrdCont) {
-            Muon::RpcPrepDataContainer* clusterPRD = m_clusterTool->cluster(*rpcPrdCont);
-            std::vector<const Muon::RpcPrepDataCollection*> theRPCs;
-            std::transform(clusterPRD->begin(), clusterPRD->end(), std::back_inserter(theRPCs), [](auto* c){return c;});
-            
-
-            findSegments(theRPCs, mdtPrdCont, segColl, rpcTruthColl);
-        }  // end if rpc
-    }
-
-    void MuonClusterSegmentFinder::findSegments(std::vector<const TgcPrepDataCollection*>& tgcCols,
-                                                const Muon::MdtPrepDataContainer* mdtPrdCont, Trk::SegmentCollection* segColl,
-                                                const PRD_MultiTruthCollection* tgcTruthColl) const {
-        ATH_MSG_INFO("Executing " << name() << "...");
-        ATH_MSG_DEBUG("start with " << segColl->size() << " segments");
-
-        candEvent* thisEvent = new candEvent;
-
-        makeClusterVecs(tgcTruthColl, tgcCols, thisEvent);
-
-        ClusterSeg::ClusterAnalysis theAnalysis;
-        ATH_MSG_DEBUG("the size of Clust is " << thisEvent->Clust().size());
-        std::vector<std::vector<ClusterSeg::SpacePoint>> sPoints = theAnalysis.analyse(thisEvent->Clust());
-
-        processSpacePoints(thisEvent, sPoints);
-        if (!thisEvent->segTrkColl()->empty())
-            ATH_MSG_DEBUG("it made at least one track ");
-        else
-            ATH_MSG_DEBUG("processSpacePoints didn't make anything");
-
-        std::map<int, bool> themap;
-        findOverlap(themap, thisEvent);
-        resolveCollections(themap, thisEvent);
-
-        getSegments(thisEvent, mdtPrdCont, segColl);
-
-        ATH_MSG_DEBUG("now have " << segColl->size() << " segments");
-
-        if (m_doNtuple) {
-            Tree& t = getTree();
-            t.m_ntuple->fill(thisEvent->Clust());
-            t.m_tree->Fill();
-        }
-        delete thisEvent;
-    }
-
-    void MuonClusterSegmentFinder::findSegments(std::vector<const RpcPrepDataCollection*>& rpcCols,
-                                                const Muon::MdtPrepDataContainer* mdtPrdCont, Trk::SegmentCollection* segColl,
-                                                const PRD_MultiTruthCollection* rpcTruthColl) const {
-        ATH_MSG_INFO("Executing " << name() << "...");
-        ATH_MSG_DEBUG("start with " << segColl->size() << " segments");
-
-        candEvent* thisEvent = new candEvent;
-
-        makeClusterVecs(rpcTruthColl, rpcCols, thisEvent);
-
-        ClusterSeg::ClusterAnalysis theAnalysis;
-        ATH_MSG_DEBUG("the size of Clust is " << thisEvent->Clust().size());
-        std::vector<std::vector<ClusterSeg::SpacePoint>> sPoints = theAnalysis.analyse(thisEvent->Clust());
-
-        processSpacePoints(thisEvent, sPoints);
-        if (!thisEvent->segTrkColl()->empty())
-            ATH_MSG_DEBUG("it made at least one track ");
-        else
-            ATH_MSG_DEBUG("processSpacePoints didn't make anything");
-
-        std::map<int, bool> themap;
-        findOverlap(themap, thisEvent);
-        resolveCollections(themap, thisEvent);
-
-        getSegments(thisEvent, mdtPrdCont, segColl);
-
-        ATH_MSG_DEBUG("now have " << segColl->size() << " segments");
-
-        if (m_doNtuple) {
-            Tree& t = getTree();
-            t.m_ntuple->fill(thisEvent->Clust());
-            t.m_tree->Fill();
-        }
-        delete thisEvent;
-    }
-
-    void MuonClusterSegmentFinder::findOverlap(std::map<int, bool>& themap, candEvent* theEvent) {
-        CompareMuonSegmentKeys compareKeys{};
-        if (theEvent->keyVector().size() > 1) {
-            for (unsigned int i = 0; i < theEvent->keyVector().size(); i++) { themap.insert(std::pair<int, bool>(i, true)); }
-            for (unsigned int i = 0; i < theEvent->keyVector().size() - 1; i++) {
-                for (unsigned int j = i + 1; j < theEvent->keyVector().size(); j++) {
-                    CompareMuonSegmentKeys::OverlapResult overlap = compareKeys(theEvent->keyVector()[i], theEvent->keyVector()[j]);
-                    if (overlap == 0 || overlap == 2) themap[j] = false;
-                    if (overlap == 1) themap[i] = false;
-                }
-            }
-        }
-    }
-
-    Trk::Track* MuonClusterSegmentFinder::fit(const std::vector<const Trk::MeasurementBase*>& vec2,
-                                              const Trk::TrackParameters& startpar) const {
-        const EventContext& ctx = Gaudi::Hive::currentContext();
-        std::unique_ptr<Trk::Track> segtrack{m_slTrackFitter->fit(ctx, vec2, startpar, false, Trk::nonInteracting)};
-
-        if (segtrack) {
-            ATH_MSG_DEBUG("segment fit succeeded");
-
-            std::unique_ptr<Trk::Track> cleanedTrack = m_trackCleaner->clean(*segtrack, ctx);
-            if (cleanedTrack && !(*cleanedTrack->perigeeParameters() == *segtrack->perigeeParameters())) {
-                // using release until the entire code can be migrated to use smart pointers
-                segtrack.swap(cleanedTrack);
-            } else {
-                ATH_MSG_DEBUG("track remains unchanged");
-            }
-
-            if (!m_edmHelperSvc->goodTrack(*segtrack, 30) && vec2.size() > 4) {
-                ATH_MSG_DEBUG("bad segment fit:");
-                if (segtrack->fitQuality())
-                    ATH_MSG_DEBUG("with chi^2/nDoF = " << segtrack->fitQuality()->chiSquared() << "/"
-                                                       << segtrack->fitQuality()->numberDoF());
-
-                return nullptr;
-            }
-        }
-        return segtrack.release();
-    }
-
-    void MuonClusterSegmentFinder::makeClusterVecs(const std::vector<const Muon::MuonClusterOnTrack*>& clustCol,
-                                                   candEvent* theEvent) const {
-        for (const MuonClusterOnTrack* clust : clustCol) {
-            MuonStationIndex::PhiIndex pIndex = m_idHelperSvc->phiIndex(clust->identify());
-            bool tmatch(false);
-            int barcode(0);
-            if (m_idHelperSvc->measuresPhi(clust->identify())) {
-                theEvent->clusters().push_back(clust);
-                ClusterSeg::Cluster* cluster =
-                    new ClusterSeg::Cluster(clust->globalPosition().x(), clust->globalPosition().y(), clust->globalPosition().z(), true,
-                                            MuonStationIndex::TechnologyIndex::TGC, pIndex, tmatch, barcode);
-                theEvent->Clust().push_back(cluster);
-            } else {
-                theEvent->clusters().push_back(clust);
-                ClusterSeg::Cluster* cluster =
-                    new ClusterSeg::Cluster(clust->globalPosition().x(), clust->globalPosition().y(), clust->globalPosition().z(), false,
-                                            MuonStationIndex::TechnologyIndex::TGC, pIndex, tmatch, barcode);
-                theEvent->Clust().push_back(cluster);
-            }
-        }
-    }
-
-    void MuonClusterSegmentFinder::makeClusterVecs(const PRD_MultiTruthCollection* truthCollectionTGC,
-                                                   const std::vector<const TgcPrepDataCollection*>& tgcCols, candEvent* theEvent) const {
-        for (std::vector<const TgcPrepDataCollection*>::const_iterator colIt = tgcCols.begin(); colIt != tgcCols.end(); ++colIt) {
-            TgcPrepDataCollection::const_iterator pit = (*colIt)->begin();
-            for (; pit != (*colIt)->end(); ++pit) {
-                const MuonCluster* cl = *pit;
-                if (!cl) continue;
-                bool tmatch = false;
-                int barcode = 0;
-                if (truthCollectionTGC) {
-                    const Identifier& id = (*pit)->identify();
-                    tmatch = matchTruth(*truthCollectionTGC, id, barcode);
-                }
-                const MuonClusterOnTrack* clust = m_clusterCreator->createRIO_OnTrack(*cl, cl->globalPosition());
-                MuonStationIndex::PhiIndex pIndex = m_idHelperSvc->phiIndex(clust->identify());
-                if (m_idHelperSvc->measuresPhi(clust->identify())) {
-                    theEvent->clusters().push_back(clust);
-                    ClusterSeg::Cluster* cluster =
-                        new ClusterSeg::Cluster(clust->globalPosition().x(), clust->globalPosition().y(), clust->globalPosition().z(), true,
-                                                MuonStationIndex::TechnologyIndex::TGC, pIndex, tmatch, barcode);
-                    theEvent->Clust().push_back(cluster);
-                } else {
-                    theEvent->clusters().push_back(clust);
-                    ClusterSeg::Cluster* cluster =
-                        new ClusterSeg::Cluster(clust->globalPosition().x(), clust->globalPosition().y(), clust->globalPosition().z(),
-                                                false, MuonStationIndex::TechnologyIndex::TGC, pIndex, tmatch, barcode);
-                    theEvent->Clust().push_back(cluster);
-                }
-            }
-        }
-    }
-
-    void MuonClusterSegmentFinder::makeClusterVecs(const PRD_MultiTruthCollection* truthCollectionRPC,
-                                                   const std::vector<const RpcPrepDataCollection*>& rpcCols, candEvent* theEvent) const {
-        for (std::vector<const RpcPrepDataCollection*>::const_iterator colIt = rpcCols.begin(); colIt != rpcCols.end(); ++colIt) {
-            RpcPrepDataCollection::const_iterator pit = (*colIt)->begin();
-            for (; pit != (*colIt)->end(); ++pit) {
-                const MuonCluster* cl = *pit;
-                if (!cl) continue;
-                bool tmatch = false;
-                int barcode = 0;
-                if (truthCollectionRPC) {
-                    const Identifier& id = (*pit)->identify();
-                    tmatch = matchTruth(*truthCollectionRPC, id, barcode);
-                }
-                const MuonClusterOnTrack* clust = m_clusterCreator->createRIO_OnTrack(*cl, cl->globalPosition());
-                MuonStationIndex::PhiIndex pIndex = m_idHelperSvc->phiIndex(clust->identify());
-                if (m_idHelperSvc->measuresPhi(clust->identify())) {
-                    theEvent->clusters().push_back(clust);
-                    ClusterSeg::Cluster* cluster =
-                        new ClusterSeg::Cluster(clust->globalPosition().x(), clust->globalPosition().y(), clust->globalPosition().z(), true,
-                                                MuonStationIndex::TechnologyIndex::RPC, pIndex, tmatch, barcode);
-                    theEvent->Clust().push_back(cluster);
-                } else {
-                    theEvent->clusters().push_back(clust);
-                    ClusterSeg::Cluster* cluster =
-                        new ClusterSeg::Cluster(clust->globalPosition().x(), clust->globalPosition().y(), clust->globalPosition().z(),
-                                                false, MuonStationIndex::TechnologyIndex::RPC, pIndex, tmatch, barcode);
-                    theEvent->Clust().push_back(cluster);
-                }
-            }
-        }
-    }
-
-    void MuonClusterSegmentFinder::processSpacePoints(candEvent* theEvent,
-                                                      std::vector<std::vector<ClusterSeg::SpacePoint>>& sPoints) const {
-        bool truthSeed(true);
-        int fakeCounter(0);
-        unsigned int barcodeCounter(0);
-        int barcodeVal(0);
-
-        for (const std::vector<ClusterSeg::SpacePoint>& sit : sPoints) {
-            if (sit.size() < 2) continue;
-            std::vector<const MuonClusterOnTrack*> vec1;
-            std::vector<const Trk::MeasurementBase*> vec2;
-
-            for (unsigned int i = 0; i < sit.size(); i++) {
-                int spEit = sit[i].eit();
-                vec1.push_back(theEvent->clusters()[spEit]);
-                vec2.push_back(theEvent->clusters()[spEit]);
-                int spPit = sit[i].pit();
-                vec1.push_back(theEvent->clusters()[spPit]);
-                vec2.push_back(theEvent->clusters()[spPit]);
-                if (!(sit[i].isMatch()))
-                    fakeCounter++;
-                else if (barcodeCounter == 0) {
-                    barcodeVal = sit[i].barcode();
-                    barcodeCounter++;
-                } else if (barcodeVal == sit[i].barcode())
-                    barcodeCounter++;
-            }
-
-            if (fakeCounter != 0) truthSeed = false;
-            std::sort(vec2.begin(), vec2.end(), sortfunctionMB);
-            Trk::TrackParameters* startpar = nullptr;
-            Amg::Vector3D gp(sit.front().x(), sit.front().y(), sit.front().z());
-            Amg::Vector3D gd(sit.back().x() - sit.front().x(), sit.back().y() - sit.front().y(), sit.back().z() - sit.front().z());
-            Amg::Vector3D perpos = gp + -10 * (gd.unit());
-            if (perpos.dot(gd) < 0) gd = -1 * gd;
-            startpar = new Trk::Perigee(perpos, gd, 0, perpos);
-            ATH_MSG_DEBUG("It is starting a fit with " << vec2.size() << "Measurement Base elements and " << startpar);
-            Trk::Track* segtrack = fit(vec2, *startpar);
-            delete startpar;
-            if (segtrack) {
-                MuonSegmentKey keyEntry = MuonSegmentKey(vec2);
-                theEvent->keyVector().push_back(keyEntry);
-                double chi2 = segtrack->fitQuality()->chiSquared();
-                double dof = segtrack->fitQuality()->doubleNumberDoF();
-                if (m_tree) {
-                    Tree& t = getTree();
-                    if (truthSeed) t.m_ntuple->fill(chi2 / dof, ClusterSeg::FillType::chi2T);
-                    t.m_ntuple->fill(chi2 / dof, ClusterSeg::FillType::chi2);
-                }
-                ATH_MSG_DEBUG("the chi2 is " << chi2 << "the dof are " << dof << " and the chi2/dof is " << chi2 / dof);
-                theEvent->segTrkColl()->push_back(segtrack);
-                theEvent->trackSeeds().emplace_back(gp, gd);
-                theEvent->hits().push_back(vec1);
-            } else {
-                ATH_MSG_DEBUG("segment fit failed");
-            }
-        }
-    }
-
-    void MuonClusterSegmentFinder::resolveCollections(const std::map<int, bool>& themap, candEvent* theEvent) const {
-        for (unsigned int i = 0; i < theEvent->keyVector().size(); i++) {
-            if (themap.at(i)) {
-                theEvent->resolvedTrackSeeds().emplace_back(theEvent->trackSeeds()[i].first, theEvent->trackSeeds()[i].second);
-                theEvent->resolvedhits().push_back(theEvent->hits()[i]);
-                theEvent->resolvedTracks()->push_back(new Trk::Track(*(theEvent->segTrkColl()->at(i))));
-            }
-        }
-        if (theEvent->keyVector().size() == 1) {
-            theEvent->resolvedTrackSeeds().emplace_back(theEvent->trackSeeds()[0].first, theEvent->trackSeeds()[0].second);
-            theEvent->resolvedhits().push_back(theEvent->hits()[0]);
-            theEvent->resolvedTracks()->push_back(new Trk::Track(*(theEvent->segTrkColl()->at(0))));
-        }
-        ATH_MSG_DEBUG("Resolved track candidates: old size " << theEvent->segTrkColl()->size() << " new size "
-                                                             << theEvent->resolvedTracks()->size());
-    }
-
-    void MuonClusterSegmentFinder::getSegments(candEvent* theEvent, const Muon::MdtPrepDataContainer* mdtPrdCont,
-                                               Trk::SegmentCollection* segColl) const {
-        std::vector<const Muon::MuonSegment*> appendSegments;
-
-        const std::vector<const Muon::MuonClusterOnTrack*> MCOTs;
-        for (unsigned int i = 0; i < theEvent->resolvedTracks()->size(); i++) {
-            const DataVector<const Trk::TrackParameters>* tpVec = theEvent->resolvedTracks()->at(i)->trackParameters();
-            if (!tpVec || tpVec->empty() || !tpVec->front()) continue;
-            const Trk::TrackParameters& startPars = *tpVec->front();
-
-            const std::vector<const MuonClusterOnTrack*>& MCOTs = theEvent->resolvedhits()[i];
-            if (MCOTs.empty()) continue;
-
-            const Identifier& id = MCOTs.front()->identify();
-            MuonStationIndex::DetectorRegionIndex regionIndex = m_idHelperSvc->regionIndex(id);
-            MuonStationIndex::LayerIndex layerIndex = m_idHelperSvc->layerIndex(id);
-
-            MuonLayerSurface::SurfacePtr surfacePtr(startPars.associatedSurface().clone());
-            std::shared_ptr<const Trk::TrackParameters> parsPtr(startPars.clone());
-
-            // get sectors and loop over them
-            std::vector<int> sectors;
-            theEvent->sectorMapping().getSectors(startPars.position().phi(), sectors);
-            for (auto sector : sectors) {
-                MuonLayerSurface layerSurface(surfacePtr, sector, regionIndex, layerIndex);
-                MuonSystemExtension::Intersection intersection(parsPtr, layerSurface);
-
-                std::vector<const MdtPrepDataCollection*> mdtCols;
-                if (!getLayerData(sector, regionIndex, layerIndex, mdtPrdCont, mdtCols)) {
-                    ATH_MSG_DEBUG("Failed to get MDT PRD collections ");
-                    continue;
-                }
-                std::vector<const Muon::MdtDriftCircleOnTrack*> MDTs;
-                for (const auto *mdtCol : mdtCols) {
-                    if (!m_muonPRDSelectionTool->calibrateAndSelectMdt(intersection, *mdtCol, MDTs)) {
-                        ATH_MSG_DEBUG("Failed to calibrate MDT PRD collection ");
-                        continue;
-                    }
-                }
-                ATH_MSG_DEBUG("Running mdt segment finding: MDTs " << MDTs.size() << " MCOTs " << MCOTs.size());
-                m_segmentMaker->find(theEvent->resolvedTrackSeeds()[i].first, theEvent->resolvedTrackSeeds()[i].second, MDTs, MCOTs, false,
-                                     segColl);
-                ATH_MSG_DEBUG("the size of the segment collection is " << segColl->size());
-                for (unsigned int j = 0; j < segColl->size(); j++) {
-                    Trk::Segment* tseg = segColl->at(j);
-                    ATH_MSG_DEBUG("the " << j << "th segment contains " << (dynamic_cast<MuonSegment*>(tseg))->numberOfContainedROTs()
-                                         << " ROTs ");
-                }
-            }
-        }
-    }
-
-    bool MuonClusterSegmentFinder::getLayerData(int sector, MuonStationIndex::DetectorRegionIndex regionIndex,
-                                                MuonStationIndex::LayerIndex layerIndex, const Muon::MdtPrepDataContainer* input,
-                                                std::vector<const MdtPrepDataCollection*>& output) const {
-        // get technologies in the given layer
-        unsigned int sectorLayerHash = MuonStationIndex::sectorLayerHash(regionIndex, layerIndex);
-
-        // get hashes
-        const MuonLayerHashProviderTool::HashVec& hashes =
-            m_layerHashProvider->getHashes(sector, MuonStationIndex::TechnologyIndex::MDT, sectorLayerHash);
-
-        // skip empty inputs
-        if (hashes.empty()) return true;
-
-        // loop over hashes
-        for (MuonLayerHashProviderTool::HashVec::const_iterator it = hashes.begin(); it != hashes.end(); ++it) {
-            // skip if not found
-            const auto *col = input->indexFindPtr(*it);
-            if (!col) {
-                // ATH_MSG_WARNING("Cannot find hash " << *it << " in container at " << location);
-                continue;
-            }
-            ATH_MSG_VERBOSE("  adding " << m_idHelperSvc->toStringChamber(col->identify()) << " size " << col->size());
-            // else add
-            output.push_back(col);
-        }
-        return true;
-    }
-
-    MuonClusterSegmentFinder::Tree& MuonClusterSegmentFinder::getTree() const
-    {
-      // We earlier checked that no more than one thread is being used.
-      Tree* t ATLAS_THREAD_SAFE = m_tree.get();
-      return *t;
-    }
-
-
-}  // namespace Muon
diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/MuonClusterSegmentFinder.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/MuonClusterSegmentFinder.h
deleted file mode 100644
index c0e87ead0b54..000000000000
--- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/MuonClusterSegmentFinder.h
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
-  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
-*/
-
-#ifndef MUON_MUONCLUSTERSEGMENTFINDER_H
-#define MUON_MUONCLUSTERSEGMENTFINDER_H
-
-#include <string>
-#include <vector>
-
-#include "AthenaBaseComps/AthAlgTool.h"
-#include "GaudiKernel/ServiceHandle.h"
-#include "GaudiKernel/ToolHandle.h"
-#include "MuonClusterization/IMuonClusterizationTool.h"
-#include "MuonDetDescrUtils/MuonSectorMapping.h"
-#include "MuonIdHelpers/IMuonIdHelperSvc.h"
-#include "MuonLinearSegmentMakerUtilities/ClusterNtuple.h"
-#include "MuonPrepRawData/MuonCluster.h"
-#include "MuonPrepRawData/RpcPrepDataCollection.h"
-#include "MuonPrepRawData/TgcPrepDataCollection.h"
-#include "MuonPrepRawDataProviderTools/MuonLayerHashProviderTool.h"
-#include "MuonRIO_OnTrack/MuonClusterOnTrack.h"
-#include "MuonRecHelperTools/IMuonEDMHelperSvc.h"
-#include "MuonRecHelperTools/MuonEDMPrinterTool.h"
-#include "MuonRecToolInterfaces/IMuonClusterOnTrackCreator.h"
-#include "MuonRecToolInterfaces/IMuonPRDSelectionTool.h"
-#include "MuonRecToolInterfaces/IMuonSegmentMaker.h"
-#include "MuonRecToolInterfaces/IMuonTrackCleaner.h"
-#include "MuonRecToolInterfaces/IMuonTrackToSegmentTool.h"
-#include "MuonSegment/MuonSegment.h"
-#include "MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinder.h"
-#include "MuonSegmentMakerToolInterfaces/IMuonSegmentOverlapRemovalTool.h"
-#include "MuonSegmentMakerUtils/CompareMuonSegmentKeys.h"
-#include "MuonSegmentMakerUtils/MuonSegmentKey.h"
-#include "TrkFitterInterfaces/ITrackFitter.h"
-#include "TrkParameters/TrackParameters.h"
-#include "TrkToolInterfaces/ITrackAmbiguityProcessorTool.h"
-#include "TrkTrack/Track.h"
-#include "TrkTrack/TrackCollection.h"
-#include "TrkTruthData/PRD_MultiTruthCollection.h"
-
-class TTree;
-class TFile;
-
-namespace Trk {
-    class MeasurementBase;
-}  // namespace Trk
-
-namespace Muon {
-
-    struct candEvent {
-        candEvent()
-          : m_segTrkColl (std::make_unique<TrackCollection>()),
-            m_resolvedTracks (std::make_unique<TrackCollection>())
-        {
-        }
-        ~candEvent() = default;
-
-        TrackCollection* segTrkColl() const { return m_segTrkColl.get(); }
-        std::vector<const MuonClusterOnTrack*>& clusters() { return m_clusters; }
-        std::vector<ClusterSeg::Cluster*>& Clust() { return m_Clust; }
-        std::vector<std::vector<const MuonClusterOnTrack*>>& hits() { return m_hits; }
-        std::vector<std::pair<Amg::Vector3D, Amg::Vector3D>>& trackSeeds() { return m_trackSeeds; }
-        std::vector<MuonSegmentKey>& keyVector() { return m_keyVector; }
-        std::vector<std::vector<ClusterSeg::SpacePoint>>& SPoints() { return m_SPoints; }
-        MuonSectorMapping& sectorMapping() { return m_sectorMapping; }
-        TrackCollection* resolvedTracks() const { return m_resolvedTracks.get(); }
-        std::vector<std::pair<Amg::Vector3D, Amg::Vector3D>>& resolvedTrackSeeds() { return m_resolvedTrackSeeds; }
-        std::vector<std::vector<const MuonClusterOnTrack*>>& resolvedhits() { return m_resolvedhits; }
-
-        std::unique_ptr<TrackCollection> m_segTrkColl{nullptr};
-        std::unique_ptr<TrackCollection> m_resolvedTracks{nullptr};
-
-        std::vector<const MuonClusterOnTrack*> m_clusters;
-        std::vector<ClusterSeg::Cluster*> m_Clust;
-        std::vector<std::vector<const MuonClusterOnTrack*>> m_hits;
-        std::vector<std::pair<Amg::Vector3D, Amg::Vector3D>> m_trackSeeds;
-        std::vector<MuonSegmentKey> m_keyVector;
-        std::vector<std::vector<ClusterSeg::SpacePoint>> m_SPoints;
-        MuonSectorMapping m_sectorMapping;
-        std::vector<std::pair<Amg::Vector3D, Amg::Vector3D>> m_resolvedTrackSeeds;
-        std::vector<std::vector<const MuonClusterOnTrack*>> m_resolvedhits;
-    };
-
-    class MuonClusterSegmentFinder : virtual public IMuonClusterSegmentFinder, public AthAlgTool {
-    public:
-        /** Default AlgTool functions */
-        MuonClusterSegmentFinder(const std::string& type, const std::string& name, const IInterface* parent);
-        virtual ~MuonClusterSegmentFinder() = default;
-        StatusCode initialize();
-        StatusCode finalize();
-
-        void getClusterSegments(const Muon::MdtPrepDataContainer* mdtPrdCont, const Muon::RpcPrepDataContainer* rpcPrdCont,
-                                const Muon::TgcPrepDataContainer* tgcPrdCont, const PRD_MultiTruthCollection* tgcTruthColl,
-                                const PRD_MultiTruthCollection* rpcTruthColl, Trk::SegmentCollection* segColl) const;
-
-        void getClusterSegments(const Muon::MdtPrepDataContainer* mdtPrdCont, std::vector<const Muon::TgcPrepDataCollection*>* tgcCols,
-                                std::vector<const Muon::RpcPrepDataCollection*>* rpcCols, const PRD_MultiTruthCollection* tgcTruthColl,
-                                const PRD_MultiTruthCollection* rpcTruthColl, Trk::SegmentCollection* segColl) const;
-
-        /** tgc segment finding */
-        void findSegments(std::vector<const TgcPrepDataCollection*>& tgcCols, const Muon::MdtPrepDataContainer* mdtPrdCont,
-                          Trk::SegmentCollection* segColl, const PRD_MultiTruthCollection* tgcTruthColl) const;
-        /** rpc segment finding */
-        void findSegments(std::vector<const RpcPrepDataCollection*>& rpcCols, const Muon::MdtPrepDataContainer* mdtPrdCont,
-                          Trk::SegmentCollection* segColl, const PRD_MultiTruthCollection* tgcTruthColl) const;
-
-    private:
-        ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{
-            this,
-            "MuonIdHelperSvc",
-            "Muon::MuonIdHelperSvc/MuonIdHelperSvc",
-        };
-        ServiceHandle<IMuonEDMHelperSvc> m_edmHelperSvc{
-            this,
-            "edmHelper",
-            "Muon::MuonEDMHelperSvc/MuonEDMHelperSvc",
-            "Handle to the service providing the IMuonEDMHelperSvc interface",
-        };  //<! Id helper tool
-
-        PublicToolHandle<MuonEDMPrinterTool> m_printer{
-            this,
-            "MuonEDMPrinterTool",
-            "Muon::MuonEDMPrinterTool/MuonEDMPrinterTool",
-        };
-        ToolHandle<MuonLayerHashProviderTool> m_layerHashProvider{
-            this,
-            "MuonLayerHashProviderTool",
-            "Muon::MuonLayerHashProviderTool/MuonLayerHashProviderTool",
-        };
-        ToolHandle<IMuonPRDSelectionTool> m_muonPRDSelectionTool{
-            this, "MuonPRDSelectionTool", ""
-        };
-        ToolHandle<IMuonSegmentMaker> m_segmentMaker{
-            this,
-            "MdtSegmentMaker",
-            "Muon::DCMathSegmentMaker/DCMathSegmentMaker",
-        };
-        ToolHandle<Muon::IMuonClusterizationTool> m_clusterTool{
-            this,
-            "MuonClusterizationTool",
-            "Muon::MuonClusterizationTool/MuonClusterizationTool",
-        };  //<! clustering tool
-        ToolHandle<IMuonClusterOnTrackCreator> m_clusterCreator{
-            this,
-            "MuonClusterOnTrackCreator",
-            "Muon::MuonClusterOnTrackCreator/MuonClusterOnTrackCreator",
-        };
-        ToolHandle<IMuonTrackToSegmentTool> m_trackToSegmentTool{
-            this,
-            "TrackToSegmentTool",
-            "Muon::MuonTrackToSegmentTool/MuonTrackToSegmentTool",
-        };  //<! track to segment converter
-        ToolHandle<Trk::ITrackFitter> m_slTrackFitter{
-            this,
-            "SLFitter",
-            "Trk::GlobalChi2Fitter/MCTBSLFitter",
-        };  //<! fitter, always use straightline
-        ToolHandle<Trk::ITrackAmbiguityProcessorTool> m_ambiguityProcessor{
-            this,
-            "AmbiguityProcessor",
-            "Trk::TrackSelectionProcessorTool/MuonAmbiProcessor",
-        };  //!< Tool for ambiguity solving
-        ToolHandle<IMuonTrackCleaner> m_trackCleaner{
-            this,
-            "TrackCleaner",
-            "Muon::MuonTrackCleaner/MuonTrackCleaner",
-        };
-        ToolHandle<IMuonSegmentOverlapRemovalTool> m_segmentOverlapRemovalTool{
-            this,
-            "MuonSegmentOverlapRemovalTool",
-            "Muon::MuonSegmentOverlapRemovalTool/MuonSegmentOverlapRemovalTool",
-        };
-
-        bool m_doNtuple{false};
-        struct Tree {
-          TFile* m_file{nullptr};
-          TTree* m_tree{nullptr};
-          ClusterSeg::ClusterNtuple* m_ntuple{nullptr};
-        };
-        std::unique_ptr<Tree> m_tree;
-
-        bool matchTruth(const PRD_MultiTruthCollection& truthCol, const Identifier& id, int& barcode) const;
-        Trk::Track* fit(const std::vector<const Trk::MeasurementBase*>& vec2, const Trk::TrackParameters& startpar) const;
-        void makeClusterVecs(const std::vector<const Muon::MuonClusterOnTrack*>& clustCol, candEvent* theEvent) const;
-        void makeClusterVecs(const PRD_MultiTruthCollection* truthCollectionTGC, const std::vector<const TgcPrepDataCollection*>& tgcCols,
-                             candEvent* theEvent) const;
-        void makeClusterVecs(const PRD_MultiTruthCollection* truthCollectionRPC, const std::vector<const RpcPrepDataCollection*>& rpcCols,
-                             candEvent* theEvent) const;
-        static void findOverlap(std::map<int, bool>& themap, candEvent* theEvent) ;
-        void processSpacePoints(candEvent* theEvent, std::vector<std::vector<ClusterSeg::SpacePoint>>& sPoints) const;
-        void resolveCollections(const std::map<int, bool>& themap, candEvent* theEvent) const;
-        void getSegments(candEvent* theEvent, const Muon::MdtPrepDataContainer* mdtPrdCont, Trk::SegmentCollection* segColl) const;
-        bool getLayerData(int sector, MuonStationIndex::DetectorRegionIndex regionIndex, MuonStationIndex::LayerIndex layerIndex,
-                          const Muon::MdtPrepDataContainer* input, std::vector<const MdtPrepDataCollection*>& output) const;
-
-      Tree& getTree() const;
-    };
-
-}  // namespace Muon
-
-#endif
diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/components/MuonClusterSegmentMakerTools_entries.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/components/MuonClusterSegmentMakerTools_entries.cxx
deleted file mode 100644
index 5d9fa99aa95a..000000000000
--- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonClusterSegmentMakerTools/src/components/MuonClusterSegmentMakerTools_entries.cxx
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "../MuonClusterSegmentFinder.h"
-
-using namespace Muon;
-
-DECLARE_COMPONENT(MuonClusterSegmentFinder)
diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonLayerSegmentMakerTools/src/MuonLayerSegmentFinderTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonLayerSegmentMakerTools/src/MuonLayerSegmentFinderTool.cxx
index fb6bca3365ff..a0210dfe66b0 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonLayerSegmentMakerTools/src/MuonLayerSegmentFinderTool.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonLayerSegmentMakerTools/src/MuonLayerSegmentFinderTool.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "MuonLayerSegmentFinderTool.h"
@@ -306,7 +306,9 @@ namespace Muon {
 
                 // treat the case that the hit is a composite TGC hit
                 if (hit->tgc) {
-                    for (const auto& prd : hit->tgc->etaCluster.hitList) handleCluster(*prd, clusters);
+                    for (const auto& prd : hit->tgc->etaCluster) {
+                        handleCluster(*prd, clusters);
+                    }
                 } else if (hit->prd) {
                     Identifier id = hit->prd->identify();
                     if (m_idHelperSvc->isMdt(id))
@@ -333,10 +335,10 @@ namespace Muon {
 
                 for (const auto& phi_hit : maximum.hits) {
                     // treat the case that the hit is a composite TGC hit
-                    if (phi_hit->tgc && !phi_hit->tgc->phiCluster.hitList.empty()) {
-                        Identifier id = phi_hit->tgc->phiCluster.hitList.front()->identify();
+                    if (phi_hit->tgc) {
+                        Identifier id = phi_hit->tgc->phiCluster.front()->identify();
                         if (m_idHelperSvc->layerIndex(id) != intersection.layerSurface.layerIndex) continue;
-                        for (const auto& prd : phi_hit->tgc->phiCluster.hitList) handleCluster(*prd, clusters);
+                        for (const auto& prd : phi_hit->tgc->phiCluster) handleCluster(*prd, clusters);
                     } else if (phi_hit->prd) {
                         Identifier id = phi_hit->prd->identify();
                         if (m_idHelperSvc->layerIndex(id) != intersection.layerSurface.layerIndex) continue;
diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonLayerSegmentMakerTools/src/MuonLayerSegmentFinderTool.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonLayerSegmentMakerTools/src/MuonLayerSegmentFinderTool.h
index 00739f64de6c..bb040be351e8 100644
--- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonLayerSegmentMakerTools/src/MuonLayerSegmentFinderTool.h
+++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonLayerSegmentMakerTools/src/MuonLayerSegmentFinderTool.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef MUON_MUONLAYERSEGMENTFINDERTOOL_H
@@ -19,7 +19,6 @@
 #include "MuonRecHelperTools/MuonEDMPrinterTool.h"
 #include "MuonRecToolInterfaces/IMuonPRDSelectionTool.h"
 #include "MuonRecToolInterfaces/IMuonSegmentMaker.h"
-#include "MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinder.h"
 #include "MuonSegmentMakerToolInterfaces/IMuonNSWSegmentFinderTool.h"
 #include "MuonSegmentMakerToolInterfaces/IMuonLayerSegmentFinderTool.h"
 #include "MuonRecToolInterfaces/HoughDataPerSec.h"
diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinder.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinder.h
deleted file mode 100644
index f929463465d5..000000000000
--- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinder.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
-*/
-
-#ifndef MUON_IMUONCLUSTERSEGMENTFINDER_H
-#define MUON_IMUONCLUSTERSEGMENTFINDER_H
-
-#include <vector>
-
-#include "GaudiKernel/IAlgTool.h"
-#include "MuonPrepRawData/MuonPrepDataContainer.h"
-#include "MuonPrepRawData/RpcPrepDataCollection.h"
-#include "MuonPrepRawData/TgcPrepDataCollection.h"
-#include "MuonRIO_OnTrack/MuonClusterOnTrack.h"
-#include "TrkSegment/SegmentCollection.h"
-#include "TrkTruthData/PRD_MultiTruthCollection.h"
-
-namespace Muon {
-
-    class MuonSegment;
-
-    /** Interface for tools calculating hit count summaries for track */
-    class IMuonClusterSegmentFinder : virtual public IAlgTool {
-    public:
-        /** IAlgTool interface */
-        static const InterfaceID& interfaceID() {
-            static const InterfaceID IID_IMuonClusterSegmentFinder("Muon::IMuonClusterSegmentFinder", 1, 0);
-            return IID_IMuonClusterSegmentFinder;
-        }
-
-        virtual void getClusterSegments(const Muon::MdtPrepDataContainer* mdtPrdCont, const Muon::RpcPrepDataContainer* rpcPrdCont,
-                                        const Muon::TgcPrepDataContainer* tgcPrdCont, const PRD_MultiTruthCollection* tgcTruthColl,
-                                        const PRD_MultiTruthCollection* rpcTruthColl, Trk::SegmentCollection* segColl) const = 0;
-
-        virtual void getClusterSegments(const Muon::MdtPrepDataContainer* mdtPrdCont,
-                                        std::vector<const Muon::TgcPrepDataCollection*>* tgcCols,
-                                        std::vector<const Muon::RpcPrepDataCollection*>* rpcCols,
-                                        const PRD_MultiTruthCollection* tgcTruthColl, const PRD_MultiTruthCollection* rpcTruthColl,
-                                        Trk::SegmentCollection* segColl) const = 0;
-
-        /** @brief Find tgc + mdt segments for a given set of TGC hit collections */
-        virtual void findSegments(std::vector<const TgcPrepDataCollection*>& tgcCols, const Muon::MdtPrepDataContainer* mdtPrdCont,
-                                  Trk::SegmentCollection* segColl, const PRD_MultiTruthCollection* tgcTruthColl) const = 0;
-
-        /** @brief Find rpc + mdt segments for a given set of RPC hit collections */
-        virtual void findSegments(std::vector<const RpcPrepDataCollection*>& rpcCols, const Muon::MdtPrepDataContainer* mdtPrdCont,
-                                  Trk::SegmentCollection* segColl, const PRD_MultiTruthCollection* rpcTruthColl) const = 0;
-
-        virtual ~IMuonClusterSegmentFinder() = default;
-    };
-
-}  // namespace Muon
-
-#endif  // IMuonClusterSegmentFinder_H
diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonPatternSegmentMaker.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonPatternSegmentMaker.h
deleted file mode 100644
index 6d501440702e..000000000000
--- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMakerToolInterfaces/MuonSegmentMakerToolInterfaces/IMuonPatternSegmentMaker.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
-*/
-
-#ifndef MUONSEGMENTMAKETOOLINTERFACES_MUON_IMUONPATTERNSEGMENTMAKER_H
-#define MUONSEGMENTMAKETOOLINTERFACES_MUON_IMUONPATTERNSEGMENTMAKER_H
-
-#include <vector>
-
-#include "GaudiKernel/IAlgTool.h"
-#include "MuonEDM_AssociationObjects/MuonSegmentCombPatternCombAssociationMap.h"
-#include "MuonPattern/MuonPatternCombinationCollection.h"
-#include "MuonPrepRawData/RpcPrepDataCollection.h"
-#include "MuonPrepRawData/TgcPrepDataCollection.h"
-#include "MuonSegment/MuonSegmentCombinationCollection.h"
-#include "TrkSegment/SegmentCollection.h"
-
-namespace Trk {
-    class Track;
-}
-
-namespace Muon {
-
-    /** @brief The IMuonSegmentMaker is a pure virtual interface for tools to find tracks starting from MuonSegmentCombinations  */
-    class IMuonPatternSegmentMaker : virtual public IAlgTool {
-    public:
-        /** access to tool interface */
-        static const InterfaceID& interfaceID() {
-            static const InterfaceID IID_IMuonPatternSegmentMaker("Muon::IMuonPatternSegmentMaker", 1, 0);
-            return IID_IMuonPatternSegmentMaker;
-        }
-
-        /** @brief find tracks starting from a MuonSegmentCombination
-            @param combi a reference to a MuonSegmentCombination
-            @return a pointer to a vector of tracks, the ownership of the tracks is passed to the client calling the tool.
-        */
-        virtual void find(const MuonPatternCombination& pattern, const std::vector<const RpcPrepDataCollection*>& rpcCols,
-                          const std::vector<const TgcPrepDataCollection*>& tgcCols, Trk::SegmentCollection* segColl) const = 0;
-
-        /** @brief find tracks starting from a MuonSegmentCombinationCollection
-            @param combiCol a reference to a MuonSegmentCombinationCollection
-            @return a pointer to a vector of tracks, the ownership of the tracks is passed to the client calling the tool.
-        */
-        virtual std::unique_ptr<MuonSegmentCombinationCollection> find(const MuonPatternCombinationCollection* patterns,
-                                                                       MuonSegmentCombPatternCombAssociationMap* segPattMap,
-                                                                       const std::vector<const RpcPrepDataCollection*>& rpcCols,
-                                                                       const std::vector<const TgcPrepDataCollection*>& tgcCols) const = 0;
-
-        virtual ~IMuonPatternSegmentMaker() = default;
-    };
-
-}  // namespace Muon
-
-#endif
diff --git a/MuonSpectrometer/MuonValidation/MuonRecValidation/MuonTrackPerformance/src/MuonRecoValidationTool.cxx b/MuonSpectrometer/MuonValidation/MuonRecValidation/MuonTrackPerformance/src/MuonRecoValidationTool.cxx
index 43025b36be56..744ed26a6a73 100644
--- a/MuonSpectrometer/MuonValidation/MuonRecValidation/MuonTrackPerformance/src/MuonRecoValidationTool.cxx
+++ b/MuonSpectrometer/MuonValidation/MuonRecValidation/MuonTrackPerformance/src/MuonRecoValidationTool.cxx
@@ -421,7 +421,7 @@ namespace Muon {
         for (; hit != hit_end; ++hit) {
             // treat the case that the hit is a composite TGC hit
             if ((*hit)->tgc) {
-                for (const auto& prd : (*hit)->tgc->etaCluster.hitList) ids.insert(prd->identify());
+                for (const auto& prd : (*hit)->tgc->etaCluster) ids.insert(prd->identify());
             } else if ((*hit)->prd) {
                 ids.insert((*hit)->prd->identify());
             }
diff --git a/Reconstruction/MuonIdentification/MuonCombinedAlgs/src/MuonInDetToMuonSystemExtensionAlg.cxx b/Reconstruction/MuonIdentification/MuonCombinedAlgs/src/MuonInDetToMuonSystemExtensionAlg.cxx
index 6305c1390cd7..8c8700170015 100644
--- a/Reconstruction/MuonIdentification/MuonCombinedAlgs/src/MuonInDetToMuonSystemExtensionAlg.cxx
+++ b/Reconstruction/MuonIdentification/MuonCombinedAlgs/src/MuonInDetToMuonSystemExtensionAlg.cxx
@@ -15,7 +15,7 @@ namespace {
 
     inline const Trk::PrepRawData* prepData(const std::shared_ptr<MuonHough::Hit>& hit) {
         if (hit->prd) return hit->prd;
-        if (hit->tgc) return hit->tgc->phiCluster.hitList.front();
+        if (hit->tgc) return hit->tgc->phiCluster.front();
         return nullptr;
     }
     /// Helper struct to store the number of hits per chamber
diff --git a/Reconstruction/MuonIdentification/MuonCombinedTrackFindingTools/src/MuonStauRecoTool.cxx b/Reconstruction/MuonIdentification/MuonCombinedTrackFindingTools/src/MuonStauRecoTool.cxx
index b75a8d4e9b4d..da57e59e266b 100644
--- a/Reconstruction/MuonIdentification/MuonCombinedTrackFindingTools/src/MuonStauRecoTool.cxx
+++ b/Reconstruction/MuonIdentification/MuonCombinedTrackFindingTools/src/MuonStauRecoTool.cxx
@@ -1161,7 +1161,7 @@ namespace MuonCombined {
             ATH_MSG_DEBUG("hit x,y_min,y_max,w = " << (*hit)->x << "," << (*hit)->ymin << "," << (*hit)->ymax << "," << (*hit)->w);
             // treat the case that the hit is a composite TGC hit
             if ((*hit)->tgc) {
-                for (const auto& prd : (*hit)->tgc->etaCluster.hitList) handleCluster(*prd, clusters);
+                for (const auto& prd : (*hit)->tgc->etaCluster) handleCluster(*prd, clusters);
             } else if ((*hit)->prd) {
                 Identifier id = (*hit)->prd->identify();
                 if (m_idHelperSvc->isMdt(id))
@@ -1359,10 +1359,10 @@ namespace MuonCombined {
             const MuonHough::MuonPhiLayerHough::Maximum& maximum = **pit;
             for (const std::shared_ptr<MuonHough::PhiHit>& hit : maximum.hits) {
                 // treat the case that the hit is a composite TGC hit
-                if (hit->tgc && !hit->tgc->phiCluster.hitList.empty()) {
-                    Identifier id = hit->tgc->phiCluster.hitList.front()->identify();
+                if (hit->tgc) {
+                    Identifier id = hit->tgc->phiCluster.front()->identify();
                     if (m_idHelperSvc->layerIndex(id) != intersection.layerSurface.layerIndex) continue;
-                    for (const Muon::MuonCluster* prd : hit->tgc->phiCluster.hitList) handleCluster(*prd, phiClusterOnTracks);
+                    for (const Muon::MuonCluster* prd : hit->tgc->phiCluster) handleCluster(*prd, phiClusterOnTracks);
                 } else if (hit->prd && !(hit->prd->type(Trk::PrepRawDataType::sTgcPrepData) || hit->prd->type(Trk::PrepRawDataType::MMPrepData))) {
                     const Identifier id = hit->prd->identify();
                     if (m_idHelperSvc->layerIndex(id) != intersection.layerSurface.layerIndex) continue;
-- 
GitLab