From dcb3df45d272a6f67cc32b85b531a6c5e6d74a9a Mon Sep 17 00:00:00 2001
From: Florian Uhlig <f.uhlig@gsi.de>
Date: Fri, 3 Dec 2021 17:31:38 +0100
Subject: [PATCH] Remove circular dependency between KF and L1

To resolve the circular dependency the KF library was split into 3 separate
libraries. KF contains the base part, the new KFQA lib now contains everything
which is related to quality assurance. The new lib KFParticleInterface is the
interface needed to use the external KFParticle library.
There wasn't any cleanup of the build system done yet.
---
 reco/KF/CMakeLists.txt               | 178 +--------------------------
 reco/KF/KF.cmake                     | 169 +++++++++++++++++++++++++
 reco/KF/KFLinkDef.h                  |  10 +-
 reco/KF/KFParticleInterface.cmake    | 111 +++++++++++++++++
 reco/KF/KFParticleInterfaceLinkDef.h |  16 +++
 reco/KF/KFQA.cmake                   | 116 +++++++++++++++++
 reco/KF/KFQALinkDef.h                |  18 +++
 7 files changed, 435 insertions(+), 183 deletions(-)
 create mode 100644 reco/KF/KF.cmake
 create mode 100644 reco/KF/KFParticleInterface.cmake
 create mode 100644 reco/KF/KFParticleInterfaceLinkDef.h
 create mode 100644 reco/KF/KFQA.cmake
 create mode 100644 reco/KF/KFQALinkDef.h

