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 <time.h>
8 #include <vector>
9 #if 0 //replace 1 by 0 to remove XDAQ dependency. In this case it is assumed
10  //the machine is little endian.
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,
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{
50  return UINT32_FROM_LE(littleEndianInt);
51  }
52  };
53 
54  struct uint16le_t{
55  uint16_t littleEndianInt;
56  operator uint16_t() const{
57  return UINT16_FROM_LE(littleEndianInt);
58  }
59  };
60 
61  struct int16le_t{
62  int16_t littleEndianInt;
63  operator int16_t() const{
64  return INT16_FROM_LE(littleEndianInt);
65  }
66  };
68 
69  struct ChannelData{
72  int chId;
75  int nSamples;
79  };
80 
81 private:
84  struct matacqHeader_t{
86  unsigned char freqGHz;
87  unsigned char channelCount;
88  uint32_t timeStamp;
89  };
90 
93  struct field32spec_t{
94  int offset;
95  unsigned int mask;
96  };
97 
100  static const field32spec_t fov32;
101  static const field32spec_t fedId32;
102  static const field32spec_t bxId32;
103  static const field32spec_t lv132;
105  static const field32spec_t boeType32;
106  static const field32spec_t dccLen32;
108  static const field32spec_t runNum32;
109  static const field32spec_t h1Marker32;
110 
111 
112  //constructors
113 public:
123  MatacqTBRawEvent(const unsigned char* dataBuffer, std::size_t bufferSize){
124  setRawData(dataBuffer, bufferSize);
125  }
126  //methods
127 public:
134  int getFov() const { return read32(daqHeader, fov32);}
135 
139  int getFedId() const { return read32(daqHeader, fedId32);}
140 
144  int getBxId() const { return read32(daqHeader, bxId32);}
145 
149  unsigned getEventId() const { return read32(daqHeader, lv132);}
150 
154  int getTriggerType() const { return read32(daqHeader, triggerType32);}
155 
159  int getBoe() const { return read32(daqHeader, boeType32);}
160 
164  unsigned getDccLen() const { return read32(daqHeader, dccLen32);}
165 
169  unsigned getDaqLen() const { return fragLen;}
170 
171 
175  int getDccErrors() const { return read32(daqHeader, dccErrors32);}
176 
180  unsigned getRunNum() const { return read32(daqHeader, runNum32);}
181 
185  int getH1Marker() const { return read32(daqHeader, h1Marker32);}
186 
187 
192 
197  int32_t getStatus() const { return error;}
198 
202  int getFreqGHz() const { return matacqHeader->freqGHz;}
203 
207  int getChannelCount() const { return matacqHeader->channelCount;}
208 
214  const std::vector<ChannelData>& getChannelData() const{
215  return channelData;
216  }
217 
222  int getParsedLen() { return parsedLen; }
223 
229  time_t getTimeStamp() const { return matacqHeader->timeStamp;}
230 
231 
236  int getTTrigPs() const { return tTrigPs;}
237 
238 private:
244  int read32(const uint32le_t* pData, field32spec_t spec) const;
245 
253  void setRawData(const unsigned char* buffer, std::size_t bufferSize);
254 
255  //fields
256 private:
259  int boe;
260 
263  int bxId;
264 
268 
271  std::vector<ChannelData> channelData;
272 
276 
280 
283  unsigned dccLen;
284 
287  unsigned eventId;
288 
291  int32_t error;
292 
295  int fedId;
296 
299  int fov;
300 
303  int fragLen;
304 
307  int freqGHz;
308 
311  int h1Marker;
312 
316 
320 
324 
328 
331  unsigned runNum;
332 
335  time_t timeStamp;
336 
339  int tTrigPs;
340 
344 };
345 
346 #endif //MATACQRAWEVENT_H not defined
int getFedId() const
int getH1Marker() const
int getDccErrors() const
int getTriggerType() const
static const field32spec_t lv132
static const field32spec_t fov32
unsigned getDaqLen() const
unsigned getEventId() const
static const field32spec_t boeType32
int read32(const uint32le_t *pData, field32spec_t spec) const
int getTTrigPs() const
int getChannelCount() const
static const field32spec_t runNum32
uint16le_t * pSamples
std::vector< ChannelData > channelData
int32_t getStatus() const
int getMatacqDataFormatVersion() const
int getBoe() const
time_t getTimeStamp() const
const uint32le_t * daqHeader
MatacqTBRawEvent(const unsigned char *dataBuffer, std::size_t bufferSize)
static const field32spec_t triggerType32
int getFreqGHz() const
#define UINT16_FROM_LE
unsigned getRunNum() const
static const field32spec_t h1Marker32
int getBxId() const
static const field32spec_t bxId32
const matacqHeader_t * matacqHeader
#define INT16_FROM_LE
const std::vector< ChannelData > & getChannelData() const
static const field32spec_t dccLen32
#define UINT32_FROM_LE
int getFov() const
void setRawData(const unsigned char *buffer, std::size_t bufferSize)
unsigned getDccLen() const
static const field32spec_t fedId32
static const field32spec_t dccErrors32