#include <EventFilter/CSCRawToDigi/interface/CSCTMBTrailer.h>
Public Member Functions | |
bool | check () const |
unsigned int | crc22 () const |
CSCTMBTrailer (const CSCTMBStatusDigi &digi) | |
CSCTMBTrailer (unsigned short *buf, unsigned short int firmwareVersion) | |
CSCTMBTrailer (int wordCount, int firmwareVersion) | |
don't forget to pass in the size of the tmb header + clct data | |
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 |
D2007 format 6E0C 2AAA (optional) 5555 (optional) DE0F D8+CRC22(10) D8+CRC22(10) D8+WordCount
Definition at line 29 of file CSCTMBTrailer.h.
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, and thePadding.
00007 : theFirmwareVersion(firmwareVersion) 00008 { 00009 //FIXME do firmware version 00010 theData[0] = 0x6e0c; 00011 // all the necessary lines from this thing first 00012 wordCount += 5; 00013 // see if we need thePadding to make a multiple of 4 00014 thePadding = 0; 00015 00016 if(wordCount%4==2) 00017 { 00018 theData[1] = 0x2AAA; 00019 theData[2] = 0x5555; 00020 thePadding = 2; 00021 wordCount += thePadding; 00022 } 00023 // the next four words start with 11011, or a D 00024 for(int i = 1; i < 5; ++i) 00025 { 00026 theData[i+thePadding] = 0xD800; 00027 } 00028 theData[de0fOffset()] = 0xde0f; 00029 // word count excludes the trailer 00030 theData[4+thePadding] |= wordCount; 00031 }
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.
00035 : theFirmwareVersion(firmwareVersion) 00036 { 00037 // take a little too much, maybe 00038 memcpy(theData, buf, 14); 00039 switch (firmwareVersion){ 00040 case 2006: 00041 // if there's padding, there'll be a de0f in the 6th word. 00042 // If not, you'll be in CFEB-land, where they won't be de0f. 00043 thePadding = (theData[5] == 0xde0f ? 2 : 0); 00044 break; 00045 case 2007: 00047 // =VB= check for 1st word to be 0xDE0F, then check 3rd 00048 // to handle freaky cases of double 0xDE0F signatures in trailer 00049 thePadding = (theData[1] == 0xde0f ? 0 : (theData[3] == 0xde0f ? 2 : 0)); 00050 // thePadding = (theData[3] == 0xde0f ? 2 : 0); 00051 break; 00052 default: 00053 edm::LogError("CSCTMBTrailer|CSCRawToDigi") 00054 <<"failed to contruct: firmware version is bad/not defined!"; 00055 } 00056 }
CSCTMBTrailer::CSCTMBTrailer | ( | const CSCTMBStatusDigi & | digi | ) | [inline] |
Definition at line 36 of file CSCTMBTrailer.h.
References sizeInBytes(), and CSCTMBStatusDigi::trailer().
00037 { 00038 memcpy(this, digi.trailer(), sizeInBytes()); 00039 }
bool CSCTMBTrailer::check | ( | ) | const [inline] |
Definition at line 44 of file CSCTMBTrailer.h.
References theData.
00044 {return theData[0]==0x6e0c;}
unsigned int CSCTMBTrailer::crc22 | ( | ) | const |
Definition at line 58 of file CSCTMBTrailer.cc.
References crcOffset(), and theData.
Referenced by CSCTMBData::getCRC(), and selfTest().
00059 { 00060 return (theData[crcOffset()] & 0x07ff) + 00061 ((theData[crcOffset()+1] & 0x07ff) << 11); 00062 }
int CSCTMBTrailer::crcOffset | ( | ) | const [inline, private] |
Definition at line 52 of file CSCTMBTrailer.h.
References theFirmwareVersion, and thePadding.
Referenced by crc22(), and setCRC().
00052 {return (theFirmwareVersion == 2006 ? 1 : 2) + thePadding;}
unsigned short* CSCTMBTrailer::data | ( | ) | [inline] |
Definition at line 47 of file CSCTMBTrailer.h.
References theData.
Referenced by CSCTMBData::pack().
00047 {return theData;}
int CSCTMBTrailer::de0fOffset | ( | ) | const [inline, private] |
Definition at line 53 of file CSCTMBTrailer.h.
References theFirmwareVersion, and thePadding.
Referenced by CSCTMBTrailer().
00053 {return (theFirmwareVersion == 2006 ? 3 : 1) + thePadding;}
void CSCTMBTrailer::selfTest | ( | ) | [static] |
Definition at line 76 of file CSCTMBTrailer.cc.
References crc22(), and setCRC().
00077 { 00078 CSCTMBTrailer trailer(104, 2006); 00079 unsigned int crc = 0xb00b1; 00080 trailer.setCRC(crc); 00081 assert(trailer.crc22() == 0xb00b1); 00082 00083 CSCTMBTrailer trailer2(104, 2007); 00084 crc = 0xb00b1; 00085 trailer2.setCRC(crc); 00086 assert(trailer2.crc22() == 0xb00b1); 00087 00088 }
Definition at line 65 of file CSCTMBTrailer.cc.
References crcOffset(), and theData.
Referenced by CSCTMBData::pack(), and selfTest().
00066 { 00067 theData[crcOffset()] |= (crc & 0x07ff); 00068 theData[crcOffset()+1] |= ((crc>>11) & 0x07ff); 00069 }
uint16_t CSCTMBTrailer::sizeInBytes | ( | ) | const [inline] |
int CSCTMBTrailer::sizeInWords | ( | ) | const [inline] |
in 16-bit frames
Definition at line 46 of file CSCTMBTrailer.h.
References thePadding.
Referenced by CSCTMBData::pack(), and CSCTMBData::UnpackTMB().
00046 {return 5+thePadding;}
int CSCTMBTrailer::wordCount | ( | ) | const |
Definition at line 72 of file CSCTMBTrailer.cc.
References theData, and thePadding.
Referenced by cscdqm::EventProcessor::processCSC().
00072 {return theData[4+thePadding] & 0x7ff;}
unsigned short CSCTMBTrailer::theData[7] [private] |
Definition at line 55 of file CSCTMBTrailer.h.
Referenced by check(), crc22(), CSCTMBTrailer(), data(), setCRC(), and wordCount().
unsigned short int CSCTMBTrailer::theFirmwareVersion [private] |
int CSCTMBTrailer::thePadding [private] |
Definition at line 56 of file CSCTMBTrailer.h.
Referenced by crcOffset(), CSCTMBTrailer(), de0fOffset(), sizeInWords(), and wordCount().