From 1036dc23776d5a4178bb231231346e7408c3e230 Mon Sep 17 00:00:00 2001
From: "se.gorbunov" <se.gorbunov@gsi.de>
Date: Wed, 11 Sep 2024 16:39:09 +0200
Subject: [PATCH] Kf: move some fit utilities from ca:: to kf::

---
 algo/ca/core/CMakeLists.txt                   |  6 ----
 algo/ca/core/data/CaWindowData.h              |  8 ++---
 algo/ca/core/tracking/CaFramework.h           |  1 -
 algo/ca/core/tracking/CaTrackFit.cxx          | 20 ++++++-------
 algo/ca/core/tracking/CaTrackFit.h            | 18 ++++++------
 algo/ca/core/tracking/CaTrackFitter.cxx       |  8 ++---
 .../ca/core/tracking/CaTripletConstructor.cxx |  8 ++---
 algo/kf/core/CMakeLists.txt                   |  6 ++++
 .../core/data/KfMeasurementTime.cxx}          | 16 +++++-----
 .../core/data/KfMeasurementTime.h}            | 16 +++++-----
 .../core/data/KfMeasurementU.cxx}             | 10 +++----
 .../core/data/KfMeasurementU.h}               | 29 +++++++++----------
 .../core/data/KfMeasurementXy.cxx}            | 10 +++----
 .../core/data/KfMeasurementXy.h}              | 24 +++++++--------
 reco/KF/CbmKfTrackFitter.h                    |  8 ++---
 reco/KF/ParticleFitter/CbmL1PFFitter.cxx      |  6 ++--
 16 files changed, 96 insertions(+), 98 deletions(-)
 rename algo/{ca/core/data/CaMeasurementTime.cxx => kf/core/data/KfMeasurementTime.cxx} (77%)
 rename algo/{ca/core/data/CaMeasurementTime.h => kf/core/data/KfMeasurementTime.h} (87%)
 rename algo/{ca/core/data/CaMeasurementU.cxx => kf/core/data/KfMeasurementU.cxx} (89%)
 rename algo/{ca/core/data/CaMeasurementU.h => kf/core/data/KfMeasurementU.h} (79%)
 rename algo/{ca/core/data/CaMeasurementXy.cxx => kf/core/data/KfMeasurementXy.cxx} (90%)
 rename algo/{ca/core/data/CaMeasurementXy.h => kf/core/data/KfMeasurementXy.h} (90%)

diff --git a/algo/ca/core/CMakeLists.txt b/algo/ca/core/CMakeLists.txt
index 3397776972..33b3558c1b 100644
--- a/algo/ca/core/CMakeLists.txt
+++ b/algo/ca/core/CMakeLists.txt
@@ -14,9 +14,6 @@ set(SRCS
   ${CMAKE_CURRENT_SOURCE_DIR}/data/CaGrid.cxx
   ${CMAKE_CURRENT_SOURCE_DIR}/data/CaHit.cxx
   ${CMAKE_CURRENT_SOURCE_DIR}/data/CaTriplet.cxx
-  ${CMAKE_CURRENT_SOURCE_DIR}/data/CaMeasurementU.cxx
-  ${CMAKE_CURRENT_SOURCE_DIR}/data/CaMeasurementXy.cxx
-  ${CMAKE_CURRENT_SOURCE_DIR}/data/CaMeasurementTime.cxx
   ${CMAKE_CURRENT_SOURCE_DIR}/data/CaWindowData.cxx
   ${CMAKE_CURRENT_SOURCE_DIR}/data/CaTimesliceHeader.cxx
   ${CMAKE_CURRENT_SOURCE_DIR}/pars/CaConfigReader.cxx
@@ -83,9 +80,6 @@ install(
     data/CaHit.h
     data/CaInputData.h
     data/CaTrack.h
-    data/CaMeasurementU.h
-    data/CaMeasurementXy.h
-    data/CaMeasurementTime.h
     data/CaWindowData.h
     pars/CaConfigReader.h
     data/CaGridEntry.h
diff --git a/algo/ca/core/data/CaWindowData.h b/algo/ca/core/data/CaWindowData.h
index 44982ffe5e..da0e0753e9 100644
--- a/algo/ca/core/data/CaWindowData.h
+++ b/algo/ca/core/data/CaWindowData.h
@@ -14,8 +14,8 @@
 #include "CaGrid.h"
 #include "CaHit.h"
 #include "CaIteration.h"
-#include "CaMeasurementXy.h"
 #include "CaTrack.h"
+#include "KfMeasurementXy.h"
 
 #include <array>
 
@@ -156,10 +156,10 @@ namespace cbm::algo::ca
     [[gnu::always_inline]] const ca::FieldValue<fvec>& TargB() const { return fTargB; }
 
     /// \brief Measurement of the target with the uncertainty
-    [[gnu::always_inline]] ca::MeasurementXy<fvec>& TargetMeasurement() { return fTargetMeasurement; }
+    [[gnu::always_inline]] kf::MeasurementXy<fvec>& TargetMeasurement() { return fTargetMeasurement; }
 
     /// \brief Measurement of the target with the uncertainty
-    [[gnu::always_inline]] const ca::MeasurementXy<fvec>& TargetMeasurement() const { return fTargetMeasurement; }
+    [[gnu::always_inline]] const kf::MeasurementXy<fvec>& TargetMeasurement() const { return fTargetMeasurement; }
 
    private:
     static constexpr int kMaxNofStations = constants::size::MaxNstations;  ///< Alias to max number of stations
@@ -199,7 +199,7 @@ namespace cbm::algo::ca
     const Iteration* fpCurrentIteration = nullptr;
 
     ca::FieldValue<fvec> fTargB _fvecalignment{};  ///< field in the target point (modifiable, do not touch!!)
-    ca::MeasurementXy<fvec> fTargetMeasurement _fvecalignment{};  ///< target constraint
+    kf::MeasurementXy<fvec> fTargetMeasurement _fvecalignment{};  ///< target constraint
 
   } _fvecalignment;
 }  // namespace cbm::algo::ca
