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 MATACQRAWEVENT_H
4 #define MATACQRAWEVENT_H
5 
6 #include <cinttypes>
7 #include <cstddef>
8 #include <vector>
9 
10 #if 0 //replace 1 by 0 to remove XDAQ dependency. In this case it is assumed the
11  //machine is little endian.
12 #include "i2o/utils/endian.h" //from XDAQ
13 #define UINT32_FROM_LE i2odecodel
14 #define UINT16_FROM_LE i2odecodes
15 #define INT16_FROM_LE i2odecodes
16 
17 #else //assuming little endianness of the machine
18 
19 #define UINT32_FROM_LE
20 #define UINT16_FROM_LE
21 #define INT16_FROM_LE
22 
23 #endif
24 
25 #include <sys/time.h> //for timeval definition
26 
31  //typedefs, enums and static constants
32 public:
40  errorLength = 1<<1,
44  };
45 
46  /* The following types are little-endian encoded types. Use of these types
47  * for the I20 data block should offer portability to big-endian platforms.
48  */
50  struct uint32le_t{
51  uint32_t littleEndianInt;
52  operator uint32_t() const{
53  return UINT32_FROM_LE(littleEndianInt);
54  }
55  };
56 
57  struct uint16le_t{
58  uint16_t littleEndianInt;
59  operator uint16_t() const{
60  return UINT16_FROM_LE(littleEndianInt);
61  }
62  };
63 
64  struct int16le_t{
65  int16_t littleEndianInt;
66  operator int16_t() const{
67  return INT16_FROM_LE(littleEndianInt);
68  }
69  };
71 
72  struct ChannelData{
75  int chId;
78  int nSamples;
82  };
83 
84 private:
87 // struct matacqHeader_t{
88 // uint16_t version;
89 // unsigned char freqGHz;
90 // unsigned char channelCount;
91 // uint32_t orbitId;
92 // unsigned char trigRec;
93 // uint16_t postTrig;
94 // uint16_t vernier[4];
95 // uint32_t timeStamp;
96 // };
97 
101  int offset;
102  unsigned int mask;
103  };
104 
106 
108  static const field32spec_t fov32;
109  static const field32spec_t fedId32;
110  static const field32spec_t bxId32;
111  static const field32spec_t lv132;
113  static const field32spec_t boeType32;
114  static const field32spec_t dccLen32;
116  static const field32spec_t runNum32;
117  static const field32spec_t h1Marker32;
119 
121 
124  static const field32spec_t freqGHz32;
127  static const field32spec_t tTrigPs32;
128  static const field32spec_t orbitId32;
129  static const field32spec_t trigRec32;
130  static const field32spec_t postTrig32;
136 
141  static const field32spec_t delayA32;
142  static const field32spec_t dccId32;
143  static const field32spec_t color32;
144  static const field32spec_t trigType32;
145  static const field32spec_t side32;
146 
148 
149  //constructors
150 public:
160  MatacqRawEvent(const unsigned char* dataBuffer, size_t bufferSize): vernier(std::vector<int>(4)){
161  setRawData(dataBuffer, bufferSize);
162  }
163  //methods
164 public:
171  int getFov() const { return read32(daqHeader, fov32);}
172 
176  int getFedId() const { return read32(daqHeader, fedId32);}
177 
181  int getBxId() const { return read32(daqHeader, bxId32);}
182 
186  unsigned getEventId() const { return read32(daqHeader, lv132);}
187 
191  int getTriggerType() const { return read32(daqHeader, triggerType32);}
192 
196  int getBoe() const { return read32(daqHeader, boeType32);}
197 
201  unsigned getDccLen() const { return read32(daqHeader, dccLen32);}
202 
209  static unsigned getDccLen(unsigned char* data, size_t size){
210  if(size<(unsigned)(dccLen32.offset+1)*4) return (unsigned)-1;
211  return read32((uint32le_t*) data, dccLen32);
212  }
213 
221  static unsigned getOrbitId(unsigned char* data, size_t size){
222  if(size<(unsigned)(orbitId32.offset+1)*8) return (unsigned)-1;
223  return read32((uint32le_t*) data, orbitId32);
224  }
225 
232  static unsigned getRunNum(unsigned char* data, size_t size){
233  if(size<(unsigned)(runNum32.offset+1)*8) return (unsigned)-1;
234  return read32((uint32le_t*) data, runNum32);
235  }
236 
237 
241  unsigned getDaqLen() const { return fragLen;}
242 
243 
247  int getDccErrors() const { return read32(daqHeader, dccErrors32);}
248 
252  unsigned getRunNum() const { return read32(daqHeader, runNum32);}
253 
257  int getH1Marker() const { return read32(daqHeader, h1Marker32);}
258 
259 
264 
269  int32_t getStatus() const { return error;}
270 
274  int getFreqGHz() const { return /*matacqHeader->*/freqGHz;}
275 
279  int getChannelCount() const { return /*matacqHeader->*/channelCount;}
280 
286  const std::vector<ChannelData>& getChannelData() const{
287  return channelData;
288  }
289 
294  int getParsedLen() { return parsedLen; }
295 
301  time_t getTimeStamp() const { return /*matacqHeader->*/timeStamp.tv_sec; }
302 
308  void getTimeStamp(struct timeval& t) const { t = timeStamp; }
309 
314  int getTTrigPs() const { return tTrigPs; }
315 
320  uint32_t getOrbitId() const { return orbitId; }
321 
326  int getTrigRec() const { return trigRec; }
327 
331  int getPostTrig() const { return postTrig; }
332 
336  std::vector<int> getVernier() const { return vernier; }
337 
340  int getDelayA() const { return delayA; }
341 
344  int getEmtcDelay() const { return emtcDelay; }
345 
348  int getEmtcPhase() const { return emtcPhase; }
349 
353  int getAttenuation_dB() const { return attenuation_dB; }
354 
357  int getLaserPower() const { return laserPower; }
358 
359 private:
368  static int read32(const uint32le_t *pData, field32spec_t spec, bool ovfTrans = false);
369 
370 // /** Help function to get the maximum value of a data field
371 // * @param spec32 data field specification
372 // * @return maximum value
373 // */
374 // int max32(field32spec_t spec32) const;
375 
383  void setRawData(const unsigned char* buffer, size_t bufferSize);
384 
385  //fields
386 private:
389  int boe;
390 
393  int bxId;
394 
398 
401  std::vector<ChannelData> channelData;
402 
406 
410 
413  unsigned dccLen;
414 
417  unsigned eventId;
418 
421  int32_t error;
422 
425  int fedId;
426 
429  int fov;
430 
433  int fragLen;
434 
437  int freqGHz;
438 
441  int h1Marker;
442 
445  // matacqHeader_t* matacqHeader;
446 
450 
454 
458 
461  unsigned runNum;
462 
465  struct timeval timeStamp;
466 
469  int tTrigPs;
470 
474 
475  /* LHC orbit ID
476  */
477  uint32_t orbitId;
478 
481  int trigRec;
482 
485  int postTrig;
486 
489  std::vector<int> vernier;
490 
493  int delayA;
494 
497  int emtcDelay;
498 
502 
507 
511 };
512 
513 #endif //MATACQRAWEVENT_H not defined
size
Write out results.
int getTTrigPs() const
static const field32spec_t vernier1_32
static const field32spec_t fedId32
static const field32spec_t boeType32
unsigned getRunNum() const
static unsigned getRunNum(unsigned char *data, size_t size)
static int read32(const uint32le_t *pData, field32spec_t spec, bool ovfTrans=false)
int getEmtcPhase() const
int getFreqGHz() const
const int16le_t * samples
int getDelayA() const
int getPostTrig() const
static unsigned getOrbitId(unsigned char *data, size_t size)
int getTrigRec() const
static const field32spec_t runNum32
static const field32spec_t timeStamp32
#define UINT32_FROM_LE
const uint32le_t * daqHeader
static const field32spec_t trigType32
static const field32spec_t tTrigPs32
std::vector< int > vernier
static const field32spec_t channelCount32
int32_t getStatus() const
unsigned getDaqLen() const
uint32_t getOrbitId() const
unsigned getDccLen() const
#define UINT16_FROM_LE
static const field32spec_t emtcPhase32
void setRawData(const unsigned char *buffer, size_t bufferSize)
static const field32spec_t dccLen32
static const field32spec_t fov32
static const field32spec_t attenuation_dB32
static const field32spec_t lv132
int getChannelCount() const
int getMatacqDataFormatVersion() const
static const field32spec_t vernier0_32
static const field32spec_t vernier3_32
static unsigned getDccLen(unsigned char *data, size_t size)
static const field32spec_t postTrig32
int getDccErrors() const
int getTriggerType() const
uint16le_t * pSamples
int getBxId() const
void getTimeStamp(struct timeval &t) const
int getEmtcDelay() const
static const field32spec_t timeStampMicroSec32
static const field32spec_t trigRec32
#define INT16_FROM_LE
static const field32spec_t vernier2_32
int getAttenuation_dB() const
int getFedId() const
static const field32spec_t emtcDelay32
static const field32spec_t side32
int getBoe() const
unsigned getEventId() const
int getLaserPower() const
static const field32spec_t dccId32
static const field32spec_t triggerType32
static const field32spec_t color32
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
time_t getTimeStamp() const
MatacqRawEvent(const unsigned char *dataBuffer, size_t bufferSize)
static const field32spec_t delayA32
struct timeval timeStamp
const std::vector< ChannelData > & getChannelData() const
static const field32spec_t orbitId32
std::vector< ChannelData > channelData
int getFov() const
static const field32spec_t formatVersion32
static const field32spec_t dccErrors32
static const field32spec_t h1Marker32
static const field32spec_t freqGHz32
std::vector< int > getVernier() const
int getH1Marker() const
static const field32spec_t laserPower32
static const field32spec_t bxId32