From e2e45fd44c6d2c441affafb52dce1ad08d657887 Mon Sep 17 00:00:00 2001
From: Felix Weiglhofer <weiglhofer@fias.uni-frankfurt.de>
Date: Mon, 19 Jun 2023 15:11:30 +0000
Subject: [PATCH] algo: Adjust logging.

---
 algo/detectors/bmon/BmonReadoutConfig.cxx | 15 +++++++++------
 algo/detectors/tof/TofReadoutConfig.cxx   | 18 +++++++++---------
 algo/unpack/Unpack.cxx                    | 14 +++++++-------
 algo/unpack/UnpackChain.cxx               |  2 +-
 core/data/bmon/CbmBmonDigiData.h          |  1 +
 core/data/sts/CbmStsDigiData.h            |  2 ++
 core/data/tof/CbmTofDigiData.h            |  1 +
 7 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/algo/detectors/bmon/BmonReadoutConfig.cxx b/algo/detectors/bmon/BmonReadoutConfig.cxx
index 021c0167e6..1edee46e7d 100644
--- a/algo/detectors/bmon/BmonReadoutConfig.cxx
+++ b/algo/detectors/bmon/BmonReadoutConfig.cxx
@@ -9,6 +9,8 @@
 #include <bitset>
 #include <iomanip>
 
+#include <fmt/format.h>
+
 #include "AlgoFairloggerCompat.h"
 #include "gDpbMessv100.h"
 
@@ -118,7 +120,7 @@ namespace cbm::algo
           break;
         }
         case -1: {
-          LOG(info) << " Found unused GBTX link at uCh = " << uCh;
+          L_(warning) << " Found unused GBTX link at uCh = " << uCh;
           uCh += 160;
           break;
         }
