Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:14:36

0001 #ifndef EventFilter_CSCRawToDigi_CSCDMBTrailer2005_h
0002 #define EventFilter_CSCRawToDigi_CSCDMBTrailer2005_h
0003 
0004 #include "DataFormats/CSCDigi/interface/CSCDMBStatusDigi.h"
0005 #include "EventFilter/CSCRawToDigi/interface/CSCDMBHeader.h"
0006 #include "EventFilter/CSCRawToDigi/interface/CSCVDMBTrailerFormat.h"
0007 
0008 struct CSCDMBTrailer2005 : public CSCVDMBTrailerFormat {
0009   // public:
0010   CSCDMBTrailer2005() {
0011     bzero(data(), sizeInWords() * 2);
0012     bits.ddu_code_1 = bits.ddu_code_2 = bits.ddu_code_3 = bits.ddu_code_4 = 0xF;
0013     bits.ddu_code_5 = bits.ddu_code_6 = bits.ddu_code_7 = bits.ddu_code_8 = 0xE;
0014   }
0015 
0016   CSCDMBTrailer2005(const uint16_t *buf) { memcpy(data(), buf, sizeInWords() * 2); };
0017   /*
0018   CSCDMBTrailer2005(const CSCDMBStatusDigi & digi) 
0019     {
0020       memcpy(this, digi.trailer(), sizeInWords()*2);
0021     }
0022 */
0023   ///@@ NEEDS TO BE DONE
0024   void setEventInformation(const CSCDMBHeader &dmbHeader) override {
0025     bits.dmb_id = dmbHeader.dmbID();
0026     bits.crate_id = dmbHeader.crateID();
0027     bits.dmb_l1a = dmbHeader.l1a();
0028     bits.dmb_bxn = dmbHeader.bxn();
0029   };
0030 
0031   unsigned crateID() const override { return bits.crate_id; };
0032   unsigned dmbID() const override { return bits.dmb_id; };
0033 
0034   unsigned dmb_l1a() const override { return bits.dmb_l1a; };
0035   unsigned dmb_bxn() const override { return bits.dmb_bxn; };
0036 
0037   unsigned alct_endtimeout() const override { return bits.alct_endtimeout; };
0038   unsigned tmb_endtimeout() const override { return bits.tmb_endtimeout; };
0039   unsigned cfeb_endtimeout() const override { return bits.cfeb_endtimeout; };
0040 
0041   unsigned alct_starttimeout() const override { return bits.alct_starttimeout; };
0042   unsigned tmb_starttimeout() const override { return bits.tmb_starttimeout; };
0043   unsigned cfeb_starttimeout() const override { return bits.cfeb_starttimeout; };
0044 
0045   unsigned cfeb_movlp() const override { return bits.cfeb_movlp; };
0046   unsigned dmb_l1pipe() const override { return bits.dmb_l1pipe; };
0047 
0048   unsigned alct_empty() const override { return bits.alct_empty; };
0049   unsigned tmb_empty() const override { return bits.tmb_empty; };
0050   unsigned cfeb_empty() const override { return bits.cfeb_empty; };
0051 
0052   unsigned alct_half() const override { return bits.alct_half; };
0053   unsigned tmb_half() const override { return bits.tmb_half; };
0054   unsigned cfeb_half() const override { return bits.cfeb_half; };
0055 
0056   unsigned alct_full() const override { return bits.alct_full; };
0057   unsigned tmb_full() const override { return bits.tmb_full; };
0058   unsigned cfeb_full() const override { return bits.cfeb_full; };
0059 
0060   unsigned crc22() const override { return (bits.dmb_crc_1 | (bits.dmb_crc_2 << 11)); };
0061   unsigned crc_lo_parity() const override { return bits.dmb_parity_1; };
0062   unsigned crc_hi_parity() const override { return bits.dmb_parity_2; };
0063 
0064   unsigned short *data() override { return (unsigned short *)(&bits); }
0065   unsigned short *data() const override { return (unsigned short *)(&bits); }
0066 
0067   bool check() const override {
0068     return bits.ddu_code_1 == 0xF && bits.ddu_code_2 == 0xF && bits.ddu_code_3 == 0xF && bits.ddu_code_4 == 0xF &&
0069            bits.ddu_code_5 == 0xE && bits.ddu_code_6 == 0xE && bits.ddu_code_7 == 0xE && bits.ddu_code_8 == 0xE;
0070   }
0071 
0072   unsigned sizeInWords() const override { return 8; }
0073 
0074   struct {
0075     unsigned dmb_l1a : 8;
0076     unsigned dmb_bxn : 4;
0077     unsigned ddu_code_1 : 4;
0078 
0079     unsigned cfeb_half : 5;
0080     unsigned tmb_half : 1;
0081     unsigned alct_half : 1;
0082     unsigned cfeb_movlp : 5;
0083     unsigned ddu_code_2 : 4;
0084 
0085     unsigned tmb_starttimeout : 1;
0086     unsigned alct_starttimeout : 1;
0087     unsigned tmb_empty : 1;
0088     unsigned alct_empty : 1;
0089     unsigned dmb_l1pipe : 8;
0090     unsigned ddu_code_3 : 4;
0091 
0092     unsigned cfeb_starttimeout : 5;
0093     unsigned tmb_endtimeout : 1;
0094     unsigned alct_endtimeout : 1;
0095     unsigned cfeb_endtimeout : 5;
0096     unsigned ddu_code_4 : 4;
0097 
0098     unsigned cfeb_empty : 5;
0099     unsigned cfeb_full : 5;
0100     unsigned tmb_full : 1;
0101     unsigned alct_full : 1;
0102     unsigned ddu_code_5 : 4;
0103 
0104     unsigned dmb_id : 4;
0105     unsigned crate_id : 8;
0106     unsigned ddu_code_6 : 4;
0107 
0108     unsigned dmb_crc_1 : 11;
0109     unsigned dmb_parity_1 : 1;
0110     unsigned ddu_code_7 : 4;
0111 
0112     unsigned dmb_crc_2 : 11;
0113     unsigned dmb_parity_2 : 1;
0114     unsigned ddu_code_8 : 4;
0115   } bits;
0116 };
0117 
0118 #endif