File indexing completed on 2024-04-06 12:10:29
0001 #ifndef CSCSPHeader_h
0002 #define CSCSPHeader_h
0003
0004 #include <cstring> // memcpy
0005
0006 class CSCSPHeader {
0007 private:
0008
0009 unsigned sp_l1a_low : 12;
0010 unsigned header_mark_1 : 4;
0011
0012 unsigned sp_l1a_high : 12;
0013 unsigned header_mark_2 : 4;
0014
0015 unsigned zero_1 : 12;
0016 unsigned header_mark_3 : 4;
0017
0018 unsigned sp_bxn : 12;
0019 unsigned header_mark_4 : 4;
0020
0021
0022 unsigned zero_2 : 12;
0023 unsigned header_mark_5 : 4;
0024
0025 unsigned sp_slot_number : 5;
0026 unsigned sp_ersv : 3;
0027 unsigned
0028 sp_trigger_sector : 4;
0029
0030 unsigned header_mark_6 : 4;
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 unsigned fmm_status : 6;
0043 unsigned ddm : 1;
0044 unsigned zero_3 : 5;
0045 unsigned header_mark_7 : 4;
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 unsigned csr_dfc : 11;
0063 unsigned skip : 1;
0064 unsigned header_mark_8 : 4;
0065
0066 friend class CSCTFPacker;
0067
0068 public:
0069 bool check(void) const {
0070 return header_mark_1 != 0x9 || header_mark_2 != 0x9 || header_mark_3 != 0x9 || header_mark_4 != 0x9 ||
0071 header_mark_5 != 0xA || header_mark_6 != 0xA || header_mark_7 != 0xA || header_mark_8 != 0xA ||
0072 zero_1 != 0 || zero_2 != 0 || zero_3 != 0;
0073 }
0074
0075 unsigned int BXN(void) const throw() { return sp_bxn; }
0076 unsigned int L1A(void) const throw() { return (sp_l1a_high << 12) | sp_l1a_low; }
0077
0078 unsigned int slot(void) const throw() { return sp_slot_number; }
0079 unsigned int trigger_sector(void) const throw() { return sp_trigger_sector; }
0080
0081 unsigned int sector(void) const throw() {
0082 if (sp_ersv < 2)
0083 return sp_trigger_sector & 0x7;
0084 else
0085 return (sp_trigger_sector <= 6 ? sp_trigger_sector : sp_trigger_sector - 6);
0086 }
0087 unsigned int endcap(void) const throw() {
0088 if (sp_ersv < 2)
0089 return sp_trigger_sector & 0x8;
0090 else
0091 return (sp_trigger_sector <= 6 ? 1 : 0);
0092 }
0093
0094 enum FMM { WOF = 1, OSY = 2, BUZY = 4, READY = 8, FA_OSY = 16, SP_OSY = 32 };
0095 unsigned int status(void) const throw() { return fmm_status; }
0096
0097 unsigned int nTBINs(void) const throw() { return csr_dfc & 0x7; }
0098
0099 bool suppression(void) const throw() { return csr_dfc & 0x8; }
0100
0101 enum ACTIVE { F1 = 1, F2 = 2, F3 = 4, F4 = 8, F5 = 16, DT = 32, SP = 64 };
0102 unsigned int active(void) const throw() { return csr_dfc >> 4; }
0103
0104 bool empty(void) const throw() { return skip; }
0105
0106 int format_version(void) const throw() { return sp_ersv; }
0107 bool ddu_readout(void) const throw() { return ddm; }
0108
0109 bool unpack(const unsigned short *&buf) throw() {
0110 memcpy((void *)this, buf, 8 * sizeof(short));
0111 buf += 8;
0112 return check();
0113 }
0114
0115 CSCSPHeader(void) {}
0116 };
0117
0118 #endif