From b9aa225063fd1c974c47d35993a1ab8dfab39fc2 Mon Sep 17 00:00:00 2001
From: P-A Loizeau <p.-a.loizeau@gsi.de>
Date: Tue, 9 Jul 2024 11:33:19 +0200
Subject: [PATCH] [Bmon] Ignore unmapped channels in online unpacker

=> Due to noisy unconnected channel not being masked in HW during mCBM 2024 data taking (and probably 2022 one)
---
 algo/detectors/bmon/UnpackMS.cxx | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/algo/detectors/bmon/UnpackMS.cxx b/algo/detectors/bmon/UnpackMS.cxx
index c6a198f4f2..dde62ac44f 100644
--- a/algo/detectors/bmon/UnpackMS.cxx
+++ b/algo/detectors/bmon/UnpackMS.cxx
@@ -6,6 +6,7 @@
 
 #include <cassert>
 #include <cmath>
+#include <log.hpp>
 #include <sstream>
 #include <utility>
 #include <vector>
@@ -27,6 +28,8 @@ namespace cbm::algo::bmon
     // --- Output data
     Result_t result = {};
 
+    L_(debug) << "EQ ID 0x" << std::hex << msDescr.eq_id << std::dec;
+
     // --- Number of messages in microslice
     auto msSize = msDescr.size;
     if (msSize % sizeof(critof001::Message) != 0) {
@@ -114,7 +117,6 @@ namespace cbm::algo::bmon
   {
     // IGNORES:
     // - Duplicate messages
-    // - (0 == uChanUId)
     // - (fviRpcChUId.size() < uRemappedChannelNrInSys)
     // - successive digis with same time
     // (these are filtered in original version but not here)
@@ -131,11 +133,17 @@ namespace cbm::algo::bmon
     const uint32_t channel    = message.getGdpbHitChanId();
     const uint32_t channelUId = (elinkPar.fChannelUId)[channel];
 
-    double messageTime  = message.getMsgFullTimeD(time.currentEpochInTs) - elinkPar.fTimeOffset;
-    const double charge = (double) message.getGdpbHit32Tot();  //cast from uint32_t
+    L_(debug) << "GET4 Idx " << elink << " channel " << channel << " 0x" << std::hex << channelUId << std::dec;
+    if (0 < channelUId) {
+      double messageTime  = message.getMsgFullTimeD(time.currentEpochInTs) - elinkPar.fTimeOffset;
+      const double charge = (double) message.getGdpbHit32Tot();  //cast from uint32_t
 
-    // --- Create output digi
-    digiVec.emplace_back(channelUId, messageTime, charge);
+      // --- Create output digi
+      digiVec.emplace_back(channelUId, messageTime, charge);
+    }
+    else {
+      L_(debug) << "Ignoring digi on unmapped channel";
+    }
   }
   // --------------------------------------------------------------------------
 
-- 
GitLab