File indexing completed on 2023-03-17 10:50:28
0001 #ifndef DataFormats_L1TParticleFlow_sums_h
0002 #define DataFormats_L1TParticleFlow_sums_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
0008 namespace l1ct {
0009
0010 struct Sum {
0011 pt_t hwPt;
0012 glbphi_t hwPhi;
0013 pt_t hwSumPt;
0014
0015 inline bool operator==(const Sum &other) const {
0016 return hwPt == other.hwPt && hwPhi == other.hwPhi && hwSumPt == other.hwSumPt;
0017 }
0018
0019 inline void clear() {
0020 hwPt = 0;
0021 hwPhi = 0;
0022 hwSumPt = 0;
0023 }
0024
0025 int intPt() const { return Scales::intPt(hwPt); }
0026 int intPhi() const { return hwPhi.to_int(); }
0027 int intSumPt() const { return Scales::intPt(hwSumPt); }
0028 float floatPt() const { return Scales::floatPt(hwPt); }
0029 float floatPhi() const { return Scales::floatPhi(hwPhi); }
0030 float floatSumPt() const { return Scales::floatPt(hwSumPt); }
0031
0032 static const int BITWIDTH = pt_t::width + glbphi_t::width + pt_t::width;
0033 inline ap_uint<BITWIDTH> pack() const {
0034 ap_uint<BITWIDTH> ret;
0035 unsigned int start = 0;
0036 pack_into_bits(ret, start, hwPt);
0037 pack_into_bits(ret, start, hwPhi);
0038 pack_into_bits(ret, start, hwSumPt);
0039 return ret;
0040 }
0041 inline static Sum unpack(const ap_uint<BITWIDTH> &src) {
0042 Sum ret;
0043 unsigned int start = 0;
0044 unpack_from_bits(src, start, ret.hwPt);
0045 unpack_from_bits(src, start, ret.hwPhi);
0046 unpack_from_bits(src, start, ret.hwSumPt);
0047 return ret;
0048 }
0049
0050 l1gt::Sum toGT() const {
0051 l1gt::Sum sum;
0052 sum.valid = (hwPt != 0) || (hwSumPt != 0);
0053 sum.vector_pt = CTtoGT_pt(hwPt);
0054 sum.vector_phi = CTtoGT_phi(hwPhi);
0055 sum.scalar_pt = CTtoGT_phi(hwSumPt);
0056 return sum;
0057 }
0058 };
0059
0060 inline void clear(Sum &c) { c.clear(); }
0061
0062 }
0063
0064 #endif