Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef CSCSPTrailer_h
0002 #define CSCSPTrailer_h
0003 
0004 #include <cstring>
0005 
0006 class CSCSPTrailer {
0007 private:
0008   /////// word 1 ///////
0009   unsigned l1a_ : 8;
0010   unsigned word_count_low : 4;
0011   unsigned trailer_mark_1 : 4;  // constant, should be 1111 = 0xF
0012   /////// word 2 ///////
0013   unsigned trailer_mark_2 : 4;  // constant, should be 1111 = 0xF
0014   unsigned trailer_mark_3 : 3;  // constant, should be  111 = 0x7
0015   unsigned l1a_fifo_full_ : 1;
0016   unsigned word_count_high : 4;
0017   unsigned trailer_mark_4 : 4;  // constant, should be 1111 = 0xF
0018   /////// word 3 ///////
0019   unsigned month_ : 4;
0020   unsigned year_ : 4;
0021   unsigned bb_ : 1;  // SP readout configuration year base (0 / 16)
0022   unsigned spare_1 : 1;
0023   unsigned spare_2 : 1;
0024   unsigned zero_1 : 1;
0025   unsigned trailer_mark_5 : 4;  // constant, should be 1111 = 0xF
0026   /////// word 4 ///////
0027   unsigned core_configuraton : 12;
0028   unsigned trailer_mark_6 : 4;  // constant, should be 1111 = 0xF
0029   /////// word 5 ///////
0030   unsigned day_ : 5;
0031   unsigned zero_2 : 7;
0032   unsigned trailer_mark_7 : 4;  // constant, should be 1110 = 0xE
0033   /////// word 6 ///////
0034   unsigned board_id_ : 12;
0035   unsigned trailer_mark_8 : 4;  // constant, should be 1110 = 0xE
0036   /////// word 7 ///////
0037   unsigned crc_low : 11;
0038   unsigned crc_low_parity : 1;
0039   unsigned trailer_mark_9 : 4;  // constant, should be 1110 = 0xE
0040   /////// word 8 ///////
0041   unsigned crc_high : 11;
0042   unsigned crc_high_parity : 1;
0043   unsigned trailer_mark_10 : 4;  // constant, should be 1110 = 0xE
0044 
0045   friend class CSCTFPacker;
0046 
0047 public:
0048   bool check(void) const throw() {
0049     return spare_1 != 0 || spare_2 != 0 || zero_1 != 0 || zero_2 != 0 || trailer_mark_1 != 0xF ||
0050            trailer_mark_2 != 0xF || trailer_mark_3 != 0x7 || trailer_mark_4 != 0xF || trailer_mark_5 != 0xF ||
0051            trailer_mark_6 != 0xF || trailer_mark_7 != 0xE || trailer_mark_8 != 0xE || trailer_mark_9 != 0xE ||
0052            trailer_mark_10 != 0xE;
0053   }
0054 
0055   unsigned int l1a_7bits(void) const throw() { return l1a_; }
0056   unsigned int l1a_queue_size(void) const throw() { return (word_count_high << 4) | word_count_low; }
0057   bool l1a_fifo_full(void) const throw() { return l1a_fifo_full_; }
0058 
0059   unsigned int year(void) const throw() { return 2000 + 16 * bb_ + year_; }
0060   unsigned int month(void) const throw() { return month_; }
0061   unsigned int day(void) const throw() { return day_; }
0062   unsigned int configuration(void) const throw() { return core_configuraton; }
0063 
0064   //unsigned int slot    (void) const throw() { return  board_id_&0x1F;       }
0065   //unsigned int sector  (void) const throw() { return (board_id_&0x700)>>8;  }
0066   //unsigned int endcap  (void) const throw() { return (board_id_&0x800)>>11; }
0067 
0068   unsigned int board_id(void) const throw() { return board_id_; }
0069 
0070   unsigned int crc(void) const throw() { return crc_low | (crc_high << 11); }
0071 
0072   bool unpack(const unsigned short *&buf) throw() {
0073     std::memcpy(this, buf, 8 * sizeof(short));
0074     buf += 8;
0075     return check();
0076   }
0077 
0078   CSCSPTrailer(void) {}
0079 };
0080 
0081 #endif