From 2454920f311ff930686d3b850f9d19a63b2a8d87 Mon Sep 17 00:00:00 2001
From: "s.zharko@gsi.de" <s.zharko@gsi.de>
Date: Sat, 1 Feb 2025 23:55:22 +0100
Subject: [PATCH] online: an empty chain for V0-finding

---
 algo/CMakeLists.txt           |  3 ++
 algo/global/Reco.cxx          | 13 ++++++++-
 algo/global/Reco.h            |  4 +++
 algo/kfp/KfpV0Finder.cxx      | 25 +++++++++++++++++
 algo/kfp/KfpV0Finder.h        | 47 +++++++++++++++++++++++++++++++
 algo/kfp/KfpV0FinderChain.cxx | 30 ++++++++++++++++++++
 algo/kfp/KfpV0FinderChain.h   | 53 +++++++++++++++++++++++++++++++++++
 core/data/CbmEventTriggers.h  |  3 ++
 8 files changed, 177 insertions(+), 1 deletion(-)
 create mode 100644 algo/kfp/KfpV0Finder.cxx
 create mode 100644 algo/kfp/KfpV0Finder.h
 create mode 100644 algo/kfp/KfpV0FinderChain.cxx
 create mode 100644 algo/kfp/KfpV0FinderChain.h

diff --git a/algo/CMakeLists.txt b/algo/CMakeLists.txt
index a2a052fa4..0524146a4 100644
--- a/algo/CMakeLists.txt
+++ b/algo/CMakeLists.txt
@@ -56,6 +56,7 @@ add_subdirectory(log)
 add_subdirectory(data)
 add_subdirectory(kf)
 add_subdirectory(ca)
+#add_subdirectory(kfp) # For KFParticleOnline
 
 # exclude unittests from being build inside the container
 if (NOT CBM_ONLINE_STANDALONE)
@@ -160,6 +161,8 @@ set(SRCS
   ca/TrackingSetup.cxx
   ca/TrackingChain.cxx
   ca/qa/CaQa.cxx
+  kfp/KfpV0Finder.cxx
+  kfp/KfpV0FinderChain.cxx
   kfp/KfpV0FinderConfig.cxx
 )
 
diff --git a/algo/global/Reco.cxx b/algo/global/Reco.cxx
index cfde9b3b4..7f7de2d06 100644
--- a/algo/global/Reco.cxx
+++ b/algo/global/Reco.cxx
@@ -22,6 +22,7 @@
 #include "ca/core/data/CaTrack.h"
 #include "compat/OpenMP.h"
 #include "evbuild/Config.h"
+#include "kfp/KfpV0FinderChain.h"
 #include "much/Unpack.h"
 #include "qa/QaManager.h"
 #include "qa/hitfind/BmonHitfindQa.h"
@@ -275,7 +276,12 @@ void Reco::Init(const Options& opts)
     fTrackingEvent->RegisterSetup(pTrackingSetup);
     fTrackingEvent->SetContext(&fContext);
     fTrackingEvent->Init();
-  
+
+    fV0Finder = std::make_unique<V0FinderChain>();
+    fV0Finder->SetContext(&fContext);
+    fV0Finder->Init();
+  }
+
   // Initialize the QA manager
   if (fQaManager != nullptr) {
     fQaManager->Init();
@@ -575,6 +581,11 @@ bool Reco::ReconstructEvent(const DigiEvent& digiEvent)
     }
   }
 
+  //* V0-selector
+  {
+    auto triggers = fV0Finder->ProcessEvent(recoEvent);
+  }
+
   fEvSelectingMonitor.IncrementCounter(evselect::ECounter::EventsSelected);
   return true;
 }
diff --git a/algo/global/Reco.h b/algo/global/Reco.h
index 1ab27d58d..eb8ba804a 100644
--- a/algo/global/Reco.h
+++ b/algo/global/Reco.h
@@ -21,6 +21,7 @@ namespace cbm::algo
   class HistogramSender;
   class Options;
   class TrackingChain;
+  class V0FinderChain;
 
   template<class M>
   struct UnpackMonitor;
@@ -185,6 +186,9 @@ namespace cbm::algo
     std::unique_ptr<TrackingChain> fTracking;       ///< Tracking in timeslice
     std::unique_ptr<TrackingChain> fTrackingEvent;  ///< Tracking in event
 
+    // V0-finding
+    std::unique_ptr<V0FinderChain> fV0Finder;  ///< V0-finding chain (in event or a bunch of events)
+
     // Event selection
     evselect::Monitor fEvSelectingMonitor;  ///< Monitor for event selecting
 
