File indexing completed on 2023-03-17 10:50:28
0001 #ifndef DataFormats_L1TParticleFlow_taus_h
0002 #define DataFormats_L1TParticleFlow_taus_h
0003
0004 #include "DataFormats/L1TParticleFlow/interface/datatypes.h"
0005 #include "DataFormats/L1TParticleFlow/interface/bit_encoding.h"
0006
0007 namespace l1ct {
0008
0009 struct Tau {
0010 typedef ap_uint<2> type_t;
0011 typedef ap_uint<10> rawid_t;
0012 typedef ap_uint<2> lepid_t;
0013
0014 pt_t hwPt;
0015 glbeta_t hwEta;
0016 glbphi_t hwPhi;
0017 pt_t hwSeedPt;
0018 z0_t hwSeedZ0;
0019 bool hwCharge;
0020 type_t hwType;
0021 rawid_t hwRawId;
0022 lepid_t hwIdVsMu;
0023 lepid_t hwIdVsEle;
0024 rawid_t hwIsoOrMVA;
0025
0026 inline bool operator==(const Tau &other) const {
0027 return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi && hwSeedPt == other.hwSeedPt &&
0028 hwSeedZ0 == other.hwSeedZ0 && hwCharge == other.hwCharge && hwType == other.hwType &&
0029 hwIsoOrMVA == other.hwIsoOrMVA && hwIdVsMu == other.hwIdVsMu && hwIdVsEle == other.hwIdVsEle;
0030 }
0031
0032 inline bool operator>(const Tau &other) const { return hwPt > other.hwPt; }
0033 inline bool operator<(const Tau &other) const { return hwPt < other.hwPt; }
0034
0035 inline pt_t hwAbsIso() const {
0036 pt10_t ret;
0037 ret(9, 0) = hwRawId(9, 0);
0038 return ret;
0039 }
0040
0041 inline void setAbsIso(pt10_t absIso) { hwRawId(9, 0) = absIso(9, 0); }
0042
0043 inline void clear() {
0044 hwPt = 0;
0045 hwEta = 0;
0046 hwPhi = 0;
0047 hwSeedPt = 0;
0048 hwSeedZ0 = 0;
0049 hwCharge = 0;
0050 hwType = 0;
0051 hwIsoOrMVA = 0;
0052 hwIdVsMu = 0;
0053 hwIdVsEle = 0;
0054 hwIsoOrMVA = 0;
0055 }
0056
0057 int intPt() const { return Scales::intPt(hwPt); }
0058 int intEta() const { return hwEta.to_int(); }
0059 int intPhi() const { return hwPhi.to_int(); }
0060 int intSeedPt() const { return Scales::intPt(hwSeedPt); }
0061 float floatPt() const { return Scales::floatPt(hwPt); }
0062 float floatEta() const { return Scales::floatEta(hwEta); }
0063 float floatPhi() const { return Scales::floatPhi(hwPhi); }
0064 float floatSeedPt() const { return Scales::floatPt(hwSeedPt); }
0065 float floatSeedZ0() const { return Scales::floatZ0(hwSeedZ0); }
0066 int intCharge() const { return hwCharge ? +1 : -1; }
0067 int pdgId() const { return -15 * intCharge(); }
0068 int intType() const { return hwType.to_int(); }
0069
0070 float floatAbsIso() const { return Scales::floatPt(hwAbsIso()); }
0071
0072 static const int BITWIDTH = pt_t::width + glbeta_t::width + glbphi_t::width + pt10_t::width + z0_t::width + 1 +
0073 type_t::width + rawid_t::width + 2 * lepid_t::width;
0074 inline ap_uint<BITWIDTH> pack() const {
0075 ap_uint<BITWIDTH> ret;
0076 unsigned int start = 0;
0077 pack_into_bits(ret, start, hwPt);
0078 pack_into_bits(ret, start, hwEta);
0079 pack_into_bits(ret, start, hwPhi);
0080 pack_into_bits(ret, start, hwSeedPt);
0081 pack_into_bits(ret, start, hwSeedZ0);
0082 pack_bool_into_bits(ret, start, hwCharge);
0083 pack_into_bits(ret, start, hwType);
0084 pack_into_bits(ret, start, hwRawId);
0085 pack_into_bits(ret, start, hwIdVsMu);
0086 pack_into_bits(ret, start, hwIdVsEle);
0087 pack_into_bits(ret, start, hwIsoOrMVA);
0088 return ret;
0089 }
0090 inline static Tau unpack(const ap_uint<BITWIDTH> &src) {
0091 Tau ret;
0092 unsigned int start = 0;
0093 unpack_from_bits(src, start, ret.hwPt);
0094 unpack_from_bits(src, start, ret.hwEta);
0095 unpack_from_bits(src, start, ret.hwPhi);
0096 unpack_from_bits(src, start, ret.hwSeedPt);
0097 unpack_from_bits(src, start, ret.hwSeedZ0);
0098 unpack_from_bits(src, start, ret.hwType);
0099 unpack_from_bits(src, start, ret.hwRawId);
0100 unpack_from_bits(src, start, ret.hwIdVsMu);
0101 unpack_from_bits(src, start, ret.hwIdVsEle);
0102 unpack_from_bits(src, start, ret.hwIsoOrMVA);
0103 return ret;
0104 }
0105 };
0106
0107 inline void clear(Tau &c) { c.clear(); }
0108
0109 }
0110
0111 #endif