CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
MatacqTBRawEvent Class Reference

#include <MatacqRawEvent.h>

Classes

struct  ChannelData
 
struct  field32spec_t
 
struct  int16le_t
 
struct  matacqHeader_t
 
struct  uint16le_t
 
struct  uint32le_t
 

Public Types

enum  matacqError_t { errorLengthConsistency = 1 << 0, errorLength = 1 << 1, errorWrongBoe = 1 << 2 }
 

Public Member Functions

int getBoe () const
 
int getBxId () const
 
int getChannelCount () const
 
const std::vector< ChannelData > & getChannelData () const
 
unsigned getDaqLen () const
 
int getDccErrors () const
 
unsigned getDccLen () const
 
unsigned getEventId () const
 
int getFedId () const
 
int getFov () const
 
int getFreqGHz () const
 
int getH1Marker () const
 
int getMatacqDataFormatVersion () const
 
int getParsedLen ()
 
unsigned getRunNum () const
 
int32_t getStatus () const
 
time_t getTimeStamp () const
 
int getTriggerType () const
 
int getTTrigPs () const
 
 MatacqTBRawEvent (const unsigned char *dataBuffer, std::size_t bufferSize)
 

Private Member Functions

int read32 (const uint32le_t *pData, field32spec_t spec) const
 
void setRawData (const unsigned char *buffer, std::size_t bufferSize)
 

Private Attributes

int boe
 
int bxId
 
int channelCount
 
std::vector< ChannelDatachannelData
 
const uint32le_tdaqHeader
 
int dccErrors
 
unsigned dccLen
 
int32_t error
 
unsigned eventId
 
int fedId
 
int fov
 
int fragLen
 
int freqGHz
 
int h1Marker
 
int matacqDataFormatVersion
 
const matacqHeader_tmatacqHeader
 
int parsedLen
 
uint16le_tpSamples
 
unsigned runNum
 
time_t timeStamp
 
int triggerType
 
int tTrigPs
 

Static Private Attributes

static const field32spec_t boeType32 = {1, 0xF0000000}
 
static const field32spec_t bxId32 = {0, 0xFFF00000}
 
static const field32spec_t dccErrors32 = {2, 0xFF000000}
 
static const field32spec_t dccLen32 = {2, 0x00FFFFFF}
 
static const field32spec_t fedId32 = {0, 0x000FFF00}
 
static const field32spec_t fov32 = {0, 0x000000F0}
 
static const field32spec_t h1Marker32 = {3, 0xF0000000}
 
static const field32spec_t lv132 = {1, 0x00FFFFFF}
 
static const field32spec_t runNum32 = {3, 0x00FFFFFF}
 
static const field32spec_t triggerType32 = {1, 0x0F000000}
 

Detailed Description

Wrapper for matacq raw event fragments. This class provides the method to interpret the data.

Definition at line 27 of file MatacqRawEvent.h.

Member Enumeration Documentation

Enumerator
errorLengthConsistency 

Event length is specified both in the data header and the trailer. This flags indicates an inconsitency between the two indications.

errorLength 

Error in data length.

errorWrongBoe 

Wrong Begin of eevent flag

Definition at line 30 of file MatacqRawEvent.h.

Constructor & Destructor Documentation

MatacqTBRawEvent::MatacqTBRawEvent ( const unsigned char *  dataBuffer,
std::size_t  bufferSize 
)
inline

Constuctor.

Parameters
dataBufferpointer to the raw data. Beware the data are not copied, therefore the data must be kept valid during the lifetime of the constructed object. pData must be aligned at least on 32-bit words.
bufferSizesize of the buffer pointed by dataBuffer and containing the data. The data themselves are allowed to be smaller than the buffer.
Exceptions
std::exceptionif the data cannot be decoded due to data corruption or truncation.

Definition at line 116 of file MatacqRawEvent.h.

References setRawData().

