#include <CSCTMBTrailer.h>
Public Member Functions | |
bool | check () const |
unsigned int | crc22 () const |
CSCTMBTrailer (int wordCount, int firmwareVersion) | |
don't forget to pass in the size of the tmb header + clct data | |
CSCTMBTrailer (unsigned short *buf, unsigned short int firmwareVersion) | |
CSCTMBTrailer (const CSCTMBStatusDigi &digi) | |
unsigned short * | data () |
void | setCRC (int crc) |
uint16_t | sizeInBytes () const |
int | sizeInWords () const |
in 16-bit frames | |
int | wordCount () const |
Static Public Member Functions | |
static void | selfTest () |
Private Member Functions | |
int | crcOffset () const |
int | de0fOffset () const |
Private Attributes | |
unsigned short | theData [7] |
unsigned short int | theFirmwareVersion |
int | thePadding |
Defined to begin at the 6E0C word 2006 format 6E0C 2AAA (optional) 5555 (optional) D8+CRC22(10) D8+CRC22(10) DE0F D8+WordCount D2007 format 6E0C 2AAA (optional) 5555 (optional) DE0F D8+CRC22(10) D8+CRC22(10) D8+WordCount
Definition at line 30 of file CSCTMBTrailer.h.
CSCTMBTrailer::CSCTMBTrailer | ( | int | wordCount, |
int | firmwareVersion | ||
) |
don't forget to pass in the size of the tmb header + clct data
Definition at line 6 of file CSCTMBTrailer.cc.
References de0fOffset(), i, theData, thePadding, and wordCount().
: theFirmwareVersion(firmwareVersion) { //FIXME do firmware version theData[0] = 0x6e0c; // all the necessary lines from this thing first wordCount += 5; // see if we need thePadding to make a multiple of 4 thePadding = 0; if(wordCount%4==2) { theData[1] = 0x2AAA; theData[2] = 0x5555; thePadding = 2; wordCount += thePadding; } // the next four words start with 11011, or a D for(int i = 1; i < 5; ++i) { theData[i+thePadding] = 0xD800; } theData[de0fOffset()] = 0xde0f; // word count excludes the trailer theData[4+thePadding] |= wordCount; }
CSCTMBTrailer::CSCTMBTrailer | ( | unsigned short * | buf, |
unsigned short int | firmwareVersion | ||
) |
in 2007 format de0f line moved
Definition at line 34 of file CSCTMBTrailer.cc.
References theData, and thePadding.
: theFirmwareVersion(firmwareVersion) { // take a little too much, maybe memcpy(theData, buf, 14); switch (firmwareVersion){ case 2006: // if there's padding, there'll be a de0f in the 6th word. // If not, you'll be in CFEB-land, where they won't be de0f. thePadding = (theData[5] == 0xde0f ? 2 : 0); break; case 2007: // =VB= check for 1st word to be 0xDE0F, then check 3rd // to handle freaky cases of double 0xDE0F signatures in trailer thePadding = (theData[1] == 0xde0f ? 0 : (theData[3] == 0xde0f ? 2 : 0)); // thePadding = (theData[3] == 0xde0f ? 2 : 0); break; default: edm::LogError("CSCTMBTrailer|CSCRawToDigi") <<"failed to contruct: firmware version is bad/not defined!"; } }
CSCTMBTrailer::CSCTMBTrailer | ( | const CSCTMBStatusDigi & | digi | ) | [inline] |
Definition at line 37 of file CSCTMBTrailer.h.
References sizeInBytes(), and CSCTMBStatusDigi::trailer().
{ memcpy(this, digi.trailer(), sizeInBytes()); }
bool CSCTMBTrailer::check | ( | ) | const [inline] |
unsigned int CSCTMBTrailer::crc22 | ( | ) | const |
Definition at line 58 of file CSCTMBTrailer.cc.
References crcOffset(), and theData.
Referenced by CSCTMBData::getCRC(), and selfTest().
int CSCTMBTrailer::crcOffset | ( | ) | const [inline, private] |
Definition at line 53 of file CSCTMBTrailer.h.
References theFirmwareVersion, and thePadding.
Referenced by crc22(), and setCRC().
{return (theFirmwareVersion == 2006 ? 1 : 2) + thePadding;}
unsigned short* CSCTMBTrailer::data | ( | ) | [inline] |
Definition at line 48 of file CSCTMBTrailer.h.
References theData.
Referenced by CSCTMBData::pack().
{return theData;}
int CSCTMBTrailer::de0fOffset | ( | ) | const [inline, private] |
Definition at line 54 of file CSCTMBTrailer.h.
References theFirmwareVersion, and thePadding.
Referenced by CSCTMBTrailer().
{return (theFirmwareVersion == 2006 ? 3 : 1) + thePadding;}
void CSCTMBTrailer::selfTest | ( | ) | [static] |
Definition at line 76 of file CSCTMBTrailer.cc.
References crc22(), and setCRC().
{ CSCTMBTrailer trailer(104, 2006); unsigned int crc = 0xb00b1; trailer.setCRC(crc); assert(trailer.crc22() == 0xb00b1); CSCTMBTrailer trailer2(104, 2007); crc = 0xb00b1; trailer2.setCRC(crc); assert(trailer2.crc22() == 0xb00b1); }
void CSCTMBTrailer::setCRC | ( | int | crc | ) |
Definition at line 65 of file CSCTMBTrailer.cc.
References crcOffset(), and theData.
Referenced by CSCTMBData::pack(), and selfTest().
uint16_t CSCTMBTrailer::sizeInBytes | ( | ) | const [inline] |
int CSCTMBTrailer::sizeInWords | ( | ) | const [inline] |
in 16-bit frames
Definition at line 47 of file CSCTMBTrailer.h.
References thePadding.
Referenced by CSCTMBData::pack(), and CSCTMBData::UnpackTMB().
{return 5+thePadding;}
int CSCTMBTrailer::wordCount | ( | ) | const |
Definition at line 72 of file CSCTMBTrailer.cc.
References theData, and thePadding.
Referenced by CSCTMBTrailer(), and cscdqm::EventProcessor::processCSC().
{return theData[4+thePadding] & 0x7ff;}
unsigned short CSCTMBTrailer::theData[7] [private] |
Definition at line 56 of file CSCTMBTrailer.h.
Referenced by check(), crc22(), CSCTMBTrailer(), data(), setCRC(), and wordCount().
unsigned short int CSCTMBTrailer::theFirmwareVersion [private] |
Definition at line 58 of file CSCTMBTrailer.h.
Referenced by crcOffset(), and de0fOffset().
int CSCTMBTrailer::thePadding [private] |
Definition at line 57 of file CSCTMBTrailer.h.
Referenced by crcOffset(), CSCTMBTrailer(), de0fOffset(), sizeInWords(), and wordCount().