File indexing completed on 2023-10-26 08:14:04
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 #include "DataFormats/L1TParticleFlow/interface/gt_datatypes.h"
0007
0008 namespace l1ct {
0009
0010 struct Tau {
0011 typedef ap_uint<2> type_t;
0012 typedef ap_uint<10> rawid_t;
0013 typedef ap_uint<2> lepid_t;
0014
0015 pt_t hwPt;
0016 glbeta_t hwEta;
0017 glbphi_t hwPhi;
0018 pt_t hwSeedPt;
0019 z0_t hwSeedZ0;
0020 bool hwCharge;
0021 type_t hwType;
0022 rawid_t hwRawId;
0023 lepid_t hwIdVsMu;
0024 lepid_t hwIdVsEle;
0025 rawid_t hwIsoOrMVA;
0026
0027 inline bool operator==(const Tau &other) const {
0028 return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi && hwSeedPt == other.hwSeedPt &&
0029 hwSeedZ0 == other.hwSeedZ0 && hwCharge == other.hwCharge && hwType == other.hwType &&
0030 hwIsoOrMVA == other.hwIsoOrMVA && hwIdVsMu == other.hwIdVsMu && hwIdVsEle == other.hwIdVsEle;
0031 }
0032
0033 inline bool operator>(const Tau &other) const { return hwPt > other.hwPt; }
0034 inline bool operator<(const Tau &other) const { return hwPt < other.hwPt; }
0035
0036 inline pt_t hwAbsIso() const {
0037 pt10_t ret;
0038 ret(9, 0) = hwRawId(9, 0);
0039 return ret;
0040 }
0041
0042 inline void setAbsIso(pt10_t absIso) { hwRawId(9, 0) = absIso(9, 0); }
0043
0044 inline void clear() {
0045 hwPt = 0;
0046 hwEta = 0;
0047 hwPhi = 0;
0048 hwSeedPt = 0;
0049 hwSeedZ0 = 0;
0050 hwCharge = false;
0051 hwType = 0;
0052 hwIsoOrMVA = 0;
0053 hwIdVsMu = 0;
0054 hwIdVsEle = 0;
0055 hwIsoOrMVA = 0;
0056 }
0057
0058 int intPt() const { return Scales::intPt(hwPt); }
0059 int intEta() const { return hwEta.to_int(); }
0060 int intPhi() const { return hwPhi.to_int(); }
0061 int intSeedPt() const { return Scales::intPt(hwSeedPt); }
0062 float floatPt() const { return Scales::floatPt(hwPt); }
0063 float floatEta() const { return Scales::floatEta(hwEta); }
0064 float floatPhi() const { return Scales::floatPhi(hwPhi); }
0065 float floatSeedPt() const { return Scales::floatPt(hwSeedPt); }
0066 float floatSeedZ0() const { return Scales::floatZ0(hwSeedZ0); }
0067 int intCharge() const { return hwCharge ? +1 : -1; }
0068 int pdgId() const { return -15 * intCharge(); }
0069 int intType() const { return hwType.to_int(); }
0070
0071 float floatAbsIso() const { return Scales::floatPt(hwAbsIso()); }
0072
0073 static const int BITWIDTH = pt_t::width + glbeta_t::width + glbphi_t::width + pt10_t::width + z0_t::width + 1 +
0074 type_t::width + rawid_t::width + 2 * lepid_t::width;
0075 inline ap_uint<BITWIDTH> pack() const {
0076 ap_uint<BITWIDTH> ret;
0077 unsigned int start = 0;
0078 pack_into_bits(ret, start, hwPt);
0079 pack_into_bits(ret, start, hwEta);
0080 pack_into_bits(ret, start, hwPhi);
0081 pack_into_bits(ret, start, hwSeedPt);
0082 pack_into_bits(ret, start, hwSeedZ0);
0083 pack_bool_into_bits(ret, start, hwCharge);
0084 pack_into_bits(ret, start, hwType);
0085 pack_into_bits(ret, start, hwRawId);
0086 pack_into_bits(ret, start, hwIdVsMu);
0087 pack_into_bits(ret, start, hwIdVsEle);
0088 pack_into_bits(ret, start, hwIsoOrMVA);
0089 return ret;
0090 }
0091
0092 inline static Tau unpack(const ap_uint<BITWIDTH> &src) {
0093 Tau ret;
0094 unsigned int start = 0;
0095 unpack_from_bits(src, start, ret.hwPt);
0096 unpack_from_bits(src, start, ret.hwEta);
0097 unpack_from_bits(src, start, ret.hwPhi);
0098 unpack_from_bits(src, start, ret.hwSeedPt);
0099 unpack_from_bits(src, start, ret.hwSeedZ0);
0100 unpack_from_bits(src, start, ret.hwType);
0101 unpack_from_bits(src, start, ret.hwRawId);
0102 unpack_from_bits(src, start, ret.hwIdVsMu);
0103 unpack_from_bits(src, start, ret.hwIdVsEle);
0104 unpack_from_bits(src, start, ret.hwIsoOrMVA);
0105 return ret;
0106 }
0107
0108 l1gt::Tau toGT() const {
0109 l1gt::Tau t;
0110 t.valid = hwPt != 0;
0111
0112 t.v3.pt = CTtoGT_pt(hwPt);
0113 t.v3.phi = CTtoGT_phi(hwPhi);
0114 t.v3.eta = CTtoGT_eta(hwEta);
0115
0116 t.seed_pt = hwSeedPt;
0117 t.seed_z0(l1ct::z0_t::width - 1, 0) = hwSeedZ0(l1ct::z0_t::width - 1, 0);
0118 t.charge = hwCharge;
0119
0120 t.type = hwType;
0121 t.isolation = hwRawId;
0122 return t;
0123 }
0124 };
0125
0126 inline void clear(Tau &c) { c.clear(); }
0127
0128 }
0129
0130 #endif