116 { setRawData(dataBuffer, bufferSize); }
void setRawData(const unsigned char *buffer, std::size_t bufferSize)

Member Function Documentation

int MatacqTBRawEvent::getBoe ( ) const
inline

Gets the beging of event field contents (BOE). Must be 0x5.

Returns
BOE

Definition at line 150 of file MatacqRawEvent.h.

References boeType32, daqHeader, and read32().

Referenced by setRawData().

150 { return read32(daqHeader, boeType32); }
static const field32spec_t boeType32
int read32(const uint32le_t *pData, field32spec_t spec) const
const uint32le_t * daqHeader
int MatacqTBRawEvent::getBxId ( ) const
inline

Gets the bunch crossing id field contents.

Returns
BX id

Definition at line 135 of file MatacqRawEvent.h.

References bxId32, daqHeader, and read32().

Referenced by MatacqTBDataFormatter::printData().

135 { return read32(daqHeader, bxId32); }
int read32(const uint32le_t *pData, field32spec_t spec) const
const uint32le_t * daqHeader
static const field32spec_t bxId32
int MatacqTBRawEvent::getChannelCount ( ) const
inline

Gets the matacq channel count field contents.

Returns
number of channels

Definition at line 196 of file MatacqRawEvent.h.

References MatacqTBRawEvent::matacqHeader_t::channelCount, and matacqHeader.

Referenced by MatacqTBDataFormatter::printData(), and setRawData().

196 { return matacqHeader->channelCount; }
const matacqHeader_t * matacqHeader
const std::vector<ChannelData>& MatacqTBRawEvent::getChannelData ( ) const
inline

