From ac97d5200d28bc390667dff2a64b8980cbed6b44 Mon Sep 17 00:00:00 2001
From: Roel Aaij <roel.aaij@cern.ch>
Date: Tue, 25 Apr 2023 20:52:04 +0200
Subject: [PATCH] [MEPProvider] Add Events/OUT counter

---
 AllenOnline/src/MEPProvider.cpp | 13 +++++++------
 AllenOnline/src/MEPProvider.h   |  1 +
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/AllenOnline/src/MEPProvider.cpp b/AllenOnline/src/MEPProvider.cpp
index 7262cb422..7ccc68eb9 100755
--- a/AllenOnline/src/MEPProvider.cpp
+++ b/AllenOnline/src/MEPProvider.cpp
@@ -142,12 +142,12 @@ std::tuple<bool, bool, bool, size_t, size_t, std::any> MEPProvider::get_slice( s
 
   // Check if I/O and transposition is done and return a slice index
   if ( !timed_out && transposed && !m_read_error ) {
+    size_t n_events = transposed->n_transposed ? *( transposed->n_transposed ) : 0u;
     if ( msgLevel( MSG::DEBUG ) ) {
       debug() << "get_slice returning " << transposed->slice_index << "; error " << m_read_error << " done " << done
-              << " n_filled "
-              << ( transposed->n_transposed ? std::to_string( *( transposed->n_transposed ) ) : std::string{} )
-              << endmsg;
+              << " n_filled " << ( n_events != 0 ? std::to_string( n_events ) : std::string{} ) << endmsg;
     }
+    ( *m_eventsToBatches ) += n_events;
     return {!m_read_error, done, timed_out, transposed->slice_index, *( transposed->n_transposed ), odin_span};
   } else {
     if ( timed_out && msgLevel( MSG::DEBUG ) ) {
@@ -316,9 +316,10 @@ StatusCode MEPProvider::initialize() {
     return StatusCode::FAILURE;
   }
 
-  m_mepsInput   = std::make_unique<Gaudi::Accumulators::Counter<>>( burstsSvc, "IN" );
-  m_eventsInput = std::make_unique<Gaudi::Accumulators::Counter<>>( eventsSvc, "IN" );
-  m_mbInput     = std::make_unique<Gaudi::Accumulators::Counter<>>( eventsSvc, "MB_IN" );
+  m_mepsInput       = std::make_unique<Gaudi::Accumulators::Counter<>>( burstsSvc, "IN" );
+  m_eventsInput     = std::make_unique<Gaudi::Accumulators::Counter<>>( eventsSvc, "IN" );
+  m_eventsToBatches = std::make_unique<Gaudi::Accumulators::Counter<>>( eventsSvc, "OUT" );
+  m_mbInput         = std::make_unique<Gaudi::Accumulators::Counter<>>( eventsSvc, "MB_IN" );
 
 #ifdef HAVE_MPI
   if ( !m_buffer_numa.value().empty() && m_buffer_numa.value().size() != n_buffers() ) {
diff --git a/AllenOnline/src/MEPProvider.h b/AllenOnline/src/MEPProvider.h
index 4cf857d47..7c495689c 100644
--- a/AllenOnline/src/MEPProvider.h
+++ b/AllenOnline/src/MEPProvider.h
@@ -350,5 +350,6 @@ private:
 
   std::unique_ptr<Gaudi::Accumulators::Counter<>> m_mepsInput;
   std::unique_ptr<Gaudi::Accumulators::Counter<>> m_eventsInput;
+  std::unique_ptr<Gaudi::Accumulators::Counter<>> m_eventsToBatches;
   std::unique_ptr<Gaudi::Accumulators::Counter<>> m_mbInput;
 };
-- 
GitLab