File indexing completed on 2024-05-11 03:34:02
0001 #ifndef DataFormats_L1TParticleFlow_jets_h
0002 #define DataFormats_L1TParticleFlow_jets_h
0003
0004 #include "DataFormats/L1TParticleFlow/interface/datatypes.h"
0005 #include "DataFormats/L1TParticleFlow/interface/gt_datatypes.h"
0006 #include "DataFormats/L1TParticleFlow/interface/bit_encoding.h"
0007 #include <array>
0008 #include <cstdint>
0009
0010 namespace l1ct {
0011
0012 struct Jet {
0013 pt_t hwPt;
0014 glbeta_t hwEta;
0015 glbphi_t hwPhi;
0016 z0_t hwZ0;
0017 b_tag_score_t hwBtagScore;
0018
0019 inline bool operator==(const Jet &other) const {
0020 return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi;
0021 }
0022
0023 inline bool operator>(const Jet &other) const { return hwPt > other.hwPt; }
0024 inline bool operator<(const Jet &other) const { return hwPt < other.hwPt; }
0025
0026 inline void clear() {
0027 hwPt = 0;
0028 hwEta = 0;
0029 hwPhi = 0;
0030 hwZ0 = 0;
0031 hwBtagScore = 0;
0032 }
0033
0034 int intPt() const { return Scales::intPt(hwPt); }
0035 int intEta() const { return hwEta.to_int(); }
0036 int intPhi() const { return hwPhi.to_int(); }
0037 float floatPt() const { return Scales::floatPt(hwPt); }
0038 float floatEta() const { return Scales::floatEta(hwEta); }
0039 float floatPhi() const { return Scales::floatPhi(hwPhi); }
0040 float floatBtagScore() const { return Scales::floatBtagScore(hwBtagScore); }
0041 float floatZ0() const { return Scales::floatZ0(hwZ0); }
0042
0043 static const int BITWIDTH = pt_t::width + glbeta_t::width + glbphi_t::width + z0_t::width + b_tag_score_t::width;
0044 inline ap_uint<BITWIDTH> pack_ap() const {
0045 ap_uint<BITWIDTH> ret;
0046 unsigned int start = 0;
0047 pack_into_bits(ret, start, hwPt);
0048 pack_into_bits(ret, start, hwEta);
0049 pack_into_bits(ret, start, hwPhi);
0050 pack_into_bits(ret, start, hwZ0);
0051 pack_into_bits(ret, start, hwBtagScore);
0052 return ret;
0053 }
0054
0055 inline std::array<uint64_t, 2> pack() const {
0056 std::array<uint64_t, 2> packed = {{0, 0}};
0057 ap_uint<BITWIDTH> bits = this->pack_ap();
0058 packed[0] = bits;
0059
0060 return packed;
0061 }
0062
0063 inline static Jet unpack_ap(const ap_uint<BITWIDTH> &src) {
0064 Jet ret;
0065 ret.initFromBits(src);
0066 return ret;
0067 }
0068
0069 inline void initFromBits(const ap_uint<BITWIDTH> &src) {
0070 unsigned int start = 0;
0071 unpack_from_bits(src, start, hwPt);
0072 unpack_from_bits(src, start, hwEta);
0073 unpack_from_bits(src, start, hwPhi);
0074 unpack_from_bits(src, start, hwZ0);
0075 unpack_from_bits(src, start, hwBtagScore);
0076 }
0077
0078 inline static Jet unpack(const std::array<uint64_t, 2> &src) {
0079
0080 ap_uint<BITWIDTH> bits = src[0];
0081 return unpack_ap(bits);
0082 }
0083
0084 inline static Jet unpack(long long unsigned int &src) {
0085
0086 ap_uint<BITWIDTH> bits = src;
0087 return unpack_ap(bits);
0088 }
0089
0090 l1gt::Jet toGT() const {
0091 l1gt::Jet j;
0092 j.valid = hwPt != 0;
0093 j.v3.pt = CTtoGT_pt(hwPt);
0094 j.v3.phi = CTtoGT_phi(hwPhi);
0095 j.v3.eta = CTtoGT_eta(hwEta);
0096 j.z0(l1ct::z0_t::width - 1, 0) = hwZ0(l1ct::z0_t::width - 1, 0);
0097 j.hwBtagScore = hwBtagScore;
0098 return j;
0099 }
0100 };
0101
0102 inline void clear(Jet &c) { c.clear(); }
0103
0104 }
0105
0106 #endif