From 842def424bc87e1c53d366301560e204302beebc Mon Sep 17 00:00:00 2001
From: "s.zharko@gsi.de" <s.zharko@gsi.de>
Date: Thu, 14 Sep 2023 13:43:34 +0200
Subject: [PATCH] CA-Online:

- Added new library CaCore in cbmroot/algo/ca/core, where the code from cbmroot/reco/L1/L1Algo will be iteratively moved
---
 algo/CMakeLists.txt                     | 17 +++++-
 algo/ca/CMakeLists.txt                  |  4 ++
 algo/ca/TrackingChain.cxx               | 29 ++++++++++
 algo/ca/TrackingChain.h                 | 43 ++++++++++++++
 algo/ca/core/CMakeLists.txt             | 43 ++++++++++++++
 algo/ca/core/CaTrackingDemo.cxx         | 27 +++++++++
 algo/ca/core/CaTrackingDemo.h           | 43 ++++++++++++++
 algo/ca/core/data/CaTrack.h             | 75 +++++++++++++++++++++++++
 algo/ca/{ => core}/simd/CaSimd.h        |  0
 algo/ca/{ => core}/simd/CaSimdPseudo.h  |  0
 algo/ca/{ => core}/simd/CaSimdVc.h      |  0
 algo/global/RecoResults.h               |  5 ++
 reco/L1/CMakeLists.txt                  |  4 +-
 reco/L1/CbmL1.cxx                       |  5 +-
 reco/L1/L1Algo/L1Algo.h                 |  7 ++-
 reco/L1/L1Algo/L1BranchExtender.cxx     |  2 +-
 reco/L1/L1Algo/L1CaTrackFinder.cxx      |  6 +-
 reco/L1/L1Algo/L1CaTrackFinderSlice.cxx |  6 +-
 reco/L1/L1Algo/L1CloneMerger.cxx        |  6 +-
 reco/L1/L1Algo/L1CloneMerger.h          | 10 +++-
 reco/L1/L1Algo/L1Track.h                | 46 ---------------
 reco/L1/L1Algo/L1TrackFitter.cxx        |  4 +-
 reco/L1/L1Algo/utils/L1AlgoDraw.cxx     |  5 +-
 reco/detectors/trd/CbmTrdDigiRec.h      |  2 +
 reco/littrack/parallel/CMakeLists.txt   |  2 +-
 25 files changed, 318 insertions(+), 73 deletions(-)
 create mode 100644 algo/ca/CMakeLists.txt
 create mode 100644 algo/ca/TrackingChain.cxx
 create mode 100644 algo/ca/TrackingChain.h
 create mode 100644 algo/ca/core/CMakeLists.txt
 create mode 100644 algo/ca/core/CaTrackingDemo.cxx
 create mode 100644 algo/ca/core/CaTrackingDemo.h
 create mode 100644 algo/ca/core/data/CaTrack.h
 rename algo/ca/{ => core}/simd/CaSimd.h (100%)
 rename algo/ca/{ => core}/simd/CaSimdPseudo.h (100%)
 rename algo/ca/{ => core}/simd/CaSimdVc.h (100%)
 delete mode 100644 reco/L1/L1Algo/L1Track.h

diff --git a/algo/CMakeLists.txt b/algo/CMakeLists.txt
index 1deebb47ba..c704904a9c 100644
--- a/algo/CMakeLists.txt
+++ b/algo/CMakeLists.txt
@@ -1,6 +1,7 @@
 add_subdirectory(log)
 add_subdirectory(data)
 add_subdirectory(test)
