Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DecodingStat.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DecodingStat.cxx
1 // @file ChipStat.cxx
2 // @brief Alpide Chip decoding statistics
3 // @sa <O2/Detectors/ITSMFT/common/reconstruction/src/DecodingStat.cxx>
4 // <3cbcf82df>
5 
8 #include <bitset>
9 
10 using namespace mvtx;
11 
12 #if ( __cplusplus >= CXX_17 )
13  constexpr std::array<std::string_view, ChipStat::NErrorsDefined> ChipStat::ErrNames;
14 #endif
15 
16  constexpr std::array<uint32_t, ChipStat::NErrorsDefined> ChipStat::ErrActions;
17 
18 //________________________________________________________________________________
19 uint32_t ChipStat::getNErrors() const
20 {
21  uint32_t nerr = 0;
22  for (int i = NErrorsDefined; i--;) {
23  nerr += errorCounts[i];
24  }
25  return nerr;
26 }
27 
28 //________________________________________________________________________________
30 uint32_t ChipStat::addErrors(uint32_t mask, uint16_t chID, int verbosity)
31 {
32  uint32_t res = 0;
33  if (mask) {
34  for (int i = NErrorsDefined; i--;) {
35  if (mask & (0x1 << i)) {
36  res |= ErrActions[i] & ErrActPropagate;
37  if (verbosity > -1 && (!errorCounts[i] || verbosity > 1)) {
38 // LOGP(important, "New error registered on the FEEID:{:#04x}: chip#{}: {}", feeID, chID, ErrNames[i]);
39  res |= ErrActions[i] & ErrActDump;
40  }
41  errorCounts[i]++;
42  }
43  }
44  }
45  return res;
46 }
47 
48 //________________________________________________________________________________
51 {
52  uint32_t res = 0;
53  if (d.getErrorFlags()) {
54  for (int i = NErrorsDefined; i--;) {
55  if (d.getErrorFlags() & (0x1 << i)) {
56  res |= ErrActions[i] & ErrActPropagate;
57  if (verbosity > -1 && (!errorCounts[i] || verbosity > 1)) {
58 // LOGP(info, "New error registered at bc/orbit {}/{} on the FEEID:{:#04x} chip#{}: {}{}",
59 // d.getInteractionRecord().bc, d.getInteractionRecord().orbit,
60 // feeID, int16_t(d.getChipID()), ErrNames[i], d.getErrorDetails(i));
61  res |= ErrActions[i] & ErrActDump;
62  }
63  errorCounts[i]++;
64  }
65  }
66  }
67  return res;
68 }
69 
70 //________________________________________________________________________________
72 void ChipStat::print(bool skipNoErr, const std::string& pref) const
73 {
74  uint32_t nErr = 0;
75  for (int i = NErrorsDefined; i--;) {
76  nErr += errorCounts[i];
77  }
78 // if (!skipNoErr || nErr) {
79 // std::string rep = fmt::format("{}#{:#04x} NHits: {} errors: {}", pref.c_str(), feeID, nHits, nErr);
80 // for (int i = 0; i < NErrorsDefined; i++) {
81 // if (!skipNoErr || errorCounts[i]) {
82 // rep += fmt::format(" | Err.: {}: {}", ErrNames[i].data(), errorCounts[i]);
83 // }
84 // }
85 // LOG(info) << rep;
86 // }
87 }
88 
89 //________________________________________________________________________________
91 void GBTLinkDecodingStat::print(bool skipNoErr) const
92 {
93  int nErr = 0;
94  for (int i = NErrorsDefined; i--;) {
95  nErr += errorCounts[i];
96  }
97  if (!skipNoErr || nErr) {
98 // std::string rep = fmt::format("FEEID#{:#04x} Packet States Statistics (total packets: {}, triggers: {})", feeID, nPackets, nTriggers);
99 // bool countsSeen = false;
100 // for (int i = 0; i < GBTDataTrailer::MaxStateCombinations; i++) {
101 // if (packetStates[i]) {
102 // if (!countsSeen) {
103 // countsSeen = true;
104 // rep += " | counts for triggers: ";
105 // } else {
106 // rep += ", ";
107 // }
108 // std::bitset<GBTDataTrailer::NStatesDefined> patt(i);
109 // rep += fmt::format("b{:s}: {}", patt.to_string().c_str(), packetStates[i]);
110 // }
111 // }
112 // rep += fmt::format(" | Decoding errors: {}", nErr);
113 // for (int i = 0; i < NErrorsDefined; i++) {
114 // if (!skipNoErr || errorCounts[i]) {
115 // rep += fmt::format(" [{}: {}]", ErrNames[i].data(), errorCounts[i]);
116 // }
117 // }
118 // LOG(info) << rep;
119  }
120 }