Project
Loading...
Searching...
No Matches
GBTWord.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef ALICEO2_ITSMFT_GBTWORD_H
13#define ALICEO2_ITSMFT_GBTWORD_H
14
15// \file GBTWord.h
16// \brief Classes for creation/interpretation of ITS/MFT GBT data
17
18#include <Rtypes.h>
19#include <cstdint>
20
21namespace o2
22{
23namespace itsmft
24{
25
26constexpr uint64_t LANESMask = (0x1 << 28) - 1; // at most 28 lanes
27
29constexpr uint8_t GBTFlagDataHeader = 0xe0;
31constexpr uint8_t GBTFlagDataTrailer = 0xf0;
33constexpr uint8_t GBTFlagTrigger = 0xe8;
35constexpr uint8_t GBTFlagDiagnostic = 0xe4;
37constexpr uint8_t GBTFlagCalibration = 0xf8;
38
39// GBT header flag in the RDH
40constexpr uint8_t GBTFlagRDH = 0x00;
41// GBT header flag for the ITS IB: 001 bbbbb with bbbbb -> Lane Number (0-8)
42constexpr uint8_t GBTFlagDataIB = 0x20;
43// GBT header flag for the ITS OB: 010 bb ccc with bb -> Connector Number (00,01,10,11), ccc -> Lane Number (0-6)
44constexpr uint8_t GBTFlagDataOB = 0x40;
45// GBT header flag for the MFT
46constexpr uint8_t GBTFlagDataMFT = 0x80;
47// GBT header flag for the ITS IB idagnostic : 101 bbbbb with bbbbb -> Lane Number (0-8)
49// GBT header flag for the ITS OB diagnostic word: 110 bb ccc with bb -> Connector Number (00,01,10,11), ccc -> Lane Number (0-6)
51
52// GBT header flag for the ITS Status word : 111 bbbbb with bbbbb -> Lane Number
53constexpr uint8_t GBTFlagStatus = 0xe0;
54
55constexpr int GBTWordLength = 10; // lentgh in bytes
56constexpr int GBTPaddedWordLength = 16; // lentgh in bytes with padding
57
58struct GBTWord {
60 union {
61 // RS: packing will be needed only if some of the members cross 64 bit boundary
62 struct /*__attribute__((packed))*/ {
67 }; // HEADER NEW
68
69 struct /*__attribute__((packed))*/ {
74 // uint64_t id : 8; /// 72:79 0xe0; Header Status Word (HSW) identifier
75 }; // HEADER Legacy
76
77 struct /*__attribute__((packed))*/ {
87 // uint8_t id : 8; /// = 0xf0; Trailer Status Word (TSW) identifier
88 }; // TRAILER
89
90 struct /*__attribute__((packed))*/ {
96 uint64_t bc : 12;
100 // uint8_t id : 8; /// = 0xc0; Trigger Status Word (TSW) identifier
101 }; // TRIGGER
102
103 struct /*__attribute__((packed))*/ {
105 // uint64_t id : 8; /// 72:79 0xe4; diagnostic word identifier
106 }; // HEADER Legacy
107
108 struct __attribute__((packed)) {
109 uint64_t calibUserField : 48;
110 uint64_t calibCounter : 24;
111 // uint64_t id : 8; /// 72:79 0xf8; Calibration Status Word (HSW) identifier
112 };
113
114 struct {
117 // uint64_t id : 8; /// 72:79 0xe0; Status Word (HSW) identifier
118 }; // HEADER Legacy
119
120 uint8_t data8[16]; // 80 bits GBT word + optional padding to 128 bits
121 uint64_t data64[2] = {0};
122 };
123
124 GBTWord() = default;
125
127 bool isDataHeader() const { return id == GBTFlagDataHeader; }
128
130 bool isDataTrailer() const { return id == GBTFlagDataTrailer; }
131
133 bool isTriggerWord() const { return id == GBTFlagTrigger; }
134
136 bool isDiagnosticWord() const { return id == GBTFlagDiagnostic; }
137
139 bool isCalibrationWord() const { return id == GBTFlagCalibration; }
140
142 bool isDataIB() const { return (id & 0xe0) == GBTFlagDataIB; }
143
145 bool isCableDiagnosticIB() const { return (id & 0xe0) == GBTFlagDiagnosticIB; }
146
148 bool isDataOB() const { return (id & 0xe0) == GBTFlagDataOB; }
149
151 bool isDataMFT() const { return (id & 0xe0) == GBTFlagDataMFT; }
152
154 bool isCableDiagnosticOB() const { return (id & 0xe0) == GBTFlagDiagnosticIB; }
155
157 bool isData() const { return isDataIB() || isDataOB() || isDataMFT(); }
158
160
161 bool isStatus() const { return (id & 0xe0) == GBTFlagStatus; }
162
163 const uint64_t* getW64() const { return data64; }
164 const uint8_t* getW8() const { return data8; }
165
166 uint8_t getHeader() const { return id; }
167
168 void printX(bool padded = true, std::string com = "") const;
169 void printB(bool padded = true) const;
170
172};
173
174struct GBTDataHeader : public GBTWord {
181
184 {
186 activeLanes = lanes;
187 }
189};
190
191struct GBTDataHeaderL : public GBTWord { // legacy version
199
201 GBTDataHeaderL(int packetID, uint32_t lanes)
202 {
204 activeLanesL = lanes;
205 packetIdx = packetID;
206 }
208};
209
210struct GBTDataTrailer : public GBTWord {
223 enum PacketStates : int {
224 PacketDone = 0, // Packet finished
225 TransmissionTimeout = 1, // if timeout of transmission (lanes)
226 PacketOverflow = 2, // if max number of packets reached
227 LaneStartsViolation = 3, // if at least 1 lane had a start violation
228 LaneTimeouts = 4, // if at least 1 lane timed out
229 NStatesDefined, // total number of states defined
230 MaxStateCombinations = 0x1 << NStatesDefined // number of possible combinations
231 };
232
234 GBTDataTrailer(int lanesStop, int lanesTimeOut, bool done, bool transmTO, bool overflow, bool laneStViol, bool laneTO)
235 {
236 lanesStops = lanesStop;
237 lanesTimeout = lanesTimeOut;
239 transmissionTimeout = transmTO;
241 laneStartsViolation = laneStViol;
242 laneTimeouts = laneTO;
244 }
245
246 uint8_t getPacketState() const { return data8[8] & (MaxStateCombinations - 1); }
247
248 void setByte(uint8_t v, int which) = delete;
249
251};
252
253struct GBTTrigger : public GBTWord {
267
269 void setByte(uint8_t v, int which) = delete;
270
272};
273
274struct GBTData : public GBTWord {
277 public:
279 static int getLaneIB(uint8_t v) { return v & 0x1f; }
281 static int getConnectorOB(uint8_t v) { return (v & 0x18) >> 3; } // lane only
282 static int getLaneOB(uint8_t v) { return v & 0x7; } // connector only
283 static int getLaneOB(uint8_t v, int& connector)
284 { // separately lane and connector
285 connector = getConnectorOB(v);
286 return getLaneOB(v);
287 }
288 static int getCableID(uint8_t v) { return v & 0x1f; } // combined connector and lane
289
291 int getLaneIB() const { return getLaneIB(id); }
293 int getConnectorOB() const { return getConnectorOB(id); } // lane only
294 int getLaneOB() const { return getLaneOB(id); } // connector only
295 int getLaneOB(int& connector) const { return getLaneOB(id, connector); } // separately lane and connector
296 int getCableID() const { return getCableID(id); } // combined connector and lane
297
299};
300
311
318
319 GBTCableDiagnostic(bool ib = true, int lane = 0) { id = (ib ? GBTFlagDiagnosticIB : GBTFlagDiagnosticOB) | (lane & 0x1f); }
320 int getCableID() const { return id & 0x1f; } // combined connector and lane
321 bool isIB() const { return (id & 0xe0) == GBTFlagDiagnosticIB; }
322 bool isOB() const { return (id & 0xe0) == GBTFlagDiagnosticOB; }
324};
325
326struct GBTCableStatus : public GBTWord { // not sure this is correct, FIXME
330
331 GBTCableStatus(int lane = 0) { id = GBTFlagStatus | (lane & 0x1f); }
332 int getCableID() const { return id & 0x1f; } // combined connector and lane
334};
335
336struct GBTCalibration : public GBTWord { // calibration data word
340
343 {
345 calibUserField = userData & ((0x1UL << 48) - 1);
346 calibCounter = counter & ((0x1 << 24) - 1);
347 }
349};
350
351} // namespace itsmft
352} // namespace o2
353
354#endif
unsigned short int uint16_t
bool done
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
bool overflow
const GLdouble * v
Definition glcorearb.h:832
constexpr uint8_t GBTFlagDiagnostic
GBT diagnostic status word flag.
Definition GBTWord.h:35
constexpr int GBTPaddedWordLength
Definition GBTWord.h:56
constexpr uint8_t GBTFlagDataIB
Definition GBTWord.h:42
constexpr uint8_t GBTFlagDiagnosticIB
Definition GBTWord.h:48
constexpr uint8_t GBTFlagStatus
Definition GBTWord.h:53
constexpr uint8_t GBTFlagCalibration
GBT calibration status word flag.
Definition GBTWord.h:37
constexpr uint8_t GBTFlagDataHeader
GBT payload header flag.
Definition GBTWord.h:29
constexpr uint8_t GBTFlagDataTrailer
GBT payload trailer flag.
Definition GBTWord.h:31
constexpr uint8_t GBTFlagTrigger
GBT trigger status word flag.
Definition GBTWord.h:33
constexpr uint8_t GBTFlagRDH
Definition GBTWord.h:40
constexpr uint8_t GBTFlagDataMFT
Definition GBTWord.h:46
constexpr uint8_t GBTFlagDiagnosticOB
Definition GBTWord.h:50
constexpr int GBTWordLength
Definition GBTWord.h:55
constexpr uint64_t LANESMask
Definition GBTWord.h:26
constexpr uint8_t GBTFlagDataOB
Definition GBTWord.h:44
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
ClassDefNV(GBTCableDiagnostic, 1)
GBTCableDiagnostic(bool ib=true, int lane=0)
Definition GBTWord.h:319
GBTCableStatus(int lane=0)
Definition GBTWord.h:331
ClassDefNV(GBTCableStatus, 1)
ClassDefNV(GBTCalibration, 1)
GBTCalibration(uint64_t userData, uint16_t counter=0)
Definition GBTWord.h:342
ClassDefNV(GBTDataHeaderL, 1)
GBTDataHeaderL(int packetID, uint32_t lanes)
Definition GBTWord.h:201
GBTDataHeader(uint32_t lanes)
Definition GBTWord.h:183
ClassDefNV(GBTDataHeader, 1)
void setByte(uint8_t v, int which)=delete
ClassDefNV(GBTDataTrailer, 1)
uint8_t getPacketState() const
Definition GBTWord.h:246
GBTDataTrailer(int lanesStop, int lanesTimeOut, bool done, bool transmTO, bool overflow, bool laneStViol, bool laneTO)
Definition GBTWord.h:234
ClassDefNV(GBTData, 1)
int getCableID() const
Definition GBTWord.h:296
static int getLaneIB(uint8_t v)
extract lane of the IB as lowest 5 bits (ATTENTION: no check if this is really an IB header)
Definition GBTWord.h:279
int getLaneIB() const
extract lane of the IB as lowest 5 bits (ATTENTION: no check if this is really an IB header)
Definition GBTWord.h:291
static int getCableID(uint8_t v)
Definition GBTWord.h:288
static int getLaneOB(uint8_t v, int &connector)
Definition GBTWord.h:283
int getLaneOB(int &connector) const
Definition GBTWord.h:295
static int getLaneOB(uint8_t v)
Definition GBTWord.h:282
int getConnectorOB() const
extract connector/lane of the OB as lowest 2/3 bits (ATTENTION: no check if this is really an OB head...
Definition GBTWord.h:293
int getLaneOB() const
Definition GBTWord.h:294
static int getConnectorOB(uint8_t v)
extract connector/lane of the OB as lowest 2/3 bits (ATTENTION: no check if this is really an OB head...
Definition GBTWord.h:281
ClassDefNV(GBTDiagnostic, 1)
ClassDefNV(GBTTrigger, 1)
void setByte(uint8_t v, int which)=delete
ClassDefNV(GBTWord, 1)
uint64_t continuation
13 No data expected (too close to previous trigger or error)
Definition GBTWord.h:94
uint64_t packetOverflow
65 = 1 if timeout while waiting for data on lanes
Definition GBTWord.h:83
const uint8_t * getW8() const
Definition GBTWord.h:164
uint64_t laneStartsViolation
66 = 1 if max number of packets reached
Definition GBTWord.h:84
uint64_t na1tr
14 following data is continuation of the trigger from the previous CRU page
Definition GBTWord.h:95
uint64_t laneErrorID
0:63 Error specific diagnostic data
Definition GBTWord.h:116
uint64_t id
28:71 reserved
Definition GBTWord.h:66
uint64_t na0hn
0:27 Bit map of lanes active and eligible for readout
Definition GBTWord.h:64
uint64_t activeLanesL
0:15 Index of Data Packet within trigger
Definition GBTWord.h:71
void printB(bool padded=true) const
Definition GBTWord.cxx:34
uint64_t lanesTimeout
0:27 Bit map of “Valid Lane stops received”, 1 bit per lane, NOT USED
Definition GBTWord.h:79
uint64_t diagnosticData
Definition GBTWord.h:115
const uint64_t * getW64() const
Definition GBTWord.h:163
bool isDataIB() const
check if the GBT Header corresponds to ITS IB data (header is combined with lanes info)
Definition GBTWord.h:142
bool isDataOB() const
check if the GBT Header corresponds to ITS OB data (header is combined with lanes/connector info)
Definition GBTWord.h:148
uint64_t noData
12 Used in Continuous Mode for internally generated trigger
Definition GBTWord.h:93
uint64_t internal
0:11 12 lowest bits of trigger type received from CTP
Definition GBTWord.h:92
uint64_t lanesStops
Definition GBTWord.h:78
uint64_t laneTimeouts
67 = 1 if at least 1 lane (eligible for readout) had a “start violation”
Definition GBTWord.h:85
uint64_t orbit
28:31 reserved
Definition GBTWord.h:98
uint64_t na1hn
28:71 reserved
Definition GBTWord.h:65
bool isTriggerWord() const
check if the GBT Header corresponds to GBT trigger word
Definition GBTWord.h:133
uint64_t triggerType
Definition GBTWord.h:91
uint64_t activeLanes
Definition GBTWord.h:63
uint64_t na1h
44:64 reserved
Definition GBTWord.h:73
bool isDataMFT() const
check if the GBT Header corresponds to MFT data (header is combined with cable number)
Definition GBTWord.h:151
uint64_t data64[2]
Definition GBTWord.h:121
bool isCableDiagnosticOB() const
check if the GBT Header corresponds to ITS OB diagnostics data (header is combined with lanes info)
Definition GBTWord.h:154
uint64_t na3tr
32:63 Last received HB Orbit or trigger orbit count/ Orbit as received from CTP
Definition GBTWord.h:99
uint8_t getHeader() const
Definition GBTWord.h:166
bool isCableDiagnosticIB() const
check if the GBT Header corresponds to ITS IB diagnostics data (header is combined with lanes info)
Definition GBTWord.h:145
void printX(bool padded=true, std::string com="") const
Definition GBTWord.cxx:21
bool isDataHeader() const
check if the GBT Header corresponds to GBT payload header
Definition GBTWord.h:127
uint64_t na1t
28:55 Bit map of “Lane timeouts received”, 1 bit per lane, NOT USED
Definition GBTWord.h:80
bool isDataTrailer() const
check if the GBT Header corresponds to GBT payload trailer
Definition GBTWord.h:130
bool isDiagnosticWord() const
check if the GBT Header corresponds to Diagnostic data
Definition GBTWord.h:136
bool isCalibrationWord() const
check if the GBT Header corresponds to Calibration word
Definition GBTWord.h:139
uint64_t na0h
16:43 Bit map of lanes active and eligible for readout
Definition GBTWord.h:72
uint64_t na2tr
16:27 HB or internal trigger BC count or trigger BC from CTP
Definition GBTWord.h:97
uint8_t data8[16]
Definition GBTWord.h:120
uint64_t bc
15 reserved
Definition GBTWord.h:96
bool isCableDiagnostic() const
Definition GBTWord.h:159
uint64_t na2t
68 = 1 if at least 1 lane (eligible for readout) had a “start violation”
Definition GBTWord.h:86
bool isStatus() const
Definition GBTWord.h:161
uint64_t packetIdx
Definition GBTWord.h:70
bool isData() const
check if the GBT Header corresponds to ITS IB or OB data (header is combined with lanes/connector inf...
Definition GBTWord.h:157
uint64_t packetDone
56:63 reserved
Definition GBTWord.h:81
uint64_t transmissionTimeout
64 = 1 when current trigger packets transmission done
Definition GBTWord.h:82