CSCTMBTrailer

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
#ifndef EventFilter_CSCRawToDigi_CSCTMBTrailer_h
#define EventFilter_CSCRawToDigi_CSCTMBTrailer_h

#include <cstring>  // bzero
#include "DataFormats/CSCDigi/interface/CSCTMBStatusDigi.h"
#include <cstdint>

/** 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
*/

class CSCTMBTrailer {
public:
  /// don't forget to pass in the size of the tmb header + clct data
  CSCTMBTrailer(int wordCount, int firmwareVersion);

  CSCTMBTrailer(const uint16_t* buf, unsigned short int firmwareVersion);

  CSCTMBTrailer(const CSCTMBStatusDigi& digi) { memcpy(this, digi.trailer(), sizeInBytes()); }

  uint16_t sizeInBytes() const { return 16; }
  unsigned int crc22() const;
  void setCRC(int crc);
  bool check() const { return theData[0] == 0x6e0c; }
  /// in 16-bit frames
  int sizeInWords() const { return 5 + thePadding; }
  unsigned short* data() { return theData; }

  int wordCount() const;
  static void selfTest();

private:
  int crcOffset() const { return (theFirmwareVersion == 2006 ? 1 : 2) + thePadding; }
  int de0fOffset() const { return (theFirmwareVersion == 2006 ? 3 : 1) + thePadding; }

  unsigned short theData[7];
  int thePadding;
  unsigned short int theFirmwareVersion;
};

#endif