From f2ef8c0222f2b3064733b67091c9c3aca345e00e Mon Sep 17 00:00:00 2001
From: Felix Weiglhofer <weiglhofer@fias.uni-frankfurt.de>
Date: Tue, 4 Jul 2023 11:33:27 +0000
Subject: [PATCH] sts::Hitfinder: Fix memory limits.

---
 algo/detectors/sts/StsHitfinderChain.cxx | 5 +++--
 algo/detectors/sts/StsHitfinderChain.h   | 8 --------
 algo/params/RecoParams.yaml              | 2 +-
 3 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/algo/detectors/sts/StsHitfinderChain.cxx b/algo/detectors/sts/StsHitfinderChain.cxx
index e2eddc103d..e2899fb2ac 100644
--- a/algo/detectors/sts/StsHitfinderChain.cxx
+++ b/algo/detectors/sts/StsHitfinderChain.cxx
@@ -242,8 +242,9 @@ void sts::HitfinderChain::AllocateDynamic(size_t maxNDigisPerModule, size_t nDig
   const int nModules     = fPars->modules.size();
   const int nModuleSides = 2 * nModules;  // Number of module front + backsides
 
-  const size_t maxNClustersPerModule = maxNDigisPerModule * kClustersPerDigiFactor;
-  const size_t maxNHitsPerModule     = maxNClustersPerModule * kHitsPerClustersFactor;
+
+  const size_t maxNClustersPerModule = maxNDigisPerModule * Params().sts.memoryLimits.clustersPerDigiModule;
+  const size_t maxNHitsPerModule     = maxNClustersPerModule * Params().sts.memoryLimits.hitsPerClusterModule;
 
   // Allocate Digi Buffers
   fHitfinder.digiOffsetPerModule.reset(nModuleSides + 1, xpu::buf_io);
diff --git a/algo/detectors/sts/StsHitfinderChain.h b/algo/detectors/sts/StsHitfinderChain.h
index 46e59f733e..7bd7e0e6d0 100644
--- a/algo/detectors/sts/StsHitfinderChain.h
+++ b/algo/detectors/sts/StsHitfinderChain.h
@@ -58,14 +58,6 @@ namespace cbm::algo::sts
       DigiMapSide back;
     };
 
-    /**
-       *  Factors used to estimate buffer sizes based on number of digis.
-       *  TODO: These values might be wildly off. Look for better estimations.
-       *  TODO: Should be configurable at runtime.
-       */
-    static constexpr float kClustersPerDigiFactor = 1.f;
-    static constexpr float kHitsPerClustersFactor = 1.5f;
-
     /**
        * Ensure parameters were set. Raises log(fatal) otherwise.
        */
diff --git a/algo/params/RecoParams.yaml b/algo/params/RecoParams.yaml
index e23a50bc39..2db4029e00 100644
--- a/algo/params/RecoParams.yaml
+++ b/algo/params/RecoParams.yaml
@@ -18,5 +18,5 @@ sts:
     clustersPerDigiTS: 1.0
     clustersPerDigiModule: 1.0
     hitsPerClusterTS: 1.0
-    hitsPerClusterModule: 1.0
+    hitsPerClusterModule: 2.0
 ...
-- 
GitLab