#include <EventFilter/EcalTBRawToDigi/src/MatacqRawEvent.h>
Public Types | |
enum | matacqError_t { errorLengthConsistency = 1<<0, errorLength = 1<<1, errorWrongBoe = 1<<2 } |
Public Member Functions | |
int | getBoe () const |
Gets the beging of event field contents (BOE). | |
int | getBxId () const |
Gets the bunch crossing id field contents. | |
int | getChannelCount () const |
Gets the matacq channel count field contents. | |
const std::vector< ChannelData > & | getChannelData () const |
Gets the matacq channel data. | |
unsigned | getDaqLen () const |
Gets the event length specifies in the DAQ trailer. | |
int | getDccErrors () const |
Gets the contents of the DCC error field. | |
unsigned | getDccLen () const |
Gets the event length specifies in the "a la DCC" header. | |
unsigned | getEventId () const |
Gets the LV1 field contents. | |
int | getFedId () const |
Gets the FED ID field contents. | |
int | getFov () const |
Gets the Fed event fragment data format (FOV) field content. | |
int | getFreqGHz () const |
Gets the matacq sampling frequency field contents. | |
int | getH1Marker () const |
Gets the header marker field contents. | |
int | getMatacqDataFormatVersion () const |
Gets the matcq data format version. | |
int | getParsedLen () |
Gets the data length in number of 64-bit words computed by the data parser. | |
unsigned | getRunNum () const |
Gets the run number field contents. | |
int32_t | getStatus () const |
Gets the raw data status. | |
time_t | getTimeStamp () const |
Gets the matacq data timestamp field contents:. | |
int | getTriggerType () const |
Gets the trigger type field contents. | |
int | getTTrigPs () const |
Gets the Matacq trigger time. | |
MatacqTBRawEvent (const unsigned char *dataBuffer, size_t bufferSize) | |
Constuctor. | |
Private Member Functions | |
int | read32 (uint32le_t *pData, field32spec_t spec) const |
Help function to decode header content. | |
void | setRawData (const unsigned char *buffer, size_t bufferSize) |
Changes the raw data pointer and updates accordingly this object. | |
Private Attributes | |
int | boe |
Begin Of Event marker. | |
int | bxId |
Bunch crossing Id. | |
int | channelCount |
Number of matacq channels in the data. | |
std::vector< ChannelData > | channelData |
Channel samples. | |
uint32le_t * | daqHeader |
Pointer to the standard CMS DAQ header. | |
int | dccErrors |
DCC error field content. | |
unsigned | dccLen |
Event length specified in 'DCC' header. | |
int32_t | error |
Error code or 0 if no error. | |
unsigned | eventId |
Event id. | |
int | fedId |
FED ID. | |
int | fov |
FED data format version. | |
int | fragLen |
event fragment length as read in the std DAQ trailer. | |
int | freqGHz |
MATACQ sampling frequency in GHz. | |
int | h1Marker |
header marker | |
int | matacqDataFormatVersion |
MATACQ data format internal version. | |
matacqHeader_t * | matacqHeader |
Matacq header:. | |
int | parsedLen |
event lenght computed by the raw data parser | |
uint16le_t * | pSamples |
Pointer to MATACQ samples block. | |
unsigned | runNum |
Run number. | |
time_t | timeStamp |
Matacq acquisition time stamp. | |
int | triggerType |
Trigger type. | |
int | tTrigPs |
MATACQ trigger time position in ps. | |
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} |
DAQ header field specifications. | |
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} |
Classes | |
struct | ChannelData |
struct | field32spec_t |
Specification of DAQ header field. More... | |
struct | int16le_t |
struct | matacqHeader_t |
Matacq header data structure. More... | |
struct | uint16le_t |
struct | uint32le_t |
This class provides the method to interpret the data.
Definition at line 27 of file MatacqRawEvent.h.
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.
00030 { 00034 errorLengthConsistency = 1<<0, 00037 errorLength = 1<<1, 00040 errorWrongBoe = 1<<2 00041 };
MatacqTBRawEvent::MatacqTBRawEvent | ( | const unsigned char * | dataBuffer, | |
size_t | bufferSize | |||
) | [inline] |
Constuctor.
dataBuffer | pointer 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. | |
bufferSize | size of the buffer pointed by dataBuffer and containing the data. The data themselves are allowed to be smaller than the buffer. |
std::exception | if the data cannot be decoded due to data corruption or truncation. |
Definition at line 123 of file MatacqRawEvent.h.
References setRawData().
00123 { 00124 setRawData(dataBuffer, bufferSize); 00125 }
int MatacqTBRawEvent::getBoe | ( | ) | const [inline] |
Gets the beging of event field contents (BOE).
Must be 0x5.
Definition at line 159 of file MatacqRawEvent.h.
References boeType32, daqHeader, and read32().
Referenced by setRawData().
int MatacqTBRawEvent::getBxId | ( | ) | const [inline] |
Gets the bunch crossing id field contents.
Definition at line 144 of file MatacqRawEvent.h.
References bxId32, daqHeader, and read32().
Referenced by MatacqTBDataFormatter::printData().
int MatacqTBRawEvent::getChannelCount | ( | ) | const [inline] |
Gets the matacq channel count field contents.
Definition at line 207 of file MatacqRawEvent.h.
References MatacqTBRawEvent::matacqHeader_t::channelCount, and matacqHeader.
Referenced by MatacqTBDataFormatter::printData(), and setRawData().
00207 { return matacqHeader->channelCount;}
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().
Definition at line 214 of file MatacqRawEvent.h.
References channelData.
Referenced by MatacqTBDataFormatter::printData().
00214 { 00215 return channelData; 00216 }
unsigned MatacqTBRawEvent::getDaqLen | ( | ) | const [inline] |
Gets the event length specifies in the DAQ trailer.
Definition at line 169 of file MatacqRawEvent.h.
References fragLen.
00169 { return fragLen;}
int MatacqTBRawEvent::getDccErrors | ( | ) | const [inline] |
Gets the contents of the DCC error field.
Currently Not used for Matacq.
Definition at line 175 of file MatacqRawEvent.h.
References daqHeader, dccErrors32, and read32().
Referenced by MatacqTBDataFormatter::printData().
00175 { return read32(daqHeader, dccErrors32);}
unsigned MatacqTBRawEvent::getDccLen | ( | ) | const [inline] |
Gets the event length specifies in the "a la DCC" header.
Definition at line 164 of file MatacqRawEvent.h.
References daqHeader, dccLen32, and read32().
Referenced by MatacqTBDataFormatter::printData().
unsigned MatacqTBRawEvent::getEventId | ( | ) | const [inline] |
Gets the LV1 field contents.
Definition at line 149 of file MatacqRawEvent.h.
References daqHeader, lv132, and read32().
Referenced by MatacqTBDataFormatter::printData().
int MatacqTBRawEvent::getFedId | ( | ) | const [inline] |
Gets the FED ID field contents.
Should be 43.
Definition at line 139 of file MatacqRawEvent.h.
References daqHeader, fedId32, and read32().
Referenced by MatacqTBDataFormatter::printData().
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()
Definition at line 134 of file MatacqRawEvent.h.
References daqHeader, fov32, and read32().
Referenced by MatacqTBDataFormatter::printData().
int MatacqTBRawEvent::getFreqGHz | ( | ) | const [inline] |
Gets the matacq sampling frequency field contents.
Definition at line 202 of file MatacqRawEvent.h.
References MatacqTBRawEvent::matacqHeader_t::freqGHz, and matacqHeader.
Referenced by MatacqTBDataFormatter::printData().
00202 { return matacqHeader->freqGHz;}
int MatacqTBRawEvent::getH1Marker | ( | ) | const [inline] |
Gets the header marker field contents.
Must be 1
Definition at line 185 of file MatacqRawEvent.h.
References daqHeader, h1Marker32, and read32().
00185 { return read32(daqHeader, h1Marker32);}
int MatacqTBRawEvent::getMatacqDataFormatVersion | ( | ) | const [inline] |
Gets the matcq data format version.
Definition at line 191 of file MatacqRawEvent.h.
References matacqHeader, and MatacqTBRawEvent::matacqHeader_t::version.
Referenced by MatacqTBDataFormatter::printData(), and setRawData().
00191 { return matacqHeader->version;}
int MatacqTBRawEvent::getParsedLen | ( | ) | [inline] |
Gets the data length in number of 64-bit words computed by the data parser.
Definition at line 222 of file MatacqRawEvent.h.
References parsedLen.
00222 { return parsedLen; }
unsigned MatacqTBRawEvent::getRunNum | ( | ) | const [inline] |
Gets the run number field contents.
Definition at line 180 of file MatacqRawEvent.h.
References daqHeader, read32(), and runNum32.
Referenced by MatacqTBDataFormatter::printData().
int32_t MatacqTBRawEvent::getStatus | ( | void | ) | const [inline] |
Gets the raw data status.
Bitwise OR of the error flags defined by matcqError_t
Definition at line 197 of file MatacqRawEvent.h.
References error.
Referenced by MatacqTBDataFormatter::printData().
00197 { return error;}
time_t MatacqTBRawEvent::getTimeStamp | ( | ) | const [inline] |
Gets the matacq data timestamp field contents:.
Definition at line 229 of file MatacqRawEvent.h.
References matacqHeader, and MatacqTBRawEvent::matacqHeader_t::timeStamp.
Referenced by MatacqTBDataFormatter::printData().
00229 { return matacqHeader->timeStamp;}
int MatacqTBRawEvent::getTriggerType | ( | ) | const [inline] |
Gets the trigger type field contents.
Definition at line 154 of file MatacqRawEvent.h.
References daqHeader, read32(), and triggerType32.
Referenced by MatacqTBDataFormatter::printData().
00154 { return read32(daqHeader, triggerType32);}
int MatacqTBRawEvent::getTTrigPs | ( | ) | const [inline] |
int MatacqTBRawEvent::read32 | ( | uint32le_t * | pData, | |
field32spec_t | spec | |||
) | const [private] |
Help function to decode header content.
data | pointer | |
spec | specification of the data field to read |
Definition at line 104 of file MatacqRawEvent.cc.
References MatacqTBRawEvent::field32spec_t::mask, MatacqTBRawEvent::field32spec_t::offset, and HLT_VtxMuL3::result.
Referenced by getBoe(), getBxId(), getDccErrors(), getDccLen(), getEventId(), getFedId(), getFov(), getH1Marker(), getRunNum(), getTriggerType(), and setRawData().
00104 { 00105 int result = pData[spec32.offset] & spec32.mask; 00106 int mask = spec32.mask; 00107 while((mask&0x1) == 0){ 00108 mask >>= 1; 00109 result >>= 1; 00110 } 00111 return result; 00112 }
void MatacqTBRawEvent::setRawData | ( | const unsigned char * | buffer, | |
size_t | bufferSize | |||
) | [private] |
Changes the raw data pointer and updates accordingly this object.
buffer | new pointer to the data buffer. Must be aligned at least on 32-bit words. | |
size | of the data buffer. |
std::exception | if the data cannot be decoded due to data corruption or truncation. |
Definition at line 35 of file MatacqRawEvent.cc.
References channelData, daqHeader, dccLen32, error, errorLength, errorLengthConsistency, errorWrongBoe, fragLen, getBoe(), getChannelCount(), getMatacqDataFormatVersion(), matacqHeader, max, parsedLen, read32(), and tTrigPs.
Referenced by MatacqTBRawEvent().
00035 { 00036 error = 0; 00037 int16le_t* begin16 = (int16le_t*) pData; 00038 int16le_t* pData16 = begin16; 00039 daqHeader = (uint32le_t*) pData16; 00040 const int daqHeaderLen = 16; //in bytes 00041 pData16 += daqHeaderLen/sizeof(pData16[0]); 00042 matacqHeader = (matacqHeader_t*) pData16; 00043 pData16 += sizeof(matacqHeader_t)/sizeof(pData16[0]); 00044 if(getMatacqDataFormatVersion()>=2){//trigger position present 00045 tTrigPs = *((int32_t*) pData16); 00046 pData16 += 2; 00047 } else{ 00048 tTrigPs = std::numeric_limits<int>::max(); 00049 } 00050 const int nCh = getChannelCount(); 00051 channelData.resize(nCh); 00052 for(int iCh=0; iCh<nCh; ++iCh){ 00053 //channel id: 00054 channelData[iCh].chId = *(pData16++); 00055 //number of time samples for this channel: 00056 channelData[iCh].nSamples = *(pData16++); 00057 //pointer to time sample data of this channel: 00058 channelData[iCh].samples = pData16; 00059 //moves to next channel data block: 00060 pData16 += channelData[iCh].nSamples; 00061 } 00062 00063 //data trailer chekes: 00064 //FED header is aligned on 64-bit=>padding to skip 00065 int padding = (4-(pData16-begin16))%4; 00066 if(padding<0) padding+=4; 00067 pData16 += padding; 00068 uint32le_t* trailer32 = (uint32le_t*)(pData16); 00069 fragLen = trailer32[1]&0xFFFFFF; 00070 00071 //cout << "Event fragment length including headers: " << fragLen 00072 // << " 64-bit words\n"; 00073 00074 //FIXME: I am expecting the event length specifies in the header to 00075 //include the header, while it is not the case in current TB 2006 data 00076 const int nHeaders = 3; 00077 if(fragLen!=read32(daqHeader,dccLen32)+nHeaders 00078 && fragLen != read32(daqHeader,dccLen32)){ 00079 //cout << "Error: fragment length is not consistent with DCC " 00080 // "length\n"; 00081 error |= errorLengthConsistency; 00082 } 00083 00084 //skip trailers 00085 const int trailerLen = 4; 00086 pData16 += trailerLen; 00087 00088 parsedLen = (pData16-begin16) / 4; 00089 00090 if((pData16-begin16)!=(4*fragLen)){ 00091 error |= errorLength; 00092 } 00093 00094 if((size_t)(pData16-begin16)>maxSize){ 00095 throw std::runtime_error(std::string("Corrupted or truncated data")); 00096 } 00097 00098 //some checks 00099 if(getBoe()!=0x5){ 00100 error |= errorWrongBoe; 00101 } 00102 }
int MatacqTBRawEvent::boe [private] |
const MatacqTBRawEvent::field32spec_t MatacqTBRawEvent::boeType32 = {1, 0xF0000000} [static, private] |
int MatacqTBRawEvent::bxId [private] |
const MatacqTBRawEvent::field32spec_t MatacqTBRawEvent::bxId32 = {0, 0xFFF00000} [static, private] |
int MatacqTBRawEvent::channelCount [private] |
std::vector<ChannelData> MatacqTBRawEvent::channelData [private] |
Channel samples.
Definition at line 271 of file MatacqRawEvent.h.
Referenced by getChannelData(), and setRawData().
uint32le_t* MatacqTBRawEvent::daqHeader [private] |
Pointer to the standard CMS DAQ header.
Definition at line 275 of file MatacqRawEvent.h.
Referenced by getBoe(), getBxId(), getDccErrors(), getDccLen(), getEventId(), getFedId(), getFov(), getH1Marker(), getRunNum(), getTriggerType(), and setRawData().
int MatacqTBRawEvent::dccErrors [private] |
const MatacqTBRawEvent::field32spec_t MatacqTBRawEvent::dccErrors32 = {2, 0xFF000000} [static, private] |
unsigned MatacqTBRawEvent::dccLen [private] |
const MatacqTBRawEvent::field32spec_t MatacqTBRawEvent::dccLen32 = {2, 0x00FFFFFF} [static, private] |
int32_t MatacqTBRawEvent::error [private] |
Error code or 0 if no error.
Definition at line 291 of file MatacqRawEvent.h.
Referenced by getStatus(), and setRawData().
unsigned MatacqTBRawEvent::eventId [private] |
int MatacqTBRawEvent::fedId [private] |
const MatacqTBRawEvent::field32spec_t MatacqTBRawEvent::fedId32 = {0, 0x000FFF00} [static, private] |
int MatacqTBRawEvent::fov [private] |
const MatacqTBRawEvent::field32spec_t MatacqTBRawEvent::fov32 = {0, 0x000000F0} [static, private] |
DAQ header field specifications.
Definition at line 100 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 303 of file MatacqRawEvent.h.
Referenced by getDaqLen(), and setRawData().
int MatacqTBRawEvent::freqGHz [private] |
int MatacqTBRawEvent::h1Marker [private] |
const MatacqTBRawEvent::field32spec_t MatacqTBRawEvent::h1Marker32 = {3, 0xF0000000} [static, private] |
const MatacqTBRawEvent::field32spec_t MatacqTBRawEvent::lv132 = {1, 0x00FFFFFF} [static, private] |
int MatacqTBRawEvent::matacqDataFormatVersion [private] |
matacqHeader_t* MatacqTBRawEvent::matacqHeader [private] |
Matacq header:.
Definition at line 315 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 323 of file MatacqRawEvent.h.
Referenced by getParsedLen(), and setRawData().
uint16le_t* MatacqTBRawEvent::pSamples [private] |
unsigned MatacqTBRawEvent::runNum [private] |
const MatacqTBRawEvent::field32spec_t MatacqTBRawEvent::runNum32 = {3, 0x00FFFFFF} [static, private] |
time_t MatacqTBRawEvent::timeStamp [private] |
int MatacqTBRawEvent::triggerType [private] |
const MatacqTBRawEvent::field32spec_t MatacqTBRawEvent::triggerType32 = {1, 0x0F000000} [static, private] |
int MatacqTBRawEvent::tTrigPs [private] |
MATACQ trigger time position in ps.
Definition at line 339 of file MatacqRawEvent.h.
Referenced by getTTrigPs(), and setRawData().