00001 #ifndef CSCTMBTrailer_h 00002 #define CSCTMBTrailer_h 00003 00004 #include <string.h> // bzero 00005 #include "DataFormats/CSCDigi/interface/CSCTMBStatusDigi.h" 00006 00029 class CSCTMBTrailer { 00030 public: 00032 CSCTMBTrailer(int wordCount, int firmwareVersion); 00033 00034 CSCTMBTrailer(unsigned short * buf, unsigned short int firmwareVersion); 00035 00036 CSCTMBTrailer(const CSCTMBStatusDigi & digi) 00037 { 00038 memcpy(this, digi.trailer(), sizeInBytes()); 00039 } 00040 00041 uint16_t sizeInBytes() const {return 16;} 00042 unsigned int crc22() const; 00043 void setCRC(int crc); 00044 bool check() const {return theData[0]==0x6e0c;} 00046 int sizeInWords() const {return 5+thePadding;} 00047 unsigned short * data() {return theData;} 00048 00049 int wordCount() const; 00050 static void selfTest(); 00051 private: 00052 int crcOffset() const {return (theFirmwareVersion == 2006 ? 1 : 2) + thePadding;} 00053 int de0fOffset() const {return (theFirmwareVersion == 2006 ? 3 : 1) + thePadding;} 00054 00055 unsigned short theData[7]; 00056 int thePadding; 00057 unsigned short int theFirmwareVersion; 00058 }; 00059 00060 #endif 00061