Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:18

0001 // @file GBTWord.h
0002 // @brief Classes for creation/interpretation of MVTX GBT data
0003 // @sa <O2/Detectors/ITSMFT/common/reconstruction/include/ITSMFTReconstruction/GBTWord.h>
0004 //     <d03b22564>
0005 
0006 #ifndef MVTXDECODER_GBTWORD_H
0007 #define MVTXDECODER_GBTWORD_H
0008 
0009 #include <cstdint>
0010 #include <string>
0011 
0012 namespace mvtx
0013 {
0014 
0015 constexpr uint64_t LANESMask = (0x1 << 9) - 1; // at most 9 lanes
0016 
0017 /// GBT payload header flag
0018 constexpr uint8_t GBTFlagIHW = 0xe0;
0019 /// GBT trigger status word flag
0020 constexpr uint8_t GBTFlagTDH = 0xe8;
0021 /// GBT calibration status word flag
0022 constexpr uint8_t GBTFlagCDW = 0xf8;
0023 /// GBT payload trailer flag
0024 constexpr uint8_t GBTFlagTDT = 0xf0;
0025 /// GBT diagnostic status word flag
0026 constexpr uint8_t GBTFlagDDW = 0xe4;
0027 
0028 // GBT header flag in the RDH
0029 constexpr uint8_t GBTFlagRDH = 0x00;
0030 
0031 // GBT header flag for the ITS IB: 001 bbbbb with bbbbb -> Lane Number (0-8)
0032 constexpr uint8_t GBTFlagDataIB = 0x20;
0033 
0034 // GBT header flag for the ITS IB idagnostic : 101 bbbbb with bbbbb -> Lane Number (0-8)
0035 constexpr uint8_t GBTFlagDiagnosticIB = 0xa0;
0036 
0037 constexpr int GBTWordLength = 10;       // lentgh in bytes
0038 
0039 struct GBTWord {
0040 #pragma GCC diagnostic push
0041 #pragma GCC diagnostic ignored "-Wpedantic"
0042   /// GBT word of 80 bits, bits 72:79 are reserver for GBT Header flag, the rest depends on specifications
0043   union {
0044     struct {
0045       uint64_t activeLanes : 28; /// 0:27   Bit map of lanes active and eligible for readout
0046       uint64_t na0hn : 36;       /// 28:71  reserved
0047       uint64_t na1hn : 8;        /// 28:71  reserved
0048       uint64_t id : 8;           /// 72:79  0xe0; Header Status Word (HSW) identifier
0049     };                           // ITS HEADER WWORD (IHW)
0050 
0051     // RS: packing will be needed only if some of the members cross 64 bit boundary
0052     struct __attribute__((packed)) {
0053       uint64_t triggerType : 12; /// 0:11   12 lowest bits of trigger type received from CTP
0054       uint64_t internal : 1;     /// 12     Used in Continuous Mode for internally generated trigger
0055       uint64_t noData : 1;       /// 13     No data expected (too close to previous trigger or error)
0056       uint64_t continuation : 1; /// 14     following data is continuation of the trigger from the previous CRU page
0057       uint64_t na1tr : 1;        /// 15     reserved
0058       uint64_t bc : 12;          /// 16:27  Trigger LHC BC (40MHz) from RU
0059       uint64_t na2tr : 4;        /// 28:31  reserved
0060       uint64_t bco : 40;         /// 32:71  sPHENIX GTM BCO
0061 //      uint8_t  id : 8;         /// = 0xe8; Trigger Data Header (TDH) identifier
0062     }; // TRIGGER DATA HEADER (TDH)
0063 
0064     struct __attribute__((packed)) {
0065       uint64_t calibUserField : 48; /// 0:47   user field
0066       uint64_t calibCounter : 24;   /// 48:71  elf-incrementing counter of
0067 //    uint64_t id : 8;              /// 72:79  0xf8; Calibration Status Word (HSW) identifier
0068     }; /// Calibration Data Word
0069 
0070 
0071     struct {
0072       uint64_t lanesStatus : 56;           /// 0:55  Bit map of “Valid Lane stops received”, 1 bit per lane, NOT USED
0073       uint64_t na0t : 5;                   /// 56:60 reserved
0074       uint64_t timeout_in_idle : 1;        /// 61  = 1 if timeout waiting for a valid word from lanes
0075       uint64_t timeout_start_stop : 1;     /// 62  = 1 if timeout waiting for end-of-packet from all lanes
0076       uint64_t timeout_to_start : 1;       /// 63  = 1 if timeout waiting for first word from first lane
0077       uint64_t packet_done : 1;            /// 64  = 1 when current trigger packets transmission done
0078       uint64_t transmission_timeout : 1;   /// 65  = 1 if timeout while waiting for data on lanes
0079       uint64_t na1t : 1;                   /// 66  reserved
0080       uint64_t lane_starts_violation : 1;  /// 67  = 1 if at least 1 lane (eligible for readout) had a “start violation”
0081       uint64_t lane_timeouts : 1;          /// 68  = 1 if at least 1 lane (eligible for readout) timed out
0082       uint64_t na2t : 3;                   /// 69:71  reserved
0083 //        uint8_t  id : 8;                 /// = 0xf0; Trigger Data Trailer (TDT) identifier
0084     }; // TRIGGER DATA TRAILER
0085 
0086     struct {
0087       uint64_t lane_status : 56;            /// 0:55  Readout status of the lanes for the current HBF.
0088                                             ///       Higher status level achieved for each lane taken from each TDT.
0089       uint64_t na3tr : 8;                   /// 56:63 reserved
0090       uint64_t na4tr : 1;                   /// 64    reserved
0091       uint64_t transmission_timeouts : 1;   /// 65    = 1 One or more lanes had a timeout in this HBF.
0092                                             ///       Cummulative logic OR of transmission_timeout field of the TDTs.
0093       uint64_t na5tr : 1;                   /// 66    reserved
0094       uint64_t lane_starts_violations : 1;  /// 67    = 1 One or more lanes had a protocol violation in this HBF.
0095                                             ///       Cummulative logic OR of transmission_timeout field of the TDTs.
0096       uint64_t index : 4;                   /// 68:71 Must be = 0 DDW0
0097       //      uint64_t id : 8;              /// 72:79  0xe4;  Status Word (HSW) identifier
0098     }; // DIAGNOSTIC DATA WORD
0099 
0100     struct {
0101       uint64_t diagnostic_data : 64;  ///  0:63 Error specific diagnostic data
0102       uint8_t  lane_error_id   :  8;  /// 64:71 Identifier of the specific error condition
0103 //      uint8_t id : 8;               /// 72:79 0xa0 - 0xa8; Diagnostic IB lane
0104     }; // DIAGNOSTIC IB LANE
0105 
0106 
0107     uint8_t data8[GBTWordLength]; // 80 bits GBT word
0108   };
0109 #pragma GCC diagnostic pop
0110 
0111   GBTWord() = default;
0112 
0113   /// check if the GBT Header corresponds to GBT payload header
0114   bool isIHW() const { return id == GBTFlagIHW; }
0115 
0116   /// check if the GBT Header corresponds to GBT payload trailer
0117   bool isTDH() const { return id == GBTFlagTDH; }
0118 
0119   /// check if the GBT Header corresponds to Calibration word
0120   bool isCDW() const { return id == GBTFlagCDW; }
0121 
0122   /// check if the GBT Header corresponds to GBT trigger word
0123   bool isTDT() const { return id == GBTFlagTDT; }
0124 
0125   /// check if the GBT Header corresponds to Diagnostic data
0126   bool isDDW() const { return id == GBTFlagDDW; }
0127 
0128   /// check if the GBT Header corresponds to ITS IB diagnostics data (header is combined with lanes info)
0129   bool isDiagnosticIB() const { return (id & 0xe0) == GBTFlagDiagnosticIB; }
0130 
0131   /// check if the GBT Header corresponds to ITS IB data (header is combined with lanes info)
0132   bool isData() const { return (id & 0xe0) == GBTFlagDataIB; }
0133 
0134   const uint8_t* getW8() const { return data8; }
0135 
0136   uint8_t getHeader() const { return id; }
0137 
0138   void printX() const;
0139 
0140   std::string asString() const;
0141 
0142 //  ClassDefNV(GBTWord, 1);
0143 };
0144 
0145 struct GBTCalibDataWord : public GBTWord { // calibration data word
0146   /// bits  0 : 47, user-written tagging fields
0147   /// bits 48 : 71, self-incrementing counter of CDW words
0148   /// bits 72 : 79, calibration indicator
0149 
0150   GBTCalibDataWord() { id = GBTFlagCDW; }
0151   GBTCalibDataWord(uint64_t userData, uint16_t counter = 0)
0152   {
0153     id = GBTFlagCDW;
0154     calibUserField = userData & ((0x1UL << 48) - 1);
0155     calibCounter = counter & ((0x1 << 24) - 1);
0156   }
0157 //  ClassDefNV(GBTCalibration, 1);
0158 };
0159 
0160 } // namespace mvtx
0161 
0162 #endif