From 87460033503e11adc938153fef7c8cb4157bbdee Mon Sep 17 00:00:00 2001
From: Felix Weiglhofer <weiglhofer@fias.uni-frankfurt.de>
Date: Wed, 12 Jul 2023 13:37:51 +0200
Subject: [PATCH] cbmreco: Monitor ts index delta.

---
 algo/global/Reco.cxx | 4 ++++
 algo/global/Reco.h   | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/algo/global/Reco.cxx b/algo/global/Reco.cxx
index 432daa3503..9ded3dc0be 100644
--- a/algo/global/Reco.cxx
+++ b/algo/global/Reco.cxx
@@ -170,6 +170,9 @@ void Reco::QueueUnpackerMetrics(const fles::Timeslice& ts, const UnpackMonitorDa
     return d.size() > 0 ? static_cast<double>(sizeBytes(d)) / x : 0.0;
   };
 
+  size_t tsDelta = ts.index() - prevTsId;
+  prevTsId       = ts.index();
+
   auto& stsDigis   = digis.fData.fSts.fDigis;
   auto& muchDigis  = digis.fData.fMuch.fDigis;
   auto& tofDigis   = digis.fData.fTof.fDigis;
@@ -185,6 +188,7 @@ void Reco::QueueUnpackerMetrics(const fles::Timeslice& ts, const UnpackMonitorDa
 
   GetMonitor().QueueMetric("cbmreco", {{"hostname", fles::system::current_hostname()}, {"child", Opts().ChildId()}},
                            {
+                             {"tsIdDelta", tsDelta},
                              {"unpackTimeTotal", monitor.fTimeUnpack},
                              {"unpackBytesInSts", monitor.fNumBytesInSts},
                              {"unpackBytesInMuch", monitor.fNumBytesInMuch},
diff --git a/algo/global/Reco.h b/algo/global/Reco.h
index ce048fe559..ac41bb2a94 100644
--- a/algo/global/Reco.h
+++ b/algo/global/Reco.h
@@ -41,6 +41,8 @@ namespace cbm::algo
     ChainContext fContext;
     xpu::timings fTimesliceTimesAcc;
 
+    size_t prevTsId = 0;
+
     // STS
     UnpackChain fUnpack;
     sts::HitfinderChain fStsHitFinder;
-- 
GitLab