From 946f47e70796f1a22b0bde102eb0536a7b5d4057 Mon Sep 17 00:00:00 2001
From: Felix Weiglhofer <weiglhofer@fias.uni-frankfurt.de>
Date: Wed, 28 Jun 2023 12:38:07 +0000
Subject: [PATCH] algo: Merge contents of Prelude.h with Definitions.h .

---
 algo/CMakeLists.txt                 |  1 -
 algo/base/Definitions.h             | 20 ++++++++++++++
 algo/base/Prelude.h                 | 32 ----------------------
 algo/base/RecoParams.h              |  2 +-
 algo/base/config/BaseTypes.h        |  2 +-
 algo/base/config/Property.h         |  2 +-
 algo/base/config/Yaml.h             |  2 +-
 algo/base/gpu/Params.h              |  1 -
 algo/base/util/TimingsFormat.h      |  2 +-
 algo/data/sts/Cluster.h             |  2 +-
 algo/data/sts/Hit.h                 |  2 +-
 algo/data/sts/HitfinderPars.h       |  2 +-
 algo/data/sts/LandauTable.h         |  2 +-
 algo/detectors/sts/ReadoutConfig.h  |  2 +-
 algo/detectors/sts/StsHitfinder.h   |  2 +-
 algo/detectors/sts/StsUnpackChain.h | 41 +++++++++++++++++++++++++++++
 algo/detectors/sts/UnpackSts.h      |  2 +-
 algo/detectors/tof/UnpackTof.h      |  2 +-
 18 files changed, 74 insertions(+), 47 deletions(-)
 delete mode 100644 algo/base/Prelude.h
 create mode 100644 algo/detectors/sts/StsUnpackChain.h

