CSCDMBTrailer2005

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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
#ifndef EventFilter_CSCRawToDigi_CSCDMBTrailer2005_h
#define EventFilter_CSCRawToDigi_CSCDMBTrailer2005_h

#include "DataFormats/CSCDigi/interface/CSCDMBStatusDigi.h"
#include "EventFilter/CSCRawToDigi/interface/CSCDMBHeader.h"
#include "EventFilter/CSCRawToDigi/interface/CSCVDMBTrailerFormat.h"

struct CSCDMBTrailer2005 : public CSCVDMBTrailerFormat {
  // public:
  CSCDMBTrailer2005() {
    bzero(data(), sizeInWords() * 2);
    bits.ddu_code_1 = bits.ddu_code_2 = bits.ddu_code_3 = bits.ddu_code_4 = 0xF;
    bits.ddu_code_5 = bits.ddu_code_6 = bits.ddu_code_7 = bits.ddu_code_8 = 0xE;
  }

  CSCDMBTrailer2005(const uint16_t *buf) { memcpy(data(), buf, sizeInWords() * 2); };
  /*
  CSCDMBTrailer2005(const CSCDMBStatusDigi & digi) 
    {
      memcpy(this, digi.trailer(), sizeInWords()*2);
    }
*/
  ///@@ NEEDS TO BE DONE
  void setEventInformation(const CSCDMBHeader &dmbHeader) override {
    bits.dmb_id = dmbHeader.dmbID();
    bits.crate_id = dmbHeader.crateID();
    bits.dmb_l1a = dmbHeader.l1a();
    bits.dmb_bxn = dmbHeader.bxn();
  };

  unsigned crateID() const override { return bits.crate_id; };
  unsigned dmbID() const override { return bits.dmb_id; };

  unsigned dmb_l1a() const override { return bits.dmb_l1a; };
  unsigned dmb_bxn() const override { return bits.dmb_bxn; };

  unsigned alct_endtimeout() const override { return bits.alct_endtimeout; };
  unsigned tmb_endtimeout() const override { return bits.tmb_endtimeout; };
  unsigned cfeb_endtimeout() const override { return bits.cfeb_endtimeout; };

  unsigned alct_starttimeout() const override { return bits.alct_starttimeout; };
  unsigned tmb_starttimeout() const override { return bits.tmb_starttimeout; };
  unsigned cfeb_starttimeout() const override { return bits.cfeb_starttimeout; };

  unsigned cfeb_movlp() const override { return bits.cfeb_movlp; };
  unsigned dmb_l1pipe() const override { return bits.dmb_l1pipe; };

  unsigned alct_empty() const override { return bits.alct_empty; };
  unsigned tmb_empty() const override { return bits.tmb_empty; };
  unsigned cfeb_empty() const override { return bits.cfeb_empty; };

  unsigned alct_half() const override { return bits.alct_half; };
  unsigned tmb_half() const override { return bits.tmb_half; };
  unsigned cfeb_half() const override { return bits.cfeb_half; };

  unsigned alct_full() const override { return bits.alct_full; };
  unsigned tmb_full() const override { return bits.tmb_full; };
  unsigned cfeb_full() const override { return bits.cfeb_full; };

  unsigned crc22() const override { return (bits.dmb_crc_1 | (bits.dmb_crc_2 << 11)); };
  unsigned crc_lo_parity() const override { return bits.dmb_parity_1; };
  unsigned crc_hi_parity() const override { return bits.dmb_parity_2; };

  unsigned short *data() override { return (unsigned short *)(&bits); }
  unsigned short *data() const override { return (unsigned short *)(&bits); }

  bool check() const override {
    return bits.ddu_code_1 == 0xF && bits.ddu_code_2 == 0xF && bits.ddu_code_3 == 0xF && bits.ddu_code_4 == 0xF &&
           bits.ddu_code_5 == 0xE && bits.ddu_code_6 == 0xE && bits.ddu_code_7 == 0xE && bits.ddu_code_8 == 0xE;
  }

  unsigned sizeInWords() const override { return 8; }

  struct {
    unsigned dmb_l1a : 8;
    unsigned dmb_bxn : 4;
    unsigned ddu_code_1 : 4;

    unsigned cfeb_half : 5;
    unsigned tmb_half : 1;
    unsigned alct_half : 1;
    unsigned cfeb_movlp : 5;
    unsigned ddu_code_2 : 4;

    unsigned tmb_starttimeout : 1;
    unsigned alct_starttimeout : 1;
    unsigned tmb_empty : 1;
    unsigned alct_empty : 1;
    unsigned dmb_l1pipe : 8;
    unsigned ddu_code_3 : 4;

    unsigned cfeb_starttimeout : 5;
    unsigned tmb_endtimeout : 1;
    unsigned alct_endtimeout : 1;
    unsigned cfeb_endtimeout : 5;
    unsigned ddu_code_4 : 4;

    unsigned cfeb_empty : 5;
    unsigned cfeb_full : 5;
    unsigned tmb_full : 1;
    unsigned alct_full : 1;
    unsigned ddu_code_5 : 4;

    unsigned dmb_id : 4;
    unsigned crate_id : 8;
    unsigned ddu_code_6 : 4;

    unsigned dmb_crc_1 : 11;
    unsigned dmb_parity_1 : 1;
    unsigned ddu_code_7 : 4;

    unsigned dmb_crc_2 : 11;
    unsigned dmb_parity_2 : 1;
    unsigned ddu_code_8 : 4;
  } bits;
};

#endif