From 81bc6d9e4f54dfdedf71d3e827a844dd13c6e049 Mon Sep 17 00:00:00 2001
From: Felix Weiglhofer <weiglhofer@fias.uni-frankfurt.de>
Date: Wed, 24 Apr 2024 09:06:36 +0000
Subject: [PATCH] online: Fix STS monitoring.

---
 algo/detectors/sts/Hitfinder.h        | 2 --
 algo/detectors/sts/HitfinderChain.cxx | 3 ++-
 algo/detectors/sts/HitfinderChain.h   | 2 ++
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/algo/detectors/sts/Hitfinder.h b/algo/detectors/sts/Hitfinder.h
index 69d8828ec9..b7ef99499e 100644
--- a/algo/detectors/sts/Hitfinder.h
+++ b/algo/detectors/sts/Hitfinder.h
@@ -114,8 +114,6 @@ namespace cbm::algo::sts
   struct HitfinderMonDevice {
     i32 nClusterBucketOverflow;
     i32 nHitBucketOverflow;
-    u64 nClusterTotal;
-    u64 nHitsTotal;
     bool HasErrors() const { return nClusterBucketOverflow > 0 || nHitBucketOverflow > 0; }
   };
 
diff --git a/algo/detectors/sts/HitfinderChain.cxx b/algo/detectors/sts/HitfinderChain.cxx
index 41aa192dde..27b6930658 100644
--- a/algo/detectors/sts/HitfinderChain.cxx
+++ b/algo/detectors/sts/HitfinderChain.cxx
@@ -179,7 +179,6 @@ sts::HitfinderChain::Result sts::HitfinderChain::operator()(gsl::span<const CbmS
   size_t nClustersTotal = std::accumulate(nClusters.begin(), nClusters.end(), 0);
   xpu::k_add_bytes<SortClusters>(nClustersTotal * sizeof(ClusterIdx));
 
-
   size_t nClustersFront = std::accumulate(nClusters.begin(), nClusters.begin() + nModules, 0);
 
   // FindHits supports to modes of parallelization: One thread per cluster or one block per module
@@ -252,6 +251,8 @@ sts::HitfinderChain::Result sts::HitfinderChain::operator()(gsl::span<const CbmS
 
   result.hits     = std::move(hits);
   result.clusters = std::move(clusters);
+  result.monitor.nClusterTotal = nClustersTotal;
+  result.monitor.nHitsTotal    = result.hits.NElements();
   result.monitor.SetDeviceMon(monitor[0]);
   return result;
 }
diff --git a/algo/detectors/sts/HitfinderChain.h b/algo/detectors/sts/HitfinderChain.h
index d63a8ca571..de9c80a875 100644
--- a/algo/detectors/sts/HitfinderChain.h
+++ b/algo/detectors/sts/HitfinderChain.h
@@ -26,6 +26,8 @@ namespace cbm::algo::sts
 {
 
   struct HitfinderMon : HitfinderMonDevice {
+    u64 nClusterTotal;
+    u64 nHitsTotal;
     xpu::timings time;
 
     void SetDeviceMon(const HitfinderMonDevice& devMon) { HitfinderMonDevice::operator=(devMon); }
-- 
GitLab