@@ -135,7 +137,7 @@ namespace cbm::algo
   // -------------------------------------------------------------------------
   void BmonReadoutConfig::BuildChannelsUidMapT0(uint32_t& uCh, uint32_t uGbtx)
   {
-    LOG(info) << " Map diamond " << moduleId[uGbtx] << " at GBTX " << uGbtx << " -  uCh = " << uCh;
+    L_(debug) << " Map diamond " << moduleId[uGbtx] << " at GBTX " << uGbtx << " -  uCh = " << uCh;
     for (uint32_t uGet4 = 0; uGet4 < numElinksPerCrob; ++uGet4) {
       for (uint32_t uGet4Ch = 0; uGet4Ch < numChanPerAsic; ++uGet4Ch) {
         /// Mapping for the 2022 beamtime
@@ -143,7 +145,8 @@ namespace cbm::algo
           uint32_t uChannelT0 = uGet4 + 32 * rpcSide[uGbtx];
           uChannelT0 /= 8;
           fviRpcChUId[uCh] = CbmTofAddress::GetUniqueAddress(moduleId[uGbtx], 0, uChannelT0, 0, rpcType[uGbtx]);
-          printf("  T0 channel: %u from GBTx %2u, indx %d address %08x", uChannelT0, uGbtx, uCh, fviRpcChUId[uCh]);
+          L_(debug) << fmt::format("  T0 channel: %u from GBTx %2u, indx %d address %08x", uChannelT0, uGbtx, uCh,
+                                   fviRpcChUId[uCh]);
         }  // Valid T0 channel
         else {
           fviRpcChUId[uCh] = 0;
@@ -156,7 +159,7 @@ namespace cbm::algo
   // -------------------------------------------------------------------------
   void BmonReadoutConfig::BuildChannelsUidMapT0_2022(uint32_t& uCh, uint32_t uGbtx)
   {
-    LOG(info) << " Map 2022 diamond " << moduleId[uGbtx] << " at GBTX " << uGbtx << " -  uCh = " << uCh;
+    L_(debug) << " Map 2022 diamond " << moduleId[uGbtx] << " at GBTX " << uGbtx << " -  uCh = " << uCh;
     for (uint32_t uGet4 = 0; uGet4 < numElinksPerCrob; ++uGet4) {
       for (uint32_t uGet4Ch = 0; uGet4Ch < numChanPerAsic; ++uGet4Ch) {
         /// Mapping for the 2022 beamtime
@@ -166,8 +169,8 @@ namespace cbm::algo
           uint32_t uChannelT0 = (uGet4 / 8 + 4 * (uGbtx / 2)) % 16;
           /// Type hard-coded to allow different parameter values to separate 2022 T0 and pre-2022 T0
           fviRpcChUId[uCh] = CbmTofAddress::GetUniqueAddress(moduleId[uGbtx], 0, uChannelT0, rpcSide[uGbtx], 5);
-          printf("  Bmon channel: %u side %u from GBTx %2u, indx %d address %08x \n", uChannelT0, rpcSide[uGbtx], uGbtx,
-                 uCh, fviRpcChUId[uCh]);
+          L_(debug) << fmt::format("  Bmon channel: %u side %u from GBTx %2u, indx %d address %08x \n", uChannelT0,
+                                   rpcSide[uGbtx], uGbtx, uCh, fviRpcChUId[uCh]);
         }  // Valid T0 channel
         else {
           fviRpcChUId[uCh] = 0;
diff --git a/algo/detectors/tof/TofReadoutConfig.cxx b/algo/detectors/tof/TofReadoutConfig.cxx
index 5ce129e3b1..8026523eab 100644
--- a/algo/detectors/tof/TofReadoutConfig.cxx
+++ b/algo/detectors/tof/TofReadoutConfig.cxx
@@ -172,7 +172,7 @@ namespace cbm::algo
           break;
         }
         case -1: {
-          LOG(info) << " Found unused GBTX link at uCh = " << uCh;
+          LOG(warning) << " Found unused GBTX link at uCh = " << uCh;
           uCh += 160;
           break;
         }
@@ -192,9 +192,9 @@ namespace cbm::algo
   // -------------------------------------------------------------------------
   void TofReadoutConfig::BuildChannelsUidMapCbm(uint32_t& uCh, uint32_t uGbtx)
   {
-    LOG(info) << " Map mTof box " << moduleId[uGbtx] << " at GBTX " << uGbtx << " -  uCh = " << uCh;
+    L_(debug) << " Map mTof box " << moduleId[uGbtx] << " at GBTX " << uGbtx << " -  uCh = " << uCh;
     if (rpcSide[uGbtx] < 2) {  // mTof modules
-      LOG(debug) << " Map mTof box " << moduleId[uGbtx] << " at GBTX  -  uCh = " << uCh;
+      L_(debug) << " Map mTof box " << moduleId[uGbtx] << " at GBTX  -  uCh = " << uCh;
       const int32_t RpcMap[5] = {4, 2, 0, 3, 1};
       for (int32_t iRpc = 0; iRpc < numRpc[uGbtx]; iRpc++) {
         int32_t iStrMax  = 32;
@@ -222,7 +222,7 @@ namespace cbm::algo
   {
     if (rpcSide[uGbtx] < 2) {
       // mTof modules
-      LOG(info) << "Start eTOF module side " << rpcSide[uGbtx] << " at " << uCh;
+      L_(debug) << "Start eTOF module side " << rpcSide[uGbtx] << " at " << uCh;
       const int32_t RpcMap[3] = {0, 1, 2};
       for (int32_t iRpc = 0; iRpc < numRpc[uGbtx]; iRpc++) {
         int32_t iStrMax = 32;
@@ -248,7 +248,7 @@ namespace cbm::algo
   // -------------------------------------------------------------------------
   void TofReadoutConfig::BuildChannelsUidMapCern(uint32_t& uCh, uint32_t)
   {
-    LOG(info) << " Map CERN 20 gap  at GBTX  -  uCh = " << uCh;
+    L_(debug) << " Map CERN 20 gap  at GBTX  -  uCh = " << uCh;
     // clang-format off
   const int32_t StrMap[32] = {0,  1,  2,  3,  4,  31, 5,  6,  7,  30, 8,
                             9,  10, 29, 11, 12, 13, 14, 28, 15, 16, 17,
@@ -268,7 +268,7 @@ namespace cbm::algo
         uCh++;
       }
     }
-    LOG(info) << " Map end CERN 20 gap  at GBTX  -  uCh = " << uCh;
+    L_(debug) << " Map end CERN 20 gap  at GBTX  -  uCh = " << uCh;
   }
 
   // -------------------------------------------------------------------------
@@ -281,14 +281,14 @@ namespace cbm::algo
       uCh++;
     }
     uCh += (24 + 2 * 32);
-    LOG(info) << " Map end ceramics  box  at GBTX  -  uCh = " << uCh;
+    L_(debug) << " Map end ceramics  box  at GBTX  -  uCh = " << uCh;
   }
 
 
   // -------------------------------------------------------------------------
   void TofReadoutConfig::BuildChannelsUidMapStar2(uint32_t& uCh, uint32_t uGbtx)
   {
-    LOG(info) << " Map Star2 box " << moduleId[uGbtx] << " at GBTX " << uGbtx << " -  uCh = " << uCh;
+    L_(debug) << " Map Star2 box " << moduleId[uGbtx] << " at GBTX " << uGbtx << " -  uCh = " << uCh;
     const int32_t iRpc[5]  = {1, -1, 1, 0, 0};
     const int32_t iSide[5] = {1, -1, 0, 1, 0};
     for (int32_t iFeet = 0; iFeet < 5; iFeet++) {
@@ -346,7 +346,7 @@ namespace cbm::algo
   // -------------------------------------------------------------------------
   void TofReadoutConfig::BuildChannelsUidMapBuc(uint32_t& uCh, uint32_t uGbtx)
   {
-    LOG(info) << " Map Buc box " << moduleId[uGbtx] << " at GBTX " << uGbtx << " -  uCh = " << uCh;
+    L_(debug) << " Map Buc box " << moduleId[uGbtx] << " at GBTX " << uGbtx << " -  uCh = " << uCh;
 
     int32_t iModuleIdMap   = moduleId[uGbtx];
     const int32_t iRpc[5]  = {0, -1, 0, 1, 1};
diff --git a/algo/unpack/Unpack.cxx b/algo/unpack/Unpack.cxx
index b28d9f092a..6d179ed130 100644
--- a/algo/unpack/Unpack.cxx
+++ b/algo/unpack/Unpack.cxx
@@ -7,8 +7,8 @@
 
 #include <chrono>
 
-#include "AlgoFairloggerCompat.h"
 #include "compat/Algorithm.h"
+#include "log.hpp"
 
 using namespace std;
 
@@ -166,7 +166,7 @@ namespace cbm::algo
         par->fElinkParams.push_back(elinkPar);
       }
       fAlgoSts[equip].SetParams(std::move(par));
-      L_(info) << "--- Configured equipment " << equip << " with " << numElinks << " elinks";
+      L_(debug) << "--- Configured equipment " << equip << " with " << numElinks << " elinks";
     }  //# equipments
 
     // Create one algorithm per component for MUCH and configure it with parameters
@@ -181,7 +181,7 @@ namespace cbm::algo
         par->fElinkParams.push_back(elinkPar);
       }
       fAlgoMuch[equip].SetParams(std::move(par));
-      L_(info) << "--- Configured equipment " << equip << " with " << numElinks << " elinks";
+      L_(debug) << "--- Configured equipment " << equip << " with " << numElinks << " elinks";
     }
 
     // Create one algorithm per component for TOF and configure it with parameters
@@ -196,7 +196,7 @@ namespace cbm::algo
         par->fElinkParams.push_back(elinkPar);
       }
       fAlgoTof[equip].SetParams(std::move(par));
-      L_(info) << "--- Configured equipment " << equip << " with " << numElinks << " elinks";
+      L_(debug) << "--- Configured equipment " << equip << " with " << numElinks << " elinks";
     }
 
     // Create one algorithm per component for T0 and configure it with parameters
@@ -211,7 +211,7 @@ namespace cbm::algo
         par->fElinkParams.push_back(elinkPar);
       }
       fAlgoBmon[equip].SetParams(std::move(par));
-      L_(info) << "--- Configured equipment " << equip << " with " << numElinks << " elinks";
+      L_(debug) << "--- Configured equipment " << equip << " with " << numElinks << " elinks";
     }
 
     // Create one algorithm per component and configure it with parameters
@@ -250,7 +250,7 @@ namespace cbm::algo
         par->fCrobParams.push_back(crobPar);
       }
       fAlgoTrd[equip].SetParams(std::move(par));
-      L_(info) << "--- Configured equipment " << equip << " with " << numCrobs << " crobs";
+      L_(debug) << "--- Configured equipment " << equip << " with " << numCrobs << " crobs";
     }
 
     // Create one algorithm per component for TRD2D and configure it with parameters
@@ -279,7 +279,7 @@ namespace cbm::algo
         par->fAsicParams.push_back(asicPar);
       }
       fAlgoTrd2d[equip].SetParams(std::move(par));