diff --git a/algo/ca/core/tracking/CaFramework.h b/algo/ca/core/tracking/CaFramework.h
index 7d88a50449..cf3e8d62fc 100644
--- a/algo/ca/core/tracking/CaFramework.h
+++ b/algo/ca/core/tracking/CaFramework.h
@@ -12,7 +12,6 @@
 #include "CaGridEntry.h"
 #include "CaHit.h"
 #include "CaInputData.h"
-#include "CaMeasurementXy.h"
 #include "CaParameters.h"
 #include "CaSimd.h"
 #include "CaStation.h"
diff --git a/algo/ca/core/tracking/CaTrackFit.cxx b/algo/ca/core/tracking/CaTrackFit.cxx
index 30d54421dd..8d6899a8ef 100644
--- a/algo/ca/core/tracking/CaTrackFit.cxx
+++ b/algo/ca/core/tracking/CaTrackFit.cxx
@@ -5,15 +5,15 @@
 #include "CaTrackFit.h"
 
 #include "CaHit.h"
-#include "CaMeasurementU.h"
-#include "CaMeasurementXy.h"
 #include "CaStation.h"
+#include "KfMeasurementU.h"
+#include "KfMeasurementXy.h"
 
 namespace cbm::algo::ca
 {
 
   template<typename DataT>
-  void TrackFit<DataT>::Filter1d(const ca::MeasurementU<DataT>& m)
+  void TrackFit<DataT>::Filter1d(const kf::MeasurementU<DataT>& m)
   {
     DataT zeta, HCH;
     DataT F0, F1, F2, F3, F4, F5, F6;
@@ -187,17 +187,17 @@ namespace cbm::algo::ca
 
 
   template<typename DataT>
-  void TrackFit<DataT>::FilterXY(const ca::MeasurementXy<DataT>& mxy, bool skipUnmeasuredCoordinates)
+  void TrackFit<DataT>::FilterXY(const kf::MeasurementXy<DataT>& mxy, bool skipUnmeasuredCoordinates)
   {
     {
-      ca::MeasurementU<DataT> mx;
+      kf::MeasurementU<DataT> mx;
       mx.SetCosPhi(DataT(1.));
       mx.SetSinPhi(DataT(0.));
       mx.SetU(mxy.X());
       mx.SetDu2(mxy.Dx2());
       mx.SetNdf(mxy.NdfX());
 
-      ca::MeasurementU<DataT> mu;
+      kf::MeasurementU<DataT> mu;
       mu.SetCosPhi(-mxy.Dxy() / mxy.Dx2());
       mu.SetSinPhi(DataT(1.));
       mu.SetU(mu.CosPhi() * mxy.X() + mxy.Y());
@@ -330,7 +330,7 @@ namespace cbm::algo::ca
   template<typename DataT>
   void TrackFit<DataT>::FilterHit(const ca::Hit& hit, const DataTmask& timeInfo)
   {
-    ca::MeasurementXy<DataT> m;
+    kf::MeasurementXy<DataT> m;
     m.SetDx2(hit.dX2());
     m.SetDy2(hit.dY2());
     m.SetDxy(hit.dXY());
@@ -343,7 +343,7 @@ namespace cbm::algo::ca
   }
 
   template<typename DataT>
-  void TrackFit<DataT>::FilterExtrapolatedXY(const ca::MeasurementXy<DataT>& m, DataT extrX, DataT extrY,
+  void TrackFit<DataT>::FilterExtrapolatedXY(const kf::MeasurementXy<DataT>& m, DataT extrX, DataT extrY,
                                              const std::array<DataT, TrackParamBase<DataT>::kNtrackParam>& Jx,
                                              const std::array<DataT, TrackParamBase<DataT>::kNtrackParam>& Jy)
   {
@@ -1217,7 +1217,7 @@ namespace cbm::algo::ca
 
 
   template<typename DataT>
-  void TrackFit<DataT>::FilterWithTargetAtLine(DataT targZ, const ca::MeasurementXy<DataT>& targXY,
+  void TrackFit<DataT>::FilterWithTargetAtLine(DataT targZ, const kf::MeasurementXy<DataT>& targXY,
                                                const ca::FieldRegion<DataT>& F)
   {
     // Add the target constraint to a straight line track
@@ -1324,7 +1324,7 @@ namespace cbm::algo::ca
 
 
   template<typename DataT>
-  std::tuple<DataT, DataT> TrackFit<DataT>::GetChi2XChi2U(ca::MeasurementXy<DataT> m, DataT x, DataT y, DataT C00,
+  std::tuple<DataT, DataT> TrackFit<DataT>::GetChi2XChi2U(kf::MeasurementXy<DataT> m, DataT x, DataT y, DataT C00,
                                                           DataT C10, DataT C11)
   {
 
diff --git a/algo/ca/core/tracking/CaTrackFit.h b/algo/ca/core/tracking/CaTrackFit.h
index dfff3a899c..de708c646f 100644
--- a/algo/ca/core/tracking/CaTrackFit.h
+++ b/algo/ca/core/tracking/CaTrackFit.h
@@ -11,10 +11,10 @@
 #pragma once  // include this header only once per compilation unit
 
 #include "CaField.h"
-#include "CaMeasurementTime.h"
-#include "CaMeasurementU.h"
-#include "CaMeasurementXy.h"
 #include "CaSimd.h"
+#include "KfMeasurementTime.h"
+#include "KfMeasurementU.h"
+#include "KfMeasurementXy.h"
 #include "KfTrackParam.h"
 #include "KfUtils.h"
 
@@ -100,16 +100,16 @@ namespace cbm::algo::ca
     DataT GetMaxExtrapolationStep() const { return fMaxExtraplationStep; }
 
     /// filter the track with the 1d measurement
-    void Filter1d(const ca::MeasurementU<DataT>& m);
+    void Filter1d(const kf::MeasurementU<DataT>& m);
 
     /// filter the track with the XY measurement
-    void FilterXY(const ca::MeasurementXy<DataT>& m, bool skipUnmeasuredCoordinates = false);
+    void FilterXY(const kf::MeasurementXy<DataT>& m, bool skipUnmeasuredCoordinates = false);
 
     /// filter the track with the time measurement
     void FilterTime(DataT t, DataT dt2, const DataTmask& m);
 
     /// filter the track with the time measurement
-    void FilterTime(MeasurementTime<DataT> mt) { FilterTime(mt.T(), mt.Dt2(), DataTmask(mt.NdfT() > DataT(0.))); }
+    void FilterTime(kf::MeasurementTime<DataT> mt) { FilterTime(mt.T(), mt.Dt2(), DataTmask(mt.NdfT() > DataT(0.))); }
 
     /// filter the track with the hit
     void FilterHit(const ca::Hit& h, const DataTmask& timeInfo);
@@ -176,7 +176,7 @@ namespace cbm::algo::ca
     /// \param extrY - extrapolated Y of the track
     /// \param Jx - Jacobian of the extrapolated X
     /// \param Jy - Jacobian of the extrapolated Y
-    void FilterExtrapolatedXY(const ca::MeasurementXy<DataT>& m, DataT extrX, DataT extrY,
+    void FilterExtrapolatedXY(const kf::MeasurementXy<DataT>& m, DataT extrX, DataT extrY,
                               const std::array<DataT, TrackParamBase<DataT>::kNtrackParam>& Jx,
                               const std::array<DataT, TrackParamBase<DataT>::kNtrackParam>& Jy);
 
@@ -196,7 +196,7 @@ namespace cbm::algo::ca
     DataT ExtrapolateLineDxy(DataT z_out) const;
 
     /// add target measuremet to the track using linearisation at a straight line
-    void FilterWithTargetAtLine(DataT targZ, const ca::MeasurementXy<DataT>& targXYInfo,
+    void FilterWithTargetAtLine(DataT targZ, const kf::MeasurementXy<DataT>& targXYInfo,
                                 const ca::FieldRegion<DataT>& F);
 
     /// \brief Approximate mean energy loss with Bethe-Bloch formula
@@ -223,7 +223,7 @@ namespace cbm::algo::ca
     /// \param C11 - track covariance C11
     /// \return pair of (chi^2_x, chi^2_u) components of the chi^2.
     ///         chi^2_u is calculated after track is fit to the X measurement
-    static std::tuple<DataT, DataT> GetChi2XChi2U(ca::MeasurementXy<DataT> m, DataT x, DataT y, DataT C00, DataT C10,
+    static std::tuple<DataT, DataT> GetChi2XChi2U(kf::MeasurementXy<DataT> m, DataT x, DataT y, DataT C00, DataT C10,
                                                   DataT C11);
 
     /// \brief fast guess of track parameterts based on its hits
diff --git a/algo/ca/core/tracking/CaTrackFitter.cxx b/algo/ca/core/tracking/CaTrackFitter.cxx
index b2cedb42f1..41afdee5b5 100644
--- a/algo/ca/core/tracking/CaTrackFitter.cxx
+++ b/algo/ca/core/tracking/CaTrackFitter.cxx
@@ -63,7 +63,7 @@ void TrackFitter::FitCaTracks(const ca::InputData& input, WindowData& wData)
 
   fvec x[constants::size::MaxNstations];                       // Hit position along the x-axis [cm]
   fvec y[constants::size::MaxNstations];                       // Hit position along the y-axis [cm]
-  ca::MeasurementXy<fvec> mxy[constants::size::MaxNstations];  // Covariance matrix for x,y
+  kf::MeasurementXy<fvec> mxy[constants::size::MaxNstations];  // Covariance matrix for x,y
 
   fvec z[constants::size::MaxNstations];  // Hit position along the z-axis (precised) [cm]
 
@@ -72,7 +72,7 @@ void TrackFitter::FitCaTracks(const ca::InputData& input, WindowData& wData)
 
   fvec x_first;
   fvec y_first;
-  ca::MeasurementXy<fvec> mxy_first;
+  kf::MeasurementXy<fvec> mxy_first;
 
   fvec time_first;
   fvec wtime_first;
@@ -80,7 +80,7 @@ void TrackFitter::FitCaTracks(const ca::InputData& input, WindowData& wData)
 
   fvec x_last;
   fvec y_last;
-  ca::MeasurementXy<fvec> mxy_last;
+  kf::MeasurementXy<fvec> mxy_last;
 
   fvec time_last;
   fvec wtime_last;
@@ -283,7 +283,7 @@ void TrackFitter::FitCaTracks(const ca::InputData& input, WindowData& wData)
       {
         fitpv.SetMask(fmask::One());
 
-        ca::MeasurementXy<fvec> vtxInfo = wData.TargetMeasurement();
+        kf::MeasurementXy<fvec> vtxInfo = wData.TargetMeasurement();
         vtxInfo.SetDx2(1.e-8);
         vtxInfo.SetDxy(0.);
         vtxInfo.SetDy2(1.e-8);
diff --git a/algo/ca/core/tracking/CaTripletConstructor.cxx b/algo/ca/core/tracking/CaTripletConstructor.cxx
index 9685e7e76a..04069c0e77 100644
--- a/algo/ca/core/tracking/CaTripletConstructor.cxx
+++ b/algo/ca/core/tracking/CaTripletConstructor.cxx
@@ -218,7 +218,7 @@ void TripletConstructor::FindDoublets(ca::TrackFit<fvec>& fit)
     fit.SetQp0(fvec(0.f));
 
     fvec z_2 = hitm.Z();
-    ca::MeasurementXy<fvec> m_2(hitm.X(), hitm.Y(), hitm.dX2(), hitm.dY2(), hitm.dXY(), fvec::One(), fvec::One());
+    kf::MeasurementXy<fvec> m_2(hitm.X(), hitm.Y(), hitm.dX2(), hitm.dY2(), hitm.dXY(), fvec::One(), fvec::One());
     fvec t_2   = hitm.T();
     fvec dt2_2 = hitm.dT2();
 
@@ -464,11 +464,11 @@ void TripletConstructor::FindTriplets()
 
     fscal x[NHits], y[NHits], z[NHits], t[NHits];
     fscal dt2[NHits];
-    ca::MeasurementXy<fvec> mxy[NHits];
+    kf::MeasurementXy<fvec> mxy[NHits];
 
     for (int ih = 0; ih < NHits; ++ih) {
       const ca::Hit& hit = frWData.Hit(iwhit[ih]);
-      mxy[ih] = ca::MeasurementXy<fvec>(hit.X(), hit.Y(), hit.dX2(), hit.dY2(), hit.dXY(), fvec::One(), fvec::One());
+      mxy[ih] = kf::MeasurementXy<fvec>(hit.X(), hit.Y(), hit.dX2(), hit.dY2(), hit.dXY(), fvec::One(), fvec::One());
 
       x[ih]   = hit.X();
       y[ih]   = hit.Y();
@@ -736,7 +736,7 @@ void TripletConstructor::CollectHits(Vector<ca::HitIndex_t>& collectedHits, ca::
     }
 
     // check chi2
-    ca::MeasurementXy<fvec> mxy(hit.X(), hit.Y(), hit.dX2(), hit.dY2(), hit.dXY(), fvec::One(), fvec::One());
+    kf::MeasurementXy<fvec> mxy(hit.X(), hit.Y(), hit.dX2(), hit.dY2(), hit.dXY(), fvec::One(), fvec::One());
 
     const fvec C10            = fit.ExtrapolateLineDxy(z);
     const auto [chi2x, chi2u] = ca::TrackFit<fvec>::GetChi2XChi2U(mxy, x, y, C00, C10, C11);
diff --git a/algo/kf/core/CMakeLists.txt b/algo/kf/core/CMakeLists.txt
index f412291aba..1d6b40765e 100644
--- a/algo/kf/core/CMakeLists.txt
+++ b/algo/kf/core/CMakeLists.txt
@@ -10,6 +10,9 @@ set(INCLUDE_DIRECTORIES
 set(SRCS 
   ${CMAKE_CURRENT_SOURCE_DIR}/KfFramework.cxx
   ${CMAKE_CURRENT_SOURCE_DIR}/data/KfTrackParam.cxx
+  ${CMAKE_CURRENT_SOURCE_DIR}/data/KfMeasurementU.cxx
+  ${CMAKE_CURRENT_SOURCE_DIR}/data/KfMeasurementXy.cxx
+  ${CMAKE_CURRENT_SOURCE_DIR}/data/KfMeasurementTime.cxx
   ${CMAKE_CURRENT_SOURCE_DIR}/geo/KfMaterialMap.cxx
   ${CMAKE_CURRENT_SOURCE_DIR}/geo/KfTarget.cxx
   ${CMAKE_CURRENT_SOURCE_DIR}/geo/KfField.cxx
@@ -68,6 +71,9 @@ install(
     KfFramework.h
     KfDefs.h
     data/KfTrackParam.h
+    data/KfMeasurementU.h
+    data/KfMeasurementXy.h
+    data/KfMeasurementTime.h
     geo/KfField.h
     geo/KfFieldRegion.h
     geo/KfFieldSlice.h
diff --git a/algo/ca/core/data/CaMeasurementTime.cxx b/algo/kf/core/data/KfMeasurementTime.cxx
similarity index 77%
rename from algo/ca/core/data/CaMeasurementTime.cxx
rename to algo/kf/core/data/KfMeasurementTime.cxx
index cf1e795ae5..132977f20b 100644
--- a/algo/ca/core/data/CaMeasurementTime.cxx
+++ b/algo/kf/core/data/KfMeasurementTime.cxx
@@ -2,15 +2,15 @@
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Sergey Gorbunov, Sergei Zharko [committer] */
 
-/// \file CaMeasurementTime.cxx
-/// \brief Implementation of the CaMeasurementTime class
+/// \file KfMeasurementTime.cxx
+/// \brief Implementation of the KfMeasurementTime class
 
-#include "CaMeasurementTime.h"
+#include "KfMeasurementTime.h"
 
 #include <iomanip>
 #include <sstream>  // for stringstream
 
-namespace cbm::algo::ca
+namespace cbm::algo::kf
 {
   //----------------------------------------------------------------------------------------------------------------------
   //
@@ -30,8 +30,8 @@ namespace cbm::algo::ca
   ///----------------------------------------------------------------------------------------------------------------------
   /// All necessary instantiations of the template class
 
-  template class cbm::algo::ca::MeasurementTime<fvec>;
-  template class cbm::algo::ca::MeasurementTime<float>;
-  template class cbm::algo::ca::MeasurementTime<double>;
+  template class MeasurementTime<fvec>;
+  template class MeasurementTime<float>;
+  template class MeasurementTime<double>;
 
-}  // namespace cbm::algo::ca
+}  // namespace cbm::algo::kf
diff --git a/algo/ca/core/data/CaMeasurementTime.h b/algo/kf/core/data/KfMeasurementTime.h
similarity index 87%
rename from algo/ca/core/data/CaMeasurementTime.h
rename to algo/kf/core/data/KfMeasurementTime.h
index dee2c3780a..10dd737115 100644
--- a/algo/ca/core/data/CaMeasurementTime.h
+++ b/algo/kf/core/data/KfMeasurementTime.h
@@ -2,20 +2,20 @@
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Sergey Gorbunov [committer], Sergei Zharko */
 
-/// \file CaMeasurementTime
-/// \brief Definition of the CaMeasurementTime class
+/// \file KfMeasurementTime
+/// \brief Definition of the KfMeasurementTime class
 
 #pragma once  // include this header only once per compilation unit
 
 
-#include "CaDefs.h"
-#include "CaSimd.h"
+#include "KfDefs.h"
+#include "KfUtils.h"
 
 #include <boost/serialization/access.hpp>
 
 #include <string>
 
-namespace cbm::algo::ca
+namespace cbm::algo::kf
 {
   /// \brief The class describes a time measurement
   ///
@@ -61,12 +61,12 @@ namespace cbm::algo::ca
     std::string ToString(int indentLevel = 0) const;
 
     /// Checks, if all fields are finite
-    bool IsFinite() const { return (kfutils::IsFinite(T()) && kfutils::IsFinite(Dt2()) && kfutils::IsFinite(NdfT())); }
+    bool IsFinite() const { return (utils::IsFinite(T()) && utils::IsFinite(Dt2()) && utils::IsFinite(NdfT())); }
 
     /// Checks, if some fields are undefined
     bool IsUndefined() const
     {
-      return (kfutils::IsUndefined(T()) || kfutils::IsUndefined(Dt2()) || kfutils::IsUndefined(NdfT()));
+      return (utils::IsUndefined(T()) || utils::IsUndefined(Dt2()) || utils::IsUndefined(NdfT()));
     }
 
     /// Serialization function
@@ -94,4 +94,4 @@ namespace cbm::algo::ca
 
   } _fvecalignment;
 
-}  // namespace cbm::algo::ca
+}  // namespace cbm::algo::kf
diff --git a/algo/ca/core/data/CaMeasurementU.cxx b/algo/kf/core/data/KfMeasurementU.cxx
similarity index 89%
rename from algo/ca/core/data/CaMeasurementU.cxx
rename to algo/kf/core/data/KfMeasurementU.cxx
index 05e72e07be..35434db5a7 100644
--- a/algo/ca/core/data/CaMeasurementU.cxx
+++ b/algo/kf/core/data/KfMeasurementU.cxx
@@ -2,15 +2,15 @@
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Sergey Gorbunov, Sergei Zharko [committer] */
 
-/// \file CaMeasurementU.cxx
-/// \brief Implementation of the CaMeasurementU class
+/// \file KfMeasurementU.cxx
+/// \brief Implementation of the KfMeasurementU class
 
-#include "CaMeasurementU.h"
+#include "KfMeasurementU.h"
 
 #include <iomanip>
 #include <sstream>
 
-namespace cbm::algo::ca
+namespace cbm::algo::kf
 {
 
   //----------------------------------------------------------------------------------------------------------------------
@@ -37,4 +37,4 @@ namespace cbm::algo::ca
   template class MeasurementU<float>;
   template class MeasurementU<double>;
 
-}  // namespace cbm::algo::ca
+}  // namespace cbm::algo::kf
diff --git a/algo/ca/core/data/CaMeasurementU.h b/algo/kf/core/data/KfMeasurementU.h
similarity index 79%
rename from algo/ca/core/data/CaMeasurementU.h
rename to algo/kf/core/data/KfMeasurementU.h
index f24ea6d1b1..01240db2f5 100644
--- a/algo/ca/core/data/CaMeasurementU.h
+++ b/algo/kf/core/data/KfMeasurementU.h
@@ -2,21 +2,20 @@
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Sergey Gorbunov [committer], Igor Kulakov, Sergei Zharko */
 
-/// \file CaMeasurementU
-/// \brief Definition of the CaMeasurementU class
+/// \file KfMeasurementU
+/// \brief Definition of the KfMeasurementU class
 
 #pragma once  // include this header only once per compilation unit
 
 
-#include "CaDefs.h"
-#include "CaSimd.h"
 #include "KfDefs.h"
+#include "KfUtils.h"
 
 #include <boost/serialization/access.hpp>
 
 #include <string>
 
-namespace cbm::algo::ca
+namespace cbm::algo::kf
 {
   /// \brief The class describes a 1D - measurement U in XY coordinate system
   ///
@@ -83,15 +82,15 @@ namespace cbm::algo::ca
     /// Checks, if all fields are finite
     bool IsFinite() const
     {
-      return (kfutils::IsFinite(CosPhi()) && kfutils::IsFinite(SinPhi()) && kfutils::IsFinite(U())
-              && kfutils::IsFinite(Du2()) && kfutils::IsFinite(Ndf()));
+      return (utils::IsFinite(CosPhi()) && utils::IsFinite(SinPhi()) && utils::IsFinite(U()) && utils::IsFinite(Du2())
+              && utils::IsFinite(Ndf()));
     }
 
     /// Checks, if some fields are undefined
     bool IsUndefined() const
     {
-      return (kfutils::IsUndefined(CosPhi()) || kfutils::IsUndefined(SinPhi()) || kfutils::IsUndefined(U())
-              || kfutils::IsUndefined(Du2()) || kfutils::IsUndefined(Ndf()));
+      return (utils::IsUndefined(CosPhi()) || utils::IsUndefined(SinPhi()) || utils::IsUndefined(U())
+              || utils::IsUndefined(Du2()) || utils::IsUndefined(Ndf()));
     }
 
     /// Serialization function
@@ -110,15 +109,15 @@ namespace cbm::algo::ca
     ///------------------------------
     /// Data members
 
-    DataT fCosPhi = kfdefs::Undef<DataT>;  ///< cos(phi)
-    DataT fSinPhi = kfdefs::Undef<DataT>;  ///< sin(phi)
-    DataT fU      = kfdefs::Undef<DataT>;  ///< measurement, u = x * cos(phi) + y * sin(phi)
-    DataT fDu2    = kfdefs::Undef<DataT>;  ///< rms^2 of the measurement
+    DataT fCosPhi = defs::Undef<DataT>;  ///< cos(phi)
+    DataT fSinPhi = defs::Undef<DataT>;  ///< sin(phi)
+    DataT fU      = defs::Undef<DataT>;  ///< measurement, u = x * cos(phi) + y * sin(phi)
+    DataT fDu2    = defs::Undef<DataT>;  ///< rms^2 of the measurement
 
     /// \brief number of degrees of freedom (used for chi2 calculation)
     /// if ndf == 1, the measurement is used in the chi2 calculation
     /// if ndf == 0, the measurement is not used in the chi2 calculation
-    DataT fNdf = kfdefs::Undef<DataT>;
+    DataT fNdf = defs::Undef<DataT>;
   } _fvecalignment;
 
-}  // namespace cbm::algo::ca
+}  // namespace cbm::algo::kf
diff --git a/algo/ca/core/data/CaMeasurementXy.cxx b/algo/kf/core/data/KfMeasurementXy.cxx
similarity index 90%
rename from algo/ca/core/data/CaMeasurementXy.cxx
rename to algo/kf/core/data/KfMeasurementXy.cxx
index ebd861fd38..36c123fd1d 100644
--- a/algo/ca/core/data/CaMeasurementXy.cxx
+++ b/algo/kf/core/data/KfMeasurementXy.cxx
@@ -2,15 +2,15 @@
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Sergey Gorbunov, Sergei Zharko [committer] */
 
-/// \file CaMeasurementXy.cxx
-/// \brief Implementation of the CaMeasurementXy class
+/// \file KfMeasurementXy.cxx
+/// \brief Implementation of the KfMeasurementXy class
 
-#include "CaMeasurementXy.h"
+#include "KfMeasurementXy.h"
 
 #include <iomanip>
 #include <sstream>  // for stringstream
 
-namespace cbm::algo::ca
+namespace cbm::algo::kf
 {
 
   //----------------------------------------------------------------------------------------------------------------------
@@ -39,4 +39,4 @@ namespace cbm::algo::ca
   template class MeasurementXy<float>;
   template class MeasurementXy<double>;
 
-}  // namespace cbm::algo::ca
+}  // namespace cbm::algo::kf
diff --git a/algo/ca/core/data/CaMeasurementXy.h b/algo/kf/core/data/KfMeasurementXy.h
similarity index 90%
rename from algo/ca/core/data/CaMeasurementXy.h
rename to algo/kf/core/data/KfMeasurementXy.h
index 11bc05905a..e01d160bbe 100644
--- a/algo/ca/core/data/CaMeasurementXy.h
+++ b/algo/kf/core/data/KfMeasurementXy.h
@@ -2,20 +2,20 @@
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Sergey Gorbunov [committer], Sergei Zharko */
 
-/// \file CaMeasurementXy.h
-/// \brief Definition of the CaMeasurementXy class
+/// \file KfMeasurementXy.h
+/// \brief Definition of the KfMeasurementXy class
 
 #pragma once  // include this header only once per compilation unit
 
 
-#include "CaDefs.h"
-#include "CaSimd.h"
+#include "KfDefs.h"
+#include "KfUtils.h"
 
 #include <boost/serialization/access.hpp>
 
 #include <string>
 
-namespace cbm::algo::ca
+namespace cbm::algo::kf
 {
   /// \brief The class describes a 2D - measurement (x, y) in XY coordinate system
   ///
@@ -131,16 +131,16 @@ namespace cbm::algo::ca
     /// Checks, if all fields are finite
     bool IsFinite() const
     {
-      return (kfutils::IsFinite(X()) && kfutils::IsFinite(Y()) && kfutils::IsFinite(Dx2()) && kfutils::IsFinite(Dy2())
-              && kfutils::IsFinite(Dxy()) && kfutils::IsFinite(NdfX()) && kfutils::IsFinite(NdfY()));
+      return (utils::IsFinite(X()) && utils::IsFinite(Y()) && utils::IsFinite(Dx2()) && utils::IsFinite(Dy2())
+              && utils::IsFinite(Dxy()) && utils::IsFinite(NdfX()) && utils::IsFinite(NdfY()));
     }
 
     /// Checks, if some fields are undefined
     bool IsUndefined() const
     {
-      return (kfutils::IsUndefined(X()) || kfutils::IsUndefined(Y()) || kfutils::IsUndefined(Dx2())
-              || kfutils::IsUndefined(Dy2()) || kfutils::IsUndefined(Dxy()) || kfutils::IsUndefined(NdfX())
-              || kfutils::IsUndefined(NdfY()));
+      return (utils::IsUndefined(X()) || utils::IsUndefined(Y()) || utils::IsUndefined(Dx2())
+              || utils::IsUndefined(Dy2()) || utils::IsUndefined(Dxy()) || utils::IsUndefined(NdfX())
+              || utils::IsUndefined(NdfY()));
     }
 
     /// Serialization function
@@ -200,7 +200,7 @@ namespace cbm::algo::ca
   inline void MeasurementXy<TdataA>::CopyBase(const int ia, const MeasurementXy<TdataB>& Tb, const int ib)
   {
     auto copy = [&](TdataA& a, const TdataB& b) {
-      kfutils::VecCopy<TdataA, TdataB, TDoAllA, TDoAllB>::CopyEntries(a, ia, b, ib);
+      utils::VecCopy<TdataA, TdataB, TDoAllA, TDoAllB>::CopyEntries(a, ia, b, ib);
     };
 
     copy(fX, Tb.X());
@@ -212,4 +212,4 @@ namespace cbm::algo::ca
     copy(fNdfY, Tb.NdfY());
   }  // CopyBase
 
-}  // namespace cbm::algo::ca
+}  // namespace cbm::algo::kf
diff --git a/reco/KF/CbmKfTrackFitter.h b/reco/KF/CbmKfTrackFitter.h
index 10f562aac2..b7281881c9 100644
--- a/reco/KF/CbmKfTrackFitter.h
+++ b/reco/KF/CbmKfTrackFitter.h
@@ -6,11 +6,11 @@
 
 
 #include "CaDefs.h"
-#include "CaMeasurementTime.h"
-#include "CaMeasurementXy.h"
 #include "CaSimd.h"
 #include "CaTrackFit.h"
 #include "CbmDefs.h"
+#include "KfMeasurementTime.h"
+#include "KfMeasurementXy.h"
 #include "KfTrackParam.h"
 
 #include <vector>
@@ -69,9 +69,9 @@ class CbmKfTrackFitter {
 
     /// == Hit information ( if present )
 
-    ca::MeasurementXy<double> fMxy{};  ///< XY-measurement at fZ
+    kf::MeasurementXy<double> fMxy{};  ///< XY-measurement at fZ
 
-    ca::MeasurementTime<double> fMt{};  ///< time measurement at fZ
+    kf::MeasurementTime<double> fMt{};  ///< time measurement at fZ
 
     /// == Flags etc
     bool fIsXySet{false};          ///< true if the XY measurement is set
diff --git a/reco/KF/ParticleFitter/CbmL1PFFitter.cxx b/reco/KF/ParticleFitter/CbmL1PFFitter.cxx
index e7945c93bf..288c725b0d 100644
--- a/reco/KF/ParticleFitter/CbmL1PFFitter.cxx
+++ b/reco/KF/ParticleFitter/CbmL1PFFitter.cxx
@@ -150,7 +150,7 @@ inline int CbmL1PFFitter::GetStsStationIndex(const CbmStsHit* hit)
 }
 
 
-void FilterFirst(ca::TrackFit<fvec>& fit, ca::MeasurementXy<fvec>& mxy, fvec& t, fvec& dt2)
+void FilterFirst(ca::TrackFit<fvec>& fit, kf::MeasurementXy<fvec>& mxy, fvec& t, fvec& dt2)
 {
   TrackParamV& tr = fit.Tr();
   tr.ResetErrors(mxy.Dx2(), mxy.Dy2(), 1., 1., 1., dt2, 1.e2);
@@ -190,13 +190,13 @@ void CbmL1PFFitter::Fit(std::vector<CbmStsTrack>& Tracks, const std::vector<CbmM
   fvec y[nHits];
   fvec z[nHits];
   fvec t[nHits];
-  ca::MeasurementXy<fvec> mxy[nHits];
+  kf::MeasurementXy<fvec> mxy[nHits];
   fvec dt2[nHits];
   fmask w[nHits];
 
   //  fvec y_temp;
   fvec x_first, y_first, t_first, x_last, y_last, t_last;
-  ca::MeasurementXy<fvec> mxy_first, mxy_last;
+  kf::MeasurementXy<fvec> mxy_first, mxy_last;
   fvec dt2_first, dt2_last;
 
   fvec z0, z1, z2, dz, z_start, z_end;
-- 
GitLab