From 7995e307e1dd1a7cb313bd4f78cebe6f733cbe10 Mon Sep 17 00:00:00 2001
From: Alexandru Bercuci <abercuci@niham.nipne.ro>
Date: Thu, 30 Jan 2025 11:22:17 +0200
Subject: [PATCH] add protection for loss of optical link synchronization. To
 be fixed in FW

---
 algo/detectors/trd2d/UnpackMS.cxx | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/algo/detectors/trd2d/UnpackMS.cxx b/algo/detectors/trd2d/UnpackMS.cxx
index 9c0be4cba..9184338d6 100644
--- a/algo/detectors/trd2d/UnpackMS.cxx
+++ b/algo/detectors/trd2d/UnpackMS.cxx
@@ -428,7 +428,7 @@ namespace cbm::algo::trd2d
     for (uint16_t ipad(0); ipad < NFASPMOD * NFASPPAD; ipad++) {
       if (!ctx.fRobDigi[ipad].size()) continue;
       for (auto id : ctx.fRobDigi[ipad]) {
-        L_(debug) << id.ToString();
+        // L_(debug) << id.ToString();
         outputDigis.emplace_back(std::move(id));
       }
     }
@@ -442,7 +442,13 @@ namespace cbm::algo::trd2d
   {
     constexpr uint8_t m24 =
       uint8_t(eMessageVersion::kMess24);  // message versions compatible with the current algo specialization
-    const uint8_t fasp_mod_id    = fParams.mapFaspId2Mod<m24>(messes[0].fasp);
+    const uint8_t fasp_mod_id = fParams.mapFaspId2Mod<m24>(messes[0].fasp);
+    L_(debug) << "pushDigis<v24> fasp=" << (int) messes[0].fasp << "/" << (int) fasp_mod_id;
+    if (fParams.fAsicParams.find(fasp_mod_id) == fParams.fAsicParams.end()) {
+      L_(error) << "pushDigis<v24> fasp=" << (int) messes[0].fasp << "/" << (int) fasp_mod_id
+                << " not mapped to param.olink[" << (int) fParams.fEqId << "]=0x" << std::hex << (int) fParams.fEqAdd;
+      return false;
+    }
     const UnpackAsicPar& asicPar = fParams.fAsicParams.at(fasp_mod_id);
 
     for (auto imess : messes) {
-- 
GitLab