File indexing completed on 2024-04-06 12:10:29
0001 #ifndef CSCSPTrailer_h
0002 #define CSCSPTrailer_h
0003
0004 #include <cstring>
0005
0006 class CSCSPTrailer {
0007 private:
0008
0009 unsigned l1a_ : 8;
0010 unsigned word_count_low : 4;
0011 unsigned trailer_mark_1 : 4;
0012
0013 unsigned trailer_mark_2 : 4;
0014 unsigned trailer_mark_3 : 3;
0015 unsigned l1a_fifo_full_ : 1;
0016 unsigned word_count_high : 4;
0017 unsigned trailer_mark_4 : 4;
0018
0019 unsigned month_ : 4;
0020 unsigned year_ : 4;
0021 unsigned bb_ : 1;
0022 unsigned spare_1 : 1;
0023 unsigned spare_2 : 1;
0024 unsigned zero_1 : 1;
0025 unsigned trailer_mark_5 : 4;
0026
0027 unsigned core_configuraton : 12;
0028 unsigned trailer_mark_6 : 4;
0029
0030 unsigned day_ : 5;
0031 unsigned zero_2 : 7;
0032 unsigned trailer_mark_7 : 4;
0033
0034 unsigned board_id_ : 12;
0035 unsigned trailer_mark_8 : 4;
0036
0037 unsigned crc_low : 11;
0038 unsigned crc_low_parity : 1;
0039 unsigned trailer_mark_9 : 4;
0040
0041 unsigned crc_high : 11;
0042 unsigned crc_high_parity : 1;
0043 unsigned trailer_mark_10 : 4;
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
0065
0066
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