From 6e84908bef9d64565b923d6fb679562e50a0e138 Mon Sep 17 00:00:00 2001
From: John Baines <john.baines@cern.ch>
Date: Wed, 19 Dec 2018 15:13:52 +0100
Subject: [PATCH] Pseudomerge of FTK athena/Trigger packages from release 21 to
 master (part 1)

---
 .../python/TrigFastTrackFinder_Config.py      |   4 +-
 .../src/TrigFastTrackFinder.cxx               |  15 +-
 .../TrigFTK/FTKStandaloneMonitoring/README.md | 106 +++
 .../IFTK_DataProviderSvc.h                    |   4 +-
 .../FTK_DataProviderSvc/FTK_DataProviderSvc.h |  32 +-
 .../src/FTK_DataProviderSvc.cxx               | 424 ++++++-----
 .../python/FTK_DataProviderSvc_Config.py      | 201 ------
 .../FTK_RecExample/share/FTKRec_jobOptions.py |  44 +-
 .../IFTK_DuplicateTrackRemovalTool.h          |   3 +
 .../FTK_RecToolInterfaces/IFTK_HashIDTool.h   |  30 +
 Trigger/TrigFTK/FTK_RecTools/CMakeLists.txt   |  13 +-
 .../FTK_RecTools/FTK_HashIDTool.h             | 139 ++++
 .../FTK_PixelClusterOnTrackTool.h             | 387 +++++-----
 .../FTK_RecTools/FTK_VertexFinderTool.h       |  25 +-
 .../src/FTK_DuplicateTrackRemovalTool.cxx     | 229 +++---
 .../FTK_RecTools/src/FTK_HashIDTool.cxx       | 529 ++++++++++++++
 .../src/FTK_PixelClusterOnTrackTool.cxx       |  16 +-
 .../src/FTK_SCTClusterOnTrackTool.cxx         |   8 +-
 .../src/components/FTK_RecTools_entries.cxx   |   2 +
 .../src/FTKByteStreamDecoderEncoder.cxx       |  33 +-
 .../src/FTKByteStreamDecoderEncoder.h         |   3 +-
 .../src/FTKByteStreamDecoderEncoderAux.cxx    |  66 +-
 .../src/FTKByteStreamDecoderEncoderAux.h      |  10 +-
 .../src/TrigFTKByteStreamTool.cxx             |   2 +-
 Trigger/TrigFTK/TrigFTKPool/CMakeLists.txt    |   5 +-
 .../TrigFTK_Monitoring/FtkHltEfficiencyFex.h  |  30 +-
 .../python/FtkHltEfficiencyConfig.py          |   4 +-
 .../python/FtkHltEfficiencyMonitoring.py      | 108 ++-
 .../src/FtkHltEfficiencyFex.cxx               |  83 ++-
 .../TrigFTK/TrigFTK_RawData/CMakeLists.txt    |   9 +-
 .../TrigFTK_RawData/FTK_RawTrack.h            |  15 +-
 .../TrigFTK/TrigFTK_RawData/src/EigenHalf.h   | 673 ++++++++++++++++++
 .../TrigFTK_RawData/src/FTK_RawTrack.cxx      | 180 +++--
 .../TrigFTK_RawDataAlgs/CMakeLists.txt        |   5 +-
 .../share/FTKMonitor_topOptions.py            |   3 -
 .../src/FTK_RDO_CreatorAlgo.cxx               |  24 +-
 .../src/FTK_RDO_MonitorAlgo.cxx               | 413 ++++-------
 .../src/FTK_RDO_MonitorAlgo.h                 |  22 +-
 .../src/FTK_RawTrackCnv_p1.cxx                |   4 -
 .../TrigFTK_RecAlgs/TrigFTK_VxPrimary.h       |   1 -
 .../TrigFTK_RecAlgs/TrigFTK_VxPrimaryAllTE.h  |   1 -
 .../TrigFTK_RecAlgs/src/TrigFTK_VxPrimary.cxx |   2 -
 .../src/TrigFTK_VxPrimaryAllTE.cxx            |   2 -
 .../python/TrigFTK_DataProviderSvc_Config.py  |  21 +-
 .../TrigFTKHypo/src/TrigFTKAvailableHypo.cxx  |   2 +-
 .../TrigFTKHypo/src/TrigFTKAvailableHypo.h    |   2 +-
 .../python/TrigInDetFTKSequence.py            |  24 +-
 .../python/TrigInDetRecToolsFTK.py            |   5 +
 48 files changed, 2737 insertions(+), 1226 deletions(-)
 create mode 100644 Trigger/TrigFTK/FTKStandaloneMonitoring/README.md
 delete mode 100644 Trigger/TrigFTK/FTK_RecExample/python/FTK_DataProviderSvc_Config.py
 create mode 100644 Trigger/TrigFTK/FTK_RecToolInterfaces/FTK_RecToolInterfaces/IFTK_HashIDTool.h
 create mode 100644 Trigger/TrigFTK/FTK_RecTools/FTK_RecTools/FTK_HashIDTool.h
 create mode 100644 Trigger/TrigFTK/FTK_RecTools/src/FTK_HashIDTool.cxx
 create mode 100644 Trigger/TrigFTK/TrigFTK_RawData/src/EigenHalf.h

diff --git a/Trigger/TrigAlgorithms/TrigFastTrackFinder/python/TrigFastTrackFinder_Config.py b/Trigger/TrigAlgorithms/TrigFastTrackFinder/python/TrigFastTrackFinder_Config.py
index f9595911bf2..31eb86f2ab0 100755
--- a/Trigger/TrigAlgorithms/TrigFastTrackFinder/python/TrigFastTrackFinder_Config.py
+++ b/Trigger/TrigAlgorithms/TrigFastTrackFinder/python/TrigFastTrackFinder_Config.py
@@ -473,8 +473,8 @@ class TrigFastTrackFinderBase(TrigFastTrackFinder):
           from TrigFTK_RecExample.TrigFTKLoadTools import theFTK_DataProviderSvc
           self.FTK_DataProviderSvc = theFTK_DataProviderSvc
           self.FTK_Mode=True
-        if type=="FTKRefit":    
-          self.FTK_Refit=True
+          if type=="FTKRefit":    
+              self.FTK_Refit=True
         else:
           #Spacepoint conversion
           from TrigOnlineSpacePointTool.TrigOnlineSpacePointToolConf import TrigSpacePointConversionTool
diff --git a/Trigger/TrigAlgorithms/TrigFastTrackFinder/src/TrigFastTrackFinder.cxx b/Trigger/TrigAlgorithms/TrigFastTrackFinder/src/TrigFastTrackFinder.cxx
index 9420fb63a10..9db5ee1bee0 100644
--- a/Trigger/TrigAlgorithms/TrigFastTrackFinder/src/TrigFastTrackFinder.cxx
+++ b/Trigger/TrigAlgorithms/TrigFastTrackFinder/src/TrigFastTrackFinder.cxx
@@ -296,6 +296,13 @@ HLT::ErrorCode TrigFastTrackFinder::hltInitialize() {
     m_TrackFitterTimer          = addTimer("TrackFitter","TrackFitter_nTracks");
   }
   
