CMS 3D CMS Logo

jets.h
Go to the documentation of this file.
1 #ifndef DataFormats_L1TParticleFlow_jets_h
2 #define DataFormats_L1TParticleFlow_jets_h
3 
7 #include <array>
8 #include <cstdint>
9 
10 namespace l1ct {
11 
12  struct Jet {
18 
19  inline bool operator==(const Jet &other) const {
20  return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi;
21  }
22 
23  inline bool operator>(const Jet &other) const { return hwPt > other.hwPt; }
24  inline bool operator<(const Jet &other) const { return hwPt < other.hwPt; }
25 
26  inline void clear() {
27  hwPt = 0;
28  hwEta = 0;
29  hwPhi = 0;
30  hwZ0 = 0;
31  hwBtagScore = 0;
32  }
33 
34  int intPt() const { return Scales::intPt(hwPt); }
35  int intEta() const { return hwEta.to_int(); }
36  int intPhi() const { return hwPhi.to_int(); }
37  float floatPt() const { return Scales::floatPt(hwPt); }
38  float floatEta() const { return Scales::floatEta(hwEta); }
39  float floatPhi() const { return Scales::floatPhi(hwPhi); }
41  float floatZ0() const { return Scales::floatZ0(hwZ0); }
42 
44  inline ap_uint<BITWIDTH> pack_ap() const {
45  ap_uint<BITWIDTH> ret;
46  unsigned int start = 0;
52  return ret;
53  }
54 
55  inline std::array<uint64_t, 2> pack() const {
56  std::array<uint64_t, 2> packed = {{0, 0}};
57  ap_uint<BITWIDTH> bits = this->pack_ap();
58  packed[0] = bits;
59  //packed[1] = bits[slice]; // for when there are more than 64 bits in the word
60  return packed;
61  }
62 
63  inline static Jet unpack_ap(const ap_uint<BITWIDTH> &src) {
64  Jet ret;
65  ret.initFromBits(src);
66  return ret;
67  }
68 
69  inline void initFromBits(const ap_uint<BITWIDTH> &src) {
70  unsigned int start = 0;
76  }
77 
78  inline static Jet unpack(const std::array<uint64_t, 2> &src) {
79  // just one set while the word has fewer than 64 bits
80  ap_uint<BITWIDTH> bits = src[0];
81  return unpack_ap(bits);
82  }
83 
84  inline static Jet unpack(long long unsigned int &src) {
85  // unpack from single 64b int
86  ap_uint<BITWIDTH> bits = src;
87  return unpack_ap(bits);
88  }
89 
90  l1gt::Jet toGT() const {
91  l1gt::Jet j;
92  j.valid = hwPt != 0;
93  j.v3.pt = CTtoGT_pt(hwPt);
94  j.v3.phi = CTtoGT_phi(hwPhi);
95  j.v3.eta = CTtoGT_eta(hwEta);
96  j.z0(l1ct::z0_t::width - 1, 0) = hwZ0(l1ct::z0_t::width - 1, 0);
97  j.hwBtagScore = hwBtagScore;
98  return j;
99  }
100  };
101 
102  inline void clear(Jet &c) { c.clear(); }
103 
104 } // namespace l1ct
105 
106 #endif
Definition: start.py:1
float floatPhi() const
Definition: jets.h:39
float floatZ0(z0_t z0)
Definition: datatypes.h:171
float floatBtagScore() const
Definition: jets.h:40
z0_t hwZ0
Definition: jets.h:16
static Jet unpack_ap(const ap_uint< BITWIDTH > &src)
Definition: jets.h:63
ap_uint< BITWIDTH > pack_ap() const
Definition: jets.h:44
ret
prodAgent to be discontinued
l1gt::eta_t CTtoGT_eta(glbeta_t x)
Definition: gt_datatypes.h:375
bool operator>(const Jet &other) const
Definition: jets.h:23
static Jet unpack(long long unsigned int &src)
Definition: jets.h:84
int intPt() const
Definition: jets.h:34
glbeta_t hwEta
Definition: jets.h:14
ap_int< 11 > glbphi_t
Definition: datatypes.h:19
pt_t hwPt
Definition: jets.h:13
void clear()
Definition: jets.h:26
ap_ufixed< 10, 1, AP_RND, AP_SAT > b_tag_score_t
Definition: datatypes.h:37
float floatEta(eta_t eta)
Definition: datatypes.h:165
Definition: Jet.py:1
void pack_into_bits(U &u, unsigned int &start, const T &data)
Definition: bit_encoding.h:8
float floatPt(pt_t pt)
Definition: datatypes.h:154
static Jet unpack(const std::array< uint64_t, 2 > &src)
Definition: jets.h:78
std::array< uint64_t, 2 > pack() const
Definition: jets.h:55
b_tag_score_t hwBtagScore
Definition: jets.h:17
int intPhi() const
Definition: jets.h:36
ap_int< 10 > z0_t
Definition: datatypes.h:21
l1gt::Jet toGT() const
Definition: jets.h:90
int intPt(pt_t pt)
Definition: datatypes.h:157
ap_ufixed< 14, 12, AP_TRN, AP_SAT > pt_t
Definition: datatypes.h:10
float floatZ0() const
Definition: jets.h:41
float floatPt() const
Definition: jets.h:37
float floatBtagScore(b_tag_score_t b_tag_score)
Definition: datatypes.h:179
bool operator<(const Jet &other) const
Definition: jets.h:24
static const int BITWIDTH
Definition: jets.h:43
l1gt::phi_t CTtoGT_phi(glbphi_t x)
Definition: gt_datatypes.h:380
void initFromBits(const ap_uint< BITWIDTH > &src)
Definition: jets.h:69
float floatEta() const
Definition: jets.h:38
float floatPhi(phi_t phi)
Definition: datatypes.h:166
glbphi_t hwPhi
Definition: jets.h:15
void unpack_from_bits(const U &u, unsigned int &start, T &data)
Definition: bit_encoding.h:15
bool operator==(const Jet &other) const
Definition: jets.h:19
l1gt::pt_t CTtoGT_pt(pt_t x)
Definition: gt_datatypes.h:369
void clear(EGIsoObj &c)
Definition: egamma.h:82
int intEta() const
Definition: jets.h:35
ap_int< 12 > glbeta_t
Definition: datatypes.h:18
Definition: datatypes.h:8