From ec5c26d2243e489f48f5706d85f32efef31a4411 Mon Sep 17 00:00:00 2001
From: P-A Loizeau <p.-a.loizeau@gsi.de>
Date: Fri, 29 Jan 2021 18:55:49 +0100
Subject: [PATCH] [mCBM 2020] Separate hit reco and tracking: - Move the TOF
 Tracking to new macro mcbm_tof_tracking.C - Add common run wrapper macro
 mcbm_tof_tracking_kronos.C - Add two new tests to cover tracking after each
 event builder (same as when in reco macro)

---
 macro/beamtime/mcbm2020/CMakeLists.txt        |  19 +
 macro/beamtime/mcbm2020/mcbm_build_and_reco.C | 174 +--------
 macro/beamtime/mcbm2020/mcbm_event_reco.C     | 174 +--------
 macro/beamtime/mcbm2020/mcbm_tof_tracking.C   | 341 ++++++++++++++++++
 .../mcbm2020/mcbm_tof_tracking_kronos.C       |  56 +++
 5 files changed, 418 insertions(+), 346 deletions(-)
 create mode 100644 macro/beamtime/mcbm2020/mcbm_tof_tracking.C
 create mode 100644 macro/beamtime/mcbm2020/mcbm_tof_tracking_kronos.C

diff --git a/macro/beamtime/mcbm2020/CMakeLists.txt b/macro/beamtime/mcbm2020/CMakeLists.txt
index 7813b2ecf7..83e09cfc10 100644
--- a/macro/beamtime/mcbm2020/CMakeLists.txt
+++ b/macro/beamtime/mcbm2020/CMakeLists.txt
@@ -25,6 +25,7 @@ If(DEFINED ENV{RAW_DATA_PATH} )
   GENERATE_ROOT_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/macro/beamtime/mcbm2020/mcbm_build_and_reco.C ) # TW event building + Cluster Finding + Hit reconstruction, Event based
   GENERATE_ROOT_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/macro/beamtime/mcbm2020/mcbm_event_reco.C )  # Digi dt event building + Cluster Finding + Hit reconstruction, Event based
   GENERATE_ROOT_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/macro/beamtime/mcbm2020/mcbm_event_ana.C )   # TOF Track extension toward other detectors
+  GENERATE_ROOT_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/macro/beamtime/mcbm2020/mcbm_tof_tracking.C ) # TOF Tracking, Event based
   GENERATE_ROOT_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/macro/beamtime/mcbm2020/MonitorT0.C )        # CbmMcbm2018MonitorTaskT0 + CbmMcbm2018MonitorAlgoT0
   GENERATE_ROOT_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/macro/beamtime/mcbm2020/MonitorSts.C )       # CbmMcbm2018MonitorSts.h
   GENERATE_ROOT_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/macro/beamtime/mcbm2020/MonitorMuch.C )      # CbmMcbm2018MonitorMuchLite.h
@@ -123,6 +124,24 @@ If(DEFINED ENV{RAW_DATA_PATH} )
       Set(fixture_mcbm_event_reco_${RUN} fixture_done_${testname})
       set_tests_properties(${testname} PROPERTIES FIXTURES_SETUP ${fixture_mcbm_event_reco_${RUN}})
 
+      Set(testname mcbm_track_evt_win_2020_${RUN})
+      Add_Test(${testname} ${CBMROOT_BINARY_DIR}/macro/beamtime/mcbm2020/mcbm_tof_tracking.sh ${RUN} "kTRUE" )
+      Set_Tests_Properties(${testname} PROPERTIES TIMEOUT "600")
+      Set_Tests_Properties(${testname} PROPERTIES PASS_REGULAR_EXPRESSION "Test Passed;All ok")
+      set_tests_properties(${testname} PROPERTIES FIXTURES_REQUIRED ${fixture_mcbm_build_reco_${RUN}})
+      set_tests_properties(${testname} PROPERTIES DEPENDS mcbm_build_reco_2020_${RUN})
+      Set(fixture_mcbm_track_evt_win_${RUN} fixture_done_${testname})
+      set_tests_properties(${testname} PROPERTIES FIXTURES_SETUP ${fixture_mcbm_track_evt_win_${RUN}})
+
+      Set(testname mcbm_track_event_2020_${RUN})
+      Add_Test(${testname} ${CBMROOT_BINARY_DIR}/macro/beamtime/mcbm2020/mcbm_tof_tracking.sh ${RUN} )
+      Set_Tests_Properties(${testname} PROPERTIES TIMEOUT "600")
+      Set_Tests_Properties(${testname} PROPERTIES PASS_REGULAR_EXPRESSION "Test Passed;All ok")
+      set_tests_properties(${testname} PROPERTIES FIXTURES_REQUIRED ${fixture_mcbm_event_reco_${RUN}})
+      set_tests_properties(${testname} PROPERTIES DEPENDS mcbm_event_reco_2020_${RUN})
+      Set(fixture_mcbm_track_event_${RUN} fixture_done_${testname})
+      set_tests_properties(${testname} PROPERTIES FIXTURES_SETUP ${fixture_mcbm_track_event_${RUN}})
+
       Set(testname mcbm_evt_win_ana_2020_${RUN})
       Add_Test(${testname} ${CBMROOT_BINARY_DIR}/macro/beamtime/mcbm2020/mcbm_event_ana.sh ${RUN} 1000 "kTRUE" )
       Set_Tests_Properties(${testname} PROPERTIES TIMEOUT "600")
