File indexing completed on 2024-04-06 12:10:29
0001 #ifndef CSCSP_SPblock_h
0002 #define CSCSP_SPblock_h
0003 #include <vector>
0004 #include <cstring>
0005 #include "EventFilter/CSCTFRawToDigi/src/CSCSP_MEblock.h"
0006 #include "EventFilter/CSCTFRawToDigi/src/CSCSP_MBblock.h"
0007
0008 class CSCSP_SPblock {
0009 private:
0010
0011 unsigned phi_ : 5;
0012 unsigned sign_ : 1;
0013 unsigned front_rear : 1;
0014 unsigned charge_ : 1;
0015 unsigned eta_ : 5;
0016 unsigned halo_ : 1;
0017
0018 unsigned se : 1;
0019 unsigned zero_1 : 1;
0020
0021 unsigned deltaPhi12_ : 8;
0022 unsigned deltaPhi23_ : 4;
0023 unsigned zero_2 : 1;
0024 unsigned bxn0_ : 1;
0025 unsigned bc0_ : 1;
0026 unsigned zero_3 : 1;
0027
0028 unsigned me1_id : 3;
0029 unsigned me2_id : 2;
0030 unsigned me3_id : 2;
0031 unsigned me4_id : 2;
0032 unsigned mb_id : 3;
0033 unsigned ms_id : 3;
0034 unsigned zero_4 : 1;
0035
0036 unsigned me1_tbin : 3;
0037 unsigned me2_tbin : 3;
0038 unsigned me3_tbin : 3;
0039 unsigned me4_tbin : 3;
0040 unsigned mb_tbin : 3;
0041 unsigned zero_5 : 1;
0042
0043
0044
0045 friend class CSCSPEvent;
0046 CSCSP_MEblock lct_[4];
0047 CSCSP_MBblock dt_;
0048
0049 bool lctFilled[4], dtFilled;
0050
0051
0052
0053 friend class CSCSPRecord;
0054 friend class CSCTFPacker;
0055 unsigned int tbin_;
0056 unsigned int mode_;
0057 unsigned int id_;
0058
0059 public:
0060 bool check(void) const throw() { return zero_1 != 0 || zero_2 != 0 || zero_3 != 0 || zero_4 != 0 || zero_5 != 0; }
0061
0062 unsigned int phi(void) const throw() { return phi_; }
0063 unsigned int sign(void) const throw() { return sign_; }
0064 unsigned int f_r(void) const throw() { return front_rear; };
0065 unsigned int charge(void) const throw() { return charge_; }
0066 unsigned int eta(void) const throw() { return eta_; }
0067 unsigned int halo(void) const throw() { return halo_; }
0068 unsigned int syncErr(void) const throw() { return se; }
0069
0070 unsigned int deltaPhi12(void) const throw() { return deltaPhi12_; }
0071 unsigned int deltaPhi23(void) const throw() { return deltaPhi23_; }
0072 unsigned int bx0(void) const throw() { return bxn0_; }
0073 unsigned int bc0(void) const throw() { return bc0_; }
0074
0075 unsigned int ME1_id(void) const throw() { return me1_id; }
0076 unsigned int ME2_id(void) const throw() { return me2_id; }
0077 unsigned int ME3_id(void) const throw() { return me3_id; }
0078 unsigned int ME4_id(void) const throw() { return me4_id; }
0079 unsigned int MB_id(void) const throw() { return mb_id; }
0080 unsigned int MS_id(void) const throw() { return ms_id; }
0081
0082 unsigned int ME1_tbin(void) const throw() { return me1_tbin; }
0083 unsigned int ME2_tbin(void) const throw() { return me2_tbin; }
0084 unsigned int ME3_tbin(void) const throw() { return me3_tbin; }
0085 unsigned int ME4_tbin(void) const throw() { return me4_tbin; }
0086 unsigned int MB_tbin(void) const throw() { return mb_tbin; }
0087
0088 unsigned int tbin(void) const throw() { return tbin_; }
0089 unsigned int id(void) const throw() { return id_; }
0090
0091
0092 std::vector<CSCSP_MEblock> LCTs(void) const throw() {
0093 std::vector<CSCSP_MEblock> result;
0094 for (int station = 0; station < 4; station++)
0095 if (lctFilled[station])
0096 result.push_back(lct_[station]);
0097 return result;
0098 }
0099
0100
0101 std::vector<CSCSP_MBblock> dtStub(void) const throw() {
0102 std::vector<CSCSP_MBblock> result;
0103 if (dtFilled)
0104 result.push_back(dt_);
0105 return result;
0106 }
0107
0108 unsigned int ptLUTaddress(void) const throw() {
0109 return (sign_ << 20) | (mode_ << 16) | ((eta_ & 0x1E) << 11) | (deltaPhi23_ << 8) | deltaPhi12_;
0110 }
0111 unsigned int mode(void) const throw() { return mode_; }
0112
0113 bool unpack(const unsigned short *&buf) throw() {
0114 std::memcpy((void *)this, buf, 4 * sizeof(short));
0115 buf += 4;
0116 return check();
0117 }
0118
0119 CSCSP_SPblock(void) {}
0120 };
0121
0122 #endif