File indexing completed on 2022-06-10 01:50:15
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
0017 inline bool operator==(const Jet &other) const {
0018 return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi;
0019 }
0020
0021 inline bool operator>(const Jet &other) const { return hwPt > other.hwPt; }
0022 inline bool operator<(const Jet &other) const { return hwPt < other.hwPt; }
0023
0024 inline void clear() {
0025 hwPt = 0;
0026 hwEta = 0;
0027 hwPhi = 0;
0028 }
0029
0030 int intPt() const { return Scales::intPt(hwPt); }
0031 int intEta() const { return hwEta.to_int(); }
0032 int intPhi() const { return hwPhi.to_int(); }
0033 float floatPt() const { return Scales::floatPt(hwPt); }
0034 float floatEta() const { return Scales::floatEta(hwEta); }
0035 float floatPhi() const { return Scales::floatPhi(hwPhi); }
0036
0037 static const int BITWIDTH = pt_t::width + glbeta_t::width + glbphi_t::width;
0038 inline ap_uint<BITWIDTH> pack_ap() const {
0039 ap_uint<BITWIDTH> ret;
0040 unsigned int start = 0;
0041 pack_into_bits(ret, start, hwPt);
0042 pack_into_bits(ret, start, hwEta);
0043 pack_into_bits(ret, start, hwPhi);
0044 return ret;
0045 }
0046
0047 inline std::array<uint64_t, 2> pack() const {
0048 std::array<uint64_t, 2> packed;
0049 ap_uint<BITWIDTH> bits = this->pack_ap();
0050 packed[0] = bits;
0051
0052 return packed;
0053 }
0054
0055 inline static Jet unpack_ap(const ap_uint<BITWIDTH> &src) {
0056 Jet ret;
0057 ret.initFromBits(src);
0058 return ret;
0059 }
0060
0061 inline void initFromBits(const ap_uint<BITWIDTH> &src) {
0062 unsigned int start = 0;
0063 unpack_from_bits(src, start, hwPt);
0064 unpack_from_bits(src, start, hwEta);
0065 unpack_from_bits(src, start, hwPhi);
0066 }
0067
0068 inline static Jet unpack(const std::array<uint64_t, 2> &src) {
0069
0070 ap_uint<BITWIDTH> bits = src[0];
0071 return unpack_ap(bits);
0072 }
0073
0074 inline static Jet unpack(long long unsigned int &src) {
0075
0076 ap_uint<BITWIDTH> bits = src;
0077 return unpack_ap(bits);
0078 }
0079
0080 l1gt::Jet toGT() const {
0081 l1gt::Jet j;
0082 j.valid = hwPt != 0;
0083 j.v3.pt = CTtoGT_pt(hwPt);
0084 j.v3.phi = CTtoGT_phi(hwPhi);
0085 j.v3.eta = CTtoGT_eta(hwEta);
0086 j.z0 = 0;
0087 return j;
0088 }
0089 };
0090
0091 inline void clear(Jet &c) { c.clear(); }
0092
0093 }
0094
0095 #endif