diff --git a/macro/beamtime/mcbm2020/mcbm_build_and_reco.C b/macro/beamtime/mcbm2020/mcbm_build_and_reco.C
index 11f438a855..ee0d1a8968 100644
--- a/macro/beamtime/mcbm2020/mcbm_build_and_reco.C
+++ b/macro/beamtime/mcbm2020/mcbm_build_and_reco.C
@@ -261,7 +261,6 @@ Bool_t mcbm_build_and_reco(UInt_t uRunId     = 831,
 
 
   // -----   Local reconstruction in TOF   ----------------------------------
-  // ------------------------------------------------------------------------
   // TOF defaults
   Int_t calMode      = 93;
   Int_t calSel       = 1;
@@ -295,179 +294,8 @@ Bool_t mcbm_build_and_reco(UInt_t uRunId     = 831,
 
   run->AddTask(tofCluster);
   std::cout << "-I- Added task " << tofCluster->GetName() << std::endl;
+  // ------------------------------------------------------------------------
 
-  // -----   Track reconstruction   ------------------------------------------
-  Int_t iTrackMode = 2;
-  switch (iTrackMode) {
-    case 2: {
-      Int_t iGenCor      = 1;
-      Double_t dScalFac  = 1.;
-      Double_t dChi2Lim2 = 3.5;
-      TString cTrkFile =
-        parDir + "/tof/" + Form("%s_tofFindTracks.hst.root", cCalId.Data());
-      Int_t iTrackingSetup = 1;
-      Int_t iCalOpt        = 1;
-
-      CbmTofTrackFinder* tofTrackFinder = new CbmTofTrackFinderNN();
-      tofTrackFinder->SetMaxTofTimeDifference(0.2);  // in ns/cm
-      tofTrackFinder->SetTxLIM(0.3);                 // max slope dx/dz
-      tofTrackFinder->SetTyLIM(0.3);  // max dev from mean slope dy/dz
-      tofTrackFinder->SetTyMean(0.);  // mean slope dy/dz
-      CbmTofTrackFitter* tofTrackFitter = new CbmTofTrackFitterKF(0, 211);
-      TFitter* MyFit                    = new TFitter(1);  // initialize Minuit
-      tofTrackFinder->SetFitter(tofTrackFitter);
-
-      CbmTofFindTracks* tofFindTracks =
-        new CbmTofFindTracks("TOF Track Finder");
-      tofFindTracks->UseFinder(tofTrackFinder);
-      tofFindTracks->UseFitter(tofTrackFitter);
-      tofFindTracks->SetCalOpt(iCalOpt);
-      // 1 - update offsets, 2 - update walk, 0 - bypass
-      tofFindTracks->SetCorMode(
-        iGenCor);  // valid options: 0,1,2,3,4,5,6, 10 - 19
-      tofFindTracks->SetTtTarg(
-        0.065);  // target value for Mar2020 triple stack -> betapeak ~ 0.95
-      //tofFindTracks->SetTtTarg(0.041);  // target value for inverse velocity, > 0.033 ns/cm!
-      //tofFindTracks->SetTtTarg(0.035);  // target value for inverse velocity, > 0.033 ns/cm!
-      tofFindTracks->SetCalParFileName(
-        cTrkFile);  // Tracker parameter value file name
-      tofFindTracks->SetBeamCounter(5, 0, 0);  // default beam counter
-      tofFindTracks->SetStationMaxHMul(
-        30);  // Max Hit Multiplicity in any used station
-
-      tofFindTracks->SetT0MAX(dScalFac);  // in ns
-      tofFindTracks->SetSIGT(0.08);       // default in ns
-      tofFindTracks->SetSIGX(0.3);        // default in cm
-      tofFindTracks->SetSIGY(0.45);       // default in cm
-      tofFindTracks->SetSIGZ(0.05);       // default in cm
-      tofFindTracks->SetUseSigCalib(
-        kFALSE);  // ignore resolutions in CalPar file
-      tofTrackFinder->SetSIGLIM(dChi2Lim2
-                                * 2.);  // matching window in multiples of chi2
-      tofTrackFinder->SetChiMaxAccept(dChi2Lim2);  // max tracklet chi2
-
-      Int_t iMinNofHits   = -1;
-      Int_t iNStations    = 0;
-      Int_t iNReqStations = 3;
-      switch (iTrackingSetup) {
-        case 0:  // bypass mode
-          iMinNofHits = -1;
-          iNStations  = 1;
-          tofFindTracks->SetStation(0, 5, 0, 0);  // Diamond
-          break;
-
-        case 1:  // for calibration mode of full setup
-          iMinNofHits   = 3;
-          iNStations    = 28;
-          iNReqStations = 4;
-          tofFindTracks->SetStation(0, 5, 0, 0);
-          tofFindTracks->SetStation(1, 0, 2, 2);
-          tofFindTracks->SetStation(2, 0, 1, 2);
-          tofFindTracks->SetStation(3, 0, 0, 2);
-          tofFindTracks->SetStation(4, 0, 2, 1);
-          tofFindTracks->SetStation(5, 0, 1, 1);
-          tofFindTracks->SetStation(6, 0, 0, 1);
-          tofFindTracks->SetStation(7, 0, 2, 3);
-          tofFindTracks->SetStation(8, 0, 1, 3);
-          tofFindTracks->SetStation(9, 0, 0, 3);
-          tofFindTracks->SetStation(10, 0, 2, 0);
-          tofFindTracks->SetStation(11, 0, 1, 0);
-          tofFindTracks->SetStation(12, 0, 0, 0);
-          tofFindTracks->SetStation(13, 0, 2, 4);
-          tofFindTracks->SetStation(14, 0, 1, 4);
-          tofFindTracks->SetStation(15, 0, 0, 4);
-          tofFindTracks->SetStation(16, 0, 4, 0);
-          tofFindTracks->SetStation(17, 0, 3, 0);
-          tofFindTracks->SetStation(18, 0, 4, 1);
-          tofFindTracks->SetStation(19, 0, 3, 1);
-          tofFindTracks->SetStation(20, 0, 4, 2);
-          tofFindTracks->SetStation(21, 0, 3, 2);
-          tofFindTracks->SetStation(22, 0, 4, 3);
-          tofFindTracks->SetStation(23, 0, 3, 3);
-          tofFindTracks->SetStation(24, 0, 4, 4);
-          tofFindTracks->SetStation(25, 0, 3, 4);
-          tofFindTracks->SetStation(26, 9, 0, 0);
-          tofFindTracks->SetStation(27, 9, 0, 1);
-          break;
-
-        case 2:  // for geometry check mode of full setup
-          iMinNofHits   = 3;
-          iNStations    = 27;
-          iNReqStations = 4;
-          tofFindTracks->SetStation(0, 0, 2, 2);
-          tofFindTracks->SetStation(1, 0, 1, 2);
-          tofFindTracks->SetStation(2, 0, 0, 2);
-          tofFindTracks->SetStation(3, 0, 2, 1);
-          tofFindTracks->SetStation(4, 0, 1, 1);
-          tofFindTracks->SetStation(5, 0, 0, 1);
-          tofFindTracks->SetStation(6, 0, 2, 3);
-          tofFindTracks->SetStation(7, 0, 1, 3);
-          tofFindTracks->SetStation(8, 0, 0, 3);
-          tofFindTracks->SetStation(9, 0, 2, 0);
-          tofFindTracks->SetStation(10, 0, 1, 0);
-          tofFindTracks->SetStation(11, 0, 0, 0);
-          tofFindTracks->SetStation(12, 0, 2, 4);
-          tofFindTracks->SetStation(13, 0, 1, 4);
-          tofFindTracks->SetStation(14, 0, 0, 4);
-          tofFindTracks->SetStation(15, 0, 4, 0);
-          tofFindTracks->SetStation(16, 0, 3, 0);
-          tofFindTracks->SetStation(17, 0, 4, 1);
-          tofFindTracks->SetStation(18, 0, 3, 1);
-          tofFindTracks->SetStation(19, 0, 4, 2);
-          tofFindTracks->SetStation(20, 0, 3, 2);
-          tofFindTracks->SetStation(21, 0, 4, 3);
-          tofFindTracks->SetStation(22, 0, 3, 3);
-          tofFindTracks->SetStation(23, 0, 4, 4);
-          tofFindTracks->SetStation(24, 0, 3, 4);
-          tofFindTracks->SetStation(25, 9, 0, 0);
-          tofFindTracks->SetStation(26, 9, 0, 1);
-          break;
-
-        case 3:  // for reduced bias tracking of full setup
-          iMinNofHits   = 3;
-          iNStations    = 28;
-          iNReqStations = 4;
-          tofFindTracks->SetStation(0, 0, 2, 2);
-          tofFindTracks->SetStation(1, 0, 1, 2);
-          tofFindTracks->SetStation(2, 0, 0, 2);
-          tofFindTracks->SetStation(3, 0, 2, 1);
-          tofFindTracks->SetStation(4, 0, 1, 1);
-          tofFindTracks->SetStation(5, 0, 0, 1);
-          tofFindTracks->SetStation(6, 0, 2, 3);
-          tofFindTracks->SetStation(7, 0, 1, 3);
-          tofFindTracks->SetStation(8, 0, 0, 3);
-          tofFindTracks->SetStation(9, 0, 2, 0);
-          tofFindTracks->SetStation(10, 0, 1, 0);
-          tofFindTracks->SetStation(11, 0, 0, 0);
-          tofFindTracks->SetStation(12, 0, 2, 4);
-          tofFindTracks->SetStation(13, 0, 1, 4);
-          tofFindTracks->SetStation(14, 0, 0, 4);
-          tofFindTracks->SetStation(15, 0, 4, 0);
-          tofFindTracks->SetStation(16, 0, 3, 0);
-          tofFindTracks->SetStation(17, 0, 4, 1);
-          tofFindTracks->SetStation(18, 0, 3, 1);
-          tofFindTracks->SetStation(19, 0, 4, 2);
-          tofFindTracks->SetStation(20, 0, 3, 2);
-          tofFindTracks->SetStation(21, 0, 4, 3);
-          tofFindTracks->SetStation(22, 0, 3, 3);
-          tofFindTracks->SetStation(23, 0, 4, 4);
-          tofFindTracks->SetStation(24, 0, 3, 4);
-          tofFindTracks->SetStation(25, 9, 0, 0);
-          tofFindTracks->SetStation(26, 9, 0, 1);
-          tofFindTracks->SetStation(27, 5, 0, 0);
-          break;
-      }
-      tofFindTracks->SetMinNofHits(iMinNofHits);
-      tofFindTracks->SetNStations(iNStations);
-      tofFindTracks->SetNReqStations(iNReqStations);
-      //tofFindTracks->PrintSetup();
-      run->AddTask(tofFindTracks);
-    } break;
-    case 1: {
-    }
-    case 0:
-    default:;
-  }
 
   // -----   Local reconstruction of RICH Hits ------------------------------
   CbmRichMCbmHitProducer* hitProdRich = new CbmRichMCbmHitProducer();
diff --git a/macro/beamtime/mcbm2020/mcbm_event_reco.C b/macro/beamtime/mcbm2020/mcbm_event_reco.C
index bedfbedf3f..53cb42e832 100644
--- a/macro/beamtime/mcbm2020/mcbm_event_reco.C
+++ b/macro/beamtime/mcbm2020/mcbm_event_reco.C
@@ -191,7 +191,6 @@ Bool_t mcbm_event_reco(UInt_t uRunId     = 831,
 
 
   // -----   Local reconstruction in TOF   ----------------------------------
-  // ------------------------------------------------------------------------
   // TOF defaults
   Int_t calMode      = 93;
   Int_t calSel       = 1;
@@ -225,179 +224,8 @@ Bool_t mcbm_event_reco(UInt_t uRunId     = 831,
 
   run->AddTask(tofCluster);
   std::cout << "-I- Added task " << tofCluster->GetName() << std::endl;
+  // ------------------------------------------------------------------------
 
-  // -----   Track reconstruction   ------------------------------------------
-  Int_t iTrackMode = 2;
-  switch (iTrackMode) {
-    case 2: {
-      Int_t iGenCor      = 1;
-      Double_t dScalFac  = 1.;
-      Double_t dChi2Lim2 = 3.5;
-      TString cTrkFile =
-        parDir + "/tof/" + Form("%s_tofFindTracks.hst.root", cCalId.Data());
-      Int_t iTrackingSetup = 1;
-      Int_t iCalOpt        = 0;
-
-      CbmTofTrackFinder* tofTrackFinder = new CbmTofTrackFinderNN();
-      tofTrackFinder->SetMaxTofTimeDifference(0.2);  // in ns/cm
-      tofTrackFinder->SetTxLIM(0.3);                 // max slope dx/dz
-      tofTrackFinder->SetTyLIM(0.3);  // max dev from mean slope dy/dz
-      tofTrackFinder->SetTyMean(0.);  // mean slope dy/dz
-      CbmTofTrackFitter* tofTrackFitter = new CbmTofTrackFitterKF(0, 211);
-      TFitter* MyFit                    = new TFitter(1);  // initialize Minuit
-      tofTrackFinder->SetFitter(tofTrackFitter);
-
-      CbmTofFindTracks* tofFindTracks =
-        new CbmTofFindTracks("TOF Track Finder");
-      tofFindTracks->UseFinder(tofTrackFinder);
-      tofFindTracks->UseFitter(tofTrackFitter);
-      tofFindTracks->SetCalOpt(iCalOpt);
-      // 1 - update offsets, 2 - update walk, 0 - bypass
-      tofFindTracks->SetCorMode(
-        iGenCor);  // valid options: 0,1,2,3,4,5,6, 10 - 19
-      tofFindTracks->SetTtTarg(
-        0.065);  // target value for Mar2020 triple stack -> betapeak ~ 0.95
-      //tofFindTracks->SetTtTarg(0.041);  // target value for inverse velocity, > 0.033 ns/cm!
-      //tofFindTracks->SetTtTarg(0.035);  // target value for inverse velocity, > 0.033 ns/cm!
-      tofFindTracks->SetCalParFileName(
-        cTrkFile);  // Tracker parameter value file name
-      tofFindTracks->SetBeamCounter(5, 0, 0);  // default beam counter
-      tofFindTracks->SetStationMaxHMul(
-        30);  // Max Hit Multiplicity in any used station
-
-      tofFindTracks->SetT0MAX(dScalFac);  // in ns
-      tofFindTracks->SetSIGT(0.08);       // default in ns
-      tofFindTracks->SetSIGX(0.3);        // default in cm
-      tofFindTracks->SetSIGY(0.45);       // default in cm
-      tofFindTracks->SetSIGZ(0.05);       // default in cm
-      tofFindTracks->SetUseSigCalib(
-        kFALSE);  // ignore resolutions in CalPar file
-      tofTrackFinder->SetSIGLIM(dChi2Lim2
-                                * 2.);  // matching window in multiples of chi2
-      tofTrackFinder->SetChiMaxAccept(dChi2Lim2);  // max tracklet chi2
-
-      Int_t iMinNofHits   = -1;
-      Int_t iNStations    = 0;
-      Int_t iNReqStations = 3;
-      switch (iTrackingSetup) {
-        case 0:  // bypass mode
-          iMinNofHits = -1;
-          iNStations  = 1;
-          tofFindTracks->SetStation(0, 5, 0, 0);  // Diamond
-          break;
-
-        case 1:  // for calibration mode of full setup
-          iMinNofHits   = 3;
-          iNStations    = 28;
-          iNReqStations = 4;
-          tofFindTracks->SetStation(0, 5, 0, 0);
-          tofFindTracks->SetStation(1, 0, 2, 2);
-          tofFindTracks->SetStation(2, 0, 1, 2);
-          tofFindTracks->SetStation(3, 0, 0, 2);
-          tofFindTracks->SetStation(4, 0, 2, 1);
-          tofFindTracks->SetStation(5, 0, 1, 1);
-          tofFindTracks->SetStation(6, 0, 0, 1);
-          tofFindTracks->SetStation(7, 0, 2, 3);
-          tofFindTracks->SetStation(8, 0, 1, 3);
-          tofFindTracks->SetStation(9, 0, 0, 3);
-          tofFindTracks->SetStation(10, 0, 2, 0);
-          tofFindTracks->SetStation(11, 0, 1, 0);
-          tofFindTracks->SetStation(12, 0, 0, 0);
-          tofFindTracks->SetStation(13, 0, 2, 4);
-          tofFindTracks->SetStation(14, 0, 1, 4);
-          tofFindTracks->SetStation(15, 0, 0, 4);
-          tofFindTracks->SetStation(16, 0, 4, 0);
-          tofFindTracks->SetStation(17, 0, 3, 0);
-          tofFindTracks->SetStation(18, 0, 4, 1);
-          tofFindTracks->SetStation(19, 0, 3, 1);
-          tofFindTracks->SetStation(20, 0, 4, 2);
-          tofFindTracks->SetStation(21, 0, 3, 2);
-          tofFindTracks->SetStation(22, 0, 4, 3);
-          tofFindTracks->SetStation(23, 0, 3, 3);
-          tofFindTracks->SetStation(24, 0, 4, 4);
-          tofFindTracks->SetStation(25, 0, 3, 4);
-          tofFindTracks->SetStation(26, 9, 0, 0);
-          tofFindTracks->SetStation(27, 9, 0, 1);
-          break;
-
-        case 2:  // for geometry check mode of full setup
-          iMinNofHits   = 3;
-          iNStations    = 27;
-          iNReqStations = 4;
-          tofFindTracks->SetStation(0, 0, 2, 2);
-          tofFindTracks->SetStation(1, 0, 1, 2);
-          tofFindTracks->SetStation(2, 0, 0, 2);
-          tofFindTracks->SetStation(3, 0, 2, 1);
-          tofFindTracks->SetStation(4, 0, 1, 1);
-          tofFindTracks->SetStation(5, 0, 0, 1);
-          tofFindTracks->SetStation(6, 0, 2, 3);
-          tofFindTracks->SetStation(7, 0, 1, 3);
-          tofFindTracks->SetStation(8, 0, 0, 3);
-          tofFindTracks->SetStation(9, 0, 2, 0);
-          tofFindTracks->SetStation(10, 0, 1, 0);
-          tofFindTracks->SetStation(11, 0, 0, 0);
-          tofFindTracks->SetStation(12, 0, 2, 4);
-          tofFindTracks->SetStation(13, 0, 1, 4);
-          tofFindTracks->SetStation(14, 0, 0, 4);
-          tofFindTracks->SetStation(15, 0, 4, 0);
-          tofFindTracks->SetStation(16, 0, 3, 0);
-          tofFindTracks->SetStation(17, 0, 4, 1);
-          tofFindTracks->SetStation(18, 0, 3, 1);
-          tofFindTracks->SetStation(19, 0, 4, 2);
-          tofFindTracks->SetStation(20, 0, 3, 2);
-          tofFindTracks->SetStation(21, 0, 4, 3);
-          tofFindTracks->SetStation(22, 0, 3, 3);
-          tofFindTracks->SetStation(23, 0, 4, 4);
-          tofFindTracks->SetStation(24, 0, 3, 4);
-          tofFindTracks->SetStation(25, 9, 0, 0);
-          tofFindTracks->SetStation(26, 9, 0, 1);
-          break;
-
-        case 3:  // for reduced bias tracking of full setup
-          iMinNofHits   = 3;
-          iNStations    = 28;
-          iNReqStations = 4;
-          tofFindTracks->SetStation(0, 0, 2, 2);
-          tofFindTracks->SetStation(1, 0, 1, 2);
-          tofFindTracks->SetStation(2, 0, 0, 2);
-          tofFindTracks->SetStation(3, 0, 2, 1);
-          tofFindTracks->SetStation(4, 0, 1, 1);
-          tofFindTracks->SetStation(5, 0, 0, 1);
-          tofFindTracks->SetStation(6, 0, 2, 3);
-          tofFindTracks->SetStation(7, 0, 1, 3);
-          tofFindTracks->SetStation(8, 0, 0, 3);
-          tofFindTracks->SetStation(9, 0, 2, 0);
-          tofFindTracks->SetStation(10, 0, 1, 0);
-          tofFindTracks->SetStation(11, 0, 0, 0);
-          tofFindTracks->SetStation(12, 0, 2, 4);
-          tofFindTracks->SetStation(13, 0, 1, 4);
-          tofFindTracks->SetStation(14, 0, 0, 4);
-          tofFindTracks->SetStation(15, 0, 4, 0);
-          tofFindTracks->SetStation(16, 0, 3, 0);
-          tofFindTracks->SetStation(17, 0, 4, 1);
-          tofFindTracks->SetStation(18, 0, 3, 1);
-          tofFindTracks->SetStation(19, 0, 4, 2);
-          tofFindTracks->SetStation(20, 0, 3, 2);
-          tofFindTracks->SetStation(21, 0, 4, 3);
-          tofFindTracks->SetStation(22, 0, 3, 3);
-          tofFindTracks->SetStation(23, 0, 4, 4);
-          tofFindTracks->SetStation(24, 0, 3, 4);
-          tofFindTracks->SetStation(25, 9, 0, 0);
-          tofFindTracks->SetStation(26, 9, 0, 1);
-          tofFindTracks->SetStation(27, 5, 0, 0);
-          break;
-      }
-      tofFindTracks->SetMinNofHits(iMinNofHits);
-      tofFindTracks->SetNStations(iNStations);
-      tofFindTracks->SetNReqStations(iNReqStations);
-      //tofFindTracks->PrintSetup();
-      run->AddTask(tofFindTracks);
-    } break;
-    case 1: {
-    }
-    case 0:
-    default:;
-  }
 
   // -----   Local reconstruction of RICH Hits ------------------------------
   CbmRichMCbmHitProducer* hitProdRich = new CbmRichMCbmHitProducer();
diff --git a/macro/beamtime/mcbm2020/mcbm_tof_tracking.C b/macro/beamtime/mcbm2020/mcbm_tof_tracking.C
new file mode 100644
index 0000000000..e329e8e5dd
--- /dev/null
+++ b/macro/beamtime/mcbm2020/mcbm_tof_tracking.C
@@ -0,0 +1,341 @@
+// --------------------------------------------------------------------------
+//
+// Macro for reconstruction "TOF tracks" in mcbm data (2020)
+// Runs on output of event-based combined hit reconstruction for all systems.
+//
+// --------------------------------------------------------------------------
+
+Bool_t mcbm_tof_tracking(UInt_t uRunId     = 831,
+                         Bool_t bEventWin  = kFALSE,
+                         Int_t iTrackMode  = 2,
+                         Int_t iCalOpt     = 0,
+                         Int_t nTimeslices = 0,
+                         TString sInpDir   = "./data",
+                         TString sOutDir   = "./data",
+                         TString cCalId     = "831.50.3.0") {
+
+  // --- Logger settings ----------------------------------------------------
+  TString logLevel     = "INFO";
+  TString logVerbosity = "LOW";
+  // ------------------------------------------------------------------------
+
+
+  // -----   Environment   --------------------------------------------------
+  TString myName   = "mcbm_tof_tracking";  // this macro's name for screen outp
+  TString srcDir   = gSystem->Getenv("VMCWORKDIR");  // top source directory
+  TString paramDir = srcDir + "/macro/beamtime/mcbm2020/";
+  TString parDir   = srcDir + "/parameters";
+  // ------------------------------------------------------------------------
+
+
+  // -----   In- and output file names   ------------------------------------
+  TString inFile     = sInpDir + Form("/reco_mcbm_event_%03u.root", uRunId);
+  TString parFileIn  = sInpDir + Form("/reco_mcbm_event_params_%03u.root",
+                                      uRunId);
+  TString parFileOut = sOutDir + Form("/tracking_mcbm_event_params_%03u.root",
+                                      uRunId);
+  TString outFile    = sOutDir + Form("/tracking_mcbm_event_%03u.root", uRunId);
+  if (bEventWin) {
+     inFile     = sInpDir + Form("/reco_mcbm_evt_win_%03u.root", uRunId);
+     parFileIn  = sInpDir + Form("/reco_mcbm_evt_win_params_%03u.root",
+                                 uRunId);
+     parFileOut = sOutDir + Form("/tracking_mcbm_evt_win_params_%03u.root",
+                                 uRunId);
+     outFile    = sOutDir + Form("/tracking_mcbm_evt_win_%03u.root", uRunId);
+  }  // if( bEventWin )
+  // ------------------------------------------------------------------------
+
+  /*
+  std::cout << sInpDir << std::endl << sOutDir << std::endl;
+  std::cout << inFile << std::endl
+            << parFileIn << std::endl
+            << parFileOut << std::endl
+            << outFile << std::endl;
+  std::cout << uRunId << " " << nTimeslices << std::endl;
+
+  return kTRUE;
+  */
+
+  // --- Load the geometry setup ----
+  // This is currently only required by the TRD (parameters)
+  std::string geoSetupTag = "mcbm_beam_2020_03";
+  TString geoFile =
+    paramDir + geoSetupTag.data() + ".geo.root";  // Created in sim. run
+  CbmSetup* geoSetup = CbmSetup::Instance();
+  geoSetup->LoadSetup(geoSetupTag.data());
+  TList* parFileList = new TList();
+  // ------------------------------------------------------------------------
+
+  // -----   Timer   --------------------------------------------------------
+  TStopwatch timer;
+  timer.Start();
+  // ------------------------------------------------------------------------
+
+
+  // -----   FairRunAna   ---------------------------------------------------
+  FairRunAna* run             = new FairRunAna();
+  FairFileSource* inputSource = new FairFileSource(inFile);
+  run->SetSource(inputSource);
+
+  FairRootFileSink* outputSink = new FairRootFileSink(outFile);
+  run->SetSink(outputSink);
+  run->SetGeomFile(geoFile);
+
+  // Define output file for FairMonitor histograms
+  TString monitorFile {outFile};
+  monitorFile.ReplaceAll("reco", "reco.monitor");
+  FairMonitor::GetMonitor()->EnableMonitor(kTRUE, monitorFile);
+  // ------------------------------------------------------------------------
+
+
+  // -----   Logger settings   ----------------------------------------------
+  FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
+  FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
+  // ------------------------------------------------------------------------
+
+
+  // -----   Track reconstruction   ------------------------------------------
+  switch (iTrackMode) {
+    case 2: {
+      Int_t iGenCor      = 1;
+      Double_t dScalFac  = 1.;
+      Double_t dChi2Lim2 = 3.5;
+      TString cTrkFile =
+        parDir + "/tof/" + Form("%s_tofFindTracks.hst.root", cCalId.Data());
+      Int_t iTrackingSetup = 1;
+
+      CbmTofTrackFinder* tofTrackFinder = new CbmTofTrackFinderNN();
+      tofTrackFinder->SetMaxTofTimeDifference(0.2);  // in ns/cm
+      tofTrackFinder->SetTxLIM(0.3);                 // max slope dx/dz
+      tofTrackFinder->SetTyLIM(0.3);  // max dev from mean slope dy/dz
+      tofTrackFinder->SetTyMean(0.);  // mean slope dy/dz
+      CbmTofTrackFitter* tofTrackFitter = new CbmTofTrackFitterKF(0, 211);
+      TFitter* MyFit                    = new TFitter(1);  // initialize Minuit
+      tofTrackFinder->SetFitter(tofTrackFitter);
+
+      CbmTofFindTracks* tofFindTracks =
+        new CbmTofFindTracks("TOF Track Finder");
+      tofFindTracks->UseFinder(tofTrackFinder);
+      tofFindTracks->UseFitter(tofTrackFitter);
+      tofFindTracks->SetCalOpt(iCalOpt);
+      // 1 - update offsets, 2 - update walk, 0 - bypass
+      tofFindTracks->SetCorMode(
+        iGenCor);  // valid options: 0,1,2,3,4,5,6, 10 - 19
+      tofFindTracks->SetTtTarg(
+        0.065);  // target value for Mar2020 triple stack -> betapeak ~ 0.95
+      //tofFindTracks->SetTtTarg(0.041);  // target value for inverse velocity, > 0.033 ns/cm!
+      //tofFindTracks->SetTtTarg(0.035);  // target value for inverse velocity, > 0.033 ns/cm!
+      tofFindTracks->SetCalParFileName(
+        cTrkFile);  // Tracker parameter value file name
+      tofFindTracks->SetBeamCounter(5, 0, 0);  // default beam counter
+      tofFindTracks->SetStationMaxHMul(
+        30);  // Max Hit Multiplicity in any used station
+
+      tofFindTracks->SetT0MAX(dScalFac);  // in ns
+      tofFindTracks->SetSIGT(0.08);       // default in ns
+      tofFindTracks->SetSIGX(0.3);        // default in cm
+      tofFindTracks->SetSIGY(0.45);       // default in cm
+      tofFindTracks->SetSIGZ(0.05);       // default in cm
+      tofFindTracks->SetUseSigCalib(
+        kFALSE);  // ignore resolutions in CalPar file
+      tofTrackFinder->SetSIGLIM(dChi2Lim2
+                                * 2.);  // matching window in multiples of chi2
+      tofTrackFinder->SetChiMaxAccept(dChi2Lim2);  // max tracklet chi2
+
+      Int_t iMinNofHits   = -1;
+      Int_t iNStations    = 0;
+      Int_t iNReqStations = 3;
+      switch (iTrackingSetup) {
+        case 0:  // bypass mode
+          iMinNofHits = -1;
+          iNStations  = 1;
+          tofFindTracks->SetStation(0, 5, 0, 0);  // Diamond
+          break;
+
+        case 1:  // for calibration mode of full setup
+          iMinNofHits   = 3;
+          iNStations    = 28;
+          iNReqStations = 4;
+          tofFindTracks->SetStation(0, 5, 0, 0);
+          tofFindTracks->SetStation(1, 0, 2, 2);
+          tofFindTracks->SetStation(2, 0, 1, 2);
+          tofFindTracks->SetStation(3, 0, 0, 2);
+          tofFindTracks->SetStation(4, 0, 2, 1);
+          tofFindTracks->SetStation(5, 0, 1, 1);
+          tofFindTracks->SetStation(6, 0, 0, 1);
+          tofFindTracks->SetStation(7, 0, 2, 3);
+          tofFindTracks->SetStation(8, 0, 1, 3);
+          tofFindTracks->SetStation(9, 0, 0, 3);
+          tofFindTracks->SetStation(10, 0, 2, 0);
+          tofFindTracks->SetStation(11, 0, 1, 0);
+          tofFindTracks->SetStation(12, 0, 0, 0);
+          tofFindTracks->SetStation(13, 0, 2, 4);
+          tofFindTracks->SetStation(14, 0, 1, 4);
+          tofFindTracks->SetStation(15, 0, 0, 4);
+          tofFindTracks->SetStation(16, 0, 4, 0);
+          tofFindTracks->SetStation(17, 0, 3, 0);
+          tofFindTracks->SetStation(18, 0, 4, 1);
+          tofFindTracks->SetStation(19, 0, 3, 1);
+          tofFindTracks->SetStation(20, 0, 4, 2);
+          tofFindTracks->SetStation(21, 0, 3, 2);
+          tofFindTracks->SetStation(22, 0, 4, 3);
+          tofFindTracks->SetStation(23, 0, 3, 3);
+          tofFindTracks->SetStation(24, 0, 4, 4);
+          tofFindTracks->SetStation(25, 0, 3, 4);
+          tofFindTracks->SetStation(26, 9, 0, 0);
+          tofFindTracks->SetStation(27, 9, 0, 1);
+          break;
+
+        case 2:  // for geometry check mode of full setup
+          iMinNofHits   = 3;
+          iNStations    = 27;
+          iNReqStations = 4;
+          tofFindTracks->SetStation(0, 0, 2, 2);
+          tofFindTracks->SetStation(1, 0, 1, 2);
+          tofFindTracks->SetStation(2, 0, 0, 2);
+          tofFindTracks->SetStation(3, 0, 2, 1);
+          tofFindTracks->SetStation(4, 0, 1, 1);
+          tofFindTracks->SetStation(5, 0, 0, 1);
+          tofFindTracks->SetStation(6, 0, 2, 3);
+          tofFindTracks->SetStation(7, 0, 1, 3);
+          tofFindTracks->SetStation(8, 0, 0, 3);
+          tofFindTracks->SetStation(9, 0, 2, 0);
+          tofFindTracks->SetStation(10, 0, 1, 0);
+          tofFindTracks->SetStation(11, 0, 0, 0);
+          tofFindTracks->SetStation(12, 0, 2, 4);
+          tofFindTracks->SetStation(13, 0, 1, 4);
+          tofFindTracks->SetStation(14, 0, 0, 4);
+          tofFindTracks->SetStation(15, 0, 4, 0);
+          tofFindTracks->SetStation(16, 0, 3, 0);
+          tofFindTracks->SetStation(17, 0, 4, 1);
+          tofFindTracks->SetStation(18, 0, 3, 1);
+          tofFindTracks->SetStation(19, 0, 4, 2);
+          tofFindTracks->SetStation(20, 0, 3, 2);
+          tofFindTracks->SetStation(21, 0, 4, 3);
+          tofFindTracks->SetStation(22, 0, 3, 3);
+          tofFindTracks->SetStation(23, 0, 4, 4);
+          tofFindTracks->SetStation(24, 0, 3, 4);
+          tofFindTracks->SetStation(25, 9, 0, 0);
+          tofFindTracks->SetStation(26, 9, 0, 1);
+          break;
+
+        case 3:  // for reduced bias tracking of full setup
+          iMinNofHits   = 3;
+          iNStations    = 28;
+          iNReqStations = 4;
+          tofFindTracks->SetStation(0, 0, 2, 2);
+          tofFindTracks->SetStation(1, 0, 1, 2);
+          tofFindTracks->SetStation(2, 0, 0, 2);
+          tofFindTracks->SetStation(3, 0, 2, 1);
+          tofFindTracks->SetStation(4, 0, 1, 1);
+          tofFindTracks->SetStation(5, 0, 0, 1);
+          tofFindTracks->SetStation(6, 0, 2, 3);
+          tofFindTracks->SetStation(7, 0, 1, 3);
+          tofFindTracks->SetStation(8, 0, 0, 3);
+          tofFindTracks->SetStation(9, 0, 2, 0);
+          tofFindTracks->SetStation(10, 0, 1, 0);
+          tofFindTracks->SetStation(11, 0, 0, 0);
+          tofFindTracks->SetStation(12, 0, 2, 4);
+          tofFindTracks->SetStation(13, 0, 1, 4);
+          tofFindTracks->SetStation(14, 0, 0, 4);
+          tofFindTracks->SetStation(15, 0, 4, 0);
+          tofFindTracks->SetStation(16, 0, 3, 0);
+          tofFindTracks->SetStation(17, 0, 4, 1);
+          tofFindTracks->SetStation(18, 0, 3, 1);
+          tofFindTracks->SetStation(19, 0, 4, 2);
+          tofFindTracks->SetStation(20, 0, 3, 2);
+          tofFindTracks->SetStation(21, 0, 4, 3);
+          tofFindTracks->SetStation(22, 0, 3, 3);
+          tofFindTracks->SetStation(23, 0, 4, 4);
+          tofFindTracks->SetStation(24, 0, 3, 4);
+          tofFindTracks->SetStation(25, 9, 0, 0);
+          tofFindTracks->SetStation(26, 9, 0, 1);
+          tofFindTracks->SetStation(27, 5, 0, 0);
+          break;
+      }
+      tofFindTracks->SetMinNofHits(iMinNofHits);
+      tofFindTracks->SetNStations(iNStations);
+      tofFindTracks->SetNReqStations(iNReqStations);
+      //tofFindTracks->PrintSetup();
+      run->AddTask(tofFindTracks);
+    } break;
+    case 1: {
+    }
+    case 0:
+    default:;
+  }
+
+
+  // -----  Parameter database   --------------------------------------------
+  std::cout << std::endl << std::endl;
+  std::cout << "-I- " << myName << ": Set runtime DB" << std::endl;
+  FairRuntimeDb* rtdb        = run->GetRuntimeDb();
+  FairParRootFileIo* parIo1  = new FairParRootFileIo();
+  FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo();
+  FairParRootFileIo* parIo3  = new FairParRootFileIo();
+  parIo1->open(parFileIn.Data(), "READ");
+  rtdb->setFirstInput(parIo1);
+  parIo2->open(parFileList, "in");
+  rtdb->setSecondInput(parIo2);
+  parIo3->open(parFileOut.Data(), "RECREATE");
+  // ------------------------------------------------------------------------
+
+
+  // -----   Run initialisation   -------------------------------------------
+  std::cout << std::endl;
+  std::cout << "-I- " << myName << ": Initialise run" << std::endl;
+  run->Init();
+  rtdb->setOutput(parIo3);
+  rtdb->saveOutput();
+  rtdb->print();
+  // ------------------------------------------------------------------------
+
+
+  // -----   Start run   ----------------------------------------------------
+  std::cout << std::endl << std::endl;
+  std::cout << "-I- " << myName << ": Starting run" << std::endl;
+  run->Run(0, nTimeslices);
+  // ------------------------------------------------------------------------
+
+
+  // -----   Finish   -------------------------------------------------------
+  timer.Stop();
+  FairMonitor::GetMonitor()->Print();
+  Double_t rtime = timer.RealTime();
+  Double_t ctime = timer.CpuTime();
+  std::cout << std::endl << std::endl;
+  std::cout << "Macro finished successfully." << std::endl;
+  std::cout << "Output file is " << outFile << std::endl;
+  std::cout << "Parameter file is " << parFileOut << std::endl;
+  std::cout << "Real time " << rtime << " s, CPU time " << ctime << " s"
+            << std::endl;
+  std::cout << std::endl;
+  // ------------------------------------------------------------------------
+
+
+  // -----   Resource monitoring   ------------------------------------------
+  // Extract the maximal used memory an add is as Dart measurement
+  // This line is filtered by CTest and the value send to CDash
+  FairSystemInfo sysInfo;
+  Float_t maxMemory = sysInfo.GetMaxMemory();
+  std::cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">";
+  std::cout << maxMemory;
+  std::cout << "</DartMeasurement>" << std::endl;
+
+  Float_t cpuUsage = ctime / rtime;
+  std::cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">";
+  std::cout << cpuUsage;
+  std::cout << "</DartMeasurement>" << std::endl;
+  // ------------------------------------------------------------------------
+
+
+  // -----   Function needed for CTest runtime dependency   -----------------
+  //  RemoveGeoManager();
+  // ------------------------------------------------------------------------
+
+  /// --- Screen output for automatic tests
+  std::cout << " Test passed" << std::endl;
+  std::cout << " All ok " << std::endl;
+
+  return kTRUE;
+}
diff --git a/macro/beamtime/mcbm2020/mcbm_tof_tracking_kronos.C b/macro/beamtime/mcbm2020/mcbm_tof_tracking_kronos.C
new file mode 100644
index 0000000000..b509ff4b3a
--- /dev/null
+++ b/macro/beamtime/mcbm2020/mcbm_tof_tracking_kronos.C
@@ -0,0 +1,56 @@
+// --------------------------------------------------------------------------
+//
+// Macro for reconstruction "TOF tracks" in mcbm data (2020)
+// Runs on output of event-based combined hit reconstruction for all systems.
+// Wrapper setting the paths for analysis using the HPC farm's common files.
+//
+// --------------------------------------------------------------------------
+
+#include "mcbm_tof_tracking.C"
+
+Bool_t mcbm_tof_tracking_kronos(UInt_t uRunIdx = 28,
+                                Bool_t bEventWin  = kFALSE,
+                                Int_t iTrackMode  = 2,
+                                Int_t iCalOpt     = 0,
+                                Int_t nTimeslices = 0,
+                                TString sInpDir = "/lustre/cbm/users/ploizeau/mcbm2020/"
+                                                  "unp_evt_data_7f229b3f_20201103",
+                                TString sOutDir = "./data") {
+  UInt_t uRunId = 0;
+
+  if (99999 != uRunIdx) {
+    std::vector<UInt_t> vuListRunId = {
+      692, 698, 702, 704, 705, 706, 707,            //  7 =>  0 -  6
+      744, 750, 759, 760, 761, 762, 799,            //  7 =>  7 - 13
+      811, 812, 816, 817, 819,                      //  5 => 14 - 18
+      820, 821, 822, 824, 826, 827, 828, 829,       //  8 => 19 - 26
+      830, 831, 836,                                //  3 => 27 - 29
+      841, 846, 849,                                //  3 => 30 - 32
+      850, 851, 852, 854, 855, 856, 857, 858, 859,  //  9 => 33 - 41
+      860, 861, 862, 863, 864, 865, 866             //  7 => 42 - 48
+
+      /*
+      /// With runs < 1 min due to missmatch!
+      811, 812, 816, 817, 818, 819,                  //  6 => 14 - 19
+      820, 821, 822, 824, 826, 827, 828, 829,        //  8 => 20 - 27
+      830, 831, 836, 839,                            //  4 => 28 - 31
+      840, 841, 842, 844, 845, 846, 848, 849,        //  8 => 32 - 39
+      850, 851, 852, 854, 855, 856, 857, 858, 859,   //  9 => 40 - 48
+      860, 861, 862, 863, 864, 865, 866              //  7 => 49 - 55
+      */
+    };
+    if (vuListRunId.size() <= uRunIdx) return kFALSE;
+
+    uRunId = vuListRunId[uRunIdx];
+  }  // if( 99999 != uRunIdx )
+
+  if (uRunId < 692 && 0 != uRunId) return kFALSE;
+
+  return mcbm_tof_tracking(uRunId,
+                           bEventWin,
+                           iTrackMode,
+                           iCalOpt,
+                           nTimeslices,
+                           sInpDir,
+                           sOutDir );
+}
-- 
GitLab