diff --git a/algo/kfp/KfpV0Finder.cxx b/algo/kfp/KfpV0Finder.cxx
new file mode 100644
index 000000000..58ca42939
--- /dev/null
+++ b/algo/kfp/KfpV0Finder.cxx
@@ -0,0 +1,25 @@
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Sergei Zharko [committer] */
+
+/// \file   KfpV0Finder.cxx
+/// \date   01.02.2025
+/// \brief  A V0 finding algorithm (implementation)
+/// \author Sergei Zharko <s.zharko@gsi.de>
+
+#include "kfp/KfpV0Finder.h"
+
+using cbm::algo::kfp::V0Finder;
+
+
+// ---------------------------------------------------------------------------------------------------------------------
+//
+void V0Finder::Init() {}
+
+// ---------------------------------------------------------------------------------------------------------------------
+//
+CbmEventTriggers V0Finder::Process(const RecoResults&)
+{
+  CbmEventTriggers res;
+  return res;
+}
diff --git a/algo/kfp/KfpV0Finder.h b/algo/kfp/KfpV0Finder.h
new file mode 100644
index 000000000..d0a8a451a
--- /dev/null
+++ b/algo/kfp/KfpV0Finder.h
@@ -0,0 +1,47 @@
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Sergei Zharko [committer] */
+
+/// \file   KfpV0Finder.h
+/// \date   01.02.2025
+/// \brief  A V0 finding algorithm
+/// \author Sergei Zharko <s.zharko@gsi.de>
+
+#pragma once
+
+#include "CbmEventTriggers.h"
+#include "global/RecoResults.h"
+
+namespace cbm::algo::kfp
+{
+  /// \class V0Finder
+  /// \brief A V0-finding algorithm
+  class V0Finder {
+   public:
+    /// \brief Default constructor
+    V0Finder() = default;
+
+    /// \brief Copy constructor
+    V0Finder(const V0Finder&) = delete;
+
+    /// \brief Move constructor
+    V0Finder(V0Finder&&) = delete;
+
+    /// \brief Destructor
+    ~V0Finder() = default;
+
+    /// \brief Copy assignment operator
+    V0Finder& operator=(const V0Finder&) = delete;
+
+    /// \brief Move assignment operator
+    V0Finder& operator=(V0Finder&&) = delete;
+
+    /// \brief Initializes the instance (called in the beginning of the run)
+    void Init();
+
+    /// \brief Processes a reconstructed data sample, returns a collection of fired triggers
+    CbmEventTriggers Process(const RecoResults& recoEvent);
+
+   private:
+  };
+}  // namespace cbm::algo::kfp
diff --git a/algo/kfp/KfpV0FinderChain.cxx b/algo/kfp/KfpV0FinderChain.cxx
new file mode 100644
index 000000000..a2a78be1c
--- /dev/null
+++ b/algo/kfp/KfpV0FinderChain.cxx
@@ -0,0 +1,30 @@
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Sergei Zharko [committer] */
+
+/// \file   KfpV0FinderChain.cxx
+/// \date   01.02.2025
+/// \brief  A chain for V0 finding (implementation)
+/// \author Sergei Zharko <s.zharko@gsi.de>
+
+#include "kfp/KfpV0FinderChain.h"
+
+#include "log/AlgoFairloggerCompat.h"
+
+using cbm::algo::V0FinderChain;
+
+// ---------------------------------------------------------------------------------------------------------------------
+//
+void V0FinderChain::Finalize() {}
+
+// ---------------------------------------------------------------------------------------------------------------------
+//
+void V0FinderChain::Init()
+{
+  L_(info) << "Initializing the V0-finder chain ...";
+  L_(info) << "Initializing the V0-finder chain ... done";
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+//
+CbmEventTriggers V0FinderChain::ProcessEvent(const RecoResults& recoEvent) { return fV0Finder.Process(recoEvent); }
diff --git a/algo/kfp/KfpV0FinderChain.h b/algo/kfp/KfpV0FinderChain.h
new file mode 100644
index 000000000..e3582f931
--- /dev/null
+++ b/algo/kfp/KfpV0FinderChain.h
@@ -0,0 +1,53 @@
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Sergei Zharko [committer] */
+
+/// \file   KfpV0FinderChain.h
+/// \date   01.02.2025
+/// \brief  A chain for V0 finding
+/// \author Sergei Zharko <s.zharko@gsi.de>
+
+#pragma once
+
+#include "CbmEventTriggers.h"
+#include "base/SubChain.h"
+#include "global/RecoResults.h"
+#include "kfp/KfpV0Finder.h"
+
+namespace cbm::algo
+{
+  /// \class V0FinderChain
+  /// \brief A chain for the V0 finder
+  class V0FinderChain : public SubChain {
+   public:
+    /// \brief Default constructor
+    V0FinderChain() = default;
+
+    /// \brief Copy constructor
+    V0FinderChain(const V0FinderChain&) = delete;
+
+    /// \brief Move constructor
+    V0FinderChain(V0FinderChain&&) = delete;
+
+    /// \brief Destructor
+    ~V0FinderChain() = default;
+
+    /// \brief Copy assignment operator
+    V0FinderChain& operator=(const V0FinderChain&) = delete;
+
+    /// \brief Move assignment operator
+    V0FinderChain& operator=(V0FinderChain&&) = delete;
+
+    /// \brief Finalizes the instance (called in the end of the run)
+    void Finalize();
+
+    /// \brief Initializes the instance (called in the beginning of the run)
+    void Init();
+
+    /// \brief Processes an event, returns a collection of fired triggers
+    CbmEventTriggers ProcessEvent(const RecoResults& recoEvent);
+
+   private:
+    kfp::V0Finder fV0Finder;  ///< Instance of the V0-finding algorithm
+  };
+}  // namespace cbm::algo
diff --git a/core/data/CbmEventTriggers.h b/core/data/CbmEventTriggers.h
index ce1b8de53..365d286e5 100644
--- a/core/data/CbmEventTriggers.h
+++ b/core/data/CbmEventTriggers.h
@@ -9,6 +9,9 @@
 
 #pragma once
 
+#include <cstdint>
+#include <string>
+
 #if !defined(NO_ROOT) && !XPU_IS_HIP_CUDA
 #include <Rtypes.h>  // for ClassDef
 #endif
-- 
GitLab