File indexing completed on 2025-08-06 08:17:18
0001
0002
0003
0004
0005
0006 #include "DecodingStat.h"
0007 #include "PixelData.h"
0008 #include "mvtx_utils.h"
0009
0010 #include <bitset>
0011 #include <sstream>
0012
0013 using namespace mvtx;
0014
0015 #if (__cplusplus >= CXX_17)
0016 constexpr std::array<std::string_view, ChipStat::NErrorsDefined> ChipStat::ErrNames;
0017 #endif
0018
0019 constexpr std::array<uint32_t, ChipStat::NErrorsDefined> ChipStat::ErrActions;
0020
0021
0022 uint32_t ChipStat::getNErrors() const
0023 {
0024 uint32_t nerr = 0;
0025 for (int i = NErrorsDefined; i--;)
0026 {
0027 nerr += errorCounts[i];
0028 }
0029 return nerr;
0030 }
0031
0032
0033
0034 uint32_t ChipStat::addErrors(uint32_t mask, uint16_t chID, int verbosity)
0035 {
0036 uint32_t res = 0;
0037 if (mask)
0038 {
0039 for (uint32_t i = NErrorsDefined; i--;)
0040 {
0041 if (mask & (0x1U << i))
0042 {
0043 res |= ErrActions[i] & ErrActPropagate;
0044 if (verbosity > -1 && (!errorCounts[i] || verbosity > 1))
0045 {
0046 log_error << "New error registered on the FEEID: " << feeID << ": chip: " << chID << " " << ErrNames[i] << std::endl;
0047 res |= ErrActions[i] & ErrActDump;
0048 }
0049 errorCounts[i]++;
0050 }
0051 }
0052 }
0053 return res;
0054 }
0055
0056
0057
0058 uint32_t ChipStat::addErrors(const ChipPixelData& d, int verbosity)
0059 {
0060 uint32_t res = 0;
0061 if (d.getErrorFlags())
0062 {
0063 for (uint32_t i = NErrorsDefined; i--;)
0064 {
0065 if (d.getErrorFlags() & (0x1U << i))
0066 {
0067 res |= ErrActions[i] & ErrActPropagate;
0068 if (verbosity > -1 && (!errorCounts[i] || verbosity > 1))
0069 {
0070
0071
0072
0073 res |= ErrActions[i] & ErrActDump;
0074 }
0075 errorCounts[i]++;
0076 }
0077 }
0078 }
0079 return res;
0080 }
0081
0082
0083
0084 void ChipStat::print(bool skipNoErr, const std::string& pref) const
0085 {
0086 uint32_t nErr = 0;
0087 for (int i = NErrorsDefined; i--;)
0088 {
0089 nErr += errorCounts[i];
0090 }
0091 if (!skipNoErr || nErr)
0092 {
0093 std::ostringstream rep(pref.c_str());
0094 rep << feeID << " NHits: " << nHits << " errors: " << nErr;
0095 for (uint32_t i = 0; i < NErrorsDefined; i++)
0096 {
0097 if (!skipNoErr || errorCounts[i])
0098 {
0099 rep << " | Err.: " << ErrNames[i].data() << " : " << errorCounts[i];
0100 }
0101 }
0102 log_error << rep.str().c_str() << std::endl;
0103 }
0104 }
0105
0106
0107
0108 void GBTLinkDecodingStat::print(bool skipNoErr) const
0109 {
0110 int nErr = 0;
0111 for (int i = NErrorsDefined; i--;)
0112 {
0113 nErr += errorCounts[i];
0114 }
0115 if (!skipNoErr || nErr)
0116 {
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138 }
0139 }