test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 <inttypes.h>
7 #include <vector>
8 
9 #if 0 //replace 1 by 0 to remove XDAQ dependency. In this case it is assumed the
10  //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 
24 #include <sys/time.h> //for timeval definition
25 
30  //typedefs, enums and static constants
31 public:
39  errorLength = 1<<1,
43  };
44 
45  /* The following types are little-endian encoded types. Use of these types
46  * for the I20 data block should offer portability to big-endian platforms.
47  */
49  struct uint32le_t{
50  uint32_t littleEndianInt;
51  operator uint32_t() const{
53  }
54  };
55 
56  struct uint16le_t{
57  uint16_t littleEndianInt;
58  operator uint16_t() const{
60  }
61  };
62 
63  struct int16le_t{
64  int16_t littleEndianInt;
65  operator int16_t() const{
67  }
68  };
70 
71  struct ChannelData{
74  int chId;
77  int nSamples;
81  };
82 
83 private:
86 // struct matacqHeader_t{
87 // uint16_t version;
88 // unsigned char freqGHz;
89 // unsigned char channelCount;
90 // uint32_t orbitId;
91 // unsigned char trigRec;
92 // uint16_t postTrig;
93 // uint16_t vernier[4];
94 // uint32_t timeStamp;
95 // };
96 
99  struct field32spec_t{
100  int offset;
101  unsigned int mask;
102  };
103 
105 
107  static const field32spec_t fov32;
108  static const field32spec_t fedId32;
109  static const field32spec_t bxId32;
110  static const field32spec_t lv132;
112  static const field32spec_t boeType32;
113  static const field32spec_t dccLen32;
115  static const field32spec_t runNum32;
116  static const field32spec_t h1Marker32;
118 
120 
123  static const field32spec_t freqGHz32;
126  static const field32spec_t tTrigPs32;
127  static const field32spec_t orbitId32;
128  static const field32spec_t trigRec32;
129  static const field32spec_t postTrig32;
135 
140  static const field32spec_t delayA32;
141  static const field32spec_t dccId32;
142  static const field32spec_t color32;
143  static const field32spec_t trigType32;
144  static const field32spec_t side32;
145 
147 
148  //constructors
149 public:
159  MatacqRawEvent(const unsigned char* dataBuffer, size_t bufferSize): vernier(std::vector<int>(4)){
160  setRawData(dataBuffer, bufferSize);
161  }
162  //methods
163 public:
170  int getFov() const { return read32(daqHeader, fov32);}
171 
175  int getFedId() const { return read32(daqHeader, fedId32);}
176 
180  int getBxId() const { return read32(daqHeader, bxId32);}
181 
185  unsigned getEventId() const { return read32(daqHeader, lv132);}
186 
190  int getTriggerType() const { return read32(daqHeader, triggerType32);}
191 
195  int getBoe() const { return read32(daqHeader, boeType32);}
196 
200  unsigned getDccLen() const { return read32(daqHeader, dccLen32);}
201 
208  static unsigned getDccLen(unsigned char* data, size_t size){
209  if(size<(unsigned)(dccLen32.offset+1)*4) return (unsigned)-1;
210  return read32((uint32le_t*) data, dccLen32);
211  }
212 
220  static unsigned getOrbitId(unsigned char* data, size_t size){
221  if(size<(unsigned)(orbitId32.offset+1)*8) return (unsigned)-1;
222  return read32((uint32le_t*) data, orbitId32);
223  }
224 
231  static unsigned getRunNum(unsigned char* data, size_t size){
232  if(size<(unsigned)(runNum32.offset+1)*8) return (unsigned)-1;
233  return read32((uint32le_t*) data, runNum32);
234  }
235 
236 
240  unsigned getDaqLen() const { return fragLen;}
241 
242 
246  int getDccErrors() const { return read32(daqHeader, dccErrors32);}
247 
251  unsigned getRunNum() const { return read32(daqHeader, runNum32);}
252 
256  int getH1Marker() const { return read32(daqHeader, h1Marker32);}
257 
258 
263 
268  int32_t getStatus() const { return error;}
269 
273  int getFreqGHz() const { return /*matacqHeader->*/freqGHz;}
274 
278  int getChannelCount() const { return /*matacqHeader->*/channelCount;}
279 
285  const std::vector<ChannelData>& getChannelData() const{
286  return channelData;
287  }
288 
293  int getParsedLen() { return parsedLen; }
294 
300  time_t getTimeStamp() const { return /*matacqHeader->*/timeStamp.tv_sec; }
301 
307  void getTimeStamp(struct timeval& t) const { t = timeStamp; }
308 
313  int getTTrigPs() const { return tTrigPs; }
314 
319  uint32_t getOrbitId() const { return orbitId; }
320 
325  int getTrigRec() const { return trigRec; }
326 
330  int getPostTrig() const { return postTrig; }
331 
335  std::vector<int> getVernier() const { return vernier; }
336 
339  int getDelayA() const { return delayA; }
340 
343  int getEmtcDelay() const { return emtcDelay; }
344 
347  int getEmtcPhase() const { return emtcPhase; }
348 
352  int getAttenuation_dB() const { return attenuation_dB; }
353 
356  int getLaserPower() const { return laserPower; }
357 
358 private:
367  static int read32(uint32le_t* pData, field32spec_t spec, bool ovfTrans = false);
368 
369 // /** Help function to get the maximum value of a data field
370 // * @param spec32 data field specification
371 // * @return maximum value
372 // */
373 // int max32(field32spec_t spec32) const;
374 
382  void setRawData(const unsigned char* buffer, size_t bufferSize);
383 
384  //fields
385 private:
388  int boe;
389 
392  int bxId;
393 
397 
400  std::vector<ChannelData> channelData;
401 
405 
409 
412  unsigned dccLen;
413 
416  unsigned eventId;
417 
420  int32_t error;
421 
424  int fedId;
425 
428  int fov;
429 
432  int fragLen;
433 
436  int freqGHz;
437 
440  int h1Marker;
441 
444  // matacqHeader_t* matacqHeader;
445 
449 
453 
457 
460  unsigned runNum;
461 
464  struct timeval timeStamp;
465 
468  int tTrigPs;
469 
473 
474  /* LHC orbit ID
475  */
476  uint32_t orbitId;
477 
480  int trigRec;
481 
484  int postTrig;
485 
488  std::vector<int> vernier;
489 
492  int delayA;
493 
496  int emtcDelay;
497 
501 
506 
510 };
511 
512 #endif //MATACQRAWEVENT_H not defined
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)
int getEmtcPhase() const
int getFreqGHz() const
const int16le_t * samples
int getDelayA() const
uint32le_t * daqHeader
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
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
static int read32(uint32le_t *pData, field32spec_t spec, bool ovfTrans=false)
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
tuple size
Write out results.
static const field32spec_t bxId32