From 1456e126b5b7969549a7a216fe7f48810a1d8c4f Mon Sep 17 00:00:00 2001
From: Dominik Smith <smith@th.physik.uni-frankfurt.de>
Date: Tue, 30 May 2023 12:37:13 +0200
Subject: [PATCH] Added print() functions to monitoring structs of cbm::algo
 unpackers.

---
 algo/detectors/bmon/UnpackBmon.h | 8 ++++++++
 algo/detectors/much/UnpackMuch.h | 8 ++++++++
 algo/detectors/sts/UnpackSts.h   | 8 +++++++-
 algo/detectors/tof/UnpackTof.h   | 8 ++++++++
 algo/detectors/trd/UnpackTrd.h   | 8 ++++++++
 reco/tasks/CbmTaskUnpack.cxx     | 4 +---
 6 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/algo/detectors/bmon/UnpackBmon.h b/algo/detectors/bmon/UnpackBmon.h
index 5549a677c7..576f714b43 100644
--- a/algo/detectors/bmon/UnpackBmon.h
+++ b/algo/detectors/bmon/UnpackBmon.h
@@ -15,6 +15,7 @@
 #include <cstddef>
 #include <cstdint>
 #include <memory>
+#include <sstream>
 #include <vector>
 
 #include "CriGet4Mess001.h"
@@ -63,6 +64,13 @@ namespace cbm::algo
                            + fNumErrInvalidMsSize + fNumErrTimestampOverflow;
       return (numErrors > 0 ? true : false);
     }
+    std::string print()
+    {
+      std::stringstream ss;
+      ss << "errors " << fNumNonHitOrTsbMessage << " | " << fNumErrElinkOutOfRange << " | "
+         << fNumErrInvalidFirstMessage << " | " << fNumErrInvalidMsSize << " | " << fNumErrTimestampOverflow << " | ";
+      return ss.str();
+    }
   };
 
 
diff --git a/algo/detectors/much/UnpackMuch.h b/algo/detectors/much/UnpackMuch.h
index fe0310fc73..a5af4d786c 100644
--- a/algo/detectors/much/UnpackMuch.h
+++ b/algo/detectors/much/UnpackMuch.h
@@ -15,6 +15,7 @@
 #include <cstddef>
 #include <cstdint>
 #include <memory>
+#include <sstream>
 #include <vector>
 
 #include "StsXyterMessage.h"
@@ -61,6 +62,13 @@ namespace cbm::algo
                            + fNumErrInvalidMsSize + fNumErrTimestampOverflow;
       return (numErrors > 0 ? true : false);
     }
+    std::string print()
+    {
+      std::stringstream ss;
+      ss << "errors " << fNumNonHitOrTsbMessage << " | " << fNumErrElinkOutOfRange << " | "
+         << fNumErrInvalidFirstMessage << " | " << fNumErrInvalidMsSize << " | " << fNumErrTimestampOverflow << " | ";
+      return ss.str();
+    }
   };
 
 
diff --git a/algo/detectors/sts/UnpackSts.h b/algo/detectors/sts/UnpackSts.h
index ed1fd22a25..522ca24051 100644
--- a/algo/detectors/sts/UnpackSts.h
+++ b/algo/detectors/sts/UnpackSts.h
@@ -66,9 +66,15 @@ namespace cbm::algo
                            + fNumErrInvalidMsSize + fNumErrTimestampOverflow;
       return (numErrors > 0 ? true : false);
     }
+    std::string print()
+    {
+      std::stringstream ss;
+      ss << "errors " << fNumNonHitOrTsbMessage << " | " << fNumErrElinkOutOfRange << " | "
+         << fNumErrInvalidFirstMessage << " | " << fNumErrInvalidMsSize << " | " << fNumErrTimestampOverflow << " | ";
+      return ss.str();
+    }
   };
 
-
   /** @class UnpackSts
    ** @author Pierre-Alain Loizeau <p.-a.loizeau@gsi.de>
    ** @author Volker Friese <v.friese@gsi.de>
diff --git a/algo/detectors/tof/UnpackTof.h b/algo/detectors/tof/UnpackTof.h
index ac1166be47..c616229b3c 100644
--- a/algo/detectors/tof/UnpackTof.h
+++ b/algo/detectors/tof/UnpackTof.h
@@ -15,6 +15,7 @@
 #include <cstddef>
 #include <cstdint>
 #include <memory>
+#include <sstream>
 #include <vector>
 
 #include "CriGet4Mess001.h"
@@ -61,6 +62,13 @@ namespace cbm::algo
                            + fNumErrInvalidStartEpoch;
       return (numErrors > 0 ? true : false);
     }
+    std::string print()
+    {
+      std::stringstream ss;
+      ss << "errors " << fNumNonHitOrTsbMessage << " | " << fNumErrElinkOutOfRange << " | "
+         << fNumErrInvalidFirstMessage << " | " << fNumErrInvalidMsSize << " | " << fNumErrTimestampOverflow << " | ";
+      return ss.str();
+    }
   };
 
   /** @class UnpackTof
diff --git a/algo/detectors/trd/UnpackTrd.h b/algo/detectors/trd/UnpackTrd.h
index 8d43d737cf..737722a572 100644
--- a/algo/detectors/trd/UnpackTrd.h
+++ b/algo/detectors/trd/UnpackTrd.h
@@ -13,6 +13,7 @@
 #include "Timeslice.hpp"
 
 #include <memory>
+#include <sstream>
 
 #include <cmath>
 
@@ -84,6 +85,13 @@ namespace cbm::algo
                            + fNumErrInvalidMsSize + fNumErrTimestampOverflow;
       return (numErrors > 0 ? true : false);
     }
+    std::string print()
+    {
+      std::stringstream ss;
+      ss << "errors " << fNumNonHitOrTsbMessage << " | " << fNumErrElinkOutOfRange << " | "
+         << fNumErrInvalidFirstMessage << " | " << fNumErrInvalidMsSize << " | " << fNumErrTimestampOverflow << " | ";
+      return ss.str();
+    }
   };
 
 
diff --git a/reco/tasks/CbmTaskUnpack.cxx b/reco/tasks/CbmTaskUnpack.cxx
index a5b8926b88..7aafa5cbbc 100644
--- a/reco/tasks/CbmTaskUnpack.cxx
+++ b/reco/tasks/CbmTaskUnpack.cxx
@@ -76,9 +76,7 @@ uint64_t CbmTaskUnpack::MsLoop(const fles::Timeslice* timeslice, UnpackAlgo& alg
     *numBytesInComp += msDescriptor.size;
     auto result = algo(msContent, msDescriptor, timeslice->start_time());
     LOG(debug1) << GetName() << ": Component " << comp << ", microslice " << mslice << ", digis " << result.first.size()
-                << ", errors " << result.second.fNumNonHitOrTsbMessage << " | " << result.second.fNumErrElinkOutOfRange
-                << " | " << result.second.fNumErrInvalidFirstMessage << " | " << result.second.fNumErrInvalidMsSize
-                << " | " << result.second.fNumErrTimestampOverflow << " | ";
+                << ", " << result.second.print();
     *numDigisInComp += result.first.size();
 #pragma omp critical(insert_digis)
     digis->insert(digis->end(), result.first.begin(), result.first.end());
-- 
GitLab