+add_subdirectory(ca)
 
 set(DEVICE_SRCS
   base/gpu/DeviceImage.cxx
@@ -48,6 +49,7 @@ set(SRCS
   global/Reco.cxx
   qa/DigiEventQa.cxx
   qa/Histo1D.cxx
+  ca/TrackingChain.cxx
 )
 
 set(BUILD_INFO_CXX ${CMAKE_CURRENT_BINARY_DIR}/base/BuildInfo.cxx)
@@ -79,12 +81,17 @@ target_include_directories(Algo
          ${CMAKE_CURRENT_SOURCE_DIR}/unpack
          ${CMAKE_CURRENT_SOURCE_DIR}/detectors
          ${CMAKE_CURRENT_SOURCE_DIR}/qa
+         ${CMAKE_CURRENT_SOURCE_DIR}/ca
+         ${CMAKE_CURRENT_SOURCE_DIR}/ca/core
+         ${CMAKE_CURRENT_SOURCE_DIR}/ca/core/data
+         ${CMAKE_CURRENT_SOURCE_DIR}/ca/core/simd
          ${CMAKE_CURRENT_SOURCE_DIR}
          ${CMAKE_SOURCE_DIR}/core/data/global
 )
 
 target_link_libraries(Algo
   PUBLIC    OnlineData
+            CaCore
             ROOT::GenVector
             GSL
             fmt::fmt
@@ -127,6 +134,8 @@ install(DIRECTORY detectors/sts TYPE INCLUDE FILES_MATCHING PATTERN "*.h")
 install(DIRECTORY detectors/tof TYPE INCLUDE FILES_MATCHING PATTERN "*.h")
 install(DIRECTORY detectors/trd TYPE INCLUDE FILES_MATCHING PATTERN "*.h")
 install(DIRECTORY detectors/trd2d TYPE INCLUDE FILES_MATCHING PATTERN "*.h")
+install(DIRECTORY ca TYPE INCLUDE FILES_MATCHING PATTERN "*.h")
+#install(DIRECTORY ca/data TYPE INCLUDE FILES_MATCHING PATTERN "*.h")
 
 
 install(
@@ -136,9 +145,11 @@ install(
     base/Options.h
     base/RecoParams.h
     base/SubChain.h
-    ca/simd/CaSimd.h
-    ca/simd/CaSimdVc.h
-    ca/simd/CaSimdPseudo.h
+    ca/TrackingChain.h
+    #ca/simd/CaSimd.h
+    #ca/simd/CaSimdVc.h
+    #ca/simd/CaSimdPseudo.h
+    #ca/data/CaTrack.h
     global/Reco.h
   DESTINATION
     include/
diff --git a/algo/ca/CMakeLists.txt b/algo/ca/CMakeLists.txt
new file mode 100644
index 0000000000..aaadd1cd0e
--- /dev/null
+++ b/algo/ca/CMakeLists.txt
@@ -0,0 +1,4 @@
+add_subdirectory(core) # libCaCore.so
+
+
+
diff --git a/algo/ca/TrackingChain.cxx b/algo/ca/TrackingChain.cxx
new file mode 100644
index 0000000000..cff605438b
--- /dev/null
+++ b/algo/ca/TrackingChain.cxx
@@ -0,0 +1,29 @@
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Sergei Zharko [committer] */
+
+/// @file   TrackingChain.cxx
+/// @date   14.09.2023
+/// @brief  A chain class to execute CA tracking algorithm in online reconstruction (implementation)
+/// @author S.Zharko <s.zharko@gsi.de>
+
+#include "TrackingChain.h"
+
+using cbm::algo::TrackingChain;
+using cbm::algo::ca::Track;
+
+// ---------------------------------------------------------------------------------------------------------------------
+//
+void TrackingChain::Init() { fTracking.Init(); }
+
+// ---------------------------------------------------------------------------------------------------------------------
+//
+std::vector<Track> TrackingChain::Run(const RecoResults& recoResults)
+{
+  std::vector<Track> vRecoTracks;
+  return vRecoTracks;
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+//
+void TrackingChain::Finalize() {}
diff --git a/algo/ca/TrackingChain.h b/algo/ca/TrackingChain.h
new file mode 100644
index 0000000000..bb91baa15d
--- /dev/null
+++ b/algo/ca/TrackingChain.h
@@ -0,0 +1,43 @@
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Sergei Zharko [committer] */
+
+/// @file   TrackingChain.h
+/// @date   13.09.2023
+/// @brief  A chain class to execute CA tracking algorithm in online reconstruction (header)
+/// @author S.Zharko <s.zharko@gsi.de>
+
+#ifndef CBM_ALGO_CA_TRACKING_CHAIN
+#define CBM_ALGO_CA_TRACKING_CHAIN 1
+
+#include <vector>
+
+#include "CaTrack.h"
+#include "CaTrackingDemo.h"
+#include "RecoResults.h"
+#include "SubChain.h"
+
+namespace cbm::algo
+{
+  /// @class cbm::algo::TrackingChain
+  /// @brief A chain for tracking algorithm
+  ///
+  /// The class executes a tracking algorithm in the online data reconstruction chain.
+  class TrackingChain : public SubChain {
+  public:
+    /// @brief  Provides action in the initialization of the run
+    void Init();
+
+    /// @brief  Provides action for a given time-slice
+    /// @return A vector of cbm::algo::ca::Track
+    std::vector<ca::Track> Run(const RecoResults& recoResults);
+
+    /// @brief  Provides action in the end of the run
+    void Finalize();
+
+  private:
+    ca::TrackingDemo fTracking;  ///< Tracking algorithm
+  };
+}  // namespace cbm::algo
+
+#endif  // CBM_ALGO_CA_TRACKING_CHAIN
diff --git a/algo/ca/core/CMakeLists.txt b/algo/ca/core/CMakeLists.txt
new file mode 100644
index 0000000000..fcf22148e0
--- /dev/null
+++ b/algo/ca/core/CMakeLists.txt
@@ -0,0 +1,43 @@
+set(INCLUDE_DIRECTORIES
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  ${CMAKE_CURRENT_SOURCE_DIR}/simd
+  ${CMAKE_CURRENT_SOURCE_DIR}/data
+)
+
+set(SRCS
+  ${CMAKE_CURRENT_SOURCE_DIR}/CaTrackingDemo.cxx
+)
+
+add_library(CaCore SHARED ${SRCS})
+
+target_include_directories(CaCore
+  PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/data
+         ${CMAKE_CURRENT_SOURCE_DIR}/simd
+         ${CMAKE_CURRENT_SOURCE_DIR}
+)
+
+target_compile_definitions(CaCore PUBLIC NO_ROOT)
+target_link_libraries(CaCore
+                      OnlineDataLog
+                      external::fles_ipc
+                      xpu
+                      Boost::serialization
+                      external::yaml-cpp
+                      external::fles_logging
+                     )
+
+install(TARGETS CaCore DESTINATION lib)
+install(DIRECTORY simd TYPE INCLUDE FILES_MATCHING PATTERN "*.h")
+install(DIRECTORY data TYPE INCLUDE FILES_MATCHING PATTERN "*.h")
+
+install(
+  FILES
+    CaTrackingDemo.h
+    data/CaTrack.h
+    simd/CaSimd.h
+    simd/CaSimdVc.h
+    simd/CaSimdPseudo.h
+  DESTINATION
+    include/
+)
+
diff --git a/algo/ca/core/CaTrackingDemo.cxx b/algo/ca/core/CaTrackingDemo.cxx
new file mode 100644
index 0000000000..b1fd5dac4a
--- /dev/null
+++ b/algo/ca/core/CaTrackingDemo.cxx
@@ -0,0 +1,27 @@
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Sergei Zharko [committer] */
+
+/// @file   CaTrackingDemo.h
+/// @date   14.09.2023
+/// @brief  A demonstration dummy class for tracking algorithm (implementation)
+/// @author S.Zharko <s.zharko@gsi.de>
+
+#include "CaTrackingDemo.h"
+
+#include "log.hpp"
+
+using cbm::algo::ca::TrackingDemo;
+using cbm::algo::ca::TrackingMonitorData;
+
+// ---------------------------------------------------------------------------------------------------------------------
+//
+void TrackingDemo::Init() { L_(info) << "TrackingDemo::Init is called"; }
+
+// ---------------------------------------------------------------------------------------------------------------------
+//
+void TrackingDemo::Execute() {}
+
+// ---------------------------------------------------------------------------------------------------------------------
+//
+void TrackingDemo::Finilize() {}
diff --git a/algo/ca/core/CaTrackingDemo.h b/algo/ca/core/CaTrackingDemo.h
new file mode 100644
index 0000000000..ba84ee6313
--- /dev/null
+++ b/algo/ca/core/CaTrackingDemo.h
@@ -0,0 +1,43 @@
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Sergei Zharko [committer] */
+
+/// @file   CaTrackingDemo.h
+/// @date   13.09.2023
+/// @brief  A demonstration dummy class for tracking algorithm (header)
+/// @author S.Zharko <s.zharko@gsi.de>
+
+#ifndef CBM_ALGO_CA_TRACKING_DEMO
+#define CBM_ALGO_CA_TRACKING_DEMO 1
+
+#include <sstream>
+#include <utility>
+
+namespace cbm::algo::ca
+{
+  /// @struct cbm::algo::ca::TrackingMonitorData
+  /// @brief  Monitor class for tracking
+  struct TrackingMonitorData {
+    int fNumHits   = 0;
+    int fNumTracks = 0;
+    std::string print() const
+    {
+      std::stringstream msg;
+      msg << "Tracking statistics: \n";
+      msg << "\t- number of hits:   " << fNumHits << '\n';
+      msg << "\t- number of tracks: " << fNumTracks;
+      return msg.str();
+    }
+  };
+
+  /// @class cbm::algo::ca::TrackingDemo
+  /// @brief Dummy tracking class to address all the needs for the CA tracking execution [to be replaced later]
+  class TrackingDemo {
+  public:
+    void Init();
+    void Execute();
+    void Finilize();
+  };
+}  // namespace cbm::algo::ca
+
+#endif  // CBM_ALGO_CA_TRACKING_DEMO
diff --git a/algo/ca/core/data/CaTrack.h b/algo/ca/core/data/CaTrack.h
new file mode 100644
index 0000000000..3c8520b4ac
--- /dev/null
+++ b/algo/ca/core/data/CaTrack.h
@@ -0,0 +1,75 @@
+/* Copyright (C) 2010-2023 Frankfurt Institute for Advanced Studies, Goethe-Universitaet Frankfurt, Frankfurt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Ivan Kisel,  Sergey Gorbunov, Maksym Zyzak, Igor Kulakov [committer], Sergei Zharko */
+
+/*
+ *====================================================================
+ *
+ *  CBM Level 1 Reconstruction 
+ *  
+ *  Authors: I.Kisel,  S.Gorbunov
+ *
+ *  e-mail : ikisel@kip.uni-heidelberg.de 
+ *
+ *====================================================================
+ *
+ *  L1 track class
+ *
+ *====================================================================
+ */
+
+#ifndef CBM_ALGO_CA_TRACK
+#define CBM_ALGO_CA_TRACK 1
+
+#include <boost/serialization/access.hpp>
+
+#include <limits>
+
+namespace cbm::algo::ca
+{
+  /// @class cbm::algo::ca::Track
+  /// @brief Class representing a track in the L1 tracking algorithm
+  ///
+  /// Track parameters vector: {x, y, tx, ty, q/p, z, t}
+  /// Covariation matrix: C[20] (C55) corresponds to the time variance
+  ///
+  class Track {
+  public:
+    using fscal = float;
+    static constexpr float kNaN {std::numeric_limits<float>::signaling_NaN()};
+    static constexpr int kNparTr {8};
+    static constexpr int kNparCov {28};
+
+    // TODO: SZh. 14.09.2023: Replace with std::array
+    unsigned char NHits {0};        ///< Number of hits in track
+    fscal TFirst[kNparTr] {kNaN};   ///< Track parameters on the first station
+    fscal CFirst[kNparCov] {kNaN};  ///< Track parameter covariation matrix elements on the first station
+    fscal TLast[kNparTr] {kNaN};    ///< Track parameters on the last station
+    fscal CLast[kNparCov] {kNaN};   ///< Track parameter covariation matrix elements on the second station
+    fscal Tpv[kNparTr] {kNaN};      ///< Track parameters in the primary vertex
+    fscal Cpv[kNparCov] {kNaN};     ///< Track parameter covariation matrix elements in the primary vertex
+    fscal chi2 {kNaN};              ///< Track fit chi-square value
+    short int NDF {0};              ///< Track fit NDF value
+
+    friend class boost::serialization::access;
+    template<class Archive>
+    void serialize(Archive& ar, const unsigned int /*version*/)
+    {
+      ar& NHits;
+      for (int i = 0; i < kNparTr; ++i) {
+        ar& TFirst[i];
+        ar& TLast[i];
+        ar& Tpv[i];
+      }
+      for (int i = 0; i < kNparCov; ++i) {
+        ar& CFirst[i];
+        ar& CLast[i];
+        ar& Cpv[i];
+      }
+      ar& chi2;
+      ar& NDF;
+    }
+  };
+}  // namespace cbm::algo::ca
+
+#endif  // CBM_ALGO_CA_TRACK
diff --git a/algo/ca/simd/CaSimd.h b/algo/ca/core/simd/CaSimd.h
similarity index 100%
rename from algo/ca/simd/CaSimd.h
rename to algo/ca/core/simd/CaSimd.h
diff --git a/algo/ca/simd/CaSimdPseudo.h b/algo/ca/core/simd/CaSimdPseudo.h
similarity index 100%
rename from algo/ca/simd/CaSimdPseudo.h
rename to algo/ca/core/simd/CaSimdPseudo.h
diff --git a/algo/ca/simd/CaSimdVc.h b/algo/ca/core/simd/CaSimdVc.h
similarity index 100%
rename from algo/ca/simd/CaSimdVc.h
rename to algo/ca/core/simd/CaSimdVc.h
diff --git a/algo/global/RecoResults.h b/algo/global/RecoResults.h
index 95e6c06772..86de0d0ebe 100644
--- a/algo/global/RecoResults.h
+++ b/algo/global/RecoResults.h
@@ -8,6 +8,7 @@
 
 #include <vector>
 
+#include "CaTrack.h"
 #include "RecoResultsDescriptor.h"
 
 class CbmStsDigi;
@@ -29,10 +30,13 @@ namespace cbm::algo
     const RecoResultsDescriptor& Descriptor() const { return fDescriptor; }
     const std::vector<CbmDigiEvent>& Events() const { return fEvents; }
     std::vector<CbmDigiEvent>& Events() { return fEvents; }
+    const std::vector<ca::Track>& Tracks() const { return fTracks; }
+    std::vector<ca::Track>& Tracks() { return fTracks; }
 
   private:
     RecoResultsDescriptor fDescriptor;
     std::vector<CbmDigiEvent> fEvents;
+    std::vector<ca::Track> fTracks;
 
     friend class boost::serialization::access;
 
@@ -42,6 +46,7 @@ namespace cbm::algo
     void serialize(Archive& ar, const unsigned int /*version*/)
     {
       ar& fEvents;
+      ar& fTracks;
     }
   };
 }  // namespace cbm::algo
diff --git a/reco/L1/CMakeLists.txt b/reco/L1/CMakeLists.txt
index f13f88b3ac..1150d541a7 100644
--- a/reco/L1/CMakeLists.txt
+++ b/reco/L1/CMakeLists.txt
@@ -9,8 +9,6 @@
 ADD_DEFINITIONS(-DDO_TPCCATRACKER_EFF_PERFORMANCE -DNonhomogeneousField -DCBM -DUSE_TIMERS)
 
 set(INCLUDE_DIRECTORIES
-  ${CMAKE_SOURCE_DIR}/algo/ca
-  ${CMAKE_SOURCE_DIR}/algo/ca/simd
   ${CMAKE_CURRENT_SOURCE_DIR}
   ${CMAKE_CURRENT_SOURCE_DIR}/L1Algo
   ${CMAKE_CURRENT_SOURCE_DIR}/OffLineInterface
@@ -164,6 +162,7 @@ ENDIF(SSE_FOUND)
 set(LIBRARY_NAME L1)
 set(LINKDEF ${LIBRARY_NAME}LinkDef.h)
 set(PUBLIC_DEPENDENCIES
+  CaCore
   CbmBase
   CbmData
   CbmQaBase
@@ -216,7 +215,6 @@ install(FILES CbmL1Counters.h
   L1Algo/L1Utils.h
   L1Algo/L1SimdSerializer.h
   L1Algo/L1TrackPar.h
-  L1Algo/L1Track.h
   utils/CbmCaIdealHitProducer.h
   utils/CbmCaIdealHitProducerDet.h
   L1Algo/utils/CaUvConverter.h
diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx
index 5113d5e38d..21a76099e3 100644
--- a/reco/L1/CbmL1.cxx
+++ b/reco/L1/CbmL1.cxx
@@ -74,6 +74,7 @@
 using std::cout;
 using std::endl;
 using std::ios;
+using CaTrack = cbm::algo::ca::Track;
 
 ClassImp(CbmL1);
 
@@ -767,7 +768,7 @@ void CbmL1::Reconstruct(CbmEvent* event)
 
   int trackFirstHit = 0;
 
-  for (L1Vector<L1Track>::iterator it = fpAlgo->fRecoTracks.begin(); it != fpAlgo->fRecoTracks.end();
+  for (L1Vector<CaTrack>::iterator it = fpAlgo->fRecoTracks.begin(); it != fpAlgo->fRecoTracks.end();
        trackFirstHit += it->NHits, it++) {
 
     CbmL1Track t;
@@ -1020,7 +1021,7 @@ void CbmL1::IdealTrackFinder()
 
     if (MC.Hits.size() < 4) continue;
 
-    L1Track algoTr;
+    CaTrack algoTr;
     algoTr.NHits = 0;
 
     L1Vector<int> hitIndices("CbmL1::hitIndices", fpAlgo->GetParameters()->GetNstationsActive(), -1);
diff --git a/reco/L1/L1Algo/L1Algo.h b/reco/L1/L1Algo/L1Algo.h
index d54967897f..f74298118a 100644
--- a/reco/L1/L1Algo/L1Algo.h
+++ b/reco/L1/L1Algo/L1Algo.h
@@ -28,6 +28,7 @@ class L1AlgoDraw;
 #include <limits>
 #include <map>
 
+#include "CaTrack.h"
 #include "L1Branch.h"
 #include "L1CloneMerger.h"
 #include "L1Field.h"
@@ -38,7 +39,6 @@ class L1AlgoDraw;
 #include "L1InputData.h"
 #include "L1Parameters.h"
 #include "L1Station.h"
-#include "L1Track.h"
 #include "L1TrackPar.h"
 #include "L1Triplet.h"
 #include "L1Utils.h"
@@ -291,10 +291,11 @@ public:
 
   double fCaRecoTime {0.};  // time of the track finder + fitter
 
-  L1Vector<L1Track> fRecoTracks {"L1Algo::fRecoTracks"};   ///< reconstructed tracks
+  L1Vector<cbm::algo::ca::Track> fRecoTracks {"L1Algo::fRecoTracks"};  ///< reconstructed tracks
   L1Vector<L1HitIndex_t> fRecoHits {"L1Algo::fRecoHits"};  ///< packed hits of reconstructed tracks
 
-  L1Vector<L1Track> fSliceRecoTracks {"L1Algo::fSliceRecoTracks"};   ///< reconstructed tracks in sub-timeslice
+  L1Vector<cbm::algo::ca::Track> fSliceRecoTracks {
+    "L1Algo::fSliceRecoTracks"};                                     ///< reconstructed tracks in sub-timeslice
   L1Vector<L1HitIndex_t> fSliceRecoHits {"L1Algo::fSliceRecoHits"};  ///< packed hits of reconstructed tracks
 
   /// Created triplets vs station index
diff --git a/reco/L1/L1Algo/L1BranchExtender.cxx b/reco/L1/L1Algo/L1BranchExtender.cxx
index d30eac5083..42dc1bbb07 100644
--- a/reco/L1/L1Algo/L1BranchExtender.cxx
+++ b/reco/L1/L1Algo/L1BranchExtender.cxx
@@ -4,11 +4,11 @@
 
 #include <iostream>
 
+#include "CaTrack.h"
 #include "L1Algo.h"
 #include "L1Branch.h"
 #include "L1HitArea.h"
 #include "L1HitPoint.h"
-#include "L1Track.h"
 #include "L1TrackPar.h"
 
 // using namespace std;
diff --git a/reco/L1/L1Algo/L1CaTrackFinder.cxx b/reco/L1/L1Algo/L1CaTrackFinder.cxx
index 4d6e49acfa..c4e0841016 100644
--- a/reco/L1/L1Algo/L1CaTrackFinder.cxx
+++ b/reco/L1/L1Algo/L1CaTrackFinder.cxx
@@ -20,8 +20,10 @@
 
 #include <chrono>
 
+#include "CaTrack.h"
 #include "L1Algo.h"
-#include "L1Track.h"
+
+using Track = cbm::algo::ca::Track;
 
 void L1Algo::CaTrackFinder()
 {
@@ -178,7 +180,7 @@ void L1Algo::CaTrackFinder()
     // TODO: only add those hits from the region before tsStartNew that belong to the not stored tracks
 
     int trackFirstHit = 0;
-    for (L1Vector<L1Track>::iterator it = fSliceRecoTracks.begin(); it != fSliceRecoTracks.end();
+    for (L1Vector<Track>::iterator it = fSliceRecoTracks.begin(); it != fSliceRecoTracks.end();
          trackFirstHit += it->NHits, it++) {
 
       bool isTrackCompletelyInOverlap = true;
diff --git a/reco/L1/L1Algo/L1CaTrackFinderSlice.cxx b/reco/L1/L1Algo/L1CaTrackFinderSlice.cxx
index 504e7d8f65..42ed8f1e5a 100644
--- a/reco/L1/L1Algo/L1CaTrackFinderSlice.cxx
+++ b/reco/L1/L1Algo/L1CaTrackFinderSlice.cxx
@@ -22,6 +22,7 @@
 #include "CbmL1.h"
 #include "CbmL1MCTrack.h"
 
+#include "CaTrack.h"
 #include "L1Algo.h"
 #include "L1Assert.h"
 #include "L1Branch.h"
@@ -29,7 +30,6 @@
 #include "L1Grid.h"
 #include "L1HitArea.h"
 #include "L1HitPoint.h"
-#include "L1Track.h"
 #include "L1TrackPar.h"
 #include "L1TripletConstructor.h"
 #ifdef DRAW
@@ -59,7 +59,7 @@
 // using namespace std;
 using std::cout;
 using std::endl;
-
+using Track = cbm::algo::ca::Track;
 
 bool L1Algo::checkTripletMatch(const L1Triplet& l, const L1Triplet& r, fscal& dchi2) const
 {
@@ -664,7 +664,7 @@ void L1Algo::CaTrackFinderSlice()
           fscal timeFlight = sqrt(dx * dx + dy * dy + dz * dz) / 30.f;  // c = 30[cm/ns]
           sumTime += (hit.t - timeFlight);
         }
-        L1Track t;
+        Track t;
         t.NHits = tr.NHits;
         fSliceRecoTracks.push_back(t);
         if (0) {  // SG debug
diff --git a/reco/L1/L1Algo/L1CloneMerger.cxx b/reco/L1/L1Algo/L1CloneMerger.cxx
index 82ed524da5..d4346f0cb6 100644
--- a/reco/L1/L1Algo/L1CloneMerger.cxx
+++ b/reco/L1/L1Algo/L1CloneMerger.cxx
@@ -11,10 +11,12 @@
 
 #include <iostream>
 
+#include "CaTrack.h"
 #include "L1Algo.h"
 #include "L1Fit.h"
 #include "L1Parameters.h"
-#include "L1Track.h"
+
+using Track = cbm::algo::ca::Track;
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
@@ -26,7 +28,7 @@ L1CloneMerger::~L1CloneMerger() {}
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
-void L1CloneMerger::Exec(L1Vector<L1Track>& extTracks, L1Vector<L1HitIndex_t>& extRecoHits)
+void L1CloneMerger::Exec(L1Vector<Track>& extTracks, L1Vector<L1HitIndex_t>& extRecoHits)
 {
   L1Vector<unsigned short>& firstStation = fTrackFirstStation;
   L1Vector<unsigned short>& lastStation  = fTrackLastStation;
diff --git a/reco/L1/L1Algo/L1CloneMerger.h b/reco/L1/L1Algo/L1CloneMerger.h
index 6fd847adc2..8f75a2a2e1 100644
--- a/reco/L1/L1Algo/L1CloneMerger.h
+++ b/reco/L1/L1Algo/L1CloneMerger.h
@@ -14,7 +14,11 @@
 #include "L1Hit.h"  // For L1HitIndex_t
 #include "L1Vector.h"
 
-class L1Track;
+namespace cbm::algo::ca
+{
+  class Track;
+}
+
 class L1Algo;
 
 /// Class implements a clones merger algorithm for the CA (L1) track finder
@@ -44,7 +48,7 @@ public:
   /// Executes track clones merging algorithm and updates input containers
   /// \param  extTracks   Reference to the external container of reconstructed tracks
   /// \param  extRecoHits Reference to the external container of reconstructed hit indexes
-  void Exec(L1Vector<L1Track>& extTracks, L1Vector<L1HitIndex_t>&);
+  void Exec(L1Vector<cbm::algo::ca::Track>& extTracks, L1Vector<L1HitIndex_t>&);
 
 private:
   // ***************
@@ -109,7 +113,7 @@ private:
   /// Flag: is the track a downstream neighbour of another track
   L1Vector<char> fTrackIsDownstreamNeighbour {"L1CloneMerger::fTrackIsDownstreamNeighbour"};
 
-  L1Vector<L1Track> fTracksNew {"L1CAMergerClones::fTracksNew"};  ///< vector of tracks after the merge
+  L1Vector<cbm::algo::ca::Track> fTracksNew {"L1CAMergerClones::fTracksNew"};  ///< vector of tracks after the merge
 
   L1Vector<L1HitIndex_t> fRecoHitsNew {"L1CAMergerClones::fRecoHitsNew"};  ///< vector of track hits after the merge
 
diff --git a/reco/L1/L1Algo/L1Track.h b/reco/L1/L1Algo/L1Track.h
deleted file mode 100644
index 4732851a98..0000000000
--- a/reco/L1/L1Algo/L1Track.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Copyright (C) 2010-2017 Frankfurt Institute for Advanced Studies, Goethe-Universitaet Frankfurt, Frankfurt
-   SPDX-License-Identifier: GPL-3.0-only
-   Authors: Ivan Kisel,  Sergey Gorbunov, Maksym Zyzak, Igor Kulakov [committer] */
-
-/*
- *====================================================================
- *
- *  CBM Level 1 Reconstruction 
- *  
- *  Authors: I.Kisel,  S.Gorbunov
- *
- *  e-mail : ikisel@kip.uni-heidelberg.de 
- *
- *====================================================================
- *
- *  L1 track class
- *
- *====================================================================
- */
-
-#ifndef L1Track_H
-#define L1Track_H
-
-#include <limits>
-
-/// Class representing a track in the L1 tracking algorithm
-/// Track parameters vector: {x, y, tx, ty, q/p, z, t}
-/// Covariation matrix: C[20] (C55) corresponds to the time variance
-///
-class L1Track {
-public:
-  static constexpr float kNaN {std::numeric_limits<float>::signaling_NaN()};
-
-  unsigned char NHits {0};  ///< Number of hits in track
-  fscal TFirst[8] {kNaN};   ///< Track parameters on the first station
-  fscal CFirst[28] {kNaN};  ///< Track parameter covariation matrix elements on the first station
-  fscal TLast[8] {kNaN};    ///< Track parameters on the last station
-  fscal CLast[28] {kNaN};   ///< Track parameter covariation matrix elements on the second station
-  fscal Tpv[8] {kNaN};      ///< Track parameters in the primary vertex
-  fscal Cpv[28] {kNaN};     ///< Track parameter covariation matrix elements in the primary vertex
-  fscal chi2 {kNaN};        ///< Track fit chi-square value
-  short int NDF {0};        ///< Track fit NDF value
-};
-
-
-#endif  // L1Track_H
diff --git a/reco/L1/L1Algo/L1TrackFitter.cxx b/reco/L1/L1Algo/L1TrackFitter.cxx
index c3c0a0b730..8414ac51ee 100644
--- a/reco/L1/L1Algo/L1TrackFitter.cxx
+++ b/reco/L1/L1Algo/L1TrackFitter.cxx
@@ -12,7 +12,7 @@
 using std::cout;
 using std::endl;
 using std::vector;
-
+using Track = cbm::algo::ca::Track;
 
 namespace NS_L1TrackFitter
 {
@@ -43,7 +43,7 @@ void L1Algo::L1KFTrackFitter()
   fit.SetParticleMass(GetDefaultParticleMass());
   fit.SetDoFitVelocity(true);
 
-  L1Track* t[fvec::size()] {nullptr};
+  Track* t[fvec::size()] {nullptr};
 
   const L1Station* sta = fParameters.GetStations().begin();
 
diff --git a/reco/L1/L1Algo/utils/L1AlgoDraw.cxx b/reco/L1/L1Algo/utils/L1AlgoDraw.cxx
index 6b7b4134d1..329a2c6603 100644
--- a/reco/L1/L1Algo/utils/L1AlgoDraw.cxx
+++ b/reco/L1/L1Algo/utils/L1AlgoDraw.cxx
@@ -28,6 +28,7 @@
 //       caused errors. Please, don't use "using" in headers
 using std::cout;
 using std::endl;
+using Track = cbm::algo::ca::Track;
 
 L1AlgoDraw::L1AlgoDraw()
 {
@@ -237,8 +238,8 @@ void L1AlgoDraw::DrawRecoTracks()
 
   int curRecoHit                   = 0;
   L1Vector<L1HitIndex_t>& recoHits = algo->fSliceRecoHits;
-  for (vector<L1Track>::iterator it = algo->fSliceRecoTracks.begin(); it != algo->fSliceRecoTracks.end(); ++it) {
-    L1Track& T = *it;
+  for (vector<Track>::iterator it = algo->fSliceRecoTracks.begin(); it != algo->fSliceRecoTracks.end(); ++it) {
+    Track& T   = *it;
     int nHits  = T.NHits;
     //     if (nHits > 5) continue; // draw clones
     //     YZ->cd(); YZ->Update();
diff --git a/reco/detectors/trd/CbmTrdDigiRec.h b/reco/detectors/trd/CbmTrdDigiRec.h
index 7f1762a411..a3b4d21768 100644
--- a/reco/detectors/trd/CbmTrdDigiRec.h
+++ b/reco/detectors/trd/CbmTrdDigiRec.h
@@ -7,6 +7,8 @@
 
 #include "CbmTrdDigi.h"
 
+#include "Rtypes.h"  // for ROOT typedefs (Double_t etc.) and TESTBIT
+
 /** @class CbmTrdDigiRec
  ** @brief Extend the TRD(2D) digi class to incorporate FEE calibration. 
  ** @author Alexandru Bercucic <abercuci@niham.nipne.ro>
diff --git a/reco/littrack/parallel/CMakeLists.txt b/reco/littrack/parallel/CMakeLists.txt
index 9be3b2d207..4acecba75e 100644
--- a/reco/littrack/parallel/CMakeLists.txt
+++ b/reco/littrack/parallel/CMakeLists.txt
@@ -2,7 +2,7 @@
 
 set(INCLUDE_DIRECTORIES
   ${CMAKE_CURRENT_SOURCE_DIR}
-  ${CBMROOT_SOURCE_DIR}/algo/ca/simd
+  ${CBMROOT_SOURCE_DIR}/algo/ca/core/simd
   )
 
 
-- 
GitLab