diff --git a/Tracking/Acts/FaserActsKalmanFilter/CMakeLists.txt b/Tracking/Acts/FaserActsKalmanFilter/CMakeLists.txt
index f6bea2a7f8c27efb76bfd56ff939e43cd08c4b70..f2bb899d9df6a29e6c567523a8239cf9836c8735 100755
--- a/Tracking/Acts/FaserActsKalmanFilter/CMakeLists.txt
+++ b/Tracking/Acts/FaserActsKalmanFilter/CMakeLists.txt
@@ -55,6 +55,7 @@ atlas_add_component(FaserActsKalmanFilter
     PerformanceWriterTool.h
     PlotHelpers.h
     ResPlotTool.h
+    RootSeedWriteTool.h
     RootTrajectoryStatesWriterTool.h
     RootTrajectorySummaryWriterTool.h
     SeedingAlg.h
@@ -95,6 +96,7 @@ atlas_add_component(FaserActsKalmanFilter
     src/PlotHelpers.cxx
 #todo    src/ResPlotTool.cxx
     src/SeedingAlg.cxx
+    src/RootSeedWriteTool.cxx
     src/RootTrajectoryStatesWriterTool.cxx
     src/RootTrajectorySummaryWriterTool.cxx
 #    src/SegmentFitClusterTrackFinderTool.cxx
diff --git a/Tracking/Acts/FaserActsKalmanFilter/python/CKF2Alignment.py b/Tracking/Acts/FaserActsKalmanFilter/python/CKF2Alignment.py
index c36e0f9af097528f1a5c67d30c718e49941e40d1..2246218726c88de49d87d958af14afbffd7e971b 100644
--- a/Tracking/Acts/FaserActsKalmanFilter/python/CKF2Alignment.py
+++ b/Tracking/Acts/FaserActsKalmanFilter/python/CKF2Alignment.py
@@ -52,7 +52,7 @@ def CKF2AlignmentCfg(flags, **kwargs):
     track_seed_tool.covQOverP = initial_variance_inflation[4] * sigma_qop * sigma_qop
     track_seed_tool.std_cluster = 0.0231
     track_seed_tool.TrackCollection = "Segments"
-    # useless in the alignment, will clean them up
+    
     trajectory_states_writer_tool = CompFactory.RootTrajectoryStatesWriterTool()
     trajectory_states_writer_tool.noDiagnostics = kwargs.pop("noDiagnostics", True)
     trajectory_states_writer_tool1 = CompFactory.RootTrajectoryStatesWriterTool()
diff --git a/Tracking/Acts/FaserActsKalmanFilter/python/CKF2Config.py b/Tracking/Acts/FaserActsKalmanFilter/python/CKF2Config.py
index 8b64aa57d8d7927c84b31ffae8c224b9b868a3a7..8249b2b34ddf2fdacefd383a088c19a5ded5cba5 100644
--- a/Tracking/Acts/FaserActsKalmanFilter/python/CKF2Config.py
+++ b/Tracking/Acts/FaserActsKalmanFilter/python/CKF2Config.py
@@ -58,7 +58,13 @@ def CKF2Cfg(flags, actsOutputTag, **kwargs):
     track_seed_tool.covQOverP = initial_variance_inflation[4] * sigma_qop * sigma_qop
     track_seed_tool.std_cluster = 0.0231
     track_seed_tool.TrackCollection = "Segments"
+    
+    
+    seed_writer_tool = CompFactory.RootSeedWriterTool()
+    seed_writer_tool.noDiagnostics = kwargs.get("noDiagnostics", True)
+    seed_writer_tool.FilePath = f"{actsOutputTag}_seed_summary_circleFitTrackSeedTool.root"
 
+    
     trajectory_states_writer_tool = CompFactory.RootTrajectoryStatesWriterTool()
     trajectory_states_writer_tool.noDiagnostics = kwargs.get("noDiagnostics", True)
     trajectory_states_writer_tool.FilePath = f"{actsOutputTag}_track_states_ckf.root"
@@ -100,6 +106,7 @@ def CKF2Cfg(flags, actsOutputTag, **kwargs):
 
     ckf.TrackSeed = track_seed_tool
     ckf.ActsLogging = "INFO"
+    ckf.RootSeedWriterTool = seed_writer_tool
     ckf.RootTrajectoryStatesWriterTool = trajectory_states_writer_tool
     ckf.RootTrajectorySummaryWriterTool = trajectory_summary_writer_tool
     #@todo    
@@ -107,6 +114,7 @@ def CKF2Cfg(flags, actsOutputTag, **kwargs):
     ckf.TrackingGeometryTool=actsTrackingGeometryTool
     ckf.isMC = flags.Input.isMC
     ckf.noDiagnostics = kwargs.get("noDiagnostics", True)
+    ckf.seedWriter = kwargs.get("seedWriter",False)
     ckf.SummaryWriter = kwargs.get("SummaryWriter", False)
     ckf.StatesWriter = kwargs.get("StatesWriter", False)
     ckf.PerformanceWriter = False
diff --git a/Tracking/Acts/FaserActsKalmanFilter/python/CombinatorialKalmanFilterConfig.py b/Tracking/Acts/FaserActsKalmanFilter/python/CombinatorialKalmanFilterConfig.py
index fac9e7ec1713f9e387da5746ea5c9fd98519202e..004a44127375ec42c395bf8a64a1c72421ca875e 100644
--- a/Tracking/Acts/FaserActsKalmanFilter/python/CombinatorialKalmanFilterConfig.py
+++ b/Tracking/Acts/FaserActsKalmanFilter/python/CombinatorialKalmanFilterConfig.py
@@ -54,6 +54,7 @@ def CombinatorialKalmanFilterCfg(flags, **kwargs):
     track_seed_tool.std_cluster = 0.023
     track_seed_tool.origin = 0
 
+
     trajectory_states_writer_tool = CompFactory.RootTrajectoryStatesWriterTool()
     trajectory_states_writer_tool.noDiagnostics = kwargs["noDiagnostics"]
     trajectory_states_writer_tool.MC = True
diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/CKF2.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/CKF2.cxx
index 09b1c377dfb0cadf6c30cb5ae2b7370a3466071f..5269b2f512074d2f7f55b12e3c5769fe2de751e2 100644
--- a/Tracking/Acts/FaserActsKalmanFilter/src/CKF2.cxx
+++ b/Tracking/Acts/FaserActsKalmanFilter/src/CKF2.cxx
@@ -33,6 +33,7 @@
 #include "Acts/Propagator/PropagatorError.hpp"
 #include "Acts/TrackFinding/CombinatorialKalmanFilterError.hpp"
 #include "Acts/EventData/ProxyAccessor.hpp"
+#include "CircleFitTrackSeedTool.h"
 
 size_t CKF2::TrackInfo::nClusters {0};
 
@@ -54,6 +55,10 @@ StatusCode CKF2::initialize() {
 //todo  if (m_performanceWriter && !m_noDiagnostics) {
 //todo    ATH_CHECK(m_performanceWriterTool.retrieve());
 //todo  }
+  
+  if (m_statesWriter && !m_noDiagnostics) {
+    ATH_CHECK(m_seedWriterTool.retrieve());
+  }
   if (m_statesWriter && !m_noDiagnostics) {
     ATH_CHECK(m_trajectoryStatesWriterTool.retrieve());
   }
@@ -115,7 +120,7 @@ StatusCode CKF2::execute() {
   std::shared_ptr<std::vector<IndexSourceLink>> sourceLinks =
       m_trackSeedTool->sourceLinks();
   double targetZposition = m_trackSeedTool->targetZPosition();
- 
+  
   std::shared_ptr<std::vector<Measurement>> measurements = m_trackSeedTool->measurements();
   std::shared_ptr<std::vector<const Tracker::FaserSCT_Cluster*>> clusters = m_trackSeedTool->clusters();
   std::shared_ptr<std::vector<const Tracker::FaserSCT_SpacePoint*>> spacePoints = m_trackSeedTool->spacePoints();
@@ -123,6 +128,22 @@ StatusCode CKF2::execute() {
 
   TrackInfo::nClusters = sourceLinks->size();
 
+
+  CircleFitTrackSeedTool* Tool = dynamic_cast<CircleFitTrackSeedTool*>(m_trackSeedTool.get());
+  if(Tool){
+    std::shared_ptr<std::vector<CircleFitTrackSeedTool::Seed>> selectedseeds = Tool->seeds();
+    double seedTargetZPosition = Tool->targetZPosition();
+    Acts::BoundSquareMatrix seedCov = Tool->covBound();
+
+    if (m_seedWriter && !m_noDiagnostics) {
+      ATH_CHECK(m_seedWriterTool->write(gctx, seedTargetZPosition, seedCov, *selectedseeds, m_isMC));
+    }
+  }
+  else{
+    ATH_MSG_ERROR("Failed to cast to CircleFitTrackSeedTool");
+  }
+  
+
   // construct the container 
   auto allTrackContainer = std::make_shared<Acts::VectorTrackContainer>();
   auto allTrackStateContainer = std::make_shared<Acts::VectorMultiTrajectory>();
diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/CKF2.h b/Tracking/Acts/FaserActsKalmanFilter/src/CKF2.h
index 121770f7fb1c994ae4a3902ec7ec952335230608..61dfb97781e9a2f6fd0e513a0467ff4c44a7cfab 100644
--- a/Tracking/Acts/FaserActsKalmanFilter/src/CKF2.h
+++ b/Tracking/Acts/FaserActsKalmanFilter/src/CKF2.h
@@ -15,6 +15,7 @@
 #include "TrajectoryWriterTool.h"
 #include "TrkTrack/TrackCollection.h"
 #include "FaserActsKalmanFilter/ITrackSeedTool.h"
+#include "RootSeedWriteTool.h"
 #include "RootTrajectoryStatesWriterTool.h"
 #include "RootTrajectorySummaryWriterTool.h"
 #include "PerformanceWriterTool.h"
@@ -93,6 +94,7 @@ private:
   Gaudi::Property<bool> m_summaryWriter {this, "SummaryWriter", true};
   Gaudi::Property<bool> m_noDiagnostics {this, "noDiagnostics", true, "Set ACTS logging level to INFO and do not run performance writer, states writer or summary writer"};
   Gaudi::Property<bool> m_statesWriter {this, "StatesWriter", false};
+  Gaudi::Property<bool> m_seedWriter {this, "seedWriter", true};
   Gaudi::Property<bool> m_resolvePassive {this, "resolvePassive", false};
   Gaudi::Property<bool> m_resolveMaterial {this, "resolveMaterial", true};
   Gaudi::Property<bool> m_resolveSensitive {this, "resolveSensitive", true};
@@ -107,6 +109,7 @@ private:
 //todo  ToolHandle<PerformanceWriterTool> m_performanceWriterTool {this, "PerformanceWriterTool", "PerformanceWriterTool"};
   ToolHandle<RootTrajectoryStatesWriterTool> m_trajectoryStatesWriterTool {this, "RootTrajectoryStatesWriterTool", "RootTrajectoryStatesWriterTool"};
   ToolHandle<RootTrajectorySummaryWriterTool> m_trajectorySummaryWriterTool {this, "RootTrajectorySummaryWriterTool", "RootTrajectorySummaryWriterTool"};
+  ToolHandle<RootSeedWriterTool> m_seedWriterTool {this, "RootSeedWriterTool", "RootSeedWriterTool"};
   ToolHandle<KalmanFitterTool> m_kalmanFitterTool1 {this, "KalmanFitterTool1", "KalmanFitterTool"};
   ToolHandle<CreateTrkTrackTool> m_createTrkTrackTool {this, "CreateTrkTrackTool", "CreateTrkTrackTool"};
   Gaudi::Property<bool> m_isMC {this, "isMC", false};
diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/CircleFitTrackSeedTool.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/CircleFitTrackSeedTool.cxx
index 30b96fa57d5186dae48ee35936bdf09ade758e83..3ef87ed5ad559b9f107ddbf8cf8e31060318d436 100644
--- a/Tracking/Acts/FaserActsKalmanFilter/src/CircleFitTrackSeedTool.cxx
+++ b/Tracking/Acts/FaserActsKalmanFilter/src/CircleFitTrackSeedTool.cxx
@@ -166,6 +166,8 @@ StatusCode CircleFitTrackSeedTool::run(std::vector<int> maskedLayers, bool backw
   cov(Acts::eBoundQOverP, Acts::eBoundQOverP) = m_covQOverP;
   cov(Acts::eBoundTime, Acts::eBoundTime) = m_covTime;
 
+  m_cov = cov;
+
   double origin;
   if (!backward) {
     auto minSeed = std::min_element(
@@ -183,7 +185,7 @@ StatusCode CircleFitTrackSeedTool::run(std::vector<int> maskedLayers, bool backw
     ATH_MSG_DEBUG("seed size: " << seed.size << ", chi2: " << seed.chi2);
     initParams.push_back(seed.get_params(origin, cov, backward));
   }
-
+  m_seeds = std::make_shared<std::vector<Seed>>(selectedSeeds);
   m_initialTrackParameters = std::make_shared<std::vector<Acts::BoundTrackParameters>>(initParams);
   m_sourceLinks = std::make_shared<std::vector<IndexSourceLink>>(sourceLinks);
   // m_idLinks = std::make_shared<IdentifierLink>(identifierLinkMap);
@@ -227,6 +229,8 @@ CircleFitTrackSeedTool::Segment::Segment(const Trk::Track* track, const FaserSCT
   for (const Trk::TrackStateOnSurface* trackState : *(track->trackStateOnSurfaces())) {
     auto clusterOnTrack = dynamic_cast<const Tracker::FaserSCT_ClusterOnTrack*> (trackState->measurementOnTrack());
     if (clusterOnTrack) {
+      //get measurements of per segment****
+      Measurements.push_back(trackState->measurementOnTrack());
       const Tracker::FaserSCT_Cluster* cluster = clusterOnTrack->prepRawData();
       Identifier id = cluster->identify();
       if (std::find(maskedLayers.begin(), maskedLayers.end(), 3 * idHelper->station(id) + idHelper->layer(id)) != maskedLayers.end()) {
@@ -240,13 +244,14 @@ CircleFitTrackSeedTool::Segment::Segment(const Trk::Track* track, const FaserSCT
         }
       }
       station = idHelper->station(id);
-//      if(station==0)continue;
+      //if(station==0)continue;
       clusterSet.set(CircleFitTrackSeedTool::s_indexMap.at(id));
-      auto fitParameters = track->trackParameters()->front();
-      position = fitParameters->position();
-      momentum = fitParameters->momentum();
     }
   }
+  auto fitParameters = track->trackParameters()->front();
+  position = fitParameters->position();
+  momentum = fitParameters->momentum();
+
   fakePositions.push_back(position);
   fakePositions.push_back(position - 30 * momentum.normalized());
   fakePositions.push_back(position + 30 * momentum.normalized());
@@ -255,9 +260,13 @@ CircleFitTrackSeedTool::Segment::Segment(const Trk::Track* track, const FaserSCT
 CircleFitTrackSeedTool::Seed::Seed(const std::vector<Segment> &segments, bool backward) :
     clusterSet(CircleFitTrackSeedTool::s_indexMap.size()) {
   for (const Segment &seg : segments) {
+    segs.push_back(seg);//get the segments of one Seed*********************************
     clusters.insert(clusters.end(), seg.clusters.begin(), seg.clusters.end());
+    //get measurements of every Seed**********
+    Measurements.insert(Measurements.end(),seg.Measurements.begin(),seg.Measurements.end());
     spacePoints.insert(spacePoints.end(), seg.spacePoints.begin(), seg.spacePoints.end());
     positions.push_back(seg.position);
+    
     // TODO use reconstruct space points instead of fake positions
     fakePositions.insert(fakePositions.end(), seg.fakePositions.begin(), seg.fakePositions.end());
     for (size_t i = 0; i < seg.clusterSet.size(); ++i) {
@@ -352,15 +361,6 @@ Acts::BoundTrackParameters CircleFitTrackSeedTool::Seed::get_params(double origi
   double theta = Acts::VectorHelpers::theta(direction);
   double phi = Acts::VectorHelpers::phi(direction);
 
-  Acts::BoundVector params = Acts::BoundVector::Zero();
-  params[Acts::eBoundLoc0] = 0;
-  params[Acts::eBoundLoc1] = 0;
-  params[Acts::eBoundTime] = 0;
-  params[Acts::eBoundPhi] = phi;
-  params[Acts::eBoundTheta] = theta;
-  //params[Acts::eBoundQOverP] = particleHypothesis.qOverP(p, charge);
-  params[Acts::eBoundQOverP] = charge/momentum;
-
   Acts::Vector3 pos(0,0,0);
   if (!backward) {
     pos = positions[0] - (positions[0].z() - origin)/direction.z() * direction;
@@ -368,7 +368,20 @@ Acts::BoundTrackParameters CircleFitTrackSeedTool::Seed::get_params(double origi
     size_t size = positions.size();
     pos = positions[size-1] + (origin - positions[size-1].z())/direction.z() * direction;
   }
-  auto refPlane = Acts::Surface::makeShared<Acts::PlaneSurface>(pos, direction.normalized()); 
+  Acts::BoundVector params = Acts::BoundVector::Zero();
+  params[Acts::eBoundLoc0] = pos.y();
+  params[Acts::eBoundLoc1] = pos.x();
+  params[Acts::eBoundTime] = 0;
+  params[Acts::eBoundPhi] = phi;
+  params[Acts::eBoundTheta] = theta;
+  //params[Acts::eBoundQOverP] = particleHypothesis.qOverP(p, charge);
+
+  params[Acts::eBoundQOverP] = charge/(momentum);
+
+  
+  Acts::Vector3 direct(0,0,-1);
+  auto refPlane = Acts::Surface::makeShared<Acts::PlaneSurface>(pos, direct); 
  //@todo make the particle hypothesis configurable
   return Acts::BoundTrackParameters(refPlane, params, cov, Acts::ParticleHypothesis::muon()); 
 }
+
diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/CircleFitTrackSeedTool.h b/Tracking/Acts/FaserActsKalmanFilter/src/CircleFitTrackSeedTool.h
index f937872d9fdf182aa0551dcb40a7c70310234e5c..3b38d518fccc55626c68477a88a7c953bc684499 100644
--- a/Tracking/Acts/FaserActsKalmanFilter/src/CircleFitTrackSeedTool.h
+++ b/Tracking/Acts/FaserActsKalmanFilter/src/CircleFitTrackSeedTool.h
@@ -11,6 +11,10 @@
 #include "FaserActsGeometryInterfaces/IFaserActsTrackingGeometryTool.h"
 #include "FaserActsKalmanFilter/ITrackSeedTool.h"
 #include "TrkTrack/TrackCollection.h"
+#include "TrackerRIO_OnTrack/FaserSCT_ClusterOnTrack.h"
+#include "TrkRIO_OnTrack/RIO_OnTrack.h"
+#include "TrkSurfaces/Surface.h"
+
 // #include "TrackerSimData/TrackerSimDataCollection.h"
 // #include "GeneratorObjects/McEventCollection.h"
 #include <array>
@@ -31,7 +35,8 @@ public:
   virtual StatusCode initialize() override;
   virtual StatusCode finalize() override;
   virtual StatusCode run(std::vector<int> maskedLayers = {}, bool backward=false) override;
-
+  
+  
   const std::shared_ptr<std::vector<Acts::BoundTrackParameters>> initialTrackParameters() const override;
   const std::shared_ptr<const Acts::Surface> initialSurface() const override;
   const std::shared_ptr<std::vector<IndexSourceLink>> sourceLinks() const override;
@@ -40,15 +45,17 @@ public:
   const std::shared_ptr<std::vector<const Tracker::FaserSCT_Cluster*>> clusters() const override;
   const std::shared_ptr<std::vector<std::array<std::vector<const Tracker::FaserSCT_Cluster*>, 3>>> seedClusters() const override;
   const std::shared_ptr<std::vector<const Tracker::FaserSCT_SpacePoint*>> spacePoints() const override;
-  double targetZPosition() const override;
+  double targetZPosition() const override;//****
+  Acts::BoundSquareMatrix covBound() const;//****
+
 
-private:
   struct Segment {
   public:
     Segment(const Trk::Track* track, const FaserSCT_ID *idHelper, const std::vector<int> &maskedLayers = {});
     int station = -1;
     std::vector<const Tracker::FaserSCT_Cluster*> clusters;
     std::vector<const Tracker::FaserSCT_SpacePoint*> spacePoints;
+    std::vector<const Trk::MeasurementBase*> Measurements;//*************************
     ClusterSet clusterSet;
     Acts::Vector3 position;
     std::vector<Acts::Vector3> fakePositions;
@@ -56,11 +63,14 @@ private:
   };
 
   struct Seed {
+  public:	  
     Seed(const std::vector<Segment> &segments, bool backward=false);
 
     ClusterSet clusterSet;
     std::vector<const Tracker::FaserSCT_Cluster*> clusters;
+    std::vector<Segment> segs;//get segments of Seed************************
     std::vector<const Tracker::FaserSCT_SpacePoint*> spacePoints;
+    std::vector<const Trk::MeasurementBase*> Measurements;//*************************
     std::vector<Acts::Vector3> positions;
     std::vector<Acts::Vector3> fakePositions;
 
@@ -81,6 +91,12 @@ private:
     double m_sigma_x = 0.8;
     double m_sigma_y = 0.016;
   };
+  const std::shared_ptr<std::vector<CircleFitTrackSeedTool::Seed>> seeds() const;
+
+
+
+private:
+ 
 
   void go(const std::array<std::vector<Segment>, 4> &v, std::vector<Segment> &combination,
           std::vector<Seed> &seeds, int offset, int k, bool backward=false);
@@ -96,7 +112,11 @@ private:
   std::shared_ptr<std::vector<const Tracker::FaserSCT_Cluster*>> m_clusters {};
   std::shared_ptr<std::vector<std::array<std::vector<const Tracker::FaserSCT_Cluster*>, 3>>> m_seedClusters {};
   std::shared_ptr<std::vector<const Tracker::FaserSCT_SpacePoint*>> m_spacePoints {};
+ 
+  std::shared_ptr<std::vector<Seed>> m_seeds {};
+
   double m_targetZPosition {0};
+  Acts::BoundSquareMatrix m_cov;
 
   const FaserSCT_ID* m_idHelper {nullptr};
   const TrackerDD::SCT_DetectorManager* m_detManager {nullptr};
@@ -105,8 +125,6 @@ private:
   SG::ReadHandleKey<TrackCollection> m_trackCollection { this, "TrackCollection", "SegmentFit", "Input track collection name" };
   SG::ReadHandleKey<Tracker::FaserSCT_ClusterContainer> m_clusterContainerKey { this, "ClusterContainer", "SCT_ClusterContainer"};
   SG::ReadHandleKey<FaserSCT_SpacePointContainer> m_spacePointContainerKey { this, "SpacePoints", "SCT_SpacePointContainer"};
-  // SG::ReadHandleKey<McEventCollection> m_mcEventCollectionKey { this, "McEventCollection", "TruthEvent"};
-  // SG::ReadHandleKey<TrackerSimDataCollection> m_simDataCollectionKey { this, "TrackerSimDataCollection", "SCT_SDO_Map"};
 
   Gaudi::Property<double> m_std_cluster {this, "std_cluster", 0.04};
   // covariance of the initial parameters
@@ -119,6 +137,12 @@ private:
   Gaudi::Property<bool> m_removeIFT{this, "removeIFT", false};
 };
 
+
+inline const std::shared_ptr<std::vector<CircleFitTrackSeedTool::Seed>> 
+CircleFitTrackSeedTool::seeds() const {
+  return m_seeds;
+}
+
 inline const std::shared_ptr<std::vector<Acts::BoundTrackParameters>>
 CircleFitTrackSeedTool::initialTrackParameters() const {
   return m_initialTrackParameters;
@@ -163,4 +187,9 @@ inline double CircleFitTrackSeedTool::targetZPosition() const {
   return m_targetZPosition;
 }
 
+inline Acts::BoundSquareMatrix CircleFitTrackSeedTool::covBound() const {
+  return m_cov;
+}
+
+
 #endif  // FASERACTSKALMANFILTER_CIRCLEFITTRACKSEEDTOOL_H
diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/RootSeedWriteTool.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/RootSeedWriteTool.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..ff9e4f6f7540d86f6292f9f07c544f4b3d57d925
--- /dev/null
+++ b/Tracking/Acts/FaserActsKalmanFilter/src/RootSeedWriteTool.cxx
@@ -0,0 +1,506 @@
+#include"RootSeedWriteTool.h"
+
+#include "TrackerSpacePoint/FaserSCT_SpacePoint.h"
+#include "TrackerPrepRawData/FaserSCT_Cluster.h"
+#include "Identifier/Identifier.h"
+#include "TrackClassification.h"
+#include "GeoPrimitives/GeoPrimitives.h"
+//#include "Acts/EventData/MultiTrajectory.hpp"
+//#include "Acts/EventData/MultiTrajectoryHelpers.hpp"
+
+#include "Acts/EventData/detail/TransformationBoundToFree.hpp"
+#include "Acts/Utilities/Helpers.hpp"
+
+//#include "GeoPrimitives/CLHEPtoEigenConverter.h"
+#include "TrackerReadoutGeometry/SiDetectorElement.h"
+#include "xAODTruth/TruthParticle.h"
+#include "HepMC3/GenParticle.h"
+#include "HepMC3/GenVertex.h"
+
+#include <TFile.h>
+#include <TTree.h>
+#include<string>
+RootSeedWriterTool::RootSeedWriterTool(
+    const std::string& type, const std::string& name, const IInterface* parent)
+    : AthAlgTool(type, name, parent) {}
+
+/// NaN values for TTree variables
+//constexpr float NaNfloat = std::numeric_limits<float>::quiet_NaN();
+constexpr float NaNfloat = std::numeric_limits<float>::quiet_NaN();
+constexpr float NaNdouble = std::numeric_limits<double>::quiet_NaN();
+constexpr int NaNint = std::numeric_limits<int>::quiet_NaN();
+using Acts::VectorHelpers::eta;
+using Acts::VectorHelpers::perp;
+using Acts::VectorHelpers::phi;
+using Acts::VectorHelpers::theta;
+
+
+StatusCode RootSeedWriterTool::initialize() {
+//  ATH_CHECK(detStore()->retrieve(m_idHelper, "FaserSCT_ID"));
+  ATH_CHECK(m_mcEventCollectionKey.initialize());
+  ATH_CHECK(m_simDataCollectionKey.initialize());
+  ATH_CHECK(m_fiducialParticleTool.retrieve());
+  //ATH_CHECK(m_truthParticleContainer.initialize());
+
+  if (!m_noDiagnostics) {
+    std::string filePath = m_filePath;
+    std::string treeName = m_treeName;
+    m_outputFile = TFile::Open(filePath.c_str(), "RECREATE");
+    if (m_outputFile == nullptr) {
+      ATH_MSG_WARNING("Unable to open output file at " << m_filePath);
+      return StatusCode::RECOVERABLE;
+    }
+    m_outputFile->cd();
+    m_outputTree = new TTree(treeName.c_str(), treeName.c_str());
+    if (m_outputTree == nullptr) {
+      ATH_MSG_ERROR("Unable to create TTree");
+      return StatusCode::FAILURE;
+    }
+    
+    
+    m_outputTree->Branch("truth_p", &m_truth_p);
+    m_outputTree->Branch("truth_vx", &m_truth_vx);
+    m_outputTree->Branch("truth_vy", &m_truth_vy);
+    m_outputTree->Branch("truth_vz", &m_truth_vz);
+    m_outputTree->Branch("truth_px", &m_truth_px);
+    m_outputTree->Branch("truth_py", &m_truth_py);
+    m_outputTree->Branch("truth_pz", &m_truth_pz);
+    m_outputTree->Branch("truth_pT", &m_truth_pT);
+//    m_outputTree->Branch("truth_pdg", &m_truth_pdg);
+    m_outputTree->Branch("truth_barcode", &m_truth_barcode);
+    m_outputTree->Branch("truth_theta", &m_truth_theta);
+    m_outputTree->Branch("truth_phi", &m_truth_phi);
+    m_outputTree->Branch("truth_eta", &m_truth_eta);
+    m_outputTree->Branch("truth_isFiducial", &m_truth_isFiducial);
+
+    m_outputTree->Branch("event_number", &m_eventNr);
+    m_outputTree->Branch("targetZPosition", &m_targetZPosition);
+
+    m_outputTree->Branch("nSeeds", &m_nseeds);
+    m_outputTree->Branch("nClusters", &m_nClusters);
+    m_outputTree->Branch("nMeasurements", &m_nMeasurements);
+    m_outputTree->Branch("nSegments", &m_nSegments);
+    m_outputTree->Branch("Positionx", &m_positionX);
+    m_outputTree->Branch("Positiony", &m_positionY);
+    m_outputTree->Branch("Positionz", &m_positionZ);
+    m_outputTree->Branch("Spacepoint_x", &m_spacePointX);
+    m_outputTree->Branch("Spacepoint_y", &m_spacePointY);
+    m_outputTree->Branch("Spacepoint_z", &m_spacePointZ);
+    m_outputTree->Branch("Fakeposition_x", &m_fakePositionX);
+    m_outputTree->Branch("FakePosition_y", &m_fakePositionY);
+    m_outputTree->Branch("FakePosition_z", &m_fakePositionZ);
+
+    m_outputTree->Branch("nMajorityHits", &m_nMajorityHits);
+    m_outputTree->Branch("majorityParticleId", &m_majorityParticleId);
+    m_outputTree->Branch("t_truthHitRatio", &m_t_truthHitRatio);
+    //m_outputTree->Branch("t_charge", &m_t_charge);
+    //m_outputTree->Branch("t_time", &m_t_time);
+
+    m_outputTree->Branch("track_loc0", &m_track_loc0);
+    m_outputTree->Branch("track_loc1", &m_track_loc1);
+    m_outputTree->Branch("track_theta", &m_track_theta);
+    m_outputTree->Branch("track_phi", &m_track_phi);
+    m_outputTree->Branch("track_QoverP", &m_track_QoverP);
+    m_outputTree->Branch("track_time", &m_track_time);
+    
+    m_outputTree->Branch("track_vx", &m_track_vx);
+    m_outputTree->Branch("track_vy", &m_track_vy);
+    m_outputTree->Branch("track_vz", &m_track_vz);
+    m_outputTree->Branch("track_px", &m_track_px);
+    m_outputTree->Branch("track_py", &m_track_py);
+    m_outputTree->Branch("track_pz", &m_track_pz);
+    m_outputTree->Branch("track_eta", &m_track_eta);
+    m_outputTree->Branch("track_p", &m_track_p);
+    m_outputTree->Branch("track_pT", &m_track_pT);
+    
+    m_outputTree->Branch("t_loc0", &m_t_loc0);
+    m_outputTree->Branch("t_loc1", &m_t_loc1);
+    m_outputTree->Branch("t_theta", &m_t_theta);
+    m_outputTree->Branch("t_phi", &m_t_phi);
+    m_outputTree->Branch("t_QoverP", &m_t_QoverP);
+    m_outputTree->Branch("t_time", &m_t_time);
+    
+    m_outputTree->Branch("t_vx", &m_t_vx);
+    m_outputTree->Branch("t_vy", &m_t_vy);
+    m_outputTree->Branch("t_vz", &m_t_vz);
+    m_outputTree->Branch("t_px", &m_t_px);
+    m_outputTree->Branch("t_py", &m_t_py);
+    m_outputTree->Branch("t_pz", &m_t_pz);
+    m_outputTree->Branch("t_eta", &m_t_eta);
+    m_outputTree->Branch("t_p", &m_t_p);
+    m_outputTree->Branch("t_pT", &m_t_pT);
+
+
+  }
+  return StatusCode::SUCCESS;
+}
+StatusCode RootSeedWriterTool::finalize() {
+  if (!m_noDiagnostics) {
+    m_outputFile->cd();
+    m_outputTree->Write();
+    m_outputFile->Close();
+  }
+  return StatusCode::SUCCESS;
+}
+
+
+StatusCode RootSeedWriterTool::write(const Acts::GeometryContext& geoContext, const double &targetZPosition, const Acts::BoundSquareMatrix& cov, const std::vector<CircleFitTrackSeedTool::Seed> &seeds, bool isMC, bool backward) const {
+  EventContext ctx = Gaudi::Hive::currentContext();
+
+  std::shared_ptr<TrackerSimDataCollection> simData {nullptr};
+  std::map<int, const HepMC::GenParticle*> particles {};
+  if (isMC) {
+
+    SG::ReadHandle<TrackerSimDataCollection> simDataHandle {m_simDataCollectionKey, ctx};
+    ATH_CHECK(simDataHandle.isValid());
+    simData = std::make_shared<TrackerSimDataCollection>(*simDataHandle);
+    
+    SG::ReadHandle<McEventCollection> mcEvents {m_mcEventCollectionKey, ctx};
+    ATH_CHECK(mcEvents.isValid());
+    if (mcEvents->size() != 1) {
+      ATH_MSG_ERROR("There should be exactly one event in the McEventCollection.");
+      return StatusCode::FAILURE;
+    }
+    for (const auto& particle : mcEvents->front()->particles()) {
+      particles[HepMC::barcode(particle)] = &(*particle);
+       
+      
+
+       bool isFiducial = m_fiducialParticleTool->isFiducial(HepMC::barcode(particle));
+  //     m_truth_pdg.push_back(particle->pdgId());
+      
+       m_truth_isFiducial.push_back(isFiducial); 
+       if(isFiducial){
+
+        float truth_vx = NaNfloat;
+        float truth_vy = NaNfloat;
+        float truth_vz = NaNfloat;
+        float truth_px = NaNfloat;
+        float truth_py = NaNfloat;
+        float truth_pz = NaNfloat;
+        float truth_theta = NaNfloat;
+        float truth_phi = NaNfloat;
+        float truth_eta = NaNfloat;
+        float truth_p = NaNfloat;
+        float truth_pT = NaNfloat;
+
+        const HepMC::GenParticle* truthparticle = &(*particle);
+        std::optional<const Acts::BoundTrackParameters> truthParameters
+               = extrapolateToReferenceSurface(ctx, truthparticle, targetZPosition);
+        if(!truthParameters){
+          continue;
+        }
+	
+	m_truth_barcode.push_back(HepMC::barcode(particle));
+        truth_p = truthParameters->momentum().norm();
+       //  m_truth_charge = truthParameters->charge();
+       //  m_truth_time = truthParameters->time();
+        truth_vx = truthParameters->position(geoContext).x();
+        truth_vy = truthParameters->position(geoContext).y();
+        truth_vz = truthParameters->position(geoContext).z();
+        truth_px = truthParameters->momentum().x();
+        truth_py = truthParameters->momentum().y();
+        truth_pz = truthParameters->momentum().z();
+        truth_theta = theta(truthParameters->momentum().normalized());
+        truth_phi = phi(truthParameters->momentum().normalized());
+        truth_eta = eta(truthParameters->momentum().normalized());
+        truth_pT = truth_p * perp(truthParameters->momentum().normalized());
+
+        m_truth_vx.push_back(truth_vx);
+        m_truth_vy.push_back(truth_vy);
+        m_truth_vz.push_back(truth_vz);
+
+        m_truth_p.push_back(truth_p);
+        m_truth_px.push_back(truth_px);
+        m_truth_py.push_back(truth_py);
+        m_truth_pz.push_back(truth_pz);
+        m_truth_pT.push_back(truth_pT);
+        m_truth_theta.push_back(truth_theta);
+        m_truth_phi.push_back(truth_phi);
+        m_truth_eta.push_back(truth_eta);
+      }
+    }
+  }
+  
+  // For each particle within a track, how many hits did it contribute
+  std::vector<ParticleHitCount> particleHitCounts;
+
+  // Loop over the seeds from CircleFitTrackSeedTool
+  m_eventNr = ctx.eventID().event_number();
+  m_targetZPosition = targetZPosition;
+  m_nseeds = seeds.size();
+  for(auto seed : seeds){
+    m_nClusters.push_back(seed.clusters.size());
+    m_nMeasurements.push_back(seed.Measurements.size());
+    m_nSegments.push_back(seed.stations);//seed has 'stations'variable,it means the size of segments;
+      
+    for(auto po : seed.positions){
+      m_positionX.push_back(po.x());
+      m_positionY.push_back(po.y());
+      m_positionZ.push_back(po.z());
+    }
+  
+    for(auto fake : seed.fakePositions){
+      m_fakePositionX.push_back(fake.x());
+      m_fakePositionY.push_back(fake.y());
+      m_fakePositionZ.push_back(fake.z());
+    }
+    for(auto sp : seed.spacePoints){
+      auto pos = sp->globalPosition();
+      m_spacePointX.push_back(pos.x());
+      m_spacePointY.push_back(pos.y());
+      m_spacePointZ.push_back(pos.z());
+    }
+
+
+
+    //initilize the truth info;
+    uint64_t majorityParticleId = NaNint;
+    double nMajorityHits = NaNdouble;
+    double t_truthHitRatio = NaNdouble;
+    //float t_charge = NaNint;
+   // float t_time = NaNfloat;
+    float t_vx = NaNfloat;
+    float t_vy = NaNfloat;
+    float t_vz = NaNfloat;
+    float t_px = NaNfloat;
+    float t_py = NaNfloat;
+    float t_pz = NaNfloat;
+    float t_eta = NaNfloat;
+    float t_p = NaNfloat;
+    float t_pT = NaNfloat;
+
+    if (isMC) {
+      
+     // Get the majority truth particle to this seed
+      ATH_MSG_VERBOSE("get majority truth particle");
+      identifyContributingParticles(*simData, seed.clusters, particleHitCounts);
+      for (const auto& particle : particleHitCounts) {
+        ATH_MSG_VERBOSE(particle.particleId << ": " << particle.hitCount << " hits");
+      }
+
+      bool foundMajorityParticle = false;
+      // Get the truth particle info
+      if (not particleHitCounts.empty()) {
+        // Get the barcode of the majority truth particle
+        majorityParticleId = particleHitCounts.front().particleId;
+        nMajorityHits = particleHitCounts.front().hitCount;
+
+	//Get the purity of every seed
+        t_truthHitRatio = nMajorityHits / seed.Measurements.size();
+        
+	// Find the truth particle via the barcode
+        auto ip = particles.find(majorityParticleId);
+        if (ip != particles.end()) {
+          foundMajorityParticle = true;
+
+          const HepMC::GenParticle* particle = ip->second;
+          ATH_MSG_DEBUG("Find the truth particle with barcode = " << majorityParticleId);
+	  
+
+       //   const HepMC::FourVector &vertex = particle->production_vertex()->position();
+       //	  const HepMC::FourVector &momentum = particle->momentum();
+          std::optional<const Acts::BoundTrackParameters> truthParameters
+             = extrapolateToReferenceSurface(ctx, particle, targetZPosition);
+
+          if (!truthParameters) {
+            continue;
+          }
+
+	  Acts::BoundTrackParameters  boundParams = seed.get_params(targetZPosition, cov, backward);
+          auto params = boundParams.parameters();
+          double loc0  = params[Acts::eBoundLoc0];
+          double loc1 =  params[Acts::eBoundLoc1];
+          double phi =  params[Acts::eBoundPhi];
+          double theta = params[Acts::eBoundTheta];
+          double QoverP = params[Acts::eBoundQOverP];
+          double time = params[Acts::eBoundTime];
+	  
+	 float track_p = boundParams.momentum().norm();
+        //track_charge = truthParameters->charge();
+        //track_time = truthParameters->time();
+         float track_vx = boundParams.position(geoContext).x();
+         float track_vy = boundParams.position(geoContext).y();
+         float track_vz = boundParams.position(geoContext).z();
+         float track_px = boundParams.momentum().x();
+         float track_py = boundParams.momentum().y();
+         float track_pz = boundParams.momentum().z();
+         float track_eta = eta(boundParams.momentum().normalized());
+         float track_pT = track_p * perp(boundParams.momentum().normalized());
+
+
+
+          m_track_loc0.push_back(loc0);
+          m_track_loc1.push_back(loc1);
+          m_track_theta.push_back(theta);
+          m_track_phi.push_back(phi);
+          m_track_QoverP.push_back(QoverP);
+          m_track_time.push_back(time);
+          
+	  
+	  m_track_vx.push_back(track_vx);
+          m_track_vy.push_back(track_vy);
+          m_track_vz.push_back(track_vz);
+          m_track_px.push_back(track_px);
+          m_track_py.push_back(track_py);
+          m_track_pz.push_back(track_pz);
+          m_track_eta.push_back(track_eta);
+          m_track_p.push_back(track_p);
+          m_track_pT.push_back(track_pT);
+         
+
+
+	  auto truthParams = truthParameters->parameters();
+          double t_loc0 = truthParams[Acts::eBoundLoc0];
+          double t_loc1 = truthParams[Acts::eBoundLoc1];
+          double t_phi = truthParams[Acts::eBoundPhi];
+          double t_theta = truthParams[Acts::eBoundTheta];
+          double t_QoverP = truthParams[Acts::eBoundQOverP];
+          double t_time = truthParams[Acts::eBoundTime];
+	  m_t_loc0.push_back(t_loc0);
+	  m_t_loc1.push_back(t_loc1);
+	  m_t_theta.push_back(t_theta);
+	  m_t_phi.push_back(t_phi);
+	  m_t_QoverP.push_back(t_QoverP);
+	  m_t_time.push_back(t_time);
+
+	  t_p = truthParameters->momentum().norm();
+        //  t_charge = truthParameters->charge();
+        //  t_time = truthParameters->time();
+          t_vx = truthParameters->position(geoContext).x();
+          t_vy = truthParameters->position(geoContext).y();
+          t_vz = truthParameters->position(geoContext).z();
+          t_px = truthParameters->momentum().x();
+          t_py = truthParameters->momentum().y();
+          t_pz = truthParameters->momentum().z();
+          t_eta = eta(truthParameters->momentum().normalized());
+          t_pT = t_p * perp(truthParameters->momentum().normalized());
+
+
+
+        }
+	else {
+	  ATH_MSG_WARNING("Truth particle with barcode = " << majorityParticleId << " not found in the input collection!");
+	}
+      }
+      if (not foundMajorityParticle) {
+        ATH_MSG_WARNING("Truth particle for seed is not found!");
+      }
+    }
+    m_majorityParticleId.push_back(majorityParticleId);
+    m_nMajorityHits.push_back(nMajorityHits);
+    m_t_truthHitRatio.push_back(t_truthHitRatio);
+    //m_t_charge.push_back(t_charge);
+    //m_t_time.push_back(t_time);
+    m_t_vx.push_back(t_vx);
+    m_t_vy.push_back(t_vy);
+    m_t_vz.push_back(t_vz);
+    m_t_px.push_back(t_px);
+    m_t_py.push_back(t_py);
+    m_t_pz.push_back(t_pz);
+    m_t_eta.push_back(t_eta);
+    m_t_p.push_back(t_p);
+    m_t_pT.push_back(t_pT);
+  } 
+    
+  m_outputTree->Fill();
+  
+  m_truth_p.clear();
+  m_truth_vx.clear();
+  m_truth_vy.clear();
+  m_truth_vz.clear();
+  m_truth_px.clear();
+  m_truth_py.clear();
+  m_truth_pz.clear();
+  m_truth_pT.clear();
+//  m_truth_pdg.clear();
+  m_truth_barcode.clear();
+  m_truth_isFiducial.clear();
+  m_truth_theta.clear();
+  m_truth_phi.clear(); 
+  m_truth_eta.clear();
+  m_targetZPosition=0.0;
+  m_nseeds=0;
+  m_nClusters.clear();
+  m_nMeasurements.clear();
+  m_nSegments.clear();
+
+  m_positionX.clear();
+  m_positionY.clear();
+  m_positionZ.clear();
+  
+  m_spacePointX.clear();
+  m_spacePointY.clear();
+  m_spacePointZ.clear();
+  
+  m_fakePositionX.clear();
+  m_fakePositionY.clear();
+  m_fakePositionZ.clear();
+
+  m_nMajorityHits.clear();
+  m_majorityParticleId.clear();
+  m_t_truthHitRatio.clear();
+  //m_t_charge.clear();
+  //m_t_time.clear();
+
+  m_track_loc0.clear();
+  m_track_loc1.clear();
+  m_track_theta.clear();
+  m_track_phi.clear();
+  m_track_QoverP.clear();
+  m_track_time.clear();
+  m_track_vx.clear();
+  m_track_vy.clear();
+  m_track_vz.clear();
+  m_track_px.clear();
+  m_track_py.clear();
+  m_track_pz.clear();
+  m_track_p.clear();
+  m_track_pT.clear();
+  m_track_eta.clear();
+
+  m_t_loc0.clear();
+  m_t_loc1.clear();
+  m_t_theta.clear();
+  m_t_phi.clear();
+  m_t_QoverP.clear();
+  m_t_time.clear();
+
+  m_t_vx.clear();
+  m_t_vy.clear();
+  m_t_vz.clear();
+  m_t_px.clear();
+  m_t_py.clear();
+  m_t_pz.clear();
+  m_t_eta.clear();
+
+  return StatusCode::SUCCESS;  
+}
+
+
+std::optional<const Acts::BoundTrackParameters> RootSeedWriterTool::extrapolateToReferenceSurface(
+    const EventContext& ctx, const HepMC::GenParticle* particle, const double& targetZ) const {
+  const HepMC::FourVector &vertex = particle->production_vertex()->position();
+  const HepMC::FourVector &momentum = particle->momentum();
+
+  // The coordinate system of the Acts::PlaneSurface is defined as
+  // T = Z = normal, U = X x T = -Y, V = T x U = x
+  auto startSurface = Acts::Surface::makeShared<Acts::PlaneSurface>(
+      Acts::Vector3(0, 0, vertex.z()), Acts::Vector3(0, 0, 1));
+  auto targetSurface = Acts::Surface::makeShared<Acts::PlaneSurface>(
+      Acts::Vector3(0, 0, targetZ), Acts::Vector3(0, 0, -1));
+  Acts::BoundVector params = Acts::BoundVector::Zero();
+  params[Acts::eBoundLoc0] = -vertex.y();
+  params[Acts::eBoundLoc1] = vertex.x();
+  params[Acts::eBoundPhi] = momentum.phi();
+  params[Acts::eBoundTheta] = momentum.theta();
+  // FIXME get charge of HepMC::GenParticle, the following does not work, e.g. for pions
+  double charge = particle->pdg_id() > 0 ? -1 : 1;
+  double MeV2GeV = 1e-3;
+  params[Acts::eBoundQOverP] = charge / (momentum.rho() * MeV2GeV);
+  params[Acts::eBoundTime] = vertex.t();
+  Acts::BoundTrackParameters startParameters(std::move(startSurface), params,  std::nullopt, Acts::ParticleHypothesis::muon());
+  std::optional<const Acts::BoundTrackParameters> targetParameters =
+      m_extrapolationTool->propagate(ctx, startParameters, *targetSurface);
+  return targetParameters;
+}
diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/RootSeedWriteTool.h b/Tracking/Acts/FaserActsKalmanFilter/src/RootSeedWriteTool.h
new file mode 100644
index 0000000000000000000000000000000000000000..3569a846812b7869c363bdba1299ae490f9fcb74
--- /dev/null
+++ b/Tracking/Acts/FaserActsKalmanFilter/src/RootSeedWriteTool.h
@@ -0,0 +1,135 @@
+#ifndef ROOTSEEDWRITETOOL_H
+#define ROOTSEEDWRITETOOL_H
+#include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h"
+#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h"
+#include "CircleFitTrackSeedTool.h"
+#include "Gaudi/Property.h"
+#include "GaudiKernel/IInterface.h"
+#include "GaudiKernel/StatusCode.h"
+#include"AthenaBaseComps/AthAlgTool.h"
+#include "Acts/EventData/TrackParameters.hpp"
+#include "Acts/Geometry/GeometryContext.hpp"
+
+#include "FaserActsGeometryInterfaces/IFaserActsExtrapolationTool.h"
+#include "FaserActsKalmanFilter/IFiducialParticleTool.h"
+#include "TrackerSimData/TrackerSimDataCollection.h"
+#include "GeneratorObjects/McEventCollection.h"
+
+//#include "xAODEventInfo/EventInfo.h"
+
+#include"CircleFitTrackSeedTool.h"
+#include<string>
+#include<vector>
+
+class TFile;
+class TTree;
+
+
+class RootSeedWriterTool : public AthAlgTool {
+public:
+  RootSeedWriterTool(const std::string& type, const std::string& name, const IInterface* parent);
+  ~RootSeedWriterTool() override = default;
+  StatusCode write(const Acts::GeometryContext& geoContext, const double& targetZPosition, const Acts::BoundSquareMatrix& cov, const std::vector<CircleFitTrackSeedTool::Seed> &seeds, bool isMC, bool backward = false) const;
+  StatusCode initialize() override;
+  StatusCode finalize() override;
+private:
+  
+  std::optional<const Acts::BoundTrackParameters> extrapolateToReferenceSurface(
+      const EventContext& ctx, const HepMC::GenParticle* particle, const double& targetZ) const;
+
+  ToolHandle<CircleFitTrackSeedTool>m_trackSeedTool {this, "trackSeedTool", "CircleFitTrackSeedTool"};
+  ToolHandle<IFaserActsExtrapolationTool> m_extrapolationTool {
+      this, "ExtrapolationTool", "FaserActsExtrapolationTool"};
+
+  SG::ReadHandleKey<TrackerSimDataCollection> m_simDataCollectionKey {
+    this, "TrackerSimDataCollection", "SCT_SDO_Map"};
+  SG::ReadHandleKey<McEventCollection> m_mcEventCollectionKey {
+    this, "McEventCollection", "TruthEvent"};
+  ToolHandle<IFiducialParticleTool> m_fiducialParticleTool {this, "FiducialParticleTool", "FiducialParticleTool"};
+
+
+  Gaudi::Property<bool> m_noDiagnostics {this, "noDiagnostics", true, "Set ACTS logging level to INFO and do not run performents writer,seed writer, states writer or summary writer"};
+  Gaudi::Property<std::string> m_filePath{this, "FilePath", "seed_summary_circleFitTrackSeedTool.root", "Output root file"};
+  Gaudi::Property<std::string> m_treeName{this, "TreeName", "tree", "Tree name"};
+  Gaudi::Property<bool> m_mc {this, "MC", false};
+
+  
+  TFile* m_outputFile;
+  TTree* m_outputTree;
+
+  //mutable std::vector<double> m_truth_pdg;
+  mutable std::vector<double> m_truth_barcode;
+ 
+  mutable std::vector<bool> m_truth_isFiducial;
+  mutable std::vector<float> m_truth_vx;
+  mutable std::vector<float> m_truth_vy;
+  mutable std::vector<float> m_truth_vz;
+  mutable std::vector<float> m_truth_p;
+  mutable std::vector<float> m_truth_px;
+  mutable std::vector<float> m_truth_py;
+  mutable std::vector<float> m_truth_pz;
+  mutable std::vector<float> m_truth_pT;
+  mutable std::vector<float> m_truth_theta;
+  mutable std::vector<float> m_truth_phi;
+  mutable std::vector<float> m_truth_eta;
+
+  mutable uint32_t m_eventNr{0};
+  mutable double m_targetZPosition{0.0};
+  mutable std::vector<unsigned int> m_nClusters;
+  mutable std::vector<unsigned int> m_nMeasurements;
+  mutable uint32_t m_nseeds{0};
+  mutable std::vector<unsigned int> m_nSegments;
+  mutable std::vector<double> m_positionX;
+  mutable std::vector<double> m_positionY;
+  mutable std::vector<double> m_positionZ;
+  mutable std::vector<double> m_spacePointX;
+  mutable std::vector<double> m_spacePointY;
+  mutable std::vector<double> m_spacePointZ;
+  mutable std::vector<double> m_fakePositionX;
+  mutable std::vector<double> m_fakePositionY;
+  mutable std::vector<double> m_fakePositionZ;
+
+  mutable std::vector<double> m_nMajorityHits;  ///< The number of hits from majority particle
+  mutable std::vector<uint64_t> m_majorityParticleId;      ///< The particle Id of the majority particle
+  mutable std::vector<double> m_t_truthHitRatio;  ///< the purity of every track
+  //mutable std::vector<int> m_t_charge;   ///< Charge of majority particle
+  //mutable std::vector<float> m_t_time;   ///< Time of majority particle
+
+
+  mutable std::vector<double> m_track_loc0;
+  mutable std::vector<double> m_track_loc1;
+  mutable std::vector<double> m_track_theta;
+  mutable std::vector<double> m_track_phi;
+  mutable std::vector<double> m_track_QoverP;
+  mutable std::vector<double> m_track_time;
+  mutable std::vector<float> m_track_vx;     
+  mutable std::vector<float> m_track_vy;     
+  mutable std::vector<float> m_track_vz;     
+  mutable std::vector<float> m_track_px;     
+  mutable std::vector<float> m_track_py;     
+  mutable std::vector<float> m_track_pz;    
+  mutable std::vector<float> m_track_p;      
+  mutable std::vector<float> m_track_pT;     
+  mutable std::vector<float> m_track_eta;    
+
+
+  mutable std::vector<double> m_t_loc0;
+  mutable std::vector<double> m_t_loc1;
+  mutable std::vector<double> m_t_theta;
+  mutable std::vector<double> m_t_phi;
+  mutable std::vector<double> m_t_QoverP;
+  mutable std::vector<double> m_t_time;
+
+  mutable std::vector<float> m_t_vx;     ///< Vertex x positions of majority particle
+  mutable std::vector<float> m_t_vy;     ///< Vertex y positions of majority particle
+  mutable std::vector<float> m_t_vz;     ///< Vertex z positions of majority particle
+  mutable std::vector<float> m_t_px;     ///< Initial momenta px of majority particle
+  mutable std::vector<float> m_t_py;     ///< Initial momenta py of majority particle
+  mutable std::vector<float> m_t_pz;     ///< Initial momenta pz of majority particle
+//  mutable std::vector<float> m_t_theta;  ///< In * m_MeV2GeVitial momenta theta of majority particle
+//  mutable std::vector<float> m_t_phi;    ///< Initial momenta phi of majority particle
+  mutable std::vector<float> m_t_p;      ///< Initial abs momenta of majority particle
+  mutable std::vector<float> m_t_pT;     ///< Initial momenta pT of majority particle
+  mutable std::vector<float> m_t_eta;    ///< Initial momenta eta of majority particle
+};
+#endif
diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/RootTrajectorySummaryWriterTool.h b/Tracking/Acts/FaserActsKalmanFilter/src/RootTrajectorySummaryWriterTool.h
index 91dcfbd53816223333ea43a5c5ebc62aaf0f14fc..e371a312d956a52ae2f47828bc5751eade0496f9 100644
--- a/Tracking/Acts/FaserActsKalmanFilter/src/RootTrajectorySummaryWriterTool.h
+++ b/Tracking/Acts/FaserActsKalmanFilter/src/RootTrajectorySummaryWriterTool.h
@@ -28,10 +28,11 @@ public:
   StatusCode write( const Acts::GeometryContext& geoContext, const FaserActsTrackContainer& tracks, bool isMC) const;
   StatusCode initialize() override;
   StatusCode finalize() override;
-
-private:
   std::optional<const Acts::BoundTrackParameters> extrapolateToReferenceSurface(
       const EventContext& ctx, const HepMC::GenParticle* particle) const;
+private:
+//  std::optional<const Acts::BoundTrackParameters> extrapolateToReferenceSurface(
+  //    const EventContext& ctx, const HepMC::GenParticle* particle) const;
   const FaserSCT_ID* m_idHelper {nullptr};
   SG::ReadHandleKey<TrackerSimDataCollection> m_simDataCollectionKey {
     this, "TrackerSimDataCollection", "SCT_SDO_Map"};
diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/components/FaserActsKalmanFilter_entries.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/components/FaserActsKalmanFilter_entries.cxx
index 09d804e3b1825dff94d417ee249bc2f95c65cf46..d44f838734e7fedcc61eaed927aa01bd2f8fec90 100755
--- a/Tracking/Acts/FaserActsKalmanFilter/src/components/FaserActsKalmanFilter_entries.cxx
+++ b/Tracking/Acts/FaserActsKalmanFilter/src/components/FaserActsKalmanFilter_entries.cxx
@@ -32,6 +32,7 @@
 #include "../CreateTrkTrackTool.h"
 #include "../TrackTruthMatchingTool.h"
 #include "../FiducialParticleTool.h"
+#include "../RootSeedWriteTool.h"
 
 DECLARE_COMPONENT(FaserActsKalmanFilterAlg)
 //#todoDECLARE_COMPONENT(CombinatorialKalmanFilterAlg)
@@ -45,6 +46,7 @@ DECLARE_COMPONENT(FaserActsKalmanFilterAlg)
 //DECLARE_COMPONENT(ProtoTrackWriterTool)
 //DECLARE_COMPONENT(SegmentFitClusterTrackFinderTool)
 //DECLARE_COMPONENT(SegmentFitTrackFinderTool)
+DECLARE_COMPONENT(RootSeedWriterTool)
 DECLARE_COMPONENT(RootTrajectoryStatesWriterTool)
 DECLARE_COMPONENT(RootTrajectorySummaryWriterTool)
 //DECLARE_COMPONENT(MultiTrackFinderTool)