+    
+  auto scbs = m_beamSpotKey.initialize();
+  if(scbs.isFailure()) {
+    ATH_MSG_ERROR("Error initializing beamspot info");
+    return HLT::BAD_JOB_SETUP;
+  }
+
   if(m_ftkMode) {
     StatusCode sc= m_ftkDataProviderSvc.retrieve();
     if(sc.isFailure()) {
@@ -316,14 +323,6 @@ HLT::ErrorCode TrigFastTrackFinder::hltInitialize() {
     
     ATH_MSG_DEBUG(" TrigFastTrackFinder : MinHits set to " << m_minHits);
     
-    if (m_useBeamSpot) {
-      auto sc = m_beamSpotKey.initialize();
-      if(sc.isFailure()) {
-         ATH_MSG_ERROR("Error initializing beamspot info");
-         return HLT::BAD_JOB_SETUP;
-      }
-    }
-    
     StatusCode sc=m_numberingTool.retrieve(); 
     if(sc.isFailure()) { 
       ATH_MSG_ERROR("Could not retrieve "<<m_numberingTool); 
diff --git a/Trigger/TrigFTK/FTKStandaloneMonitoring/README.md b/Trigger/TrigFTK/FTKStandaloneMonitoring/README.md
new file mode 100644
index 00000000000..45472cd1a64
--- /dev/null
+++ b/Trigger/TrigFTK/FTKStandaloneMonitoring/README.md
@@ -0,0 +1,106 @@
+# Reference
+
+Explanation of the package structure in [FTKStandaloneMonitoringDoc](https://twiki.cern.ch/twiki/bin/view/Atlas/FTKStandaloneMonitoringDoc)
+
+
+# Check out (lxplus only)
+
+```
+setupATLAS 
+lsetup git
+mkdir testdir
+cd testdir
+git atlas init-workdir https://:@gitlab.cern.ch:8443/atlas-ftk/athena.git -p FTKStandaloneMonitoring
+cd athena/
+git checkout <present-branch> # a present branch, or:
+git checkout -b new-feature --no-track # new development, or:
+git checkout -b new-feature upstream/21.1 --no-track # or from upstream
+cd ..
+```
+
+#  Compilation
+
+if not already done
+```
+setupATLAS 
+lsetup git
+```
+
+for old athena releases e.g. 21.0.17,AtlasHLT
+```
+asetup 21.0.17,AtlasHLT,here
+mv CMakeLists.txt athena/
+cd athena
+rm -r Projects
+mv Trigger/TrigFTK/FTKStandaloneMonitoring/ .
+rm -r Trigger
+mkdir build
+cd build/
+cmake ../athena/
+make
+```
+
+for new athena releases
+```
+asetup 21.1.2,AthenaP1,here
+mkdir build
+cd build/
+cmake ../athena/Projects/WorkDir/
+make
+```
+#  Setup and Running
+
+* At lxplus
+
+```
+source x86*/setup.sh
+cd x86*/bin
+
+./MonitoringFTKHWSWComparison -f /eos/user/a/amaranti/FTK_DQM_tests/21.0.11_lxplus/OUT.BS_FTK.root -n /eos/user/a/amaranti/FTK_DQM_tests/20.11.2.6.2_AtlasP1MON_lxplus/FTKIPtoFTK/OUT.NTUP.root -s -v
+```
+* At P1
+
+first setup athena at P1:
+```
+source /det/ftk/ftk_setup.sh FTK-02-00-01
+export TDAQ_PARTITION=FTK-DQM-HWSWComparison
+alias asetup='. /sw/atlas/AtlasSetup/scripts/asetup.sh'
+asetup 21.1.2,AthenaP1,here
+```
+assuming you are in testdir
+```
+source build/x86*/setup.sh
+cd build/x86*/bin
+```
+
+running
+```
+./MonitoringFTKHWSWComparison -f /atlas-home/0/giulini/xTakashiAlex/files/alex.OUT.BS_FTK.root -n /atlas-home/0/giulini/xTakashiAlex/files/alex.OUT.NTUP.root
+```
+to be added if you are not running within the partition
+```
+ -p PARTITION_NAME 
+```
+
+to see the histograms:
+```
+oh_display 
+```
+
+click on Histogram repository and then on the partition name and again on the partition name
+
+#  Setup and running script from offline release at P1
+
+
+```
+source /det/ftk/ftk_setup.sh FTK-02-00-04
+export TDAQ_PARTITION=FTK-DQM-HWSWComparison
+alias asetup='. /sw/atlas/AtlasSetup/scripts/asetup.sh'
+asetup 21.1.4,AthenaP1,here
+MonitoringFTKHWSWComparison -f /atlas-home/0/giulini/xTakashiAlex/files/alex.OUT.BS_FTK.root -n /atlas-home/0/giulini/xTakashiAlex/files/alex.OUT.NTUP.root -p $TDAQ_PARTITION 
+```
+or without -p option if run within the partition
+```
+oh_display 
+```
+click on Histogram repository and then on the partition name and again on the partition name
diff --git a/Trigger/TrigFTK/FTK_DataProviderInterfaces/FTK_DataProviderInterfaces/IFTK_DataProviderSvc.h b/Trigger/TrigFTK/FTK_DataProviderInterfaces/FTK_DataProviderInterfaces/IFTK_DataProviderSvc.h
index 76d2493f2d9..2d63de11b84 100644
--- a/Trigger/TrigFTK/FTK_DataProviderInterfaces/FTK_DataProviderInterfaces/IFTK_DataProviderSvc.h
+++ b/Trigger/TrigFTK/FTK_DataProviderInterfaces/FTK_DataProviderInterfaces/IFTK_DataProviderSvc.h
@@ -11,7 +11,7 @@
 #include "AthenaKernel/IOVSvcDefs.h"
 #include "TrkTrack/Track.h"
 #include "TrkTrack/TrackCollection.h"
-#include "TrigFTK_RawData/FTK_RawTrack.h"
+#include "TrigFTK_RawData/FTK_RawTrackContainer.h"
 #include "IRegionSelector/IRoiDescriptor.h"
 #include "xAODTracking/VertexFwd.h"
 #include "xAODTracking/TrackParticleFwd.h"
@@ -41,6 +41,8 @@ public:
 
   /// Retrieve interface ID
   static const InterfaceID& interfaceID() { return IID_IFTK_DataProviderSvc; }
+
+  virtual const FTK_RawTrackContainer* getRawTracks() = 0;
   
   virtual TrackCollection* getTracks(const bool withRefit) = 0;
   virtual TrackCollection* getTracks(const bool withRefit, unsigned int& nErrors) = 0;
diff --git a/Trigger/TrigFTK/FTK_DataProviderSvc/FTK_DataProviderSvc/FTK_DataProviderSvc.h b/Trigger/TrigFTK/FTK_DataProviderSvc/FTK_DataProviderSvc/FTK_DataProviderSvc.h
index 93ba02c47ca..67c6383f44c 100644
--- a/Trigger/TrigFTK/FTK_DataProviderSvc/FTK_DataProviderSvc/FTK_DataProviderSvc.h
+++ b/Trigger/TrigFTK/FTK_DataProviderSvc/FTK_DataProviderSvc/FTK_DataProviderSvc.h
@@ -14,17 +14,11 @@
 #include "StoreGate/ReadCondHandleKey.h"
 #include "StoreGate/StoreGateSvc.h"
 #include "GaudiKernel/IIncidentListener.h"
-//#include "IRegionSelector/IRoiDescriptor.h"
-//#include "TrkTrack/TrackCollection.h"
 #include "TrigFTK_RawData/FTK_RawTrack.h"
 #include "TrigFTK_RawData/FTK_RawTrackContainer.h"
 #include "TrkTrack/TrackCollection.h"
 #include "FTK_DataProviderInterfaces/IFTK_DataProviderSvc.h"
 
-//#include "TrkFitterInterfaces/ITrackFitter.h"
-//#include "TrkFitterUtils/FitterTypes.h"
-//#include "InDetRIO_OnTrack/SiClusterOnTrack.h"
-//#include "InDetRIO_OnTrack/PixelClusterOnTrack.h"
 #include "TrkRIO_OnTrack/RIO_OnTrack.h"
 #include "InDetPrepRawData/PixelClusterCollection.h"
 #include "InDetPrepRawData/SCT_ClusterCollection.h"
@@ -37,11 +31,12 @@
 #include "xAODTracking/TrackParticleContainer.h"
 #include "FTK_DataProviderInterfaces/IFTK_UncertaintyTool.h"
 #include "FTK_RecToolInterfaces/IFTK_DuplicateTrackRemovalTool.h"
-#include "PixelConditionsData/PixelOfflineCalibData.h"
 #include "InDetCondServices/ISiLorentzAngleTool.h"
+#include "PixelConditionsData/PixelOfflineCalibData.h"
 
 #include <mutex>
 #include <vector>
+#include "FTK_RecToolInterfaces/IFTK_HashIDTool.h"
 
 /// Forward Declarations ///
 class AtlasDetectorID;
@@ -91,6 +86,9 @@ class FTK_DataProviderSvc : public virtual IFTK_DataProviderSvc, virtual public
  virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvInterface);
  virtual StatusCode initialize();
  virtual StatusCode finalize();
+
+ virtual const FTK_RawTrackContainer* getRawTracks();
+
  virtual TrackCollection* getTracksInRoi(const IRoiDescriptor&, const bool withRefit);
  virtual TrackCollection* getTracksInRoi(const IRoiDescriptor&, const bool withRefit, unsigned int& nErrors);
 
@@ -145,8 +143,8 @@ class FTK_DataProviderSvc : public virtual IFTK_DataProviderSvc, virtual public
  bool fillVertexContainerCache(bool withRefit, xAOD::TrackParticleContainer*);
 
  
- const Trk::RIO_OnTrack* createPixelCluster(const FTK_RawPixelCluster& raw_pixel_cluster,  const Trk::TrackParameters& trkPerigee);
- const Trk::RIO_OnTrack* createSCT_Cluster( const FTK_RawSCT_Cluster& raw_sct_cluster, const Trk::TrackParameters& trkPerigee);
+ const Trk::RIO_OnTrack* createPixelCluster(const IdentifierHash hash, const FTK_RawPixelCluster& raw_pixel_cluster,  const Trk::TrackParameters& trkPerigee);
+ const Trk::RIO_OnTrack* createSCT_Cluster(const IdentifierHash hash, const FTK_RawSCT_Cluster& raw_sct_cluster, const Trk::TrackParameters& trkPerigee);
  
  StatusCode getTruthCollections();
  void createSCT_Truth(Identifier id, int barCode);
@@ -155,6 +153,9 @@ class FTK_DataProviderSvc : public virtual IFTK_DataProviderSvc, virtual public
  InDet::SCT_ClusterCollection*  getSCT_ClusterCollection(IdentifierHash hashId);
  InDet::PixelClusterCollection* getPixelClusterCollection(IdentifierHash hashId);
 
+ unsigned int getPixelHashID(const FTK_RawTrack& track, unsigned int iclus);
+ unsigned int getSCTHashID(const FTK_RawTrack& track, unsigned int iclus);
+   
 
 
  private:
@@ -171,8 +172,8 @@ class FTK_DataProviderSvc : public virtual IFTK_DataProviderSvc, virtual public
 
   const AtlasDetectorID* m_id_helper;
 
-  SG::ReadCondHandleKey<PixelCalib::PixelOfflineCalibData> m_clusterErrorKey{this, "PixelOfflineCalibData", "PixelOfflineCalibData", "Output key of pixel cluster"};
   SG::ReadCondHandleKey<InDetDD::SiDetectorElementCollection> m_SCTDetEleCollKey{this, "SCTDetEleCollKey", "SCT_DetectorElementCollection", "Key of SiDetectorElementCollection for SCT"};
+  SG::ReadCondHandleKey<PixelCalib::PixelOfflineCalibData> m_clusterErrorKey{this, "PixelOfflineCalibData", "PixelOfflineCalibData", "Output key of pixel cluster"};
 
   ToolHandle<IFTK_UncertaintyTool> m_uncertaintyTool;
   ToolHandle<Trk::ITrackFitter> m_trackFitter;
@@ -185,6 +186,7 @@ class FTK_DataProviderSvc : public virtual IFTK_DataProviderSvc, virtual public
   ToolHandle< IFTK_DuplicateTrackRemovalTool > m_DuplicateTrackRemovalTool;
   ToolHandle<ISiLorentzAngleTool> m_pixelLorentzAngleTool{this, "PixelLorentzAngleTool", "SiLorentzAngleTool/PixelLorentzAngleTool", "Tool to retrieve Lorentz angle of Pixel"};
   ToolHandle<ISiLorentzAngleTool> m_sctLorentzAngleTool{this, "SCTLorentzAngleTool", "SiLorentzAngleTool/SCTLorentzAngleTool", "Tool to retrieve Lorentz angle of SCT"};
+  ToolHandle<IFTK_HashIDTool> m_hashIDTool;
 
   double m_trainingBeamspotX;
   double m_trainingBeamspotY;
@@ -271,7 +273,10 @@ class FTK_DataProviderSvc : public virtual IFTK_DataProviderSvc, virtual public
   std::vector<unsigned int> m_nMissingPixelClusters;
 
   bool m_reverseIBLlocx;
+  bool m_doVertexing;
   bool m_doVertexSorting;
+  bool m_processAuxTracks;
+  bool m_getHashIDfromConstants;
 
   // Mutex to protect the contents.
   mutable std::mutex m_mutex;
@@ -279,15 +284,12 @@ class FTK_DataProviderSvc : public virtual IFTK_DataProviderSvc, virtual public
   mutable std::vector<EventContext::ContextEvt_t> m_cacheSCTElements;
   // Pointer of InDetDD::SiDetectorElementCollection
   mutable Gaudi::Hive::ContextSpecificPtr<const InDetDD::SiDetectorElementCollection> m_SCTDetectorElements;  
+
+
 };
 
 inline bool compareFTK_Clusters (const Trk::RIO_OnTrack* cl1, const Trk::RIO_OnTrack* cl2) {
    
-  //  double r1 = cl1->globalPosition().x()*cl1->globalPosition().x() + cl1->globalPosition().y()*cl1->globalPosition().y();
-  //double r2 = cl2->globalPosition().x()*cl2->globalPosition().x() + cl2->globalPosition().y()*cl2->globalPosition().y();
-  //r1+=cl1->globalPosition().z()*cl1->globalPosition().z();
-  //r2+=cl2->globalPosition().z()*cl2->globalPosition().z();
-
   return (cl1->globalPosition().mag()<cl2->globalPosition().mag());
   
 }
diff --git a/Trigger/TrigFTK/FTK_DataProviderSvc/src/FTK_DataProviderSvc.cxx b/Trigger/TrigFTK/FTK_DataProviderSvc/src/FTK_DataProviderSvc.cxx
index 83f3ebdf22a..9c78c54b70b 100644
--- a/Trigger/TrigFTK/FTK_DataProviderSvc/src/FTK_DataProviderSvc.cxx
+++ b/Trigger/TrigFTK/FTK_DataProviderSvc/src/FTK_DataProviderSvc.cxx
@@ -51,6 +51,7 @@
 #include "TrkFitterInterfaces/ITrackFitter.h"
 #include "TrkToolInterfaces/ITrackSummaryTool.h"
 #include "TrkTrackSummary/TrackSummary.h"
+#include "FTK_RecToolInterfaces/IFTK_HashIDTool.h"
 #include "FTK_RecToolInterfaces/IFTK_DuplicateTrackRemovalTool.h"
 #include "FTK_RecToolInterfaces/IFTK_VertexFinderTool.h"
 #include "TrkVertexFitterInterfaces/IVertexCollectionSortingTool.h"
@@ -107,6 +108,7 @@ FTK_DataProviderSvc::FTK_DataProviderSvc(const std::string& name, ISvcLocator* s
   m_RawVertexFinderTool("FTK_VertexFinderTool"),
   m_ROTcreator("Trk::IRIO_OnTrackCreator/FTK_ROTcreatorTool"),
   m_DuplicateTrackRemovalTool("FTK_DuplicateTrackRemovalTool"),
+  m_hashIDTool("FTK_HashIDTool"),
   m_trainingBeamspotX(0.),
   m_trainingBeamspotY(0.),
   m_trainingBeamspotZ(0.),
@@ -156,9 +158,11 @@ FTK_DataProviderSvc::FTK_DataProviderSvc(const std::string& name, ISvcLocator* s
   m_dEtaCut(0.6),
   m_nErrors(0),
   m_reverseIBLlocx(false),
+  m_doVertexing(true),
   m_doVertexSorting(true),
-  m_mutex{},
-  m_cacheSCTElements{}
+  m_processAuxTracks(false), 
+  m_getHashIDfromConstants(false)
+
 {
 
   declareProperty("TrackCollectionName",m_trackCacheName);
@@ -168,6 +172,7 @@ FTK_DataProviderSvc::FTK_DataProviderSvc(const std::string& name, ISvcLocator* s
   declareProperty("UncertaintyTool",m_uncertaintyTool);
   declareProperty("TrackSummaryTool", m_trackSumTool);
   declareProperty("DuplicateTrackRemovalTool",m_DuplicateTrackRemovalTool);
+  declareProperty("HashIDTool",m_hashIDTool);
   declareProperty("TrackParticleCreatorTool", m_particleCreatorTool);
   declareProperty("VertexFinderTool",m_VertexFinderTool);
   declareProperty("ROTcreatorTool",m_ROTcreator);
@@ -199,7 +204,9 @@ FTK_DataProviderSvc::FTK_DataProviderSvc(const std::string& name, ISvcLocator* s
   declareProperty("setBroadSCT_ClusterOnTrackErrors",m_broadSCT_Errors);
   declareProperty("RemoveDuplicates",m_remove_duplicates);
   declareProperty("ReverseIBLlocX",m_reverseIBLlocx, "reverse the direction of IBL locX from FTK");
-
+  declareProperty("DoVertexing",m_doVertexing, "Enable Vertexing methods");
+  declareProperty("ProcessAuxTracks",m_processAuxTracks, "process Aux Tracks ");
+  declareProperty("HashIDfromConstants",m_getHashIDfromConstants, "Get HashID from Constants");
 
 }
 
@@ -241,6 +248,10 @@ std::string FTK_DataProviderSvc::getFastVertexCacheName(const bool withRefit) {
 StatusCode FTK_DataProviderSvc::initialize() {
 
   /// Setup StoreGateSvc ///
+  if (m_remove_duplicates && m_processAuxTracks) {
+    ATH_MSG_WARNING(" Both RemoveDuplicates and ProcessAuxTracks requested, but can't do Duplicate Track Removal when processing Aux tracks - returning StatusCode::FAILURE");
+    return StatusCode::FAILURE;
+  }
 
   ATH_CHECK(service( "StoreGateSvc", m_storeGate ));
   StoreGateSvc* detStore;
@@ -248,7 +259,7 @@ StatusCode FTK_DataProviderSvc::initialize() {
   ATH_CHECK(m_clusterErrorKey.initialize());
   ATH_CHECK(detStore->retrieve(m_pixelId, "PixelID"));
   ATH_CHECK(detStore->retrieve(m_sctId, "SCT_ID"));
-  ATH_CHECK(detStore->retrieve(m_pixelManager));
+  ATH_CHECK(detStore->retrieve(m_pixelManager,"Pixel"));
   ATH_CHECK(detStore->retrieve(m_id_helper, "AtlasID"));
   ATH_MSG_INFO( " getting UncertaintyTool with name " << m_uncertaintyTool.name());
   ATH_CHECK(m_uncertaintyTool.retrieve());
@@ -258,18 +269,30 @@ StatusCode FTK_DataProviderSvc::initialize() {
   ATH_CHECK(m_trackSumTool.retrieve());
   ATH_MSG_INFO( " getting particleCreatorTool tool with name " << m_particleCreatorTool.name());
   ATH_CHECK(m_particleCreatorTool.retrieve());
-  ATH_MSG_INFO( " getting vertexFinderTool tool with name " << m_VertexFinderTool.name());
-  ATH_CHECK(m_VertexFinderTool.retrieve());
-  if (m_doVertexSorting) { 
-    ATH_MSG_INFO( " getting vertexCollectionSortingTool tool with name " << m_VertexCollectionSortingTool.name());
-    ATH_CHECK(m_VertexCollectionSortingTool.retrieve());
-  }
-  ATH_MSG_INFO( " getting DuplicateTrackRemovalTool tool with name " << m_DuplicateTrackRemovalTool.name());
-  ATH_CHECK(m_DuplicateTrackRemovalTool.retrieve());
-  ATH_MSG_INFO( " getting FTK_RawTrackVertexFinderTool tool with name " << m_RawVertexFinderTool.name());
-  ATH_CHECK(m_RawVertexFinderTool.retrieve());
-  ATH_MSG_INFO( " getting ROTcreator tool with name " << m_ROTcreator.name());
-  ATH_CHECK(m_ROTcreator.retrieve());
+  if (m_doVertexing) {
+    ATH_MSG_INFO( " getting FTK_RawTrackVertexFinderTool tool with name " << m_RawVertexFinderTool.name());
+    ATH_CHECK(m_RawVertexFinderTool.retrieve());
+    ATH_MSG_INFO( " getting vertexFinderTool tool with name " << m_VertexFinderTool.name());
+    ATH_CHECK(m_VertexFinderTool.retrieve());
+    if (m_doVertexSorting) { 
+      ATH_MSG_INFO( " getting vertexCollectionSortingTool tool with name " << m_VertexCollectionSortingTool.name());
+      ATH_CHECK(m_VertexCollectionSortingTool.retrieve());
+    }
+  } else {
+    ATH_MSG_INFO( " Vertex Finding is Disabled");
+  }
+  if (m_remove_duplicates) {
+    ATH_MSG_INFO( " getting DuplicateTrackRemovalTool tool with name " << m_DuplicateTrackRemovalTool.name());
+    ATH_CHECK(m_DuplicateTrackRemovalTool.retrieve());
+  }
+  if (m_processAuxTracks or m_getHashIDfromConstants) {
+    ATH_MSG_INFO( " getting HashIDTool tool with name " << m_hashIDTool.name());
+    ATH_CHECK(m_hashIDTool.retrieve());
+  }
+  if (m_correctPixelClusters|| m_correctSCTClusters) {
+    ATH_MSG_INFO( " getting ROTcreator tool with name " << m_ROTcreator.name());
+    ATH_CHECK(m_ROTcreator.retrieve());
+  }
   ATH_CHECK(m_pixelLorentzAngleTool.retrieve());
   ATH_CHECK(m_sctLorentzAngleTool.retrieve());
 
@@ -289,6 +312,13 @@ StatusCode FTK_DataProviderSvc::initialize() {
   ATH_MSG_INFO( "PRD Truth SCT name: " << m_ftkSctTruthName);
   ATH_MSG_INFO( "PRD Truth Pixel name : " << m_ftkPixelTruthName);
 
+  if (m_processAuxTracks) {
+    ATH_MSG_INFO( "Processing AUX format tracks ");
+  }
+  if (m_getHashIDfromConstants) {
+    ATH_MSG_INFO( "getting HashId from Constants ");
+  }
+
   ATH_MSG_INFO( "Correcting for FTK training beamspot at x " <<  m_trainingBeamspotX <<" y " << 	m_trainingBeamspotY
       << " z " <<  m_trainingBeamspotZ << " TiltX " << m_trainingBeamspotTiltX << "TiltY " << m_trainingBeamspotTiltY );
   ATH_MSG_INFO( " Pixel Barrel Phi Offsets (pixels): " << m_pixelBarrelPhiOffsets);
@@ -744,7 +774,7 @@ xAOD::VertexContainer* FTK_DataProviderSvc::getFastVertices(const ftk::FTK_Track
        }
        sc = m_storeGate->record(vertices.second, cacheName+"Aux.");
        if (sc.isFailure()) {
-	 ATH_MSG_DEBUG( "fillVertexContainerCache: Failed to record VertexAuxCollection " << cacheName );
+	 ATH_MSG_DEBUG( "getFastVertices: Failed to record VertexAuxCollection " << cacheName );
 	 delete(vertices.second);
 	 return userVertex;
        }
@@ -779,7 +809,7 @@ xAOD::VertexContainer* FTK_DataProviderSvc::getFastVertices(const ftk::FTK_Track
 	}
 	sc = m_storeGate->record(vertices.second, cacheName+"Aux.");
 	if (sc.isFailure()) {
-	  ATH_MSG_DEBUG( "fillVertexContainerCache: Failed to record VertexAuxCollection " << cacheName );
+	  ATH_MSG_DEBUG( "getFastVertices: Failed to record VertexAuxCollection " << cacheName );
 	  delete(vertices.second);
 	  return  userVertex;
 	}
@@ -807,7 +837,7 @@ xAOD::VertexContainer* FTK_DataProviderSvc::getFastVertices(const ftk::FTK_Track
          }
 	 sc = m_storeGate->record(vertices.second, cacheName+"Aux.");
 	 if (sc.isFailure()) {
-	   ATH_MSG_DEBUG( "fillVertexContainerCache: Failed to record VertexAuxCollection " << cacheName );
+	   ATH_MSG_DEBUG( "getFastVertices: Failed to record VertexAuxCollection " << cacheName );
 	   delete(vertices.second);
 	   return userVertex;
 	 }
@@ -826,53 +856,68 @@ xAOD::VertexContainer* FTK_DataProviderSvc::getFastVertices(const ftk::FTK_Track
 bool FTK_DataProviderSvc::fillVertexContainerCache(bool withRefit, xAOD::TrackParticleContainer* tps) {
 
   bool gotVertices = false;
+
+  xAOD::VertexContainer* myVertexContainer = nullptr;
+  xAOD::VertexAuxContainer* myVertexAuxContainer = nullptr;
+  std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*> myVxContainers = std::make_pair( myVertexContainer, myVertexAuxContainer );
+  
   if (tps->size() > 1) {
     ATH_MSG_DEBUG( "fillVertexContainerCache: finding vertices from " << tps->size() << " TrackParticles ");
-
+    
     std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*> theXAODContainers = m_VertexFinderTool->findVertex(tps);
-
-    ATH_MSG_DEBUG( "fillVertexContainerCache: got "<< theXAODContainers.first->size() << " vertices");
-    if (theXAODContainers.first == nullptr) return gotVertices;
-
-    xAOD::VertexContainer* myVertexContainer = 0;
-    xAOD::VertexAuxContainer* myVertexAuxContainer = 0;
-    std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*> myVxContainers = std::make_pair( myVertexContainer, myVertexAuxContainer );
     
-    if (theXAODContainers.first->size() >1 && m_doVertexSorting) {
-      myVxContainers = m_VertexCollectionSortingTool->sortVertexContainer(*theXAODContainers.first);
-      delete theXAODContainers.first; 
-      delete theXAODContainers.second; 
-    } else {
-      myVxContainers.first = theXAODContainers.first;
-      myVxContainers.second = theXAODContainers.second;
-    }
-    if (myVxContainers.first == nullptr) return gotVertices;
-    if (not myVxContainers.first->hasStore()) return gotVertices;
-
-    std::string cacheName= m_vertexCacheName;
-    if (withRefit) cacheName+="Refit";
+    if (theXAODContainers.first != nullptr) {
+      
+      if (theXAODContainers.first->size() >1 && m_doVertexSorting) {
+	ATH_MSG_DEBUG( "doing vertex sorting");
+	myVxContainers = m_VertexCollectionSortingTool->sortVertexContainer(*theXAODContainers.first);
+	delete theXAODContainers.first; 
+	delete theXAODContainers.second; 
+      } else {
+	ATH_MSG_DEBUG( "NOT doing vertex sorting");
 
-    StatusCode sc = m_storeGate->record(myVxContainers.first, cacheName);
-    if (sc.isFailure()) {
-      ATH_MSG_DEBUG( "fillVertexContainerCache: Failed to record VertexCollection " << cacheName );
-      delete(myVxContainers.first);
-      delete(myVxContainers.second);
-      return gotVertices;
+	myVxContainers.first = theXAODContainers.first;
+	myVxContainers.second = theXAODContainers.second;
+      }
+      if (myVxContainers.first != nullptr && myVxContainers.first->hasStore()) gotVertices=true;
     }
+  }
+  if (!gotVertices) {
+    ATH_MSG_DEBUG( "failed to make vertices, creating empty collection");
+    myVxContainers.first = new  xAOD::VertexContainer();
+    myVxContainers.second = new  xAOD::VertexAuxContainer();
+    myVxContainers.first->setStore( myVxContainers.second);
+    gotVertices=true;
+  }
+  
+  std::string cacheName= m_vertexCacheName;
+  if (withRefit) cacheName+="Refit";
+  
+  StatusCode sc = m_storeGate->record(myVxContainers.first, cacheName);
+  if (sc.isFailure()) {
+    ATH_MSG_DEBUG( "fillVertexContainerCache: Failed to record VertexCollection " << cacheName );
+    delete(myVxContainers.first);
+    delete(myVxContainers.second);
+    gotVertices=false;
+  } else {
     sc = m_storeGate->record(myVxContainers.second, cacheName+"Aux.");
     if (sc.isFailure()) {
       ATH_MSG_DEBUG( "fillVertexContainerCache: Failed to record VertexAuxCollection " << cacheName );
       delete(myVxContainers.second);
-      return gotVertices;
+      gotVertices=false;
     }
+  }
+  
+  if (gotVertices) {
     if (withRefit) {
       m_refit_vertex = myVxContainers.first;
     } else {
       m_conv_vertex = myVxContainers.first;
     }
-    gotVertices=true;
+    
+    ATH_MSG_DEBUG( "fillVertexContainerCache: got "<< myVxContainers.first->size() << " vertices");
   }
-
+    
   return gotVertices;
 }
 
@@ -884,63 +929,72 @@ xAOD::VertexContainer* FTK_DataProviderSvc::getVertexContainer(const bool withRe
    xAOD::VertexContainer* userVertex = new xAOD::VertexContainer(SG::VIEW_ELEMENTS);
 #endif
 
-  if (fillTrackParticleCache(withRefit).isFailure()) {
-
-    // must always create a VertexContainer in StroreGate
+   bool doVertexing = m_doVertexing;
+   if (this->nRawTracks() <2) doVertexing = false;
+   if (doVertexing) {
+     if (fillTrackParticleCache(withRefit).isSuccess()) {
+       if (withRefit && m_refit_tp->size()<2) doVertexing=false;
+       if ((!withRefit) && m_conv_tp->size()<2) doVertexing=false;
+     }
+   }
+   if (!doVertexing) {
 
-    std::string cacheName= m_vertexCacheName;
-    if (withRefit) cacheName+="Refit";
-    if (!m_storeGate->contains<xAOD::VertexContainer>(cacheName)) {
-      xAOD::VertexContainer* vertex = new xAOD::VertexContainer();
-      xAOD::VertexAuxContainer* vertexAux =new xAOD::VertexAuxContainer();
-      vertex->setStore(vertexAux);
+     // must always create a VertexContainer in StoreGate
+     
+     std::string cacheName= m_vertexCacheName;
+     if (withRefit) cacheName+="Refit";
+     if (!m_storeGate->contains<xAOD::VertexContainer>(cacheName)) {
+       xAOD::VertexContainer* vertex = new xAOD::VertexContainer();
+       xAOD::VertexAuxContainer* vertexAux =new xAOD::VertexAuxContainer();
+       vertex->setStore(vertexAux);
       StatusCode sc = m_storeGate->record(vertex, cacheName);
       if (sc.isFailure()) {
-	ATH_MSG_DEBUG( "fillVertexContainerCache: Failed to record VertexCollection " << cacheName );
+	ATH_MSG_DEBUG( "getVertexContainer: Failed to record VertexCollection " << cacheName );
 	delete(vertex);
 	delete(vertexAux);
       } else {
 	sc = m_storeGate->record(vertexAux, cacheName+"Aux.");
 	if (sc.isFailure()) {
-	  ATH_MSG_DEBUG( "fillVertexContainerCache: Failed to record VertexAuxCollection " << cacheName );
+	  ATH_MSG_DEBUG( "getVertexContainer: Failed to record VertexAuxCollection " << cacheName );
 	  delete(vertexAux);
+	} else {
+	  ATH_MSG_DEBUG( "recorded empty VertexContainer in storegate");
 	}
       }
-    }
- 	  
-    return userVertex;
-  }
+     }	  
+     return userVertex;
+   }
 
-  if (withRefit) { // get vertex from refitted tracks
-    if (!m_got_refit_vertex) {
-      ATH_MSG_DEBUG( "getVertexContainer: filling VertexContainer from refitted tracks ");
+   if (withRefit) { // get vertex from refitted tracks
+     if (!m_got_refit_vertex) {
+       ATH_MSG_DEBUG( "getVertexContainer: filling VertexContainer from refitted tracks ");
       m_got_refit_vertex = fillVertexContainerCache(withRefit, m_refit_tp);
-    }
-    if (m_got_refit_vertex) {
-      ATH_MSG_DEBUG( "getVertexContainer: cache contains " << m_refit_vertex->size() <<  " vertices from refitted tracks");
-      for (auto pv = m_refit_vertex->begin(); pv != m_refit_vertex->end(); ++pv) {
-        userVertex->push_back(*pv);
-      }
-    }
-  } else {   // get vertex from converted tracks
-    if (!m_got_conv_vertex) {
-      ATH_MSG_DEBUG( "getVertexContainer: filling VertexContainer from converted tracks ");
-      m_got_conv_vertex = fillVertexContainerCache(withRefit, m_conv_tp);
-    }
-    if (m_got_conv_vertex) {
-      ATH_MSG_DEBUG( "getVertexContainer: cache contains " << m_conv_vertex->size() <<  " vertices from converted tracks");
-      for (auto pv = m_conv_vertex->begin(); pv != m_conv_vertex->end(); ++pv) {
-        userVertex->push_back(*pv);
-      }
-    }
-  }
-  return userVertex;
-
+     }
+     if (m_got_refit_vertex) {
+       ATH_MSG_DEBUG( "getVertexContainer: cache contains " << m_refit_vertex->size() <<  " vertices from refitted tracks");
+       for (auto pv = m_refit_vertex->begin(); pv != m_refit_vertex->end(); ++pv) {
+	 userVertex->push_back(*pv);
+       }
+     }
+   } else {   // get vertex from converted tracks
+     if (!m_got_conv_vertex) {
+       ATH_MSG_DEBUG( "getVertexContainer: filling VertexContainer from converted tracks ");
+       m_got_conv_vertex = fillVertexContainerCache(withRefit, m_conv_tp);
+     }
+     if (m_got_conv_vertex) {
+       ATH_MSG_DEBUG( "getVertexContainer: cache contains " << m_conv_vertex->size() <<  " vertices from converted tracks");
+       for (auto pv = m_conv_vertex->begin(); pv != m_conv_vertex->end(); ++pv) {
+	 userVertex->push_back(*pv);
+       }
+     }
+   }
+   return userVertex;
 }
+  
 
 StatusCode FTK_DataProviderSvc::getVertexContainer(xAOD::VertexContainer* userVertex, const bool withRefit){
 
-  if (fillTrackParticleCache(withRefit).isFailure()) {
+  if ((!m_doVertexing) || fillTrackParticleCache(withRefit).isFailure()) {
     // must always create a VertexContainer in StroreGate
     
     std::string cacheName= m_vertexCacheName;
@@ -1003,6 +1057,13 @@ TrackCollection* FTK_DataProviderSvc::getTracks(const bool withRefit, unsigned i
   return tracks;
 }
 
+const FTK_RawTrackContainer* FTK_DataProviderSvc::getRawTracks() {
+  getFTK_RawTracksFromSG();
+  ATH_MSG_DEBUG("FTK_DataProviderSvc::getRawTracks: m_ftk_tracks " << std::hex << m_ftk_tracks << std::dec);
+
+  return (m_gotRawTracks?  m_ftk_tracks : nullptr);
+}
+
 TrackCollection* FTK_DataProviderSvc::getTracks(const bool withRefit){
 
 #ifdef  FTK_useViewVector
@@ -1182,11 +1243,11 @@ Trk::Track* FTK_DataProviderSvc::getCachedTrack(const unsigned int ftk_track_ind
 
 void FTK_DataProviderSvc::getFTK_RawTracksFromSG(){
   /// get the FTK Track pointers from StoreGate ///
-
+  
   if (!m_newEvent) return;
   m_newEvent=false;
-
-
+  
+  
   if(m_doTruth) {//get MC-truth collections
     m_collectionsReady=true;
     StatusCode sc = getTruthCollections();
@@ -1195,36 +1256,42 @@ void FTK_DataProviderSvc::getFTK_RawTracksFromSG(){
       m_collectionsReady=false;
     }
   }
-
+  
   // new event - get the tracks from StoreGate
   if (!m_storeGate->contains<FTK_RawTrackContainer>(m_RDO_key)) {
     
     ATH_MSG_DEBUG( "getFTK_RawTracksFromSG: FTK tracks  "<< m_RDO_key <<" not found in StoreGate !");
-    return;
   } else {    
-    if (m_remove_duplicates){//get all tracks, and then call duplicate removal tool
-      const FTK_RawTrackContainer* temporaryTracks=nullptr;
-      StatusCode sc = m_storeGate->retrieve(temporaryTracks, m_RDO_key);
-      ATH_MSG_DEBUG( "getFTK_RawTracksFromSG:  Got " << temporaryTracks->size() << " raw FTK tracks (RDO) from  StoreGate ");
-      m_ftk_tracks = m_DuplicateTrackRemovalTool->removeDuplicates(temporaryTracks);
-      if (sc.isFailure()) {
-	ATH_MSG_WARNING( "getFTK_RawTracksFromSG: Failed to get FTK Tracks Container when using removeDumplicates ");
-	return;
+    
+    StatusCode sc = StatusCode::SUCCESS;
+    
+    const FTK_RawTrackContainer* temporaryTracks=nullptr;
+    sc = m_storeGate->retrieve(temporaryTracks, m_RDO_key);
+    if (sc.isFailure()) {
+      ATH_MSG_VERBOSE( "getFTK_RawTracksFromSG: Failed to get FTK Tracks Container");
+    } else {
+      if (m_processAuxTracks){//get all tracks, and then call hashIDTool to create new collection with track parameters & module ids set
+	ATH_MSG_DEBUG( "getFTK_RawTracksFromSG:  Got " << temporaryTracks->size() << " raw FTK tracks (RDO) from  StoreGate, now processing Aux Tracks");
+	
+	const FTK_RawTrackContainer* processed_tracks = m_hashIDTool->processTracks(*temporaryTracks,m_reverseIBLlocx);
+	
+	temporaryTracks = processed_tracks;
+	ATH_MSG_DEBUG( "getFTK_RawTracksFromSG:  After Aux Track processing " << temporaryTracks->size() << " Tracks");
+      } else if (m_remove_duplicates){//get all tracks, and then call duplicate removal tool
+	ATH_MSG_DEBUG( "getFTK_RawTracksFromSG:  Got " << temporaryTracks->size() << " raw FTK tracks (RDO) from  StoreGate before removeDuplicates");
+	const FTK_RawTrackContainer* new_tracks = m_DuplicateTrackRemovalTool->removeDuplicates(temporaryTracks);
+	temporaryTracks = new_tracks;
       }
-    } else{//the original way
-      ATH_MSG_VERBOSE( "getFTK_RawTracksFromSG:  Doing storegate retrieve");
-      StatusCode sc = m_storeGate->retrieve(m_ftk_tracks, m_RDO_key);
-      if (sc.isFailure()) {
-	ATH_MSG_WARNING( "getFTK_RawTracksFromSG: Failed to get FTK Tracks Container");
-	return;
+      
+      m_ftk_tracks = temporaryTracks;
+      
+      ATH_MSG_DEBUG( "getFTK_RawTracksFromSG:  Got " << m_ftk_tracks->size() << " raw FTK tracks (RDO) from  StoreGate ");
+      if (m_ftk_tracks->size()==0){
+	ATH_MSG_VERBOSE( "no FTK Tracks in the event");
+      } else {
+	m_gotRawTracks = true;
       }
-    }
-  }
-  if (m_ftk_tracks->size()==0){
-    ATH_MSG_VERBOSE( "no FTK Tracks in the event");
-  } else {
-    ATH_MSG_DEBUG( "getFTK_RawTracksFromSG:  Got " << m_ftk_tracks->size() << " raw FTK tracks (RDO) from  StoreGate ");
-    m_gotRawTracks = true;
+    }      
   }
   
   // Creating collection for pixel clusters
@@ -1410,7 +1477,7 @@ Trk::Track* FTK_DataProviderSvc::ConvertTrack(const unsigned int iTrack){
   // Find if the track includes IBL - needed for the error calculaton 
   for( unsigned int cluster_number = 0; cluster_number < track.getPixelClusters().size(); ++cluster_number){
     if ( !track.isMissingPixelLayer(cluster_number)) {
-      Identifier wafer_id = m_pixelId->wafer_id(Identifier(track.getPixelClusters()[cluster_number].getModuleID()));
+      Identifier wafer_id = m_pixelId->wafer_id(Identifier(this->getPixelHashID(track,cluster_number)));
       if (m_pixelId->barrel_ec(wafer_id)==0 && m_pixelId->layer_disk(wafer_id)==0) {
 	hasIBL=true;
 	break;
@@ -1485,21 +1552,22 @@ Trk::Track* FTK_DataProviderSvc::ConvertTrack(const unsigned int iTrack){
       m_nMissingPixelClusters[cluster_number]++;
       continue;
     }
-    if (raw_pixel_cluster.getModuleID()==0){
-      ATH_MSG_DEBUG( "hashId is " << raw_pixel_cluster.getModuleID() << " Layer " << cluster_number << " getWordA() "
-          << raw_pixel_cluster.getWordA() << " getWordB() " << raw_pixel_cluster.getWordB() );
-    }
-    const Trk::RIO_OnTrack* pixel_cluster_on_track = createPixelCluster(raw_pixel_cluster,*trkPerigee);
-    if (pixel_cluster_on_track==nullptr){
-      ATH_MSG_WARNING(" PixelClusterOnTrack failed to create cluster " << cluster_number);
+    if (this->getPixelHashID(track,cluster_number)>=m_pixelId->wafer_hash_max()){
+      ATH_MSG_DEBUG( "hashId is 0x" << std::hex<<this->getPixelHashID(track,cluster_number) << " MaxHash is 0x" << m_pixelId->wafer_hash_max() << std::dec << " Layer " << cluster_number);
       m_nFailedPixelClusters[cluster_number]++;
     } else {
-
-      clusters.push_back(pixel_cluster_on_track);
-
-      ATH_MSG_VERBOSE(cluster_number << ": r= " << std::sqrt(std::pow(pixel_cluster_on_track->globalPosition().x(),2)+pow(pixel_cluster_on_track->globalPosition().y(),2))
-		      << " z= " << pixel_cluster_on_track->globalPosition().z() << " phi " << pixel_cluster_on_track->globalPosition().phi() 
-		      << " eta= " << pixel_cluster_on_track->globalPosition().eta());
+      const Trk::RIO_OnTrack* pixel_cluster_on_track = createPixelCluster(this->getPixelHashID(track,cluster_number),raw_pixel_cluster,*trkPerigee);
+      if (pixel_cluster_on_track==nullptr){
+	ATH_MSG_WARNING(" PixelClusterOnTrack failed to create cluster " << cluster_number);
+	m_nFailedPixelClusters[cluster_number]++;
+      } else {
+	
+	clusters.push_back(pixel_cluster_on_track);
+	
+	ATH_MSG_VERBOSE(cluster_number << ": r= " << std::sqrt(std::pow(pixel_cluster_on_track->globalPosition().x(),2)+pow(pixel_cluster_on_track->globalPosition().y(),2))
+			<< " z= " << pixel_cluster_on_track->globalPosition().z() << " phi " << pixel_cluster_on_track->globalPosition().phi() 
+			<< " eta= " << pixel_cluster_on_track->globalPosition().eta());
+      }
     }
       
   }	
@@ -1520,18 +1588,23 @@ Trk::Track* FTK_DataProviderSvc::ConvertTrack(const unsigned int iTrack){
       m_nMissingSCTClusters[cluster_number]++;
       continue;
     }
-    const Trk::RIO_OnTrack* sct_cluster_on_track = createSCT_Cluster(raw_cluster, *trkPerigee);
 
-	
-    if (sct_cluster_on_track==nullptr){
-      ATH_MSG_WARNING(" SCT_ClusterOnTrack failed to create cluster " <<  cluster_number);
+    if (this->getSCTHashID(track,cluster_number)>=m_sctId->wafer_hash_max()){
+      ATH_MSG_DEBUG( "hashId is " << this->getSCTHashID(track,cluster_number) << " MaxHash is " << m_sctId->wafer_hash_max() << " Layer " << cluster_number);
       m_nFailedSCTClusters[cluster_number]++;
     } else {
-      
-      ATH_MSG_VERBOSE( cluster_number << ": r= " << std::sqrt(std::pow(sct_cluster_on_track->globalPosition().x(),2)+std::pow(sct_cluster_on_track->globalPosition().y(),2))
-		       << " z= " << sct_cluster_on_track->globalPosition().z());
-	  
-      clusters.push_back(sct_cluster_on_track);
+
+      const Trk::RIO_OnTrack* sct_cluster_on_track = createSCT_Cluster(this->getSCTHashID(track,cluster_number), raw_cluster, *trkPerigee);
+      if (sct_cluster_on_track==nullptr){
+	ATH_MSG_WARNING(" SCT_ClusterOnTrack failed to create cluster " <<  cluster_number);
+	m_nFailedSCTClusters[cluster_number]++;
+      } else {
+	
+	ATH_MSG_VERBOSE( cluster_number << ": r= " << std::sqrt(std::pow(sct_cluster_on_track->globalPosition().x(),2)+std::pow(sct_cluster_on_track->globalPosition().y(),2))
+			 << " z= " << sct_cluster_on_track->globalPosition().z());
+	
+	clusters.push_back(sct_cluster_on_track);
+      }
     }
   }
   
@@ -1634,10 +1707,8 @@ Trk::Track* FTK_DataProviderSvc::ConvertTrack(const unsigned int iTrack){
 }
 
 
-const Trk::RIO_OnTrack* FTK_DataProviderSvc::createSCT_Cluster(const FTK_RawSCT_Cluster& raw_cluster, const Trk::TrackParameters& trkPerigee) {
+const Trk::RIO_OnTrack* FTK_DataProviderSvc::createSCT_Cluster(const IdentifierHash hash, const FTK_RawSCT_Cluster& raw_cluster, const Trk::TrackParameters& trkPerigee) {
 
-
-  const IdentifierHash hash=raw_cluster.getModuleID();
   const int rawStripCoord= raw_cluster.getHitCoord();
   int clusterWidth=raw_cluster.getHitWidth();
 
@@ -1656,6 +1727,7 @@ const Trk::RIO_OnTrack* FTK_DataProviderSvc::createSCT_Cluster(const FTK_RawSCT_
 
   const InDetDD::SiDetectorElement* pDE = getSCTDetectorElement(hash);
 
+  //const InDetDD::SiDetectorElement* pDE = m_SCT_Manager->getDetectorElement(hash);
 
   ATH_MSG_VERBOSE( " SCT FTKHit HitCoord rawStripCoord" << rawStripCoord << " hashID 0x" << std::hex << hash << std::dec << " " << m_id_helper->print_to_string(pDE->identify()));
 
@@ -1698,8 +1770,7 @@ const Trk::RIO_OnTrack* FTK_DataProviderSvc::createSCT_Cluster(const FTK_RawSCT_
   const double width((double(nStrips)/double(nStrips+1))*( lastStripPos.xPhi()-firstStripPos.xPhi()));
   const InDetDD::SiLocalPosition centre((firstStripPos+lastStripPos)/2.0);
 
-  const double shift = m_sctLorentzAngleTool->getLorentzShift(hash);
-  Amg::Vector2D localPos(centre.xPhi()+shift,  centre.xEta());
+  Amg::Vector2D localPos(centre.xPhi(),  centre.xEta());
 
   ATH_MSG_VERBOSE(" centre.xPhi() " << centre.xPhi()  << " centre.xEta() " << centre.xEta());
 
@@ -1709,8 +1780,6 @@ const Trk::RIO_OnTrack* FTK_DataProviderSvc::createSCT_Cluster(const FTK_RawSCT_
   ATH_MSG_VERBOSE(" creating SiWidth with nstrips   = " << clusterWidth << " width " << width << " stripLength " << stripLength);
   InDet::SiWidth siWidth(Amg::Vector2D(clusterWidth,1), Amg::Vector2D(width,stripLength) );
 
-  Amg::Vector2D position(localPos[Trk::locX], localPos[Trk::locY]);
-
   Amg::MatrixX* cov = new Amg::MatrixX(2,2);
   cov->setZero();
 
@@ -1735,7 +1804,7 @@ const Trk::RIO_OnTrack* FTK_DataProviderSvc::createSCT_Cluster(const FTK_RawSCT_
     ATH_MSG_VERBOSE(" pDE->sinStereoLocal(localPos) " << pDE->sinStereoLocal(localPos) << " pDE->phiPitch(localPos) " << pDE->phiPitch(localPos) << " pDE->phiPitch() " << pDE->phiPitch() << " siWidth.phiR() " << siWidth.phiR() << " siWidth.z() " << siWidth.z() );
   }
 
-  InDet::SCT_Cluster* pCL = new InDet::SCT_Cluster(strip_id, position, rdoList, siWidth, pDE, cov);
+  InDet::SCT_Cluster* pCL = new InDet::SCT_Cluster(strip_id, localPos, rdoList, siWidth, pDE, cov);
   ATH_MSG_VERBOSE("covariance " << (*cov)(0,0) << ", " << (*cov)(0,1));
   ATH_MSG_VERBOSE("           " << (*cov)(1,0) << ", " << (*cov)(1,1)) ;
 
@@ -1753,13 +1822,15 @@ const Trk::RIO_OnTrack* FTK_DataProviderSvc::createSCT_Cluster(const FTK_RawSCT_
       //	  const Trk::PrepRawData* cluster = sct_cluster;
       sct_cluster_on_track= m_ROTcreator->correct(*pCL,trkPerigee);
     }
-
-     if (!m_correctSCTClusters || sct_cluster_on_track == nullptr) {
-      Amg::Vector2D locPos(pCL->localPosition()[Trk::locX]+shift,pCL->localPosition()[Trk::locY]);
+    
+    if (!m_correctSCTClusters || sct_cluster_on_track == nullptr) {
+      
+      const double shift = m_sctLorentzAngleTool->getLorentzShift(hash);
+      Amg::Vector2D locPosShifted(pCL->localPosition()[Trk::locX]+shift,pCL->localPosition()[Trk::locY]);
       ATH_MSG_VERBOSE("locX "<< pCL->localPosition()[Trk::locX] << " locY " << pCL->localPosition()[Trk::locY] << " lorentz shift " << shift);
-
+      
       sct_cluster_on_track = new InDet::SCT_ClusterOnTrack (pCL,
-							    locPos,
+							    locPosShifted,
 							    pCL->localCovariance(),
 							    idHash,
 							    pCL->globalPosition(),m_broadSCT_Errors); // last parameter: isbroad=true
@@ -1797,11 +1868,8 @@ float FTK_DataProviderSvc::dphi(const float p1, const float p2) const {
   return diff1;
 }
 
+const Trk::RIO_OnTrack*  FTK_DataProviderSvc::createPixelCluster(const IdentifierHash hash, const FTK_RawPixelCluster& raw_pixel_cluster,  const Trk::TrackParameters& trkPerigee) {
 
-
-
-const Trk::RIO_OnTrack*  FTK_DataProviderSvc::createPixelCluster(const FTK_RawPixelCluster& raw_pixel_cluster,  const Trk::TrackParameters& trkPerigee) {
-  IdentifierHash hash = raw_pixel_cluster.getModuleID();
   Identifier wafer_id = m_pixelId->wafer_id(hash); // Need to set up this tool
   const InDetDD::SiDetectorElement* pDE = m_pixelManager->getDetectorElement(hash);
 
@@ -1922,7 +1990,6 @@ const Trk::RIO_OnTrack*  FTK_DataProviderSvc::createPixelCluster(const FTK_RawPi
 
   InDet::SiWidth siWidth(Amg::Vector2D(phiWidth,etaWidth),Amg::Vector2D(phiW,etaW));
 
-  //  Amg::Vector2D position(phiPos+shift,etaPos);
   Amg::Vector2D position(phiPos,etaPos);
 
   //  ATH_MSG_VERBOSE("FTK_DataProviderSvc::createPixelCluster: local coordinates phiPos, etaPos"<<  phiPos+shift << ", " << etaPos << " includes Lorentz shift " << shift);
@@ -1947,13 +2014,15 @@ const Trk::RIO_OnTrack*  FTK_DataProviderSvc::createPixelCluster(const FTK_RawPi
   double averageZPitch = siWidth.z()/colRow.y();
   ATH_MSG_VERBOSE(" siWidth.colRow() " << siWidth.colRow());
   ATH_MSG_VERBOSE(" siWidth.z() " << siWidth.z() <<   " colRow.y() " << colRow.y() << "  averageZpitch " << averageZPitch  );
-
+  
+  
   // use parameterization only if the cluster does not
   // contain long pixels or ganged pixels
   // Also require calibration service is available....
-
+  
   double eta = -std::log(std::tan(trkPerigee.parameters()[Trk::theta]/2.));
-
+  
+  
   if(averageZPitch > 399*micrometer && averageZPitch < 401*micrometer){
     SG::ReadCondHandle<PixelCalib::PixelOfflineCalibData> offlineCalibData(m_clusterErrorKey);
     if(pixelDetectorElement->isBarrel()){
@@ -1968,16 +2037,20 @@ const Trk::RIO_OnTrack*  FTK_DataProviderSvc::createPixelCluster(const FTK_RawPi
       (*cov)(0,0) = square(offlineCalibData->getPixelClusterErrorData()->getPixelEndcapPhiError(ibin));
       (*cov)(1,1) = square(offlineCalibData->getPixelClusterErrorData()->getPixelEndcapRError(ibin));
       ATH_MSG_VERBOSE("Endcap Corrections " << (*cov)(0,0)<< " " <<  (*cov)(1,1) );
-    }
+    }      
   } else {
     ATH_MSG_VERBOSE(" Corrections for pixel with length!=400um " << averageZPitch);
     (*cov)(0,0) = square(siWidth.phiR()/colRow.x()) * ONE_TWELFTH  ;
     (*cov)(1,1) = square(averageZPitch)* ONE_TWELFTH  ;
   }
-  InDet::PixelCluster* pixel_cluster = new InDet::PixelCluster(pixel_id, position, rdoList, siWidth, pixelDetectorElement, cov);
+
+  InDet::PixelCluster* pixel_cluster = new InDet::PixelCluster(pixel_id, position, rdoList, siWidth,
+      pixelDetectorElement, cov);
   ATH_MSG_VERBOSE("covariance " << (*cov)(0,0) << ", " << (*cov)(0,1));
   ATH_MSG_VERBOSE("           " << (*cov)(1,0) << ", " <<   (*cov)(1,1)) ;
 
+
+
   const IdentifierHash idHash = m_pixelId->wafer_hash(m_pixelId->wafer_id(pixel_cluster->identify()));
   ATH_MSG_VERBOSE(" hash " << hash << " wafer hash " << idHash);
 
@@ -1994,6 +2067,7 @@ const Trk::RIO_OnTrack*  FTK_DataProviderSvc::createPixelCluster(const FTK_RawPi
     if (!m_correctPixelClusters || pixel_cluster_on_track==nullptr) {
       const double shift = m_pixelLorentzAngleTool->getLorentzShift(hash);
       Amg::Vector2D locPos(pixel_cluster->localPosition()[Trk::locX]+shift,pixel_cluster->localPosition()[Trk::locY]);
+
       ATH_MSG_VERBOSE("locX "<< pixel_cluster->localPosition()[Trk::locX] << " locY " << pixel_cluster->localPosition()[Trk::locY] << " lorentz shift " << shift);
       pixel_cluster_on_track=new InDet::PixelClusterOnTrack (pixel_cluster,
 							     locPos,
@@ -2173,8 +2247,35 @@ void FTK_DataProviderSvc::handle(const Incident& incident) {
     for (auto& it :  m_nFailedPixelClusters) it=0;
     for (auto& it :  m_nMissingSCTClusters) it=0;
     for (auto& it :  m_nMissingPixelClusters) it=0;
+  }
+}
+
+unsigned int FTK_DataProviderSvc::getPixelHashID(const FTK_RawTrack& track, unsigned int iclus){
+  unsigned int id=0;
+  if (m_getHashIDfromConstants) {
+    id = m_hashIDTool->getHash(track.getTower(), track.getSectorID(), iclus);
+    if (id != track.getPixelCluster(iclus).getModuleID()) {
+      ATH_MSG_WARNING("Pixel ModuleID mismatch: ID from track 0x" << std::hex << track.getPixelCluster(iclus).getModuleID() 
+		      << " id from constants 0x" << id << " using id from constants");
+    }
+  } else {
+    id = track.getPixelCluster(iclus).getModuleID();
+  }
+  return id;
+}
 
+unsigned int FTK_DataProviderSvc::getSCTHashID(const FTK_RawTrack& track, unsigned int iclus){
+  unsigned int id=0;
+  if (m_getHashIDfromConstants) {
+    id = m_hashIDTool->getHash(track.getTower(), track.getSectorID(), iclus+4);
+    if (id != track.getPixelCluster(iclus).getModuleID()) {
+      ATH_MSG_WARNING("SCT ModuleID mismatch: ID from track 0x" << std::hex << track.getPixelCluster(iclus).getModuleID() 
+		      << " id from constants 0x" << id << " using id from constants");
+    }
+  } else {
+    id = track.getSCTCluster(iclus).getModuleID();
   }
+  return id;
 }
 
 const InDetDD::SiDetectorElement* FTK_DataProviderSvc::getSCTDetectorElement(const IdentifierHash hash) const {
@@ -2197,3 +2298,4 @@ const InDetDD::SiDetectorElement* FTK_DataProviderSvc::getSCTDetectorElement(con
   }
   return (m_SCTDetectorElements.isValid() ? m_SCTDetectorElements->getDetectorElement(hash) : nullptr);
 }
+
diff --git a/Trigger/TrigFTK/FTK_RecExample/python/FTK_DataProviderSvc_Config.py b/Trigger/TrigFTK/FTK_RecExample/python/FTK_DataProviderSvc_Config.py
deleted file mode 100644
index a057b8bdfba..00000000000
--- a/Trigger/TrigFTK/FTK_RecExample/python/FTK_DataProviderSvc_Config.py
+++ /dev/null
@@ -1,201 +0,0 @@
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-
-from FTK_DataProviderSvc.FTK_DataProviderSvcConf import FTK_DataProviderSvc, FTK_UncertaintyTool
-
-from AthenaCommon.Constants import *   # for "INFO"
-
-
-class ConfiguredFTK_DataProviderSvc(FTK_DataProviderSvc) :
-
-    def __init__(self, name = "ConfiguredFTK_DataProviderSvc"):
-        print "In FTK_DataProviderSvc_Config.py"
-        FTK_DataProviderSvc.__init__(self, name)
-
-        # SiLorentzAngleTool for SCT
-        from AthenaCommon.AppMgr import ToolSvc
-        from SiLorentzAngleSvc.SCTLorentzAngleToolSetup import SCTLorentzAngleToolSetup
-        sctLorentzAngleToolSetup = SCTLorentzAngleToolSetup()
-        FTK_DataProviderSvc.SCTLorentzAngleTool = sctLorentzAngleToolSetup.SCTLorentzAngleTool
-
-        # Track Fitter
-        from TrkGlobalChi2Fitter.TrkGlobalChi2FitterConf import Trk__GlobalChi2Fitter
-        from InDetTrigRecExample.InDetTrigConfigRecLoadTools import InDetTrigExtrapolator, InDetTrigNavigator, InDetTrigPropagator, InDetTrigRefitRotCreator,InDetTrigBroadInDetRotCreator, \
-             InDetTrigUpdator, InDetTrigMaterialUpdator, InDetTrigUpdator, InDetTrigMaterialUpdator
-        from TrkDetDescrSvc.AtlasTrackingGeometrySvc import AtlasTrackingGeometrySvc
-
-        from TrkDistributedKalmanFilter.DistributedKalmanFilter_Config import ConfiguredDistributedKalmanFilter
-
-        FTK_TrackFitter = Trk__GlobalChi2Fitter(name = "FTK_TrackFitter",
-                                                ExtrapolationTool     = InDetTrigExtrapolator,
-                                                NavigatorTool         = InDetTrigNavigator,
-                                                PropagatorTool        = InDetTrigPropagator,
-                                                RotCreatorTool        = InDetTrigRefitRotCreator,
-                                                BroadRotCreatorTool   = InDetTrigBroadInDetRotCreator,
-                                                MeasurementUpdateTool = InDetTrigUpdator,
-                                                TrackingGeometrySvc   = AtlasTrackingGeometrySvc,
-                                                MaterialUpdateTool    = InDetTrigMaterialUpdator,
-                                                StraightLine          = False,
-                                                OutlierCut            = 4,
-                                                SignedDriftRadius     = True,
-                                                RecalibrateSilicon    = True,
-                                                RecalibrateTRT        = True,
-                                                ReintegrateOutliers   = True,
-                                                TrackChi2PerNDFCut    = 7,
-                                                TRTExtensionCuts      = False,
-                                                MaxIterations         = 40,
-                                                Acceleration          = True,
-                                                Momentum=1000.,
-                                                )
-        from AthenaCommon.AppMgr import ToolSvc
-
-        print "printing FTK_TrackFitter configured with DKF"
-        print FTK_TrackFitter
-        ToolSvc += FTK_TrackFitter
-        print "added FTK_TrackFitter to ToolSvc"
-
-
-        from InDetTrigRecExample.InDetTrigConfigRecLoadTools import InDetTrigExtrapolator,InDetTrigTrackSelectorTool,InDetTrigHoleSearchTool
-        from InDetTrigRecExample.InDetTrigConfigRecLoadTools import InDetTrigTrackSummaryToolSharedHits, InDetTrigPrdAssociationTool
-
-
-        from InDetTrackSummaryHelperTool.InDetTrackSummaryHelperToolConf import InDet__InDetTrackSummaryHelperTool
-        FTK_TrackSummaryHelperTool = InDet__InDetTrackSummaryHelperTool(name = "FTK_TrackSummaryHelperTool",
-                                                                AssoTool     = InDetTrigPrdAssociationTool,
-                                                                DoSharedHits = False,
-                                                                HoleSearch   = InDetTrigHoleSearchTool,
-                                                                TestBLayerTool = None,
-                                                                PixelToTPIDTool = None,
-                                                                usePixel=True,
-                                                                useSCT=True,
-                                                                useTRT=False
-                                                                )
-
-        ToolSvc += FTK_TrackSummaryHelperTool
-        print "added FTK_TrackSummaryHelperTool to ToolSvc"
-
-
-
-        from TrkTrackSummaryTool.TrkTrackSummaryToolConf import Trk__TrackSummaryTool
-        FTK_TrackSummaryTool = Trk__TrackSummaryTool(name = "FTK_TrackSummaryTool",
-                                             InDetSummaryHelperTool = FTK_TrackSummaryHelperTool,
-                                             InDetHoleSearchTool    = None,
-                                             doSharedHits           = False,
-                                             TRT_ElectronPidTool    = None
-                                             )
-        ToolSvc += FTK_TrackSummaryTool
-        print "added FTK_TrackSummaryTool to ToolSvc"
-
-
-        from TrkParticleCreator.TrkParticleCreatorConf import Trk__TrackParticleCreatorTool
-
-
-        FTK_TrackParticleCreatorTool = Trk__TrackParticleCreatorTool( name = "FTK_ParticleCreatorTool",
-                                                         Extrapolator = InDetTrigExtrapolator,
-                                                         TrackSummaryTool = FTK_TrackSummaryTool,
-                                                         KeepParameters = True,
-                                                         ForceTrackSummaryUpdate = False,  #summary update moved (in the slimmer now)
-                                                         )
-
-        ToolSvc += FTK_TrackParticleCreatorTool
-        print FTK_TrackParticleCreatorTool
-        print " added FTK_TrackParticleCreatorTool to ToolSvc"
-
-
-        from TrigInDetConf.TrigInDetRecVtxTools import InDetTrigLinFactory, InDetTrigVxEdmCnv
-        from TrigInDetConf.TrigInDetRecVtxTools import InDetTrigLinFactory, InDetTrigVxEdmCnv
-
-        from TrkVertexSeedFinderTools.TrkVertexSeedFinderToolsConf import Trk__ZScanSeedFinder
-        FTK_VtxSeedFinder = Trk__ZScanSeedFinder(name = "FTK_ZScanSeedFinder"
-                                                    #Mode1dFinder = # default, no setting needed
-                                                    )
-        ToolSvc += FTK_VtxSeedFinder
-
-        from TrkVertexFitterUtils.TrkVertexFitterUtilsConf import Trk__ImpactPoint3dEstimator, Trk__DetAnnealingMaker
-
-        FTK_ImpactPoint3dEstimator = Trk__ImpactPoint3dEstimator(name         = "FTK_TrkImpactPoint3dEstimator",
-                                                         Extrapolator = InDetTrigExtrapolator,
-                                                         )
-
-        ToolSvc += FTK_ImpactPoint3dEstimator
-
-
-        FTK_AnnealingMaker = Trk__DetAnnealingMaker(name = "FTK_TrkAnnealingMaker")
-        FTK_AnnealingMaker.SetOfTemperatures = [64.,16.,4.,2.,1.5,1.] # not default
-        ToolSvc += FTK_AnnealingMaker
-
-
-        from TrkVertexFitters.TrkVertexFittersConf import Trk__SequentialVertexSmoother
-        FTK_VertexSmoother =  Trk__SequentialVertexSmoother(name="FTK_SequentialVertexSmoother")
-        ToolSvc += FTK_VertexSmoother
-
-
-        from TrkVertexFitters.TrkVertexFittersConf import Trk__AdaptiveVertexFitter
-        FTK_VxFitterTool = Trk__AdaptiveVertexFitter(name                         = "FTK_AdaptiveVxFitterTool",
-                                             SeedFinder                   = FTK_VtxSeedFinder,
-                                             LinearizedTrackFactory       = InDetTrigLinFactory,
-                                             ImpactPoint3dEstimator       = FTK_ImpactPoint3dEstimator,
-                                             AnnealingMaker               = FTK_AnnealingMaker,
-                                             #TrackCompatibilityEstimator =
-                                             VertexSmoother = FTK_VertexSmoother,
-                                             #VertexUpdator = ,  #does not use any tools?
-                                             #onlyzseed = ,
-                                             )
-
-        ToolSvc += FTK_VxFitterTool
-
-        from InDetPriVxFinderTool.InDetPriVxFinderToolConf import InDet__InDetIterativePriVxFinderTool
-        FTK_PriVxFinderTool = InDet__InDetIterativePriVxFinderTool(name             = "FTK_PriVxFinderTool",
-                                                                   VertexFitterTool = FTK_VxFitterTool,
-                                                                   TrackSelector    = InDetTrigTrackSelectorTool,
-                                                                   SeedFinder = FTK_VtxSeedFinder,
-                                                                   ImpactPoint3dEstimator = FTK_ImpactPoint3dEstimator,
-                                                                   LinearizedTrackFactory = InDetTrigLinFactory,
-                                                                   useBeamConstraint = True,
-                                                                   significanceCutSeeding = 12,
-                                                                   maximumChi2cutForSeeding = 49,
-                                                                   maxVertices = 200
-                                                                   )
-        ToolSvc += FTK_PriVxFinderTool
-
-
-        from FTK_DataProviderSvc.FTK_DataProviderSvcConf import FTK_UncertaintyTool
-        theFTK_UncertaintyTool= FTK_UncertaintyTool(name="FTK_UncertaintyTool")
-        ToolSvc+=theFTK_UncertaintyTool
-
-        from FTK_RecTools.FTK_RecToolsConf import FTK_VertexFinderTool
-        FTK_RawVertexFinderTool=  FTK_VertexFinderTool(name="FTK_RawVertexFinderTool",
-                                                           VertexInternalEdmFactory=InDetTrigVxEdmCnv)
-        ToolSvc+=FTK_RawVertexFinderTool
-
-        self.TrackCollectionName= "FTK_TrackCollection"
-        self.TrackParticleContainerName= "FTK_TrackParticleContainer"
-        self.VxContainerName="FTK_VxContainer"
-        self.VertexContainerName="FTK_VertexContainer"
-        self.PixelTruthName="FTK_PRD_MultiTruthPixel"
-        self.SctTruthName="FTK_PRD_MultiTruthSCT"
-        self.PixelClusterContainerName= "FTK_PixelClusterContainer"
-        self.SCT_ClusterContainerName= "FTK_SCT_ClusterContainer"
-
-        self.TrackFitter = FTK_TrackFitter
-        self.UncertaintyTool=theFTK_UncertaintyTool
-        self.TrackSummaryTool=FTK_TrackSummaryTool
-        self.TrackParticleCreatorTool=FTK_TrackParticleCreatorTool
-        self.RawVertexFinderTool=FTK_RawVertexFinderTool
-        self.VertexFinderTool=FTK_PriVxFinderTool
-        self.ROTcreatorTool = InDetTrigRefitRotCreator
-
-        from RecExConfig.RecFlags import rec
-
-        self.doTruth=rec.doTruth()
-        self.TrainingBeamspotX= 0.0
-        self.TrainingBeamspotY= 0.0
-        self.TrainingBeamspotZ = 0.0
-        self.TrainingBeamspotTiltX= 0.0
-        self.TrainingBeamspotTiltY= 0.0
-        self. PixelBarrelPhiOffsets=[0.,0.,0.,0.]
-        self. PixelBarrelEtaOffsets=[0.,0.,0.,0.]
-        self. PixelEndCapPhiOffsets=[0.,0.,0.]
-        self. PixelEndCapEtaOffsets=[0.,0.,0.]
-
-
-
diff --git a/Trigger/TrigFTK/FTK_RecExample/share/FTKRec_jobOptions.py b/Trigger/TrigFTK/FTK_RecExample/share/FTKRec_jobOptions.py
index 2e2e5fd7bfd..0ec272d1278 100644
--- a/Trigger/TrigFTK/FTK_RecExample/share/FTKRec_jobOptions.py
+++ b/Trigger/TrigFTK/FTK_RecExample/share/FTKRec_jobOptions.py
@@ -1,28 +1,20 @@
 include.block('FTK_RecExample/FTKRec_jobOptions.py')
 
-
 from RecExConfig.RecFlags import rec
-from AthenaCommon.GlobalFlags import GlobalFlags
-
-if rec.doFTK() and globalflags.InputFormat() == 'bytestream':
-    ByteStreamAddressProviderSvc = Service( "ByteStreamAddressProviderSvc")
-    ByteStreamAddressProviderSvc.TypeNames += [ "FTK_RawTrackContainer/FTK_RDO_Tracks"]
-    
+from AthenaCommon.BeamFlags import jobproperties
+ 
 if rec.doFTK():
-
-    # SiLorentzAngleTool for SCT
-    from AthenaCommon.AppMgr import ToolSvc
-    from SiLorentzAngleSvc.SCTLorentzAngleToolSetup import SCTLorentzAngleToolSetup
-    sctLorentzAngleToolSetup = SCTLorentzAngleToolSetup()
+    from AthenaCommon.GlobalFlags import GlobalFlags
+    if rec.doFTK() and globalflags.InputFormat() == 'bytestream':
+        ByteStreamAddressProviderSvc = Service( "ByteStreamAddressProviderSvc")
+        ByteStreamAddressProviderSvc.TypeNames += [ "FTK_RawTrackContainer/FTK_RDO_Tracks"]
 
     from TrigFTK_RecExample.TrigFTK_DataProviderSvc_Config import TrigFTK_DataProviderSvc
     theFTK_DataProviderSvc = TrigFTK_DataProviderSvc("TrigFTK_DataProviderSvc")
     ServiceMgr += theFTK_DataProviderSvc
-    from AthenaCommon import CfgGetter
-    ServiceMgr.TrigFTK_DataProviderSvc.SCTLorentzAngleTool=CfgGetter.getPrivateTool("SCTLorentzAngleTool")
-    
+
     from TrigFTK_RawDataAlgs.TrigFTK_RawDataAlgsConf import FTK_RDO_ReaderAlgo
-    
+
     FTK_RDO_Reader = FTK_RDO_ReaderAlgo( "FTK_RDO_ReaderAlgo")
     FTK_RDO_Reader.FTK_DataProvider=theFTK_DataProviderSvc
     FTK_RDO_Reader.RDO_CollectionName="FTK_RDO_Tracks"
@@ -30,23 +22,27 @@ if rec.doFTK():
     FTK_RDO_Reader.fillTree=False
     FTK_RDO_Reader.GetTracks=True
     FTK_RDO_Reader.GetTrackParticles=True
-    FTK_RDO_Reader.GetVertex=True
     FTK_RDO_Reader.GetRefitTracks=True
     FTK_RDO_Reader.GetRefitTrackParticles=True
-    FTK_RDO_Reader.GetRefitVertex=True
+    if (jobproperties.Beam.beamType() == 'cosmics'):
+        FTK_RDO_Reader.GetVertex=False
+        FTK_RDO_Reader.GetRefitVertex=False
+    else:
+        FTK_RDO_Reader.GetVertex=True
+        FTK_RDO_Reader.GetRefitVertex=True
     FTK_RDO_Reader.GetTruthVertex=False
-    
+
     from AthenaCommon.AlgSequence import AlgSequence
-    
+
     alg = AlgSequence() 
     alg += FTK_RDO_Reader 
     
-    
-    if rec.doTruth():
+
+    if rec.doTruth() and (rec.doWriteAOD() or rec.doWriteESD()):
         include ('FTK_RecExample/ConfiguredFTK_TrackTruth.py')
         FTK_TracksTruth = ConfiguredFTK_TrackTruth(Tracks="FTK_TrackCollection",
-                                                   TracksTruth = "FTK_Tracks_TruthCollection",
-                                                   DetailedTruth = "FTK_Tracks_DetailedTruthCollection")
+                                                TracksTruth = "FTK_Tracks_TruthCollection",
+                                                DetailedTruth = "FTK_Tracks_DetailedTruthCollection")
         FTK_RefitTracksTruth = ConfiguredFTK_TrackTruth(Tracks="FTK_TrackCollectionRefit", 
                                                      TracksTruth = "FTK_RefitTracks_TruthCollection",
                                                      DetailedTruth = "FTK_RefitTracks_DetailedTruthCollection")
diff --git a/Trigger/TrigFTK/FTK_RecToolInterfaces/FTK_RecToolInterfaces/IFTK_DuplicateTrackRemovalTool.h b/Trigger/TrigFTK/FTK_RecToolInterfaces/FTK_RecToolInterfaces/IFTK_DuplicateTrackRemovalTool.h
index dc4fbffa813..841d17b2915 100644
--- a/Trigger/TrigFTK/FTK_RecToolInterfaces/FTK_RecToolInterfaces/IFTK_DuplicateTrackRemovalTool.h
+++ b/Trigger/TrigFTK/FTK_RecToolInterfaces/FTK_RecToolInterfaces/IFTK_DuplicateTrackRemovalTool.h
@@ -1,3 +1,6 @@
+/*
+  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+*/
 
 //abstract interface
 
diff --git a/Trigger/TrigFTK/FTK_RecToolInterfaces/FTK_RecToolInterfaces/IFTK_HashIDTool.h b/Trigger/TrigFTK/FTK_RecToolInterfaces/FTK_RecToolInterfaces/IFTK_HashIDTool.h
new file mode 100644
index 00000000000..0184d6f2e3c
--- /dev/null
+++ b/Trigger/TrigFTK/FTK_RecToolInterfaces/FTK_RecToolInterfaces/IFTK_HashIDTool.h
@@ -0,0 +1,30 @@
+/*
+  Copyright (C) 2018 CERN for the benefit of the ATLAS collaboration
+*/
+
+#ifndef IFTK_HASHIDTOOL_H
+#define IFTK_HASHIDTOOL_H
+
+
+#include "GaudiKernel/IAlgTool.h"
+#include "TrigFTK_RawData/FTK_RawTrackContainer.h"
+
+static const InterfaceID IID_IFTK_HashIDTool("IFTK_HashIDTool",1,0);
+
+class IFTK_HashIDTool: virtual public IAlgTool {
+  
+ public:
+
+  static const InterfaceID& interfaceID ()   //!< the Tool's interface
+  {  return IID_IFTK_HashIDTool; }  	
+
+  virtual unsigned int getHash(unsigned int tower, unsigned int sector,  unsigned int plane)=0;
+
+  virtual unsigned int getHashFromAuxSector(unsigned int tower, unsigned int sector,  unsigned int plane)=0;
+  
+  virtual bool findHash(unsigned int hash, bool isSCT, unsigned int& tower, unsigned int& sector, unsigned int& plane)=0;
+
+  virtual FTK_RawTrackContainer* processTracks(const FTK_RawTrackContainer& inputTracks, const bool reverseIBL)=0;
+};
+
+#endif // IFTK_HASHIDTOOL_H
diff --git a/Trigger/TrigFTK/FTK_RecTools/CMakeLists.txt b/Trigger/TrigFTK/FTK_RecTools/CMakeLists.txt
index d7f5090807e..c6c91eacac4 100644
--- a/Trigger/TrigFTK/FTK_RecTools/CMakeLists.txt
+++ b/Trigger/TrigFTK/FTK_RecTools/CMakeLists.txt
@@ -13,13 +13,13 @@ atlas_depends_on_subdirs( PUBLIC
                           GaudiKernel
                           Tools/PyJobTransforms
                           DetectorDescription/GeoPrimitives
-                          InnerDetector/InDetConditions/InDetCondServices
                           Tracking/TrkEvent/TrkTrack
                           Tracking/TrkEvent/VxVertex
                           Tracking/TrkVertexFitter/TrkVxEdmCnv
                           Trigger/TrigFTK/FTK_DataProviderInterfaces
                           Trigger/TrigFTK/FTK_RecToolInterfaces
                           Trigger/TrigFTK/TrigFTK_RawData
+			  Trigger/TrigFTK/TrigFTKSim
                           InnerDetector/InDetDetDescr/SCT_ModuleDistortions
                           InnerDetector/InDetRecEvent/InDetPrepRawData
                           InnerDetector/InDetRecEvent/InDetRIO_OnTrack
@@ -40,17 +40,20 @@ atlas_depends_on_subdirs( PUBLIC
 
 
 # External dependencies:
-find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread )
+find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread Eigen CLHEP )
 
 # Component(s) in the package:
 atlas_add_library( FTK_RecToolsLib
                    src/*.cxx
                    PUBLIC_HEADERS FTK_RecTools
-                   INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
-                   LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps GeoPrimitives xAODTracking TrkTrack VxVertex FTK_DataProviderInterfaces TrigFTK_RawData TrkVxEdmCnvLib  InDetPrepRawData InDetRIO_OnTrack TrkParameters TrkToolInterfaces TrkRIO_OnTrack TrkAmbiguityProcessorLib StoreGateLib SGtests EventPrimitives InDetIdentifier InDetReadoutGeometry SiClusterizationToolLib TrkSurfaces PixelConditionsData)
+		   INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
+		   PRIVATE_INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS}
+                   LINK_LIBRARIES ${ROOT_LIBRARIES} ${EIGEN_LIBRARIES}  ${CLHEP_LIBRARIES} AthenaBaseComps GeoPrimitives xAODTracking TrkTrack VxVertex FTK_DataProviderInterfaces TrigFTK_RawData TrkVxEdmCnvLib TrigFTKSimLib InDetPrepRawData InDetRIO_OnTrack TrkParameters TrkToolInterfaces TrkAmbiguityProcessorLib StoreGateLib SGtests EventPrimitives InDetIdentifier InDetReadoutGeometry SiClusterizationToolLib TrkSurfaces PixelConditionsData)
 
 atlas_add_component( FTK_RecTools
                      src/*.cxx src/components/*.cxx
                      INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
-                     LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps GeoPrimitives xAODTracking TrkTrack VxVertex TrkVxEdmCnvLib FTK_DataProviderInterfaces TrigFTK_RawData TrkParameters FTK_RecToolsLib InDetPrepRawData InDetRIO_OnTrack TrkParameters TrkToolInterfaces TrkAmbiguityProcessorLib StoreGateLib SGtests EventPrimitives InDetIdentifier InDetReadoutGeometry SiClusterizationToolLib TrkSurfaces PixelConditionsData)
+		     PRIVATE_INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS}
+                     LINK_LIBRARIES ${ROOT_LIBRARIES} ${EIGEN_LIBRARIES}  ${CLHEP_LIBRARIES} AthenaBaseComps GeoPrimitives xAODTracking TrkTrack VxVertex TrkVxEdmCnvLib FTK_DataProviderInterfaces TrigFTK_RawData TrigFTKSimLib TrkParameters FTK_RecToolsLib InDetPrepRawData InDetRIO_OnTrack TrkParameters TrkToolInterfaces TrkAmbiguityProcessorLib StoreGateLib SGtests EventPrimitives InDetIdentifier InDetReadoutGeometry SiClusterizationToolLib TrkSurfaces PixelConditionsData)
+
 
diff --git a/Trigger/TrigFTK/FTK_RecTools/FTK_RecTools/FTK_HashIDTool.h b/Trigger/TrigFTK/FTK_RecTools/FTK_RecTools/FTK_HashIDTool.h
new file mode 100644
index 00000000000..aca70c078bd
--- /dev/null
+++ b/Trigger/TrigFTK/FTK_RecTools/FTK_RecTools/FTK_HashIDTool.h
@@ -0,0 +1,139 @@
+/*
+  Copyright (C) 2018 CERN for the benefit of the ATLAS collaboration
+*/
+
+#ifndef FTK_HASHIDTOOL_H
+#define FTK_HASHIDTOOL_H
+#include "GaudiKernel/ToolHandle.h"
+
+#include "AthenaBaseComps/AthAlgTool.h"
+
+#include <vector>
+#include <string>
+#include <map>
+#include "CLHEP/Vector/ThreeVector.h"
+#include "FTK_RecToolInterfaces/IFTK_HashIDTool.h"
+#include "TrigFTK_RawData/FTK_RawTrackContainer.h"
+#include "GeoPrimitives/GeoPrimitives.h"
+
+using Amg::Vector3D;
+
+
+class PixelID;
+class AtlasDetectorID;
+namespace InDetDD {
+  class PixelDetectorManager;
+}
+
+class FTK_HashIDTool : public AthAlgTool, virtual public IFTK_HashIDTool {
+  
+  
+ public:
+  FTK_HashIDTool ( const std::string&, const std::string&, const IInterface* );
+  virtual ~FTK_HashIDTool ();
+  virtual StatusCode initialize();
+  
+  unsigned int getHash(unsigned int tower, unsigned int sector,  unsigned int plane);
+
+  unsigned int getHashFromAuxSector(unsigned int tower, unsigned int sector,  unsigned int plane);
+  
+  bool findHash(unsigned int hash, bool isSCT, unsigned int& tower, unsigned int& sector, unsigned int& plane);
+  
+  FTK_RawTrackContainer* processTracks(const FTK_RawTrackContainer& inputTracks, const bool reverseIBL);
+  
+ private:
+  
+  
+  const Amg::Vector3D getPixelClusterPosition(const FTK_RawPixelCluster& raw_pixel_cluster, const bool reverseIBL);
+
+  inline float get_d0(Amg::Vector3D& s0, Amg::Vector3D& s1, Amg::Vector3D& s2) {
+    float phi0 = s0.phi();
+    float phi1 = s1.phi();
+    float phi2 = s2.phi();
+    float r0 = s0.perp();
+    float r1 = s1.perp();
+    float r2 = s2.perp();
+    
+    return r0*r1*r2*(phi0*r1 - phi0*r2 - phi1*r0 + phi1*r2 + phi2*r0 - phi2*r1)/(r0*r0*r1 - r0*r0*r2 - r0*r1*r1 + r0*r2*r2 + r1*r1*r2 - r1*r2*r2);
+  }
+  
+  //Parametrise triplet as quadratic a + t*x + (alpha/2)*x**2
+  inline float get_alpha(Amg::Vector3D& s0, Amg::Vector3D& s1, Amg::Vector3D& s2) {
+    float dx1 = s1.x()-s0.x();
+    float dy1 = s1.y()-s0.y();
+    float dx2 = s2.x()-s0.x();
+    float dy2 = s2.y()-s0.y();
+    
+    //Transform into line with s1 and s2 on x-axis, s1 at (0,0)
+    float x1prime = sqrt(dx1*dx1+dy1*dy1);
+    float x2prime = (dx2*dx1 + dy2*dy1)/x1prime;
+    float y2prime = (dy2*dx1 - dx2*dy1)/x1prime;
+    return 2*y2prime/(x2prime*(x2prime-x1prime));
+  }
+  
+  //IDSCAN Hit Filter style pT calculation
+  inline float get_invpT(Amg::Vector3D& s0, Amg::Vector3D& s1, Amg::Vector3D& s2) {
+    //pT = 0.3*B*R
+    float a = get_alpha(s0, s1, s2);
+    if (a==0.0) {
+      return 1e-9;
+    }
+    return -a/0.6;
+  }
+  
+  //IDSCAN Hit Filter style phi calculation
+  inline float get_phi(Amg::Vector3D& s0, Amg::Vector3D& s1, Amg::Vector3D& s2) {
+    float x0 = s0.x();
+    float x1 = s1.x();
+    float y0 = s0.y();
+    float y1 = s1.y();
+    
+    //Transform into coordinate system rotated so that y0'=y1'=0, at angle phi
+    float phi = std::atan2(y1-y0,x1-x0);       
+    float L = std::fabs(x0*cos(phi) - y0*sin(phi));//Distance to 0th spacepoint from origin
+    //y = (alpha/2)*x**2 + t*x to describe parabola
+    float alpha = get_alpha(s0,s1,s2);
+    //Distance between 0th and 1st spaceppoint
+    float x1prime = std::sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0));
+    float t   = -0.5*alpha*x1prime;
+    //t' = phi0' in small angle approximation
+    float phi0prime = t - alpha*L;
+    
+    float phi_prime = phi + phi0prime;
+    if(phi_prime<-M_PI) phi_prime+=2*M_PI;
+    if(phi_prime>M_PI)  phi_prime-=2*M_PI;
+    return phi_prime;
+  }
+  
+  inline float get_z0(Amg::Vector3D& s1, Amg::Vector3D& s2) {
+    
+    return ((s2.perp()*s1.z()-s2.z()*s1.perp())/(s2.perp() - s1.perp()));
+    
+  }
+  inline float get_cotTheta(Amg::Vector3D& s1, Amg::Vector3D& s2) {
+    
+    return ((s2.z() - s1.z())/ (s2.perp() - s1.perp()));
+  }
+  
+ private:
+  
+  typedef std::vector<std::vector<int>> ftk_sectormap;
+  
+  int readModuleIds(unsigned int itower, ftk_sectormap& hashID);
+  
+  size_t m_max_tower;
+  
+  std::vector<ftk_sectormap*> m_moduleFromSector;
+  std::vector<std::vector<int>> m_sector8toSector12;
+  
+  std::string m_ConstantsDir;
+  std::string m_PatternsVersion;
+  
+  const PixelID* m_pixelId;
+  const AtlasDetectorID* m_id_helper;
+  const InDetDD::PixelDetectorManager* m_pixelManager;
+
+  bool m_maxD0;
+};
+
+#endif // FTK_HASHIDTOOL_H
diff --git a/Trigger/TrigFTK/FTK_RecTools/FTK_RecTools/FTK_PixelClusterOnTrackTool.h b/Trigger/TrigFTK/FTK_RecTools/FTK_RecTools/FTK_PixelClusterOnTrackTool.h
index fa49834ec70..1d20fb45b9f 100644
--- a/Trigger/TrigFTK/FTK_RecTools/FTK_RecTools/FTK_PixelClusterOnTrackTool.h
+++ b/Trigger/TrigFTK/FTK_RecTools/FTK_RecTools/FTK_PixelClusterOnTrackTool.h
@@ -2,208 +2,201 @@
   Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
 */
 
-///////////////////////////////////////////////////////////////////
-//  Header file for class  FTK_PixelClusterOnTrackTool
-///////////////////////////////////////////////////////////////////
-
-#ifndef FTK_PixelClusterOnTrackTool_H
-#define FTK_PixelClusterOnTrackTool_H
-
-#include "GaudiKernel/ToolHandle.h"
-#include "AthenaBaseComps/AthAlgTool.h"
-
-
-#include "TrkToolInterfaces/IRIO_OnTrackCreator.h"
+///////////////////////////////////////////////////////////////////
+//  Header file for class  FTK_PixelClusterOnTrackTool
+///////////////////////////////////////////////////////////////////
+
+#ifndef FTK_PixelClusterOnTrackTool_H
+#define FTK_PixelClusterOnTrackTool_H
+
+#include "GaudiKernel/ToolHandle.h"
+#include "AthenaBaseComps/AthAlgTool.h"
+
+
+#include "TrkToolInterfaces/IRIO_OnTrackCreator.h"
 #include "InDetRIO_OnTrack/PixelRIO_OnTrackErrorScaling.h"
-#include "InDetRIO_OnTrack/PixelClusterOnTrack.h"
-
-#include "InDetPrepRawData/PixelGangedClusterAmbiguities.h"
-#include "TrkParameters/TrackParameters.h"
-//#include "InDetIdentifier/PixelID.h"
-#include "GeoPrimitives/GeoPrimitives.h"
-#include "TrkAmbiguityProcessor/dRMap.h"
-#include "SiClusterizationTool/NnClusterizationFactory.h"
-
-//#include "PixelConditionsTools/IModuleDistortionsTool.h"
-
+#include "InDetRIO_OnTrack/PixelClusterOnTrack.h"
+
+#include "InDetPrepRawData/PixelGangedClusterAmbiguities.h"
+#include "TrkParameters/TrackParameters.h"
+//#include "InDetIdentifier/PixelID.h"
+#include "GeoPrimitives/GeoPrimitives.h"
+#include "TrkAmbiguityProcessor/dRMap.h"
+#include "SiClusterizationTool/NnClusterizationFactory.h"
+
 #include "PixelConditionsData/PixelOfflineCalibData.h"
 #include "InDetCondServices/ISiLorentzAngleTool.h"
-#include "AthenaPoolUtilities/CondAttrListCollection.h"
-class PixelID;
-class IModuleDistortionsTool;
-
-class StoreGateSvc;
-class IIBLParameterSvc;
-
-//namespace InDet {
-
-  /** @brief creates FTK_PixelClusterOnTrack objects allowing to
-      calibrate cluster position and error using a given track hypothesis. 
-
-      See doxygen of Trk::RIO_OnTrackCreator for details.
-      Different strategies to calibrate the cluster error can be chosen
-      by job Option. Also the handle to the general hit-error scaling
-      is implemented.
-
-      Special strategies for correction can be invoked by calling the
-      correct method with an additional argument from the 
-      PixelClusterStrategy enumeration
-
-  */
-
-
-namespace InDet {
-  enum PixelClusterStrategy {
-    PIXELCLUSTER_DEFAULT=0,
-    PIXELCLUSTER_OUTLIER=1,
-    PIXELCLUSTER_SHARED =2,
-    PIXELCLUSTER_SPLIT  =3
-    };
-}
-
-  class FTK_PixelClusterOnTrackTool: 
-        public AthAlgTool, virtual public Trk::IRIO_OnTrackCreator
-{
-  ///////////////////////////////////////////////////////////////////
-  // Public methods:
-  ///////////////////////////////////////////////////////////////////
-
-public:
-
-  //! AlgTool constructor 
-  FTK_PixelClusterOnTrackTool(const std::string&,const std::string&,
-                          const IInterface*);
-  virtual ~FTK_PixelClusterOnTrackTool ();
-  //! AlgTool initialisation
-  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!).
-
-      Depending on job options it changes the pixel cluster position
-      and error according to the parameters (in particular, the angle)
-      of the intersecting track.
-  */
-  virtual const InDet::PixelClusterOnTrack* correct(const Trk::PrepRawData&,
-                                                    const Trk::TrackParameters&) const;
-
-  virtual 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&, 
-                           Amg::Vector2D&,  Amg::MatrixX&) const;
-                                                                                                         
-  virtual bool getErrorsTIDE_Ambi( const InDet::PixelCluster*, const Trk::TrackParameters&,  
-                        Amg::Vector2D&,  Amg::MatrixX&) const;
-
-  virtual const InDet::PixelClusterOnTrack* correct
-    (const Trk::PrepRawData&, const Trk::TrackParameters&, 
-     const InDet::PixelClusterStrategy) const;
-
-     
-  ///////////////////////////////////////////////////////////////////
-  // Private methods:
-  ///////////////////////////////////////////////////////////////////
-  
- 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:
-  ///////////////////////////////////////////////////////////////////
-
-  ToolHandle<IModuleDistortionsTool>            m_pixDistoTool    ;
+#include "AthenaPoolUtilities/CondAttrListCollection.h"
+class PixelID;
+class IModuleDistortionsTool;
+
+class StoreGateSvc;
+class IIBLParameterSvc;
+
+
+  /** @brief creates FTK_PixelClusterOnTrack objects allowing to
+      calibrate cluster position and error using a given track hypothesis. 
+
+      See doxygen of Trk::RIO_OnTrackCreator for details.
+      Different strategies to calibrate the cluster error can be chosen
+      by job Option. Also the handle to the general hit-error scaling
+      is implemented.
+
+      Special strategies for correction can be invoked by calling the
+      correct method with an additional argument from the 
+      PixelClusterStrategy enumeration
+
+  */
+
+
+namespace InDet {
+  enum PixelClusterStrategy {
+    PIXELCLUSTER_DEFAULT=0,
+    PIXELCLUSTER_OUTLIER=1,
+    PIXELCLUSTER_SHARED =2,
+    PIXELCLUSTER_SPLIT  =3
+    };
+}
+
+  class FTK_PixelClusterOnTrackTool: 
+        public AthAlgTool, virtual public Trk::IRIO_OnTrackCreator
+{
+  ///////////////////////////////////////////////////////////////////
+  // Public methods:
+  ///////////////////////////////////////////////////////////////////
+
+public:
+
+  //! AlgTool constructor 
+  FTK_PixelClusterOnTrackTool(const std::string&,const std::string&,
+                          const IInterface*);
+  virtual ~FTK_PixelClusterOnTrackTool ();
+  //! AlgTool initialisation
+  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!).
+
+      Depending on job options it changes the pixel cluster position
+      and error according to the parameters (in particular, the angle)
+      of the intersecting track.
+  */
+  virtual const InDet::PixelClusterOnTrack* correct(const Trk::PrepRawData&,
+                                                    const Trk::TrackParameters&) const;
+
+  virtual 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&, 
+                           Amg::Vector2D&,  Amg::MatrixX&) const;
+                                                                                                         
+  virtual bool getErrorsTIDE_Ambi( const InDet::PixelCluster*, const Trk::TrackParameters&,  
+                        Amg::Vector2D&,  Amg::MatrixX&) const;
+
+  virtual const InDet::PixelClusterOnTrack* correct
+    (const Trk::PrepRawData&, const Trk::TrackParameters&, 
+     const InDet::PixelClusterStrategy) const;
+
+     
+  ///////////////////////////////////////////////////////////////////
+  // Private methods:
+  ///////////////////////////////////////////////////////////////////
+  
+ 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:
+  ///////////////////////////////////////////////////////////////////
+
+  ToolHandle<IModuleDistortionsTool>            m_pixDistoTool    ;
   ToolHandle<ISiLorentzAngleTool> m_lorentzAngleTool{this, "LorentzAngleTool", "SiLorentzAngleTool", "Tool to retreive Lorentz angle"};
-  StoreGateSvc*                                 m_detStore        ;
-  /* 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
+  StoreGateSvc*                                 m_detStore        ;
+  /* 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
   SG::ReadCondHandleKey<PixelCalib::PixelOfflineCalibData> m_clusterErrorKey{this, "PixelOfflineCalibData", "PixelOfflineCalibData", "Output key of pixel cluster"};
   SG::ReadCondHandleKey<RIO_OnTrackErrorScaling> m_pixelErrorScalingKey
     {this,"PixelErrorScalingKey", "" /* "/Indet/TrkErrorScalingPixel" */, "Key for pixel error scaling conditions data. No error scaling if empty"};
+  bool                               m_disableDistortions;
+  bool                               m_rel13like         ;
+  int                                m_positionStrategy  ;
+  mutable int                        m_errorStrategy     ;
+  
+  
+  /** @brief Flag controlling how module distortions are taken into account:
+      
+  case 0 -----> No distorsions implemented;
+  
+  case 1 -----> Set curvature (in 1/meter) and twist (in radiant) equal for all modules;
+  
+  case 2 -----> Read curvatures and twists from textfile containing Survey data;
+  
+  case 3 -----> Set curvature and twist from Gaussian random generator with mean and RMS coming from Survey data;
+  
+  case 4 -----> Read curvatures and twists from database (not ready yet);
+  */
+  //! identifier-helper
+  const PixelID*                     m_pixelid;
+  
+  /** Enable NN based calibration (do only if NN calibration is applied) **/
+  mutable bool                      m_applyNNcorrection;
+  mutable bool                      m_applydRcorrection;
+  bool                              m_NNIBLcorrection;
+  bool                              m_IBLAbsent;
+  
+  /** NN clusterizationi factory for NN based positions and errors **/
+  ToolHandle<InDet::NnClusterizationFactory>                   m_NnClusterizationFactory;
+  ServiceHandle<StoreGateSvc>                           m_storeGate;            //!< Event store
+  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;
+  std::string m_splitClusterMapName; //no longer used
+  mutable std::vector< std::vector<float> > m_fX, m_fY, m_fB, m_fC, m_fD;
+  
+  //moved from static to member variable
+  static constexpr int NBINPHI=9;
+  static constexpr int NBINETA=6;
+  double m_calphi[NBINPHI];
+  double m_caleta[NBINETA][3];
+  double m_calerrphi[NBINPHI][3];
+  double m_calerreta[NBINETA][3];
+  double m_phix[NBINPHI+1];
+  double m_etax[NBINETA+1];
+};
 
-  bool                               m_disableDistortions;
-  bool                               m_rel13like         ;
-  int                                m_positionStrategy  ;
-  mutable int                        m_errorStrategy     ;
-  
-  
-  /** @brief Flag controlling how module distortions are taken into account:
-      
-  case 0 -----> No distorsions implemented;
-  
-  case 1 -----> Set curvature (in 1/meter) and twist (in radiant) equal for all modules;
-  
-  case 2 -----> Read curvatures and twists from textfile containing Survey data;
-  
-  case 3 -----> Set curvature and twist from Gaussian random generator with mean and RMS coming from Survey data;
-  
-  case 4 -----> Read curvatures and twists from database (not ready yet);
-  */
-  //! identifier-helper
-  const PixelID*                     m_pixelid;
-  
-  /** Enable NN based calibration (do only if NN calibration is applied) **/
-  mutable bool                      m_applyNNcorrection;
-  mutable bool                      m_applydRcorrection;
-  bool                              m_NNIBLcorrection;
-  bool                              m_IBLAbsent;
-  
-  /** NN clusterizationi factory for NN based positions and errors **/
-  ToolHandle<InDet::NnClusterizationFactory>                   m_NnClusterizationFactory;
-  ServiceHandle<StoreGateSvc>                           m_storeGate;            //!< Event store
-  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;
-  std::string m_splitClusterMapName; //no longer used
-  mutable std::vector< std::vector<float> > m_fX, m_fY, m_fB, m_fC, m_fD;
-  
-  //moved from static to member variable
-  static constexpr int NBINPHI=9;
-  static constexpr int NBINETA=6;
-  double m_calphi[NBINPHI];
-  double m_caleta[NBINETA][3];
-  double m_calerrphi[NBINPHI][3];
-  double m_calerreta[NBINETA][3];
-  double m_phix[NBINPHI+1];
-  double m_etax[NBINETA+1];
-};
-
-//} // end of namespace FTK
-
-#endif // FTK_PixelClusterOnTrackTool_H
+#endif // FTK_PixelClusterOnTrackTool_H
diff --git a/Trigger/TrigFTK/FTK_RecTools/FTK_RecTools/FTK_VertexFinderTool.h b/Trigger/TrigFTK/FTK_RecTools/FTK_RecTools/FTK_VertexFinderTool.h
index ba699acc4d9..e26b078fece 100644
--- a/Trigger/TrigFTK/FTK_RecTools/FTK_RecTools/FTK_VertexFinderTool.h
+++ b/Trigger/TrigFTK/FTK_RecTools/FTK_RecTools/FTK_VertexFinderTool.h
@@ -99,23 +99,22 @@ class FTK_VertexFinderTool : public AthAlgTool, virtual public IFTK_VertexFinder
   //
   //  Get the element of the covariance matrix for id0th and id1th track parameter
   //
-//   VxContainer* findVertex(const FTK_RawTrackContainer* trks);
-//   VxContainer* findVertex(const TrackCollection* trks);
- 	 std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*> findVertex(const FTK_RawTrackContainer* trks);
-   std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*> findVertex(const TrackCollection* trks);
- private:
 
-    bool m_barrelOnly;
-    bool m_hasIBL;
-    double  m_cluster_size;
-    double m_chi2cut;
-    double m_constTrkPt;
-    double m_constTrkEta;
-    double m_z0errfactor;
+  std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*> findVertex(const FTK_RawTrackContainer* trks);
+  std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*> findVertex(const TrackCollection* trks);
+ private:
+  
+  bool m_barrelOnly;
+  bool m_hasIBL;
+  double  m_cluster_size;
+  double m_chi2cut;
+  double m_constTrkPt;
+  double m_constTrkEta;
+  double m_z0errfactor;
   //
   //  Helper functions with the uncerianties
   //
-    std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*> findVertex(std::vector<MyTrack>& trks);
+  std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*> findVertex(std::vector<MyTrack>& trks);
   double ctheta2eta(double cot);
   std::vector<MyTrack> getTracks(const FTK_RawTrackContainer* trks);
   std::vector<MyTrack> getTracks(const TrackCollection* trks);
diff --git a/Trigger/TrigFTK/FTK_RecTools/src/FTK_DuplicateTrackRemovalTool.cxx b/Trigger/TrigFTK/FTK_RecTools/src/FTK_DuplicateTrackRemovalTool.cxx
index 60a738eff67..8881c7f130e 100644
--- a/Trigger/TrigFTK/FTK_RecTools/src/FTK_DuplicateTrackRemovalTool.cxx
+++ b/Trigger/TrigFTK/FTK_RecTools/src/FTK_DuplicateTrackRemovalTool.cxx
@@ -124,7 +124,6 @@ void FTK_DuplicateTrackRemovalTool::addtophimap(double trackphi, unsigned int po
 }
 void FTK_DuplicateTrackRemovalTool::removefromphimap(double oldtrackphi, unsigned int e){
 
-	//remove the old track from the map
 	auto& vec = m_phimap[oldtrackphi];
 	auto ind = std::find(vec.begin(),vec.end(),e);
 	if (ind==vec.end()) ATH_MSG_WARNING("Wasn't in the map?! "<<oldtrackphi<<" "<<e);
@@ -132,16 +131,16 @@ void FTK_DuplicateTrackRemovalTool::removefromphimap(double oldtrackphi, unsigne
 
 	//take of removing wraparound entries
 	if (oldtrackphi>(CLHEP::pi-m_dphi_roughmatch)) {
-		vec = m_phimap[oldtrackphi-CLHEP::twopi];
-		auto ind = std::find(vec.begin(),vec.end(),e);
-		if (ind==vec.end()) ATH_MSG_WARNING("Wasn't in the map?! "<<oldtrackphi<<" "<<e);
-		else vec.erase(ind);
+	  vec = m_phimap[oldtrackphi-CLHEP::twopi];
+	  auto ind = std::find(vec.begin(),vec.end(),e);
+	  if (ind==vec.end()) ATH_MSG_WARNING("Wasn't in the map?! "<<oldtrackphi<<" "<<e);
+	  else vec.erase(ind);
 	}
 	else if (oldtrackphi<(-CLHEP::pi+m_dphi_roughmatch)) {
-		vec = m_phimap[oldtrackphi+CLHEP::twopi];
-		auto ind = std::find(vec.begin(),vec.end(),e);
-		if (ind==vec.end()) ATH_MSG_WARNING("Wasn't in the map?! "<<oldtrackphi<<" "<<e);
-		else vec.erase(ind);
+	  vec = m_phimap[oldtrackphi+CLHEP::twopi];
+	  auto ind = std::find(vec.begin(),vec.end(),e);
+	  if (ind==vec.end()) ATH_MSG_WARNING("Wasn't in the map?! "<<oldtrackphi<<" "<<e);
+	  else vec.erase(ind);
 	}
 }
 #endif
@@ -154,150 +153,150 @@ FTK_RawTrackContainer* FTK_DuplicateTrackRemovalTool::removeDuplicates(const FTK
 #endif
 
 #ifdef FTKDuplicateTrackRemovalUseMap
-	  m_phimap.clear();
-	  std::set<unsigned int> trackstokill;
+    m_phimap.clear();
+    std::set<unsigned int> trackstokill;
 #endif
 
   ATH_MSG_DEBUG("I'm in removeDuplicates!");
   m_trks_nodups->clear();
   m_trks_nodups->reserve(trks->size());
   for (unsigned int i = 0; i!=trks->size(); i++) {
-	  const FTK_RawTrack *track = trks->at(i);
-
-	  //now we should see whether this track overlaps with one (or more?) tracks already in the nodups container
-	  std::vector<unsigned int> matching_oldtracks;
-
+    const FTK_RawTrack *track = trks->at(i);
+    
+    //now we should see whether this track overlaps with one (or more?) tracks already in the nodups container
+    std::vector<unsigned int> matching_oldtracks;
+    
 #ifdef FTKDuplicateTrackRemovalUseMap
-	  //search just the range of phi in the map of old tracks near the phi of this new track
-	  //the map goes from -pi-dphi_roughmatch to pi+dphi_roughmatch, to handle wraparound
-	  double trackphi = track->getPhi();
-	  auto lower = m_phimap.lower_bound(trackphi-m_dphi_roughmatch);
-	  auto upper = m_phimap.upper_bound(trackphi+m_dphi_roughmatch);
-	  for (auto it=lower; it!=upper; it++){
-		  for (unsigned int e : it->second) {//these are the indices of the old tracks at each phi value in the phi range
-			  //ATH_MSG_DEBUG("Looking for match of track "<<i<<" with oldtrack "<<e);
-			  const FTK_RawTrack *oldtrack = m_trks_nodups->at(e);
-			  if (this->match(track,oldtrack)) {
-				  matching_oldtracks.push_back(e);
-			  }
-		  }
-	  }
+    //search just the range of phi in the map of old tracks near the phi of this new track
+    //the map goes from -pi-dphi_roughmatch to pi+dphi_roughmatch, to handle wraparound
+    double trackphi = track->getPhi();
+    auto lower = m_phimap.lower_bound(trackphi-m_dphi_roughmatch);
+    auto upper = m_phimap.upper_bound(trackphi+m_dphi_roughmatch);
+    for (auto it=lower; it!=upper; it++){
+      for (unsigned int e : it->second) {//these are the indices of the old tracks at each phi value in the phi range
+	//ATH_MSG_DEBUG("Looking for match of track "<<i<<" with oldtrack "<<e);
+	const FTK_RawTrack *oldtrack = m_trks_nodups->at(e);
+	if (this->match(track,oldtrack)) {
+	  matching_oldtracks.push_back(e);
+	}
+      }
+    }
 #else
-	  //loop over all old tracks and see if they match
-	  for (unsigned int e = 0; e!=m_trks_nodups->size(); e++) {
-		  const FTK_RawTrack *oldtrack = m_trks_nodups->at(e);
-
-		  //first check for a rough match in phi
-		  double dphi = TVector2::Phi_mpi_pi(track->getPhi()-oldtrack->getPhi());//make sure it's in -pi..pi
-		  dphi = fabs(dphi);//then take abs since we don't care about sign
-		  if (dphi>m_dphi_roughmatch) continue;//no match if dphi is larger than dphi_roughmatch, 0.3 by default
-
-		  if (this->match(track,oldtrack)) {
-			  matching_oldtracks.push_back(e);
-		  }
-	  }
+    //loop over all old tracks and see if they match
+    for (unsigned int e = 0; e!=m_trks_nodups->size(); e++) {
+      const FTK_RawTrack *oldtrack = m_trks_nodups->at(e);
+      
+      //first check for a rough match in phi
+      double dphi = TVector2::Phi_mpi_pi(track->getPhi()-oldtrack->getPhi());//make sure it's in -pi..pi
+      dphi = fabs(dphi);//then take abs since we don't care about sign
+      if (dphi>m_dphi_roughmatch) continue;//no match if dphi is larger than dphi_roughmatch, 0.3 by default
+      
+      if (this->match(track,oldtrack)) {
+	matching_oldtracks.push_back(e);
+      }
+    }
 #endif
 
-	  //ATH_MSG_DEBUG("Found "<<matching_oldtracks.size()<<" old tracks matching track "<<i);
-	  if (matching_oldtracks.size()==0){//if there's no match, just add the new track
+    //ATH_MSG_DEBUG("Found "<<matching_oldtracks.size()<<" old tracks matching track "<<i);
+    if (matching_oldtracks.size()==0){//if there's no match, just add the new track
 #ifdef FTKDuplicateTrackRemovalTestMultiple
-		  for (int j=0; j<3; ++j){ // ACH - temporary test - add multiple times, to test multiple matches!
+      for (int j=0; j<3; ++j){ // ACH - temporary test - add multiple times, to test multiple matches!
 #endif
 #ifdef FTKDuplicateTrackRemovalUseMap
-		  addtophimap(trackphi,m_trks_nodups->size());//so e.g. the first track will be index 0, since the size is 0 just before we push_back the first track
+	addtophimap(trackphi,m_trks_nodups->size());//so e.g. the first track will be index 0, since the size is 0 just before we push_back the first track
 #endif
-		  m_trks_nodups->push_back((FTK_RawTrack*)track);
+	m_trks_nodups->push_back((FTK_RawTrack*)track);
 #ifdef FTKDuplicateTrackRemovalTestMultiple
-		  } // ACH - temporary test - add multiple times, to test multiple matches!
+      } // ACH - temporary test - add multiple times, to test multiple matches!
 #endif
-	  }
-
-	  //if it does match, either replace the matching track(s) with this new track, or ignore this new track, depending on which track we like best
-	  else if (matching_oldtracks.size()==1){
-		  unsigned int e = matching_oldtracks[0];
-		  const FTK_RawTrack *oldtrack = m_trks_nodups->at(e);
-		  const FTK_RawTrack *besttrack = this->besttrack(track,oldtrack);
-		  if (besttrack==track){
+    }
+    
+    //if it does match, either replace the matching track(s) with this new track, or ignore this new track, depending on which track we like best
+    else if (matching_oldtracks.size()==1){
+      unsigned int e = matching_oldtracks[0];
+      const FTK_RawTrack *oldtrack = m_trks_nodups->at(e);
+      const FTK_RawTrack *besttrack = this->besttrack(track,oldtrack);
+      if (besttrack==track){
 #ifdef FTKDuplicateTrackRemovalUseMap
-			  removefromphimap(oldtrack->getPhi(),e);//remove the old track from the map
-			  addtophimap(trackphi,e);//add the new track to the map
+	removefromphimap(oldtrack->getPhi(),e);//remove the old track from the map
+	addtophimap(trackphi,e);//add the new track to the map
 #endif
-			  m_trks_nodups->at(e)=(FTK_RawTrack*)track;
-		  }
-		  else{
-			  //nothing to do - the better track was already in the output container
-		  }
-	  }
-
-	  else { // more than 1 matching existing track (yet the existing matching tracks did not match each other)
-		  ATH_MSG_WARNING("Found multiple tracks ("<<matching_oldtracks.size()<<") matching track "<<i);
-
-		  // is the new track better than all the matching old tracks?
-		  bool newisbest = true;//start with an optimistic attitude!
-		  for (unsigned int e : matching_oldtracks){
-			  const FTK_RawTrack *oldtrack = m_trks_nodups->at(e);
-			  const FTK_RawTrack *besttrack = this->besttrack(track,oldtrack);
-			  if (besttrack!=track){
-				  newisbest=false; // guess we're not the best, give up!
-				  break;
-			  }
-		  }
-
-		  // if the new track is better than all the matching old tracks, remove the old tracks and add this one, otherwise do nothing (the new track is dropped)
-		  if (newisbest){
+	m_trks_nodups->at(e)=(FTK_RawTrack*)track;
+      }
+      else{
+	//nothing to do - the better track was already in the output container
+      }
+    }
+    
+    else { // more than 1 matching existing track (yet the existing matching tracks did not match each other)
+      ATH_MSG_WARNING("Found multiple tracks ("<<matching_oldtracks.size()<<") matching track "<<i);
+      
+      // is the new track better than all the matching old tracks?
+      bool newisbest = true;//start with an optimistic attitude!
+      for (unsigned int e : matching_oldtracks){
+	const FTK_RawTrack *oldtrack = m_trks_nodups->at(e);
+	const FTK_RawTrack *besttrack = this->besttrack(track,oldtrack);
+	if (besttrack!=track){
+	  newisbest=false; // guess we're not the best, give up!
+	  break;
+	}
+      }
+      
+      // if the new track is better than all the matching old tracks, remove the old tracks and add this one, otherwise do nothing (the new track is dropped)
+      if (newisbest){
 			  //yikes, we're better than all the matching old tracks
-			  bool replacedfirsttrack = false;//I want to check that the algorithm really replaces the first old track with the new one, and just once
-			  for (unsigned int e : matching_oldtracks){
-
+	bool replacedfirsttrack = false;//I want to check that the algorithm really replaces the first old track with the new one, and just once
+	for (unsigned int e : matching_oldtracks){
+	  
 #ifdef FTKDuplicateTrackRemovalUseMap
-				  removefromphimap(m_trks_nodups->at(e)->getPhi(),e);
+	  removefromphimap(m_trks_nodups->at(e)->getPhi(),e);
 #endif
-				  if (e==matching_oldtracks[0]) {//this should be a little faster than removing all the old matching tracks and then adding the new one
-
+	  if (e==matching_oldtracks[0]) {//this should be a little faster than removing all the old matching tracks and then adding the new one
+	    
 #ifdef FTKDuplicateTrackRemovalUseMap
-					  addtophimap(trackphi,e);
+	    addtophimap(trackphi,e);
 #endif
-					  m_trks_nodups->at(e)=(FTK_RawTrack*)track; // replace the first matching track with this new track
-					  if (replacedfirsttrack) ATH_MSG_WARNING("We already did replace the first matching track!");
-					  replacedfirsttrack=true;//just check that we really did it!
-				  }
-				  else {
-					  //remove the old matching tracks beyond the first  one
+	    m_trks_nodups->at(e)=(FTK_RawTrack*)track; // replace the first matching track with this new track
+	    if (replacedfirsttrack) ATH_MSG_WARNING("We already did replace the first matching track!");
+	    replacedfirsttrack=true;//just check that we really did it!
+	  }
+	  else {
+	    //remove the old matching tracks beyond the first  one
 #ifdef FTKDuplicateTrackRemovalUseMap
-					  trackstokill.insert(e);//we'll remove these from the tracks returned at the end of the day, so we don't screw up the map in the meantime
+	    trackstokill.insert(e);//we'll remove these from the tracks returned at the end of the day, so we don't screw up the map in the meantime
 #else
-					  m_trks_nodups->erase(m_trks_nodups->begin()+e); // yes this is really the way you remove an element from a vector, you have to pass in the iterator
+	    m_trks_nodups->erase(m_trks_nodups->begin()+e); // yes this is really the way you remove an element from a vector, you have to pass in the iterator
 #endif
-				  }
-			  }
-			  if (!replacedfirsttrack)  ATH_MSG_WARNING("Why did I not replace the first track?!");
-
-		  } // new track is best one
-
-	  } // deciding what to do based on the number of matches
+	  }
+	}
+	if (!replacedfirsttrack)  ATH_MSG_WARNING("Why did I not replace the first track?!");
 
+      } // new track is best one
+      
+    } // deciding what to do based on the number of matches
+    
   } // loop over incoming tracks
-
+  
 #ifdef FTKDuplicateTrackRemovalUseMap
   //remove those tracks that we flagged for killing
   if (trackstokill.size()){
-	  ATH_MSG_WARNING("Killing an extra "<<trackstokill.size()<<" tracks from multiple matches");
-	  FTK_RawTrackContainer* trks_nodups_temp  = new FTK_RawTrackContainer(SG::VIEW_ELEMENTS);//we don't own the tracks, we're just going to hold them
-	  for (unsigned int e = 0; e!=m_trks_nodups->size(); e++) {
-		  if (std::find(trackstokill.begin(),trackstokill.end(),e)==trackstokill.end()) trks_nodups_temp->push_back((FTK_RawTrack*)m_trks_nodups->at(e));
-	  }
-	  m_trks_nodups->clear();
-	  delete m_trks_nodups;
-	  m_trks_nodups = trks_nodups_temp;
+    ATH_MSG_WARNING("Killing an extra "<<trackstokill.size()<<" tracks from multiple matches");
+    FTK_RawTrackContainer* trks_nodups_temp  = new FTK_RawTrackContainer(SG::VIEW_ELEMENTS);//we don't own the tracks, we're just going to hold them
+    for (unsigned int e = 0; e!=m_trks_nodups->size(); e++) {
+      if (std::find(trackstokill.begin(),trackstokill.end(),e)==trackstokill.end()) trks_nodups_temp->push_back((FTK_RawTrack*)m_trks_nodups->at(e));
+    }
+    m_trks_nodups->clear();
+    delete m_trks_nodups;
+    m_trks_nodups = trks_nodups_temp;
   }
 #endif
-
+  
 #ifdef FTKDuplicateTrackRemovalTiming
   } // loop over doing the removal
   clock_t tEnd = clock();
   double elapsed_secs = double(tEnd - tStart) / CLOCKS_PER_SEC;
   ATH_MSG_INFO("Time taken: "<<elapsed_secs<<" ms");//it's "ms", not "s", since we did 1000 times
 #endif
-
+  
   return m_trks_nodups;
 }
diff --git a/Trigger/TrigFTK/FTK_RecTools/src/FTK_HashIDTool.cxx b/Trigger/TrigFTK/FTK_RecTools/src/FTK_HashIDTool.cxx
new file mode 100644
index 00000000000..c8aaec5bbf2
--- /dev/null
+++ b/Trigger/TrigFTK/FTK_RecTools/src/FTK_HashIDTool.cxx
@@ -0,0 +1,529 @@
+/*
+  Copyright (C) 2018 CERN for the benefit of the ATLAS collaboration
+*/
+#include <vector>
+#include <string>
+#include <map>
+#include "FTK_RecTools/FTK_HashIDTool.h"
+#include "GeoPrimitives/GeoPrimitives.h"
+#include "TrigFTKSim/ftk_dcap.h"
+
+#include "TrigFTK_RawData/FTK_RawTrackContainer.h"
+#include "CLHEP/Vector/ThreeVector.h"
+#include "AtlasDetDescr/AtlasDetectorID.h"
+#include "InDetIdentifier/SCT_ID.h"
+#include "InDetIdentifier/PixelID.h"
+#include "InDetReadoutGeometry/PixelDetectorManager.h"
+#include "InDetReadoutGeometry/SCT_DetectorManager.h"
+#include "InDetReadoutGeometry/PixelModuleDesign.h"
+#include "InDetReadoutGeometry/SCT_ModuleSideDesign.h"
+#include "InDetReadoutGeometry/SCT_BarrelModuleSideDesign.h"
+#include "InDetReadoutGeometry/SCT_ForwardModuleSideDesign.h"
+#include "InDetReadoutGeometry/SiDetectorElement.h"
+#include "InDetPrepRawData/SiWidth.h"
+#include "InDetPrepRawData/PixelCluster.h"
+
+#include "TMath.h"
+
+using namespace std;
+
+using Amg::Vector3D;
+
+namespace {
+  inline double square(const double x){
+    return x*x;
+  }
+  const double ONE_TWELFTH = 1./12.;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+FTK_HashIDTool::FTK_HashIDTool(const std::string& t, 
+			       const std::string& n,
+			       const IInterface*  p ): 
+  AthAlgTool(t,n,p),
+  m_max_tower(64),
+  m_pixelId(0),
+  m_id_helper(0),
+  m_pixelManager(0),
+  m_maxD0(0.)
+{
+
+  declareProperty("ConstantsDir",m_ConstantsDir="/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/FTK","directory for constants");
+  declareProperty("PatternsVersion",m_PatternsVersion="DataAlignment2017_xm05_ym09_Reb64_v9","Patterns Version");
+  declareProperty("Ntowers",m_max_tower,"No. FTK Towers");
+  declareProperty("MaxD0",m_maxD0,"Truncate d0 at this maximum value");
+}
+
+FTK_HashIDTool::~FTK_HashIDTool()
+{ }
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+
+
+StatusCode FTK_HashIDTool::initialize(){
+
+
+  MsgStream athlog(msgSvc(), name());
+  ATH_MSG_INFO("FTK_HashIDTool::initialize()" );
+
+  ATH_MSG_INFO("ConstantsDir: "<<m_ConstantsDir);
+  ATH_MSG_INFO("PatternsVersion: "<<m_PatternsVersion);
+  ATH_MSG_INFO("Ntowers= " << m_max_tower);
+
+  StatusCode ret=StatusCode::SUCCESS;
+  m_moduleFromSector.resize(m_max_tower);
+  m_sector8toSector12.resize(m_max_tower);
+  for (unsigned int itower=0; itower<m_max_tower; itower++) {
+    
+    m_moduleFromSector[itower] = new ftk_sectormap();
+    unsigned int returnCode = (this)->readModuleIds(itower, *(m_moduleFromSector[itower]));
+  if (returnCode) {
+      ATH_MSG_WARNING("Error " << returnCode << " loading constants for tower " << itower);
+      ret=StatusCode::FAILURE;
+      break;
+    } 
+    
+  }  
+  if (ret.isSuccess()) {
+    StoreGateSvc* detStore;
+    ATH_CHECK(service("DetectorStore", detStore));
+    
+    ATH_CHECK(detStore->retrieve(m_pixelId, "PixelID"));
+    ATH_CHECK(detStore->retrieve(m_id_helper, "AtlasID"));
+    ATH_CHECK(detStore->retrieve(m_pixelManager));
+  }
+  return ret; 
+}
+
+
+
+bool FTK_HashIDTool::findHash(unsigned int hash, bool isSCT, unsigned int& tower, unsigned int& sector, unsigned int& plane) {
+  int i = (int) hash;
+  sector=tower=plane=0xffffffff;
+  bool found=false;
+
+  //  for (unsigned int itower = 0; itower < m_moduleFromSector.size(); itower++) {
+  ftk_sectormap* map = m_moduleFromSector[tower];
+  if (map) {   
+    //      for ( unsigned int isector=0; isector < map->size();isector++) {
+    if ((*map)[sector].size() > 0) {
+      auto first= (*map)[sector].begin();
+      if (isSCT) first+=4;
+      auto last = (*map)[sector].end();
+      if (!isSCT) last -=8;
+
+      auto p = std::find(first, last, i);
+      if ( p!= last ) {
+	plane = std::distance(first, p);
+
+      }
+    }
+  }
+
+  return found;
+}
+
+
+bool haveAuxTracks(const FTK_RawTrackContainer& inputTracks) {
+  bool haveAux=false;
+  for (auto track : inputTracks) {
+    if (track->getIsAuxFormat()) {
+      haveAux=true;
+      break;
+    }
+  }
+  return haveAux;
+}
+
+
+FTK_RawTrackContainer* FTK_HashIDTool::processTracks(const FTK_RawTrackContainer& inputTracks, const bool reverseIBL) {
+
+  FTK_RawTrackContainer* outputTracks = new FTK_RawTrackContainer();
+  ATH_MSG_DEBUG("FTK_HashIDTool::processTracks Created new FTK_RawTrackContainer at 0x" << std::hex<<outputTracks << std::dec);
+  
+  unsigned int nAuxTracks=0;
+  unsigned int nGoodAuxTracks=0;
+  unsigned int itrack=0;
+  for (auto track : inputTracks) {
+    std::vector<Amg::Vector3D> pointsOnTrack;
+    pointsOnTrack.reserve(3);
+    if (!track->getIsAuxFormat()) {
+      ATH_MSG_DEBUG(" Track " << itrack << " is in FLIC format");
+      outputTracks->push_back(new FTK_RawTrack(*track));
+    } else {
+      ATH_MSG_DEBUG(" Track " << itrack << " is in AUX format - converting");
+      nAuxTracks++;
+      uint32_t layermap = track->getLayerMap();
+      uint32_t idtower = track->getTower();
+      uint32_t idsector = track->getSectorID();
+      uint32_t layer=0;
+      FTK_RawTrack* newTrack = new FTK_RawTrack();
+      for( unsigned int ipix = 0; ipix < track->getPixelClusters().size(); ++ipix,++layer){
+	if (!track->isMissingPixelLayer(ipix)){
+	  FTK_RawPixelCluster clus(track->getPixelWordA(ipix),track->getPixelWordB(ipix),track->getPixelBarcode(ipix));
+	  uint32_t id = this->getHashFromAuxSector(idtower, idsector, layer);
+	  if (id == 0xffffffff) {
+	    ATH_MSG_WARNING(" Failed to get ID for pixel module with tower " << idtower << " sector " << idsector << "  layer " << layer);
+	    layermap &= ~(0x1 << layer); // clear bit for layer 
+	  } else {
+	    ATH_MSG_DEBUG(" pix " << ipix << " Setting module ID 0x" <<std::hex << id << std::dec);
+	    //ATH_MSG_DEBUG(" pix " << ipix << " Original   ID 0x" <<std::hex << track->getPixelClusters()[ipix].getModuleID() << std::dec);
+	  }
+	  clus.setModuleID(id);
+	  ATH_MSG_DEBUG(" clus.getModuleID(id) 0x" <<std::hex << clus.getModuleID() << std::dec);
+	  newTrack->setPixelCluster(ipix,clus);
+	  if (id !=0xffffffff) {
+	    ATH_MSG_DEBUG("newTrack->getPixelCluster(ipix).getModuleID() 0x"<<std::hex <<   newTrack->getPixelCluster(ipix).getModuleID() << std::dec);
+	    const Amg::Vector3D point = this->getPixelClusterPosition(clus,reverseIBL);
+	    pointsOnTrack.push_back(point);
+	  }
+	}
+      }
+      for( unsigned int isct = 0; isct < track->getSCTClusters().size(); ++isct,++layer){
+	if (!track->isMissingSCTLayer(isct)){
+	  uint32_t id = this->getHashFromAuxSector(idtower, idsector, layer);
+	  if (id == 0xffffffff) {
+	    ATH_MSG_WARNING(" Failed to get ID for SCT module with tower " << idtower << " sector " << idsector << "  layer " << layer);
+	    layermap &= ~(0x1 << layer); // clear bit for layer 
+	  } else {
+	    ATH_MSG_DEBUG(" sct " << isct << " Setting module ID 0x" <<std::hex << id << std::dec << " coord " << track->getSCTClusters()[isct].getHitCoord() );
+	    //ATH_MSG_DEBUG(" sct " << isct << " Original   ID 0x" <<std::hex << track->getSCTClusters()[isct].getModuleID() << std::dec);
+
+	  }
+	  
+	  FTK_RawSCT_Cluster clus(track->getSCTWord(isct),track->getSCTBarcode(isct));
+	  clus.setModuleID(id);
+	  newTrack->setSCTCluster(layer,clus);
+	  ATH_MSG_DEBUG(" NewTrack SCT cluster " << isct << " layer " << layer << " ModuleID 0x" << std::hex << newTrack->getSCTClusters()[isct].getModuleID() << std::dec << " coordinate " << newTrack->getSCTClusters()[isct].getHitCoord());
+	}  
+      }
+      float invpT=0.;
+      float d0=0.;
+      float z0=0.;
+      float phi=0.;
+      float cotTheta =0.;
+
+      if (pointsOnTrack.size() < 2) {
+	ATH_MSG_DEBUG(" Only " << pointsOnTrack.size() << " valid pixel clusters on track - can't calculate parameters, skipping track");
+	delete(newTrack);
+	continue;
+      } else if ( pointsOnTrack.size() ==2) {
+	ATH_MSG_DEBUG(" Only " << pointsOnTrack.size() << " valid pixel clusters on track - using origin as third point for pT estimation");
+	Amg::Vector3D origin(0.,0.,0.);
+	phi = this->get_phi(origin,pointsOnTrack[0],pointsOnTrack[1]);
+	invpT = this->get_invpT(origin,pointsOnTrack[0],pointsOnTrack[1]);
+	d0 = 0.;
+	z0 = this->get_z0(pointsOnTrack[0],pointsOnTrack[1]);
+	cotTheta= this->get_cotTheta(pointsOnTrack[0],pointsOnTrack[1]);
+      } else {
+	ATH_MSG_DEBUG(" Using 3 pixel points to get track parameters");
+	phi = this->get_phi(pointsOnTrack[0],pointsOnTrack[1],pointsOnTrack[2]);
+	invpT = this->get_invpT(pointsOnTrack[0],pointsOnTrack[1],pointsOnTrack[2]);
+	if (m_maxD0==0.) {
+	  d0=0.;
+	} else {
+	  d0 = this->get_d0(pointsOnTrack[0],pointsOnTrack[1],pointsOnTrack[2]);
+	  if (std::fabs(d0)>m_maxD0) d0=(d0>0?m_maxD0:-m_maxD0);
+	}
+	z0 = this->get_z0(pointsOnTrack[0],pointsOnTrack[2]);
+	cotTheta = this->get_cotTheta(pointsOnTrack[0],pointsOnTrack[2]);
+      }
+      newTrack->setChi2(1.);
+      newTrack->setInvPt(invpT);
+      newTrack->setPhi(phi);
+      newTrack->setD0(d0);
+      newTrack->setZ0(z0);
+      newTrack->setCotTh(cotTheta);
+      newTrack->setLayerMap(layermap);
+      newTrack->setSectorID(idsector);
+      newTrack->setSectorID(idtower);
+      newTrack->setRoadID(track->getRoadID());
+
+      ATH_MSG_DEBUG (itrack << ": AUX      : phi " << phi << " cotTheta " << cotTheta << " invpT " << invpT << " d0 " << d0 << " z0 " << z0);
+      //      ATH_MSG_DEBUG (itrack << ": ORIGINAL : phi " << track->getPhi() << " cotTheta " << track->getCotTh() << " invpT " << track->getInvPt() << " d0 " << track->getD0() << " z0 " << track->getZ0());
+      float ftkTrkTheta = std::atan2(1.0,newTrack->getCotTh());
+      float ftkTrkEta = -std::log(std::tan(ftkTrkTheta/2.));
+      float ftkTrkPt=1.e12;
+      if (fabs(newTrack->getInvPt()) >= 1.e-12) ftkTrkPt=1./newTrack->getInvPt();
+      
+      ATH_MSG_DEBUG( itrack << ": pT: " << ftkTrkPt  << " eta: " << ftkTrkEta << " phi: " <<  newTrack->getPhi() << " d0: " << newTrack->getD0() <<
+		       " z0: " << newTrack->getZ0()<< " cot " << newTrack->getCotTh() << " theta " << ftkTrkTheta << " invPt " << newTrack->getInvPt() <<
+		       " nPix: " << newTrack->getPixelClusters().size() << " nSCT: "<< newTrack->getSCTClusters().size()  );
+      ATH_MSG_DEBUG( "     SectorID " << newTrack->getSectorID()   <<   "  RoadID "  << newTrack->getRoadID() << " LayerMap 0x" << std::hex << newTrack->getLayerMap()<<std::dec);
+	
+
+      nGoodAuxTracks++;
+      outputTracks->push_back(newTrack);
+    
+    }
+    itrack++;
+  }
+  ATH_MSG_DEBUG("FTK_HashIDTool::processTracks processed " << inputTracks.size() << " tracks of which " << nAuxTracks << " were Aux Tracks " << " of which " << nGoodAuxTracks << " were processed successfully");
+  return outputTracks;
+}
+
+	
+unsigned int FTK_HashIDTool::getHash(unsigned int tower, unsigned int sector,  unsigned int plane) {
+  unsigned int hash =  0xffffffff;
+  if (plane >= 12) {
+    ATH_MSG_ERROR("getHash: Invalid plane " << plane);
+    return hash;
+  }
+  if (m_moduleFromSector[tower]==nullptr) return hash;
+  if ((*m_moduleFromSector[tower]).size() <= sector) return hash;
+  if (plane >=(*m_moduleFromSector[tower])[sector].size()) return hash;
+  return (unsigned int)(*m_moduleFromSector[tower])[sector][plane];
+}
+
+
+unsigned int FTK_HashIDTool::getHashFromAuxSector(unsigned int tower, unsigned int sector,  unsigned int plane) {
+  unsigned int hash =  0xffffffff;
+  if (plane >= 12) {
+    ATH_MSG_ERROR("getHashFromAuxSector: Invalid plane " << plane);
+    return hash;
+  }
+  if (sector>m_sector8toSector12[tower].size()) {
+    ATH_MSG_ERROR("getHashFromAuxSector: Invalid sector " << sector << " max " << m_sector8toSector12.size()-1);
+    return hash;
+  }
+  unsigned int remappedSector=m_sector8toSector12[tower][sector];
+  if (m_moduleFromSector[tower]==nullptr) return hash;
+  if ((*m_moduleFromSector[tower]).size() <= remappedSector) return hash;
+  if (plane >=(*m_moduleFromSector[tower])[remappedSector].size()) return hash;
+  return (unsigned int)(*m_moduleFromSector[tower])[remappedSector][plane];
+}
+
+
+int FTK_HashIDTool::readModuleIds(unsigned int itower, ftk_sectormap& hashID) {
+   int nSector8L,nPlane8L;
+   // define which 8L plane goes to which 12L plane
+   vector<int> const remapPlanes={1,2,3, 4,6,8,9,10, 0,5,7,11};
+   enum {
+      ERROR_PATTFILE=1,
+      ERROR_CONNFILE=2
+   };
+
+
+   std::stringstream ssPat, ssCon;
+   ssPat << m_ConstantsDir<<"/FitConstants/"<<m_PatternsVersion<<"/sectors_raw_8L_reg"<<itower<<".patt.bz2";
+   
+   std::string pattfilename=ssPat.str();
+   ATH_MSG_DEBUG("Sectors file: "<<pattfilename);
+   const char * cpattfilename = pattfilename.c_str();
+   std::unique_ptr<ftk_dcap::istream> patt_8L = std::unique_ptr<ftk_dcap::istream> (ftk_dcap::open_for_read(cpattfilename));
+   if(!patt_8L) {
+     ATH_MSG_WARNING("readSectorDefinition failed to open file "<<cpattfilename
+		     <<" for reading, skipping");
+     return ERROR_PATTFILE;
+   }
+   ssCon << m_ConstantsDir<<"/FitConstants/"<<m_PatternsVersion<<"/sectors_raw_8L_reg"<<itower<<".conn";
+   std::string connfilename=ssCon.str();
+   ATH_MSG_DEBUG("Connections file: "<<connfilename);
+   const char * charconnfilename = connfilename.c_str();
+   ifstream conn(charconnfilename);
+   if (!conn) {
+     ATH_MSG_WARNING("readSectorDefinition failed to open file "<<charconnfilename
+		     <<" for reading, skipping");
+
+     return ERROR_CONNFILE;
+   }
+
+   (*patt_8L)>>nSector8L>>nPlane8L;
+   // check errors here
+   //   (*patt_8L).fail(), nSector8L>0, 0<nPlane8L<remapPlanes.size()
+   int lastSector8=-1;
+   int lastSector12=-1;
+   int error=0;
+
+   unsigned int icount=0;
+   while(!((*patt_8L).eof()||conn.eof())) {
+      int iSectorPatt,iSectorConn;
+      (*patt_8L)>>iSectorPatt;
+      conn>>iSectorConn;
+      if((*patt_8L).fail()||conn.fail()) {
+         // end
+         break;
+      }
+      if((iSectorPatt!=lastSector8+1)||
+         (iSectorPatt!=iSectorConn)||
+         (iSectorPatt<0)||(iSectorPatt>=nSector8L)) {
+         error=ERROR_PATTFILE;
+         // file is corrupted
+         break;
+      }
+
+      m_sector8toSector12[itower].push_back(icount);
+
+      vector<int> moduleData(remapPlanes.size());
+      // read 8L module IDs
+      for(int k=0;k<nPlane8L;k++) {
+         (*patt_8L)>>moduleData[remapPlanes[k]];
+      }
+      int dummy;
+      // skip dummy entries
+      (*patt_8L)>>dummy;
+      (*patt_8L)>>dummy;
+      // read connection data and store 12L module data
+
+      int n12;
+      conn>>n12;
+      for(int i=0;i<n12;i++) {
+         int sector12;
+         conn>>dummy>>sector12;
+         if(lastSector12+1!=sector12) {
+            error=ERROR_CONNFILE;
+            break;
+         }
+         for(unsigned int k=nPlane8L;k<remapPlanes.size();k++) {
+            conn>>moduleData[remapPlanes[k]];
+         }
+	 hashID.push_back(moduleData);
+         lastSector12=sector12;
+	 icount++;
+      }
+      if(error) break;
+
+      lastSector8=iSectorPatt;
+   }
+
+     
+
+   return error;
+}
+
+
+
+const Amg::Vector3D FTK_HashIDTool::getPixelClusterPosition(const FTK_RawPixelCluster& raw_pixel_cluster, const bool reverseIBL) {
+  IdentifierHash hash = raw_pixel_cluster.getModuleID();
+  Identifier wafer_id = m_pixelId->wafer_id(hash); // Need to set up this tool
+  const InDetDD::SiDetectorElement* pDE = m_pixelManager->getDetectorElement(hash);
+
+  ATH_MSG_VERBOSE( "FTK_HashIDTool::getPixelClusterPosition: Pixel FTKHit hashID 0x" << std::hex << hash << std::dec << " " << m_id_helper->print_to_string(pDE->identify()));
+
+  const InDetDD::SiDetectorElement* pixelDetectorElement = m_pixelManager->getDetectorElement(hash);
+  const InDetDD::PixelModuleDesign* design
+    (dynamic_cast<const InDetDD::PixelModuleDesign*>(&pixelDetectorElement->design()));
+
+  ATH_MSG_VERBOSE( "FTK_HashIDTool::getPixelClusterPosition: raw FTK cluster position: " <<
+      " Row(phi): " <<  raw_pixel_cluster.getRowCoord() << " Col(eta): " << raw_pixel_cluster.getColCoord() <<
+      " RowWidth: " << raw_pixel_cluster.getRowWidth() << " ColWidth: " << raw_pixel_cluster.getColWidth());
+
+  unsigned int layer = m_pixelId->layer_disk(wafer_id);
+  bool isBarrel = (m_pixelId->barrel_ec(wafer_id)==0);
+
+
+  if (isBarrel) {
+    if (layer==0) {
+      ATH_MSG_VERBOSE( "FTK_HashIDTool::getPixelClusterPosition: IBL ");
+    } else {
+      ATH_MSG_VERBOSE( "FTK_HashIDTool::getPixelClusterPosition: Pixel Barrel layer  " << layer);
+    }
+  } else {
+    ATH_MSG_VERBOSE( "FTK_HashIDTool::getPixelClusterPosition: Pixel Endcap layer  " << layer);
+  }
+  ATH_MSG_VERBOSE( "FTK_HashIDTool::getPixelClusterPosition: Module rows= " << design->rows() << " phiPitch= " << design->phiPitch() << " width= " << design->width() );
+  ATH_MSG_VERBOSE( "FTK_HashIDTool::getPixelClusterPosition: columns = " << design->columns() << " etaPitch= " << design->etaPitch() <<  " length " << design->length());
+
+  int rawLocalPhiCoord;
+  
+  if (reverseIBL && isBarrel && layer==0) {
+    rawLocalPhiCoord = 2680 -  raw_pixel_cluster.getRowCoord(); //335*8=2680
+  } else {
+    rawLocalPhiCoord = raw_pixel_cluster.getRowCoord();
+  }
+
+  int rawLocalEtaCoord= raw_pixel_cluster.getColCoord();
+
+  const InDetDD::SiCellId cornerCell(0, 0);
+  const InDetDD::SiLocalPosition localPositionOfCornerCell = design->localPositionOfCell(cornerCell);
+  const double phi0 = localPositionOfCornerCell.xPhi();
+  const double eta0 = localPositionOfCornerCell.xEta();
+
+  ATH_MSG_VERBOSE( "FTK_HashIDTool::getPixelClusterPosition: local position of pixel at (0,0) is "<<  phi0 << ",  " << eta0);
+
+
+
+  // ftk row coordinates: units of 6.25 microns, origin is centre of zeroth pixel
+  // ftk column coordinates: units of 25 microns, origin is edge of the zeroth coordinate
+
+  double phiPos = ((double) rawLocalPhiCoord) * 6.25e-3 + phi0; // rawLocalPhiCoord=0 is the centre of the zeroth pixel
+
+  if (!isBarrel) phiPos-=0.025; // correcttion for the fact that rawLocalPhiCoord=0 seems to be the edge of the endcap pixel, not the centre!
+  
+  double etaPos=0.;
+  if (isBarrel && layer==0) {
+    etaPos = ((double) rawLocalEtaCoord) * 25.0e-3 + eta0 - 0.25; // rawLocalEtaCoord=0 is the edge (-0.25mm) of the zeroth IBL pixel.
+  } else {
+    etaPos = ((double) rawLocalEtaCoord) * 25.0e-3 + eta0 - 0.3; // rawLocalEtaCoord=0 is the edge (-0.3mm) of the zeroth pixel.
+  }
+
+  ATH_MSG_VERBOSE( "FTK_HashIDTool::getPixelClusterPosition: Cluster position phiPos, etaPos "<<  phiPos << ", " << etaPos);
+
+  if ( etaPos >  design->length()/2.) {
+    ATH_MSG_DEBUG( "FTK_HashIDTool::getPixelClusterPosition: Illegal position: Setting Cluster eta position to module length/2.");
+    etaPos = design->length()/2.;
+  } else if (  etaPos <  -design->length()/2. ) {
+    etaPos = -design->length()/2.;
+    ATH_MSG_DEBUG( "FTK_HashIDTool::getPixelClusterPosition: Illegal position: Setting Cluster eta position to -(module length/2.)");
+  }
+  if ( phiPos >  design->width()/2.) {
+    phiPos = design->width()/2.;
+    ATH_MSG_DEBUG( "FTK_HashIDTool::getPixelClusterPosition: Illegal position: Setting Cluster phi position to module width/2.");
+  } else if (  phiPos <  -design->width()/2. ) {
+    phiPos = -design->width()/2.;
+    ATH_MSG_DEBUG( "FTK_HashIDTool::getPixelClusterPosition: Illegal position: Setting Cluster phi position to -(module width/2.)");
+  }
+  const InDetDD::SiLocalPosition cellLocalPosition(etaPos,phiPos);
+
+  const InDetDD::SiCellId  cell = design->cellIdOfPosition(cellLocalPosition);
+
+  int phi_index = cell.phiIndex();
+  int eta_index = cell.etaIndex();
+  ATH_MSG_VERBOSE( "FTK_HashIDTool::getPixelClusterPosition: Cell created with phiIndex " << phi_index << " eta_index " <<   eta_index << " expected: phiIndex " << (int) ((phiPos-phi0)/design->phiPitch()) << " eta index " << (int) ((etaPos-eta0)/design->etaPitch()));
+
+
+  Identifier pixel_id = m_pixelId->pixel_id(wafer_id, phi_index, eta_index);
+
+
+  int phiWidth    = std::max(raw_pixel_cluster.getRowWidth(),1u);
+  int etaWidth    = std::max(raw_pixel_cluster.getColWidth(),1u);
+
+  int colMin = (int)(eta_index-0.5*etaWidth);
+  int colMax = colMin+etaWidth;
+
+  int rowMin = (int)(phi_index-0.5*phiWidth);
+  int rowMax = rowMin+phiWidth;
+
+
+  double etaW = design->widthFromColumnRange(colMin, colMax-1);
+  double phiW = design->widthFromRowRange(rowMin, rowMax-1);
+
+
+  ATH_MSG_VERBOSE("phiW = design->widthFromRowRange("<<rowMin<<","<<rowMax-1<<") = " << phiW);
+  ATH_MSG_VERBOSE("etaW = design->widthFromRowRange("<<colMin<<","<<colMax-1<<") = " << etaW);
+
+  InDet::SiWidth siWidth(Amg::Vector2D(phiWidth,etaWidth),Amg::Vector2D(phiW,etaW));
+
+  Amg::Vector2D position(phiPos,etaPos);
+
+  ATH_MSG_VERBOSE("FTK_HashIDTool::getPixelClusterPosition: local coordinates phiPos, etaPos"<<  phiPos << ", " << etaPos);
+  ATH_MSG_VERBOSE("FTK_HashIDTool::getPixelClusterPosition: FTK cluster phiwidth " << phiWidth << " etawidth " <<  etaWidth << " siWidth.phiR() " << siWidth.phiR() << " siWidth.z() " << siWidth.z());
+
+  std::vector<Identifier> rdoList;
+  rdoList.push_back(pixel_id);
+
+  Amg::MatrixX* cov = new Amg::MatrixX(2,2);
+  cov->setZero();
+
+  (*cov)(0,0) = siWidth.phiR()*siWidth.phiR()*ONE_TWELFTH;
+  (*cov)(1,1) = siWidth.z()*siWidth.z()* ONE_TWELFTH;
+
+  ATH_MSG_VERBOSE("FTK_HashIDTool::getPixelClusterPosition: Setting defaulterrors (*cov)(0,0) " <<  (*cov)(0,0) << " (*cov)(1,1)" << (*cov)(1,1) );
+
+  InDet::PixelCluster pixel_cluster(pixel_id, position, rdoList, siWidth,pixelDetectorElement, cov);
+
+  Amg::Vector3D pos (pixel_cluster.globalPosition().x(),pixel_cluster.globalPosition().y(), pixel_cluster.globalPosition().z());
+
+  return pos;
+}
diff --git a/Trigger/TrigFTK/FTK_RecTools/src/FTK_PixelClusterOnTrackTool.cxx b/Trigger/TrigFTK/FTK_RecTools/src/FTK_PixelClusterOnTrackTool.cxx
index 73059acead5..cfe0500eb3c 100644
--- a/Trigger/TrigFTK/FTK_RecTools/src/FTK_PixelClusterOnTrackTool.cxx
+++ b/Trigger/TrigFTK/FTK_RecTools/src/FTK_PixelClusterOnTrackTool.cxx
@@ -174,18 +174,6 @@ FTK_PixelClusterOnTrackTool::initialize() {
     ATH_MSG_WARNING("Can not retrieve " << m_storeGate << ". Exiting.");
     return StatusCode::FAILURE;
   }
-
-  /* ME : booking of test histos is something to be hidden from production code !
-     sc = service("HistogramDataSvc", m_HistSvc, true);
-     // Define here the histograms;
-     m_h_Resx = m_HistSvc->book(m_foldername,"Resx","X shift (um)",400,-400.,400.);
-     m_h_Resy = m_HistSvc->book(m_foldername,"Resy","Y shift (um)",400,-400.,400.);
-     m_h_Locx = m_HistSvc->book(m_foldername,"Locx","X position (mm)",400,-20.,20.);
-     m_h_Locy = m_HistSvc->book(m_foldername,"Locy","Y position (mm)",800,-40.,40.);
-     m_h_ThetaTrack = m_HistSvc->book(m_foldername,"ThetaTrack","Theta Track (rad)",140,-7.,7);
-     m_h_PhiTrack = m_HistSvc->book(m_foldername,"PhiTrack","Phi Track (rad)",140,-7.,7);
-   */
-   
    
   m_dRMap = SG::ReadHandleKey<InDet::DRMap>(m_dRMapName);
   ATH_CHECK( m_dRMap.initialize() );
@@ -198,9 +186,9 @@ FTK_PixelClusterOnTrackTool::initialize() {
   m_etax[0]=0.; m_etax[NBINETA]=2.7;
   for (int i=0; i<NBINETA-1; i++) m_etax[i+1]=(etacen[i]+etacen[i+1])/2.;
 
-  ///UGLY!
+  //UGLY!
 #include "IBL_calibration.h"
-  ///  
+  //  
 
   ATH_CHECK(m_lorentzAngleTool.retrieve());
    
diff --git a/Trigger/TrigFTK/FTK_RecTools/src/FTK_SCTClusterOnTrackTool.cxx b/Trigger/TrigFTK/FTK_RecTools/src/FTK_SCTClusterOnTrackTool.cxx
index 7f5be3c1f95..cde73bcba4e 100644
--- a/Trigger/TrigFTK/FTK_RecTools/src/FTK_SCTClusterOnTrackTool.cxx
+++ b/Trigger/TrigFTK/FTK_RecTools/src/FTK_SCTClusterOnTrackTool.cxx
@@ -16,7 +16,6 @@
 
 #include "TrkSurfaces/RectangleBounds.h"
 #include "TrkSurfaces/TrapezoidBounds.h"
-
 #include "TrkRIO_OnTrack/check_cast.h"
 
 using CLHEP::micrometer;
@@ -26,17 +25,15 @@ using CLHEP::deg;
 // Constructor
 ///////////////////////////////////////////////////////////////////
 
-FTK_SCTClusterOnTrackTool::FTK_SCTClusterOnTrackTool
-  (const std::string &t, const std::string &n, const IInterface *p) :
+FTK_SCTClusterOnTrackTool::FTK_SCTClusterOnTrackTool (const std::string &t, const std::string &n, const IInterface *p) :
   AthAlgTool(t, n, p),
   m_distortionsTool("SCT_DistortionsTool", this),
   m_option_make2dimBarrelClusters(false),
   m_doDistortions(false),
   m_option_errorStrategy(-1),
   m_option_correctionStrategy(-1) {
-  // declareInterface<FTK_SCTClusterOnTrackTool>(this);
   declareInterface<IRIO_OnTrackCreator>(this);
-
+  
   declareProperty("MakeTwoDimBarrelClusters", m_option_make2dimBarrelClusters,
                   "flag if strip length should be part of the measurement");
   declareProperty("ErrorStrategy", m_option_errorStrategy,
@@ -98,7 +95,6 @@ FTK_SCTClusterOnTrackTool::initialize() {
   }
 
   ATH_CHECK(m_lorentzAngleTool.retrieve());
-
   return sc;
 }
 
diff --git a/Trigger/TrigFTK/FTK_RecTools/src/components/FTK_RecTools_entries.cxx b/Trigger/TrigFTK/FTK_RecTools/src/components/FTK_RecTools_entries.cxx
index 7968522d92a..06fa95a0351 100644
--- a/Trigger/TrigFTK/FTK_RecTools/src/components/FTK_RecTools_entries.cxx
+++ b/Trigger/TrigFTK/FTK_RecTools/src/components/FTK_RecTools_entries.cxx
@@ -3,8 +3,10 @@
 #include "FTK_RecTools/FTK_PixelClusterOnTrackTool.h"
 #include "FTK_RecTools/FTK_SCTClusterOnTrackTool.h"
 #include "FTK_RecTools/FTK_DuplicateTrackRemovalTool.h"
+#include "FTK_RecTools/FTK_HashIDTool.h"
 
 DECLARE_COMPONENT( FTK_VertexFinderTool )
+DECLARE_COMPONENT( FTK_HashIDTool )
 DECLARE_COMPONENT( FTK_PixelClusterOnTrackTool )
 DECLARE_COMPONENT( FTK_SCTClusterOnTrackTool )
 DECLARE_COMPONENT( FTK_DuplicateTrackRemovalTool )
diff --git a/Trigger/TrigFTK/TrigFTKByteStream/src/FTKByteStreamDecoderEncoder.cxx b/Trigger/TrigFTK/TrigFTKByteStream/src/FTKByteStreamDecoderEncoder.cxx
index 1c7f17c14c2..61042b6eb7d 100644
--- a/Trigger/TrigFTK/TrigFTKByteStream/src/FTKByteStreamDecoderEncoder.cxx
+++ b/Trigger/TrigFTK/TrigFTKByteStream/src/FTKByteStreamDecoderEncoder.cxx
@@ -46,6 +46,8 @@ namespace FTK {
   FTKByteStreamDecoderEncoderTool::~FTKByteStreamDecoderEncoderTool(){;}
 
   StatusCode   FTKByteStreamDecoderEncoderTool::initialize(){
+    if (m_doHeader) ATH_MSG_INFO("Unpacking Header of size " << FTKByteStreamDecoderEncoder::headerSize);
+    if (m_doTrailer) ATH_MSG_INFO("Unpacking Trailer ");
     return StatusCode::SUCCESS;
   }
 
@@ -117,9 +119,12 @@ namespace FTK {
   }
 
   FTK_RawTrack* FTKByteStreamDecoderEncoderTool::unpackFTTrack( OFFLINE_FRAGMENTS_NAMESPACE::PointerType data){
-    FTK_RawTrack* track = new FTK_RawTrack(data[0], data[1], data[2], data[3], data[4], data[5]); // first six words are track params
+    uint32_t data2 = (data[2] & 0xffffff) | ((FTK_RAWTRACK_VERSION)<<24); // force to latest version
+    FTK_RawTrack* track = new FTK_RawTrack(data[0], data[1], data2, data[3], data[4], data[5]); // first six words are track params
     ATH_MSG_DEBUG("[Track: " << track->getInvPt() << " " << track->getPhi() << " " 
 		  << track->getCotTh() << " " << track->getD0() << "]");
+    track->setIsAuxFormat(false);
+
     data += TrackParamsBlobSize;
   
     // get pixel hits  
@@ -163,10 +168,10 @@ namespace FTK {
     if (marker!=FTKByteStreamDecoderEncoder::headerMarker){
       ATH_MSG_DEBUG("Not dealing with an FTK fragment " << std::hex << marker << " vs the marker " << FTKByteStreamDecoderEncoder::headerMarker << std::dec );
       //rodData += FTKByteStreamDecoderEncoder::headerSize -1;
-      return;
+      //return;
     }
     //skip to the end
-    rodData += 9;
+    rodData += FTKByteStreamDecoderEncoder::headerSize;
   }
 
   void FTKByteStreamDecoderEncoderTool::packTrailer(std::vector<uint32_t> &payload){
@@ -257,9 +262,25 @@ namespace FTK {
 
   StatusCode FTKByteStreamDecoderEncoderTool::decode(const uint32_t nDataWords, OFFLINE_FRAGMENTS_NAMESPACE::PointerType rodData, FTK_RawTrackContainer* result) {
     
-    ATH_MSG_DEBUG("rodData: " << rodData);
-
-    uint32_t nTracks = nDataWords / TrackBlobSize;
+    uint32_t tracktotalsize=nDataWords;
+    if (m_doHeader){
+      if (tracktotalsize > FTKByteStreamDecoderEncoder::headerSize) {
+	tracktotalsize -= FTKByteStreamDecoderEncoder::headerSize;
+      } else {
+	ATH_MSG_VERBOSE("FTKByteStreamDecoderEncoderAuxTool::decode for nDataWords= "  << nDataWords << " Ntracks= 0");
+	return StatusCode::SUCCESS;
+      }
+    }
+    if (m_doTrailer){
+      if (tracktotalsize >FTKByteStreamDecoderEncoder:: trailerSize) {
+	tracktotalsize -= FTKByteStreamDecoderEncoder::trailerSize;
+      } else {
+	ATH_MSG_VERBOSE("FTKByteStreamDecoderEncoderAuxTool::decode for nDataWords= "  << nDataWords << " Ntracks= 0");
+	return StatusCode::SUCCESS;
+      }
+    }
+    uint32_t nTracks = tracktotalsize / TrackBlobSize;
+    ATH_MSG_VERBOSE("FTKByteStreamDecoderEncoderAuxTool::decode for nDataWords= " << nDataWords<< " Ntracks= " << nTracks);
     
     if (m_doHeader){
       unpackHeader(rodData);
diff --git a/Trigger/TrigFTK/TrigFTKByteStream/src/FTKByteStreamDecoderEncoder.h b/Trigger/TrigFTK/TrigFTKByteStream/src/FTKByteStreamDecoderEncoder.h
index 4c16cf5ad9d..6af81671a47 100644
--- a/Trigger/TrigFTK/TrigFTKByteStream/src/FTKByteStreamDecoderEncoder.h
+++ b/Trigger/TrigFTK/TrigFTKByteStream/src/FTKByteStreamDecoderEncoder.h
@@ -15,7 +15,8 @@
 
 namespace FTKByteStreamDecoderEncoder {
   const uint32_t headerMarker = 0xee1234ee; 
-  const uint32_t headerSize   = 0x9;
+  const uint32_t headerSize   = 9;
+  const uint32_t trailerSize   = 0;
   const size_t TrackBlobSize = 22; // magic number from BS specification
   const size_t TrackParamsBlobSize = 6; // --||--
   const size_t PixHitParamsBlobSize = 2; // --||--
diff --git a/Trigger/TrigFTK/TrigFTKByteStream/src/FTKByteStreamDecoderEncoderAux.cxx b/Trigger/TrigFTK/TrigFTKByteStream/src/FTKByteStreamDecoderEncoderAux.cxx
index 37c34cc3b25..99884b075ab 100644
--- a/Trigger/TrigFTK/TrigFTKByteStream/src/FTKByteStreamDecoderEncoderAux.cxx
+++ b/Trigger/TrigFTK/TrigFTKByteStream/src/FTKByteStreamDecoderEncoderAux.cxx
@@ -35,7 +35,7 @@ namespace FTK {
 								   const std::string& type, 
 								   const IInterface* parent) 
     : AthAlgTool(toolname, type, parent),
-      m_doHeader(false),
+      m_doHeader(true),
       m_doTrailer(false)
   {
     declareInterface< IFTKByteStreamDecoderEncoderTool  >( this );
@@ -85,7 +85,7 @@ namespace FTK {
   void FTKByteStreamDecoderEncoderAuxTool::unpackPixCluster(OFFLINE_FRAGMENTS_NAMESPACE::PointerType data, 
 							 FTK_RawPixelCluster& cluster){
     cluster.setWordA(0); // no moduleID
-    cluster.setWordB(*(data+1));
+    cluster.setWordB(*data);
   }
 
   void FTKByteStreamDecoderEncoderAuxTool::packSCTCluster(const FTK_RawSCT_Cluster& cluster, 
@@ -104,8 +104,8 @@ namespace FTK {
   void FTKByteStreamDecoderEncoderAuxTool::unpackSCTCluster(OFFLINE_FRAGMENTS_NAMESPACE::PointerType data, 
 							 FTK_RawSCT_Cluster& cluster){
 
-    uint32_t coord = (*(data+1) & 0x7ff);
-    uint32_t width = (((*(data+1)>>12) & 0x7));
+    uint32_t coord = (*data & 0x7ff);
+    uint32_t width = ( ((*data)>>12) & 0x7);
     uint32_t word = (width<<28) + (coord<<16); 
     cluster.setWord(word);
   }
@@ -131,10 +131,21 @@ namespace FTK {
 
     FTK_RawTrack* track = new FTK_RawTrack();
     track->setSectorID(data[0] & 0xffff);
-    track->setTower(m_towerID);  // Bugfix for towerID set to 0 in data
+    //    track->setTower(m_towerID);  // Bugfix for towerID set to 0 in data
+    track->setTower((data[0]>>24) & 0x3f);  // Bugfix for towerID set to 0 in data
     track->setRoadID(data[1] & 0xffffff);
-    track->setLayerMap(0x75e);
-    
+    uint32_t lay1 = (data[0]>>16)&0x1;
+    uint32_t lay2 = (data[0]>>17)&0x1;
+    uint32_t lay3 = (data[0]>>18)&0x1;
+    uint32_t lay4 = (data[0]>>19)&0x1;
+    uint32_t lay6 = (data[0]>>20)&0x1;
+    uint32_t lay8 = (data[0]>>21)&0x1;
+    uint32_t lay9 = (data[0]>>22)&0x1;
+    uint32_t lay10 = (data[0]>>23)&0x1;
+    uint32_t layermap = (lay1<<1 | lay2<<2 | lay3<<3 | lay4<<4 | lay6<<6 | lay8 <<8 | lay9 << 9 | lay10 << 10);
+    track->setLayerMap(layermap); 
+    track->setIsAuxFormat(true);
+
     data += TrackParamsBlobSize;
     
 
@@ -142,7 +153,6 @@ namespace FTK {
     // get pixel hits  
     track->getPixelClusters().resize(NPixLayers);
     for ( size_t i = 1; i < NPixLayers; ++i) {
-
       unpackPixCluster(data, track->getPixelCluster(i) );    
       data += PixHitParamsBlobSize;
 
@@ -181,15 +191,9 @@ namespace FTK {
   }
 
   void FTKByteStreamDecoderEncoderAuxTool::unpackHeader(OFFLINE_FRAGMENTS_NAMESPACE::PointerType &rodData){
-    //marker
-    uint32_t marker = rodData[0];
-    if (marker!=FTKByteStreamDecoderEncoderAux::headerMarker){
-      ATH_MSG_DEBUG("Not dealing with an FTK fragment " << std::hex << marker << " vs the marker " << FTKByteStreamDecoderEncoderAux::headerMarker << std::dec );
-      //rodData += FTKByteStreamDecoderEncoderAux::headerSize -1;
-      return;
-    }
+
     //skip to the end
-    rodData += 7;
+    rodData += headerSize;
   }
 
   void FTKByteStreamDecoderEncoderAuxTool::packTrailer(std::vector<uint32_t> &payload){
@@ -206,8 +210,7 @@ namespace FTK {
 
   void FTKByteStreamDecoderEncoderAuxTool::unpackMonitoring(OFFLINE_FRAGMENTS_NAMESPACE::PointerType &rodData){
     if ( (rodData[0] & 0xFFFF0000) == 0xE0DA0000) {
-      ATH_MSG_DEBUG("marker 0xE0DA0000 found");
-      //while (
+      ATH_MSG_VERBOSE("marker 0xE0DA0000 found");
     }
     return;
   }
@@ -217,9 +220,9 @@ namespace FTK {
     auto beforeMonitoring = rodData;
     unpackMonitoring(rodData);
     if (rodData == beforeMonitoring){
-      ATH_MSG_DEBUG("Extra monitoring records not found");
+      ATH_MSG_VERBOSE("Extra monitoring records not found");
     } else {
-      ATH_MSG_DEBUG("Monitoring records of size " << (rodData-beforeMonitoring)/sizeof(OFFLINE_FRAGMENTS_NAMESPACE::PointerType));
+      ATH_MSG_VERBOSE("Monitoring records of size " << (rodData-beforeMonitoring)/sizeof(OFFLINE_FRAGMENTS_NAMESPACE::PointerType));
     }
 
     //first word
@@ -228,15 +231,15 @@ namespace FTK {
       ATH_MSG_ERROR("Trailer first word should read 0xe0da0000 but got 0x"<<std::hex<<firstword<<std::dec);
     }
     uint32_t extL1id = rodData[1];     
-    ATH_MSG_DEBUG("extL1id " << extL1id);
+    ATH_MSG_VERBOSE("extL1id " << extL1id);
 
     uint32_t error_flag = rodData[2];  
-    ATH_MSG_DEBUG("error_flag " << error_flag);
+    ATH_MSG_VERBOSE("error_flag " << error_flag);
     //reserved word
-    ATH_MSG_DEBUG("reserved " << rodData[3]);   rodData++;
+    ATH_MSG_VERBOSE("reserved " << rodData[3]);   rodData++;
 
     uint32_t  numDataElems  = rodData[4]; 
-    ATH_MSG_DEBUG("Number of Data Elements " << numDataElems);
+    ATH_MSG_VERBOSE("Number of Data Elements " << numDataElems);
     
     //last word
     uint32_t  lastword = rodData[5]; 
@@ -274,18 +277,23 @@ namespace FTK {
 
   StatusCode FTKByteStreamDecoderEncoderAuxTool::decode(uint32_t nDataWords, OFFLINE_FRAGMENTS_NAMESPACE::PointerType rodData, FTK_RawTrackContainer* result) {
 
-    ATH_MSG_DEBUG("FTKByteStreamDecoderEncoderAuxTool::decode for nDataWords=" << nDataWords);
 
-    uint32_t nTracks = nDataWords / TrackBlobSize;
+    if (nDataWords <= (headerSize + trailerSize)) {
+      ATH_MSG_VERBOSE("FTKByteStreamDecoderEncoderAuxTool::decode for nDataWords= "  << nDataWords << " Ntracks= 0");
+      return StatusCode::SUCCESS;
+    }
     
-    ATH_MSG_DEBUG("rodData: " << rodData);
+    uint32_t nTracks = (nDataWords - headerSize - trailerSize) / TrackBlobSize;
+    uint32_t nOver = nDataWords - nTracks*TrackBlobSize - headerSize - trailerSize;
+    
+    ATH_MSG_VERBOSE("FTKByteStreamDecoderEncoderAuxTool::decode for nDataWords= " << nDataWords<< " Ntracks= " << nTracks << " remainder (should be zero) " << nOver);
 
     if (m_doHeader){
       unpackHeader(rodData);
     }
-    ATH_MSG_DEBUG("rodData: " << rodData);
+
     result->reserve(result->size() + nTracks);
-    for ( size_t i = 0; i < nTracks; ++i ) {
+    for ( size_t i = 0; i < nTracks; ++i ) { 
       FTK_RawTrack* track = unpackFTTrack( rodData );
       rodData += TrackBlobSize;
       result->push_back(track);
diff --git a/Trigger/TrigFTK/TrigFTKByteStream/src/FTKByteStreamDecoderEncoderAux.h b/Trigger/TrigFTK/TrigFTKByteStream/src/FTKByteStreamDecoderEncoderAux.h
index e3f96fccd00..2daaa3e060b 100644
--- a/Trigger/TrigFTK/TrigFTKByteStream/src/FTKByteStreamDecoderEncoderAux.h
+++ b/Trigger/TrigFTK/TrigFTKByteStream/src/FTKByteStreamDecoderEncoderAux.h
@@ -16,15 +16,17 @@
 
 namespace FTKByteStreamDecoderEncoderAux {
 
-  const size_t TrackBlobSize = 18; // magic number from BS specification
+  const size_t TrackBlobSize = 10; // magic number from BS specification
   const size_t TrackParamsBlobSize = 2; // --||--
-  const size_t PixHitParamsBlobSize = 2; // --||--
-  const size_t SCTHitParamsBlobSize = 2; // --||--
+  const size_t PixHitParamsBlobSize = 1; // --||--
+  const size_t SCTHitParamsBlobSize = 1; // --||--
   const size_t NPixLayers=4; // number of layers in FTK_RawTrack (not the no. layers in BS)
   const size_t NSCTLayers=8; // number of layers in FTK_RawTrack (not the no. layers in BS)
 
   const uint32_t headerMarker = 0xb0f00000; 
-  const uint32_t headerSize   = 0x7;
+  const uint32_t trailerMarker = 0xe0da0000;
+  const uint32_t headerSize   = 8;
+  const uint32_t trailerSize   = 3;
 
 }
 
diff --git a/Trigger/TrigFTK/TrigFTKByteStream/src/TrigFTKByteStreamTool.cxx b/Trigger/TrigFTK/TrigFTKByteStream/src/TrigFTKByteStreamTool.cxx
index 15661dc727e..5faf8c3e41a 100755
--- a/Trigger/TrigFTK/TrigFTKByteStream/src/TrigFTKByteStreamTool.cxx
+++ b/Trigger/TrigFTK/TrigFTKByteStream/src/TrigFTKByteStreamTool.cxx
@@ -159,7 +159,7 @@ StatusCode FTK::TrigFTKByteStreamTool::convert(IROBDataProviderSvc& dataProvider
     uint16_t rodMinorVersion= ver.minor_version();
 
     if (rodMinorVersion==m_AuxFormat) {
-      ATH_MSG_DEBUG("Unpacking Data in AUX Format with rodMinorVersion 0x" << std::hex << rodMinorVersion << std::dec);
+      ATH_MSG_DEBUG("Unpacking Data in AUX Format with rodMinorVersion 0x" << std::hex << rodMinorVersion << std::dec<<" no. data words " << nData);
       if (m_decodeAux) {
 	StatusCode scdca = m_decoderAux->decode(nData, rodData, result);    
 	if (scdca.isFailure()){
diff --git a/Trigger/TrigFTK/TrigFTKPool/CMakeLists.txt b/Trigger/TrigFTK/TrigFTKPool/CMakeLists.txt
index cd3c0e83cb3..5042e1fa683 100644
--- a/Trigger/TrigFTK/TrigFTKPool/CMakeLists.txt
+++ b/Trigger/TrigFTK/TrigFTKPool/CMakeLists.txt
@@ -9,6 +9,7 @@ atlas_subdir( TrigFTKPool )
 atlas_depends_on_subdirs( PUBLIC
                           Control/AthenaKernel
                           Control/AthContainers
+                          Control/DataModelAthenaPool
                           PRIVATE
                           Database/AthenaPOOL/AthenaPoolCnvSvc
                           Database/AthenaPOOL/AthenaPoolUtilities )
@@ -28,11 +29,11 @@ atlas_add_poolcnv_library( TrigFTKPoolPoolCnv
                            src/*.cxx
                            FILES TrigFTKPool/FTKTestData.h TrigFTKPool/FTKAthTrackContainer.h TrigFTKPool/FTKTrackFitterStats.h
                            INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
-                           LINK_LIBRARIES ${ROOT_LIBRARIES} AthContainers AthenaPoolCnvSvcLib AthenaPoolUtilities TrigFTKPool )
+                           LINK_LIBRARIES ${ROOT_LIBRARIES} DataModelAthenaPoolLib AthContainers AthenaPoolCnvSvcLib AthenaPoolUtilities TrigFTKPool )
 
 atlas_add_dictionary( TrigFTKPoolDict
                       TrigFTKPool/TrigFTKPoolDict.h
                       TrigFTKPool/selection.xml
                       INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
-                      LINK_LIBRARIES ${ROOT_LIBRARIES} AthContainers AthenaPoolCnvSvcLib AthenaPoolUtilities TrigFTKPool )
+                      LINK_LIBRARIES ${ROOT_LIBRARIES} DataModelAthenaPoolLib AthContainers AthenaPoolCnvSvcLib AthenaPoolUtilities TrigFTKPool )
 
diff --git a/Trigger/TrigFTK/TrigFTK_Monitoring/TrigFTK_Monitoring/FtkHltEfficiencyFex.h b/Trigger/TrigFTK/TrigFTK_Monitoring/TrigFTK_Monitoring/FtkHltEfficiencyFex.h
index 9fbce397fe1..125e1fd9ec4 100644
--- a/Trigger/TrigFTK/TrigFTK_Monitoring/TrigFTK_Monitoring/FtkHltEfficiencyFex.h
+++ b/Trigger/TrigFTK/TrigFTK_Monitoring/TrigFTK_Monitoring/FtkHltEfficiencyFex.h
@@ -102,6 +102,7 @@ namespace TrigFTK {
       double        m_max2DZ0;
 
       std::vector<TrigTimer*> m_timer;
+
       enum FtkHltEfficiencyTimers
       {
         AlgoTime            =  0,
@@ -113,7 +114,34 @@ namespace TrigFTK {
         nTimers /// Leave this entry at the end
       };
       int m_eventCounter;
-  };
+      
+      unsigned int m_nFTKRawTracks;
+
+      unsigned int m_nFTKTracks;
+      unsigned int m_nFTKTrackParticles;
+      unsigned int m_nTrackErrors;
+      unsigned int m_nTrackParticleErrors;
+
+      double m_fMissPix0;
+      double m_fMissPix1;
+      double m_fMissPix2;
+      double m_fMissPix3;
+
+      int m_nFailPix;
+
+      double m_fMissSCT0;
+      double m_fMissSCT1;
+      double m_fMissSCT2;
+      double m_fMissSCT3;
+      double m_fMissSCT4;
+      double m_fMissSCT5;
+      double m_fMissSCT6;
+      double m_fMissSCT7;
+
+
+      int m_nFailSCT;
+
+};
 
 } // end namespace
 #endif
diff --git a/Trigger/TrigFTK/TrigFTK_Monitoring/python/FtkHltEfficiencyConfig.py b/Trigger/TrigFTK/TrigFTK_Monitoring/python/FtkHltEfficiencyConfig.py
index 370fc494418..e5af4952670 100644
--- a/Trigger/TrigFTK/TrigFTK_Monitoring/python/FtkHltEfficiencyConfig.py
+++ b/Trigger/TrigFTK/TrigFTK_Monitoring/python/FtkHltEfficiencyConfig.py
@@ -28,10 +28,10 @@ class FtkHltEfficiencyFex ( TrigFTK__FtkHltEfficiencyFex ) :
         self.DeltaRMax            = 0.05    # float
 
         # Track Filtering
-        self.MinPt              = 0.0     # float
+        self.MinPt              = 2.0     # float
         self.MaxEta             = 10.0    # float
         self.MaxZ0              = 100.0   # float
-        self.MaxD0              = 2.0     # float
+        self.MaxD0              = 1.0     # float
 
         self.MaxHLTZ0Err        = 100.0   # float
         self.MaxHLTD0Err        = 100.0   # float
diff --git a/Trigger/TrigFTK/TrigFTK_Monitoring/python/FtkHltEfficiencyMonitoring.py b/Trigger/TrigFTK/TrigFTK_Monitoring/python/FtkHltEfficiencyMonitoring.py
index b4eaa27cd0d..d357cea6785 100644
--- a/Trigger/TrigFTK/TrigFTK_Monitoring/python/FtkHltEfficiencyMonitoring.py
+++ b/Trigger/TrigFTK/TrigFTK_Monitoring/python/FtkHltEfficiencyMonitoring.py
@@ -108,17 +108,119 @@ class FtkHltEfficiencyMonitoring(TrigGenericMonitoringToolConfig):
         xbins=2, xmin=-.5, xmax=1.5) ]
 
     # others
-    nBins += 5 + 5
+    nBins += 50 + 50
     self.Histograms += [ defineHistogram(
         'numb_HLT_trks',
         type='TH1F',
-        title='number of HLT tracks;#tracks;#events',
+        title='number of HLT tracks (effic Denominator);#tracks;#events',
         xbins=50, xmin=0, xmax=500)]
     self.Histograms += [ defineHistogram(
         'numb_FTK_trks',
         type='TH1F',
-        title='number of FTK tracks;#tracks;#events',
+        title='number of FTK tracks (effic numerator);#tracks;#events',
         xbins=50, xmin=0, xmax=500)]
 
+
+    nBins += 50*3
+    self.Histograms += [ defineHistogram(
+        'nFTKRawTrk',
+        type='TH1F',
+        title='number of FTK RAW tracks;#tracks;#events',
+        xbins=50, xmin=0, xmax=500)]
+    self.Histograms += [ defineHistogram(
+        'nTrackErrors',
+        type='TH1F',
+        title='number of FTK tracks not converted due to errors;#tracks;#events',
+        xbins=50, xmin=0, xmax=500)]
+    self.Histograms += [ defineHistogram(
+        'nTPErrors',
+        type='TH1F',
+        title='number of FTK TrackParticles missing due to Errors;#tracks;#events',
+        xbins=50, xmin=0, xmax=500)]
+
+    nBins += 50*4
+
+    self.Histograms += [ defineHistogram(
+        'fTrkMissingPix0',
+        type='TH1F',
+        title='fraction of tracks per event missing IBL;Fraction of Tracks;No. Events',
+        xbins=50, xmin=0, xmax=1)]
+    self.Histograms += [ defineHistogram(
+        'fTrkMissingPix1',
+        type='TH1F',
+        title='fraction of tracks per event missing Pix1;Fraction of Tracks;No. Events',
+        xbins=50, xmin=0, xmax=1)]
+    self.Histograms += [ defineHistogram(
+        'fTrkMissingPix2',
+        type='TH1F',
+        title='fraction of tracks per event missing Pix2;Fraction of Tracks;No. Events',
+        xbins=50, xmin=0, xmax=1)]
+    self.Histograms += [ defineHistogram(
+        'fTrkMissingPix3',
+        type='TH1F',
+        title='fraction of tracks per event missing Pix3;Fraction of Tracks;No. Events',
+        xbins=50, xmin=0, xmax=1)]
+
+    nBins += 50*8
+
+
+    self.Histograms += [ defineHistogram(
+      'fTrkMissingSCT0',
+      type='TH1F',
+      title='fraction of tracks per event missing SCT0;Fraction of Tracks;No. Events',
+      xbins=50, xmin=0, xmax=1)]
+
+    self.Histograms += [ defineHistogram(
+      'fTrkMissingSCT1',
+      type='TH1F',
+      title='fraction of tracks per event missing SCT1;Fraction of Tracks;No. Events',
+      xbins=50, xmin=0, xmax=1)]
+    self.Histograms += [ defineHistogram(
+      'fTrkMissingSCT2',
+      type='TH1F',
+      title='fraction of tracks per event missing SCT2;Fraction of Tracks;No. Events',
+      xbins=50, xmin=0, xmax=1)]
+    self.Histograms += [ defineHistogram(
+      'fTrkMissingSCT3',
+      type='TH1F',
+      title='fraction of tracks per event missing SCT3;Fraction of Tracks;No. Events',
+      xbins=50, xmin=0, xmax=1)]
+    self.Histograms += [ defineHistogram(
+      'fTrkMissingSCT4',
+      type='TH1F',
+      title='fraction of tracks per event missing SCT4;Fraction of Tracks;No. Events',
+      xbins=50, xmin=0, xmax=1)]
+    self.Histograms += [ defineHistogram(
+      'fTrkMissingSCT5',
+      type='TH1F',
+      title='fraction of tracks per event missing SCT5;Fraction of Tracks;No. Events',
+      xbins=50, xmin=0, xmax=1)]
+
+    self.Histograms += [ defineHistogram(
+      'fTrkMissingSCT6',
+      type='TH1F',
+      title='fraction of tracks per event missing SCT6;Fraction of Tracks;No. Events',
+      xbins=50, xmin=0, xmax=1)]
+
+    self.Histograms += [ defineHistogram(
+      'fTrkMissingSCT7',
+      type='TH1F',
+      title='fraction of tracks per event missing SCT7;Fraction of Tracks;No. Events',
+      xbins=50, xmin=0, xmax=1)]
+
+    nBins += 50*2
+
+    self.Histograms += [ defineHistogram(
+      'nTrkFailedPix',
+      type='TH1F',
+      title='No. tracks per event with failed Pixel hit conversion;No. of Tracks;No. Events',
+      xbins=50, xmin=0, xmax=1)]
+
+    self.Histograms += [ defineHistogram(
+      'nTrkFailedSCT',
+      type='TH1F',
+      title='No. tracks per event with failed SCT hit conversion;No. of Tracks;No. Events',
+      xbins=50, xmin=0, xmax=1)]
+
     print "FtkHltEfficiencyMonitoring: booked", nBins, " histogram bins"
 
diff --git a/Trigger/TrigFTK/TrigFTK_Monitoring/src/FtkHltEfficiencyFex.cxx b/Trigger/TrigFTK/TrigFTK_Monitoring/src/FtkHltEfficiencyFex.cxx
index 9535246788b..63d07c3a3bd 100644
--- a/Trigger/TrigFTK/TrigFTK_Monitoring/src/FtkHltEfficiencyFex.cxx
+++ b/Trigger/TrigFTK/TrigFTK_Monitoring/src/FtkHltEfficiencyFex.cxx
@@ -33,10 +33,10 @@ using namespace TrigFTK;
   declareProperty("FTK_DataProvider", m_FTKDataProviderSvc);
   declareProperty("DeltaRMax", m_deltaR_max = 0.05);
 
-  declareProperty("MinPt",           m_minPt          = 0);
+  declareProperty("MinPt",           m_minPt          = 2);
   declareProperty("MaxEta",          m_maxEta         = 10);
   declareProperty("MaxZ0",           m_maxZ0          = 100);
-  declareProperty("MaxD0",           m_maxD0          = 2);
+  declareProperty("MaxD0",           m_maxD0          = 1);
 
   declareProperty("MaxHLTZ0Err",        m_maxHLTZ0err       = 100);
   declareProperty("MaxHLTD0Err",        m_maxHLTD0err       = 100);
@@ -73,6 +73,26 @@ using namespace TrigFTK;
   declareMonitoredVariable("numb_HLT_trks",                 m_efficiencyAnalysis->m_numb_ref_trks );
   declareMonitoredVariable("numb_FTK_trks",                 m_efficiencyAnalysis->m_numb_test_trks );
 
+  declareMonitoredVariable("nFTKRawTrk",m_nFTKRawTracks);
+  declareMonitoredVariable("nFTKTrackParticles", m_nFTKTrackParticles);
+  declareMonitoredVariable("nTrackErrors", m_nTrackErrors);
+  declareMonitoredVariable("nTPErrors", m_nTrackParticleErrors);
+  
+  declareMonitoredVariable("nTrkFailedPix", m_nFailPix);
+  declareMonitoredVariable("nTrkFailedSCT", m_nFailSCT);
+  declareMonitoredVariable("fTrkMissingPix0", m_fMissPix0);
+  declareMonitoredVariable("fTrkMissingPix1", m_fMissPix1);
+  declareMonitoredVariable("fTrkMissingPix2", m_fMissPix2);
+  declareMonitoredVariable("fTrkMissingPix3", m_fMissPix3);
+  declareMonitoredVariable("fTrkMissingSCT0",m_fMissSCT0);
+  declareMonitoredVariable("fTrkMissingSCT1",m_fMissSCT1);
+  declareMonitoredVariable("fTrkMissingSCT2",m_fMissSCT2);
+  declareMonitoredVariable("fTrkMissingSCT3",m_fMissSCT3);
+  declareMonitoredVariable("fTrkMissingSCT4",m_fMissSCT4);
+  declareMonitoredVariable("fTrkMissingSCT5",m_fMissSCT5);
+  declareMonitoredVariable("fTrkMissingSCT6",m_fMissSCT6);
+  declareMonitoredVariable("fTrkMissingSCT7",m_fMissSCT7);
+
   // purity variables from m_purityAnalysis
   m_purityAnalysis->monitored_ref_track.declareForMonitoring( this, "FTK_trk_");
   m_purityAnalysis->monitored_ref_unmatched_track.declareForMonitoring( this, "FTK_fake_trk_");
@@ -172,6 +192,9 @@ HLT::ErrorCode FtkHltEfficiencyFex::hltExecute(const HLT::TriggerElement* input,
   m_efficiencyAnalysis->Clear();
   m_purityAnalysis->Clear();
 
+
+ 
+
   // Get the ROI descriptor
   const TrigRoiDescriptor* roiDescriptor = 0;
   HLT::ErrorCode status = getFeature( input, roiDescriptor );
@@ -211,6 +234,62 @@ HLT::ErrorCode FtkHltEfficiencyFex::hltExecute(const HLT::TriggerElement* input,
       ATH_MSG_DEBUG("Failed to get FTK TrackParticleContainer ");
     if(m_timer[GetFtkTracksTime]) m_timer[GetFtkTracksTime]->stop();    
     ATH_MSG_DEBUG("FTK retrieval time " << m_timer[GetFtkTracksTime]->elapsed());
+
+    m_nFTKRawTracks = m_FTKDataProviderSvc->nRawTracks();
+    m_nFTKTracks = m_FTKDataProviderSvc->nTracks(false);
+    m_nFTKTrackParticles = m_FTKDataProviderSvc->nTrackParticles(false);
+    m_nTrackErrors = m_FTKDataProviderSvc->nTrackErrors(false);
+    m_nTrackParticleErrors = m_FTKDataProviderSvc->nTrackParticleErrors(false);
+    ATH_MSG_DEBUG(" No. RAW tracks= " << m_nFTKRawTracks);
+    ATH_MSG_DEBUG(" No. Converted tracks = " << m_nFTKTracks << " with " <<  m_nTrackErrors << " Errors");
+    ATH_MSG_DEBUG(" No. Converted tracks = " << m_nFTKTracks << " with " <<  m_nTrackErrors << " Errors");
+    ATH_MSG_DEBUG(" TrackParticles = " << m_nTrackParticleErrors << " with " << m_nTrackParticleErrors << " Errors");
+
+    m_fMissPix0=m_fMissPix1=m_fMissPix2=m_fMissPix3=m_nFailPix=-1;
+    m_fMissSCT0=m_fMissSCT1=m_fMissSCT2=m_fMissSCT3=m_fMissSCT4=m_fMissSCT5=m_fMissSCT6=m_fMissSCT7=m_nFailSCT=-1;
+
+
+    if (m_nFTKRawTracks>0){
+      std::vector<unsigned int> nMissingPixelClusters = m_FTKDataProviderSvc->nMissingPixelClusters();
+      std::vector<unsigned int> nFailedPixelClusters = m_FTKDataProviderSvc->nFailedPixelClusters();
+      unsigned nFailPix=0; 
+      for (unsigned int lay=0; lay<4; lay++) nFailPix+=nFailedPixelClusters[lay];
+      m_nFailPix=nFailPix;
+
+      ATH_MSG_DEBUG(" Missing Pixel Hits in IBL: " <<  nMissingPixelClusters[0] << ", Lay1: "<<  nMissingPixelClusters[1] << ", Lay2: "<<  nMissingPixelClusters[2] << ", Lay3: "<<  nMissingPixelClusters[3]);
+      ATH_MSG_DEBUG(" Failed  Pixel Hits in IBL: " <<  nFailedPixelClusters[0] << ", Lay1: "<<  nFailedPixelClusters[1] << ", Lay2: "<<  nFailedPixelClusters[2]<< ", Lay3: "<<  nFailedPixelClusters[3]);
+      m_fMissPix0=static_cast<double>(nMissingPixelClusters[0])/static_cast<double>(m_nFTKRawTracks);
+      m_fMissPix1=static_cast<double>(nMissingPixelClusters[1])/static_cast<double>(m_nFTKRawTracks);
+      m_fMissPix2=static_cast<double>(nMissingPixelClusters[2])/static_cast<double>(m_nFTKRawTracks);
+      m_fMissPix3=static_cast<double>(nMissingPixelClusters[3])/static_cast<double>(m_nFTKRawTracks);
+      ATH_MSG_DEBUG(" Fraction of Tracks missing Pixel Hits in IBL: " <<  m_fMissPix0 << ", Lay1: "<<  m_fMissPix1 << ", Lay2: "<<  m_fMissPix2 << ", Lay3: "<<  m_fMissPix3);
+
+      std::vector<unsigned int> nMissingSCTClusters = m_FTKDataProviderSvc->nMissingSCTClusters();
+      std::vector<unsigned int> nFailedSCTClusters = m_FTKDataProviderSvc->nFailedSCTClusters();
+
+      unsigned nFailSCT=0; 
+      for (unsigned int lay=0; lay<8; lay++) nFailSCT+=nFailedSCTClusters[lay];
+      m_nFailSCT=nFailSCT;
+      
+      ATH_MSG_DEBUG(" Missing SCT Hits in Lay0: " <<  nMissingSCTClusters[0] << ", Lay1: "<<  nMissingSCTClusters[1] << ", Lay2: "<<  nMissingSCTClusters[2] << 
+		    ", Lay3: " <<  nMissingSCTClusters[3] << ", Lay4: " <<  nMissingSCTClusters[4] << ", Lay5: "<<  nMissingSCTClusters[5]<< 
+		    ", Lay6: "<<  nMissingSCTClusters[6] << ", Lay7: "<<  nMissingSCTClusters[7]);
+      ATH_MSG_DEBUG(" Failed SCT Hits in Lay0: " <<  nFailedSCTClusters[0] << ", Lay1: "<<  nFailedSCTClusters[1] << ", Lay2: "<<  nFailedSCTClusters[2] << 
+		    ", Lay3: " <<  nFailedSCTClusters[3] << ", Lay4: " <<  nFailedSCTClusters[4] << ", Lay5: "<<  nFailedSCTClusters[5]<< 
+		    ", Lay6: "<<  nFailedSCTClusters[6] << ", Lay7: "<<  nFailedSCTClusters[7]);
+
+      m_fMissSCT0=static_cast<double>(nMissingSCTClusters[0])/static_cast<double>(m_nFTKRawTracks);
+      m_fMissSCT1=static_cast<double>(nMissingSCTClusters[1])/static_cast<double>(m_nFTKRawTracks);
+      m_fMissSCT2=static_cast<double>(nMissingSCTClusters[2])/static_cast<double>(m_nFTKRawTracks);
+      m_fMissSCT3=static_cast<double>(nMissingSCTClusters[3])/static_cast<double>(m_nFTKRawTracks);
+      m_fMissSCT4=static_cast<double>(nMissingSCTClusters[4])/static_cast<double>(m_nFTKRawTracks);
+      m_fMissSCT5=static_cast<double>(nMissingSCTClusters[5])/static_cast<double>(m_nFTKRawTracks);
+      m_fMissSCT6=static_cast<double>(nMissingSCTClusters[6])/static_cast<double>(m_nFTKRawTracks);
+      m_fMissSCT7=static_cast<double>(nMissingSCTClusters[7])/static_cast<double>(m_nFTKRawTracks);
+      ATH_MSG_DEBUG(" Fraction Tracks Missing SCT Hits in Lay0: " <<  m_fMissSCT0 << ", Lay1: "<<  m_fMissSCT1 << ", Lay2: "<<  m_fMissSCT2 << ", Lay3: "<<  m_fMissSCT3<< 
+		    ", Lay4: " <<  m_fMissSCT4 << ", Lay5: "<<  m_fMissSCT5 << ", Lay6: "<<  m_fMissSCT6 << ", Lay7: "<<  m_fMissSCT7);
+    }
+
   }
   
   // run efficiency analysis
diff --git a/Trigger/TrigFTK/TrigFTK_RawData/CMakeLists.txt b/Trigger/TrigFTK/TrigFTK_RawData/CMakeLists.txt
index 4bf26f345ca..63739afe346 100644
--- a/Trigger/TrigFTK/TrigFTK_RawData/CMakeLists.txt
+++ b/Trigger/TrigFTK/TrigFTK_RawData/CMakeLists.txt
@@ -12,20 +12,21 @@ atlas_depends_on_subdirs( PUBLIC
 
 # External dependencies:
 find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread )
+find_package(Eigen)
 
 # Component(s) in the package:
 atlas_add_library( TrigFTK_RawData
                    src/*.cxx
                    PUBLIC_HEADERS TrigFTK_RawData
-                   PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
-                   LINK_LIBRARIES AthContainers AthenaKernel
+                   PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS}
+                   LINK_LIBRARIES ${EIGEN_LIBRARIES} AthContainers AthenaKernel
                    PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} )
 
 atlas_add_dictionary( TrigFTK_RawDataDict
                       TrigFTK_RawData/TrigFTK_RawDataDict.h
                       TrigFTK_RawData/selection.xml
-                      INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
-                      LINK_LIBRARIES ${ROOT_LIBRARIES} AthContainers AthenaKernel TrigFTK_RawData
+                      INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS}
+                      LINK_LIBRARIES ${ROOT_LIBRARIES} ${EIGEN_LIBRARIES} AthContainers AthenaKernel TrigFTK_RawData
                       DATA_LINKS FTK_RawTrack FTK_RawPixelCluster FTK_RawSCT_Cluster
                       ELEMENT_LINKS FTK_RawTrackContainer )
 
diff --git a/Trigger/TrigFTK/TrigFTK_RawData/TrigFTK_RawData/FTK_RawTrack.h b/Trigger/TrigFTK/TrigFTK_RawData/TrigFTK_RawData/FTK_RawTrack.h
index 7e4da3a525d..0b3c4a1d7c3 100644
--- a/Trigger/TrigFTK/TrigFTK_RawData/TrigFTK_RawData/FTK_RawTrack.h
+++ b/Trigger/TrigFTK/TrigFTK_RawData/TrigFTK_RawData/FTK_RawTrack.h
@@ -25,10 +25,13 @@ PURPOSE:  A base class for RAW FTK tracks.
 //#define NPIXLAYERS 4
 //#define NSCTLAYERS 8 //0,2,4,6 = Axial, 1,3,5,7 = Stero
 
+#define FTK_RAWTRACK_VERSION 0x1
+
 class FTK_RawTrack {
 
  public:
   FTK_RawTrack(); 
+  FTK_RawTrack(const FTK_RawTrack&); 
   FTK_RawTrack(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t);
   FTK_RawTrack(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, const std::vector<FTK_RawPixelCluster>&, const std::vector<FTK_RawSCT_Cluster>&);
   ~FTK_RawTrack();
@@ -60,6 +63,7 @@ class FTK_RawTrack {
   uint32_t getPixelBarcode( int ) const;
   uint32_t getSCTWord( int )      const;
   uint32_t getSCTBarcode( int )   const;
+  bool getIsAuxFormat() const;
 
   signed long getBarcode() const {return m_barcode; }
   FTK_RawPixelCluster& getPixelCluster( int );
@@ -90,6 +94,8 @@ class FTK_RawTrack {
   void setCotTh(float);
   void setInvPt(float);
   void setChi2(float);
+  void setIsAuxFormat(bool);
+
   //  void setQuality(float);
   void setPixelCluster(unsigned int layer,  const FTK_RawPixelCluster& );
   void setSCTCluster( unsigned int layer,    const FTK_RawSCT_Cluster&  );
@@ -97,8 +103,14 @@ class FTK_RawTrack {
   void setSCTClusters(   std::vector<FTK_RawSCT_Cluster>&  );
   void setBarcode(signed long barcode) { m_barcode = barcode; }
 
-  
  private:
+
+  inline unsigned int trackVersion() const  
+  {
+    return (m_word_th3>>24);
+  }
+
+
   uint32_t m_word_th1;
   uint32_t m_word_th2;
   uint32_t m_word_th3;
@@ -123,7 +135,6 @@ class FTK_RawTrack {
   //  static const float s_quality_multiplier;
   static const float s_invpt_multiplier;
 
-
 };
 
 CLASS_DEF( FTK_RawTrack , 239377431 , 2 )
diff --git a/Trigger/TrigFTK/TrigFTK_RawData/src/EigenHalf.h b/Trigger/TrigFTK/TrigFTK_RawData/src/EigenHalf.h
new file mode 100644
index 00000000000..65d20b741f8
--- /dev/null
+++ b/Trigger/TrigFTK/TrigFTK_RawData/src/EigenHalf.h
@@ -0,0 +1,673 @@
+// This file is part of Eigen, a lightweight C++ template library
+// for linear algebra.
+//
+// This Source Code Form is subject to the terms of the Mozilla
+// Public License v. 2.0. If a copy of the MPL was not distributed
+// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+//
+// The original license follows:
+//
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted.
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+// Standard 16-bit float type, mostly useful for GPUs. Defines a new
+// type Eigen::half (inheriting from CUDA's __half struct) with
+// operator overloads such that it behaves basically as an arithmetic
+// type. It will be quite slow on CPUs (so it is recommended to stay
+// in fp32 for CPUs, except for simple parameter conversions, I/O
+// to disk and the likes), but fast on GPUs.
+
+
+#ifndef EIGEN_HALF_CUDA_H
+#define EIGEN_HALF_CUDA_H
+
+#if __cplusplus > 199711L
+#define EIGEN_EXPLICIT_CAST(tgt_type) explicit operator tgt_type()
+#else
+#define EIGEN_EXPLICIT_CAST(tgt_type) operator tgt_type()
+#endif
+
+
+namespace Eigen {
+
+struct half;
+
+namespace half_impl {
+
+#if !defined(EIGEN_HAS_CUDA_FP16)
+// Make our own __half_raw definition that is similar to CUDA's.
+struct __half_raw {
+  EIGEN_DEVICE_FUNC __half_raw() : x(0) {}
+  explicit EIGEN_DEVICE_FUNC __half_raw(unsigned short raw) : x(raw) {}
+  unsigned short x;
+};
+#elif defined(EIGEN_CUDACC_VER) && EIGEN_CUDACC_VER < 90000
+// In CUDA < 9.0, __half is the equivalent of CUDA 9's __half_raw
+typedef __half __half_raw;
+#endif
+
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC __half_raw raw_uint16_to_half(unsigned short x);
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC __half_raw float_to_half_rtne(float ff);
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC float half_to_float(__half_raw h);
+
+struct half_base : public __half_raw {
+  EIGEN_DEVICE_FUNC half_base() {}
+  EIGEN_DEVICE_FUNC half_base(const half_base& h) : __half_raw(h) {}
+  EIGEN_DEVICE_FUNC half_base(const __half_raw& h) : __half_raw(h) {}
+#if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDACC_VER) && EIGEN_CUDACC_VER >= 90000
+  EIGEN_DEVICE_FUNC half_base(const __half& h) : __half_raw(*(__half_raw*)&h) {}
+#endif
+};
+
+} // namespace half_impl
+
+// Class definition.
+struct half : public half_impl::half_base {
+  #if !defined(EIGEN_HAS_CUDA_FP16) || (defined(EIGEN_CUDACC_VER) && EIGEN_CUDACC_VER < 90000)
+    typedef half_impl::__half_raw __half_raw;
+  #endif
+
+  EIGEN_DEVICE_FUNC half() {}
+
+  EIGEN_DEVICE_FUNC half(const __half_raw& h) : half_impl::half_base(h) {}
+  EIGEN_DEVICE_FUNC half(const half& h) : half_impl::half_base(h) {}
+#if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDACC_VER) && EIGEN_CUDACC_VER >= 90000
+  EIGEN_DEVICE_FUNC half(const __half& h) : half_impl::half_base(h) {}
+#endif
+
+  explicit EIGEN_DEVICE_FUNC half(bool b)
+      : half_impl::half_base(half_impl::raw_uint16_to_half(b ? 0x3c00 : 0)) {}
+  template<class T>
+  explicit EIGEN_DEVICE_FUNC half(const T& val)
+      : half_impl::half_base(half_impl::float_to_half_rtne(static_cast<float>(val))) {}
+  explicit EIGEN_DEVICE_FUNC half(float f)
+      : half_impl::half_base(half_impl::float_to_half_rtne(f)) {}
+
+  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(bool) const {
+    // +0.0 and -0.0 become false, everything else becomes true.
+    return (x & 0x7fff) != 0;
+  }
+  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(signed char) const {
+    return static_cast<signed char>(half_impl::half_to_float(*this));
+  }
+  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(unsigned char) const {
+    return static_cast<unsigned char>(half_impl::half_to_float(*this));
+  }
+  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(short) const {
+    return static_cast<short>(half_impl::half_to_float(*this));
+  }
+  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(unsigned short) const {
+    return static_cast<unsigned short>(half_impl::half_to_float(*this));
+  }
+  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(int) const {
+    return static_cast<int>(half_impl::half_to_float(*this));
+  }
+  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(unsigned int) const {
+    return static_cast<unsigned int>(half_impl::half_to_float(*this));
+  }
+  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(long) const {
+    return static_cast<long>(half_impl::half_to_float(*this));
+  }
+  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(unsigned long) const {
+    return static_cast<unsigned long>(half_impl::half_to_float(*this));
+  }
+  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(long long) const {
+    return static_cast<long long>(half_impl::half_to_float(*this));
+  }
+  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(unsigned long long) const {
+    return static_cast<unsigned long long>(half_to_float(*this));
+  }
+  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(float) const {
+    return half_impl::half_to_float(*this);
+  }
+  EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(double) const {
+    return static_cast<double>(half_impl::half_to_float(*this));
+  }
+
+  EIGEN_DEVICE_FUNC half& operator=(const half& other) {
+    x = other.x;
+    return *this;
+  }
+};
+
+} // end namespace Eigen
+
+namespace std {
+template<>
+struct numeric_limits<Eigen::half> {
+  static const bool is_specialized = true;
+  static const bool is_signed = true;
+  static const bool is_integer = false;
+  static const bool is_exact = false;
+  static const bool has_infinity = true;
+  static const bool has_quiet_NaN = true;
+  static const bool has_signaling_NaN = true;
+  static const float_denorm_style has_denorm = denorm_present;
+  static const bool has_denorm_loss = false;
+  static const std::float_round_style round_style = std::round_to_nearest;
+  static const bool is_iec559 = false;
+  static const bool is_bounded = false;
+  static const bool is_modulo = false;
+  static const int digits = 11;
+  static const int digits10 = 3;      // according to http://half.sourceforge.net/structstd_1_1numeric__limits_3_01half__float_1_1half_01_4.html
+  static const int max_digits10 = 5;  // according to http://half.sourceforge.net/structstd_1_1numeric__limits_3_01half__float_1_1half_01_4.html
+  static const int radix = 2;
+  static const int min_exponent = -13;
+  static const int min_exponent10 = -4;
+  static const int max_exponent = 16;
+  static const int max_exponent10 = 4;
+  static const bool traps = true;
+  static const bool tinyness_before = false;
+
+  static Eigen::half (min)() { return Eigen::half_impl::raw_uint16_to_half(0x400); }
+  static Eigen::half lowest() { return Eigen::half_impl::raw_uint16_to_half(0xfbff); }
+  static Eigen::half (max)() { return Eigen::half_impl::raw_uint16_to_half(0x7bff); }
+  static Eigen::half epsilon() { return Eigen::half_impl::raw_uint16_to_half(0x0800); }
+  static Eigen::half round_error() { return Eigen::half(0.5); }
+  static Eigen::half infinity() { return Eigen::half_impl::raw_uint16_to_half(0x7c00); }
+  static Eigen::half quiet_NaN() { return Eigen::half_impl::raw_uint16_to_half(0x7e00); }
+  static Eigen::half signaling_NaN() { return Eigen::half_impl::raw_uint16_to_half(0x7e00); }
+  static Eigen::half denorm_min() { return Eigen::half_impl::raw_uint16_to_half(0x1); }
+};
+
+// If std::numeric_limits<T> is specialized, should also specialize
+// std::numeric_limits<const T>, std::numeric_limits<volatile T>, and
+// std::numeric_limits<const volatile T>
+// https://stackoverflow.com/a/16519653/
+template<>
+struct numeric_limits<const Eigen::half> : numeric_limits<Eigen::half> {};
+template<>
+struct numeric_limits<volatile Eigen::half> : numeric_limits<Eigen::half> {};
+template<>
+struct numeric_limits<const volatile Eigen::half> : numeric_limits<Eigen::half> {};
+} // end namespace std
+
+namespace Eigen {
+
+namespace half_impl {
+
+#if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 530
+
+// Intrinsics for native fp16 support. Note that on current hardware,
+// these are no faster than fp32 arithmetic (you need to use the half2
+// versions to get the ALU speed increased), but you do save the
+// conversion steps back and forth.
+
+EIGEN_STRONG_INLINE __device__ half operator + (const half& a, const half& b) {
+  return __hadd(a, b);
+}
+EIGEN_STRONG_INLINE __device__ half operator * (const half& a, const half& b) {
+  return __hmul(a, b);
+}
+EIGEN_STRONG_INLINE __device__ half operator - (const half& a, const half& b) {
+  return __hsub(a, b);
+}
+EIGEN_STRONG_INLINE __device__ half operator / (const half& a, const half& b) {
+  float num = __half2float(a);
+  float denom = __half2float(b);
+  return __float2half(num / denom);
+}
+EIGEN_STRONG_INLINE __device__ half operator - (const half& a) {
+  return __hneg(a);
+}
+EIGEN_STRONG_INLINE __device__ half& operator += (half& a, const half& b) {
+  a = a + b;
+  return a;
+}
+EIGEN_STRONG_INLINE __device__ half& operator *= (half& a, const half& b) {
+  a = a * b;
+  return a;
+}
+EIGEN_STRONG_INLINE __device__ half& operator -= (half& a, const half& b) {
+  a = a - b;
+  return a;
+}
+EIGEN_STRONG_INLINE __device__ half& operator /= (half& a, const half& b) {
+  a = a / b;
+  return a;
+}
+EIGEN_STRONG_INLINE __device__ bool operator == (const half& a, const half& b) {
+  return __heq(a, b);
+}
+EIGEN_STRONG_INLINE __device__ bool operator != (const half& a, const half& b) {
+  return __hne(a, b);
+}
+EIGEN_STRONG_INLINE __device__ bool operator < (const half& a, const half& b) {
+  return __hlt(a, b);
+}
+EIGEN_STRONG_INLINE __device__ bool operator <= (const half& a, const half& b) {
+  return __hle(a, b);
+}
+EIGEN_STRONG_INLINE __device__ bool operator > (const half& a, const half& b) {
+  return __hgt(a, b);
+}
+EIGEN_STRONG_INLINE __device__ bool operator >= (const half& a, const half& b) {
+  return __hge(a, b);
+}
+
+#else  // Emulate support for half floats
+
+// Definitions for CPUs and older CUDA, mostly working through conversion
+// to/from fp32.
+
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator + (const half& a, const half& b) {
+  return half(float(a) + float(b));
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator * (const half& a, const half& b) {
+  return half(float(a) * float(b));
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator - (const half& a, const half& b) {
+  return half(float(a) - float(b));
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator / (const half& a, const half& b) {
+  return half(float(a) / float(b));
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator - (const half& a) {
+  half result;
+  result.x = a.x ^ 0x8000;
+  return result;
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half& operator += (half& a, const half& b) {
+  a = half(float(a) + float(b));
+  return a;
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half& operator *= (half& a, const half& b) {
+  a = half(float(a) * float(b));
+  return a;
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half& operator -= (half& a, const half& b) {
+  a = half(float(a) - float(b));
+  return a;
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half& operator /= (half& a, const half& b) {
+  a = half(float(a) / float(b));
+  return a;
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator == (const half& a, const half& b) {
+  return float(a) == float(b);
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator != (const half& a, const half& b) {
+  return float(a) != float(b);
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator < (const half& a, const half& b) {
+  return float(a) < float(b);
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator <= (const half& a, const half& b) {
+  return float(a) <= float(b);
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator > (const half& a, const half& b) {
+  return float(a) > float(b);
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator >= (const half& a, const half& b) {
+  return float(a) >= float(b);
+}
+
+#endif  // Emulate support for half floats
+
+// Division by an index. Do it in full float precision to avoid accuracy
+// issues in converting the denominator to half.
+//EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator / (const half& a, Index b) {
+//  return half(static_cast<float>(a) / static_cast<float>(b));
+//}
+
+// Conversion routines, including fallbacks for the host or older CUDA.
+// Note that newer Intel CPUs (Haswell or newer) have vectorized versions of
+// these in hardware. If we need more performance on older/other CPUs, they are
+// also possible to vectorize directly.
+
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC __half_raw raw_uint16_to_half(unsigned short x) {
+  __half_raw h;
+  h.x = x;
+  return h;
+}
+
+union FP32 {
+  unsigned int u;
+  float f;
+};
+
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC __half_raw float_to_half_rtne(float ff) {
+#if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 300
+  __half tmp_ff = __float2half(ff);
+  return *(__half_raw*)&tmp_ff;
+
+#elif defined(EIGEN_HAS_FP16_C)
+  __half_raw h;
+  h.x = _cvtss_sh(ff, 0);
+  return h;
+
+#else
+  FP32 f; f.f = ff;
+
+  const FP32 f32infty = { 255 << 23 };
+  const FP32 f16max = { (127 + 16) << 23 };
+  const FP32 denorm_magic = { ((127 - 15) + (23 - 10) + 1) << 23 };
+  unsigned int sign_mask = 0x80000000u;
+  __half_raw o;
+  o.x = static_cast<unsigned short>(0x0u);
+
+  unsigned int sign = f.u & sign_mask;
+  f.u ^= sign;
+
+  // NOTE all the integer compares in this function can be safely
+  // compiled into signed compares since all operands are below
+  // 0x80000000. Important if you want fast straight SSE2 code
+  // (since there's no unsigned PCMPGTD).
+
+  if (f.u >= f16max.u) {  // result is Inf or NaN (all exponent bits set)
+    o.x = (f.u > f32infty.u) ? 0x7e00 : 0x7c00; // NaN->qNaN and Inf->Inf
+  } else {  // (De)normalized number or zero
+    if (f.u < (113 << 23)) {  // resulting FP16 is subnormal or zero
+      // use a magic value to align our 10 mantissa bits at the bottom of
+      // the float. as long as FP addition is round-to-nearest-even this
+      // just works.
+      f.f += denorm_magic.f;
+
+      // and one integer subtract of the bias later, we have our final float!
+      o.x = static_cast<unsigned short>(f.u - denorm_magic.u);
+    } else {
+      unsigned int mant_odd = (f.u >> 13) & 1; // resulting mantissa is odd
+
+      // update exponent, rounding bias part 1
+      f.u += ((unsigned int)(15 - 127) << 23) + 0xfff;
+      // rounding bias part 2
+      f.u += mant_odd;
+      // take the bits!
+      o.x = static_cast<unsigned short>(f.u >> 13);
+    }
+  }
+
+  o.x |= static_cast<unsigned short>(sign >> 16);
+  return o;
+#endif
+}
+
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC float half_to_float(__half_raw h) {
+#if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 300
+  return __half2float(h);
+
+#elif defined(EIGEN_HAS_FP16_C)
+  return _cvtsh_ss(h.x);
+
+#else
+  const FP32 magic = { 113 << 23 };
+  const unsigned int shifted_exp = 0x7c00 << 13; // exponent mask after shift
+  FP32 o;
+
+  o.u = (h.x & 0x7fff) << 13;             // exponent/mantissa bits
+  unsigned int exp = shifted_exp & o.u;   // just the exponent
+  o.u += (127 - 15) << 23;                // exponent adjust
+
+  // handle exponent special cases
+  if (exp == shifted_exp) {     // Inf/NaN?
+    o.u += (128 - 16) << 23;    // extra exp adjust
+  } else if (exp == 0) {        // Zero/Denormal?
+    o.u += 1 << 23;             // extra exp adjust
+    o.f -= magic.f;             // renormalize
+  }
+
+  o.u |= (h.x & 0x8000) << 16;    // sign bit
+  return o.f;
+#endif
+}
+
+// --- standard functions ---
+
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool (isinf)(const half& a) {
+  return (a.x & 0x7fff) == 0x7c00;
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool (isnan)(const half& a) {
+#if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 530
+  return __hisnan(a);
+#else
+  return (a.x & 0x7fff) > 0x7c00;
+#endif
+}
+//EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool (isfinite)(const half& a) {
+//  return !(isinf EIGEN_NOT_A_MACRO (a)) && !(isnan EIGEN_NOT_A_MACRO (a));
+//}
+
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half abs(const half& a) {
+  half result;
+  result.x = a.x & 0x7FFF;
+  return result;
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half exp(const half& a) {
+#if EIGEN_CUDACC_VER >= 80000 && defined EIGEN_CUDA_ARCH && EIGEN_CUDA_ARCH >= 530
+  return half(hexp(a));
+#else
+   return half(::expf(float(a)));
+#endif
+}
+//EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half expm1(const half& a) {
+//  return half(numext::expm1(float(a)));
+//}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half log(const half& a) {
+#if defined(EIGEN_HAS_CUDA_FP16) && EIGEN_CUDACC_VER >= 80000 && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 530
+  return half(::hlog(a));
+#else
+  return half(::logf(float(a)));
+#endif
+}
+//EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half log1p(const half& a) {
+//  return half(numext::log1p(float(a)));
+//}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half log10(const half& a) {
+  return half(::log10f(float(a)));
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half sqrt(const half& a) {
+#if EIGEN_CUDACC_VER >= 80000 && defined EIGEN_CUDA_ARCH && EIGEN_CUDA_ARCH >= 530
+  return half(hsqrt(a));
+#else
+    return half(::sqrtf(float(a)));
+#endif
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half pow(const half& a, const half& b) {
+  return half(::powf(float(a), float(b)));
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half sin(const half& a) {
+  return half(::sinf(float(a)));
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half cos(const half& a) {
+  return half(::cosf(float(a)));
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half tan(const half& a) {
+  return half(::tanf(float(a)));
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half tanh(const half& a) {
+  return half(::tanhf(float(a)));
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half floor(const half& a) {
+#if EIGEN_CUDACC_VER >= 80000 && defined EIGEN_CUDA_ARCH && EIGEN_CUDA_ARCH >= 300
+  return half(hfloor(a));
+#else
+  return half(::floorf(float(a)));
+#endif
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half ceil(const half& a) {
+#if EIGEN_CUDACC_VER >= 80000 && defined EIGEN_CUDA_ARCH && EIGEN_CUDA_ARCH >= 300
+  return half(hceil(a));
+#else
+  return half(::ceilf(float(a)));
+#endif
+}
+
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half (min)(const half& a, const half& b) {
+#if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 530
+  return __hlt(b, a) ? b : a;
+#else
+  const float f1 = static_cast<float>(a);
+  const float f2 = static_cast<float>(b);
+  return f2 < f1 ? b : a;
+#endif
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half (max)(const half& a, const half& b) {
+#if defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 530
+  return __hlt(a, b) ? b : a;
+#else
+  const float f1 = static_cast<float>(a);
+  const float f2 = static_cast<float>(b);
+  return f1 < f2 ? b : a;
+#endif
+}
+
+EIGEN_ALWAYS_INLINE std::ostream& operator << (std::ostream& os, const half& v) {
+  os << static_cast<float>(v);
+  return os;
+}
+
+} // end namespace half_impl
+
+// import Eigen::half_impl::half into Eigen namespace
+// using half_impl::half;
+
+namespace internal {
+
+template<>
+struct random_default_impl<half, false, false>
+{
+  static inline half run(const half& x, const half& y)
+  {
+    return x + (y-x) * half(float(std::rand()) / float(RAND_MAX));
+  }
+  static inline half run()
+  {
+    return run(half(-1.f), half(1.f));
+  }
+};
+
+template<> struct is_arithmetic<half> { enum { value = true }; };
+
+} // end namespace internal
+
+template<> struct NumTraits<Eigen::half>
+    : GenericNumTraits<Eigen::half>
+{
+  enum {
+    IsSigned = true,
+    IsInteger = false,
+    IsComplex = false,
+    RequireInitialization = false
+  };
+
+  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Eigen::half epsilon() {
+    return half_impl::raw_uint16_to_half(0x0800);
+  }
+  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Eigen::half dummy_precision() { return Eigen::half(1e-2f); }
+  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Eigen::half highest() {
+    return half_impl::raw_uint16_to_half(0x7bff);
+  }
+  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Eigen::half lowest() {
+    return half_impl::raw_uint16_to_half(0xfbff);
+  }
+  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Eigen::half infinity() {
+    return half_impl::raw_uint16_to_half(0x7c00);
+  }
+  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Eigen::half quiet_NaN() {
+    return half_impl::raw_uint16_to_half(0x7c01);
+  }
+};
+
+} // end namespace Eigen
+
+// C-like standard mathematical functions and trancendentals.
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half fabsh(const Eigen::half& a) {
+  Eigen::half result;
+  result.x = a.x & 0x7FFF;
+  return result;
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half exph(const Eigen::half& a) {
+  return Eigen::half(::expf(float(a)));
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half logh(const Eigen::half& a) {
+#if EIGEN_CUDACC_VER >= 80000 && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 530
+  return Eigen::half(::hlog(a));
+#else
+  return Eigen::half(::logf(float(a)));
+#endif
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half sqrth(const Eigen::half& a) {
+  return Eigen::half(::sqrtf(float(a)));
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half powh(const Eigen::half& a, const Eigen::half& b) {
+  return Eigen::half(::powf(float(a), float(b)));
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half floorh(const Eigen::half& a) {
+  return Eigen::half(::floorf(float(a)));
+}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half ceilh(const Eigen::half& a) {
+  return Eigen::half(::ceilf(float(a)));
+}
+
+namespace std {
+
+#if __cplusplus > 199711L
+template <>
+struct hash<Eigen::half> {
+  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::size_t operator()(const Eigen::half& a) const {
+    return static_cast<std::size_t>(a.x);
+  }
+};
+#endif
+
+} // end namespace std
+
+
+// Add the missing shfl_xor intrinsic
+#if defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 300
+__device__ EIGEN_STRONG_INLINE Eigen::half __shfl_xor(Eigen::half var, int laneMask, int width=warpSize) {
+  #if EIGEN_CUDACC_VER < 90000
+  return static_cast<Eigen::half>(__shfl_xor(static_cast<float>(var), laneMask, width));
+  #else
+  return static_cast<Eigen::half>(__shfl_xor_sync(0xFFFFFFFF, static_cast<float>(var), laneMask, width));
+  #endif
+}
+#endif
+
+// ldg() has an overload for __half_raw, but we also need one for Eigen::half.
+#if defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 350
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half __ldg(const Eigen::half* ptr) {
+  return Eigen::half_impl::raw_uint16_to_half(
+      __ldg(reinterpret_cast<const unsigned short*>(ptr)));
+}
+#endif
+
+
+#if defined(EIGEN_CUDA_ARCH)
+namespace Eigen {
+namespace numext {
+
+template<>
+EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
+bool (isnan)(const Eigen::half& h) {
+  return (half_impl::isnan)(h);
+}
+
+template<>
+EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
+bool (isinf)(const Eigen::half& h) {
+  return (half_impl::isinf)(h);
+}
+
+template<>
+EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
+bool (isfinite)(const Eigen::half& h) {
+  return (half_impl::isfinite)(h);
+}
+
+} // namespace Eigen
+}  // namespace numext
+#endif
+
+#endif // EIGEN_HALF_CUDA_H
diff --git a/Trigger/TrigFTK/TrigFTK_RawData/src/FTK_RawTrack.cxx b/Trigger/TrigFTK/TrigFTK_RawData/src/FTK_RawTrack.cxx
index e514d1c589f..6bbc675e768 100644
--- a/Trigger/TrigFTK/TrigFTK_RawData/src/FTK_RawTrack.cxx
+++ b/Trigger/TrigFTK/TrigFTK_RawData/src/FTK_RawTrack.cxx
@@ -3,12 +3,15 @@
 */
 
 #include "TrigFTK_RawData/FTK_RawTrack.h"
-
+#include "Eigen/Core"
+#define EIGEN_DEVICE_FUNC 
+#include "EigenHalf.h"
+#undef EIGEN_DEVICE_FUNC 
 #include <iostream>
 #include <TMath.h>
 #include <cmath>
 
-using namespace std;
+using Eigen::half_impl::__half_raw;
 
 const float FTK_RawTrack::s_d0_multiplier     = 1000.; // reciprocal of precision
 const float FTK_RawTrack::s_z0_multiplier     = 100.; 
@@ -19,10 +22,13 @@ const float FTK_RawTrack::s_chi2_multiplier   = 1000.;
 //const float FTK_RawTrack::s_quality_multiplier = 1000.;
 
 
+// The Default constructor sets the version to the current version. 
+// The constructors with datawords tak ethe version set in the dataword.
+
 FTK_RawTrack::FTK_RawTrack() :
   m_word_th1((0xbda)<<16), // sector (16 bit), 0xa (4 bit), 0d (4 bit), 0xb (4 bit), reserved (3 bit), is fSSB (1 bit)
   m_word_th2(0), // layermap (12 bit), reserved (4 bit), tower (7 bit), reserved (1bit), TF num (3 bit), reserved (5 bit)
-  m_word_th3(0), // road (24 bit), reserved (8 bit)
+  m_word_th3((FTK_RAWTRACK_VERSION)<<24), // road (24 bit), reserved (8 bit)
   m_word_th4(0), // TRACK_D0, TRACK_CHISQ   16-bit, 16-bit
   m_word_th5(0), // TRACK_COTTH, TRACK_Z0   16-bit, 16-bit
   m_word_th6(0),  // TRACK_CURV, TRACK_PHI0  16-bit, 16-bit
@@ -42,9 +48,30 @@ FTK_RawTrack::FTK_RawTrack() :
   }
 }
 
+FTK_RawTrack::FTK_RawTrack(const FTK_RawTrack& track) {
+
+  m_pix_clusters.reserve(track.getPixelClusters().size());
+  m_sct_clusters.reserve(track.getSCTClusters().size());
+
+  unsigned int layer=0;
+  for (unsigned int ipix=0; ipix < track.getPixelClusters().size();  ++ipix,++layer){
+    m_pix_clusters.push_back(track.getPixelCluster(layer));
+  }
+  for (unsigned int isct=0; isct < track.getSCTClusters().size();  ++isct,++layer){
+    m_sct_clusters.push_back(track.getSCTCluster(layer));
+  }
+  m_word_th1 = track.getTH1();
+  m_word_th2 = track.getTH2();
+  m_word_th3 = track.getTH3();
+  m_word_th4 = track.getTH4();
+  m_word_th5 = track.getTH5();
+  m_word_th6 = track.getTH6();
+
+  m_barcode=track.getBarcode();
+}
+
 FTK_RawTrack::FTK_RawTrack(uint32_t word_th1, uint32_t word_th2, uint32_t word_th3, uint32_t word_th4, uint32_t word_th5, uint32_t word_th6)
 {
-  
   m_barcode = 0;
   m_word_th1 = word_th1;
   m_word_th2 = word_th2;
@@ -69,6 +96,7 @@ FTK_RawTrack::FTK_RawTrack(uint32_t word_th1, uint32_t word_th2, uint32_t word_t
 
 FTK_RawTrack::FTK_RawTrack(uint32_t word_th1, uint32_t word_th2, uint32_t word_th3, uint32_t word_th4, uint32_t word_th5, uint32_t word_th6, const std::vector<FTK_RawPixelCluster>& pixel_clusters, const std::vector<FTK_RawSCT_Cluster>& SCT_clusters){
 
+
   m_barcode = 0;
   m_word_th1 = word_th1;
   m_word_th2 = word_th2;
@@ -225,11 +253,8 @@ void FTK_RawTrack::setTower(unsigned int tower) {
 
 void FTK_RawTrack::setD0(float track_d0){
 
-  float d0_f =  track_d0 * s_d0_multiplier + (float) s_sixteen_bit_offset;
-  if (d0_f>65535.) d0_f = 65535.;
-  else if (d0_f < 0.) d0_f = 0;
+  uint16_t d0 = Eigen::half(track_d0).x;
 
-  uint32_t d0 = round(d0_f);
   m_word_th4 = (d0 | m_word_th4);
 
   return; 
@@ -237,36 +262,32 @@ void FTK_RawTrack::setD0(float track_d0){
 
 void FTK_RawTrack::setZ0(float track_z0){
 
-  float z0_f =  track_z0 *  s_z0_multiplier + (float)s_sixteen_bit_offset;
-  if (z0_f>65535.) z0_f = 65535.;
-  else if (z0_f < 0.) z0_f = 0;
-  
-  uint32_t z0 = round(z0_f);
-
-  z0 = z0 << 16;
+  uint16_t z0 = Eigen::half(track_z0).x;
 
-  m_word_th5 = z0 | m_word_th5;
+  m_word_th5 = (z0 << 16) | m_word_th5;
 
   return;
 }
 
 void FTK_RawTrack::setCotTh(float track_cot){
-  float cot_f = track_cot * s_cot_multiplier + (float)s_sixteen_bit_offset;
 
-  if (cot_f>65535.) cot_f = 65535.;
-  if (cot_f < 0.) cot_f = 0.;
-  uint32_t cot = round(cot_f);
+  uint16_t cot = Eigen::half(track_cot).x;
+
   m_word_th5 = cot | m_word_th5;
 
   return;
 }
 
 double FTK_RawTrack::getCotTh() const{
+  double cot_f=0.;
   uint16_t cot = m_word_th5 & 0xffff;
-  double cot_f = (double) cot;
-  cot_f = cot_f-s_sixteen_bit_offset;
-  cot_f = cot_f/s_cot_multiplier;
-
+  if ((this->trackVersion())==0) {
+    cot_f = (double) cot;
+    cot_f = cot_f-s_sixteen_bit_offset;
+    cot_f = cot_f/s_cot_multiplier;
+  } else {
+    cot_f = float(Eigen::half(__half_raw(cot)));
+  }
   return cot_f;
 }
 
@@ -274,26 +295,17 @@ double FTK_RawTrack::getCotTh() const{
 
 void FTK_RawTrack::setPhi(float track_phi){
 
-  uint32_t phi = 0;
+  uint16_t phi = Eigen::half(track_phi).x;
 
-  // input phi must be in range -pi to pi 
+  m_word_th6 = (phi<<16) | m_word_th6;
 
-  float phi_value  = s_phi_multiplier*track_phi + s_sixteen_bit_offset;
-  if (phi_value<0) phi_value=0;
-  else if (phi_value>65535.)phi_value=65535.;
-  phi=round(phi_value);
-  phi = phi << 16;
-  m_word_th6 = phi | m_word_th6;
   return;
 }
 
 void FTK_RawTrack::setInvPt(float track_invpt){
 
+  uint16_t invpt = Eigen::half(track_invpt).x;
 
-  float ptinv = track_invpt * s_invpt_multiplier + (float) s_sixteen_bit_offset;
-  if (ptinv<0.) ptinv=0.;
-  else if (ptinv>65535.) ptinv=65535.;
-  uint16_t invpt = round(ptinv); 
   m_word_th6 = invpt | m_word_th6;
   return;
 }
@@ -301,11 +313,17 @@ void FTK_RawTrack::setInvPt(float track_invpt){
 
 double FTK_RawTrack::getInvPt() const{
 
-  uint32_t invpt = (m_word_th6 & 0xffff);
   
-  double invpt_f = (double) invpt;
-  invpt_f = (invpt_f-s_sixteen_bit_offset);
-  invpt_f =  invpt_f /s_invpt_multiplier;
+  double invpt_f = 0.;
+
+  if (this->trackVersion()==0) {
+    uint32_t invpt = (m_word_th6 & 0xffff);
+    invpt_f = (invpt-s_sixteen_bit_offset);
+    invpt_f =  invpt_f /s_invpt_multiplier;
+  } else {
+    uint16_t invpt = (m_word_th6 & 0xffff);
+    invpt_f = float(Eigen::half(__half_raw(invpt)));
+  }
   return invpt_f;
 }
 
@@ -313,58 +331,76 @@ double FTK_RawTrack::getInvPt() const{
 
 void FTK_RawTrack::setChi2(float track_chi2){
 
-  float ch2_f = track_chi2* s_chi2_multiplier;
-  if (ch2_f > 65535.)ch2_f = 65535.; 
-  uint32_t chi2 = round(ch2_f);
-  chi2 = chi2 << 16;
-  m_word_th4 = chi2 | m_word_th4;
+  uint16_t chi2 = Eigen::half(track_chi2).x;
+  m_word_th4 = (chi2<< 16) | m_word_th4;
 
   return;
 }
 
-// ununsed now
-// void FTK_RawTrack::setQuality(float track_qual){
-  
-//   float q_f = track_qual * s_quality_multiplier;
-//   if (q_f > 65535.) q_f = 65535.;
-//   else if (q_f < 0) q_f = 0.;
-//   uint32_t qual = round (q_f);
-//   qual = qual << 16;
-//   m_word_th5 = qual | m_word_th5;
-
-//   return;
-// }
-
 float FTK_RawTrack::getD0() const{
-  uint32_t d0=m_word_th4 & 0xffff;
-  double d0_f = ((double)d0 - (double)s_sixteen_bit_offset)/s_d0_multiplier;
+  double d0_f = 0.;
+  if (this->trackVersion()==0) {
+    uint32_t d0=m_word_th4 & 0xffff;
+    d0_f = ((double)d0 - (double)s_sixteen_bit_offset)/s_d0_multiplier;
+  } else {
+    uint16_t d0=m_word_th4 & 0xffff;
+     d0_f = float(Eigen::half(__half_raw(d0)));
+  }
   return d0_f;
+    
 }
 
 float FTK_RawTrack::getZ0() const{
-  uint32_t z0 = (m_word_th5 & 0xffff0000) >> 16;
-  double z0_f = ((double)z0 - (double) s_sixteen_bit_offset)/s_z0_multiplier;
+  double z0_f=0.;
+  if (this->trackVersion()==0) {
+    uint32_t z0 = (m_word_th5 & 0xffff0000) >> 16;
+    z0_f = ((double)z0 - (double) s_sixteen_bit_offset)/s_z0_multiplier;
+  } else {
+    uint16_t z0 = (m_word_th5 & 0xffff0000) >> 16;
+    z0_f = float(Eigen::half(__half_raw(z0)));
+  }
   return z0_f;
 }
 
 float FTK_RawTrack::getPhi() const{
-  uint32_t phi = (m_word_th6 & 0xffff0000) >> 16;
-  double d0_f = ((double)phi - (double) s_sixteen_bit_offset)/s_phi_multiplier;
-  return d0_f;
+  double phi_f=0.;
+  if (this->trackVersion()==0) {
+    uint32_t  phi = (m_word_th6 & 0xffff0000) >> 16;
+    phi_f = ((double)phi - (double) s_sixteen_bit_offset)/s_phi_multiplier;
+  } else {
+    uint16_t  phi = (m_word_th6 & 0xffff0000) >> 16;
+    phi_f = float(Eigen::half(__half_raw(phi)));
+  }
+  return phi_f;
 }
 
 
 double FTK_RawTrack::getChi2() const{
-  uint32_t chi2 = (m_word_th4 & 0xffff0000) >> 16;
-  double chi2_f = (double)chi2/s_chi2_multiplier;
+  double chi2_f = 0.;
+  if (this->trackVersion()==0) {
+    uint32_t chi2 = (m_word_th4 & 0xffff0000) >> 16;
+    chi2_f = (double)chi2/s_chi2_multiplier;
+  } else {
+    uint16_t chi2 = (m_word_th4 & 0xffff0000) >> 16;
+    chi2_f = float(Eigen::half(__half_raw(chi2)));
+  }
   return chi2_f;
+
+}
+
+
+void FTK_RawTrack::setIsAuxFormat(bool isAux) {
+  if (isAux) {
+    m_word_th2 =   m_word_th2 | 0x1000;
+  } else {
+    m_word_th2 =   m_word_th2 & 0xFFFFEFFF;
+  }
+}
+
+bool FTK_RawTrack::getIsAuxFormat() const {
+  return ((m_word_th2 & 0x1000) !=0);
 }
 
-// double FTK_RawTrack::getQuality() const{
-//   uint32_t qual = m_word_th5 >> 16;
-//   double qual_f = (double) qual /s_quality_multiplier;
-//   return qual_f;
-// }
 
 #if defined(__MAKECINT__)
 #pragma link C++ class FTK_RawTrack;
diff --git a/Trigger/TrigFTK/TrigFTK_RawDataAlgs/CMakeLists.txt b/Trigger/TrigFTK/TrigFTK_RawDataAlgs/CMakeLists.txt
index 1720c9a5ce1..fedb70caa56 100644
--- a/Trigger/TrigFTK/TrigFTK_RawDataAlgs/CMakeLists.txt
+++ b/Trigger/TrigFTK/TrigFTK_RawDataAlgs/CMakeLists.txt
@@ -26,7 +26,8 @@ atlas_depends_on_subdirs( PUBLIC
                           InnerDetector/InDetDetDescr/InDetIdentifier
                           InnerDetector/InDetDetDescr/InDetReadoutGeometry
                           Tracking/TrkEvent/TrkTrack
-                          Tracking/TrkEvent/TrkTrackSummary )
+                          Tracking/TrkEvent/TrkTrackSummary 
+                          Trigger/TrigFTK/FTK_RecToolInterfaces)
 
 # External dependencies:
 find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread )
@@ -42,7 +43,7 @@ atlas_add_library( TrigFTK_RawDataAlgsLib
 atlas_add_component( TrigFTK_RawDataAlgs
                      src/components/*.cxx
                      INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
-                     LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps PileUpToolsLib GaudiKernel TrkEventPrimitives FTK_DataProviderInterfaces TrigFTKPool TrigFTKSimLib TrigFTK_RawData AtlasDetDescr EventInfo xAODTracking  xAODTruth InDetIdentifier InDetReadoutGeometry TrkTrack TrkTrackSummary VxVertex TrigFTK_RawDataAlgsLib )
+                     LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps PileUpToolsLib GaudiKernel TrkEventPrimitives  FTK_DataProviderInterfaces TrigFTKPool TrigFTKSimLib TrigFTK_RawData AtlasDetDescr EventInfo xAODTracking  xAODTruth InDetIdentifier InDetReadoutGeometry TrkTrack TrkTrackSummary VxVertex TrigFTK_RawDataAlgsLib )
 
 # Install files from the package:
 atlas_install_python_modules( python/*.py )
diff --git a/Trigger/TrigFTK/TrigFTK_RawDataAlgs/share/FTKMonitor_topOptions.py b/Trigger/TrigFTK/TrigFTK_RawDataAlgs/share/FTKMonitor_topOptions.py
index ee21fe0f98d..76dd63324cc 100644
--- a/Trigger/TrigFTK/TrigFTK_RawDataAlgs/share/FTKMonitor_topOptions.py
+++ b/Trigger/TrigFTK/TrigFTK_RawDataAlgs/share/FTKMonitor_topOptions.py
@@ -46,9 +46,6 @@ svcMgr += THistSvc(Output = ["TRACKS DATAFILE='ftk.root', OPT='RECREATE'"])
 #ServiceMgr.ConfiguredFTK_DataProviderSvc.OutputLevel=VERBOSE
 #topSequence.FTK_RDO_MonitorAlgo.reverseIBLlocx=True
 #topSequence.FTK_RDO_MonitorAlgo.OutputLevel=DEBUG
-topSequence.FTK_RDO_MonitorAlgo.GetHashFromTrack=True        # if both set to true, will compare and report errors
-topSequence.FTK_RDO_MonitorAlgo.GetHashFromConstants=False   # if both set to true, will compare and report errors
-
 #topSequence.FTK_Tracks_DetailedTruthCollectionMaker.OutputLevel=VERBOSE
 #topSequence.FTK_RefitTracks_DetailedTruthCollectionMaker.OutputLevel=VERBOSE
 #ToolSvc.FTK_TrackFitter.OutputLevel=VERBOSE
diff --git a/Trigger/TrigFTK/TrigFTK_RawDataAlgs/src/FTK_RDO_CreatorAlgo.cxx b/Trigger/TrigFTK/TrigFTK_RawDataAlgs/src/FTK_RDO_CreatorAlgo.cxx
index 09f4e6a511e..b34c2037836 100644
--- a/Trigger/TrigFTK/TrigFTK_RawDataAlgs/src/FTK_RDO_CreatorAlgo.cxx
+++ b/Trigger/TrigFTK/TrigFTK_RawDataAlgs/src/FTK_RDO_CreatorAlgo.cxx
@@ -63,11 +63,11 @@ FTK_RDO_CreatorAlgo::FTK_RDO_CreatorAlgo(const std::string& name, ISvcLocator* p
   declareProperty("ReverseIBLlocX",m_reverseIBLlocx, "reverse the direction of IBL locX from FTK");
 
   m_FTK_RawTrack_checkFails.reserve(9);
-  m_FTK_RawSCT_Cluster_checkFails.reserve(5);
-  m_FTK_RawPixelCluster_checkFails.reserve(3);
+  m_FTK_RawSCT_Cluster_checkFails.reserve(3);
+  m_FTK_RawPixelCluster_checkFails.reserve(5);
   for (unsigned int i=0; i < 9; i++)   m_FTK_RawTrack_checkFails[i]=0;
-  for (unsigned int i=0; i < 5; i++)   m_FTK_RawSCT_Cluster_checkFails[i]=0;
-  for (unsigned int i=0; i < 3; i++)   m_FTK_RawPixelCluster_checkFails[i]=0;
+  for (unsigned int i=0; i < 3; i++)   m_FTK_RawSCT_Cluster_checkFails[i]=0;
+  for (unsigned int i=0; i < 5; i++)   m_FTK_RawPixelCluster_checkFails[i]=0;
 }
 
 FTK_RDO_CreatorAlgo::~FTK_RDO_CreatorAlgo()
@@ -552,11 +552,11 @@ void FTK_RDO_CreatorAlgo::printTrack(const FTKTrack& track, const FTK_RawTrack *
 }
 
 #define d0Res 0.001
-#define z0Res 0.01
-#define phiRes 0.0001
+#define z0Res 0.001
+#define phiRes 0.001
 #define chi2Res 0.001
-#define cotThetaRes 0.00025
-#define invPtRes 5e-8 // MeV^-1
+#define cotThetaRes 0.001
+#define invPtRes 0.0015 
 #define sctStripRes 0.5
 #define pixColRes 0.1
 #define pixRowRes 0.1
@@ -696,9 +696,11 @@ bool FTK_RDO_CreatorAlgo::check_track(const FTKTrack &track, FTK_RawTrack &rdo)
 
 bool FTK_RDO_CreatorAlgo::checkValue(const float &v1, const float &v2, const float &res, const std::string &what) {
   bool check_ok = true;
-  if (fabs(v1-v2) > res) {
-    ATH_MSG_INFO( "FTK_RDO_CreatorAlgo::checkValue check failed for "<< what << " difference FTKTrack-RDO= " <<  v1-v2 << " values:  FTKTrack " << v1 << " RDO " << v2 << " resolution "  << res);
-    check_ok=false;
+  if (fabs(v1+v2)>1e-10) {
+    if (fabs(2*(v1-v2)/(v1+v2)) > res) {
+      ATH_MSG_INFO( "FTK_RDO_CreatorAlgo::checkValue check failed for "<< what << " difference 2*(FTKTrack-RDO)/(FTKTrack+RDO) = " <<  2*(v1-v2)/(v1+v2) << " values:  FTKTrack " << v1 << " RDO " << v2 << " resolution "  << res);
+      check_ok=false;
+    }
   }
   return check_ok;
 }
diff --git a/Trigger/TrigFTK/TrigFTK_RawDataAlgs/src/FTK_RDO_MonitorAlgo.cxx b/Trigger/TrigFTK/TrigFTK_RawDataAlgs/src/FTK_RDO_MonitorAlgo.cxx
index 338c2ff8af6..9b2213040d6 100644
--- a/Trigger/TrigFTK/TrigFTK_RawDataAlgs/src/FTK_RDO_MonitorAlgo.cxx
+++ b/Trigger/TrigFTK/TrigFTK_RawDataAlgs/src/FTK_RDO_MonitorAlgo.cxx
@@ -33,6 +33,7 @@
 #include "GaudiKernel/IHistogramSvc.h"
 #include "GaudiKernel/ITHistSvc.h"
 #include "GaudiKernel/MsgStream.h"
+#include "InDetRIO_OnTrack/SiClusterOnTrack.h"
 
 #include "TMath.h"
 
@@ -56,16 +57,16 @@ FTK_RDO_MonitorAlgo::FTK_RDO_MonitorAlgo(const std::string& name, ISvcLocator* p
   m_maxphi(10.),
   m_minMatches(6),
   m_reverseIBLlocx(false),
-  m_max_tower(64),
   m_Nlayers(12),
   m_getHashFromTrack(true),
   m_getHashFromConstants(false),
-  m_towerID(0),
   m_getRawTracks(true),
   m_getTracks(true),
-  m_getRefitTracks(true)
+  m_getRefitTracks(true),
+  m_HashIDTool("IFTK_HashIDTool/TrigFTK_HashIDTool")
 
 {
+  declareProperty("HashIDTool",m_HashIDTool);
   declareProperty("RDO_CollectionName",m_ftk_raw_trackcollection_Name, "Collection name of RDO");
   declareProperty("offlineTracksName",m_offlineTracksName," offline tracks collection name");
   declareProperty("FTK_DataProvider", m_DataProviderSvc);
@@ -78,13 +79,9 @@ FTK_RDO_MonitorAlgo::FTK_RDO_MonitorAlgo(const std::string& name, ISvcLocator* p
   declareProperty("maxphi", m_maxphi,"Maximum phi for offline track");
   declareProperty("minMatches", m_minMatches,"Minimum number of matched hits");
   declareProperty("reverseIBLlocx",m_reverseIBLlocx,"reverse direction of IBL locx from FTK");
-  declareProperty("ConstantsDir",m_ConstantsDir="/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/FTK","directory for constants");
-  declareProperty("PatternsVersion",m_PatternsVersion="ftk.64tower.2016.mc16.v2","Patterns Version");
-  declareProperty("Ntowers",m_max_tower,"No. FTK Towers");
   declareProperty("Nlayers",m_Nlayers,"No. FTK layers in the SectorsFile");
   declareProperty("GetHashFromTrack",m_getHashFromTrack," Get HashID From Track");
   declareProperty("GetHashFromConstants",m_getHashFromConstants," Get HashID From Constants");
-  declareProperty("TowerID",m_towerID,"if non-zero TowerID overrides value in BS");
   declareProperty("getRawTracks",m_getRawTracks,"get Raw FTK tracks");
   declareProperty("getTracks",m_getTracks,"get FTK tracks");
   declareProperty("getRefitTracks",m_getRefitTracks,"get Refit FTK tracks");
@@ -111,7 +108,9 @@ StatusCode FTK_RDO_MonitorAlgo::initialize(){
   /// Get Histogram Service ///
   ATH_CHECK(service("THistSvc", m_rootHistSvc));
 
-  
+  if (m_getHashFromConstants) {
+    ATH_CHECK(m_HashIDTool.retrieve());
+  }
 
   ///Tree
   std::string trackRootPath;
@@ -164,9 +163,6 @@ StatusCode FTK_RDO_MonitorAlgo::initialize(){
   if ( m_reverseIBLlocx ) 
     ATH_MSG_INFO("reversing direction of IBL locx");
 
-  ATH_MSG_INFO("ConstantsDir: "<<m_ConstantsDir);
-  ATH_MSG_INFO("PatternsVersion: "<<m_PatternsVersion);
-  ATH_MSG_INFO("Ntowers= " << m_max_tower);
   ATH_MSG_INFO("Nlayers= "<<m_Nlayers);
 
   if (m_getHashFromTrack && m_getHashFromConstants) {
@@ -180,24 +176,7 @@ StatusCode FTK_RDO_MonitorAlgo::initialize(){
     m_getHashFromTrack=true;
   }
     
-
-  StatusCode ret=StatusCode::SUCCESS;
-  if (m_getHashFromConstants) {
-    m_moduleFromSector.resize(m_max_tower);
-    for (unsigned int itower=0; itower<m_max_tower; itower++) {
-            
-      m_moduleFromSector[itower] = new sectormap();
-      unsigned int returnCode = (this)->readModuleIds(itower, *(m_moduleFromSector[itower]));
-
-      if (returnCode) {
-	ATH_MSG_WARNING("Error " << returnCode << " loading constants for tower " << itower);
-	ret=StatusCode::FAILURE;
-	break;
-      } 
-
-    }
-  }
-  return ret; 
+  return StatusCode::SUCCESS; 
 }
 
 
@@ -227,17 +206,9 @@ StatusCode FTK_RDO_MonitorAlgo::execute() {
   }
   
   // get FTK tracks
-  const FTK_RawTrackContainer *rawTracks ( nullptr );
-  
-  if ( evtStore()->contains<FTK_RawTrackContainer> ( m_ftk_raw_trackcollection_Name) ) {
-    if ( evtStore()->retrieve ( rawTracks, m_ftk_raw_trackcollection_Name  ).isFailure() ) {
-      ATH_MSG_DEBUG("Could not retrieve FTK_RawTrackContainer " <<  m_ftk_raw_trackcollection_Name << " in StoreGate.");
-    }
-  } else {
-    ATH_MSG_DEBUG("Could not find FTK_RawTrackContainer " <<  m_ftk_raw_trackcollection_Name << " in StoreGate.");
-    
-  }
-  
+  const FTK_RawTrackContainer *rawTracks = m_DataProviderSvc->getRawTracks();
+  ATH_MSG_DEBUG("rawTracks at " << std::hex << rawTracks << std::dec);
+
   if (rawTracks == nullptr) {
     ATH_MSG_DEBUG("No FTK tracks");
     return StatusCode::SUCCESS;
@@ -246,7 +217,23 @@ StatusCode FTK_RDO_MonitorAlgo::execute() {
   
   ATH_MSG_DEBUG(" Got FTK_RawTrackContainer with " << rawTracks->size() << " tracks");
   m_h_FTK_RawTrack_n->Fill(rawTracks->size());
+
+  if (rawTracks->size()==0) {
+    ATH_MSG_DEBUG("No FTK tracks");
+    return StatusCode::SUCCESS;
+  }
   
+  // Trigger conversion of FTK tracks - needed later when we get the cached tracks
+  if (m_getTracks) {
+    TrackCollection* ftkTracks=m_DataProviderSvc->getTracks(false);
+    ATH_MSG_DEBUG("Got " << ftkTracks->size() << " Converted Tracks");
+    delete(ftkTracks);
+  }
+  if (m_getRefitTracks) {
+    TrackCollection* ftkRefitTracks=m_DataProviderSvc->getTracks(true);
+    ATH_MSG_DEBUG("Got " << ftkRefitTracks->size() << " Refitted Tracks");
+    delete(ftkRefitTracks);
+  }
 
   unsigned int pixMaxHash = m_pixelId->wafer_hash_max();
   unsigned int sctMaxHash = m_sctId->wafer_hash_max();
@@ -335,19 +322,11 @@ StatusCode FTK_RDO_MonitorAlgo::execute() {
 	float ftkTrkEta = -std::log(std::tan(ftkTrkTheta/2.));
 	float ftkTrkPt=1.e10;
 	if (fabs((ftkRawTrack)->getInvPt()) >= 1e-10) ftkTrkPt=1./(ftkRawTrack)->getInvPt();
-	
-	ATH_MSG_VERBOSE(" FTK     Track " << ftkTrackMatch.second << " pT " << ftkTrkPt << " eta " << ftkTrkEta << 
-			" phi0 " << (ftkRawTrack)->getPhi() << " d0 " << (ftkRawTrack)->getD0() << " z0 " << (ftkRawTrack)->getZ0());
-	
+	ATH_MSG_VERBOSE(" FTK     Track " << ftkTrackMatch.first << " pT " << ftkTrkPt << " eta " << ftkTrkEta << 
+		    " phi0 " << (ftkRawTrack)->getPhi() << " d0 " << (ftkRawTrack)->getD0() << " z0 " << (ftkRawTrack)->getZ0());
+    
 	//	ATH_MSG_VERBOSE( " nPix: " << (ftkRawTrack)->getPixelClusters().size() << " nSCT: "<< (ftkRawTrack)->getSCTClusters().size()<< " barCode: "<<(ftkRawTrack)->getBarcode()  );
-	  //    ATH_MSG_VERBOSE( "     SectorID " << (ftkRawTrack)->getSectorID()   <<   "  RoadID "  << (ftkRawTrack)->getRoadID() << " LayerMap " << (ftkRawTrack)->getLayerMap());
-	
-	
-	m_h_FTK_pt->Fill(ftkTrkPt);
-	m_h_FTK_eta->Fill(ftkTrkEta);
-	m_h_FTK_phi->Fill((ftkRawTrack)->getPhi());
-	m_h_FTK_d0->Fill((ftkRawTrack)->getD0());
-	m_h_FTK_z0->Fill((ftkRawTrack)->getZ0());
+	//    ATH_MSG_VERBOSE( "     SectorID " << (ftkRawTrack)->getSectorID()   <<   "  RoadID "  << (ftkRawTrack)->getRoadID() << " LayerMap " << (ftkRawTrack)->getLayerMap());
 	
 	if (eta> m_mineta && eta<m_maxeta && phi0> m_minphi && phi0<m_maxphi) {
 	  
@@ -408,11 +387,6 @@ StatusCode FTK_RDO_MonitorAlgo::finalize() {
   MsgStream athlog(msgSvc(), name());
   ATH_MSG_INFO("finalize()" );
   
-  if (m_getHashFromConstants) {
-    for (unsigned int it=0; it<m_max_tower; it++) {
-      delete(m_moduleFromSector[it]);
-    }
-  }
   return StatusCode::SUCCESS;
 
 }
@@ -422,7 +396,6 @@ void FTK_RDO_MonitorAlgo::Hist_Init(std::vector<TH1D*> *histograms){
 
   // FTK Raw Track Histograms //
 
- 
   m_h_FTK_nHitMatch    = new TH1D("h_FTKMoni_nHitMatch",    "No. Hits on track matching Offline; No. Matched Hits; NTracks",      12,  0.,    12.);
   histograms->push_back(m_h_FTK_nHitMatch);
 
@@ -500,9 +473,6 @@ void FTK_RDO_MonitorAlgo::Hist_Init(std::vector<TH1D*> *histograms){
   histograms->push_back(m_h_sctb_locX);
   m_h_scte_locX= new TH1D("h_scte_locX", "SCTE: rawLocalPhiCoord%2)", 2,  -0.5,    1.5);
   histograms->push_back(m_h_scte_locX);
-
-
-
     
   TString histname,histtitle;
   
@@ -620,8 +590,6 @@ void FTK_RDO_MonitorAlgo::Hist_Init(std::vector<TH1D*> *histograms){
   m_h_sctb_1_dlocX.resize(7);
   m_h_scte_0_dlocX.resize(7);
   m_h_scte_1_dlocX.resize(7);
-
-
   
   for (unsigned int trackType=0; trackType<7; trackType++) {
     
@@ -774,7 +742,6 @@ void FTK_RDO_MonitorAlgo::Hist_Init(std::vector<TH1D*> *histograms){
 
   m_h_ftk_pix_etaClusWidth = new TH1D("h_FTKMoni_pix_etaClusWidth", "Pixel cluster width in eta", 8,  -0.5,    7.5);
   histograms->push_back(m_h_ftk_pix_etaClusWidth);
-
   
 }
 		    
@@ -802,18 +769,28 @@ void FTK_RDO_MonitorAlgo::fillMaps(const FTK_RawTrackContainer* rawTracks, std::
   FTK_RawTrackContainer::const_iterator pTrack = rawTracks->begin();
   FTK_RawTrackContainer::const_iterator pLastTrack = rawTracks->end();
   for ( int itr=0; pTrack!= pLastTrack; pTrack++, itr++) {
+
+    const FTK_RawTrack* ftkRawTrack = *pTrack;
+
+    float ftkTrkTheta = std::atan2(1.0,(ftkRawTrack)->getCotTh());
+    float ftkTrkEta = -std::log(std::tan(ftkTrkTheta/2.));
+    float ftkTrkPt=1.e10;
+    if (fabs((ftkRawTrack)->getInvPt()) >= 1e-10) ftkTrkPt=1./(ftkRawTrack)->getInvPt();
+       
     
+    m_h_FTK_pt->Fill(ftkTrkPt);
+    m_h_FTK_eta->Fill(ftkTrkEta);
+    m_h_FTK_phi->Fill((ftkRawTrack)->getPhi());
+    m_h_FTK_d0->Fill((ftkRawTrack)->getD0());
+    m_h_FTK_z0->Fill((ftkRawTrack)->getZ0());
+
     unsigned int tower = (*pTrack)->getTower();
     unsigned int sector = (*pTrack)->getSectorID();
 
-    if (m_towerID!=0) tower=m_towerID;
-      
     ATH_MSG_VERBOSE( itr << std::hex <<
 		     ": Tower 0x" << tower << "     SectorID 0x" << (*pTrack)->getSectorID()   <<   
 		     "  RoadID 0x"  << (*pTrack)->getRoadID() << " LayerMap 0x" << (*pTrack)->getLayerMap() << std::dec <<
 		     " nPix: " << (*pTrack)->getPixelClusters().size() << " nSCT: "<< (*pTrack)->getSCTClusters().size());
-    
-    
 
     unsigned int iPlane=0,ihist=0;
     if (m_Nlayers==8) iPlane=1;
@@ -829,34 +806,53 @@ void FTK_RDO_MonitorAlgo::fillMaps(const FTK_RawTrackContainer* rawTracks, std::
             
       
       IdentifierHash hash=0xffffffff;
+      IdentifierHash hashfromTrack=0xffffffff;
+      IdentifierHash hashfromConstants =0xffffffff;
+
+      bool trackHashValid=false;
+      bool constHashValid=false;
 
-      if (m_getHashFromTrack) hash = (*pTrack)->getPixelClusters()[iPlane].getModuleID();
+      if (m_getHashFromTrack) {
+	hashfromTrack = (*pTrack)->getPixelClusters()[iPlane].getModuleID();
+	if (hashfromTrack<pixMaxHash) {
+	  trackHashValid=true;
+	  ATH_MSG_VERBOSE(" pixel HashID from track 0x" << std::hex << hashfromTrack << std::dec << " for tower " << tower << " sector " << sector << " plane " << iPlane);
+	} else {
+	  ATH_MSG_WARNING(" invalid pixel HashID from track 0x" << std::hex << hashfromTrack << std::dec << " for tower " << tower << " sector " << sector << " plane " << iPlane);
+	}
+      }
       
       if (m_getHashFromConstants) {
-      
-	IdentifierHash hashfromConstants = this->getHash(40, sector, iPlane);
-	if (hashfromConstants > pixMaxHash) {
-	  if ((*m_moduleFromSector[tower]).size()>0)ATH_MSG_WARNING(" invalid pixel HashID 0x" << std::hex << hash << std::dec << " for tower " << tower << " sector " << sector << " plane " << iPlane);
+	hashfromConstants = m_HashIDTool->getHash(tower, sector, iPlane);
+	if (hashfromConstants < pixMaxHash) {
+	  constHashValid=true;
+	  ATH_MSG_VERBOSE(" pixel HashID from constants 0x" << std::hex << hashfromConstants << std::dec << " for tower " << tower << " sector " << sector << " plane " << iPlane);
 	} else {
-	
-	  if (m_getHashFromTrack) { 
-	    if (hashfromConstants != hash) {
-	    
-	      ATH_MSG_WARNING(" Pixel HashID missmatch: hash from Track 0x" << std::hex << hash  << " hash from Constants 0x" << hashfromConstants << std::dec <<" tower " << tower << " sector " << sector << " plane " << iPlane);
-	      unsigned int track_tower=tower, track_sector=sector, track_plane=iPlane;
-	      bool found = this->findHash(hash, false, track_tower, track_sector, track_plane);
-	      if (found) ATH_MSG_WARNING(" track hash found at tower " << track_tower << " sector " << track_sector  << " plane " << track_plane);   
-	      ATH_MSG_WARNING(m_id_helper->print_to_string(m_pixelId->wafer_id(hash)));
-	      ATH_MSG_WARNING(m_id_helper->print_to_string(m_pixelId->wafer_id(hashfromConstants)));
-	      
-	    } else {
-	      ATH_MSG_VERBOSE(" Pixel HashID successful match: hash from Track 0x" << std::hex << hash  << " hash from Constants 0x" << hashfromConstants << std::dec <<" tower " << tower << " sector " << sector << " plane " << iPlane);
-	    }
-	  }
-	}	    
-	if (!m_getHashFromTrack)hash =  hashfromConstants;
+	  ATH_MSG_WARNING(" invalid pixel HashID from constants 0x" << std::hex << hashfromConstants << std::dec << " for tower " << tower << " sector " << sector << " plane " << iPlane);
+	}
+      }
+
+      if (constHashValid && trackHashValid) {
+	if (hashfromTrack != hashfromConstants) { 
+	  
+	  ATH_MSG_WARNING(" Pixel HashID missmatch: hash from Track 0x" << std::hex << hashfromTrack  << " hash from Constants 0x" << hashfromConstants << std::dec <<" tower " << tower << " sector " << sector << " plane " << iPlane);
+	  
+	} else {
+	  ATH_MSG_VERBOSE(" Pixel HashID successful match: hash from Track 0x" << std::hex << hashfromTrack  << " hash from Constants 0x" << hashfromConstants << std::dec <<" tower " << tower << " sector " << sector << " plane " << iPlane);
+	}
       }
       
+      if (m_getHashFromConstants && constHashValid) {
+	hash = hashfromConstants;
+	ATH_MSG_VERBOSE("Using Pixel hash from constants");
+      } else if (m_getHashFromTrack && trackHashValid) {
+	hash = hashfromTrack;
+	ATH_MSG_VERBOSE("Using Pixel hash from track");
+      } else {
+	ATH_MSG_VERBOSE("No valid Pixel hash, skipping this hit - hashfromTrack " << hashfromTrack << " hash from Constants " << hashfromConstants);
+	continue;
+      }
+
       
       m_h_pix_row[ihist]->Fill((*pTrack)->getPixelClusters()[iPlane].getRowCoord());
       m_h_pix_rowW[ihist]->Fill((*pTrack)->getPixelClusters()[iPlane].getRowWidth());
@@ -896,35 +892,51 @@ void FTK_RDO_MonitorAlgo::fillMaps(const FTK_RawTrackContainer* rawTracks, std::
       
 
       IdentifierHash hash=0xffffffff;
+      IdentifierHash hashfromTrack=0xffffffff;
+      IdentifierHash hashfromConstants=0xffffffff;
 
-      if (m_getHashFromTrack) hash = (*pTrack)->getSCTClusters()[isct].getModuleID();
+      bool trackHashValid=false;
+      bool constHashValid=false;
+
+      if (m_getHashFromTrack) {
+	hashfromTrack = (*pTrack)->getSCTClusters()[isct].getModuleID();
+	if (hashfromTrack < sctMaxHash) {
+	  trackHashValid=true;
+	  ATH_MSG_VERBOSE(" SCT HashID from track 0x" << std::hex << hashfromTrack << std::dec << " for tower " << tower << " sector " << sector << " plane " << iPlane);
+	} else {
+	  ATH_MSG_WARNING(" invalid SCT HashID from track 0x" << std::hex << hashfromTrack << std::dec << " for tower " << tower << " sector " << sector << " plane " << iPlane);
       
+	}
+      }
       if (m_getHashFromConstants) {
-        IdentifierHash hashfromConstants = this->getHash(tower, sector, iPlane);
-	if (hashfromConstants > sctMaxHash) {
-	  if ((*m_moduleFromSector[tower]).size()>0)ATH_MSG_WARNING(" invalid SCT HashID 0x" << std::hex << hash << std::dec << " for tower " << tower << " sector " << sector << " plane " << iPlane);
+        hashfromConstants = m_HashIDTool->getHash(tower, sector, iPlane);
+	if (hashfromConstants < sctMaxHash) {
+	  ATH_MSG_VERBOSE(" SCT HashID from constants 0x" << std::hex << hashfromConstants << std::dec << " for tower " << tower << " sector " << sector << " plane " << iPlane);
+	  constHashValid=true;
 	} else {
+	  ATH_MSG_WARNING(" invalid SCT HashID from constants 0x" << std::hex << hashfromConstants << std::dec << " for tower " << tower << " sector " << sector << " plane " << iPlane);
+	} 
+      }
 	  
-	  if (m_getHashFromTrack) {
-	    if (hashfromConstants != hash) {
-	    
-	      ATH_MSG_WARNING(" SCT HashID missmatch: hash from Track 0x" << std::hex << hash << " hash from Constants 0x" << hashfromConstants << std::dec <<" tower " << tower << " sector " << sector << " plane " << iPlane);
-
-	      unsigned int track_tower, track_sector, track_plane;
-
-	      bool found = this->findHash(hash, true, track_tower, track_sector, track_plane);
-		
-	      if (found) ATH_MSG_WARNING(" track hash found at tower " << track_tower << " sector " << track_sector  << " plane " << track_plane);   
-	      ATH_MSG_WARNING(m_id_helper->print_to_string(m_sctId->wafer_id(hash)));
-	      ATH_MSG_WARNING(m_id_helper->print_to_string(m_sctId->wafer_id(hashfromConstants)));
-
-	    
-	    } else {
-	      ATH_MSG_VERBOSE(" SCT HashID successful match: hash from Track 0x" << std::hex << hash << " hash from Constants 0x" << hashfromConstants << std::dec <<" tower " << tower << " sector " << sector << " plane " << iPlane);
-	    }
-	  }
+      if ( trackHashValid && constHashValid) {
+	if(hashfromTrack != hashfromConstants) {
+	  
+	  ATH_MSG_WARNING(" SCT HashID missmatch: hash from Track 0x" << std::hex << hashfromTrack << " hash from Constants 0x" << hashfromConstants << std::dec <<" tower " << tower << " sector " << sector << " plane " << iPlane);
+	  
+	} else {
+	  ATH_MSG_VERBOSE(" SCT HashID successful match: hash from Track 0x" << std::hex << hashfromTrack << " hash from Constants 0x" << hashfromConstants << std::dec <<" tower " << tower << " sector " << sector << " plane " << iPlane);
 	}
-	if (!m_getHashFromTrack) hash =  hashfromConstants;
+      }
+
+      if (m_getHashFromConstants && constHashValid) {
+	hash = hashfromConstants;
+	ATH_MSG_VERBOSE("Using SCT hash from constants");
+      } else if (m_getHashFromTrack && trackHashValid) {
+	hash = hashfromTrack;
+	ATH_MSG_VERBOSE("Using SCT hash from track");
+      } else {
+	ATH_MSG_VERBOSE("No valid SCT hash, skipping this hit - hashfromTrack " << hashfromTrack << " hash from Constants " << hashfromConstants );
+	continue;
       }
 
       ATH_MSG_VERBOSE(" FTK_RawSCT_Cluster " << isct << " FTK plane 0x" << iPlane << std::hex <<
@@ -1031,18 +1043,17 @@ const std::pair<unsigned int, unsigned int> FTK_RDO_MonitorAlgo::matchTrack(cons
       
       //      ATH_MSG_DEBUG(" getting  locX locY");
       const float locX = (float)measurement->localParameters()[Trk::locX];
-      const float locY = (float)measurement->localParameters()[Trk::locY];
-
-
       
       if (m_id_helper->is_pixel(hitId)) {
-	const std::pair<double, double>  locXlocY(locX,locY);
-	offlinetrackPixLocxLocy.insert({hash,locXlocY});
-	
+
+	const float locY = (float)measurement->localParameters()[Trk::locY];
 
 	if (hash < pixMaxHash) {
+	  const std::pair<double, double>  locXlocY(locX,locY);
+	  offlinetrackPixLocxLocy.insert({hash,locXlocY});
 	  if (pixList[hash]) {
-	    ATH_MSG_VERBOSE(" Pixel module " << hash << " is on the following FTK tracks:");
+	    ATH_MSG_VERBOSE("Pixel Hit on Offline track: hash 0x"<<std::hex<<hash<<": "<<  m_id_helper->print_to_string(m_pixelId->wafer_id(hash))<< std::dec);
+	    ATH_MSG_VERBOSE(" is on the following FTK tracks:");
 	    
 	    for (auto& ipixtr:*pixList[hash]) {
 	      ATH_MSG_VERBOSE(ipixtr);
@@ -1059,7 +1070,8 @@ const std::pair<unsigned int, unsigned int> FTK_RDO_MonitorAlgo::matchTrack(cons
 	
 	if (hash < sctMaxHash) {
 	  if (sctList[hash]) {
-	    ATH_MSG_VERBOSE(" SCT module " << hash << " is on the following FTK tracks:");
+	    ATH_MSG_VERBOSE("SCT Hit on Offline track: hash 0x"<<std::hex<<hash<<": "<<  m_id_helper->print_to_string(m_sctId->wafer_id(hash))<< std::dec);
+	    ATH_MSG_VERBOSE(" is on the following FTK tracks:");
 	    
 	    for (auto& iscttr:*sctList[hash]) {
 	      ATH_MSG_VERBOSE(iscttr);
@@ -1073,16 +1085,6 @@ const std::pair<unsigned int, unsigned int> FTK_RDO_MonitorAlgo::matchTrack(cons
       
     }
   }
-  
-  
-  
-  
-  ATH_MSG_VERBOSE(" Offline Track is matched to the following FTK tracks");
-  
-  for ( auto& i:ftkTrackIndexList) {
-    ATH_MSG_VERBOSE(i);
-  }
-  
 
   if (ftkTrackIndexList.size()==0) return index_freq;
 
@@ -1135,6 +1137,8 @@ void FTK_RDO_MonitorAlgo::compareTracks(const FTK_RawTrack* ftkTrack,
 					) {
 
   unsigned int iPlane = 0;
+  unsigned int pixMaxHash = m_pixelId->wafer_hash_max();
+  unsigned int sctMaxHash = m_sctId->wafer_hash_max();
   
   for( unsigned int i = 0; i < 4; ++i,iPlane++){
     
@@ -1157,6 +1161,9 @@ void FTK_RDO_MonitorAlgo::compareTracks(const FTK_RawTrack* ftkTrack,
     m_h_ftk_pix_etaClusWidth->Fill((double) etaWidth);
   
     const IdentifierHash hash = (ftkTrack)->getPixelClusters()[i].getModuleID();
+
+    if (hash > pixMaxHash) continue;
+
     Identifier wafer_id = m_pixelId->wafer_id(hash); // Need to set up this tool
     unsigned int layer = m_pixelId->layer_disk(wafer_id);
     bool isBarrel = (m_pixelId->barrel_ec(wafer_id)==0);
@@ -1166,10 +1173,6 @@ void FTK_RDO_MonitorAlgo::compareTracks(const FTK_RawTrack* ftkTrack,
     
     const float rawLocalEtaCoord = (ftkTrack)->getPixelClusters()[i].getColCoord();
     
-
-
-    
-
     std::string layername;
     if (isBarrel){
       if (layer==0){
@@ -1244,6 +1247,9 @@ void FTK_RDO_MonitorAlgo::compareTracks(const FTK_RawTrack* ftkTrack,
     
     int strip = (int) stripCoord;
     IdentifierHash scthash = (ftkTrack)->getSCTClusters()[isct].getModuleID();
+
+    if (scthash > sctMaxHash) continue;
+
     unsigned int clusterWidth=(ftkTrack)->getSCTClusters()[isct].getHitWidth();
 
 
@@ -1372,9 +1378,9 @@ void FTK_RDO_MonitorAlgo::compareTracks(const Trk::Track* ftkTrack,
       
       //      ATH_MSG_DEBUG(" getting  locX locY");
       const float locX = (float)measurement->localParameters()[Trk::locX];
-      const float locY = (float)measurement->localParameters()[Trk::locY];
 
       if (m_id_helper->is_pixel(hitId)) {
+	const float locY = (float)measurement->localParameters()[Trk::locY];
 
 	Identifier wafer_id = m_pixelId->wafer_id(hash); 
 	unsigned int layer = m_pixelId->layer_disk(wafer_id);
@@ -1456,7 +1462,6 @@ void FTK_RDO_MonitorAlgo::compareTracks(const Trk::Track* ftkTrack,
 
 const std::pair<double,double> FTK_RDO_MonitorAlgo::getPixLocXlocY(const IdentifierHash hash, const float rawLocalPhiCoord, const float rawLocalEtaCoord) {
 	
-  
   const InDetDD::SiDetectorElement* pixelDetectorElement = m_pixelManager->getDetectorElement(hash);
   const InDetDD::PixelModuleDesign* design = dynamic_cast<const InDetDD::PixelModuleDesign*>(&pixelDetectorElement->design());
   
@@ -1559,137 +1564,3 @@ double FTK_RDO_MonitorAlgo::getSctLocX(const InDetDD::SiDetectorElement* pDE, co
 
   return xloc;
 }
-  
-
-bool FTK_RDO_MonitorAlgo::findHash(unsigned int hash, bool isSCT, unsigned int& tower, unsigned int& sector, unsigned int& plane) {
-  int i = (int) hash;
-  sector=tower=plane=0xffffffff;
-  bool found=false;
-
-  //  for (unsigned int itower = 0; itower < m_moduleFromSector.size(); itower++) {
-  sectormap* map = m_moduleFromSector[tower];
-  if (map) {   
-    //      for ( unsigned int isector=0; isector < map->size();isector++) {
-    if ((*map)[sector].size() > 0) {
-      auto first= (*map)[sector].begin();
-      if (isSCT) first+=4;
-      auto last = (*map)[sector].end();
-      if (!isSCT) last -=8;
-
-      auto p = std::find(first, last, i);
-      if ( p!= last ) {
-	plane = std::distance(first, p);
-
-      }
-    }
-  }
-
-  return found;
-}
-	
-unsigned int FTK_RDO_MonitorAlgo::getHash(unsigned int tower, unsigned int sector,  unsigned int plane) {
-  unsigned int hash =  0xffffffff;
-  if (plane >= 12) {
-    ATH_MSG_ERROR("getHash: Invalid plane " << plane);
-    return hash;
-  }
-  if (m_moduleFromSector[tower]==nullptr) return hash;
-  if ((*m_moduleFromSector[tower]).size() <= sector) return hash;
-  if (plane >=(*m_moduleFromSector[tower])[sector].size()) return hash;
-  return (unsigned int)(*m_moduleFromSector[tower])[sector][plane];
-}
-
-
-int FTK_RDO_MonitorAlgo::readModuleIds(unsigned int itower, sectormap& hashID) {
-   int nSector8L,nPlane8L;
-   // define which 8L plane goes to which 12L plane
-   vector<int> const remapPlanes={1,2,3, 4,6,8,9,10, 0,5,7,11};
-   enum {
-      ERROR_PATTFILE=1,
-      ERROR_CONNFILE=2
-   };
-
-
-   std::stringstream ssPat, ssCon;
-   ssPat << m_ConstantsDir<<"/FitConstants/"<<m_PatternsVersion<<"/sectors_raw_8L_reg"<<itower<<".patt.bz2";
-   
-   std::string pattfilename=ssPat.str();
-   ATH_MSG_DEBUG("Sectors file: "<<pattfilename);
-   const char * cpattfilename = pattfilename.c_str();
-   ftk_dcap::istream *patt_8L=ftk_dcap::open_for_read(cpattfilename);
-   if(!patt_8L) {
-     ATH_MSG_WARNING("readSectorDefinition failed to open file "<<cpattfilename
-		     <<" for reading, skipping");
-     return ERROR_PATTFILE;
-   }
-   ssCon << m_ConstantsDir<<"/FitConstants/"<<m_PatternsVersion<<"/sectors_raw_8L_reg"<<itower<<".conn";
-   std::string connfilename=ssCon.str();
-   ATH_MSG_DEBUG("Connections file: "<<connfilename);
-   const char * charconnfilename = connfilename.c_str();
-   ifstream conn(charconnfilename);
-   if (!conn) {
-     ATH_MSG_WARNING("readSectorDefinition failed to open file "<<charconnfilename
-		     <<" for reading, skipping");
-
-     delete(patt_8L);
-     return ERROR_CONNFILE;
-   }
-
-   (*patt_8L)>>nSector8L>>nPlane8L;
-   // check errors here
-   //   (*patt_8L).fail(), nSector8L>0, 0<nPlane8L<remapPlanes.size()
-   int lastSector8=-1;
-   int lastSector12=-1;
-   int error=0;
-   while(!((*patt_8L).eof()||conn.eof())) {
-      int iSectorPatt,iSectorConn;
-      (*patt_8L)>>iSectorPatt;
-      conn>>iSectorConn;
-      if((*patt_8L).fail()||conn.fail()) {
-         // end
-         break;
-      }
-      if((iSectorPatt!=lastSector8+1)||
-         (iSectorPatt!=iSectorConn)||
-         (iSectorPatt<0)||(iSectorPatt>=nSector8L)) {
-         error=ERROR_PATTFILE;
-         // file is corrupted
-         break;
-      }
-      vector<int> moduleData(remapPlanes.size());
-      // read 8L module IDs
-      for(int k=0;k<nPlane8L;k++) {
-         (*patt_8L)>>moduleData[remapPlanes[k]];
-      }
-      int dummy;
-      // skip dummy entries
-      (*patt_8L)>>dummy;
-      (*patt_8L)>>dummy;
-      // read connection data and store 12L module data
-
-      int n12;
-      conn>>n12;
-      for(int i=0;i<n12;i++) {
-         int sector12;
-         conn>>dummy>>sector12;
-         if(lastSector12+1!=sector12) {
-            error=ERROR_CONNFILE;
-            break;
-         }
-         for(unsigned int k=nPlane8L;k<remapPlanes.size();k++) {
-            conn>>moduleData[remapPlanes[k]];
-         }
-         hashID.push_back(moduleData);
-         lastSector12=sector12;
-      }
-      if(error) break;
-
-      lastSector8=iSectorPatt;
-   }
-
-     
-
-   delete(patt_8L);
-
-   return error;
-}
diff --git a/Trigger/TrigFTK/TrigFTK_RawDataAlgs/src/FTK_RDO_MonitorAlgo.h b/Trigger/TrigFTK/TrigFTK_RawDataAlgs/src/FTK_RDO_MonitorAlgo.h
index 42df00c2103..1f92ae841d0 100644
--- a/Trigger/TrigFTK/TrigFTK_RawDataAlgs/src/FTK_RDO_MonitorAlgo.h
+++ b/Trigger/TrigFTK/TrigFTK_RawDataAlgs/src/FTK_RDO_MonitorAlgo.h
@@ -12,6 +12,7 @@
 
 #include "TrkTrack/TrackCollection.h" //
 #include "InDetPrepRawData/SiClusterContainer.h"
+
 #include "InDetCondServices/ISiLorentzAngleTool.h"
 
 #include "FTK_DataProviderInterfaces/IFTK_DataProviderSvc.h"
@@ -22,6 +23,8 @@
 #include "InDetReadoutGeometry/SiDetectorElementCollection.h"
 #include "StoreGate/ReadCondHandleKey.h"
 
+#include "FTK_RecToolInterfaces/IFTK_HashIDTool.h"
+
 #include <vector>
 #include <string>
 #include <map>
@@ -75,15 +78,6 @@ public:
 		     std::map<unsigned int,std::pair<double,double>>& offlinetrackPixLocxLocy,
 		     std::map<unsigned int,double>& offlinetrackSctLocx, bool refitTrack);
   
-  typedef std::vector<std::vector<int>> sectormap;
-
-  int readModuleIds(unsigned int itower, sectormap& hashID);
-    
-  unsigned int getHash(unsigned int tower, unsigned int sector,  unsigned int plane);
-
-  
-  bool findHash(unsigned int hash, bool isSCT, unsigned int& tower, unsigned int& sector, unsigned int& plane);
-
   /// Tools and services ///
   ITHistSvc*    m_rootHistSvc;
 
@@ -94,7 +88,6 @@ public:
   std::string m_ftk_raw_trackcollection_Name;
   std::string m_offlineTracksName;
 
-
   ServiceHandle<IFTK_DataProviderSvc> m_DataProviderSvc;
 
   const PixelID* m_pixelId;
@@ -174,20 +167,15 @@ public:
   unsigned int m_minMatches;
   bool m_reverseIBLlocx;
 
-  size_t m_max_tower;
-
-  std::vector<sectormap*> m_moduleFromSector;
-
-  std::string m_ConstantsDir;
-  std::string m_PatternsVersion;
   unsigned int m_Nlayers;
   bool m_getHashFromTrack;
   bool m_getHashFromConstants;
-  uint32_t m_towerID;
   bool m_getRawTracks;
   bool m_getTracks;
   bool m_getRefitTracks;
 
+  ToolHandle<IFTK_HashIDTool> m_HashIDTool;
+
 };
 
 #endif // FTK_RDO_MonitorAlgo_h
diff --git a/Trigger/TrigFTK/TrigFTK_RawDataTPCnv/src/FTK_RawTrackCnv_p1.cxx b/Trigger/TrigFTK/TrigFTK_RawDataTPCnv/src/FTK_RawTrackCnv_p1.cxx
index 365dc27b4f9..14f30172d1d 100644
--- a/Trigger/TrigFTK/TrigFTK_RawDataTPCnv/src/FTK_RawTrackCnv_p1.cxx
+++ b/Trigger/TrigFTK/TrigFTK_RawDataTPCnv/src/FTK_RawTrackCnv_p1.cxx
@@ -29,10 +29,6 @@ void FTK_RawTrackCnv_p1::persToTrans(const FTK_RawTrack_p1* persObj,
   }
   transObj->setPixelClusters(pix_clusters);
 
-
-  // SCT Clusters //
-  //FTK_RawSCT_Cluster sct_1(), sct_2(), sct_3(), sct_4(), sct_5(), sct_6(), sct_7(), sct_8;
- 
   std::vector<FTK_RawSCT_Cluster> sct_clusters;
 
   for (unsigned int isct=0; isct<8; isct++) {
diff --git a/Trigger/TrigFTK/TrigFTK_RecAlgs/TrigFTK_RecAlgs/TrigFTK_VxPrimary.h b/Trigger/TrigFTK/TrigFTK_RecAlgs/TrigFTK_RecAlgs/TrigFTK_VxPrimary.h
index cfd3cddc3c0..50d4324cad4 100755
--- a/Trigger/TrigFTK/TrigFTK_RecAlgs/TrigFTK_RecAlgs/TrigFTK_VxPrimary.h
+++ b/Trigger/TrigFTK/TrigFTK_RecAlgs/TrigFTK_RecAlgs/TrigFTK_VxPrimary.h
@@ -53,7 +53,6 @@ class TrigFTK_VxPrimary : public HLT::FexAlgo
 
     bool m_useRawTracks;
     bool m_useRefittedTracks;
-    bool m_getVertexContainer;
     ftk::FTK_TrackType m_trackType;
     std::string m_vertexContainerName;
     std::string m_vxContainerName;
diff --git a/Trigger/TrigFTK/TrigFTK_RecAlgs/TrigFTK_RecAlgs/TrigFTK_VxPrimaryAllTE.h b/Trigger/TrigFTK/TrigFTK_RecAlgs/TrigFTK_RecAlgs/TrigFTK_VxPrimaryAllTE.h
index 8a835d38783..f7732863b0b 100755
--- a/Trigger/TrigFTK/TrigFTK_RecAlgs/TrigFTK_RecAlgs/TrigFTK_VxPrimaryAllTE.h
+++ b/Trigger/TrigFTK/TrigFTK_RecAlgs/TrigFTK_RecAlgs/TrigFTK_VxPrimaryAllTE.h
@@ -41,7 +41,6 @@
     ServiceHandle<IFTK_DataProviderSvc> m_DataProviderSvc;
     bool m_useRawTracks;
     bool m_useRefittedTracks;
-    bool m_getVertexContainer;
     ftk::FTK_TrackType m_trackType;
     std::string m_vertexContainerName;
     std::string m_vxContainerName;
diff --git a/Trigger/TrigFTK/TrigFTK_RecAlgs/src/TrigFTK_VxPrimary.cxx b/Trigger/TrigFTK/TrigFTK_RecAlgs/src/TrigFTK_VxPrimary.cxx
index 2baa1e6d06d..6e7ad18f80b 100755
--- a/Trigger/TrigFTK/TrigFTK_RecAlgs/src/TrigFTK_VxPrimary.cxx
+++ b/Trigger/TrigFTK/TrigFTK_RecAlgs/src/TrigFTK_VxPrimary.cxx
@@ -37,7 +37,6 @@ TrigFTK_VxPrimary::TrigFTK_VxPrimary(const std::string &n, ISvcLocator *pSvcLoc)
     m_DataProviderSvc("TrigFTK_DataProviderSvc",n),
     m_useRawTracks(false),
     m_useRefittedTracks(false),
-    m_getVertexContainer(true),
     m_trackType(ftk::ConvertedTrack),
     m_vertexContainerName("PrimVertexFTK"),
     m_vxContainerName("PrimVxFTK"),
@@ -45,7 +44,6 @@ TrigFTK_VxPrimary::TrigFTK_VxPrimary(const std::string &n, ISvcLocator *pSvcLoc)
 {
   declareProperty("useRawTracks", m_useRawTracks);
   declareProperty("useRefittedTracks", m_useRefittedTracks);
-  declareProperty("getVertexContainer", m_getVertexContainer);
   declareProperty("FTK_DataProvider", m_DataProviderSvc);
   declareProperty("vertexContainerName", m_vertexContainerName);
   declareProperty("vxContainerName", m_vxContainerName);
diff --git a/Trigger/TrigFTK/TrigFTK_RecAlgs/src/TrigFTK_VxPrimaryAllTE.cxx b/Trigger/TrigFTK/TrigFTK_RecAlgs/src/TrigFTK_VxPrimaryAllTE.cxx
index feab9c8bb2d..6d298c803b2 100755
--- a/Trigger/TrigFTK/TrigFTK_RecAlgs/src/TrigFTK_VxPrimaryAllTE.cxx
+++ b/Trigger/TrigFTK/TrigFTK_RecAlgs/src/TrigFTK_VxPrimaryAllTE.cxx
@@ -27,7 +27,6 @@ TrigFTK_VxPrimaryAllTE::TrigFTK_VxPrimaryAllTE(const std::string &n, ISvcLocator
     m_DataProviderSvc("TrigFTK_DataProviderSvc",n),
     m_useRawTracks(false),
     m_useRefittedTracks(false),
-    m_getVertexContainer(false),
     m_trackType(ftk::ConvertedTrack),
     m_vertexContainerName("FTK_PrimVertex"),
     m_vxContainerName("FTK_PrimVx"),
@@ -36,7 +35,6 @@ TrigFTK_VxPrimaryAllTE::TrigFTK_VxPrimaryAllTE(const std::string &n, ISvcLocator
 {
   declareProperty("useRawTracks", m_useRawTracks);
   declareProperty("useRefittedTracks", m_useRefittedTracks);
-  declareProperty("getVertexContainer", m_getVertexContainer);
   declareProperty("useFastVertexTool", m_useFastVertexTool);
   declareProperty("FTK_DataProvider", m_DataProviderSvc);
   
diff --git a/Trigger/TrigFTK/TrigFTK_RecExample/python/TrigFTK_DataProviderSvc_Config.py b/Trigger/TrigFTK/TrigFTK_RecExample/python/TrigFTK_DataProviderSvc_Config.py
index fae4c1c817e..72844fc15cf 100644
--- a/Trigger/TrigFTK/TrigFTK_RecExample/python/TrigFTK_DataProviderSvc_Config.py
+++ b/Trigger/TrigFTK/TrigFTK_RecExample/python/TrigFTK_DataProviderSvc_Config.py
@@ -9,9 +9,8 @@ class TrigFTK_DataProviderSvc(FTK_DataProviderSvc) :
         print "In FTK_DataProviderSvc_Config.py"  
         FTK_DataProviderSvc.__init__(self, name) 
 
-        from TrigInDetConf.TrigInDetRecToolsFTK import InDetTrigTrackFitterFTK, InDetTrigRotCreatorFTK, TrigFTK_VertexCollectionSortingTool, \
-        TrigFTK_UncertaintyTool,TrigFTK_RawVertexFinderTool,InDetTrigTrackParticleCreatorToolFTK,InDetTrigTrackSummaryToolFTK
-        from InDetTrigRecExample.InDetTrigConfigRecLoadToolsPost import InDetTrigPriVxFinderTool
+        from TrigInDetConf.TrigInDetRecToolsFTK import InDetTrigTrackFitterFTK, InDetTrigRotCreatorFTK,  \
+        TrigFTK_UncertaintyTool,TrigFTK_RawVertexFinderTool,InDetTrigTrackParticleCreatorToolFTK,InDetTrigTrackSummaryToolFTK,TrigFTK_HashIDTool
         
         self.TrackCollectionName= "FTK_TrackCollection"
         self.TrackParticleContainerName= "FTK_TrackParticleContainer"
@@ -24,16 +23,24 @@ class TrigFTK_DataProviderSvc(FTK_DataProviderSvc) :
         self.CorrectPixelClusters=True
         self.CorrectSCTClusters=True
         
-        
         self.TrackFitter = InDetTrigTrackFitterFTK
         self.UncertaintyTool=TrigFTK_UncertaintyTool
         self.TrackSummaryTool=InDetTrigTrackSummaryToolFTK
         self.TrackParticleCreatorTool=InDetTrigTrackParticleCreatorToolFTK
         self.RawVertexFinderTool=TrigFTK_RawVertexFinderTool
-        self.VertexFinderTool=InDetTrigPriVxFinderTool
-        self.VertexCollectionSortingTool=TrigFTK_VertexCollectionSortingTool
-        self.ROTcreatorTool= InDetTrigRotCreatorFTK 
+        self.ROTcreatorTool= InDetTrigRotCreatorFTK
+        self.HashIDTool=TrigFTK_HashIDTool
+
+        from AthenaCommon.BeamFlags import jobproperties
 
+        if (jobproperties.Beam.beamType() != 'cosmics'):
+            from InDetTrigRecExample.InDetTrigConfigRecLoadToolsPost import InDetTrigPriVxFinderTool
+            from TrigInDetConf.TrigInDetRecToolsFTK import TrigFTK_VertexCollectionSortingTool
+            self.DoVertexing=True
+            self.VertexFinderTool=InDetTrigPriVxFinderTool
+            self.VertexCollectionSortingTool=TrigFTK_VertexCollectionSortingTool
+        else:
+            self.DoVertexing=False
         from RecExConfig.RecFlags import rec
         self.doTruth= rec.doTruth()
 
diff --git a/Trigger/TrigHypothesis/TrigFTKHypo/src/TrigFTKAvailableHypo.cxx b/Trigger/TrigHypothesis/TrigFTKHypo/src/TrigFTKAvailableHypo.cxx
index 1152eb3a47a..1ba2cb6f658 100644
--- a/Trigger/TrigHypothesis/TrigFTKHypo/src/TrigFTKAvailableHypo.cxx
+++ b/Trigger/TrigHypothesis/TrigFTKHypo/src/TrigFTKAvailableHypo.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 1995-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "TrigFTKAvailableHypo.h"
diff --git a/Trigger/TrigHypothesis/TrigFTKHypo/src/TrigFTKAvailableHypo.h b/Trigger/TrigHypothesis/TrigFTKHypo/src/TrigFTKAvailableHypo.h
index e0f75798fda..f71dd12cbf2 100644
--- a/Trigger/TrigHypothesis/TrigFTKHypo/src/TrigFTKAvailableHypo.h
+++ b/Trigger/TrigHypothesis/TrigFTKHypo/src/TrigFTKAvailableHypo.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 1995-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
 */
 
 /** @class TrigFTKAvailableHypo                                                                                                            
diff --git a/Trigger/TrigTools/TrigInDetConf/python/TrigInDetFTKSequence.py b/Trigger/TrigTools/TrigInDetConf/python/TrigInDetFTKSequence.py
index 9ed98975c31..8fad32587ff 100644
--- a/Trigger/TrigTools/TrigInDetConf/python/TrigInDetFTKSequence.py
+++ b/Trigger/TrigTools/TrigInDetConf/python/TrigInDetFTKSequence.py
@@ -14,7 +14,6 @@ class TrigInDetFTKSequence(TrigInDetSequence):
   def __init__(self,
                signatureName="Electron",
                signature="electron", 
-               #sequenceType="",
                sequenceFlavour=[""]):
 
     TrigInDetSequenceBase.__init__(self)
@@ -24,8 +23,11 @@ class TrigInDetFTKSequence(TrigInDetSequence):
     self.__sequenceFlavour__  = sequenceFlavour
     self.__step__ = [signature]
 
+    if type(sequenceFlavour)!=type(list()):
+      log.error("TrigInDetFTKSequence invoked with a non-list sequenceFlavour argument %s" )
+      
 
-    if self.__sequenceFlavour__ =="2step":
+    if "2step" in self.__sequenceFlavour__:
       if self.__signature__ == "tau":
         self.__step__ = ["tauCore","tauIso","tau"]; 
       elif self.__signature__ == "muon":
@@ -47,6 +49,9 @@ class TrigInDetFTKSequence(TrigInDetSequence):
     suffix = "FTK"
     if "refit" in sequenceFlavour:
         suffix = "FTKRefit"
+    if "mon" in sequenceFlavour:
+        suffix = "FTKMon"
+
 
     ftfname = ""
     roiupdater = ""
@@ -54,29 +59,24 @@ class TrigInDetFTKSequence(TrigInDetSequence):
     ftfname = "TrigFastTrackFinder_"+suffix;
     cnvname = "InDetTrigTrackingxAODCnv_%s_"+suffix;
 
-      
-
-    algos = list()
+    #start filling sequences
 
+    algos = [("IDTrigRoiUpdater", roiupdater)]
+    algos += [("FTK_TrackMaker", "")]
+    algos += [("TrigFTKAvailable", "")]
 
-    #the first step can be FTK only vertexing
     if "FTKVtx" in sequenceFlavour:
       algos += [("TrigFTK_VxPrimary","")]
-
       fullseq.append(algos)
+      algos = list()
 
 
-    #always run FTF
-    algos = [("IDTrigRoiUpdater", roiupdater)]
-    algos += [("FTK_TrackMaker", "")]
-    algos += [("TrigFTKAvailable", "")]
     algos += [("TrigFastTrackFinder",ftfname),
               ("InDetTrigTrackingxAODCnv",cnvname),
               ]
     fullseq.append(algos)
 
 
-
     if "PT" in sequenceFlavour:
       algos = list()
 
diff --git a/Trigger/TrigTools/TrigInDetConf/python/TrigInDetRecToolsFTK.py b/Trigger/TrigTools/TrigInDetConf/python/TrigInDetRecToolsFTK.py
index 448bbcc7313..c62802a90a8 100644
--- a/Trigger/TrigTools/TrigInDetConf/python/TrigInDetRecToolsFTK.py
+++ b/Trigger/TrigTools/TrigInDetConf/python/TrigInDetRecToolsFTK.py
@@ -180,3 +180,8 @@ TrigFTK_VertexCollectionSortingTool = Trk__VertexCollectionSortingTool(name
 ToolSvc += TrigFTK_VertexCollectionSortingTool
 if (InDetTrigFlags.doPrintConfigurables()):
   print TrigFTK_VertexCollectionSortingTool
+
+from FTK_RecTools.FTK_RecToolsConf import FTK_HashIDTool
+TrigFTK_HashIDTool = FTK_HashIDTool("TrigFTK_HashIDTool")
+ToolSvc+=TrigFTK_HashIDTool
+
-- 
GitLab