File indexing completed on 2023-03-17 10:59:46
0001
0002
0003 #ifndef MATACQTBRAWEVENT_H
0004 #define MATACQTBRAWEVENT_H
0005
0006 #include <cinttypes>
0007 #include <ctime>
0008 #include <vector>
0009
0010 #if 0
0011 #include "i2o/utils/endian.h" //from XDAQ
0012 #define UINT32_FROM_LE i2odecodel
0013 #define UINT16_FROM_LE i2odecodes
0014 #define INT16_FROM_LE i2odecodes
0015
0016 #else
0017
0018 #define UINT32_FROM_LE
0019 #define UINT16_FROM_LE
0020 #define INT16_FROM_LE
0021
0022 #endif
0023
0024
0025
0026
0027 class MatacqTBRawEvent {
0028
0029 public:
0030 enum matacqError_t {
0031
0032
0033
0034 errorLengthConsistency = 1 << 0,
0035
0036
0037 errorLength = 1 << 1,
0038
0039
0040 errorWrongBoe = 1 << 2
0041 };
0042
0043
0044
0045
0046
0047 struct uint32le_t {
0048 uint32_t littleEndianInt;
0049 operator uint32_t() const { return UINT32_FROM_LE(littleEndianInt); }
0050 };
0051
0052 struct uint16le_t {
0053 uint16_t littleEndianInt;
0054 operator uint16_t() const { return UINT16_FROM_LE(littleEndianInt); }
0055 };
0056
0057 struct int16le_t {
0058 int16_t littleEndianInt;
0059 operator int16_t() const { return INT16_FROM_LE(littleEndianInt); }
0060 };
0061
0062
0063 struct ChannelData {
0064
0065
0066 int chId;
0067
0068
0069 int nSamples;
0070
0071
0072 const int16le_t* samples;
0073 };
0074
0075 private:
0076
0077
0078 struct matacqHeader_t {
0079 uint16le_t version;
0080 unsigned char freqGHz;
0081 unsigned char channelCount;
0082 uint32_t timeStamp;
0083 };
0084
0085
0086
0087 struct field32spec_t {
0088 int offset;
0089 unsigned int mask;
0090 };
0091
0092
0093
0094 static const field32spec_t fov32;
0095 static const field32spec_t fedId32;
0096 static const field32spec_t bxId32;
0097 static const field32spec_t lv132;
0098 static const field32spec_t triggerType32;
0099 static const field32spec_t boeType32;
0100 static const field32spec_t dccLen32;
0101 static const field32spec_t dccErrors32;
0102 static const field32spec_t runNum32;
0103 static const field32spec_t h1Marker32;
0104
0105
0106 public:
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116 MatacqTBRawEvent(const unsigned char* dataBuffer, std::size_t bufferSize) { setRawData(dataBuffer, bufferSize); }
0117
0118 public:
0119
0120
0121
0122
0123
0124
0125 int getFov() const { return read32(daqHeader, fov32); }
0126
0127
0128
0129
0130 int getFedId() const { return read32(daqHeader, fedId32); }
0131
0132
0133
0134
0135 int getBxId() const { return read32(daqHeader, bxId32); }
0136
0137
0138
0139
0140 unsigned getEventId() const { return read32(daqHeader, lv132); }
0141
0142
0143
0144
0145 int getTriggerType() const { return read32(daqHeader, triggerType32); }
0146
0147
0148
0149
0150 int getBoe() const { return read32(daqHeader, boeType32); }
0151
0152
0153
0154
0155 unsigned getDccLen() const { return read32(daqHeader, dccLen32); }
0156
0157
0158
0159
0160 unsigned getDaqLen() const { return fragLen; }
0161
0162
0163
0164
0165 int getDccErrors() const { return read32(daqHeader, dccErrors32); }
0166
0167
0168
0169
0170 unsigned getRunNum() const { return read32(daqHeader, runNum32); }
0171
0172
0173
0174
0175 int getH1Marker() const { return read32(daqHeader, h1Marker32); }
0176
0177
0178
0179
0180 int getMatacqDataFormatVersion() const { return matacqHeader->version; }
0181
0182
0183
0184
0185
0186 int32_t getStatus() const { return error; }
0187
0188
0189
0190
0191 int getFreqGHz() const { return matacqHeader->freqGHz; }
0192
0193
0194
0195
0196 int getChannelCount() const { return matacqHeader->channelCount; }
0197
0198
0199
0200
0201
0202
0203 const std::vector<ChannelData>& getChannelData() const { return channelData; }
0204
0205
0206
0207
0208
0209 int getParsedLen() { return parsedLen; }
0210
0211
0212
0213
0214
0215
0216 time_t getTimeStamp() const { return matacqHeader->timeStamp; }
0217
0218
0219
0220
0221
0222 int getTTrigPs() const { return tTrigPs; }
0223
0224 private:
0225
0226
0227
0228
0229
0230 int read32(const uint32le_t* pData, field32spec_t spec) const;
0231
0232
0233
0234
0235
0236
0237
0238
0239 void setRawData(const unsigned char* buffer, std::size_t bufferSize);
0240
0241
0242 private:
0243
0244
0245 int boe;
0246
0247
0248
0249 int bxId;
0250
0251
0252
0253 int channelCount;
0254
0255
0256
0257 std::vector<ChannelData> channelData;
0258
0259
0260
0261 const uint32le_t* daqHeader;
0262
0263
0264
0265 int dccErrors;
0266
0267
0268
0269 unsigned dccLen;
0270
0271
0272
0273 unsigned eventId;
0274
0275
0276
0277 int32_t error;
0278
0279
0280
0281 int fedId;
0282
0283
0284
0285 int fov;
0286
0287
0288
0289 int fragLen;
0290
0291
0292
0293 int freqGHz;
0294
0295
0296
0297 int h1Marker;
0298
0299
0300
0301 const matacqHeader_t* matacqHeader;
0302
0303
0304
0305 int matacqDataFormatVersion;
0306
0307
0308
0309 int parsedLen;
0310
0311
0312
0313 uint16le_t* pSamples;
0314
0315
0316
0317 unsigned runNum;
0318
0319
0320
0321 time_t timeStamp;
0322
0323
0324
0325 int tTrigPs;
0326
0327
0328
0329 int triggerType;
0330 };
0331
0332 #endif