From be9a9ec8eb1a8c0255e3c93962b09d9043cfc80a Mon Sep 17 00:00:00 2001
From: John Baines <john.baines@stfc.ac.uk>
Date: Wed, 21 Oct 2020 09:26:03 +0000
Subject: [PATCH] Add code to  support Large Radius Tracking to
 TrigFastTrackFinder and its tools

---
 .../src/TrigFastTrackFinder.cxx               | 66 +++++++++++++++++--
 .../src/TrigFastTrackFinder.h                 | 10 ++-
 .../TrigCombinatorialSettings.h               |  3 +-
 .../src/TrigTrackSeedGenerator.cxx            | 36 ++++++----
 .../ITrigSpacePointConversionTool.h           |  6 +-
 .../src/SpacePointConversionUtils.h           | 47 +++++++++----
 .../src/TrigSpacePointConversionTool.cxx      | 46 +++++++++----
 .../src/TrigSpacePointConversionTool.h        |  5 +-
 8 files changed, 166 insertions(+), 53 deletions(-)

diff --git a/Trigger/TrigAlgorithms/TrigFastTrackFinder/src/TrigFastTrackFinder.cxx b/Trigger/TrigAlgorithms/TrigFastTrackFinder/src/TrigFastTrackFinder.cxx
index 825d9743efe..3c106d49e6c 100644
--- a/Trigger/TrigAlgorithms/TrigFastTrackFinder/src/TrigFastTrackFinder.cxx
+++ b/Trigger/TrigAlgorithms/TrigFastTrackFinder/src/TrigFastTrackFinder.cxx
@@ -107,7 +107,8 @@ TrigFastTrackFinder::TrigFastTrackFinder(const std::string& name, ISvcLocator* p
   m_idHelper(0),
   m_particleHypothesis(Trk::pion),
   m_useNewLayerNumberScheme(false), 
-  m_useGPU(false)
+  m_useGPU(false),
+  m_LRTmode(false)
 {
 
   /** Doublet finding properties. */
@@ -149,6 +150,10 @@ TrigFastTrackFinder::TrigFastTrackFinder(const std::string& name, ISvcLocator* p
                   m_outputTracksKey = std::string("TrigFastTrackFinder_Tracks"),
                   "TrackCollection name");
 
+  declareProperty("inputTracksName", 
+                  m_inputTracksKey = std::string(""),
+                  "TrackCollection name");
+
   declareProperty("RoIs", m_roiCollectionKey = std::string("OutputRoIs"), "RoIs to read in");
  
   declareProperty( "UseBeamSpot",           m_useBeamSpot = true);
@@ -170,6 +175,7 @@ TrigFastTrackFinder::TrigFastTrackFinder(const std::string& name, ISvcLocator* p
 
   declareProperty("useGPU", m_useGPU = false);
 
+  declareProperty("LRT_Mode", m_LRTmode);
   // declare monitoring histograms
 
 }
@@ -189,6 +195,12 @@ HLT::ErrorCode TrigFastTrackFinder::hltInitialize() {
     return HLT::BAD_JOB_SETUP;
   }
 
+  // optional input tracks collection if present the clusters on previously found tracks are not used to form seeds
+  if (m_LRTmode) {
+    if (m_inputTracksKey.initialize( !m_inputTracksKey.key().empty() ).isFailure() ) {
+      return HLT::BAD_JOB_SETUP;
+    }
+  }
   // optional PRD to track association map
   if (m_prdToTrackMap.initialize( !m_prdToTrackMap.key().empty() ).isFailure()) {
     return HLT::BAD_JOB_SETUP;
@@ -303,6 +315,13 @@ HLT::ErrorCode TrigFastTrackFinder::hltInitialize() {
   }
 
   ATH_MSG_INFO("Use GPU acceleration : "<<std::boolalpha<<m_useGPU);
+
+  if (m_LRTmode) {
+    ATH_MSG_INFO(" FTF configures in Long Range Tracking Mode");
+    // set TrigTrackSeedGenerator to LRTmode
+    m_tcs.m_LRTmode=m_LRTmode;
+
+  }
   
   ATH_MSG_DEBUG(" Initialized successfully"); 
   return HLT::OK;
@@ -398,9 +417,17 @@ StatusCode TrigFastTrackFinder::execute() {
   SG::WriteHandle<TrackCollection> outputTracks(m_outputTracksKey, ctx);
   outputTracks = std::make_unique<TrackCollection>();
 
+  const TrackCollection* inputTracks = nullptr;
+  if (m_LRTmode) {
+    if (!m_inputTracksKey.key().empty()){
+      SG::ReadHandle<TrackCollection> inputTrackHandle(m_inputTracksKey, ctx);
+      ATH_CHECK(inputTrackHandle.isValid());
+      inputTracks = inputTrackHandle.ptr();
+    }
+  }
   InDet::ExtendedSiTrackMakerEventData_xk trackEventData(m_prdToTrackMap, ctx);
-  ATH_CHECK(findTracks(trackEventData, internalRoI, *outputTracks, ctx));
-  
+  ATH_CHECK(findTracks(trackEventData, internalRoI, *inputTracks, *outputTracks, ctx));
+
   return StatusCode::SUCCESS;
 }
 
@@ -416,7 +443,17 @@ HLT::ErrorCode TrigFastTrackFinder::hltExecute(const HLT::TriggerElement*,
   TrackCollection* outputTracks = new TrackCollection(SG::OWN_ELEMENTS);
   InDet::FexSiTrackMakerEventData_xk trackEventData(*this, outputTE, m_prdToTrackMap.key());
 
-  StatusCode sc = findTracks(trackEventData, *internalRoI, *outputTracks, getContext());
+
+  const TrackCollection* inputTracks = nullptr;
+  if (m_LRTmode) {
+    if (!m_inputTracksKey.key().empty()){
+      if ( HLT::OK != getFeature(outputTE, inputTracks) ) {
+	ATH_MSG_DEBUG(" no input track collection found ");
+      } 
+    }
+  }
+  StatusCode sc = findTracks(trackEventData, *internalRoI, *inputTracks, *outputTracks, getContext());
+
   HLT::ErrorCode code = HLT::OK;
   if (sc != StatusCode::SUCCESS) {
     delete outputTracks;
@@ -435,6 +472,7 @@ HLT::ErrorCode TrigFastTrackFinder::hltExecute(const HLT::TriggerElement*,
 
 StatusCode TrigFastTrackFinder::findTracks(InDet::SiTrackMakerEventData_xk &trackEventData,
                                            const TrigRoiDescriptor& roi,
+                                           const TrackCollection& inputTracks,
                                            TrackCollection& outputTracks,
                                            const EventContext& ctx) const {
   // Run3 monitoring ---------->
@@ -462,7 +500,23 @@ StatusCode TrigFastTrackFinder::findTracks(InDet::SiTrackMakerEventData_xk &trac
 
   std::vector<TrigSiSpacePointBase> convertedSpacePoints;
   convertedSpacePoints.reserve(5000);
-  ATH_CHECK(m_spacePointTool->getSpacePoints(roi, convertedSpacePoints, mnt_roi_nSPsPIX, mnt_roi_nSPsSCT, ctx));
+
+  std::map<Identifier, std::vector<long int> > siClusterMap;
+
+  if (m_LRTmode) {
+    // In LRT mode read the input track collection and enter the clusters on track into the cluster map so these are not used for seeding
+    if (!m_inputTracksKey.key().empty()) {
+      ATH_MSG_DEBUG("LRT Mode: Got input track collection with "<<inputTracks.size()<< "tracks");
+      long int trackIndex=0;
+      for (auto t:inputTracks) {
+	updateClusterMap(trackIndex++, t, siClusterMap);
+      }
+    }
+    ATH_CHECK(m_spacePointTool->getSpacePoints(roi, convertedSpacePoints, mnt_roi_nSPsPIX, mnt_roi_nSPsSCT, ctx, &siClusterMap));
+  } else {
+    ATH_CHECK(m_spacePointTool->getSpacePoints(roi, convertedSpacePoints, mnt_roi_nSPsPIX, mnt_roi_nSPsSCT, ctx));
+  }
+
 
   mnt_timer_SpacePointConversion.stop();
   mnt_roi_nSPs    = mnt_roi_nSPsPIX + mnt_roi_nSPsSCT;
@@ -577,8 +631,6 @@ StatusCode TrigFastTrackFinder::findTracks(InDet::SiTrackMakerEventData_xk &trac
 
   long int trackIndex=0;
 
-  std::map<Identifier, std::vector<long int> > siClusterMap;
-
   bool PIX = true;
   bool SCT = true;
   m_trackMaker->newTrigEvent(ctx, trackEventData, PIX, SCT);
diff --git a/Trigger/TrigAlgorithms/TrigFastTrackFinder/src/TrigFastTrackFinder.h b/Trigger/TrigAlgorithms/TrigFastTrackFinder/src/TrigFastTrackFinder.h
index cdc3cf6a8f5..fdf9fa5b5e8 100644
--- a/Trigger/TrigAlgorithms/TrigFastTrackFinder/src/TrigFastTrackFinder.h
+++ b/Trigger/TrigAlgorithms/TrigFastTrackFinder/src/TrigFastTrackFinder.h
@@ -78,6 +78,7 @@ class TrigFastTrackFinder : public HLT::FexAlgo {
 
   StatusCode findTracks(InDet::SiTrackMakerEventData_xk &event_data,
                         const TrigRoiDescriptor& roi,
+                        const TrackCollection& inputTracks,
                         TrackCollection& outputTracks,
                         const EventContext& ctx) const;
 
@@ -111,6 +112,7 @@ protected:
 
   //DataHandles
   SG::ReadHandleKey<TrigRoiDescriptorCollection> m_roiCollectionKey;
+  SG::ReadHandleKey<TrackCollection> m_inputTracksKey;
   SG::WriteHandleKey<TrackCollection> m_outputTracksKey;
 
   SG::ReadHandleKey<Trk::PRDtoTrackMap>       m_prdToTrackMap
@@ -177,9 +179,15 @@ protected:
   // GPU acceleration
 
   bool m_useGPU;
-  
+
   void makeSeedsOnGPU(const TrigCombinatorialSettings&, const IRoiDescriptor*, const std::vector<TrigSiSpacePointBase>&, std::vector<TrigInDetTriplet>&) const;
 
+  // read input tracks and remove previously-used clusters from seed-making
+
+  // Large Radius Tracking
+  bool m_LRTmode;
+  
+
 };
 
 #endif // not TRIGFASTTRACKFINDER_TRIGFASTTRACKFINDER_H
diff --git a/Trigger/TrigTools/TrigInDetPattRecoTools/TrigInDetPattRecoTools/TrigCombinatorialSettings.h b/Trigger/TrigTools/TrigInDetPattRecoTools/TrigInDetPattRecoTools/TrigCombinatorialSettings.h
index 6d059efedf5..978a922b51a 100644
--- a/Trigger/TrigTools/TrigInDetPattRecoTools/TrigInDetPattRecoTools/TrigCombinatorialSettings.h
+++ b/Trigger/TrigTools/TrigInDetPattRecoTools/TrigInDetPattRecoTools/TrigCombinatorialSettings.h
@@ -33,7 +33,7 @@ public:
     m_maxTripletBufferLength = 3;
 
     m_zvError = 10.0;
-
+    m_LRTmode=false;
     m_layerGeometry.clear();
   }
 
@@ -53,6 +53,7 @@ public:
   unsigned int m_maxTripletBufferLength;
 
   float m_zvError;
+  bool m_LRTmode;
 
   std::vector<TRIG_INDET_SI_LAYER> m_layerGeometry;
 } TRIG_COMBINATORIAL_SETTINGS;
diff --git a/Trigger/TrigTools/TrigInDetPattRecoTools/src/TrigTrackSeedGenerator.cxx b/Trigger/TrigTools/TrigInDetPattRecoTools/src/TrigTrackSeedGenerator.cxx
index 9e8d086b96b..39ed69e03c0 100644
--- a/Trigger/TrigTools/TrigInDetPattRecoTools/src/TrigTrackSeedGenerator.cxx
+++ b/Trigger/TrigTools/TrigInDetPattRecoTools/src/TrigTrackSeedGenerator.cxx
@@ -599,6 +599,7 @@ int TrigTrackSeedGenerator::processSpacepointRangeZv(float rm, float zm, bool ch
 void TrigTrackSeedGenerator::createTriplets(const TrigSiSpacePointBase* pS, int nInner, int nOuter,
 					    std::vector<TrigInDetTriplet>& output, const IRoiDescriptor* roiDescriptor) {
 
+  if (m_settings.m_LRTmode) std::cout<<"TrigTrackSeedGenerator::createTriplets in LRT mode "<<std::endl;
 
   if(nInner==0 || nOuter==0) return;
 
@@ -765,21 +766,26 @@ void TrigTrackSeedGenerator::createTriplets(const TrigSiSpacePointBase* pS, int
 
       //6. add new triplet
 
-      const float Q = fabs_d0*fabs_d0;
+      //  Calculate triplet weight: No weighting in LRT mode, but d0**2 weighting for normal (non LRT) mode. Triplets are then sorted by lowest weight.
+      const double Q= (m_settings.m_LRTmode ? 0 : fabs_d0*fabs_d0);
       if(output.size()>=m_settings.m_maxTripletBufferLength) {
-        std::sort(output.begin(), output.end(), 
-          [](const TrigInDetTriplet& A, const TrigInDetTriplet& B) {
-            return A.Q() > B.Q();
-          }
-        );
-
-        std::vector<TrigInDetTriplet>::iterator it = output.begin();
-        if( Q >= (*it).Q()) {
-          continue;
-        }
-        output.erase(it);
+	if (m_settings.m_LRTmode) { // take the first m_maxTripletBufferLength triplets
+	  continue;
+	} else { // choose smallest d0
+
+	  std::sort(output.begin(), output.end(), 
+		    [](TrigInDetTriplet A, const TrigInDetTriplet B) {
+		      return A.Q() > B.Q();
+		    }
+		    );
+
+	  std::vector<TrigInDetTriplet>::iterator it = output.begin();
+	  if( Q >= (*it).Q()) {
+	    continue;
+	  }
+	  output.erase(it);
+	}
       }
-
       output.emplace_back(*m_SoA.m_spi[innIdx], *pS, *m_SoA.m_spo[outIdx-nInner], Q);
     }
   }
@@ -1090,7 +1096,9 @@ void TrigTrackSeedGenerator::createTripletsNew(const TrigSiSpacePointBase* pS, i
 void TrigTrackSeedGenerator::storeTriplets(std::vector<TrigInDetTriplet>& tripletVec) {
   for(std::vector<TrigInDetTriplet>::iterator it=tripletVec.begin();it!=tripletVec.end();++it) {
     float newQ = (*it).Q();
-    if((*it).s3().isSCT()) {
+
+    if((!m_settings.m_LRTmode) && (*it).s3().isSCT()) {
+      // In normal (non LRT) mode penalise SSS by 1000, PSS (if enabled) and PPS by 10000
       newQ += (*it).s1().isSCT() ? 1000.0 : 10000.0;
     }
     (*it).Q(newQ);
diff --git a/Trigger/TrigTools/TrigInDetToolInterfaces/TrigInDetToolInterfaces/ITrigSpacePointConversionTool.h b/Trigger/TrigTools/TrigInDetToolInterfaces/TrigInDetToolInterfaces/ITrigSpacePointConversionTool.h
index 6ec35c22919..b82f07f1991 100644
--- a/Trigger/TrigTools/TrigInDetToolInterfaces/TrigInDetToolInterfaces/ITrigSpacePointConversionTool.h
+++ b/Trigger/TrigTools/TrigInDetToolInterfaces/TrigInDetToolInterfaces/ITrigSpacePointConversionTool.h
@@ -6,10 +6,12 @@
 #define __ITRIG_SPACEPOINT_CONVERSION_TOOL_H__
 
 #include <vector>
+#include <map>
 #include "GaudiKernel/IAlgTool.h"
 
 #include "IRegionSelector/IRoiDescriptor.h"
 #include "TrigInDetEvent/TrigSiSpacePointBase.h"
+#include "Identifier/Identifier.h"
 
 /** @class ITrigSpacePointConversionTool    
 provides the abstract interface for offline SP conversion tool
@@ -25,9 +27,9 @@ class ITrigSpacePointConversionTool : virtual public IAlgTool {
   static const InterfaceID& interfaceID () {  //!< the Tool's interface
     return IID_ITrigSpacePointConversionTool; 
   }  	
-  
-  virtual StatusCode getSpacePoints(const IRoiDescriptor&, std::vector<TrigSiSpacePointBase>&, int&, int&, const EventContext& ctx) const = 0;
 
+  // Optional parameter clustermap can be used in LRT mode to provide a list of clusters not to be included in seed-making 
+  virtual StatusCode getSpacePoints(const IRoiDescriptor&, std::vector<TrigSiSpacePointBase>&, int&, int&, const EventContext& ctx, std::map<Identifier, std::vector<long int> >* clustermap=nullptr) const = 0;
 };
 
 #endif
diff --git a/Trigger/TrigTools/TrigOnlineSpacePointTool/src/SpacePointConversionUtils.h b/Trigger/TrigTools/TrigOnlineSpacePointTool/src/SpacePointConversionUtils.h
index 2b5ba4897bb..955add4507a 100644
--- a/Trigger/TrigTools/TrigOnlineSpacePointTool/src/SpacePointConversionUtils.h
+++ b/Trigger/TrigTools/TrigOnlineSpacePointTool/src/SpacePointConversionUtils.h
@@ -10,6 +10,7 @@
 
 namespace Trk {
   class SpacePoint;
+  class PrepRawData;
 }
 class SpacePointContainer;
 class SpacePointCollection;
@@ -20,10 +21,9 @@ class Identifier;
 class IdentifierHash;
 class TrigSiSpacePointBase;
 class IRoiDescriptor;
-
 /// header for factorised IRoiDescriptor interface
 #include "IRegionSelector/RoiUtil.h"
-
+#include "TrkPrepRawData/PrepRawData.h"
 namespace FTF {//FastTrackFinder
 
   class LayerCalculator {
@@ -123,22 +123,41 @@ namespace FTF {//FastTrackFinder
   };
 
   class RoI_Filter : public BaseSpacePointFilter {
-    public:
-  RoI_Filter(std::vector<TrigSiSpacePointBase>& vec, LayerCalculator& lc, const IRoiDescriptor* roi, bool filter_phi=true) : BaseSpacePointFilter(vec,lc), 
-      m_roi(roi), m_filter_phi(filter_phi) { }
-      virtual void operator()(const Trk::SpacePoint* p) {
-        if(m_filter_phi) {
-	  if( RoiUtil::contains( *m_roi, p->globalPosition().z(), p->globalPosition().perp(), p->globalPosition().phi() ) ) createSpacePoint(p);
+  public:
+  RoI_Filter(std::vector<TrigSiSpacePointBase>& vec, LayerCalculator& lc, const IRoiDescriptor* roi, 
+	     bool filter_phi=true,
+	     const std::map<Identifier, std::vector<long int> >* clusterMap=nullptr) : BaseSpacePointFilter(vec,lc), 
+      m_roi(roi), m_filter_phi(filter_phi), m_clusterMap(clusterMap) { }
+    virtual void operator()(const Trk::SpacePoint* p) {
+      
+      bool unused=true;
+      // if a cluster map is specified, use it to reject spacepoints where one or more clusters has already be used on a track
+      if (m_clusterMap) {
+	const std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*> clusterList =  p->clusterList();
+	if (clusterList.first) {
+	  Identifier id1=(clusterList.first)->identify();
+	  unused = m_clusterMap->find(id1)==m_clusterMap->end();
 	}
-	else {
-	  if( RoiUtil::containsZed(*m_roi, p->globalPosition().z(), p->globalPosition().perp() )) createSpacePoint(p);
+	if (clusterList.second) {
+	  Identifier id2=(clusterList.second)->identify();
+	  unused = unused && (m_clusterMap->find(id2)==m_clusterMap->end());
 	}
+	
+      }
+      
+      if(m_filter_phi) {
+	if( unused && RoiUtil::contains( *m_roi, p->globalPosition().z(), p->globalPosition().perp(), p->globalPosition().phi() ) ) createSpacePoint(p);
       }
-    private:
-      const IRoiDescriptor* m_roi;
-      bool m_filter_phi;
+      else {
+	if( unused && RoiUtil::containsZed(*m_roi, p->globalPosition().z(), p->globalPosition().perp() )) createSpacePoint(p);
+      }
+    }
+  private:
+    const IRoiDescriptor* m_roi;
+    bool m_filter_phi;
+    const std::map<Identifier, std::vector<long int> >* m_clusterMap;
   };
-
+  
   template < typename T> class SpacePointSelector {
   public:
   SpacePointSelector(T& t) : m_filter(t), m_hash2layer(nullptr), m_pIDC(nullptr) {};
diff --git a/Trigger/TrigTools/TrigOnlineSpacePointTool/src/TrigSpacePointConversionTool.cxx b/Trigger/TrigTools/TrigOnlineSpacePointTool/src/TrigSpacePointConversionTool.cxx
index 5206c65d27f..c083ba3ca1d 100644
--- a/Trigger/TrigTools/TrigOnlineSpacePointTool/src/TrigSpacePointConversionTool.cxx
+++ b/Trigger/TrigTools/TrigOnlineSpacePointTool/src/TrigSpacePointConversionTool.cxx
@@ -34,6 +34,7 @@ TrigSpacePointConversionTool::TrigSpacePointConversionTool(const std::string& t,
   declareProperty( "layerNumberTool",        m_layerNumberTool);
   declareProperty( "PixelSP_ContainerName",  m_pixelSpacePointsContainerKey = std::string("PixelTrigSpacePoints"));
   declareProperty( "SCT_SP_ContainerName",   m_sctSpacePointsContainerKey = "SCT_TrigSpacePoints" );
+  declareProperty( "UsePixelSpacePoints",    m_usePixelSpacePoints = true );
 }
 
 StatusCode TrigSpacePointConversionTool::initialize() {
@@ -83,6 +84,8 @@ StatusCode TrigSpacePointConversionTool::initialize() {
   ATH_CHECK(m_pixelSpacePointsContainerKey.initialize());
   ATH_CHECK(m_sctSpacePointsContainerKey.initialize());
 
+ if (!m_usePixelSpacePoints) ATH_MSG_INFO(" Only converting SCT spacepoints => SSS seeds only");
+
   ATH_MSG_INFO("TrigSpacePointConversionTool initialized ");
 
   return sc;
@@ -96,7 +99,7 @@ StatusCode TrigSpacePointConversionTool::finalize() {
 
 
 StatusCode TrigSpacePointConversionTool::getSpacePoints(const IRoiDescriptor& internalRoI, 
-							std::vector<TrigSiSpacePointBase>& output, int& nPix, int& nSct, const EventContext& ctx) const {
+							std::vector<TrigSiSpacePointBase>& output, int& nPix, int& nSct, const EventContext& ctx, std::map<Identifier, std::vector<long int> > *clustermap) const {
 
   output.clear();
   
@@ -125,24 +128,43 @@ StatusCode TrigSpacePointConversionTool::getSpacePoints(const IRoiDescriptor& in
   FTF::LayerCalculator lc(m_atlasId, m_pixelId, m_sctId, offsets);
     
   //filter spacepoints to reject those beyound internalRoI boundaries
-    
-  FTF::RoI_Filter filter(output, lc, &internalRoI, m_filter_phi);
-  FTF::SpacePointSelector<FTF::RoI_Filter> selector(filter);
-  
+      
   nPix = 0;
   nSct = 0;
+  if ( clustermap!=nullptr ) { 
 
-  if(m_useNewScheme) {
-    nPix=selector.select(*pixelSpacePointsContainer,listOfPixIds, m_layerNumberTool->pixelLayers());
-    nSct=selector.select(*sctSpacePointsContainer,listOfSctIds, m_layerNumberTool->sctLayers());
-  }
-  else {
-    nPix=selector.select(*pixelSpacePointsContainer,listOfPixIds);
-    nSct=selector.select(*sctSpacePointsContainer,listOfSctIds);
+    ATH_MSG_DEBUG("LRT Mode: clustermap supplied and being used to remove spacepoints from clusters already on tracks");
+    //  In LRT mode a cluster map is supplied to enable removal of clusters on tracks.
+    FTF::RoI_Filter filter(output, lc, &internalRoI, m_filter_phi, clustermap);
+    FTF::SpacePointSelector<FTF::RoI_Filter> selector(filter);
+    
+    if(m_useNewScheme) {
+      if (m_usePixelSpacePoints)  nPix=selector.select(*pixelSpacePointsContainer,listOfPixIds, m_layerNumberTool->pixelLayers());
+      nSct=selector.select(*sctSpacePointsContainer,listOfSctIds, m_layerNumberTool->sctLayers());
+    }
+    else {
+      if (m_usePixelSpacePoints)  nPix=selector.select(*pixelSpacePointsContainer,listOfPixIds);
+      nSct=selector.select(*sctSpacePointsContainer,listOfSctIds);
+    }
+
+
+  } else {
+    FTF::RoI_Filter filter(output, lc, &internalRoI, m_filter_phi);
+    FTF::SpacePointSelector<FTF::RoI_Filter> selector(filter);
+    
+    if(m_useNewScheme) {
+      nPix=selector.select(*pixelSpacePointsContainer,listOfPixIds, m_layerNumberTool->pixelLayers());
+      nSct=selector.select(*sctSpacePointsContainer,listOfSctIds, m_layerNumberTool->sctLayers());
+    }
+    else {
+      nPix=selector.select(*pixelSpacePointsContainer,listOfPixIds);
+      nSct=selector.select(*sctSpacePointsContainer,listOfSctIds);
+    }
   }
   if(!m_useBeamTilt) shiftSpacePoints(output, ctx);
   else transformSpacePoints(output, ctx);
 
+  ATH_MSG_DEBUG("Returning "<<nPix<< " Pixel Spacepoints and "<<nSct<< " SCT SpacePoints");
   return StatusCode::SUCCESS;
 }
 
diff --git a/Trigger/TrigTools/TrigOnlineSpacePointTool/src/TrigSpacePointConversionTool.h b/Trigger/TrigTools/TrigOnlineSpacePointTool/src/TrigSpacePointConversionTool.h
index 3e2dfc61d0d..8462954d9f2 100644
--- a/Trigger/TrigTools/TrigOnlineSpacePointTool/src/TrigSpacePointConversionTool.h
+++ b/Trigger/TrigTools/TrigOnlineSpacePointTool/src/TrigSpacePointConversionTool.h
@@ -37,8 +37,8 @@ class TrigSpacePointConversionTool : virtual public ITrigSpacePointConversionToo
   StatusCode finalize() override;
 
   //concrete implementations
-
-  virtual StatusCode getSpacePoints(const IRoiDescriptor&, std::vector<TrigSiSpacePointBase>&, int&, int&, const EventContext& ctx) const override final;
+  virtual StatusCode getSpacePoints(const IRoiDescriptor&, std::vector<TrigSiSpacePointBase>&, int&, int&, const EventContext& ctx, std::map<Identifier, std::vector<long int> >*clustermap=nullptr) const override final;
+  
 
  protected:
 
@@ -57,6 +57,7 @@ class TrigSpacePointConversionTool : virtual public ITrigSpacePointConversionToo
   bool m_filter_phi;
   bool m_useBeamTilt;
   bool m_useNewScheme;
+  bool m_usePixelSpacePoints;
 
   void shiftSpacePoints(std::vector<TrigSiSpacePointBase>&, const EventContext&) const;
   void transformSpacePoints(std::vector<TrigSiSpacePointBase>&, const EventContext&) const;
-- 
GitLab