CMS 3D CMS Logo

puppi.h
Go to the documentation of this file.
1 #ifndef DataFormats_L1TParticleFlow_puppi_h
2 #define DataFormats_L1TParticleFlow_puppi_h
3 
8 
9 namespace l1ct {
10 
11  struct PuppiObj {
13  glbeta_t hwEta; // wider range to support global coordinates
16 
17  static const int BITS_Z0_START = 0;
21 
22  static const int BITS_PUPPIW_START = 0;
25 
26  static const int DATA_BITS_TOTAL =
28 
29  ap_uint<DATA_BITS_TOTAL> hwData;
30 
31  inline z0_t hwZ0() const {
32 #ifndef __SYNTHESIS__
33  assert(hwId.charged() || hwPt == 0);
34 #endif
36  }
37 
38  inline void setHwZ0(z0_t z0) {
39 #ifndef __SYNTHESIS__
40  assert(hwId.charged() || hwPt == 0);
41 #endif
43  }
44 
45  inline dxy_t hwDxy() const {
46 #ifndef __SYNTHESIS__
47  assert(hwId.charged() || hwPt == 0);
48 #endif
50  }
51 
52  inline void setHwDxy(dxy_t dxy) {
53 #ifndef __SYNTHESIS__
54  assert(hwId.charged() || hwPt == 0);
55 #endif
57  }
58 
59  inline tkquality_t hwTkQuality() const {
60 #ifndef __SYNTHESIS__
61  assert(hwId.charged() || hwPt == 0);
62 #endif
64  }
65 
67 #ifndef __SYNTHESIS__
68  assert(hwId.charged() || hwPt == 0);
69 #endif
71  }
72 
73  inline puppiWgt_t hwPuppiW() const {
74 #ifndef __SYNTHESIS__
75  assert(hwId.neutral());
76 #endif
79  return ret;
80  }
81 
82  inline void setHwPuppiW(puppiWgt_t w) {
83 #ifndef __SYNTHESIS__
84  assert(hwId.neutral());
85 #endif
87  }
88 
89  inline emid_t hwEmID() const {
90 #ifndef __SYNTHESIS__
91  assert(hwId.neutral());
92 #endif
94  }
95 
96  inline void setHwEmID(emid_t w) {
97 #ifndef __SYNTHESIS__
98  assert(hwId.neutral());
99 #endif
101  }
102 
103  inline bool operator==(const PuppiObj &other) const {
104  return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi && hwId == other.hwId &&
105  hwData == other.hwData;
106  }
107 
108  inline bool operator>(const PuppiObj &other) const { return hwPt > other.hwPt; }
109  inline bool operator<(const PuppiObj &other) const { return hwPt < other.hwPt; }
110 
111  inline void clear() {
112  hwPt = 0;
113  hwEta = 0;
114  hwPhi = 0;
115  hwId.clear();
116  hwData = 0;
117  }
118 
119  inline void fill(const PFRegion &region, const PFChargedObj &src) {
120  hwEta = region.hwGlbEta(src.hwVtxEta());
121  hwPhi = region.hwGlbPhi(src.hwVtxPhi());
122  hwId = src.hwId;
123  hwPt = src.hwPt;
124  hwData = 0;
125  setHwZ0(src.hwZ0);
126  setHwDxy(src.hwDxy);
127  setHwTkQuality(src.hwTkQuality);
128  }
129  inline void fill(const PFRegion &region, const PFNeutralObj &src, pt_t puppiPt, puppiWgt_t puppiWgt) {
130  hwEta = region.hwGlbEta(src.hwEta);
131  hwPhi = region.hwGlbPhi(src.hwPhi);
132  hwId = src.hwId;
133  hwPt = puppiPt;
134  hwData = 0;
135  setHwPuppiW(puppiWgt);
136  setHwEmID(src.hwEmID);
137  }
138  inline void fill(const PFRegion &region, const HadCaloObj &src, pt_t puppiPt, puppiWgt_t puppiWgt) {
139  hwEta = region.hwGlbEta(src.hwEta);
140  hwPhi = region.hwGlbPhi(src.hwPhi);
142  hwPt = puppiPt;
143  hwData = 0;
144  setHwPuppiW(puppiWgt);
145  setHwEmID(src.hwEmID);
146  }
147 
148  int intPt() const { return Scales::intPt(hwPt); }
149  int intEta() const { return hwEta.to_int(); }
150  int intPhi() const { return hwPhi.to_int(); }
151  float floatPt() const { return Scales::floatPt(hwPt); }
152  float floatEta() const { return Scales::floatEta(hwEta); }
153  float floatPhi() const { return Scales::floatPhi(hwPhi); }
154  int intId() const { return hwId.rawId(); }
155  int pdgId() const { return hwId.pdgId(); }
156  int oldId() const { return hwPt > 0 ? hwId.oldId() : 0; }
157  int intCharge() const { return hwId.intCharge(); }
158  float floatZ0() const { return Scales::floatZ0(hwZ0()); }
159  float floatDxy() const { return Scales::floatDxy(hwDxy()); }
160  float floatPuppiW() const { return hwId.neutral() ? Scales::floatPuppiW(hwPuppiW()) : 1.0f; }
161 
163  inline ap_uint<BITWIDTH> pack() const {
164  ap_uint<BITWIDTH> ret;
165  unsigned int start = 0;
171  return ret;
172  }
173  inline void initFromBits(const ap_uint<BITWIDTH> &src) {
174  unsigned int start = 0;
180  }
181  inline static PuppiObj unpack(const ap_uint<BITWIDTH> &src) {
182  PuppiObj ret;
183  ret.initFromBits(src);
184  return ret;
185  }
186  };
187  inline void clear(PuppiObj &c) { c.clear(); }
188 
189 } // namespace l1ct
190 
191 #endif
void clear()
Definition: puppi.h:111
int intPt() const
Definition: puppi.h:148
int intCharge() const
Definition: puppi.h:157
Definition: start.py:1
bool operator<(const PuppiObj &other) const
Definition: puppi.h:109
ap_uint< 3 > tkquality_t
Definition: datatypes.h:23
ap_uint< DATA_BITS_TOTAL > hwData
Definition: puppi.h:29
float floatPhi() const
Definition: puppi.h:153
float floatZ0(z0_t z0)
Definition: datatypes.h:170
int intEta() const
Definition: puppi.h:149
static const int BITWIDTH
Definition: puppi.h:162
T w() const
ret
prodAgent to be discontinued
dxy_t hwDxy() const
Definition: puppi.h:45
ParticleID hwId
Definition: puppi.h:15
float floatPt() const
Definition: puppi.h:151
tkquality_t hwTkQuality() const
Definition: puppi.h:59
int rawId() const
Definition: datatypes.h:62
z0_t hwZ0() const
Definition: puppi.h:31
static const int DATA_NEUTRAL_BITS_TOTAL
Definition: puppi.h:24
emid_t hwEmID() const
Definition: puppi.h:89
void setHwPuppiW(puppiWgt_t w)
Definition: puppi.h:82
assert(be >=bs)
int oldId() const
Definition: puppi.h:156
void fill(const PFRegion &region, const PFNeutralObj &src, pt_t puppiPt, puppiWgt_t puppiWgt)
Definition: puppi.h:129
static const int BITS_DXY_START
Definition: puppi.h:18
int intPhi() const
Definition: puppi.h:150
ap_uint< 6 > emid_t
Definition: datatypes.h:25
static const int BITS_PUPPIW_START
Definition: puppi.h:22
float floatEta() const
Definition: puppi.h:152
int oldId() const
Definition: datatypes.h:116
bool charged() const
Definition: datatypes.h:82
ap_uint< BITWIDTH > pack() const
Definition: puppi.h:163
ap_int< 11 > glbphi_t
Definition: datatypes.h:19
glbeta_t hwEta
Definition: puppi.h:13
static const int BITS_EMID_START
Definition: puppi.h:23
float floatEta(eta_t eta)
Definition: datatypes.h:164
void setHwTkQuality(tkquality_t qual)
Definition: puppi.h:66
int pdgId() const
Definition: datatypes.h:94
float floatDxy(dxy_t dxy)
Definition: datatypes.h:171
static PuppiObj unpack(const ap_uint< BITWIDTH > &src)
Definition: puppi.h:181
void pack_into_bits(U &u, unsigned int &start, const T &data)
Definition: bit_encoding.h:8
static const int BITS_Z0_START
Definition: puppi.h:17
float floatPt(pt_t pt)
Definition: datatypes.h:153
float floatPuppiW(puppiWgt_t puppiw)
Definition: datatypes.h:172
void setHwDxy(dxy_t dxy)
Definition: puppi.h:52
static const int BITS_TKQUAL_START
Definition: puppi.h:19
float floatZ0() const
Definition: puppi.h:158
glbphi_t hwPhi
Definition: puppi.h:14
ap_ufixed< 9, 1, AP_RND_CONV, AP_WRAP > puppiWgt_t
Definition: datatypes.h:24
float floatDxy() const
Definition: puppi.h:159
ap_int< 10 > z0_t
Definition: datatypes.h:21
ap_uint< 3 > bits
Definition: datatypes.h:42
void setHwEmID(emid_t w)
Definition: puppi.h:96
int intPt(pt_t pt)
Definition: datatypes.h:156
ap_ufixed< 14, 12, AP_TRN, AP_SAT > pt_t
Definition: datatypes.h:10
void initFromBits(const ap_uint< BITWIDTH > &src)
Definition: puppi.h:173
static const int DATA_BITS_TOTAL
Definition: puppi.h:26
pt_t hwPt
Definition: puppi.h:12
void fill(const PFRegion &region, const HadCaloObj &src, pt_t puppiPt, puppiWgt_t puppiWgt)
Definition: puppi.h:138
bool operator==(const PuppiObj &other) const
Definition: puppi.h:103
int pdgId() const
Definition: puppi.h:155
int intCharge() const
Definition: datatypes.h:84
void setHwZ0(z0_t z0)
Definition: puppi.h:38
void fill(const PFRegion &region, const PFChargedObj &src)
Definition: puppi.h:119
float floatPuppiW() const
Definition: puppi.h:160
float floatPhi(phi_t phi)
Definition: datatypes.h:165
static const int DATA_CHARGED_BITS_TOTAL
Definition: puppi.h:20
void unpack_from_bits(const U &u, unsigned int &start, T &data)
Definition: bit_encoding.h:15
bool operator>(const PuppiObj &other) const
Definition: puppi.h:108
void clear(EGIsoObj &c)
Definition: egamma.h:82
ap_int< 8 > dxy_t
Definition: datatypes.h:22
bool neutral() const
Definition: datatypes.h:83
int intId() const
Definition: puppi.h:154
ap_int< 12 > glbeta_t
Definition: datatypes.h:18
puppiWgt_t hwPuppiW() const
Definition: puppi.h:73
Definition: datatypes.h:8