File indexing completed on 2024-04-06 12:04:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef DataFormatsL1GlobalMuonTrigger_L1MuGMTCand_h
0020 #define DataFormatsL1GlobalMuonTrigger_L1MuGMTCand_h
0021
0022
0023
0024
0025 #include <string>
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 class L1MuGMTCand {
0040 public:
0041
0042 L1MuGMTCand();
0043
0044
0045 L1MuGMTCand(unsigned data, int bx = 0);
0046
0047
0048 L1MuGMTCand(const L1MuGMTCand&);
0049
0050
0051 L1MuGMTCand& operator=(const L1MuGMTCand&) = default;
0052
0053
0054 virtual ~L1MuGMTCand();
0055
0056
0057 void reset();
0058
0059
0060
0061
0062
0063
0064 bool empty() const { return readDataField(PT_START, PT_LENGTH) == 0; }
0065
0066
0067 unsigned getDataWord() const { return m_dataWord; }
0068
0069
0070 std::string name() const { return m_name; }
0071
0072
0073 unsigned int phiIndex() const { return readDataField(PHI_START, PHI_LENGTH); }
0074
0075
0076 unsigned int ptIndex() const { return readDataField(PT_START, PT_LENGTH); }
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093 unsigned int quality() const { return readDataField(QUAL_START, QUAL_LENGTH); }
0094
0095
0096 bool useInSingleMuonTrigger() const { return quality() >= 4; };
0097
0098
0099 bool useInDiMuonTrigger() const { return (quality() >= 3) && (quality() != 4); };
0100
0101
0102 bool isMatchedCand() const { return quality() == 7; }
0103
0104
0105 bool isHaloCand() const { return quality() == 1; }
0106
0107
0108 unsigned int etaIndex() const { return readDataField(ETA_START, ETA_LENGTH); }
0109
0110
0111 unsigned sysign() const { return readDataField(SYSIGN_START, SYSIGN_LENGTH); }
0112
0113
0114 bool isol() const { return readDataField(ISO_START, ISO_LENGTH) == 1; }
0115
0116
0117 bool mip() const { return readDataField(MIP_START, MIP_LENGTH) == 1; }
0118
0119
0120 int bx() const { return m_bx; }
0121
0122
0123
0124 float phiValue() const;
0125
0126
0127
0128 float etaValue() const;
0129
0130
0131
0132 float ptValue() const;
0133
0134
0135 int charge() const { return (readDataField(SYSIGN_START, SYSIGN_LENGTH) & 1) == 0 ? 1 : -1; }
0136
0137
0138 bool charge_valid() const {
0139 unsigned sysign = readDataField(SYSIGN_START, SYSIGN_LENGTH);
0140 return (sysign == 0 || sysign == 1);
0141 }
0142
0143
0144 bool isSyncWord() const { return readDataField(SYSIGN_START, SYSIGN_LENGTH) == 3; }
0145
0146
0147
0148
0149
0150
0151 void setPhiPacked(unsigned phi) { writeDataField(PHI_START, PHI_LENGTH, phi); }
0152
0153
0154 void setPtPacked(unsigned pt) { writeDataField(PT_START, PT_LENGTH, pt); }
0155
0156
0157 void setQuality(unsigned quality) { writeDataField(QUAL_START, QUAL_LENGTH, quality); }
0158
0159
0160 void setEtaPacked(unsigned eta) { writeDataField(ETA_START, ETA_LENGTH, eta); }
0161
0162
0163 void setIsolation(bool isol) { writeDataField(ISO_START, ISO_LENGTH, isol ? 1 : 0); }
0164
0165
0166 void setMIP(bool mip) { writeDataField(MIP_START, MIP_LENGTH, mip ? 1 : 0); }
0167
0168
0169 void setChargePacked(unsigned ch) { writeDataField(SYSIGN_START, SYSIGN_LENGTH, ch); }
0170
0171
0172 void setBx(int bx) { m_bx = bx; }
0173
0174
0175
0176
0177 void setPhiValue(float phiVal) { m_phiValue = phiVal; }
0178
0179
0180 void setPtValue(float ptVal) { m_ptValue = ptVal; }
0181
0182
0183 void setEtaValue(float etaVal) { m_etaValue = etaVal; }
0184
0185
0186
0187
0188
0189 unsigned int linearizedPt(float lsbValue, unsigned maxScale) const { return 0; }
0190
0191 unsigned int etaRegionIndex() const { return etaIndex(); }
0192
0193 unsigned int phiRegionIndex() const { return phiIndex(); }
0194
0195
0196 bool operator==(const L1MuGMTCand&) const;
0197
0198
0199 bool operator!=(const L1MuGMTCand&) const;
0200
0201
0202 void print() const;
0203
0204
0205 friend std::ostream& operator<<(std::ostream&, const L1MuGMTCand&);
0206
0207 protected:
0208 protected:
0209 inline unsigned readDataField(unsigned start, unsigned count) const;
0210 inline void writeDataField(unsigned start, unsigned count, unsigned value);
0211
0212 std::string m_name;
0213 int m_bx;
0214 unsigned m_dataWord;
0215
0216 float m_phiValue;
0217 float m_etaValue;
0218 float m_ptValue;
0219 static const float m_invalidValue;
0220
0221
0222 enum { PHI_START = 0 };
0223 enum { PHI_LENGTH = 8 };
0224 enum { PT_START = 8 };
0225 enum { PT_LENGTH = 5 };
0226 enum { QUAL_START = 13 };
0227 enum { QUAL_LENGTH = 3 };
0228 enum { ETA_START = 16 };
0229 enum { ETA_LENGTH = 6 };
0230 enum { ISO_START = 22 };
0231 enum { ISO_LENGTH = 1 };
0232 enum { MIP_START = 23 };
0233 enum { MIP_LENGTH = 1 };
0234 enum { SYSIGN_START = 24 };
0235 enum { SYSIGN_LENGTH = 2 };
0236 };
0237
0238 unsigned L1MuGMTCand::readDataField(unsigned start, unsigned count) const {
0239 unsigned mask = ((1 << count) - 1) << start;
0240 return (m_dataWord & mask) >> start;
0241 }
0242
0243 void L1MuGMTCand::writeDataField(unsigned start, unsigned count, unsigned value) {
0244 unsigned mask = ((1 << count) - 1) << start;
0245 m_dataWord &= ~mask;
0246 m_dataWord |= (value << start) & mask;
0247 }
0248
0249 #endif