From aa5ea6c52466e17cc4df30ac3722e04da937bd4d Mon Sep 17 00:00:00 2001
From: Goetz Gaycken <goetz.gaycken@cern.ch>
Date: Fri, 21 Aug 2020 10:01:07 +0200
Subject: [PATCH 1/2] Remove unused pixel covariance correction for collimated
 tracks.

- remove the pixel covariance correction,
- remove dRmap based identification of collimated tracks,
- remove creation of dRmap.

All of the above is unused and was not properly migrated to athenaMT.
---
 .../InDetConfig/python/InDetConfigFlags.py    |   1 -
 .../python/InDetJobProperties.py              |  16 --
 .../InDetRecExample/python/TrackingCommon.py  |   2 -
 .../share/ConfiguredNewTrackingSiPattern.py   |   2 -
 .../share/InDetRecLoadTools.py                |   9 -
 .../python/InDetTrigConfigRecLoadTools.py     |   5 -
 .../SiClusterOnTrackTool/CMakeLists.txt       |   3 +-
 .../PixelClusterOnTrackTool.h                 |  53 +----
 .../src/PixelClusterOnTrackTool.cxx           | 217 ------------------
 .../TrkAmbiguityProcessor/CMakeLists.txt      |  19 +-
 .../TrkAmbiguityProcessor/dRMap.h             |  30 ---
 ...enseEnvironmentsAmbiguityProcessorTool.cxx | 105 ---------
 .../DenseEnvironmentsAmbiguityProcessorTool.h |   3 -
 13 files changed, 20 insertions(+), 445 deletions(-)
 delete mode 100644 Tracking/TrkTools/TrkAmbiguityProcessor/TrkAmbiguityProcessor/dRMap.h

diff --git a/InnerDetector/InDetConfig/python/InDetConfigFlags.py b/InnerDetector/InDetConfig/python/InDetConfigFlags.py
index fc36ba07c72b..35fa2e606eb6 100644
--- a/InnerDetector/InDetConfig/python/InDetConfigFlags.py
+++ b/InnerDetector/InDetConfig/python/InDetConfigFlags.py
@@ -165,7 +165,6 @@ def createInDetConfigFlags():
   icf.addFlag("InDet.doTIDE_Ambi", True) # Switch for running TIDE Ambi 
   icf.addFlag("InDet.doRefitInvalidCov", False) # Try Kalman fitter if the track fit in the ambiguity processor produces non positive definitematrices.
   icf.addFlag("InDet.doRejectInvalidCov", False) # Reject all tracks which have a non positive definite covariance matrix after the refit.
-  icf.addFlag("InDet.doTIDE_RescalePixelCovariances", False) # Switch for running TIDE pixel cluster covariance rescaling 
   icf.addFlag("InDet.doSSSfilter", True) # Switch for running SSS filter
   icf.addFlag("InDet.pT_SSScut", -1) # Pt cut for SSS filter [GeV]
   icf.addFlag("InDet.ForceCoraCool", False) # Use old (non CoolVectorPayload) SCT Conditions 
diff --git a/InnerDetector/InDetExample/InDetRecExample/python/InDetJobProperties.py b/InnerDetector/InDetExample/InDetRecExample/python/InDetJobProperties.py
index ecd768873b24..160c7f3fcfe4 100644
--- a/InnerDetector/InDetExample/InDetRecExample/python/InDetJobProperties.py
+++ b/InnerDetector/InDetExample/InDetRecExample/python/InDetJobProperties.py
@@ -1085,12 +1085,6 @@ class doTIDE_Ambi(InDetFlagsJobProperty):
   allowedTypes = ['bool']
   StoredValue  = True
   
-class doTIDE_RescalePixelCovariances(InDetFlagsJobProperty):
-  """ Switch for running TIDE pixel cluster covariance rescaling """
-  statusOn     = True
-  allowedTypes = ['bool']
-  StoredValue  = False
-
 class doRefitInvalidCov(InDetFlagsJobProperty):
   """ Try Kalman fitter if the track fit in the ambiguity processor produces non positive definitematrices."""
   statusOn     = True
@@ -1357,7 +1351,6 @@ class InDetJobProperties(JobPropertyContainer):
        self.checkThenSet(self.doTrackSegmentsTRT     , False)
        self.checkThenSet(self.doSlimming             , False)
        self.checkThenSet(self.doSGDeletion           , True )
-       self.checkThenSet(self.doTIDE_RescalePixelCovariances, False)
        # TEMPORARY FIX TO STOP SEG FAULT
        self.checkThenSet(self.doPixelClusterSplitting, False)
        self.checkThenSet(self.doTIDE_Ambi, False)
@@ -1654,7 +1647,6 @@ class InDetJobProperties(JobPropertyContainer):
         self.checkThenSet(self.doTrackSegmentsTRT  , True )
         self.checkThenSet(self.doPixelClusterSplitting, False)
         self.checkThenSet(self.doTIDE_Ambi, False)
-        self.checkThenSet(self.doTIDE_RescalePixelCovariances, False)
         self.checkThenSet(self.doTrackSegmentsDisappearing, False)
 
     if rec.doExpressProcessing() :
@@ -1715,11 +1707,6 @@ class InDetJobProperties(JobPropertyContainer):
       self.doSpacePointFormation = self.preProcessing() and self.doSpacePointFormation() and (DetFlags.haveRIO.pixel_on() or DetFlags.haveRIO.SCT_on())
       self.doPRDFormation        = self.preProcessing() and self.doPRDFormation()        and (DetFlags.makeRIO.pixel_on() or DetFlags.makeRIO.SCT_on() or DetFlags.makeRIO.TRT_on())
       
-      # --------------------------------------------------------------------
-      # ---- TIDE Pixel cluster covariance rescaling
-      # --------------------------------------------------------------------
-      self.doTIDE_RescalePixelCovariances = self.doTIDE_RescalePixelCovariances() and self.doPixelClusterSplitting() and self.pixelClusterSplittingType() == 'NeuralNet' and self.doTIDE_Ambi()
-
       # --------------------------------------------------------------------
       # --- 1st iteration, inside out tracking
       # --------------------------------------------------------------------
@@ -2231,8 +2218,6 @@ class InDetJobProperties(JobPropertyContainer):
             print('*   split prob1 cut:                     ', self.pixelClusterSplitProb1())
             print('*   split prob2 cut:                     ', self.pixelClusterSplitProb2())
             print('*   Min split   pt: [MeV]                ', self.pixelClusterSplitMinPt())
-            if self.doTIDE_RescalePixelCovariances():
-                print('*   rescaling pixel cluster covariances: ', self.doTIDE_RescalePixelCovariances())
           else:
             print('* - run new Pixel clustering with splitting using analog information')
             print('*   splitting technique: ', self.pixelClusterSplittingType())