diff --git a/reco/KF/CMakeLists.txt b/reco/KF/CMakeLists.txt
index f4ee221aa5..764a1701aa 100644
--- a/reco/KF/CMakeLists.txt
+++ b/reco/KF/CMakeLists.txt
@@ -1,175 +1,3 @@
-# Create a library called "libKF" which includes the source files given in
-# the array .
-# The extension is already found.  Any number of sources could be listed here.
-
-Set(INCLUDE_DIRECTORIES
-${CBMBASE_DIR} 
-
-${CBMROOT_SOURCE_DIR}/reco/base
-
-${CBMDATA_DIR}
-${CBMDATA_DIR}/base
-${CBMDATA_DIR}/sts
-${CBMDATA_DIR}/mvd
-${CBMDATA_DIR}/much
-${CBMDATA_DIR}/trd
-${CBMDATA_DIR}/rich
-${CBMDATA_DIR}/tof
-${CBMDATA_DIR}/global
-
-${CBMROOT_SOURCE_DIR}/reco/KF
-${CBMROOT_SOURCE_DIR}/reco/KF/Interface
-${CBMROOT_SOURCE_DIR}/reco/KF/KFQA
-
-${CBMDETECTORBASE_DIR}/sts
-
-${CBMROOT_SOURCE_DIR}/reco/L1
-${CBMROOT_SOURCE_DIR}/reco/L1/L1Algo
-${CBMROOT_SOURCE_DIR}/reco/L1/ParticleFinder
-
-${CBMROOT_SOURCE_DIR}/mvd 
-)
-
-Include_Directories( ${INCLUDE_DIRECTORIES})
-
-Set(SYSTEM_INCLUDE_DIRECTORIES
-  ${KFParticle_INCLUDE_DIR}
-  ${VC_INCLUDE_DIRS}
-  ${BASE_INCLUDE_DIRECTORIES} 
-)
-
-Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
-
-set(LINK_DIRECTORIES
-${Vc_LIB_DIR}
-${KFParticle_LIB_DIR}
-${FAIRROOT_LIBRARY_DIR}
-${ROOT_LIBRARY_DIR}
-${Boost_LIBRARY_DIRS}
-)
- 
-link_directories(BEFORE ${LINK_DIRECTORIES})
-
-set(SRCS
-CbmKF.cxx 
-CbmKFFieldMath.cxx 
-CbmKFHit.cxx 
-CbmKFMaterial.cxx 
-CbmKFMath.cxx 
-CbmKFPixelMeasurement.cxx 
-CbmKFPrimaryVertexFinder.cxx 
-CbmKFSecondaryVertexFinder.cxx 
-CbmKFTrackInterface.cxx 
-CbmKFUMeasurement.cxx 
-CbmKFVertexInterface.cxx 
-#Interface/CbmEcalTrackExtrapolationKF.cxx
-Interface/CbmKFStsHit.cxx 
-Interface/CbmKFTrack.cxx 
-Interface/CbmKFTrdHit.cxx 
-Interface/CbmKFTofHit.cxx 
-Interface/CbmPVFinderKF.cxx 
-Interface/CbmStsFitPerformanceTask.cxx 
-Interface/CbmStsKFTrackFitter.cxx 
-Interface/CbmStsKFSecondaryVertexFinder.cxx 
-Interface/CbmTrdTrackFitterKF.cxx 
-Interface/CbmTofTrackFitterKF.cxx 
-Interface/CbmGlobalTrackFitterKF.cxx
-# CbmKFParticle.cxx
-# CbmKFParticle_simd.cxx
-# CbmKFParticleInterface.cxx
-KFQA/CbmKFTrErrMCPoints.cxx
-KFQA/CbmKFTrackFitQa.cxx
-KFQA/CbmKFTrackQa.cxx
-KFQA/KFParticleMatch.cxx
-CbmKFParticleFinder.cxx
-CbmKFParticleFinderPID.cxx
-CbmKFParticleFinderQa.cxx
-CbmKFParticleInterface.cxx
-)
-
-
-set(HEADERS
-CbmKF.h 
-CbmKFFieldMath.h
-CbmKFHit.h
-CbmKFMaterial.h
-CbmKFMath.h
-CbmKFPixelMeasurement.h
-CbmKFPrimaryVertexFinder.h
-CbmKFSecondaryVertexFinder.h
-CbmKFTrackInterface.h
-CbmKFUMeasurement.h 
-CbmKFVertexInterface.h
-#Interface/CbmEcalTrackExtrapolationKF.h
-Interface/CbmKFStsHit.h
-Interface/CbmKFTrack.h 
-Interface/CbmKFTrdHit.h 
-Interface/CbmKFTofHit.h 
-Interface/CbmPVFinderKF.h
-Interface/CbmStsFitPerformanceTask.h
-Interface/CbmStsKFTrackFitter.h
-Interface/CbmStsKFSecondaryVertexFinder.h
-Interface/CbmTrdTrackFitterKF.h
-Interface/CbmTofTrackFitterKF.h
-Interface/CbmGlobalTrackFitterKF.h
-# CbmKFParticle.h
-KFQA/CbmKFTrErrMCPoints.h
-KFQA/CbmKFTrackFitQa.h
-KFQA/CbmKFTrackQa.h
-KFQA/CbmKFPartEfficiencies.h
-KFQA/KFParticleMatch.h
-CbmKFParticleFinder.h
-CbmKFParticleFinderPID.h
-CbmKFParticleFinderQa.h
-CbmKFParticleInterface.h
-)
-
-If (APPLE)
-  ADD_DEFINITIONS(-Wall -Wsign-promo -Wctor-dtor-privacy -Wreorder -Wno-deprecated -Wno-parentheses -DDO_TPCCATRACKER_EFF_PERFORMANCE -DNonhomogeneousField -DCBM -DUSE_TIMERS) # -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast   : wait for other parts of cbmroot\root.
-  #---Check for compiler flags
-  CHECK_CXX_COMPILER_FLAG("-Wno-pmf-conversions" HAS_PMF)
-  If(HAS_PMF)
-    ADD_DEFINITIONS(-Wno-pmf-conversions)
-  EndIf()
-  CHECK_CXX_COMPILER_FLAG("-Wstrict-null-sentinel" HAS_SENTINEL)
-  If(HAS_SENTINEL)
-    ADD_DEFINITIONS(-Wstrict-null-sentinel)
-  EndIf()
-  CHECK_CXX_COMPILER_FLAG("-Wno-non-template-friend" HAS_TEMPLATE_FRIEND)
-  If(HAS_TEMPLATE_FRIEND)
-    ADD_DEFINITIONS(-Wno-non-template-friend)
-  EndIf()
-  CHECK_CXX_COMPILER_FLAG("-Wno-pragmas" HAS_PRAGMA)
-  If(HAS_PRAGMA)
-    ADD_DEFINITIONS(-Wno-pragmas)
-  EndIf()
-Else()
-  ADD_DEFINITIONS(-Wall -Wsign-promo  -Wno-pmf-conversions -Wctor-dtor-privacy -Wreorder -Wno-deprecated -Wstrict-null-sentinel -Wno-non-template-friend -Wno-pragmas -Wno-parentheses -DDO_TPCCATRACKER_EFF_PERFORMANCE -DNonhomogeneousField -DCBM -DUSE_TIMERS) # -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast   : wait for other parts of cbmroot\root.
-EndIf()
-
-IF (SSE_FOUND)
-  Message(STATUS "KF will be compiled with SSE support")
-  ADD_DEFINITIONS(-DHAVE_SSE)
-  SET_SOURCE_FILES_PROPERTIES(${SRCS} PROPERTIES COMPILE_FLAGS 
-  "-msse -O3")
-ELSE (SSE_FOUND)
-  MESSAGE(STATUS "KF will be compiled without SSE support")
-  SET_SOURCE_FILES_PROPERTIES(${SRCS} PROPERTIES COMPILE_FLAGS 
-  "-O3")
-ENDIF (SSE_FOUND)
-
-set(LINKDEF KFLinkDef.h)
-Set(LIBRARY_NAME KF)
-Set(DEPENDENCIES
-    CbmStsBase CbmMvd CbmBase CbmRecoBase CbmData Base Vc.a Minuit2 KFParticle
-)
-Set(DEFINITIONS -DDO_TPCCATRACKER_EFF_PERFORMANCE -DNonhomogeneousField -DCBM -DUSE_TIMERS)
-
-GENERATE_LIBRARY()
-
-Add_Dependencies(KF KFPARTICLE)
-Install(FILES KFQA/CbmKFTrErrMCPoints.h
-              KFQA/CbmKFPartEfficiencies.h
-        DESTINATION include/KF/KFQA)
-Install(FILES Interface/CbmKFVertex.h
-        DESTINATION include)
+include(KF.cmake)
+include(KFQA.cmake)
+include(KFParticleInterface.cmake)
diff --git a/reco/KF/KF.cmake b/reco/KF/KF.cmake
new file mode 100644
index 0000000000..a9c0b7e63a
--- /dev/null
+++ b/reco/KF/KF.cmake
@@ -0,0 +1,169 @@
+# Create a library called "libKF" which includes the source files given in
+# the array .
+# The extension is already found.  Any number of sources could be listed here.
+
+Set(INCLUDE_DIRECTORIES
+${CBMBASE_DIR} 
+
+${CBMROOT_SOURCE_DIR}/reco/base
+
+${CBMDATA_DIR}
+${CBMDATA_DIR}/base
+${CBMDATA_DIR}/sts
+${CBMDATA_DIR}/mvd
+${CBMDATA_DIR}/much
+${CBMDATA_DIR}/trd
+${CBMDATA_DIR}/rich
+${CBMDATA_DIR}/tof
+${CBMDATA_DIR}/global
+
+${CBMROOT_SOURCE_DIR}/reco/KF
+${CBMROOT_SOURCE_DIR}/reco/KF/Interface
+${CBMROOT_SOURCE_DIR}/reco/KF/KFQA
+
+${CBMDETECTORBASE_DIR}/sts
+
+#${CBMROOT_SOURCE_DIR}/reco/L1
+#${CBMROOT_SOURCE_DIR}/reco/L1/L1Algo
+#${CBMROOT_SOURCE_DIR}/reco/L1/ParticleFinder
+
+${CBMROOT_SOURCE_DIR}/mvd 
+)
+
+Include_Directories( ${INCLUDE_DIRECTORIES})
+
+Set(SYSTEM_INCLUDE_DIRECTORIES
+  ${VC_INCLUDE_DIRS}
+  ${BASE_INCLUDE_DIRECTORIES} 
+)
+
+Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
+
+set(LINK_DIRECTORIES
+${Vc_LIB_DIR}
+${FAIRROOT_LIBRARY_DIR}
+${ROOT_LIBRARY_DIR}
+${Boost_LIBRARY_DIRS}
+)
+ 
+link_directories(BEFORE ${LINK_DIRECTORIES})
+
+set(SRCS
+CbmKF.cxx 
+CbmKFFieldMath.cxx 
+CbmKFHit.cxx 
+CbmKFMaterial.cxx 
+CbmKFMath.cxx 
+CbmKFPixelMeasurement.cxx 
+CbmKFPrimaryVertexFinder.cxx 
+CbmKFSecondaryVertexFinder.cxx 
+CbmKFTrackInterface.cxx 
+CbmKFUMeasurement.cxx 
+CbmKFVertexInterface.cxx 
+#Interface/CbmEcalTrackExtrapolationKF.cxx
+Interface/CbmKFStsHit.cxx 
+Interface/CbmKFTrack.cxx 
+Interface/CbmKFTrdHit.cxx 
+Interface/CbmKFTofHit.cxx 
+Interface/CbmPVFinderKF.cxx 
+Interface/CbmStsFitPerformanceTask.cxx 
+Interface/CbmStsKFTrackFitter.cxx 
+Interface/CbmStsKFSecondaryVertexFinder.cxx 
+Interface/CbmTrdTrackFitterKF.cxx 
+Interface/CbmTofTrackFitterKF.cxx 
+Interface/CbmGlobalTrackFitterKF.cxx
+# CbmKFParticle.cxx
+# CbmKFParticle_simd.cxx
+# CbmKFParticleInterface.cxx
+#KFQA/CbmKFTrErrMCPoints.cxx
+#KFQA/CbmKFTrackFitQa.cxx
+#KFQA/CbmKFTrackQa.cxx
+#KFQA/KFParticleMatch.cxx
+#CbmKFParticleFinder.cxx
+#CbmKFParticleFinderPID.cxx
+#CbmKFParticleFinderQa.cxx
+#CbmKFParticleInterface.cxx
+)
+
+
+set(HEADERS
+CbmKF.h 
+CbmKFFieldMath.h
+CbmKFHit.h
+CbmKFMaterial.h
+CbmKFMath.h
+CbmKFPixelMeasurement.h
+CbmKFPrimaryVertexFinder.h
+CbmKFSecondaryVertexFinder.h
+CbmKFTrackInterface.h
+CbmKFUMeasurement.h 
+CbmKFVertexInterface.h
+#Interface/CbmEcalTrackExtrapolationKF.h
+Interface/CbmKFStsHit.h
+Interface/CbmKFTrack.h 
+Interface/CbmKFTrdHit.h 
+Interface/CbmKFTofHit.h 
+Interface/CbmPVFinderKF.h
+Interface/CbmStsFitPerformanceTask.h
+Interface/CbmStsKFTrackFitter.h
+Interface/CbmStsKFSecondaryVertexFinder.h
+Interface/CbmTrdTrackFitterKF.h
+Interface/CbmTofTrackFitterKF.h
+Interface/CbmGlobalTrackFitterKF.h
+# CbmKFParticle.h
+#KFQA/CbmKFTrErrMCPoints.h
+#KFQA/CbmKFTrackFitQa.h
+#KFQA/CbmKFTrackQa.h
+#KFQA/CbmKFPartEfficiencies.h
+#KFQA/KFParticleMatch.h
+#CbmKFParticleFinder.h
+#CbmKFParticleFinderPID.h
+#CbmKFParticleFinderQa.h
+#CbmKFParticleInterface.h
+)
+
+If (APPLE)
+  ADD_DEFINITIONS(-Wall -Wsign-promo -Wctor-dtor-privacy -Wreorder -Wno-deprecated -Wno-parentheses -DDO_TPCCATRACKER_EFF_PERFORMANCE -DNonhomogeneousField -DCBM -DUSE_TIMERS) # -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast   : wait for other parts of cbmroot\root.
+  #---Check for compiler flags
+  CHECK_CXX_COMPILER_FLAG("-Wno-pmf-conversions" HAS_PMF)
+  If(HAS_PMF)
+    ADD_DEFINITIONS(-Wno-pmf-conversions)
+  EndIf()
+  CHECK_CXX_COMPILER_FLAG("-Wstrict-null-sentinel" HAS_SENTINEL)
+  If(HAS_SENTINEL)
+    ADD_DEFINITIONS(-Wstrict-null-sentinel)
+  EndIf()
+  CHECK_CXX_COMPILER_FLAG("-Wno-non-template-friend" HAS_TEMPLATE_FRIEND)
+  If(HAS_TEMPLATE_FRIEND)
+    ADD_DEFINITIONS(-Wno-non-template-friend)
+  EndIf()
+  CHECK_CXX_COMPILER_FLAG("-Wno-pragmas" HAS_PRAGMA)
+  If(HAS_PRAGMA)
+    ADD_DEFINITIONS(-Wno-pragmas)
+  EndIf()
+Else()
+  ADD_DEFINITIONS(-Wall -Wsign-promo  -Wno-pmf-conversions -Wctor-dtor-privacy -Wreorder -Wno-deprecated -Wstrict-null-sentinel -Wno-non-template-friend -Wno-pragmas -Wno-parentheses -DDO_TPCCATRACKER_EFF_PERFORMANCE -DNonhomogeneousField -DCBM -DUSE_TIMERS) # -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast   : wait for other parts of cbmroot\root.
+EndIf()
+
+IF (SSE_FOUND)
+  Message(STATUS "KF will be compiled with SSE support")
+  ADD_DEFINITIONS(-DHAVE_SSE)
+  SET_SOURCE_FILES_PROPERTIES(${SRCS} PROPERTIES COMPILE_FLAGS 
+  "-msse -O3")
+ELSE (SSE_FOUND)
+  MESSAGE(STATUS "KF will be compiled without SSE support")
+  SET_SOURCE_FILES_PROPERTIES(${SRCS} PROPERTIES COMPILE_FLAGS 
+  "-O3")
+ENDIF (SSE_FOUND)
+
+set(LINKDEF KFLinkDef.h)
+Set(LIBRARY_NAME KF)
+Set(DEPENDENCIES
+    CbmStsBase CbmMvd CbmBase CbmRecoBase CbmData Base Vc.a Minuit2
+)
+Set(DEFINITIONS -DDO_TPCCATRACKER_EFF_PERFORMANCE -DNonhomogeneousField -DCBM -DUSE_TIMERS)
+
+GENERATE_LIBRARY()
+
+Install(FILES Interface/CbmKFVertex.h
+        DESTINATION include)
diff --git a/reco/KF/KFLinkDef.h b/reco/KF/KFLinkDef.h
index ed9ca1bcc6..ee46f84a6f 100644
--- a/reco/KF/KFLinkDef.h
+++ b/reco/KF/KFLinkDef.h
@@ -36,16 +36,9 @@
 #pragma link C++ class CbmTrdTrackFitterKF + ;
 #pragma link C++ class CbmTofTrackFitterKF + ;
 #pragma link C++ class CbmGlobalTrackFitterKF + ;
