CMS 3D CMS Logo

MatacqRawEvent.h
Go to the documentation of this file.
1 // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: t; tab-width: 8; -*-
2 
3 #ifndef MATACQTBRAWEVENT_H
4 #define MATACQTBRAWEVENT_H
5 
6 #include <cinttypes>
7 #include <ctime>
8 #include <vector>
9 //replace 1 by 0 to remove XDAQ dependency. In this case it is assumed the machine is little endian.
10 #if 0
11 #include "i2o/utils/endian.h" //from XDAQ
12 #define UINT32_FROM_LE i2odecodel
13 #define UINT16_FROM_LE i2odecodes
14 #define INT16_FROM_LE i2odecodes
15 
16 #else //assuming little endianness of the machine
17 
18 #define UINT32_FROM_LE
19 #define UINT16_FROM_LE
20 #define INT16_FROM_LE
21 
22 #endif
23 
28  //typedefs, enums and static constants
29 public:
37  errorLength = 1 << 1,
40  errorWrongBoe = 1 << 2
41  };
42 
43  /* The following types are little-endian encoded types. Use of these types
44  * for the I20 data block should offer portability to big-endian platforms.
45  */
47  struct uint32le_t {
48  uint32_t littleEndianInt;
49  operator uint32_t() const { return UINT32_FROM_LE(littleEndianInt); }
50  };
51 
52  struct uint16le_t {
53  uint16_t littleEndianInt;
54  operator uint16_t() const { return UINT16_FROM_LE(littleEndianInt); }
55  };
56 
57  struct int16le_t {
58  int16_t littleEndianInt;
59  operator int16_t() const { return INT16_FROM_LE(littleEndianInt); }
60  };
62 
63  struct ChannelData {
66  int chId;
69  int nSamples;
73  };
74 
75 private:
78  struct matacqHeader_t {
80  unsigned char freqGHz;
81  unsigned char channelCount;
82  uint32_t timeStamp;
83  };
84 
87  struct field32spec_t {
88  int offset;
89  unsigned int mask;
90  };
91 
94  static const field32spec_t fov32;
95  static const field32spec_t fedId32;
96  static const field32spec_t bxId32;
97  static const field32spec_t lv132;
99  static const field32spec_t boeType32;
100  static const field32spec_t dccLen32;
102  static const field32spec_t runNum32;
103  static const field32spec_t h1Marker32;
104 
105  //constructors
106 public:
116  MatacqTBRawEvent(const unsigned char* dataBuffer, std::size_t bufferSize) { setRawData(dataBuffer, bufferSize); }
117  //methods
118 public:
125  int getFov() const { return read32(daqHeader, fov32); }
126 
130  int getFedId() const { return read32(daqHeader, fedId32); }
131 
135  int getBxId() const { return read32(daqHeader, bxId32); }
136 
140  unsigned getEventId() const { return read32(daqHeader, lv132); }
141 
145  int getTriggerType() const { return read32(daqHeader, triggerType32); }
146 
150  int getBoe() const { return read32(daqHeader, boeType32); }
151 
155  unsigned getDccLen() const { return read32(daqHeader, dccLen32); }
156 
160  unsigned getDaqLen() const { return fragLen; }
161 
165  int getDccErrors() const { return read32(daqHeader, dccErrors32); }
166 
170  unsigned getRunNum() const { return read32(daqHeader, runNum32); }
171 
175  int getH1Marker() const { return read32(daqHeader, h1Marker32); }
176 
181 
186  int32_t getStatus() const { return error; }
187 
191  int getFreqGHz() const { return matacqHeader->freqGHz; }
192 
196  int getChannelCount() const { return matacqHeader->channelCount; }
197 
203  const std::vector<ChannelData>& getChannelData() const { return channelData; }
204 
209  int getParsedLen() { return parsedLen; }
210 
216  time_t getTimeStamp() const { return matacqHeader->timeStamp; }
217 
222  int getTTrigPs() const { return tTrigPs; }
223 
224 private:
230  int read32(const uint32le_t* pData, field32spec_t spec) const;
231 
239  void setRawData(const unsigned char* buffer, std::size_t bufferSize);
240 
241  //fields
242 private:
245  int boe;
246 
249  int bxId;
250 
254 
257  std::vector<ChannelData> channelData;
258 
262 
266 
269  unsigned dccLen;
270 
273  unsigned eventId;
274 
277  int32_t error;
278 
281  int fedId;
282 
285  int fov;
286 
289  int fragLen;
290 
293  int freqGHz;
294 
297  int h1Marker;
298 
302 
306 
310 
314 
317  unsigned runNum;
318 
321  time_t timeStamp;
322 
325  int tTrigPs;
326 
330 };
331 
332 #endif //MATACQRAWEVENT_H not defined
int getH1Marker() const
const std::vector< ChannelData > & getChannelData() const
int32_t getStatus() const
static const field32spec_t lv132
static const field32spec_t fov32
static const field32spec_t boeType32
time_t getTimeStamp() const
static const field32spec_t runNum32
int getBxId() const
unsigned getDaqLen() const
uint16le_t * pSamples
std::vector< ChannelData > channelData
int read32(const uint32le_t *pData, field32spec_t spec) const
int getMatacqDataFormatVersion() const
const uint32le_t * daqHeader
int getFedId() const
MatacqTBRawEvent(const unsigned char *dataBuffer, std::size_t bufferSize)
static const field32spec_t triggerType32
unsigned getRunNum() const
int getDccErrors() const
int getFreqGHz() const
#define UINT16_FROM_LE
static const field32spec_t h1Marker32
int getBoe() const
static const field32spec_t bxId32
const matacqHeader_t * matacqHeader
int getFov() const
#define INT16_FROM_LE
static const field32spec_t dccLen32
#define UINT32_FROM_LE
unsigned getDccLen() const
void setRawData(const unsigned char *buffer, std::size_t bufferSize)
int getTriggerType() const
static const field32spec_t fedId32
int getChannelCount() const
unsigned getEventId() const
static const field32spec_t dccErrors32
int getTTrigPs() const