@@ -2764,7 +2749,6 @@ _list_InDetJobProperties = [Enabled,
                             doTIDE_Ambi,
                             doRefitInvalidCov,
                             doRejectInvalidCov,
-                            doTIDE_RescalePixelCovariances,
                             doSSSfilter,
                             pT_SSScut,
                             ForceCoraCool,
diff --git a/InnerDetector/InDetExample/InDetRecExample/python/TrackingCommon.py b/InnerDetector/InDetExample/InDetRecExample/python/TrackingCommon.py
index 84f5ebc4b79a..088720d63265 100644
--- a/InnerDetector/InDetExample/InDetRecExample/python/TrackingCommon.py
+++ b/InnerDetector/InDetExample/InDetRecExample/python/TrackingCommon.py
@@ -353,8 +353,6 @@ def getInDetPixelClusterOnTrackToolNNSplitting(name='InDetPixelClusterOnTrackToo
         if 'NnClusterizationFactory' not in kwargs :
             kwargs = setDefaults(kwargs, NnClusterizationFactory  = getNnClusterizationFactory())
 
-        if InDetFlags.doTIDE_RescalePixelCovariances() :
-            kwargs = setDefaults(kwargs, applydRcorrection = True)
     return getInDetPixelClusterOnTrackToolBase(name=name, **kwargs)
 
 def getInDetPixelClusterOnTrackTool(name='InDetPixelClusterOnTrackTool', **kwargs) :
diff --git a/InnerDetector/InDetExample/InDetRecExample/share/ConfiguredNewTrackingSiPattern.py b/InnerDetector/InDetExample/InDetRecExample/share/ConfiguredNewTrackingSiPattern.py
index 74d387eb1801..1efc7806b04d 100644
--- a/InnerDetector/InDetExample/InDetRecExample/share/ConfiguredNewTrackingSiPattern.py
+++ b/InnerDetector/InDetExample/InDetRecExample/share/ConfiguredNewTrackingSiPattern.py
@@ -553,8 +553,6 @@ class  ConfiguredNewTrackingSiPattern:
               elif NewTrackingCuts.extension() == "Disappearing":
                  InDetAmbiguityScoreProcessor.SplitClusterMap_old  = InDetKeys.SplitClusterAmbiguityMap()
               InDetAmbiguityScoreProcessor.SplitClusterMap_new  = InDetKeys.SplitClusterAmbiguityMap()+NewTrackingCuts.extension()
-           if InDetFlags.doTIDE_RescalePixelCovariances() :
-            InDetAmbiguityProcessor.applydRcorrection = True
 
          if NewTrackingCuts.mode() == "Pixel" or NewTrackingCuts.mode() == "DBM":
             InDetAmbiguityProcessor.SuppressHoleSearch = True
diff --git a/InnerDetector/InDetExample/InDetRecExample/share/InDetRecLoadTools.py b/InnerDetector/InDetExample/InDetRecExample/share/InDetRecLoadTools.py
index 5b6012e177ae..800bf2d703a4 100755
--- a/InnerDetector/InDetExample/InDetRecExample/share/InDetRecLoadTools.py
+++ b/InnerDetector/InDetExample/InDetRecExample/share/InDetRecLoadTools.py
@@ -82,15 +82,6 @@ if InDetFlags.doPixelClusterSplitting() and not InDetFlags.doSLHC():
 
         ToolSvc += NnClusterizationFactory
 
-        # special setup for DVRetracking mode
-        # if InDetFlags.doDVRetracking() :
-           # COOL binding
-        from IOVDbSvc.CondDB import conddb
-        if InDetFlags.doTIDE_RescalePixelCovariances() :
-            if not conddb.folderRequested('/PIXEL/PixelClustering/PixelCovCorr'):
-                # COOL binding
-                conddb.addFolder("PIXEL_OFL","/PIXEL/PixelClustering/PixelCovCorr")
-
         if (InDetFlags.doPrintConfigurables()):
             printfunc (NnClusterizationFactory)
 elif InDetFlags.doPixelClusterSplitting():
diff --git a/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigConfigRecLoadTools.py b/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigConfigRecLoadTools.py
index cedfd5bd8115..8cdd29a1ce71 100755
--- a/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigConfigRecLoadTools.py
+++ b/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigConfigRecLoadTools.py
@@ -112,11 +112,6 @@ if InDetTrigFlags.loadRotCreator():
                                                                       NnCollectionWithTrackReadKey = 'PixelClusterNNWithTrack')
 
     ToolSvc += TrigNnClusterizationFactory
-    
-    from IOVDbSvc.CondDB import conddb
-    if InDetTrigFlags.doTIDE_RescalePixelCovariances() :
-      if not conddb.folderRequested('/PIXEL/PixelClustering/PixelCovCorr'):
-        conddb.addFolder("PIXEL_OFL","/PIXEL/PixelClustering/PixelCovCorr")
 
   else:
     TrigNnClusterizationFactory = None
diff --git a/InnerDetector/InDetRecTools/SiClusterOnTrackTool/CMakeLists.txt b/InnerDetector/InDetRecTools/SiClusterOnTrackTool/CMakeLists.txt
index c8ff0c79709f..961ff0106c74 100644
--- a/InnerDetector/InDetRecTools/SiClusterOnTrackTool/CMakeLists.txt
+++ b/InnerDetector/InDetRecTools/SiClusterOnTrackTool/CMakeLists.txt
@@ -17,7 +17,6 @@ atlas_depends_on_subdirs( PUBLIC
                           InnerDetector/InDetRecEvent/InDetRIO_OnTrack
                           Tracking/TrkEvent/TrkParameters
                           Tracking/TrkTools/TrkToolInterfaces
-                          Tracking/TrkTools/TrkAmbiguityProcessor
                           Tracking/TrkEvent/TrkRIO_OnTrack
                           Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils
                           Control/StoreGate
@@ -40,7 +39,7 @@ atlas_add_component( SiClusterOnTrackTool
                      src/*.cxx
                      src/components/*.cxx
                      INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS}
-                     LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthenaPoolUtilities GeoPrimitives GaudiKernel InDetPrepRawData InDetRIO_OnTrack TrkParameters TrkToolInterfaces TrkAmbiguityProcessorLib  StoreGateLib SGtests EventPrimitives InDetIdentifier InDetReadoutGeometry PixelReadoutGeometry SiClusterizationToolLib TrkSurfaces TrkRIO_OnTrack PixelConditionsData TrkNeuralNetworkUtilsLib )
+                     LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthenaPoolUtilities GeoPrimitives GaudiKernel InDetPrepRawData InDetRIO_OnTrack TrkParameters TrkToolInterfaces StoreGateLib SGtests EventPrimitives InDetIdentifier InDetReadoutGeometry PixelReadoutGeometry SiClusterizationToolLib TrkSurfaces TrkRIO_OnTrack PixelConditionsData TrkNeuralNetworkUtilsLib TrkEventUtils)
 
 # Install files from the package:
 atlas_install_headers( SiClusterOnTrackTool )
diff --git a/InnerDetector/InDetRecTools/SiClusterOnTrackTool/SiClusterOnTrackTool/PixelClusterOnTrackTool.h b/InnerDetector/InDetRecTools/SiClusterOnTrackTool/SiClusterOnTrackTool/PixelClusterOnTrackTool.h
index e60bd26b65c9..b583ff3dea54 100755
--- a/InnerDetector/InDetRecTools/SiClusterOnTrackTool/SiClusterOnTrackTool/PixelClusterOnTrackTool.h
+++ b/InnerDetector/InDetRecTools/SiClusterOnTrackTool/SiClusterOnTrackTool/PixelClusterOnTrackTool.h
@@ -15,7 +15,6 @@
 #include "InDetPrepRawData/PixelGangedClusterAmbiguities.h"
 #include "TrkParameters/TrackParameters.h"
 #include "GeoPrimitives/GeoPrimitives.h"
-#include "TrkAmbiguityProcessor/dRMap.h"
 
 #include "Identifier/Identifier.h"
 #include "InDetIdentifier/PixelID.h"
@@ -73,12 +72,6 @@ public:
   virtual StatusCode initialize() override;
   //! AlgTool termination
   virtual StatusCode finalize  () override;
-  
-  
- 
-  void correctBow(const Identifier&, Amg::Vector2D& locpos, const double tanphi, const double taneta) const;
-
-  double splineIBLPullX(float x, int layer) const;
 
   /** @brief produces a PixelClusterOnTrack (object factory!).
 
@@ -89,8 +82,15 @@ public:
   virtual const InDet::PixelClusterOnTrack* correct(const Trk::PrepRawData&,
                                                     const Trk::TrackParameters&) const override;
 
-  virtual const InDet::PixelClusterOnTrack* correctDefault(const Trk::PrepRawData&,
-                                                           const Trk::TrackParameters&) const;
+  ///////////////////////////////////////////////////////////////////
+  // Private methods:
+  ///////////////////////////////////////////////////////////////////
+
+protected:
+  void correctBow(const Identifier&, Amg::Vector2D& locpos, const double tanphi, const double taneta) const;
+
+  const InDet::PixelClusterOnTrack* correctDefault(const Trk::PrepRawData&,
+                                                   const Trk::TrackParameters&) const;
 
   virtual const InDet::PixelClusterOnTrack* correctNN(const Trk::PrepRawData&, const Trk::TrackParameters&) const;
   virtual bool getErrorsDefaultAmbi( const InDet::PixelCluster*, const Trk::TrackParameters&,
@@ -110,15 +110,6 @@ public:
   
  private:
 
-  /** @brief parametrizes the pixel cluster position error as a function of 
-      the track angle alpha and the cluster width (number of rows) deltax */
-  //  double getBarrelPhiError(double& alpha, int& deltax) const;
-  //  double getBarrelEtaError(double eta, int deltax, int deltay) const;
-  // double getEndcapPhiError(int etasize, int phisize) const;
-  // double getEndcapEtaError(int etasize, int phisize) const;
-  
-  void FillFromDataBase() const;
-
   ///////////////////////////////////////////////////////////////////
   // Private data:
   ///////////////////////////////////////////////////////////////////
@@ -134,17 +125,6 @@ public:
   SG::ReadCondHandleKey<RIO_OnTrackErrorScaling> m_pixelErrorScalingKey
     {this,"PixelErrorScalingKey", "/Indet/TrkErrorScalingPixel", "Key for pixel error scaling conditions data."};
 
-  /* ME: Test histos have nothing to do with production code, use a flag
-    IHistogram1D* m_h_Resx;
-    IHistogram1D* m_h_Resy;
-    IHistogram1D* m_h_Locx;
-    IHistogram1D* m_h_Locy;
-    IHistogram1D* m_h_PhiTrack;
-    IHistogram1D* m_h_ThetaTrack;
-    IHistogram1D* m_h_Rad; 
-    IHistogram1D* m_h_Slope;
-  */
-
   //! toolhandle for central error scaling
   //! flag storing if errors need scaling or should be kept nominal
   bool                               m_disableDistortions;
@@ -172,7 +152,6 @@ public:
   /** Enable NN based calibration (do only if NN calibration is applied) **/
   bool                              m_applyNNcorrection{false};
   BooleanProperty                   m_applyNNcorrectionProperty{this, "applyNNcorrection", false};
-  bool                              m_applydRcorrection;
   bool                              m_NNIBLcorrection;
   bool                              m_IBLAbsent;
   
@@ -180,22 +159,12 @@ public:
   ToolHandle<NnClusterizationFactory>                   m_NnClusterizationFactory;
   ServiceHandle<IIBLParameterSvc>                       m_IBLParameterSvc;
 
-
-  SG::ReadHandleKey<InDet::DRMap>                      m_dRMap;      //!< the actual dR map         
-  std::string                                          m_dRMapName;
-  
   bool                                                  m_doNotRecalibrateNN;
   bool                                                  m_noNNandBroadErrors;
        /** Enable different treatment of  cluster errors based on NN information (do only if TIDE ambi is run) **/
   bool                      m_usingTIDE_Ambi;
-  SG::ReadHandleKey<InDet::PixelGangedClusterAmbiguities>    m_splitClusterMapKey; 
-  mutable std::vector< std::vector<float> > m_fX ATLAS_THREAD_SAFE; // Guarded by m_mutex
-  mutable std::vector< std::vector<float> > m_fY ATLAS_THREAD_SAFE; // Guarded by m_mutex
-  mutable std::vector< std::vector<float> > m_fB ATLAS_THREAD_SAFE; // Guarded by m_mutex
-  mutable std::vector< std::vector<float> > m_fC ATLAS_THREAD_SAFE; // Guarded by m_mutex
-  mutable std::vector< std::vector<float> > m_fD ATLAS_THREAD_SAFE; // Guarded by m_mutex
-  mutable std::mutex m_mutex;
-  
+  SG::ReadHandleKey<InDet::PixelGangedClusterAmbiguities>    m_splitClusterMapKey;
+
   //moved from static to member variable
   static constexpr int s_nbinphi=9;
   static constexpr int s_nbineta=6;
diff --git a/InnerDetector/InDetRecTools/SiClusterOnTrackTool/src/PixelClusterOnTrackTool.cxx b/InnerDetector/InDetRecTools/SiClusterOnTrackTool/src/PixelClusterOnTrackTool.cxx
index 3d830b65b6e1..1339a792da2d 100755
--- a/InnerDetector/InDetRecTools/SiClusterOnTrackTool/src/PixelClusterOnTrackTool.cxx
+++ b/InnerDetector/InDetRecTools/SiClusterOnTrackTool/src/PixelClusterOnTrackTool.cxx
@@ -60,13 +60,10 @@ InDet::PixelClusterOnTrackTool::PixelClusterOnTrackTool
   m_disableDistortions(false),
   m_rel13like(false),
   m_pixelid(nullptr),
-  m_applydRcorrection(false),
   m_NNIBLcorrection(false),
   m_IBLAbsent(true),
   m_NnClusterizationFactory("InDet::NnClusterizationFactory/NnClusterizationFactory", this),
   m_IBLParameterSvc("IBLParameterSvc", n),
-  m_dRMap(""),
-  m_dRMapName("dRMap"),
   m_doNotRecalibrateNN(false),
   m_noNNandBroadErrors(false),
   m_usingTIDE_Ambi(false),
@@ -76,11 +73,9 @@ InDet::PixelClusterOnTrackTool::PixelClusterOnTrackTool
   declareProperty("PositionStrategy", m_positionStrategy = 1, "Which calibration of cluster positions");
   declareProperty("DisableDistortions", m_disableDistortions, "Disable simulation of module distortions");
   declareProperty("Release13like", m_rel13like, "Activate release-13 like settigs");
-  declareProperty("applydRcorrection", m_applydRcorrection);
   declareProperty("NNIBLcorrection", m_NNIBLcorrection);
   declareProperty("NnClusterizationFactory", m_NnClusterizationFactory);
   declareProperty("SplitClusterAmbiguityMap", m_splitClusterMapKey);//Remove Later
-  declareProperty("dRMapName", m_dRMapName);  //This is a string to prevent the scheduler seeing trkAmbSolver as both creating and requiring the map
   declareProperty("doNotRecalibrateNN", m_doNotRecalibrateNN);
   declareProperty("m_noNNandBroadErrors", m_noNNandBroadErrors);
   declareProperty("RunningTIDE_Ambi", m_usingTIDE_Ambi);
@@ -133,9 +128,6 @@ InDet::PixelClusterOnTrackTool::initialize() {
 
   ATH_CHECK (detStore()->retrieve(m_pixelid, "PixelID"));
 
-  m_dRMap = SG::ReadHandleKey<InDet::DRMap>(m_dRMapName);
-  ATH_CHECK( m_dRMap.initialize() );
-
   m_applyNNcorrection &= !m_splitClusterMapKey.key().empty();
   ATH_CHECK(m_splitClusterMapKey.initialize(m_applyNNcorrection));
   ATH_CHECK(m_NnClusterizationFactory.retrieve( DisableTool{!m_applyNNcorrection} ));
@@ -169,70 +161,6 @@ InDet::PixelClusterOnTrackTool::finalize() {
 return StatusCode::SUCCESS;
 }
 
-void
-InDet::PixelClusterOnTrackTool::FillFromDataBase() const{
-    if (m_fX.empty()) {
-      const CondAttrListCollection *atrlistcol = nullptr;
-      if (StatusCode::SUCCESS == detStore()->retrieve(atrlistcol, "/PIXEL/PixelClustering/PixelCovCorr")) {
-        // loop over objects in collection
-        for (CondAttrListCollection::const_iterator citr = atrlistcol->begin(); citr != atrlistcol->end(); ++citr) {
-          std::vector<float> fx, fy, fb, fc, fd;
-          const coral::AttributeList &atrlist = citr->second;
-
-          fx.push_back(atrlist["fX1"].data<float>());
-          fx.push_back(atrlist["fX2"].data<float>());
-          fx.push_back(atrlist["fX3"].data<float>());
-          fx.push_back(atrlist["fX4"].data<float>());
-          fx.push_back(atrlist["fX5"].data<float>());
-          fx.push_back(atrlist["fX6"].data<float>());
-          fx.push_back(atrlist["fX7"].data<float>());
-          m_fX.emplace_back(std::move(fx));
-
-          fy.push_back(atrlist["fY1"].data<float>());
-          fy.push_back(atrlist["fY2"].data<float>());
-          fy.push_back(atrlist["fY3"].data<float>());
-          fy.push_back(atrlist["fY4"].data<float>());
-          fy.push_back(atrlist["fY5"].data<float>());
-          fy.push_back(atrlist["fY6"].data<float>());
-          fy.push_back(atrlist["fY7"].data<float>());
-          m_fY.emplace_back(std::move(fy));
-
-          fb.push_back(atrlist["fB1"].data<float>());
-          fb.push_back(atrlist["fB2"].data<float>());
-          fb.push_back(atrlist["fB3"].data<float>());
-          fb.push_back(atrlist["fB4"].data<float>());
-          fb.push_back(atrlist["fB5"].data<float>());
-          fb.push_back(atrlist["fB6"].data<float>());
-          fb.push_back(atrlist["fB7"].data<float>());
-          m_fB.emplace_back(std::move(fb));
-
-          fc.push_back(atrlist["fC1"].data<float>());
-          fc.push_back(atrlist["fC2"].data<float>());
-          fc.push_back(atrlist["fC3"].data<float>());
-          fc.push_back(atrlist["fC4"].data<float>());
-          fc.push_back(atrlist["fC5"].data<float>());
-          fc.push_back(atrlist["fC6"].data<float>());
-          fc.push_back(atrlist["fC7"].data<float>());
-          m_fC.emplace_back(std::move(fc));
-
-          fd.push_back(atrlist["fD1"].data<float>());
-          fd.push_back(atrlist["fD2"].data<float>());
-          fd.push_back(atrlist["fD3"].data<float>());
-          fd.push_back(atrlist["fD4"].data<float>());
-          fd.push_back(atrlist["fD5"].data<float>());
-          fd.push_back(atrlist["fD6"].data<float>());
-          fd.push_back(atrlist["fD7"].data<float>());
-          m_fD.emplace_back(std::move(fd));
-        }
-      }else {
-        ATH_MSG_ERROR( "Cannot find covariance corrections for key "
-                        << "/PIXEL/PixelClustering/PixelCovCorr" << " - no correction " );
-        
-      }
-    }
-}
-
-
 ///////////////////////////////////////////////////////////////////
 // Trk::SiClusterOnTrack  production
 ///////////////////////////////////////////////////////////////////
@@ -954,102 +882,11 @@ InDet::PixelClusterOnTrackTool::getErrorsTIDE_Ambi(const InDet::PixelCluster *pi
     return false;
   }
 
-  bool correctdR = false;
-  
-  std::array<float, 3> correctiondR = {{0., 0., 0.}};
-  
-  if(m_applydRcorrection){
-    SG::ReadHandle<InDet::DRMap> mapHandle(m_dRMap);
-    if(!mapHandle.isValid()){
-       ATH_MSG_ERROR("Error retreving " << m_dRMap.key());
-       return false;
-    }
-  
-    if(!mapHandle->empty() && pixelPrepCluster->isSplit() ){
-
-    const InDetDD::SiDetectorElement *det = pixelPrepCluster->detectorElement();
-
-    if (det->isBarrel()) {
-      int pixelLayer = m_pixelid->layer_disk(det->identify());
-
-      float correctiondRX = 1.0; // correction factor to be applied to covariance(!)
-      float correctiondRZ = 1.0; // correction factor to be applied to covariance(!)
-
-      const InDetDD::PixelModuleDesign *design(dynamic_cast<const InDetDD::PixelModuleDesign *>(&det->design()));
-      if (! design){
-        ATH_MSG_WARNING("Design cannot be cast to a pixel design");
-        return false;
-      }
-      const float pitchX = design->phiPitch();
-      const float pitchZ = design->etaPitch();
-
-      ATH_MSG_DEBUG("PixelClusterOnTrackTool: Trying to apply dR correction for pixelLayer " << pixelLayer);
-
-      InDet::DRMap::const_iterator it = mapHandle->find(pixelPrepCluster);
-      if (it != mapHandle->end()) {
-        correctdR = true;
-        float mindX = it->second.first;
-        float mindZ = it->second.second;
-        float mindXOverPitch = mindX / pitchX;
-        float mindZOverPitch = mindZ / pitchZ;
-
-        float dR = std::sqrt(mindX * mindX + mindZ * mindZ);
-
-        ATH_MSG_DEBUG(" ---- Min dX ---- " << mindX << " mindZ " << mindZ);
-
-        if (dR > 0. && dR < 2.0) {
-          correctiondRX = splineIBLPullX(mindXOverPitch, pixelLayer);
-          correctiondRZ = splineIBLPullX(mindZOverPitch, pixelLayer);
-
-          if (correctiondRX > 3.75) {
-            correctiondRX = 3.75;
-          }
-          if (correctiondRZ > 3.75) {
-            correctiondRZ = 3.75;
-          }
-        }else {
-          correctiondRX = 2.35;
-          correctiondRZ = 1.70;
-        }
-
-        ATH_MSG_DEBUG(
-          "PixelClusterOnTrackTool: Correction factor calculation for distX/pitch= " << mindXOverPitch << " -> " << correctiondRX << " distZ/pitch= " << mindZOverPitch << " -> " <<
-        correctiondRZ);
-      }else {
-        ATH_MSG_WARNING("Split Pixel cluster not found in dRmap! " << pixelPrepCluster);
-      }
-
-      ATH_MSG_DEBUG(
-        " ++++ Hit Error ++++ Layer " << pixelLayer << " Correction Flag " << m_applydRcorrection << " Split " << pixelPrepCluster->isSplit() << " Scaling " << correctiondRX << " " <<
-      correctiondRZ);
-
-      correctiondRX *= correctiondRX;
-      correctiondRZ *= correctiondRZ;
-
-      correctiondR[0] = correctiondRX * correctiondRX;
-      correctiondR[1] = correctiondRZ * correctiondRZ;
-      correctiondR[2] = correctiondRX * correctiondRZ;
-    }
-   }
-  }
   // AKM: now the not so nice part find the best match position option
   // Takes the error into account to scale the importance of the measurement
 
   if (numberOfSubclusters == 1) {
     finalposition = allLocalPositions[0];
-
-    if (correctdR) {
-      allErrorMatrix[0](0, 0) *= correctiondR[0];
-      allErrorMatrix[0](1, 1) *= correctiondR[1];
-      allErrorMatrix[0](0, 1) *= correctiondR[2];
-      allErrorMatrix[0](1, 0) *= correctiondR[2];
-      ATH_MSG_DEBUG(
-        " ++++ Hit Error ++++ " << numberOfSubclusters << " Split " << pixelPrepCluster->isSplit() << " Scaling " <<
-      std::sqrt(correctiondR[0]) << " " << std::sqrt(correctiondR[1]) << " Rescaled ErrX " << std::sqrt(allErrorMatrix[0](0,
-                                                                                                           0)) << " Rescaled ErrZ " <<
-      std::sqrt(allErrorMatrix[0](1, 1)));
-    }
-
     finalerrormatrix = allErrorMatrix[0];
     return true;
   }
@@ -1077,60 +914,6 @@ InDet::PixelClusterOnTrackTool::getErrorsTIDE_Ambi(const InDet::PixelCluster *pi
   }
 
   finalposition = allLocalPositions[index];
-
-  if (correctdR) {
-    allErrorMatrix[index](0, 0) *= correctiondR[0];
-    allErrorMatrix[index](1, 1) *= correctiondR[1];
-    allErrorMatrix[index](0, 1) *= correctiondR[2];
-    allErrorMatrix[index](1, 0) *= correctiondR[2];
-    ATH_MSG_DEBUG(
-      " ++++ Hit Error ++++ " << numberOfSubclusters << " Split " << pixelPrepCluster->isSplit() << " Scaling " <<
-    std::sqrt(correctiondR[0]) << " " << std::sqrt(correctiondR[1]) << " Rescaled ErrX " << std::sqrt(allErrorMatrix[index](0,
-                                                                                                             0)) << " Rescaled ErrZ " <<
-    std::sqrt(allErrorMatrix[index](1, 1)));
-  }
-
   finalerrormatrix = allErrorMatrix[index];
   return true;
 }
-
-double
-InDet::PixelClusterOnTrackTool::splineIBLPullX(float x, int layer) const {
-  std::lock_guard<std::mutex> lock(m_mutex);
-  FillFromDataBase();
-  const int fNp = m_fY[layer].size();
-  const int fKstep = 0;
-  const double fDelta = -1;
-  const auto result = std::minmax_element(std::begin(m_fX[layer]), std::end(m_fX[layer]));
-  const double fXmin = *(result.first);
-  const double fXmax = *(result.second);
-
-  int klow = 0;
-
-  if (x <= fXmin) {
-    klow = 0;
-  } else if (x >= fXmax) {
-    klow = fNp - 1;
-  } else {
-    if (fKstep) {
-      // Equidistant knots, use histogramming
-      klow = int((x - fXmin) / fDelta);
-      if (klow < fNp - 1) {
-        klow = fNp - 1;
-      }
-    } else {
-      int khig = fNp - 1, khalf;
-      // Non equidistant knots, binary search
-      while (khig - klow > 1) {
-        if (x > m_fX[layer][khalf = (klow + khig) / 2]) {
-          klow = khalf;
-        } else {
-          khig = khalf;
-        }
-      }
-    }
-  }
-  // Evaluate now
-  double dx = x - m_fX[layer][klow];
-  return(m_fY[layer][klow] + dx * (m_fB[layer][klow] + dx * (m_fC[layer][klow] + dx * m_fD[layer][klow])));
-}
diff --git a/Tracking/TrkTools/TrkAmbiguityProcessor/CMakeLists.txt b/Tracking/TrkTools/TrkAmbiguityProcessor/CMakeLists.txt
index 5e9256a66bdf..90334e12e5bb 100644
--- a/Tracking/TrkTools/TrkAmbiguityProcessor/CMakeLists.txt
+++ b/Tracking/TrkTools/TrkAmbiguityProcessor/CMakeLists.txt
@@ -27,23 +27,20 @@ atlas_depends_on_subdirs( PRIVATE
                           Tracking/TrkExtrapolation/TrkExInterfaces          )
 
 # External dependencies:
-find_package( CLHEP )
 find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread )
-find_package( HepPDT )
 
 # Component(s) in the package:
-atlas_add_library(   TrkAmbiguityProcessorLib
+atlas_add_component( TrkAmbiguityProcessor
                      src/DenseEnvironmentsAmbiguityProcessorTool.cxx
                      src/DenseEnvironmentsAmbiguityScoreProcessorTool.cxx
                      src/AmbiguityProcessorUtility.cxx
                      src/AmbiguityProcessorBase.cxx
-                     PUBLIC_HEADERS TrkAmbiguityProcessor
+                     src/SimpleAmbiguityProcessorTool.cxx
+                     src/TrackScoringTool.cxx
+                     src/TrackSelectionProcessorTool.cxx
+                     src/ToolVisitor.cxx
+                     src/RenounceToolInputsVisitor.cxx
+                     src/components/*.cxx
                      PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
-                     LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaKernel AthenaBaseComps AtlasDetDescr GaudiKernel InDetPrepRawData InDetRecToolInterfaces TrkDetElementBase TrkEventPrimitives TrkParameters TrkRIO_OnTrack TrkTrack TrkTrackSummary TrkTruthData TrkFitterInterfaces TrkToolInterfaces TrkValInterfaces TrkExInterfaces TrkCaloClusterROI)
-
-atlas_add_component( TrkAmbiguityProcessor
-                     src/SimpleAmbiguityProcessorTool.cxx  src/TrackScoringTool.cxx  src/TrackSelectionProcessorTool.cxx src/AmbiguityProcessorUtility.cxx src/AmbiguityProcessorBase.cxx
-                     src/components/*.cxx 
-                     INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${HEPPDT_INCLUDE_DIRS}
-                     LINK_LIBRARIES ${CLHEP_LIBRARIES} ${HEPPDT_LIBRARIES} TrkAmbiguityProcessorLib )
+                     LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaKernel AthenaBaseComps AtlasDetDescr GaudiKernel InDetPrepRawData InDetRecToolInterfaces  TrkDetElementBase TrkEventPrimitives TrkParameters TrkRIO_OnTrack TrkTrack TrkTrackSummary TrkTruthData TrkFitterInterfaces TrkToolInterfaces TrkValInterfaces TrkExInterfaces TrkCaloClusterROI)
 
diff --git a/Tracking/TrkTools/TrkAmbiguityProcessor/TrkAmbiguityProcessor/dRMap.h b/Tracking/TrkTools/TrkAmbiguityProcessor/TrkAmbiguityProcessor/dRMap.h
deleted file mode 100644
index 42a39dcd8593..000000000000
--- a/Tracking/TrkTools/TrkAmbiguityProcessor/TrkAmbiguityProcessor/dRMap.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
-*/
-
-/***************************************************************************
- CLASS_DEF for InDet dR map
- ------------------------------
- ATLAS Collaboration
- ***************************************************************************/
-
-#ifndef DRMAP_H
-#define DRMAP_H 1
-
-//<<<<<< INCLUDES                                                       >>>>>>
-#include "AthenaKernel/CLASS_DEF.h"
-#include <map>
-#include "InDetPrepRawData/PixelCluster.h"
-
-
-namespace InDet{
-
-  typedef std::map<const InDet::PixelCluster*, std::pair<float,float> > 
-  DRMap;
-}
-
-CLASS_DEF( InDet::DRMap , 193676466 , 1 )
-
-
-
-#endif // DRMAP_H
diff --git a/Tracking/TrkTools/TrkAmbiguityProcessor/src/DenseEnvironmentsAmbiguityProcessorTool.cxx b/Tracking/TrkTools/TrkAmbiguityProcessor/src/DenseEnvironmentsAmbiguityProcessorTool.cxx
index e6224bce632a..b132c2a2b687 100644
--- a/Tracking/TrkTools/TrkAmbiguityProcessor/src/DenseEnvironmentsAmbiguityProcessorTool.cxx
+++ b/Tracking/TrkTools/TrkAmbiguityProcessor/src/DenseEnvironmentsAmbiguityProcessorTool.cxx
@@ -115,10 +115,6 @@ Trk::DenseEnvironmentsAmbiguityProcessorTool::initialize(){
   //Initialise the ROI tool
   ATH_CHECK(m_inputHadClusterContainerName.initialize(m_useHClusSeed));
 
-  if(!m_dRMap.key().empty()){
-     ATH_CHECK(m_dRMap.initialize() );
-  }
-
   if (m_etaBounds.size() != Counter::nRegions) {
      ATH_MSG_FATAL("There must be exactly " << (Counter::nRegions) << " eta bounds but "
                    << m_etaBounds.size() << " are set." );
@@ -334,107 +330,6 @@ Trk::DenseEnvironmentsAmbiguityProcessorTool::refitPrds( const Trk::Track* track
 }
 
 
-//==================================================================================================
-
-void 
-Trk::DenseEnvironmentsAmbiguityProcessorTool::storeTrkDistanceMapdR( TrackCollection& tracks,
-                                          std::vector<Trk::Track*> &refittedTracks ){
-  ATH_MSG_VERBOSE ("Creating track Distance dR map");
-  SG::WriteHandle<InDet::DRMap> dRMapHandle (m_dRMap);
-  dRMapHandle = std::make_unique<InDet::DRMap>();
-  if ( !dRMapHandle.isValid() ){
-    ATH_MSG_WARNING("Could not record Distance dR map.");
-  } else {
-    ATH_MSG_VERBOSE("Distance dR map recorded as '" << m_dRMap.key() <<"'.");
-  }
-  constexpr double twoPi = 2.*M_PI;
-  for (const auto & track : tracks){
-      bool refit = false;
-      const DataVector<const TrackStateOnSurface>* tsosVec = track->trackStateOnSurfaces();  
-      if(!tsosVec){
-        ATH_MSG_WARNING("TSOS vector does not exist");
-        continue;   
-      }  
-      ATH_MSG_VERBOSE("---> Looping over TSOS's to allow  for cluster updates: "<< tsosVec->size() );
-      for(const auto & tsos : *tsosVec){
-          const MeasurementBase* measurement = tsos->measurementOnTrack(); 
-          if(!measurement || ! tsos->trackParameters()){
-            ATH_MSG_VERBOSE("---- TSOS has either no measurement or parameters: "<< measurement << "  " << tsos->trackParameters() );
-            continue;           
-          }
-          if(!tsos->type(Trk::TrackStateOnSurface::Measurement)) {continue;}
-          auto globalPosition = measurement->globalPosition();
-          const double radius = std::sqrt(globalPosition[0]*globalPosition[0]+globalPosition[1]*globalPosition[1]);
-          const double invRadius{1./radius};
-          // get the associated prd
-          const Trk::RIO_OnTrack* rio = dynamic_cast<const Trk::RIO_OnTrack*> ( measurement );
-          if(!rio){
-              continue;
-          }
-          const InDet::PixelCluster* pixel = dynamic_cast<const InDet::PixelCluster*> ( rio->prepRawData() );
-          // not pixel or not split
-          if (!pixel || !pixel->isSplit() ) {continue ;}
-
-          CylinderSurface iblSurface(radius,3000.0);
-          
-          const TrackParameters * trackParams = m_extrapolatorTool->extrapolate(*track,iblSurface);
-          
-          double yOnPix = trackParams->position().y();
-          double zOnPix = trackParams->position().z();
-
-          // now, find closest track  
-          double mindR = 99999999.;
-          double mindX = 99999999.;
-          double mindZ = 99999999.;
-          //
-          const double eta1{track->perigeeParameters()->momentum().eta()};
-          const double phi1{track->perigeeParameters()->momentum().phi()};
-          for (const auto & track2 : tracks){
-              if(track==track2) continue;
-              float dEta = eta1 - track2->perigeeParameters()->momentum().eta();
-              float dPhi2 = phi1 - track2->perigeeParameters()->momentum().phi();
-              double dr =  std::sqrt(dEta*dEta + dPhi2*dPhi2);
-              if(dr>0.4) continue;
-              
-              //extrapolation to pixel hit radius
-              const TrackParameters * track2Params = m_extrapolatorTool->extrapolate(*track2,iblSurface);
-          
-              const double y2OnPix = track2Params->position().y();
-              const double z2OnPix = track2Params->position().z();
-              
-              float dPhi = std::asin(yOnPix*invRadius) - std::asin(y2OnPix*invRadius);
-              if (dPhi >= M_PI) dPhi -= twoPi;
-              if (dPhi < -M_PI) dPhi += twoPi;
-              
-              const double dx = std::abs(radius*dPhi);
-              const double dz = std::abs(zOnPix - z2OnPix);
-              if(dx>mindX && dz>mindZ) continue;
-              dr = std::sqrt(dx*dx + dz*dz);
-              
-              if(dr<mindR && dr > 1.e-4){
-                  mindR = dr;
-                  mindX = dx;
-                  mindZ = dz;
-              }
-         }
-         refit = true;
-         std::pair<InDet::DRMap::iterator,bool> ret;
-         std::pair<float,float> min (mindX, mindZ);
-         ret = dRMapHandle->insert ( std::pair<const InDet::PixelCluster*,std::pair<float,float> >(pixel,min));
-         // if we already have a dR for this prd, we update it, if current value is smaller
-         if (!ret.second) {
-            InDet::DRMap::iterator it{dRMapHandle->find(pixel)};
-            auto &[x, z] = it->second;
-            if(std::sqrt(x * x + z * z) > (float)mindR) {
-                x = (float) mindX;
-                z = (float) mindZ;
-	        }
-         }
-      }
-      if(refit) refittedTracks.push_back(track);
-  }
-  }
-
 //============================================================================================================
 bool 
 Trk::DenseEnvironmentsAmbiguityProcessorTool::decideIfInHighPtBROI(const Trk::Track* ptrTrack) const{
diff --git a/Tracking/TrkTools/TrkAmbiguityProcessor/src/DenseEnvironmentsAmbiguityProcessorTool.h b/Tracking/TrkTools/TrkAmbiguityProcessor/src/DenseEnvironmentsAmbiguityProcessorTool.h
index 2acd36c3019b..dfafe963ba92 100644
--- a/Tracking/TrkTools/TrkAmbiguityProcessor/src/DenseEnvironmentsAmbiguityProcessorTool.h
+++ b/Tracking/TrkTools/TrkAmbiguityProcessor/src/DenseEnvironmentsAmbiguityProcessorTool.h
@@ -9,7 +9,6 @@
 #include "TrkFitterInterfaces/ITrackFitter.h"
 #include "TrkToolInterfaces/IAmbiTrackSelectionTool.h"
 #include "InDetPrepRawData/PixelGangedClusterAmbiguities.h"
-#include "TrkAmbiguityProcessor/dRMap.h"
 #include "TrkCaloClusterROI/CaloClusterROI_Collection.h"
 
 #include "TrkToolInterfaces/IPRDtoTrackMapTool.h"
@@ -158,8 +157,6 @@ namespace Trk {
     const PixelID* m_pixelId;
     const AtlasDetectorID* m_idHelper;
 
-    SG::WriteHandleKey<InDet::DRMap>                    m_dRMap;      //!< the actual dR map         
-
     bool m_rejectInvalidTracks;
   };
   
-- 
GitLab


From a529f718f6d9101b1f0d65c9ae0bc1b23e3f4fa4 Mon Sep 17 00:00:00 2001
From: Goetz Gaycken <goetz.gaycken@cern.ch>
Date: Wed, 22 Jul 2020 14:46:42 +0200
Subject: [PATCH 2/2] Remove support for unused calorimeter ROIs and handling
 of b track candidates.

---
 .../share/ConfiguredNewTrackingSiPattern.py   |   5 +-
 .../TrkAmbiguityProcessor/CMakeLists.txt      |   2 +-
 ...enseEnvironmentsAmbiguityProcessorTool.cxx | 205 +-----------------
 .../DenseEnvironmentsAmbiguityProcessorTool.h |  52 +----
 4 files changed, 10 insertions(+), 254 deletions(-)

diff --git a/InnerDetector/InDetExample/InDetRecExample/share/ConfiguredNewTrackingSiPattern.py b/InnerDetector/InDetExample/InDetRecExample/share/ConfiguredNewTrackingSiPattern.py
index 1efc7806b04d..641770f10935 100644
--- a/InnerDetector/InDetExample/InDetRecExample/share/ConfiguredNewTrackingSiPattern.py
+++ b/InnerDetector/InDetExample/InDetRecExample/share/ConfiguredNewTrackingSiPattern.py
@@ -514,9 +514,8 @@ class  ConfiguredNewTrackingSiPattern:
                                                    tryBremFit         = InDetFlags.doBremRecovery() and useBremMode and NewTrackingCuts.mode() != "DBM",
                                                    caloSeededBrem     = InDetFlags.doCaloSeededBrem() and NewTrackingCuts.mode() != "DBM",
                                                    pTminBrem          = NewTrackingCuts.minPTBrem(),
-                                                   RefitPrds          = True,
-                                                   doHadCaloSeed      = InDetFlags.doCaloSeededRefit(),
-                                                   InputHadClusterContainerName = InDetKeys.HadCaloClusterROIContainer()+"Bjet")
+                                                   RefitPrds          = True)
+
 
            # DenseEnvironmentsAmbiguityScoreProcessorTool
            from TrkAmbiguityProcessor.TrkAmbiguityProcessorConf import Trk__DenseEnvironmentsAmbiguityScoreProcessorTool as ScoreProcessorTool
diff --git a/Tracking/TrkTools/TrkAmbiguityProcessor/CMakeLists.txt b/Tracking/TrkTools/TrkAmbiguityProcessor/CMakeLists.txt
index 90334e12e5bb..796f2383c99c 100644
--- a/Tracking/TrkTools/TrkAmbiguityProcessor/CMakeLists.txt
+++ b/Tracking/TrkTools/TrkAmbiguityProcessor/CMakeLists.txt
@@ -42,5 +42,5 @@ atlas_add_component( TrkAmbiguityProcessor
                      src/RenounceToolInputsVisitor.cxx
                      src/components/*.cxx
                      PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
-                     LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaKernel AthenaBaseComps AtlasDetDescr GaudiKernel InDetPrepRawData InDetRecToolInterfaces  TrkDetElementBase TrkEventPrimitives TrkParameters TrkRIO_OnTrack TrkTrack TrkTrackSummary TrkTruthData TrkFitterInterfaces TrkToolInterfaces TrkValInterfaces TrkExInterfaces TrkCaloClusterROI)
+                     LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaKernel AthenaBaseComps AtlasDetDescr GaudiKernel InDetPrepRawData InDetRecToolInterfaces  TrkDetElementBase TrkEventPrimitives TrkParameters TrkRIO_OnTrack TrkTrack TrkTrackSummary TrkTruthData TrkFitterInterfaces TrkToolInterfaces TrkValInterfaces TrkExInterfaces)
 
diff --git a/Tracking/TrkTools/TrkAmbiguityProcessor/src/DenseEnvironmentsAmbiguityProcessorTool.cxx b/Tracking/TrkTools/TrkAmbiguityProcessor/src/DenseEnvironmentsAmbiguityProcessorTool.cxx
index b132c2a2b687..c11b3fce63c1 100644
--- a/Tracking/TrkTools/TrkAmbiguityProcessor/src/DenseEnvironmentsAmbiguityProcessorTool.cxx
+++ b/Tracking/TrkTools/TrkAmbiguityProcessor/src/DenseEnvironmentsAmbiguityProcessorTool.cxx
@@ -8,16 +8,9 @@
 #include "TrkTrack/TrackCollection.h"
 #include "TrkParameters/TrackParameters.h"
 #include "TrkRIO_OnTrack/RIO_OnTrack.h"
-#include "AtlasDetDescr/AtlasDetectorID.h"
 #include "TrkTrack/TrackInfo.h"
-#include "InDetRecToolInterfaces/IPixelClusterSplitProbTool.h"
 #include "TrkExInterfaces/IExtrapolator.h"
 #include "TrkTrackSummary/TrackSummary.h"
-#include "TrkCaloClusterROI/CaloClusterROI_Collection.h"
-#include "InDetPrepRawData/PixelCluster.h"
-#include "InDetPrepRawData/SCT_Cluster.h"
-#include "InDetIdentifier/PixelID.h"
-#include "AmbiguityProcessorUtility.h"
 #include <cmath>
 #include <iterator>
 
@@ -71,13 +64,6 @@ Trk::DenseEnvironmentsAmbiguityProcessorTool::DenseEnvironmentsAmbiguityProcesso
   declareProperty("pTminBrem"            , m_pTminBrem          = 1000.);
   declareProperty("etaBounds"            , m_etaBounds,"eta intervals for internal monitoring");
 
-  //To determine the ROI for high pt Bs
-  declareProperty("doHadCaloSeed"        ,m_useHClusSeed = false );
-  declareProperty("minPtBjetROI"         ,m_minPtBjetROI = 15000.); //inMeV
-  declareProperty("phiWidth"             ,m_phiWidth     = 0.1   );
-  declareProperty("etaWidth"             ,m_etaWidth     = 0.1   );
-  declareProperty("InputHadClusterContainerName",m_inputHadClusterContainerName="InDetHadCaloClusterROIs");
-
 }
 //==================================================================================================
 
@@ -101,8 +87,6 @@ Trk::DenseEnvironmentsAmbiguityProcessorTool::initialize(){
    }
 
   ATH_CHECK( m_extrapolatorTool.retrieve());
-  ATH_CHECK( detStore()->retrieve(m_pixelId, "PixelID"));
-  ATH_CHECK( detStore()->retrieve(m_idHelper, "AtlasID"));
   
   // Configuration of the material effects
   Trk::ParticleSwitcher particleSwitch;
@@ -112,9 +96,6 @@ Trk::DenseEnvironmentsAmbiguityProcessorTool::initialize(){
   if (m_tryBremFit)
     ATH_MSG_INFO( "Try brem fit and recovery for electron like tracks." );
 
-  //Initialise the ROI tool
-  ATH_CHECK(m_inputHadClusterContainerName.initialize(m_useHClusSeed));
-
   if (m_etaBounds.size() != Counter::nRegions) {
      ATH_MSG_FATAL("There must be exactly " << (Counter::nRegions) << " eta bounds but "
                    << m_etaBounds.size() << " are set." );
@@ -161,7 +142,6 @@ Trk::DenseEnvironmentsAmbiguityProcessorTool::process(const TracksScores *trackS
      }
   }
   std::vector<std::unique_ptr<const Trk::Track> > trackDustbin;
-  reloadHadROIs();
   // going to do simple algorithm for now:
   // - take track with highest score
   // - remove shared hits from all other tracks
@@ -215,37 +195,12 @@ Trk::DenseEnvironmentsAmbiguityProcessorTool::solveTracks(const TracksScores &tr
       if (m_tryBremFit && atrack.track()->info().trackProperties(Trk::TrackInfo::BremFit)) {
         stat.incrementCounterByRegion(CounterIndex::kNacceptedBrem,atrack.track());
       }
-      //Compute the fitQuality
-      const float fitQual = AmbiguityProcessor::calculateFitQuality(*atrack);
-      if(fitQual > 1.3 && decideIfInHighPtBROI(atrack.track())){
-        std::unique_ptr<Trk::Track> refittedTrack( refitTracksFromB(atrack.track(), fitQual)); //Q: Is there the case  atrack == refittedTrack ?
-        if(refittedTrack){
-          // add track to PRD_AssociationTool
-          if ( m_assoTool->addPRDs(prdToTrackMap, *refittedTrack).isFailure()){
-            ATH_MSG_ERROR( "addPRDs() failed" );
-          } 
-          // add to output list
-          finalTracks.push_back( refittedTrack.release() );
-          if (atrack.newTrack()) {
-             trackDustbin.emplace_back(atrack.release());
-          }
-        } else {
-          // add track to PRD_AssociationTool
-          StatusCode sc = m_assoTool->addPRDs(prdToTrackMap, *atrack);
-          if (m_assoTool->addPRDs(prdToTrackMap, *atrack).isFailure()){
-            ATH_MSG_ERROR( "addPRDs() failed" );
-          }
-          // add to output list 
-          finalTracks.push_back( atrack.release() );
-        }
-      } else {
-        // add track to PRD_AssociationTool
-        if (m_assoTool->addPRDs(prdToTrackMap, *atrack).isFailure()){ 
-          ATH_MSG_ERROR( "addPRDs() failed" );
-        }
-        // add to output list 
-        finalTracks.push_back( atrack.release() );
-      }
+
+      // add track to PRD_AssociationTool
+      StatusCode sc = m_assoTool->addPRDs(prdToTrackMap, *atrack);
+      if (sc.isFailure()) ATH_MSG_ERROR( "addPRDs() failed" );
+      // add to output list 
+      finalTracks.push_back( atrack.release() );
     } else if ( keepOriginal){
       // track can be kept as is, but is not yet fitted
       ATH_MSG_DEBUG ("Good track("<< atrack.track() << ") but need to fit this track first, score, add it into map again and retry ! ");
@@ -330,154 +285,6 @@ Trk::DenseEnvironmentsAmbiguityProcessorTool::refitPrds( const Trk::Track* track
 }
 
 
-//============================================================================================================
-bool 
-Trk::DenseEnvironmentsAmbiguityProcessorTool::decideIfInHighPtBROI(const Trk::Track* ptrTrack) const{
-  // Are we in a ROI?
-  bool inROIandPTok(true);
-  if(  ptrTrack->trackParameters()->front() ){
-    if(  ptrTrack->trackParameters()->front()->pT() < m_minPtBjetROI ){
-      inROIandPTok = false;
-      return false;
-    }
-    if(inROIandPTok){
-      bool inROI  = m_useHClusSeed && isHadCaloCompatible(*ptrTrack->trackParameters()->front());
-      return inROI;
-    }
-    return false;
-  } 
-  return false;
-}
-
-//============================================================================================================
-bool 
-Trk::DenseEnvironmentsAmbiguityProcessorTool::isHadCaloCompatible(const Trk::TrackParameters& Tp) const{
-  const double pi = M_PI;
-  const double pi2 = 2.*M_PI;
-  if(m_hadF.empty()) return false;
-  auto f = m_hadF.begin();
-  auto fe = m_hadF.end();
-  auto e = m_hadE.begin();
-  auto r = m_hadR.begin();
-  auto z = m_hadZ.begin();
-  double F = Tp.momentum().phi();
-  double E = Tp.eta();
-  for(; f!=fe; ++f) {
-    double df = std::abs(F-(*f));
-    if(df > pi        ) df = std::abs(pi2-df);
-    if(df < m_phiWidth) {
-      //Correct eta of cluster to take into account the z postion of the track
-      double newZ   = *z - Tp.position().z();
-      double newEta =  std::atanh( newZ / std::sqrt( (*r) * (*r) + newZ*newZ ) );
-      double de = std::abs(E-newEta);
-      if(de < m_etaWidth) return true;
-    }
-    ++e;
-    ++r;
-    ++z;
-  }
-  return false;
-}
-
-//============================================================================================================
-void 
-Trk::DenseEnvironmentsAmbiguityProcessorTool::reloadHadROIs() const{
-  // turn into conditions algorithm
-  if(m_useHClusSeed) {
-    m_hadF.clear();
-    m_hadE.clear();
-    m_hadR.clear();
-    m_hadZ.clear();
-  
-    SG::ReadHandle<CaloClusterROI_Collection> calo(m_inputHadClusterContainerName);
-    for( const auto& ccROI : *calo) {
-      m_hadF.push_back( ccROI->globalPosition().phi() );
-      m_hadE.push_back( ccROI->globalPosition().eta() );
-      m_hadR.push_back( ccROI->globalPosition().perp() );
-      m_hadZ.push_back( ccROI->globalPosition().z() );
-    }
-  }
-}
-   
-//============================================================================================================
-void 
-Trk::DenseEnvironmentsAmbiguityProcessorTool::removeInnerHits(std::vector<const Trk::MeasurementBase*>& measurements) const{
-  int count = 0; 
-  for (size_t i=0; i < measurements.size(); ++i){
-    const Trk::RIO_OnTrack* rio = dynamic_cast <const Trk::RIO_OnTrack*>(measurements.at(i));
-    if (rio != nullptr) {
-      const Identifier& surfaceID = (rio->identify()) ;                            
-      if(m_idHelper->is_pixel(surfaceID) && count ==0){  
-        //Only do this if we want to remove the pixel hits 
-        const Identifier& id = m_pixelId->wafer_id(surfaceID);
-        int layerDisk = m_pixelId -> layer_disk(id);
-        if (layerDisk < 3){
-          measurements.erase(measurements.begin()+i);
-          break;
-        }
-        break;
-      }
-      break;
-    }
-  }
-}
-
-//============================================================================================================
-Trk::Track* 
-Trk::DenseEnvironmentsAmbiguityProcessorTool::refitTracksFromB(const Trk::Track* track, double fitQualityOriginal) const{
-  const Trk::TrackParameters* par = track->perigeeParameters();
-  if (par==nullptr) {
-    par = track->trackParameters()->front();
-    if (par==nullptr) {
-      ATH_MSG_DEBUG ("Track ("<<track<<") has no Track Parameters ! No refit !");
-      return nullptr;
-    }
-  }  
-  std::vector<const Trk::MeasurementBase*> measurementSet{};
-  //store all silicon measurements into the measurementset
-  DataVector<const Trk::TrackStateOnSurface>::const_iterator TrackStateOnSurface = track->trackStateOnSurfaces()->begin();
-  for ( ; TrackStateOnSurface != track->trackStateOnSurfaces()->end(); ++TrackStateOnSurface ) {
-    if ( !(*TrackStateOnSurface) ){
-      ATH_MSG_WARNING( "This track contains an empty MeasurementBase object that won't be included in the fit" );
-      continue;
-    }
-    if ( (*TrackStateOnSurface)->measurementOnTrack() ){
-      if ( (*TrackStateOnSurface)->type( Trk::TrackStateOnSurface::Measurement) ){
-        const Trk::RIO_OnTrack* rio = dynamic_cast <const Trk::RIO_OnTrack*>( (*TrackStateOnSurface)->measurementOnTrack() );
-        if (rio != nullptr) {
-          const Identifier& surfaceID = (rio->identify()) ;                            
-          if(m_idHelper->is_pixel(surfaceID)|| m_idHelper->is_sct(surfaceID)) {
-            measurementSet.push_back( (*TrackStateOnSurface)->measurementOnTrack() );
-          }
-        }
-      }
-    }
-  }
-
-  size_t previousMeasSize = measurementSet.size();
-  while (true){
-    removeInnerHits(measurementSet); 
-    if(measurementSet.size()>4){
-      auto pRefittedTrack{fit(measurementSet,*par,true,Trk::pion)};
-      double fitQualPostRefit = 10;
-      if  (pRefittedTrack && pRefittedTrack->fitQuality() && pRefittedTrack->fitQuality()->numberDoF()!=0 ) 
-        fitQualPostRefit = pRefittedTrack->fitQuality()->chiSquared()/pRefittedTrack->fitQuality()->numberDoF(); 
-      if (fitQualityOriginal/fitQualPostRefit > 1){
-        if ( fitQualityOriginal/fitQualPostRefit > 1.2){
-          return pRefittedTrack.release();
-        }
-      }
-      if (previousMeasSize == measurementSet.size()){
-        return nullptr;
-      }
-      previousMeasSize = measurementSet.size();
-    } else {
-      //cannot refit the track because we do not have enough measurements
-      return nullptr;
-    }
-  }
-}
-
 void 
 Trk::DenseEnvironmentsAmbiguityProcessorTool::dumpStat(MsgStream &out) const{
    auto parseFileName=[](const std::string & fullname){
diff --git a/Tracking/TrkTools/TrkAmbiguityProcessor/src/DenseEnvironmentsAmbiguityProcessorTool.h b/Tracking/TrkTools/TrkAmbiguityProcessor/src/DenseEnvironmentsAmbiguityProcessorTool.h
index dfafe963ba92..13a611135397 100644
--- a/Tracking/TrkTools/TrkAmbiguityProcessor/src/DenseEnvironmentsAmbiguityProcessorTool.h
+++ b/Tracking/TrkTools/TrkAmbiguityProcessor/src/DenseEnvironmentsAmbiguityProcessorTool.h
@@ -9,7 +9,6 @@
 #include "TrkFitterInterfaces/ITrackFitter.h"
 #include "TrkToolInterfaces/IAmbiTrackSelectionTool.h"
 #include "InDetPrepRawData/PixelGangedClusterAmbiguities.h"
-#include "TrkCaloClusterROI/CaloClusterROI_Collection.h"
 
 #include "TrkToolInterfaces/IPRDtoTrackMapTool.h"
 #include "TrkEventUtils/PRDtoTrackMap.h"
@@ -27,15 +26,6 @@
 
 
 
-class AtlasDetectorID;
-class PixelID;
-
-namespace InDet{
-  class IPixelClusterSplitProbTool;
-  class PixelCluster;
-  class SCT_Cluster;
-}
-
 namespace Trk {
   class ITruthToTrack;
   class IExtrapolator;
@@ -81,32 +71,9 @@ namespace Trk {
     /**Track* 
     refitRots( const Track* track, Counter &stat) const override final;**/
 
-    /** stores the minimal dist(trk,trk) for covariance correction*/
-    void 
-    storeTrkDistanceMapdR(TrackCollection& tracks, std::vector<Trk::Track*> &refit_tracks_out );
-    
-    /** refit Tracks that are in the region of interest and removes inner hits that are wrongly assigned*/
-    void 
-    removeInnerHits(std::vector<const Trk::MeasurementBase*>& measurements) const;
-    
-    Trk::Track* 
-    refitTracksFromB(const Trk::Track* track,double fitQualityOriginal) const;
-   
-    /** see if we are in the region of interest for B tracks*/
-    bool 
-    decideIfInHighPtBROI(const Trk::Track*) const;
-
-    /** Check if the cluster is compatible with a hadronic cluster*/
-    bool 
-    isHadCaloCompatible(const Trk::TrackParameters& Tp) const;
-
-    /** Load the clusters to see if they are compatibles with ROI*/
-    void 
-    reloadHadROIs() const;
-    
     virtual std::unique_ptr<Trk::Track>
     doBremRefit(const Trk::Track & track) const override final;
-         
+
 
     std::unique_ptr<Trk::Track>
     fit(const std::vector<const Trk::PrepRawData*> &raw,
@@ -119,22 +86,9 @@ namespace Trk {
     
     std::unique_ptr<Trk::Track>
     fit(const Track &track, bool flag, Trk::ParticleHypothesis hypo) const override final;
-    
     bool 
     checkTrack(const Trk::Track *) const;
 
-    /** variables to decide if we are in a ROI */
-    bool m_useHClusSeed;
-    float m_minPtBjetROI;
-    float m_phiWidth;
-    float m_etaWidth;
-    SG::ReadHandleKey<CaloClusterROI_Collection> m_inputHadClusterContainerName;
-
-    mutable std::vector<double>   m_hadF;
-    mutable std::vector<double>   m_hadE;
-    mutable std::vector<double>   m_hadR;
-    mutable std::vector<double>   m_hadZ;
-    
     /** refitting tool - used to refit tracks once shared hits are removed. 
         Refitting tool used is configured via jobOptions.*/
     ToolHandleArray<ITrackFitter> m_fitterTool;
@@ -153,10 +107,6 @@ namespace Trk {
         which are removed are made */
     ToolHandle<IAmbiTrackSelectionTool> m_selectionTool;
 
-    /**These allow us to retrieve the helpers*/
-    const PixelID* m_pixelId;
-    const AtlasDetectorID* m_idHelper;
-
     bool m_rejectInvalidTracks;
   };
   
-- 
GitLab