Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GBTWord.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GBTWord.h
1 // @file GBTWord.h
2 // @brief Classes for creation/interpretation of MVTX GBT data
3 // @sa <O2/Detectors/ITSMFT/common/reconstruction/include/ITSMFTReconstruction/GBTWord.h>
4 // <d03b22564>
5 
6 #ifndef MVTXDECODER_GBTWORD_H
7 #define MVTXDECODER_GBTWORD_H
8 
9 #include <cstdint>
10 #include <string>
11 
12 namespace mvtx
13 {
14 
15 constexpr uint64_t LANESMask = (0x1 << 9) - 1; // at most 9 lanes
16 
18 constexpr uint8_t GBTFlagIHW = 0xe0;
20 constexpr uint8_t GBTFlagTDH = 0xe8;
22 constexpr uint8_t GBTFlagCDW = 0xf8;
24 constexpr uint8_t GBTFlagTDT = 0xf0;
26 constexpr uint8_t GBTFlagDDW = 0xe4;
27 
28 // GBT header flag in the RDH
29 constexpr uint8_t GBTFlagRDH = 0x00;
30 
31 // GBT header flag for the ITS IB: 001 bbbbb with bbbbb -> Lane Number (0-8)
32 constexpr uint8_t GBTFlagDataIB = 0x20;
33 
34 // GBT header flag for the ITS IB idagnostic : 101 bbbbb with bbbbb -> Lane Number (0-8)
35 constexpr uint8_t GBTFlagDiagnosticIB = 0xa0;
36 
37 constexpr int GBTWordLength = 10; // lentgh in bytes
38 
39 struct GBTWord {
40 #pragma GCC diagnostic push
41 #pragma GCC diagnostic ignored "-Wpedantic"
42 
43  union {
44  struct {
45  uint64_t activeLanes : 28;
46  uint64_t na0hn : 36;
47  uint64_t na1hn : 8;
48  uint64_t id : 8;
49  }; // ITS HEADER WWORD (IHW)
50 
51  // RS: packing will be needed only if some of the members cross 64 bit boundary
52  struct __attribute__((packed)) {
53  uint64_t triggerType : 12;
54  uint64_t internal : 1;
55  uint64_t noData : 1;
56  uint64_t continuation : 1;
57  uint64_t na1tr : 1;
58  uint64_t bc : 12;
59  uint64_t na2tr : 4;
60  uint64_t bco : 40;
61 // uint8_t id : 8; /// = 0xe8; Trigger Data Header (TDH) identifier
62  }; // TRIGGER DATA HEADER (TDH)
63 
64  struct __attribute__((packed)) {
65  uint64_t calibUserField : 48;
66  uint64_t calibCounter : 24;
67 // uint64_t id : 8; /// 72:79 0xf8; Calibration Status Word (HSW) identifier
68  };
69 
70 
71  struct {
72  uint64_t lanesStatus : 56;
73  uint64_t na0t : 5;
74  uint64_t timeout_in_idle : 1;
75  uint64_t timeout_start_stop : 1;
76  uint64_t timeout_to_start : 1;
77  uint64_t packet_done : 1;
78  uint64_t transmission_timeout : 1;
79  uint64_t na1t : 1;
80  uint64_t lane_starts_violation : 1;
81  uint64_t lane_timeouts : 1;
82  uint64_t na2t : 3;
83 // uint8_t id : 8; /// = 0xf0; Trigger Data Trailer (TDT) identifier
84  }; // TRIGGER DATA TRAILER
85 
86  struct {
87  uint64_t lane_status : 56;
88 
89  uint64_t na3tr : 8;
90  uint64_t na4tr : 1;
91  uint64_t transmission_timeouts : 1;
92 
93  uint64_t na5tr : 1;
94  uint64_t lane_starts_violations : 1;
95 
96  uint64_t index : 4;
97  // uint64_t id : 8; /// 72:79 0xe4; Status Word (HSW) identifier
98  }; // DIAGNOSTIC DATA WORD
99 
100  struct {
101  uint64_t diagnostic_data : 64;
102  uint8_t lane_error_id : 8;
103 // uint8_t id : 8; /// 72:79 0xa0 - 0xa8; Diagnostic IB lane
104  }; // DIAGNOSTIC IB LANE
105 
106 
107  uint8_t data8[GBTWordLength]; // 80 bits GBT word
108  };
109 #pragma GCC diagnostic pop
110 
111  GBTWord() = default;
112 
114  bool isIHW() const { return id == GBTFlagIHW; }
115 
117  bool isTDH() const { return id == GBTFlagTDH; }
118 
120  bool isCDW() const { return id == GBTFlagCDW; }
121 
123  bool isTDT() const { return id == GBTFlagTDT; }
124 
126  bool isDDW() const { return id == GBTFlagDDW; }
127 
129  bool isDiagnosticIB() const { return (id & 0xe0) == GBTFlagDiagnosticIB; }
130 
132  bool isData() const { return (id & 0xe0) == GBTFlagDataIB; }
133 
134  const uint8_t* getW8() const { return data8; }
135 
136  uint8_t getHeader() const { return id; }
137 
138  void printX() const;
139 
140  std::string asString() const;
141 
142 // ClassDefNV(GBTWord, 1);
143 };
144 
145 struct GBTCalibDataWord : public GBTWord { // calibration data word
149 
151  GBTCalibDataWord(uint64_t userData, uint16_t counter = 0)
152  {
153  id = GBTFlagCDW;
154  calibUserField = userData & ((0x1UL << 48) - 1);
155  calibCounter = counter & ((0x1 << 24) - 1);
156  }
157 // ClassDefNV(GBTCalibration, 1);
158 };
159 
160 } // namespace mvtx
161 
162 #endif