diff --git a/algo/CMakeLists.txt b/algo/CMakeLists.txt
index 02c7fcacd2..f09ec98a1d 100644
--- a/algo/CMakeLists.txt
+++ b/algo/CMakeLists.txt
@@ -121,7 +121,6 @@ install(
     base/ChainContext.h
     base/Definitions.h
     base/Options.h
-    base/Prelude.h
     base/RecoParams.h
     base/SubChain.h
     ca/simd/CaSimd.h
diff --git a/algo/base/Definitions.h b/algo/base/Definitions.h
index 3a3cb83e1b..274c2e8e05 100644
--- a/algo/base/Definitions.h
+++ b/algo/base/Definitions.h
@@ -6,11 +6,31 @@
 
 #include "MicrosliceDescriptor.hpp"  // For fles::Subsystem
 
+#include <cstdint>
+
 #include "util/EnumDict.h"
 
 namespace cbm::algo
 {
 
+  // typealias for Rust-like fixed size integer types
+  using i8  = std::int8_t;
+  using u8  = std::uint8_t;
+  using i16 = std::int16_t;
+  using u16 = std::uint16_t;
+  using i32 = std::int32_t;
+  using u32 = std::uint32_t;
+  using i64 = std::int64_t;
+  using u64 = std::uint64_t;
+  using f32 = float;
+  using f64 = double;
+
+#ifdef CBM_ALGO_REAL64
+  using real = f64;
+#else
+  using real = f32;
+#endif
+
   enum class Step
   {
     Unpack,
diff --git a/algo/base/Prelude.h b/algo/base/Prelude.h
deleted file mode 100644
index 31a5f5a5ea..0000000000
--- a/algo/base/Prelude.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 2023 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
-   SPDX-License-Identifier: GPL-3.0-only
-   Authors: Felix Weiglhofer [committer] */
-#ifndef CBM_ALGO_BASE_PRELUDE_H
-#define CBM_ALGO_BASE_PRELUDE_H
-
-#include <cstdint>
-
-namespace cbm::algo
-{
-
-  // typealias for Rust-like fixed size integer types
-  using i8  = std::int8_t;
-  using u8  = std::uint8_t;
-  using i16 = std::int16_t;
-  using u16 = std::uint16_t;
-  using i32 = std::int32_t;
-  using u32 = std::uint32_t;
-  using i64 = std::int64_t;
-  using u64 = std::uint64_t;
-  using f32 = float;
-  using f64 = double;
-
-#ifdef CBM_ALGO_REAL64
-  using real = f64;
-#else
-  using real = f32;
-#endif
-
-}  // namespace cbm::algo
-
-#endif  // CBM_ALGO_BASE_PRELUDE_H
diff --git a/algo/base/RecoParams.h b/algo/base/RecoParams.h
index b1f08da263..45c845a50e 100644
--- a/algo/base/RecoParams.h
+++ b/algo/base/RecoParams.h
@@ -6,7 +6,7 @@
 
 #include <xpu/defines.h>
 
-#include "Prelude.h"
+#include "Definitions.h"
 #include "config/Property.h"
 #include "util/EnumDict.h"
 
diff --git a/algo/base/config/BaseTypes.h b/algo/base/config/BaseTypes.h
index b69620abcd..5cb598dd7f 100644
--- a/algo/base/config/BaseTypes.h
+++ b/algo/base/config/BaseTypes.h
@@ -8,7 +8,7 @@
 #include <tuple>
 #include <vector>
 
-#include "Prelude.h"
+#include "Definitions.h"
 
 namespace cbm::algo::config
 {
diff --git a/algo/base/config/Property.h b/algo/base/config/Property.h
index baddbd9755..b099498b11 100644
--- a/algo/base/config/Property.h
+++ b/algo/base/config/Property.h
@@ -10,7 +10,7 @@
 
 #include <yaml-cpp/emittermanip.h>
 
-#include "Prelude.h"
+#include "Definitions.h"
 
 namespace cbm::algo::config
 {
diff --git a/algo/base/config/Yaml.h b/algo/base/config/Yaml.h
index cb836b0465..71895d38ce 100644
--- a/algo/base/config/Yaml.h
+++ b/algo/base/config/Yaml.h
@@ -11,7 +11,7 @@
 #include <yaml-cpp/yaml.h>
 
 #include "BaseTypes.h"
-#include "Prelude.h"
+#include "Definitions.h"
 #include "Property.h"
 #include "util/EnumDict.h"
 
diff --git a/algo/base/gpu/Params.h b/algo/base/gpu/Params.h
index b5e3beb259..86a4a40798 100644
--- a/algo/base/gpu/Params.h
+++ b/algo/base/gpu/Params.h
@@ -7,7 +7,6 @@
 #include <xpu/device.h>
 
 #include "DeviceImage.h"
-#include "Prelude.h"
 #include "RecoParams.h"
 
 namespace cbm::algo
diff --git a/algo/base/util/TimingsFormat.h b/algo/base/util/TimingsFormat.h
index 593c8cae3a..d01cda4480 100644
--- a/algo/base/util/TimingsFormat.h
+++ b/algo/base/util/TimingsFormat.h
@@ -7,7 +7,7 @@
 #include <string>
 #include <string_view>
 
-#include "Prelude.h"
+#include "Definitions.h"
 
 namespace xpu
 {
diff --git a/algo/data/sts/Cluster.h b/algo/data/sts/Cluster.h
index 0cd4fd8636..1e102b32e4 100644
--- a/algo/data/sts/Cluster.h
+++ b/algo/data/sts/Cluster.h
@@ -4,7 +4,7 @@
 #ifndef CBM_ALGO_DATA_STS_CLUSTER_H
 #define CBM_ALGO_DATA_STS_CLUSTER_H
 
-#include "Prelude.h"
+#include "Definitions.h"
 
 namespace cbm::algo::sts
 {
diff --git a/algo/data/sts/Hit.h b/algo/data/sts/Hit.h
index 1a1aa6d9e0..8446e6e1fc 100644
--- a/algo/data/sts/Hit.h
+++ b/algo/data/sts/Hit.h
@@ -5,7 +5,7 @@
 #ifndef CBM_ALGO_DATA_STS_HIT_H
 #define CBM_ALGO_DATA_STS_HIT_H
 
-#include "Prelude.h"
+#include "Definitions.h"
 
 namespace cbm::algo::sts
 {
diff --git a/algo/data/sts/HitfinderPars.h b/algo/data/sts/HitfinderPars.h
index b89cf25a4b..84e99607ed 100644
--- a/algo/data/sts/HitfinderPars.h
+++ b/algo/data/sts/HitfinderPars.h
@@ -4,8 +4,8 @@
 #ifndef CBM_ALGO_DATA_STS_HITFINDERPARS_H
 #define CBM_ALGO_DATA_STS_HITFINDERPARS_H
 
+#include "Definitions.h"
 #include "LandauTable.h"
-#include "Prelude.h"
 #include "config/Property.h"
 
 namespace cbm::algo::sts
diff --git a/algo/data/sts/LandauTable.h b/algo/data/sts/LandauTable.h
index 06ca354692..df976a44bb 100644
--- a/algo/data/sts/LandauTable.h
+++ b/algo/data/sts/LandauTable.h
@@ -6,7 +6,7 @@
 
 #include <vector>
 
-#include "Prelude.h"
+#include "Definitions.h"
 #include "compat/Filesystem.h"
 
 namespace cbm::algo::sts
diff --git a/algo/detectors/sts/ReadoutConfig.h b/algo/detectors/sts/ReadoutConfig.h
index 38e3239f08..7328fd32b6 100644
--- a/algo/detectors/sts/ReadoutConfig.h
+++ b/algo/detectors/sts/ReadoutConfig.h
@@ -8,7 +8,7 @@
 #include <string>
 #include <vector>
 
-#include "Prelude.h"
+#include "Definitions.h"
 #include "config/Property.h"
 
 namespace cbm::algo::sts
diff --git a/algo/detectors/sts/StsHitfinder.h b/algo/detectors/sts/StsHitfinder.h
index 07c0cd2bd6..f41ce3354c 100644
--- a/algo/detectors/sts/StsHitfinder.h
+++ b/algo/detectors/sts/StsHitfinder.h
@@ -9,7 +9,7 @@
 
 #include <xpu/device.h>
 
-#include "Prelude.h"
+#include "Definitions.h"
 #include "gpu/DeviceImage.h"
 #include "gpu/Params.h"
 #include "sts/Cluster.h"
diff --git a/algo/detectors/sts/StsUnpackChain.h b/algo/detectors/sts/StsUnpackChain.h
new file mode 100644
index 0000000000..c004363b2b
--- /dev/null
+++ b/algo/detectors/sts/StsUnpackChain.h
@@ -0,0 +1,41 @@
+/* Copyright (C) 2022 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Felix Weiglhofer [committer]*/
+#ifndef CBM_ALGO_DETECTORS_STS_UNPACKCHAIN_H
+#define CBM_ALGO_DETECTORS_STS_UNPACKCHAIN_H
+
+#include <optional>
+#include <unordered_map>
+#include <vector>
+
+#include <xpu/defines.h>
+#include <yaml-cpp/yaml.h>
+
+#include "Definitions.h"
+#include "ReadoutConfig.h"
+#include "SubChain.h"
+#include "UnpackSts.h"
+
+class CbmStsDigi;
+namespace fles
+{
+  class Timeslice;
+}
+
+namespace cbm::algo::sts
+{
+
+  class UnpackChain : public SubChain {
+
+  public:
+    void Init(sts::ReadoutConfig config);
+    std::vector<CbmStsDigi> Run(const fles::Timeslice& ts);
+
+  private:
+    std::unordered_map<u16, UnpackSts> fAlgoSts;
+    std::optional<sts::ReadoutConfig> fConfig;
+  };
+
+}  // namespace cbm::algo::sts
+
+#endif  // CBM_ALGO_DETECTORS_STS_UNPACKCHAIN_H
diff --git a/algo/detectors/sts/UnpackSts.h b/algo/detectors/sts/UnpackSts.h
index d06db8877a..0be3abda74 100644
--- a/algo/detectors/sts/UnpackSts.h
+++ b/algo/detectors/sts/UnpackSts.h
@@ -16,7 +16,7 @@
 #include <memory>
 #include <vector>
 
-#include "Prelude.h"
+#include "Definitions.h"
 #include "StsXyterMessage.h"
 
 namespace cbm::algo
diff --git a/algo/detectors/tof/UnpackTof.h b/algo/detectors/tof/UnpackTof.h
index 0b4457c56f..b6e9ff1a7f 100644
--- a/algo/detectors/tof/UnpackTof.h
+++ b/algo/detectors/tof/UnpackTof.h
@@ -19,7 +19,7 @@
 #include <vector>
 
 #include "CriGet4Mess001.h"
-#include "Prelude.h"
+#include "Definitions.h"
 
 namespace cbm::algo
 {
-- 
GitLab