Gets the matacq channel data. Beware that no copy is done and that the returned data will be invalidated if the data contains in the buffer is modified (see constructor and setRawData().

Returns
matacq channel data.

Definition at line 203 of file MatacqRawEvent.h.

References channelData.

Referenced by MatacqTBDataFormatter::printData().

203 { return channelData; }
std::vector< ChannelData > channelData
unsigned MatacqTBRawEvent::getDaqLen ( ) const
inline

Gets the event length specifies in the DAQ trailer

Returns
event length

Definition at line 160 of file MatacqRawEvent.h.

References fragLen.

160 { return fragLen; }
int MatacqTBRawEvent::getDccErrors ( ) const
inline

Gets the contents of the DCC error field. Currently Not used for Matacq.

Returns
dcc error

Definition at line 165 of file MatacqRawEvent.h.

References daqHeader, dccErrors32, and read32().

Referenced by MatacqTBDataFormatter::printData().

165 { return read32(daqHeader, dccErrors32); }
int read32(const uint32le_t *pData, field32spec_t spec) const
const uint32le_t * daqHeader
static const field32spec_t dccErrors32
unsigned MatacqTBRawEvent::getDccLen ( ) const
inline

Gets the event length specifies in the "a la DCC" header.

Returns
event length

Definition at line 155 of file MatacqRawEvent.h.

References daqHeader, dccLen32, and read32().

Referenced by MatacqTBDataFormatter::printData().

155 { return read32(daqHeader, dccLen32); }
int read32(const uint32le_t *pData, field32spec_t spec) const
const uint32le_t * daqHeader
static const field32spec_t dccLen32
unsigned MatacqTBRawEvent::getEventId ( ) const
inline

Gets the LV1 field contents.

Returns
LV1 id

Definition at line 140 of file MatacqRawEvent.h.

References daqHeader, lv132, and read32().

Referenced by MatacqTBDataFormatter::printData().

140 { return read32(daqHeader, lv132); }
static const field32spec_t lv132
int read32(const uint32le_t *pData, field32spec_t spec) const
const uint32le_t * daqHeader
int MatacqTBRawEvent::getFedId ( ) const
inline

Gets the FED ID field contents. Should be 43.

Returns
FED ID

Definition at line 130 of file MatacqRawEvent.h.

References daqHeader, fedId32, and read32().

Referenced by MatacqTBDataFormatter::printData().

130 { return read32(daqHeader, fedId32); }
int read32(const uint32le_t *pData, field32spec_t spec) const
const uint32le_t * daqHeader
static const field32spec_t fedId32
int MatacqTBRawEvent::getFov ( ) const
inline

Gets the Fed event fragment data format (FOV) field content. Currently the FOV is not used for MATACQ. Note that matacq data format has its own internal version. See getMatacqDataFormatVersion()

Returns
FOV

Definition at line 125 of file MatacqRawEvent.h.

References daqHeader, fov32, and read32().

Referenced by MatacqTBDataFormatter::printData().

125 { return read32(daqHeader, fov32); }
static const field32spec_t fov32
int read32(const uint32le_t *pData, field32spec_t spec) const
const uint32le_t * daqHeader
int MatacqTBRawEvent::getFreqGHz ( ) const
inline

Gets the matacq sampling frequency field contents.

Returns
sampling frequency in GHz: 1 or 2

Definition at line 191 of file MatacqRawEvent.h.

References MatacqTBRawEvent::matacqHeader_t::freqGHz, and matacqHeader.

Referenced by MatacqTBDataFormatter::printData().

191 { return matacqHeader->freqGHz; }
const matacqHeader_t * matacqHeader
int MatacqTBRawEvent::getH1Marker ( ) const
inline

Gets the header marker field contents. Must be 1

Returns
H1 header marker

Definition at line 175 of file MatacqRawEvent.h.

References daqHeader, h1Marker32, and read32().

175 { return read32(daqHeader, h1Marker32); }
int read32(const uint32le_t *pData, field32spec_t spec) const
const uint32le_t * daqHeader
static const field32spec_t h1Marker32
int MatacqTBRawEvent::getMatacqDataFormatVersion ( ) const
inline

Gets the matcq data format version

Returns
data version

Definition at line 180 of file MatacqRawEvent.h.

References matacqHeader, and MatacqTBRawEvent::matacqHeader_t::version.

Referenced by MatacqTBDataFormatter::printData(), and setRawData().

180 { return matacqHeader->version; }
const matacqHeader_t * matacqHeader
int MatacqTBRawEvent::getParsedLen ( )
inline

Gets the data length in number of 64-bit words computed by the data parser.

Returns
event length

Definition at line 209 of file MatacqRawEvent.h.

References parsedLen.

209 { return parsedLen; }
unsigned MatacqTBRawEvent::getRunNum ( ) const
inline

Gets the run number field contents.

Returns
run number

Definition at line 170 of file MatacqRawEvent.h.

References daqHeader, read32(), and runNum32.

Referenced by MatacqTBDataFormatter::printData().

170 { return read32(daqHeader, runNum32); }
int read32(const uint32le_t *pData, field32spec_t spec) const
static const field32spec_t runNum32
const uint32le_t * daqHeader
int32_t MatacqTBRawEvent::getStatus ( ) const
inline

Gets the raw data status. Bitwise OR of the error flags defined by matcqError_t

Returns
status

Definition at line 186 of file MatacqRawEvent.h.

References error.

Referenced by MatacqTBDataFormatter::printData().

186 { return error; }
time_t MatacqTBRawEvent::getTimeStamp ( ) const
inline

Gets the matacq data timestamp field contents:

Returns
acquisition date of the data expressed in number of "elapsed" second since the EPOCH as defined in POSIX.1. See time() standard c function.

Definition at line 216 of file MatacqRawEvent.h.

References matacqHeader, and MatacqTBRawEvent::matacqHeader_t::timeStamp.

Referenced by MatacqTBDataFormatter::printData().

216 { return matacqHeader->timeStamp; }
const matacqHeader_t * matacqHeader
int MatacqTBRawEvent::getTriggerType ( ) const
inline

Gets the trigger type field contents.

Returns
trigger type

Definition at line 145 of file MatacqRawEvent.h.

References daqHeader, read32(), and triggerType32.

Referenced by MatacqTBDataFormatter::printData().

145 { return read32(daqHeader, triggerType32); }
int read32(const uint32le_t *pData, field32spec_t spec) const
const uint32le_t * daqHeader
static const field32spec_t triggerType32
int MatacqTBRawEvent::getTTrigPs ( ) const
inline

Gets the Matacq trigger time.

Returns
(t_trig-t_0) in ps, with t_0 the time of the first sample and t_trig the trigger time.

Definition at line 222 of file MatacqRawEvent.h.

References tTrigPs.

222 { return tTrigPs; }
int MatacqTBRawEvent::read32 ( const uint32le_t pData,
field32spec_t  spec 
) const
private

Help function to decode header content.

Parameters
datapointer
specspecification of the data field to read
Returns
content of data field specified by 'spec'

Definition at line 102 of file MatacqRawEvent.cc.

References MatacqTBRawEvent::field32spec_t::mask, MatacqTBRawEvent::field32spec_t::offset, and mps_fire::result.

Referenced by getBoe(), getBxId(), getDccErrors(), getDccLen(), getEventId(), getFedId(), getFov(), getH1Marker(), getRunNum(), getTriggerType(), and setRawData().

102  {
103  int result = pData[spec32.offset] & spec32.mask;
104  int mask = spec32.mask;
105  while ((mask & 0x1) == 0) {
106  mask >>= 1;
107  result >>= 1;
108  }
109  return result;
110 }
tuple result
Definition: mps_fire.py:311
void MatacqTBRawEvent::setRawData ( const unsigned char *  buffer,
std::size_t  bufferSize 
)
private

Changes the raw data pointer and updates accordingly this object.

Parameters
buffernew pointer to the data buffer. Must be aligned at least on 32-bit words.
sizeof the data buffer.
Exceptions
std::exceptionif the data cannot be decoded due to data corruption or truncation.

Definition at line 33 of file MatacqRawEvent.cc.

References channelData, daqHeader, dccLen32, error, errorLength, errorLengthConsistency, errorWrongBoe, fragLen, getBoe(), getChannelCount(), getMatacqDataFormatVersion(), matacqHeader, SiStripPI::max, parsedLen, read32(), AlCaHLTBitMon_QueryRunRegistry::string, and tTrigPs.

Referenced by MatacqTBRawEvent().

33  {
34  error = 0;
35  const int16le_t* begin16 = (const int16le_t*)pData;
36  const int16le_t* pData16 = begin16;
37  daqHeader = (const uint32le_t*)pData16;
38  const int daqHeaderLen = 16; //in bytes
39  pData16 += daqHeaderLen / sizeof(pData16[0]);
40  matacqHeader = (const matacqHeader_t*)pData16;
41  pData16 += sizeof(matacqHeader_t) / sizeof(pData16[0]);
42  if (getMatacqDataFormatVersion() >= 2) { //trigger position present
43  tTrigPs = *((const int32_t*)pData16);
44  pData16 += 2;
45  } else {
47  }
48  const int nCh = getChannelCount();
49  channelData.resize(nCh);
50  for (int iCh = 0; iCh < nCh; ++iCh) {
51  //channel id:
52  channelData[iCh].chId = *(pData16++);
53  //number of time samples for this channel:
54  channelData[iCh].nSamples = *(pData16++);
55  //pointer to time sample data of this channel:
56  channelData[iCh].samples = pData16;
57  //moves to next channel data block:
58  pData16 += channelData[iCh].nSamples;
59  }
60 
61  //data trailer chekes:
62  //FED header is aligned on 64-bit=>padding to skip
63  int padding = (4 - (pData16 - begin16)) % 4;
64  if (padding < 0)
65  padding += 4;
66  pData16 += padding;
67  const uint32le_t* trailer32 = (const uint32le_t*)(pData16);
68  fragLen = trailer32[1] & 0xFFFFFF;
69 
70  //std::cout << "Event fragment length including headers: " << fragLen
71  // << " 64-bit words\n";
72 
73  //FIXME: I am expecting the event length specifies in the header to
74  //include the header, while it is not the case in current TB 2006 data
75  const int nHeaders = 3;
76  if (fragLen != read32(daqHeader, dccLen32) + nHeaders && fragLen != read32(daqHeader, dccLen32)) {
77  //std::cout << "Error: fragment length is not consistent with DCC "
78  // "length\n";
80  }
81 
82  //skip trailers
83  const int trailerLen = 4;
84  pData16 += trailerLen;
85 
86  parsedLen = (pData16 - begin16) / 4;
87 
88  if ((pData16 - begin16) != (4 * fragLen)) {
89  error |= errorLength;
90  }
91 
92  if ((size_t)(pData16 - begin16) > maxSize) {
93  throw std::runtime_error(std::string("Corrupted or truncated data"));
94  }
95 
96  //some checks
97  if (getBoe() != 0x5) {
99  }
100 }
int read32(const uint32le_t *pData, field32spec_t spec) const
int getChannelCount() const
std::vector< ChannelData > channelData
tuple maxSize
&#39;/store/data/Commissioning08/BeamHalo/RECO/StuffAlmostToP5_v1/000/061/642/10A0FE34-A67D-DD11-AD05-000...
int getMatacqDataFormatVersion() const
int getBoe() const
const uint32le_t * daqHeader
const matacqHeader_t * matacqHeader
static const field32spec_t dccLen32

Member Data Documentation

int MatacqTBRawEvent::boe
private

Begin Of Event marker

Definition at line 245 of file MatacqRawEvent.h.

const MatacqTBRawEvent::field32spec_t MatacqTBRawEvent::boeType32 = {1, 0xF0000000}
staticprivate

Definition at line 99 of file MatacqRawEvent.h.

Referenced by getBoe().

int MatacqTBRawEvent::bxId
private

Bunch crossing Id

Definition at line 249 of file MatacqRawEvent.h.

const MatacqTBRawEvent::field32spec_t MatacqTBRawEvent::bxId32 = {0, 0xFFF00000}
staticprivate

Definition at line 96 of file MatacqRawEvent.h.

Referenced by getBxId().

int MatacqTBRawEvent::channelCount
private

Number of matacq channels in the data.

Definition at line 253 of file MatacqRawEvent.h.

std::vector<ChannelData> MatacqTBRawEvent::channelData
private

Channel samples

Definition at line 257 of file MatacqRawEvent.h.

Referenced by getChannelData(), and setRawData().

const uint32le_t* MatacqTBRawEvent::daqHeader
private

Pointer to the standard CMS DAQ header

Definition at line 261 of file MatacqRawEvent.h.

Referenced by getBoe(), getBxId(), getDccErrors(), getDccLen(), getEventId(), getFedId(), getFov(), getH1Marker(), getRunNum(), getTriggerType(), and setRawData().

int MatacqTBRawEvent::dccErrors
private

DCC error field content.

Definition at line 265 of file MatacqRawEvent.h.

const MatacqTBRawEvent::field32spec_t MatacqTBRawEvent::dccErrors32 = {2, 0xFF000000}
staticprivate

Definition at line 101 of file MatacqRawEvent.h.

Referenced by getDccErrors().

unsigned MatacqTBRawEvent::dccLen
private

Event length specified in 'DCC' header

Definition at line 269 of file MatacqRawEvent.h.

const MatacqTBRawEvent::field32spec_t MatacqTBRawEvent::dccLen32 = {2, 0x00FFFFFF}
staticprivate

Definition at line 100 of file MatacqRawEvent.h.

Referenced by getDccLen(), and setRawData().

int32_t MatacqTBRawEvent::error
private

Error code or 0 if no error.

Definition at line 277 of file MatacqRawEvent.h.

Referenced by getStatus(), and setRawData().

unsigned MatacqTBRawEvent::eventId
private

Event id. Actually LV1 ID.

Definition at line 273 of file MatacqRawEvent.h.

Referenced by ntupleDataFormat.Event::eventIdStr().

int MatacqTBRawEvent::fedId
private

FED ID

Definition at line 281 of file MatacqRawEvent.h.

const MatacqTBRawEvent::field32spec_t MatacqTBRawEvent::fedId32 = {0, 0x000FFF00}
staticprivate

Definition at line 95 of file MatacqRawEvent.h.

Referenced by getFedId().

int MatacqTBRawEvent::fov
private

FED data format version

Definition at line 285 of file MatacqRawEvent.h.

const MatacqTBRawEvent::field32spec_t MatacqTBRawEvent::fov32 = {0, 0x000000F0}
staticprivate

DAQ header field specifications.

Definition at line 94 of file MatacqRawEvent.h.

Referenced by getFov().

int MatacqTBRawEvent::fragLen
private

event fragment length as read in the std DAQ trailer. In 64-bit words

Definition at line 289 of file MatacqRawEvent.h.

Referenced by getDaqLen(), and setRawData().

int MatacqTBRawEvent::freqGHz
private

MATACQ sampling frequency in GHz

Definition at line 293 of file MatacqRawEvent.h.

int MatacqTBRawEvent::h1Marker
private

header marker

Definition at line 297 of file MatacqRawEvent.h.

const MatacqTBRawEvent::field32spec_t MatacqTBRawEvent::h1Marker32 = {3, 0xF0000000}
staticprivate

Definition at line 103 of file MatacqRawEvent.h.

Referenced by getH1Marker().

const MatacqTBRawEvent::field32spec_t MatacqTBRawEvent::lv132 = {1, 0x00FFFFFF}
staticprivate

Definition at line 97 of file MatacqRawEvent.h.

Referenced by getEventId().

int MatacqTBRawEvent::matacqDataFormatVersion
private

MATACQ data format internal version

Definition at line 305 of file MatacqRawEvent.h.

const matacqHeader_t* MatacqTBRawEvent::matacqHeader
private

Matacq header:

Definition at line 301 of file MatacqRawEvent.h.

Referenced by getChannelCount(), getFreqGHz(), getMatacqDataFormatVersion(), getTimeStamp(), and setRawData().

int MatacqTBRawEvent::parsedLen
private

event lenght computed by the raw data parser

Definition at line 309 of file MatacqRawEvent.h.

Referenced by getParsedLen(), and setRawData().

uint16le_t* MatacqTBRawEvent::pSamples
private

Pointer to MATACQ samples block

Definition at line 313 of file MatacqRawEvent.h.

unsigned MatacqTBRawEvent::runNum
private

Run number

Definition at line 317 of file MatacqRawEvent.h.

const MatacqTBRawEvent::field32spec_t MatacqTBRawEvent::runNum32 = {3, 0x00FFFFFF}
staticprivate

Definition at line 102 of file MatacqRawEvent.h.

Referenced by getRunNum().

time_t MatacqTBRawEvent::timeStamp
private

Matacq acquisition time stamp

Definition at line 321 of file MatacqRawEvent.h.

int MatacqTBRawEvent::triggerType
private

Trigger type

Definition at line 329 of file MatacqRawEvent.h.

const MatacqTBRawEvent::field32spec_t MatacqTBRawEvent::triggerType32 = {1, 0x0F000000}
staticprivate

Definition at line 98 of file MatacqRawEvent.h.

Referenced by getTriggerType().

int MatacqTBRawEvent::tTrigPs
private

MATACQ trigger time position in ps

Definition at line 325 of file MatacqRawEvent.h.

Referenced by getTTrigPs(), and setRawData().