File indexing completed on 2024-04-06 12:04:01
0001 #ifndef DataFormats_CTPPSDigi_HPTDCErrorFlags_h
0002 #define DataFormats_CTPPSDigi_HPTDCErrorFlags_h
0003
0004 #include <string>
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 class HPTDCErrorFlags {
0016 public:
0017 HPTDCErrorFlags(unsigned short flags = 0) : error_flags(flags) {}
0018
0019 bool errorId(unsigned short id) const {
0020 switch (id) {
0021 case 0:
0022 return internalFatalChipError();
0023 case 1:
0024 return eventLost();
0025 case 2:
0026 return hitRejectedByEventSizeLimit();
0027 case 3:
0028 return hitErrorGroup3();
0029 case 4:
0030 return hitLostL1OverflowGroup3();
0031 case 5:
0032 return hitLostROFifoOverflowGroup3();
0033 case 6:
0034 return hitErrorGroup2();
0035 case 7:
0036 return hitLostL1OverflowGroup2();
0037 case 8:
0038 return hitLostROFifoOverflowGroup2();
0039 case 9:
0040 return hitErrorGroup1();
0041 case 10:
0042 return hitLostL1OverflowGroup1();
0043 case 11:
0044 return hitLostROFifoOverflowGroup1();
0045 case 12:
0046 return hitErrorGroup0();
0047 case 13:
0048 return hitLostL1OverflowGroup0();
0049 case 14:
0050 return hitLostROFifoOverflowGroup0();
0051 default:
0052 return true;
0053 }
0054 }
0055
0056 bool internalFatalChipError() const { return error_flags & 0x1; }
0057 bool eventLost() const { return (error_flags >> 1) & 0x1; }
0058 bool hitRejectedByEventSizeLimit() const { return (error_flags >> 2) & 0x1; }
0059 bool hitErrorGroup3() const { return (error_flags >> 3) & 0x1; }
0060 bool hitLostL1OverflowGroup3() const { return (error_flags >> 4) & 0x1; }
0061 bool hitLostROFifoOverflowGroup3() const { return (error_flags >> 5) & 0x1; }
0062 bool hitErrorGroup2() const { return (error_flags >> 6) & 0x1; }
0063 bool hitLostL1OverflowGroup2() const { return (error_flags >> 7) & 0x1; }
0064 bool hitLostROFifoOverflowGroup2() const { return (error_flags >> 8) & 0x1; }
0065 bool hitErrorGroup1() const { return (error_flags >> 9) & 0x1; }
0066 bool hitLostL1OverflowGroup1() const { return (error_flags >> 10) & 0x1; }
0067 bool hitLostROFifoOverflowGroup1() const { return (error_flags >> 11) & 0x1; }
0068 bool hitErrorGroup0() const { return (error_flags >> 12) & 0x1; }
0069 bool hitLostL1OverflowGroup0() const { return (error_flags >> 13) & 0x1; }
0070 bool hitLostROFifoOverflowGroup0() const { return (error_flags >> 14) & 0x1; }
0071
0072 inline unsigned short errorFlag() const { return error_flags; }
0073
0074 static std::string hptdcErrorName(const unsigned short id) {
0075 switch (id) {
0076 case 0:
0077 return "InternalFatalChipError";
0078 case 1:
0079 return "EventLost";
0080 case 2:
0081 return "HitRejectedByEventSizeLimit";
0082 case 3:
0083 return "HitErrorGroup3";
0084 case 4:
0085 return "HitLostL1OverflowGroup3";
0086 case 5:
0087 return "HitLostROFifoOverflowGroup3";
0088 case 6:
0089 return "HitErrorGroup2";
0090 case 7:
0091 return "HitLostL1OverflowGroup2";
0092 case 8:
0093 return "HitLostROFifoOverflowGroup2";
0094 case 9:
0095 return "HitErrorGroup1";
0096 case 10:
0097 return "HitLostL1OverflowGroup1";
0098 case 11:
0099 return "HitLostROFifoOverflowGroup1";
0100 case 12:
0101 return "HitErrorGroup0";
0102 case 13:
0103 return "HitLostL1OverflowGroup0";
0104 case 14:
0105 return "HitLostROFifoOverflowGroup0";
0106 default:
0107 return "NONE";
0108 }
0109 }
0110
0111 private:
0112 unsigned short error_flags;
0113 };
0114
0115 #endif