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
78  }
79 
80  inline void setHwPuppiW(puppiWgt_t w) {
81 #ifndef __SYNTHESIS__
82  assert(hwId.neutral());
83 #endif
85  }
86 
87  inline puppiWgt_t hwEmID() const {
88 #ifndef __SYNTHESIS__
89  assert(hwId.neutral());
90 #endif
92  }
93 
94  inline void setHwEmID(emid_t w) {
95 #ifndef __SYNTHESIS__
96  assert(hwId.neutral());
97 #endif
99  }
100 
101  inline bool operator==(const PuppiObj &other) const {
102  return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi && hwId == other.hwId &&
103  hwData == other.hwData;
104  }
105 
106  inline bool operator>(const PuppiObj &other) const { return hwPt > other.hwPt; }
107  inline bool operator<(const PuppiObj &other) const { return hwPt < other.hwPt; }
108 
109  inline void clear() {
110  hwPt = 0;
111  hwEta = 0;
112  hwPhi = 0;
113  hwId.clear();
114  hwData = 0;
115  }
116 
117  inline void fill(const PFRegion &region, const PFChargedObj &src) {
118  hwEta = region.hwGlbEta(src.hwVtxEta());
119  hwPhi = region.hwGlbPhi(src.hwVtxPhi());
120  hwId = src.hwId;
121  hwPt = src.hwPt;
122  hwData = 0;
123  setHwZ0(src.hwZ0);
124  setHwDxy(src.hwDxy);
125  setHwTkQuality(src.hwTkQuality);
126  }
127  inline void fill(const PFRegion &region, const PFNeutralObj &src, pt_t puppiPt, puppiWgt_t puppiWgt) {
128  hwEta = region.hwGlbEta(src.hwEta);
129  hwPhi = region.hwGlbPhi(src.hwPhi);
130  hwId = src.hwId;
131  hwPt = puppiPt;
132  hwData = 0;
133  setHwPuppiW(puppiWgt);
134  setHwEmID(src.hwEmID);
135  }
136  inline void fill(const PFRegion &region, const HadCaloObj &src, pt_t puppiPt, puppiWgt_t puppiWgt) {
137  hwEta = region.hwGlbEta(src.hwEta);
138  hwPhi = region.hwGlbPhi(src.hwPhi);
140  hwPt = puppiPt;
141  hwData = 0;
142  setHwPuppiW(puppiWgt);
143  setHwEmID(src.hwEmID);
144  }
145 
146  int intPt() const { return Scales::intPt(hwPt); }
147  int intEta() const { return hwEta.to_int(); }
148  int intPhi() const { return hwPhi.to_int(); }
149  float floatPt() const { return Scales::floatPt(hwPt); }
150  float floatEta() const { return Scales::floatEta(hwEta); }
151  float floatPhi() const { return Scales::floatPhi(hwPhi); }
152  int intId() const { return hwId.rawId(); }
153  int pdgId() const { return hwId.pdgId(); }
154  int oldId() const { return hwPt > 0 ? hwId.oldId() : 0; }
155  int intCharge() const { return hwId.intCharge(); }
156  float floatZ0() const { return Scales::floatZ0(hwZ0()); }
157  float floatDxy() const { return Scales::floatDxy(hwDxy()); }
158  float floatPuppiW() const { return hwId.neutral() ? Scales::floatPuppiW(hwPuppiW()) : 1.0f; }
159 
161  inline ap_uint<BITWIDTH> pack() const {
162  ap_uint<BITWIDTH> ret;
163  unsigned int start = 0;
169  return ret;
170  }
171  inline void initFromBits(const ap_uint<BITWIDTH> &src) {
172  unsigned int start = 0;
178  }
179  inline static PuppiObj unpack(const ap_uint<BITWIDTH> &src) {
180  PuppiObj ret;
181  ret.initFromBits(src);
182  return ret;
183  }
184  };
185  inline void clear(PuppiObj &c) { c.clear(); }
186 
187 } // namespace l1ct
188 
189 #endif
void clear()
Definition: puppi.h:109
int intPt() const
Definition: puppi.h:146
int intCharge() const
Definition: puppi.h:155
Definition: start.py:1
bool operator<(const PuppiObj &other) const
Definition: puppi.h:107
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:151
float floatZ0(z0_t z0)
Definition: datatypes.h:170
int intEta() const
Definition: puppi.h:147
static const int BITWIDTH
Definition: puppi.h:160
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:149
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
void setHwPuppiW(puppiWgt_t w)
Definition: puppi.h:80
assert(be >=bs)
puppiWgt_t hwEmID() const
Definition: puppi.h:87
int oldId() const
Definition: puppi.h:154
void fill(const PFRegion &region, const PFNeutralObj &src, pt_t puppiPt, puppiWgt_t puppiWgt)
Definition: puppi.h:127
static const int BITS_DXY_START
Definition: puppi.h:18
int intPhi() const
Definition: puppi.h:148
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:150
int oldId() const
Definition: datatypes.h:116
bool charged() const
Definition: datatypes.h:82
ap_uint< BITWIDTH > pack() const
Definition: puppi.h:161
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:179
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
ap_uint< 9 > puppiWgt_t
Definition: datatypes.h:24
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:156
glbphi_t hwPhi
Definition: puppi.h:14
float floatDxy() const
Definition: puppi.h:157
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:94
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:171
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:136
bool operator==(const PuppiObj &other) const
Definition: puppi.h:101
int pdgId() const
Definition: puppi.h:153
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:117
float floatPuppiW() const
Definition: puppi.h:158
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:106
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:152
ap_int< 12 > glbeta_t
Definition: datatypes.h:18
puppiWgt_t hwPuppiW() const
Definition: puppi.h:73
Definition: datatypes.h:8