-// #pragma link C++ class  CbmKFParticle+;
-
-// //KFParticle
-//#pragma link C++ class  KFParticleBase+;
-//#pragma link C++ class  KFParticle+;
-//#pragma link C++ class  KFVertex+;
-//#pragma link C++ class  KFPartEfficiencies+;
-//#pragma link C++ class  KFMCParticle+;
 
 //KFQA
+/*
 #pragma link C++ class CbmKFPartEfficiencies + ;
 
 #pragma link C++ class CbmKFTrErrMCPoints + ;
@@ -58,5 +51,6 @@
 #pragma link C++ class CbmKFParticleFinderPID + ;
 #pragma link C++ class CbmKFParticleFinderQa + ;
 #pragma link C++ class CbmKFParticleInterface + ;
+*/
 
 #endif
diff --git a/reco/KF/KFParticleInterface.cmake b/reco/KF/KFParticleInterface.cmake
new file mode 100644
index 0000000000..a8efb56852
--- /dev/null
+++ b/reco/KF/KFParticleInterface.cmake
@@ -0,0 +1,111 @@
+# Create a library called "libKF" which includes the source files given in
+# the array .
+# The extension is already found.  Any number of sources could be listed here.
+
+Set(INCLUDE_DIRECTORIES
+${CBMBASE_DIR} 
+
+${CBMROOT_SOURCE_DIR}/reco/base
+
+${CBMDATA_DIR}
+${CBMDATA_DIR}/base
+${CBMDATA_DIR}/sts
+${CBMDATA_DIR}/mvd
+${CBMDATA_DIR}/much
+${CBMDATA_DIR}/trd
+${CBMDATA_DIR}/rich
+${CBMDATA_DIR}/tof
+${CBMDATA_DIR}/global
+
+${CBMROOT_SOURCE_DIR}/reco/KF
+${CBMROOT_SOURCE_DIR}/reco/KF/Interface
+${CBMROOT_SOURCE_DIR}/reco/KF/KFQA
+
+${CBMDETECTORBASE_DIR}/sts
+
+${CBMROOT_SOURCE_DIR}/reco/L1
+${CBMROOT_SOURCE_DIR}/reco/L1/L1Algo
+#${CBMROOT_SOURCE_DIR}/reco/L1/ParticleFinder
+
+${CBMROOT_SOURCE_DIR}/mvd 
+)
+
+Include_Directories( ${INCLUDE_DIRECTORIES})
+
+Set(SYSTEM_INCLUDE_DIRECTORIES
+#  ${KFParticle_INCLUDE_DIR}
+  ${VC_INCLUDE_DIRS}
+  ${BASE_INCLUDE_DIRECTORIES} 
+)
+
+Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
+
+set(LINK_DIRECTORIES
+${Vc_LIB_DIR}
+#${KFParticle_LIB_DIR}
+${FAIRROOT_LIBRARY_DIR}
+${ROOT_LIBRARY_DIR}
+${Boost_LIBRARY_DIRS}
+)
+ 
+link_directories(BEFORE ${LINK_DIRECTORIES})
+
+set(SRCS
+CbmKFParticleFinder.cxx
+CbmKFParticleFinderPID.cxx
+CbmKFParticleFinderQa.cxx
+CbmKFParticleInterface.cxx
+)
+
+
+set(HEADERS
+CbmKFParticleFinder.h
+CbmKFParticleFinderPID.h
+CbmKFParticleFinderQa.h
+CbmKFParticleInterface.h
+)
+
+If (APPLE)
+  ADD_DEFINITIONS(-Wall -Wsign-promo -Wctor-dtor-privacy -Wreorder -Wno-deprecated -Wno-parentheses -DDO_TPCCATRACKER_EFF_PERFORMANCE -DNonhomogeneousField -DCBM -DUSE_TIMERS) # -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast   : wait for other parts of cbmroot\root.
+  #---Check for compiler flags
+  CHECK_CXX_COMPILER_FLAG("-Wno-pmf-conversions" HAS_PMF)
+  If(HAS_PMF)
+    ADD_DEFINITIONS(-Wno-pmf-conversions)
+  EndIf()
+  CHECK_CXX_COMPILER_FLAG("-Wstrict-null-sentinel" HAS_SENTINEL)
+  If(HAS_SENTINEL)
+    ADD_DEFINITIONS(-Wstrict-null-sentinel)
+  EndIf()
+  CHECK_CXX_COMPILER_FLAG("-Wno-non-template-friend" HAS_TEMPLATE_FRIEND)
+  If(HAS_TEMPLATE_FRIEND)
+    ADD_DEFINITIONS(-Wno-non-template-friend)
+  EndIf()
+  CHECK_CXX_COMPILER_FLAG("-Wno-pragmas" HAS_PRAGMA)
+  If(HAS_PRAGMA)
+    ADD_DEFINITIONS(-Wno-pragmas)
+  EndIf()
+Else()
+  ADD_DEFINITIONS(-Wall -Wsign-promo  -Wno-pmf-conversions -Wctor-dtor-privacy -Wreorder -Wno-deprecated -Wstrict-null-sentinel -Wno-non-template-friend -Wno-pragmas -Wno-parentheses -DDO_TPCCATRACKER_EFF_PERFORMANCE -DNonhomogeneousField -DCBM -DUSE_TIMERS) # -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast   : wait for other parts of cbmroot\root.
+EndIf()
+
+IF (SSE_FOUND)
+  Message(STATUS "KF will be compiled with SSE support")
+  ADD_DEFINITIONS(-DHAVE_SSE)
+  SET_SOURCE_FILES_PROPERTIES(${SRCS} PROPERTIES COMPILE_FLAGS 
+  "-msse -O3")
+ELSE (SSE_FOUND)
+  MESSAGE(STATUS "KF will be compiled without SSE support")
+  SET_SOURCE_FILES_PROPERTIES(${SRCS} PROPERTIES COMPILE_FLAGS 
+  "-O3")
+ENDIF (SSE_FOUND)
+
+set(LINKDEF KFParticleInterfaceLinkDef.h)
+Set(LIBRARY_NAME KFParticleInterface)
+Set(DEPENDENCIES
+    KF KFQA Vc.a KFParticle L1
+)
+Set(DEFINITIONS -DDO_TPCCATRACKER_EFF_PERFORMANCE -DNonhomogeneousField -DCBM -DUSE_TIMERS)
+
+GENERATE_LIBRARY()
+
+Add_Dependencies(KFParticleInterface KFPARTICLE)
diff --git a/reco/KF/KFParticleInterfaceLinkDef.h b/reco/KF/KFParticleInterfaceLinkDef.h
new file mode 100644
index 0000000000..dedd55f91f
--- /dev/null
+++ b/reco/KF/KFParticleInterfaceLinkDef.h
@@ -0,0 +1,16 @@
+/* Copyright (C) 2006-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Denis Bertini [committer], Maksym Zyzak, Volodymyr Vovchenko, Florian Uhlig */
+
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class CbmKFParticleFinder + ;
+#pragma link C++ class CbmKFParticleFinderPID + ;
+#pragma link C++ class CbmKFParticleFinderQa + ;
+#pragma link C++ class CbmKFParticleInterface + ;
+
+#endif
diff --git a/reco/KF/KFQA.cmake b/reco/KF/KFQA.cmake
new file mode 100644
index 0000000000..f94bbe426f
--- /dev/null
+++ b/reco/KF/KFQA.cmake
@@ -0,0 +1,116 @@
+# Create a library called "libKF" which includes the source files given in
+# the array .
+# The extension is already found.  Any number of sources could be listed here.
+
+Set(INCLUDE_DIRECTORIES
+${CBMBASE_DIR} 
+
+${CBMROOT_SOURCE_DIR}/reco/base
+
+${CBMDATA_DIR}
+${CBMDATA_DIR}/base
+${CBMDATA_DIR}/sts
+${CBMDATA_DIR}/mvd
+${CBMDATA_DIR}/much
+${CBMDATA_DIR}/trd
+${CBMDATA_DIR}/rich
+${CBMDATA_DIR}/tof
+${CBMDATA_DIR}/global
+
+${CBMROOT_SOURCE_DIR}/reco/KF
+${CBMROOT_SOURCE_DIR}/reco/KF/Interface
+${CBMROOT_SOURCE_DIR}/reco/KF/KFQA
+
+${CBMDETECTORBASE_DIR}/sts
+
+${CBMROOT_SOURCE_DIR}/reco/L1
+${CBMROOT_SOURCE_DIR}/reco/L1/L1Algo
+${CBMROOT_SOURCE_DIR}/reco/L1/ParticleFinder
+
+${CBMROOT_SOURCE_DIR}/mvd 
+)
+
+Include_Directories( ${INCLUDE_DIRECTORIES})
+
+Set(SYSTEM_INCLUDE_DIRECTORIES
+  ${KFParticle_INCLUDE_DIR}
+  ${VC_INCLUDE_DIRS}
+  ${BASE_INCLUDE_DIRECTORIES} 
+)
+
+Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
+
+set(LINK_DIRECTORIES
+${Vc_LIB_DIR}
+${KFParticle_LIB_DIR}
+${FAIRROOT_LIBRARY_DIR}
+${ROOT_LIBRARY_DIR}
+${Boost_LIBRARY_DIRS}
+)
+ 
+link_directories(BEFORE ${LINK_DIRECTORIES})
+
+set(SRCS
+KFQA/CbmKFTrErrMCPoints.cxx
+KFQA/CbmKFTrackFitQa.cxx
+KFQA/CbmKFTrackQa.cxx
+KFQA/KFParticleMatch.cxx
+)
+
+
+set(HEADERS
+KFQA/CbmKFTrErrMCPoints.h
+KFQA/CbmKFTrackFitQa.h
+KFQA/CbmKFTrackQa.h
+KFQA/CbmKFPartEfficiencies.h
+KFQA/KFParticleMatch.h
+)
+
+If (APPLE)
+  ADD_DEFINITIONS(-Wall -Wsign-promo -Wctor-dtor-privacy -Wreorder -Wno-deprecated -Wno-parentheses -DDO_TPCCATRACKER_EFF_PERFORMANCE -DNonhomogeneousField -DCBM -DUSE_TIMERS) # -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast   : wait for other parts of cbmroot\root.
+  #---Check for compiler flags
+  CHECK_CXX_COMPILER_FLAG("-Wno-pmf-conversions" HAS_PMF)
+  If(HAS_PMF)
+    ADD_DEFINITIONS(-Wno-pmf-conversions)
+  EndIf()
+  CHECK_CXX_COMPILER_FLAG("-Wstrict-null-sentinel" HAS_SENTINEL)
+  If(HAS_SENTINEL)
+    ADD_DEFINITIONS(-Wstrict-null-sentinel)
+  EndIf()
+  CHECK_CXX_COMPILER_FLAG("-Wno-non-template-friend" HAS_TEMPLATE_FRIEND)
+  If(HAS_TEMPLATE_FRIEND)
+    ADD_DEFINITIONS(-Wno-non-template-friend)
+  EndIf()
+  CHECK_CXX_COMPILER_FLAG("-Wno-pragmas" HAS_PRAGMA)
+  If(HAS_PRAGMA)
+    ADD_DEFINITIONS(-Wno-pragmas)
+  EndIf()
+Else()
+  ADD_DEFINITIONS(-Wall -Wsign-promo  -Wno-pmf-conversions -Wctor-dtor-privacy -Wreorder -Wno-deprecated -Wstrict-null-sentinel -Wno-non-template-friend -Wno-pragmas -Wno-parentheses -DDO_TPCCATRACKER_EFF_PERFORMANCE -DNonhomogeneousField -DCBM -DUSE_TIMERS) # -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast   : wait for other parts of cbmroot\root.
+EndIf()
+
+IF (SSE_FOUND)
+  Message(STATUS "KF will be compiled with SSE support")
+  ADD_DEFINITIONS(-DHAVE_SSE)
+  SET_SOURCE_FILES_PROPERTIES(${SRCS} PROPERTIES COMPILE_FLAGS 
+  "-msse -O3")
+ELSE (SSE_FOUND)
+  MESSAGE(STATUS "KF will be compiled without SSE support")
+  SET_SOURCE_FILES_PROPERTIES(${SRCS} PROPERTIES COMPILE_FLAGS 
+  "-O3")
+ENDIF (SSE_FOUND)
+
+set(LINKDEF KFQALinkDef.h)
+Set(LIBRARY_NAME KFQA)
+Set(DEPENDENCIES
+    KF Vc.a L1 KFParticle
+)
+
+Set(DEFINITIONS -DDO_TPCCATRACKER_EFF_PERFORMANCE -DNonhomogeneousField -DCBM -DUSE_TIMERS)
+
+GENERATE_LIBRARY()
+
+Add_Dependencies(KFQA KFPARTICLE)
+Install(FILES KFQA/CbmKFTrErrMCPoints.h
+              KFQA/CbmKFPartEfficiencies.h
+        DESTINATION include/KF/KFQA)
diff --git a/reco/KF/KFQALinkDef.h b/reco/KF/KFQALinkDef.h
new file mode 100644
index 0000000000..db9b4edfdf
--- /dev/null
+++ b/reco/KF/KFQALinkDef.h
@@ -0,0 +1,18 @@
+/* Copyright (C) 2006-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Denis Bertini [committer], Maksym Zyzak, Volodymyr Vovchenko, Florian Uhlig */
+
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class CbmKFPartEfficiencies + ;
+
+#pragma link C++ class CbmKFTrErrMCPoints + ;
+#pragma link C++ class CbmKFTrackFitQa + ;
+#pragma link C++ class CbmKFTrackQa + ;
+#pragma link C++ class KFParticleMatch + ;
+
+#endif
-- 
GitLab