-      L_(info) << "--- Configured equipment " << equip << " with " << numAsics << " asics";
+      L_(debug) << "--- Configured equipment " << equip << " with " << numAsics << " asics";
     }
 
     L_(info) << "--- Configured " << fAlgoSts.size() << " unpacker algorithms for STS.";
diff --git a/algo/unpack/UnpackChain.cxx b/algo/unpack/UnpackChain.cxx
index 21e6742b60..256d557307 100644
--- a/algo/unpack/UnpackChain.cxx
+++ b/algo/unpack/UnpackChain.cxx
@@ -25,7 +25,7 @@ Unpack::resultType UnpackChain::Run(const fles::Timeslice& timeslice)
 
   L_(info) << "Timeslice contains " << digis.fSts.Size() << " STS Digis";
   L_(info) << "Timeslice contains " << digis.fTof.Size() << " TOF Digis";
-  L_(info) << "Timeslice contains " << digis.fT0.Size() << " RPC Digis";
+  L_(info) << "Timeslice contains " << digis.fT0.Size() << " T0 Digis";
 
   return result;
 }
diff --git a/core/data/bmon/CbmBmonDigiData.h b/core/data/bmon/CbmBmonDigiData.h
index ef9f4ab74d..9cfb9624e8 100644
--- a/core/data/bmon/CbmBmonDigiData.h
+++ b/core/data/bmon/CbmBmonDigiData.h
@@ -43,6 +43,7 @@ public:
 
   /** @brief Clear content **/
   void Clear() { fDigis.clear(); }
+  size_t Size() const { return fDigis.size(); }
 
   // --- ROOT serializer
 #ifndef NO_ROOT
diff --git a/core/data/sts/CbmStsDigiData.h b/core/data/sts/CbmStsDigiData.h
index 0aaca34199..a00d86ae22 100644
--- a/core/data/sts/CbmStsDigiData.h
+++ b/core/data/sts/CbmStsDigiData.h
@@ -43,6 +43,8 @@ public:
   /** @brief Clear content **/
   void Clear() { fDigis.clear(); }
 
+  size_t Size() const { return fDigis.size(); }
+
   // --- ROOT serializer
 #ifndef NO_ROOT
   ClassDefNV(CbmStsDigiData, 1);
diff --git a/core/data/tof/CbmTofDigiData.h b/core/data/tof/CbmTofDigiData.h
index dcd73b1598..7b40710ebd 100644
--- a/core/data/tof/CbmTofDigiData.h
+++ b/core/data/tof/CbmTofDigiData.h
@@ -43,6 +43,7 @@ public:
 
   /** @brief Clear content **/
   void Clear() { fDigis.clear(); }
+  size_t Size() const { return fDigis.size(); }
 
   // --- ROOT serializer
 #ifndef NO_ROOT
-- 
GitLab