Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:19:54

0001 // @file ChipStat.cxx
0002 // @brief Alpide Chip decoding statistics
0003 // @sa <O2/Detectors/ITSMFT/common/reconstruction/src/DecodingStat.cxx>
0004 //     <3cbcf82df>
0005 
0006 #include "DecodingStat.h"
0007 #include "PixelData.h"
0008 
0009 using namespace mvtx;
0010 
0011 #if (__cplusplus >= CXX_17)
0012 constexpr std::array<std::string_view, ChipStat::NErrorsDefined>
0013     ChipStat::ErrNames;
0014 #endif
0015 
0016 constexpr std::array<uint32_t, ChipStat::NErrorsDefined> ChipStat::ErrActions;
0017 
0018 //________________________________________________________________________________
0019 uint32_t ChipStat::getNErrors() const
0020 {
0021   uint32_t nerr = 0;
0022   for (int i = NErrorsDefined; i--;)
0023   {
0024     nerr += errorCounts[i];
0025   }
0026   return nerr;
0027 }
0028 
0029 //________________________________________________________________________________
0030 /// print link decoding statistics
0031 uint32_t ChipStat::addErrors(uint32_t mask, uint16_t chID, int verbosity)
0032 {
0033   uint32_t res = 0;
0034   if (mask)
0035   {
0036     for (int i = NErrorsDefined; i--;)
0037     {
0038       if (mask & (0x1 << i))
0039       {
0040         res |= ErrActions[i] & ErrActPropagate;
0041         if (verbosity > -1 && (!errorCounts[i] || verbosity > 1))
0042         {
0043           //          LOGP(important, "New error registered on the
0044           //          FEEID:{:#04x}: chip#{}: {}", feeID, chID, ErrNames[i]);
0045           res |= ErrActions[i] & ErrActDump;
0046         }
0047         errorCounts[i]++;
0048       }
0049     }
0050   }
0051   return res;
0052 }
0053 
0054 //________________________________________________________________________________
0055 /// print link decoding statistics
0056 uint32_t ChipStat::addErrors(const ChipPixelData &d, int verbosity)
0057 {
0058   uint32_t res = 0;
0059   if (d.getErrorFlags())
0060   {
0061     for (int i = NErrorsDefined; i--;)
0062     {
0063       if (d.getErrorFlags() & (0x1 << i))
0064       {
0065         res |= ErrActions[i] & ErrActPropagate;
0066         if (verbosity > -1 && (!errorCounts[i] || verbosity > 1))
0067         {
0068           //          LOGP(info, "New error registered at bc/orbit {}/{} on the
0069           //          FEEID:{:#04x} chip#{}: {}{}",
0070           //               d.getInteractionRecord().bc,
0071           //               d.getInteractionRecord().orbit, feeID,
0072           //               int16_t(d.getChipID()), ErrNames[i],
0073           //               d.getErrorDetails(i));
0074           res |= ErrActions[i] & ErrActDump;
0075         }
0076         errorCounts[i]++;
0077       }
0078     }
0079   }
0080   return res;
0081 }
0082 
0083 //________________________________________________________________________________
0084 /// print chip decoding statistics
0085 void ChipStat::print(bool skipNoErr, const std::string &pref) const
0086 {
0087   uint32_t nErr = 0;
0088   for (int i = NErrorsDefined; i--;)
0089   {
0090     nErr += errorCounts[i];
0091   }
0092   //  if (!skipNoErr || nErr) {
0093   //    std::string rep = fmt::format("{}#{:#04x} NHits: {}  errors: {}",
0094   //    pref.c_str(), feeID, nHits, nErr); for (int i = 0; i < NErrorsDefined;
0095   //    i++) {
0096   //      if (!skipNoErr || errorCounts[i]) {
0097   //        rep += fmt::format(" | Err.: {}: {}", ErrNames[i].data(),
0098   //        errorCounts[i]);
0099   //      }
0100   //    }
0101   //    LOG(info) << rep;
0102   //  }
0103 }
0104 
0105 //________________________________________________________________________________
0106 /// print link decoding statistics
0107 void GBTLinkDecodingStat::print(bool skipNoErr) const
0108 {
0109   int nErr = 0;
0110   for (int i = NErrorsDefined; i--;)
0111   {
0112     nErr += errorCounts[i];
0113   }
0114   if (!skipNoErr || nErr)
0115   {
0116     //    std::string rep = fmt::format("FEEID#{:#04x} Packet States Statistics
0117     //    (total packets: {}, triggers: {})", feeID, nPackets, nTriggers); bool
0118     //    countsSeen = false; for (int i = 0; i <
0119     //    GBTDataTrailer::MaxStateCombinations; i++) {
0120     //      if (packetStates[i]) {
0121     //        if (!countsSeen) {
0122     //          countsSeen = true;
0123     //          rep += " | counts for triggers: ";
0124     //        } else {
0125     //          rep += ", ";
0126     //        }
0127     //        std::bitset<GBTDataTrailer::NStatesDefined> patt(i);
0128     //        rep += fmt::format("b{:s}: {}", patt.to_string().c_str(),
0129     //        packetStates[i]);
0130     //      }
0131     //    }
0132     //    rep += fmt::format(" | Decoding errors: {}", nErr);
0133     //    for (int i = 0; i < NErrorsDefined; i++) {
0134     //      if (!skipNoErr || errorCounts[i]) {
0135     //        rep += fmt::format(" [{}: {}]", ErrNames[i].data(),
0136     //        errorCounts[i]);
0137     //      }
0138     //    }
0139     //    LOG(info) << rep;
0140   }
0141 }