Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:23

0001 #ifndef EventFilter_CSCRawToDigi_CSCTMBTrailer_h
0002 #define EventFilter_CSCRawToDigi_CSCTMBTrailer_h
0003 
0004 #include <cstring>  // bzero
0005 #include "DataFormats/CSCDigi/interface/CSCTMBStatusDigi.h"
0006 #include <cstdint>
0007 
0008 /** Defined to begin at the 6E0C word 2006 format
0009 6E0C
0010 2AAA (optional)
0011 5555 (optional)
0012 D8+CRC22(10)
0013 D8+CRC22(10)
0014 DE0F
0015 D8+WordCount
0016 */
0017 
0018 /** D2007 format
0019 6E0C
0020 2AAA (optional)
0021 5555 (optional)
0022 DE0F
0023 D8+CRC22(10)
0024 D8+CRC22(10)
0025 D8+WordCount
0026 */
0027 
0028 class CSCTMBTrailer {
0029 public:
0030   /// don't forget to pass in the size of the tmb header + clct data
0031   CSCTMBTrailer(int wordCount, int firmwareVersion);
0032 
0033   CSCTMBTrailer(const uint16_t* buf, unsigned short int firmwareVersion);
0034 
0035   CSCTMBTrailer(const CSCTMBStatusDigi& digi) { memcpy(this, digi.trailer(), sizeInBytes()); }
0036 
0037   uint16_t sizeInBytes() const { return 16; }
0038   unsigned int crc22() const;
0039   void setCRC(int crc);
0040   bool check() const { return theData[0] == 0x6e0c; }
0041   /// in 16-bit frames
0042   int sizeInWords() const { return 5 + thePadding; }
0043   unsigned short* data() { return theData; }
0044 
0045   int wordCount() const;
0046   static void selfTest();
0047 
0048 private:
0049   int crcOffset() const { return (theFirmwareVersion == 2006 ? 1 : 2) + thePadding; }
0050   int de0fOffset() const { return (theFirmwareVersion == 2006 ? 3 : 1) + thePadding; }
0051 
0052   unsigned short theData[7];
0053   int thePadding;
0054   unsigned short int theFirmwareVersion;
0055 };
0056 
0057 #endif