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 //replace 1 by 0 to remove XDAQ dependency. In this case it is assumed the machine is little endian.
11 #if 0
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,
43  errorWrongBoe = 1 << 2
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 { return UINT32_FROM_LE(littleEndianInt); }
53  };
54 
55  struct uint16le_t {
56  uint16_t littleEndianInt;
57  operator uint16_t() const { return UINT16_FROM_LE(littleEndianInt); }
58  };
59 
60  struct int16le_t {
61  int16_t littleEndianInt;
62  operator int16_t() const { return INT16_FROM_LE(littleEndianInt); }
63  };
65 
66  struct ChannelData {
69  int chId;
72  int nSamples;
76  };
77 
78 private:
81  // struct matacqHeader_t{
82  // uint16_t version;
83  // unsigned char freqGHz;
84  // unsigned char channelCount;
85  // uint32_t orbitId;
86  // unsigned char trigRec;
87  // uint16_t postTrig;
88  // uint16_t vernier[4];
89  // uint32_t timeStamp;
90  // };
91 
94  struct field32spec_t {
95  int offset;
96  unsigned int mask;
97  };
98 
100 
102  static const field32spec_t fov32;
103  static const field32spec_t fedId32;
104  static const field32spec_t bxId32;
105  static const field32spec_t lv132;
107  static const field32spec_t boeType32;
108  static const field32spec_t dccLen32;
110  static const field32spec_t runNum32;
111  static const field32spec_t h1Marker32;
113 
115 
118  static const field32spec_t freqGHz32;
121  static const field32spec_t tTrigPs32;
122  static const field32spec_t orbitId32;
123  static const field32spec_t trigRec32;
124  static const field32spec_t postTrig32;
130 
135  static const field32spec_t delayA32;
136  static const field32spec_t dccId32;
137  static const field32spec_t color32;
138  static const field32spec_t trigType32;
139  static const field32spec_t side32;
140 
142 
143  //constructors
144 public:
154  MatacqRawEvent(const unsigned char* dataBuffer, size_t bufferSize) : vernier(std::vector<int>(4)) {
155  setRawData(dataBuffer, bufferSize);
156  }
157  //methods
158 public:
165  int getFov() const { return read32(daqHeader, fov32); }
166 
170  int getFedId() const { return read32(daqHeader, fedId32); }
171 
175  int getBxId() const { return read32(daqHeader, bxId32); }
176 
180  unsigned getEventId() const { return read32(daqHeader, lv132); }
181 
185  int getTriggerType() const { return read32(daqHeader, triggerType32); }
186 
190  int getBoe() const { return read32(daqHeader, boeType32); }
191 
195  unsigned getDccLen() const { return read32(daqHeader, dccLen32); }
196 
203  static unsigned getDccLen(unsigned char* data, size_t size) {
204  if (size < (unsigned)(dccLen32.offset + 1) * 4)
205  return (unsigned)-1;
206  return read32((uint32le_t*)data, dccLen32);
207  }
208 
216  static unsigned getOrbitId(unsigned char* data, size_t size) {
217  if (size < (unsigned)(orbitId32.offset + 1) * 8)
218  return (unsigned)-1;
219  return read32((uint32le_t*)data, orbitId32);
220  }
221 
228  static unsigned getRunNum(unsigned char* data, size_t size) {
229  if (size < (unsigned)(runNum32.offset + 1) * 8)
230  return (unsigned)-1;
231  return read32((uint32le_t*)data, runNum32);
232  }
233 
237  unsigned getDaqLen() const { return fragLen; }
238 
242  int getDccErrors() const { return read32(daqHeader, dccErrors32); }
243 
247  unsigned getRunNum() const { return read32(daqHeader, runNum32); }
248 
252  int getH1Marker() const { return read32(daqHeader, h1Marker32); }
253 
258 
263  int32_t getStatus() const { return error; }
264 
268  int getFreqGHz() const { return /*matacqHeader->*/ freqGHz; }
269 
273  int getChannelCount() const { return /*matacqHeader->*/ channelCount; }
274 
280  const std::vector<ChannelData>& getChannelData() const { return channelData; }
281 
286  int getParsedLen() { return parsedLen; }
287 
293  time_t getTimeStamp() const { return /*matacqHeader->*/ timeStamp.tv_sec; }
294 
300  void getTimeStamp(struct timeval& t) const { t = timeStamp; }
301 
306  int getTTrigPs() const { return tTrigPs; }
307 
312  uint32_t getOrbitId() const { return orbitId; }
313 
318  int getTrigRec() const { return trigRec; }
319 
323  int getPostTrig() const { return postTrig; }
324 
328  std::vector<int> getVernier() const { return vernier; }
329 
332  int getDelayA() const { return delayA; }
333 
336  int getEmtcDelay() const { return emtcDelay; }
337 
340  int getEmtcPhase() const { return emtcPhase; }
341 
345  int getAttenuation_dB() const { return attenuation_dB; }
346 
349  int getLaserPower() const { return laserPower; }
350 
351 private:
360  static int read32(const uint32le_t* pData, field32spec_t spec, bool ovfTrans = false);
361 
362  // /** Help function to get the maximum value of a data field
363  // * @param spec32 data field specification
364  // * @return maximum value
365  // */
366  // int max32(field32spec_t spec32) const;
367 
375  void setRawData(const unsigned char* buffer, size_t bufferSize);
376 
377  //fields
378 private:
381  int boe;
382 
385  int bxId;
386 
390 
393  std::vector<ChannelData> channelData;
394 
398 
402 
405  unsigned dccLen;
406 
409  unsigned eventId;
410 
413  int32_t error;
414 
417  int fedId;
418 
421  int fov;
422 
425  int fragLen;
426 
429  int freqGHz;
430 
433  int h1Marker;
434 
437  // matacqHeader_t* matacqHeader;
438 
442 
446 
450 
453  unsigned runNum;
454 
457  struct timeval timeStamp;
458 
461  int tTrigPs;
462 
466 
467  /* LHC orbit ID
468  */
469  uint32_t orbitId;
470 
473  int trigRec;
474 
477  int postTrig;
478 
481  std::vector<int> vernier;
482 
485  int delayA;
486 
490 
494 
499 
503 };
504 
505 #endif //MATACQRAWEVENT_H not defined
MatacqRawEvent::getParsedLen
int getParsedLen()
Definition: MatacqRawEvent.h:286
MatacqRawEvent::int16le_t::littleEndianInt
int16_t littleEndianInt
Definition: MatacqRawEvent.h:61
MatacqRawEvent::ChannelData
Definition: MatacqRawEvent.h:66
MatacqRawEvent::freqGHz32
static const field32spec_t freqGHz32
Definition: MatacqRawEvent.h:118
MatacqRawEvent::getTimeStamp
time_t getTimeStamp() const
Definition: MatacqRawEvent.h:293
MatacqRawEvent::dccErrors
int dccErrors
Definition: MatacqRawEvent.h:401
MatacqRawEvent::read32
static int read32(const uint32le_t *pData, field32spec_t spec, bool ovfTrans=false)
Definition: MatacqRawEvent.cc:195
MatacqRawEvent::lv132
static const field32spec_t lv132
Definition: MatacqRawEvent.h:105
MatacqRawEvent::getStatus
int32_t getStatus() const
Definition: MatacqRawEvent.h:263
MatacqRawEvent::boeType32
static const field32spec_t boeType32
Definition: MatacqRawEvent.h:107
MatacqRawEvent::vernier1_32
static const field32spec_t vernier1_32
Definition: MatacqRawEvent.h:126
MatacqRawEvent::postTrig
int postTrig
Definition: MatacqRawEvent.h:477
MatacqRawEvent::bxId
int bxId
Definition: MatacqRawEvent.h:385
MatacqRawEvent::dccErrors32
static const field32spec_t dccErrors32
Definition: MatacqRawEvent.h:109
MatacqRawEvent::pSamples
uint16le_t * pSamples
Definition: MatacqRawEvent.h:449
MatacqRawEvent::uint16le_t
Definition: MatacqRawEvent.h:55
MatacqRawEvent::getTrigRec
int getTrigRec() const
Definition: MatacqRawEvent.h:318
MatacqRawEvent::getChannelCount
int getChannelCount() const
Definition: MatacqRawEvent.h:273
MatacqRawEvent::getChannelData
const std::vector< ChannelData > & getChannelData() const
Definition: MatacqRawEvent.h:280
MatacqRawEvent::getRunNum
static unsigned getRunNum(unsigned char *data, size_t size)
Definition: MatacqRawEvent.h:228
MatacqRawEvent::ChannelData::nSamples
int nSamples
Definition: MatacqRawEvent.h:72
MatacqRawEvent::timeStampMicroSec32
static const field32spec_t timeStampMicroSec32
Definition: MatacqRawEvent.h:129
MatacqRawEvent::getEmtcPhase
int getEmtcPhase() const
Definition: MatacqRawEvent.h:340
MatacqRawEvent::getTimeStamp
void getTimeStamp(struct timeval &t) const
Definition: MatacqRawEvent.h:300
MatacqRawEvent::getTTrigPs
int getTTrigPs() const
Definition: MatacqRawEvent.h:306
MatacqRawEvent::laserPower32
static const field32spec_t laserPower32
Definition: MatacqRawEvent.h:131
MatacqRawEvent::formatVersion32
static const field32spec_t formatVersion32
Definition: MatacqRawEvent.h:117
MatacqRawEvent::fedId32
static const field32spec_t fedId32
Definition: MatacqRawEvent.h:103
MatacqRawEvent::channelCount
int channelCount
Definition: MatacqRawEvent.h:389
MatacqRawEvent::laserPower
int laserPower
Definition: MatacqRawEvent.h:502
MatacqRawEvent::getTriggerType
int getTriggerType() const
Definition: MatacqRawEvent.h:185
MatacqRawEvent::getOrbitId
static unsigned getOrbitId(unsigned char *data, size_t size)
Definition: MatacqRawEvent.h:216
MatacqRawEvent::getH1Marker
int getH1Marker() const
Definition: MatacqRawEvent.h:252
MatacqRawEvent::ChannelData::samples
const int16le_t * samples
Definition: MatacqRawEvent.h:75
MatacqRawEvent::getRunNum
unsigned getRunNum() const
Definition: MatacqRawEvent.h:247
MatacqRawEvent::getFreqGHz
int getFreqGHz() const
Definition: MatacqRawEvent.h:268
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
MatacqRawEvent::field32spec_t::offset
int offset
Definition: MatacqRawEvent.h:95
MatacqRawEvent::dccLen32
static const field32spec_t dccLen32
Definition: MatacqRawEvent.h:108
MatacqRawEvent::fov32
static const field32spec_t fov32
Definition: MatacqRawEvent.h:102
MatacqRawEvent::getDaqLen
unsigned getDaqLen() const
Definition: MatacqRawEvent.h:237
MatacqRawEvent::getLaserPower
int getLaserPower() const
Definition: MatacqRawEvent.h:349
MatacqRawEvent::timeStamp32
static const field32spec_t timeStamp32
Definition: MatacqRawEvent.h:120
INT16_FROM_LE
#define INT16_FROM_LE
Definition: MatacqRawEvent.h:21
MatacqRawEvent::getDccLen
unsigned getDccLen() const
Definition: MatacqRawEvent.h:195
MatacqRawEvent::setRawData
void setRawData(const unsigned char *buffer, size_t bufferSize)
Definition: MatacqRawEvent.cc:77
MatacqRawEvent::boe
int boe
Definition: MatacqRawEvent.h:381
MatacqRawEvent::fragLen
int fragLen
Definition: MatacqRawEvent.h:425
MatacqRawEvent::tTrigPs
int tTrigPs
Definition: MatacqRawEvent.h:461
MatacqRawEvent::vernier
std::vector< int > vernier
Definition: MatacqRawEvent.h:481
MatacqRawEvent::trigType32
static const field32spec_t trigType32
Definition: MatacqRawEvent.h:138
MatacqRawEvent::errorLength
Definition: MatacqRawEvent.h:40
MatacqRawEvent::trigRec
int trigRec
Definition: MatacqRawEvent.h:473
MatacqRawEvent::field32spec_t
Definition: MatacqRawEvent.h:94
MatacqRawEvent::getDccErrors
int getDccErrors() const
Definition: MatacqRawEvent.h:242
MatacqRawEvent::error
int32_t error
Definition: MatacqRawEvent.h:413
MatacqRawEvent::getMatacqDataFormatVersion
int getMatacqDataFormatVersion() const
Definition: MatacqRawEvent.h:257
MatacqRawEvent::getPostTrig
int getPostTrig() const
Definition: MatacqRawEvent.h:323
OrderedSet.t
t
Definition: OrderedSet.py:90
MatacqRawEvent
Definition: MatacqRawEvent.h:30
MatacqRawEvent::h1Marker
int h1Marker
Definition: MatacqRawEvent.h:433
MatacqRawEvent::ChannelData::chId
int chId
Definition: MatacqRawEvent.h:69
MatacqRawEvent::errorWrongBoe
Definition: MatacqRawEvent.h:43
MatacqRawEvent::orbitId32
static const field32spec_t orbitId32
Definition: MatacqRawEvent.h:122
MatacqRawEvent::uint32le_t
Definition: MatacqRawEvent.h:50
MatacqRawEvent::getFedId
int getFedId() const
Definition: MatacqRawEvent.h:170
MatacqRawEvent::getBxId
int getBxId() const
Definition: MatacqRawEvent.h:175
MatacqRawEvent::emtcDelay32
static const field32spec_t emtcDelay32
Definition: MatacqRawEvent.h:134
MatacqRawEvent::delayA32
static const field32spec_t delayA32
Definition: MatacqRawEvent.h:135
MatacqRawEvent::fedId
int fedId
Definition: MatacqRawEvent.h:417
MatacqRawEvent::channelData
std::vector< ChannelData > channelData
Definition: MatacqRawEvent.h:393
MatacqRawEvent::fov
int fov
Definition: MatacqRawEvent.h:421
createfilelist.int
int
Definition: createfilelist.py:10
MatacqRawEvent::delayA
int delayA
Definition: MatacqRawEvent.h:485
MatacqRawEvent::emtcDelay
int emtcDelay
Definition: MatacqRawEvent.h:489
MatacqRawEvent::getBoe
int getBoe() const
Definition: MatacqRawEvent.h:190
MatacqRawEvent::emtcPhase32
static const field32spec_t emtcPhase32
Definition: MatacqRawEvent.h:133
UINT16_FROM_LE
#define UINT16_FROM_LE
Definition: MatacqRawEvent.h:20
MatacqRawEvent::getDccLen
static unsigned getDccLen(unsigned char *data, size_t size)
Definition: MatacqRawEvent.h:203
MatacqRawEvent::runNum
unsigned runNum
Definition: MatacqRawEvent.h:453
MatacqRawEvent::channelCount32
static const field32spec_t channelCount32
Definition: MatacqRawEvent.h:119
MatacqRawEvent::postTrig32
static const field32spec_t postTrig32
Definition: MatacqRawEvent.h:124
MatacqRawEvent::getFov
int getFov() const
Definition: MatacqRawEvent.h:165
MatacqRawEvent::daqHeader
const uint32le_t * daqHeader
Definition: MatacqRawEvent.h:397
MatacqRawEvent::attenuation_dB
int attenuation_dB
Definition: MatacqRawEvent.h:498
MatacqRawEvent::getDelayA
int getDelayA() const
Definition: MatacqRawEvent.h:332
MatacqRawEvent::field32spec_t::mask
unsigned int mask
Definition: MatacqRawEvent.h:96
MatacqRawEvent::vernier2_32
static const field32spec_t vernier2_32
Definition: MatacqRawEvent.h:127
MatacqRawEvent::vernier3_32
static const field32spec_t vernier3_32
Definition: MatacqRawEvent.h:128
MatacqRawEvent::orbitId
uint32_t orbitId
Definition: MatacqRawEvent.h:469
MatacqRawEvent::getVernier
std::vector< int > getVernier() const
Definition: MatacqRawEvent.h:328
MatacqRawEvent::uint16le_t::littleEndianInt
uint16_t littleEndianInt
Definition: MatacqRawEvent.h:56
std
Definition: JetResolutionObject.h:76
MatacqRawEvent::MatacqRawEvent
MatacqRawEvent(const unsigned char *dataBuffer, size_t bufferSize)
Definition: MatacqRawEvent.h:154
MatacqRawEvent::matacqDataFormatVersion
int matacqDataFormatVersion
Definition: MatacqRawEvent.h:441
MatacqRawEvent::uint32le_t::littleEndianInt
uint32_t littleEndianInt
Definition: MatacqRawEvent.h:51
MatacqRawEvent::matacqError_t
matacqError_t
Definition: MatacqRawEvent.h:33
MatacqRawEvent::triggerType32
static const field32spec_t triggerType32
Definition: MatacqRawEvent.h:106
MatacqRawEvent::h1Marker32
static const field32spec_t h1Marker32
Definition: MatacqRawEvent.h:111
MatacqRawEvent::triggerType
int triggerType
Definition: MatacqRawEvent.h:465
MatacqRawEvent::trigRec32
static const field32spec_t trigRec32
Definition: MatacqRawEvent.h:123
MatacqRawEvent::runNum32
static const field32spec_t runNum32
Definition: MatacqRawEvent.h:110
UINT32_FROM_LE
#define UINT32_FROM_LE
Definition: MatacqRawEvent.h:19
MatacqRawEvent::vernier0_32
static const field32spec_t vernier0_32
Definition: MatacqRawEvent.h:125
MatacqRawEvent::dccId32
static const field32spec_t dccId32
Definition: MatacqRawEvent.h:136
MatacqRawEvent::dccLen
unsigned dccLen
Definition: MatacqRawEvent.h:405
MatacqRawEvent::getOrbitId
uint32_t getOrbitId() const
Definition: MatacqRawEvent.h:312
MatacqRawEvent::side32
static const field32spec_t side32
Definition: MatacqRawEvent.h:139
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
MatacqRawEvent::timeStamp
struct timeval timeStamp
Definition: MatacqRawEvent.h:457
MatacqRawEvent::color32
static const field32spec_t color32
Definition: MatacqRawEvent.h:137
MatacqRawEvent::tTrigPs32
static const field32spec_t tTrigPs32
Definition: MatacqRawEvent.h:121
MatacqRawEvent::int16le_t
Definition: MatacqRawEvent.h:60
MatacqRawEvent::getAttenuation_dB
int getAttenuation_dB() const
Definition: MatacqRawEvent.h:345
MatacqRawEvent::emtcPhase
int emtcPhase
Definition: MatacqRawEvent.h:493
MatacqRawEvent::errorLengthConsistency
Definition: MatacqRawEvent.h:37
MatacqRawEvent::parsedLen
int parsedLen
Definition: MatacqRawEvent.h:445
MatacqRawEvent::getEventId
unsigned getEventId() const
Definition: MatacqRawEvent.h:180
MatacqRawEvent::attenuation_dB32
static const field32spec_t attenuation_dB32
Definition: MatacqRawEvent.h:132
MatacqRawEvent::bxId32
static const field32spec_t bxId32
Definition: MatacqRawEvent.h:104
MatacqRawEvent::eventId
unsigned eventId
Definition: MatacqRawEvent.h:409
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MatacqRawEvent::getEmtcDelay
int getEmtcDelay() const
Definition: MatacqRawEvent.h:336
MatacqRawEvent::freqGHz
int freqGHz
Definition: MatacqRawEvent.h:429