CMS 3D CMS Logo

layer1_objs.h
Go to the documentation of this file.
1 #ifndef DataFormats_L1TParticleFlow_layer1_objs_h
2 #define DataFormats_L1TParticleFlow_layer1_objs_h
3 
6 
7 namespace l1ct {
8 
9  struct HadCaloObj {
11  eta_t hwEta; // relative to the region center, at calo
12  phi_t hwPhi; // relative to the region center, at calo
15 
16  inline bool operator==(const HadCaloObj &other) const {
17  return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi && hwEmPt == other.hwEmPt &&
18  hwEmID == other.hwEmID;
19  }
20 
21  inline bool operator>(const HadCaloObj &other) const { return hwPt > other.hwPt; }
22  inline bool operator<(const HadCaloObj &other) const { return hwPt < other.hwPt; }
23 
24  inline void clear() {
25  hwPt = 0;
26  hwEta = 0;
27  hwPhi = 0;
28  hwEmPt = 0;
29  hwEmID = 0;
30  }
31 
32  int intPt() const { return Scales::intPt(hwPt); }
33  int intEmPt() const { return Scales::intPt(hwEmPt); }
34  int intEta() const { return hwEta.to_int(); }
35  int intPhi() const { return hwPhi.to_int(); }
36  float floatPt() const { return Scales::floatPt(hwPt); }
37  float floatEmPt() const { return Scales::floatPt(hwEmPt); }
38  float floatEta() const { return Scales::floatEta(hwEta); }
39  float floatPhi() const { return Scales::floatPhi(hwPhi); }
40 
41  bool hwIsEM() const { return hwEmID != 0; }
42 
44  inline ap_uint<BITWIDTH> pack() const {
45  ap_uint<BITWIDTH> ret;
46  unsigned int start = 0;
52  return ret;
53  }
54  inline static HadCaloObj unpack(const ap_uint<BITWIDTH> &src) {
56  unsigned int start = 0;
57  unpack_from_bits(src, start, ret.hwPt);
58  unpack_from_bits(src, start, ret.hwEta);
59  unpack_from_bits(src, start, ret.hwPhi);
60  unpack_from_bits(src, start, ret.hwEmPt);
61  unpack_from_bits(src, start, ret.hwEmID);
62  return ret;
63  }
64  };
65 
66  inline void clear(HadCaloObj &c) { c.clear(); }
67 
68  struct EmCaloObj {
70  eta_t hwEta; // relative to the region center, at calo
71  phi_t hwPhi; // relative to the region center, at calo
73 
74  inline bool operator==(const EmCaloObj &other) const {
75  return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi && hwPtErr == other.hwPtErr &&
76  hwEmID == other.hwEmID;
77  }
78 
79  inline bool operator>(const EmCaloObj &other) const { return hwPt > other.hwPt; }
80  inline bool operator<(const EmCaloObj &other) const { return hwPt < other.hwPt; }
81 
82  inline void clear() {
83  hwPt = 0;
84  hwPtErr = 0;
85  hwEta = 0;
86  hwPhi = 0;
87  hwEmID = 0;
88  }
89 
90  int intPt() const { return Scales::intPt(hwPt); }
91  int intPtErr() const { return Scales::intPt(hwPtErr); }
92  int intEta() const { return hwEta.to_int(); }
93  int intPhi() const { return hwPhi.to_int(); }
94  float floatPt() const { return Scales::floatPt(hwPt); }
95  float floatPtErr() const { return Scales::floatPt(hwPtErr); }
96  float floatEta() const { return Scales::floatEta(hwEta); }
97  float floatPhi() const { return Scales::floatPhi(hwPhi); }
98 
100  inline ap_uint<BITWIDTH> pack() const {
101  ap_uint<BITWIDTH> ret;
102  unsigned int start = 0;
108  return ret;
109  }
110  inline static EmCaloObj unpack(const ap_uint<BITWIDTH> &src) {
111  EmCaloObj ret;
112  unsigned int start = 0;
113  unpack_from_bits(src, start, ret.hwPt);
114  unpack_from_bits(src, start, ret.hwEta);
115  unpack_from_bits(src, start, ret.hwPhi);
116  unpack_from_bits(src, start, ret.hwPtErr);
117  unpack_from_bits(src, start, ret.hwEmID);
118  return ret;
119  }
120  };
121  inline void clear(EmCaloObj &c) { c.clear(); }
122 
123  struct TkObj {
125  eta_t hwEta; // relative to the region center, at calo
126  phi_t hwPhi; // relative to the region center, at calo
127  tkdeta_t hwDEta; // vtx - calo
128  tkdphi_t hwDPhi; // |vtx - calo| (sign is derived by the charge)
129  bool hwCharge; // 1 = positive, 0 = negative
133 
134  enum TkQuality { PFLOOSE = 1, PFTIGHT = 2 };
135  bool isPFLoose() const { return hwQuality[0]; }
136  bool isPFTight() const { return hwQuality[1]; }
137  phi_t hwVtxPhi() const { return hwCharge ? hwPhi + hwDPhi : hwPhi - hwDPhi; }
138  eta_t hwVtxEta() const { return hwEta + hwDEta; }
139 
140  inline bool operator==(const TkObj &other) const {
141  return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi && hwDEta == other.hwDEta &&
142  hwDPhi == other.hwDPhi && hwZ0 == other.hwZ0 && hwDxy == other.hwDxy && hwCharge == other.hwCharge &&
143  hwQuality == other.hwQuality;
144  }
145 
146  inline bool operator>(const TkObj &other) const { return hwPt > other.hwPt; }
147  inline bool operator<(const TkObj &other) const { return hwPt < other.hwPt; }
148 
149  inline void clear() {
150  hwPt = 0;
151  hwEta = 0;
152  hwPhi = 0;
153  hwDEta = 0;
154  hwDPhi = 0;
155  hwZ0 = 0;
156  hwDxy = 0;
157  hwCharge = false;
158  hwQuality = 0;
159  }
160 
161  int intPt() const { return Scales::intPt(hwPt); }
162  int intEta() const { return hwEta.to_int(); }
163  int intPhi() const { return hwPhi.to_int(); }
164  int intVtxEta() const { return hwVtxEta().to_int(); }
165  int intVtxPhi() const { return hwVtxPhi().to_int(); }
166  int intCharge() const { return hwCharge ? +1 : -1; }
167  float floatPt() const { return Scales::floatPt(hwPt); }
168  float floatEta() const { return Scales::floatEta(hwEta); }
169  float floatPhi() const { return Scales::floatPhi(hwPhi); }
170  float floatDEta() const { return Scales::floatEta(hwDEta); }
171  float floatDPhi() const { return Scales::floatPhi(hwDPhi); }
172  float floatVtxEta() const { return Scales::floatEta(hwVtxEta()); }
173  float floatVtxPhi() const { return Scales::floatPhi(hwVtxPhi()); }
174  float floatZ0() const { return Scales::floatZ0(hwZ0); }
175  float floatDxy() const { return Scales::floatDxy(hwDxy); }
176 
179  inline ap_uint<BITWIDTH> pack() const {
180  ap_uint<BITWIDTH> ret;
181  unsigned int start = 0;
191  return ret;
192  }
193  inline static TkObj unpack(const ap_uint<BITWIDTH> &src) {
194  TkObj ret;
195  unsigned int start = 0;
196  unpack_from_bits(src, start, ret.hwPt);
197  unpack_from_bits(src, start, ret.hwEta);
198  unpack_from_bits(src, start, ret.hwPhi);
199  unpack_from_bits(src, start, ret.hwDEta);
200  unpack_from_bits(src, start, ret.hwDPhi);
201  unpack_bool_from_bits(src, start, ret.hwCharge);
202  unpack_from_bits(src, start, ret.hwZ0);
203  unpack_from_bits(src, start, ret.hwDxy);
204  unpack_from_bits(src, start, ret.hwQuality);
205  return ret;
206  }
207  };
208  inline void clear(TkObj &c) { c.clear(); }
209 
210  struct MuObj {
212  glbeta_t hwEta; // relative to the region center, at calo
213  glbphi_t hwPhi; // relative to the region center, at calo
214  tkdeta_t hwDEta; // vtx - calo
215  tkdphi_t hwDPhi; // |vtx - calo| (sign is derived by the charge)
216  bool hwCharge; // 1 = positive, 0 = negative
219  ap_uint<3> hwQuality;
220  glbphi_t hwVtxPhi() const { return hwCharge ? hwPhi + hwDPhi : hwPhi - hwDPhi; }
221  glbeta_t hwVtxEta() const { return hwEta + hwDEta; }
222 
223  inline bool operator==(const MuObj &other) const {
224  return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi && hwDEta == other.hwDEta &&
225  hwDPhi == other.hwDPhi && hwZ0 == other.hwZ0 && hwDxy == other.hwDxy && hwCharge == other.hwCharge &&
226  hwQuality == other.hwQuality;
227  }
228 
229  inline bool operator>(const MuObj &other) const { return hwPt > other.hwPt; }
230  inline bool operator<(const MuObj &other) const { return hwPt < other.hwPt; }
231 
232  inline void clear() {
233  hwPt = 0;
234  hwEta = 0;
235  hwPhi = 0;
236  hwDEta = 0;
237  hwDPhi = 0;
238  hwZ0 = 0;
239  hwDxy = 0;
240  hwCharge = false;
241  hwQuality = 0;
242  }
243 
244  int intPt() const { return Scales::intPt(hwPt); }
245  int intEta() const { return hwEta.to_int(); }
246  int intPhi() const { return hwPhi.to_int(); }
247  int intVtxEta() const { return hwVtxEta().to_int(); }
248  int intVtxPhi() const { return hwVtxPhi().to_int(); }
249  int intCharge() const { return hwCharge ? +1 : -1; }
250  float floatPt() const { return Scales::floatPt(hwPt); }
251  float floatEta() const { return Scales::floatEta(hwEta); }
252  float floatPhi() const { return Scales::floatPhi(hwPhi); }
253  float floatDEta() const { return Scales::floatEta(hwDEta); }
254  float floatDPhi() const { return Scales::floatPhi(hwDPhi); }
255  float floatVtxEta() const { return Scales::floatEta(hwVtxEta()); }
256  float floatVtxPhi() const { return Scales::floatPhi(hwVtxPhi()); }
257  float floatZ0() const { return Scales::floatZ0(hwZ0); }
258  float floatDxy() const { return Scales::floatDxy(hwDxy); }
259 
262  inline ap_uint<BITWIDTH> pack() const {
263  ap_uint<BITWIDTH> ret;
264  unsigned int start = 0;
274  return ret;
275  }
276  inline static MuObj unpack(const ap_uint<BITWIDTH> &src) {
277  MuObj ret;
278  unsigned int start = 0;
279  unpack_from_bits(src, start, ret.hwPt);
280  unpack_from_bits(src, start, ret.hwEta);
281  unpack_from_bits(src, start, ret.hwPhi);
282  unpack_from_bits(src, start, ret.hwDEta);
283  unpack_from_bits(src, start, ret.hwDPhi);
284  unpack_bool_from_bits(src, start, ret.hwCharge);
285  unpack_from_bits(src, start, ret.hwZ0);
286  unpack_from_bits(src, start, ret.hwDxy);
287  unpack_from_bits(src, start, ret.hwQuality);
288  return ret;
289  }
290  };
291  inline void clear(MuObj &c) { c.clear(); }
292 
293  struct PVObj {
295 
296  inline bool operator==(const PVObj &other) const { return hwZ0 == other.hwZ0; }
297 
298  inline void clear() { hwZ0 = 0; }
299 
300  float floatZ0() const { return Scales::floatZ0(hwZ0); }
301 
302  static const int BITWIDTH = z0_t::width;
303  inline ap_uint<BITWIDTH> pack() const {
304  ap_uint<BITWIDTH> ret;
305  unsigned int start = 0;
307  return ret;
308  }
309  inline static PVObj unpack(const ap_uint<BITWIDTH> &src) {
310  PVObj ret;
311  unsigned int start = 0;
312  unpack_from_bits(src, start, ret.hwZ0);
313  return ret;
314  }
315  };
316  inline void clear(PVObj &c) { c.clear(); }
317 
318 } // namespace l1ct
319 
320 #endif
Definition: start.py:1
int intCharge() const
Definition: layer1_objs.h:249
static PVObj unpack(const ap_uint< BITWIDTH > &src)
Definition: layer1_objs.h:309
ap_uint< 3 > tkquality_t
Definition: datatypes.h:34
tkquality_t hwQuality
Definition: layer1_objs.h:132
float floatEta() const
Definition: layer1_objs.h:251
bool operator<(const HadCaloObj &other) const
Definition: layer1_objs.h:22
float floatZ0(z0_t z0)
Definition: datatypes.h:163
float floatZ0() const
Definition: layer1_objs.h:257
float floatZ0() const
Definition: layer1_objs.h:300
float floatPhi() const
Definition: layer1_objs.h:39
int intEta() const
Definition: layer1_objs.h:162
float floatPt() const
Definition: layer1_objs.h:167
bool operator<(const EmCaloObj &other) const
Definition: layer1_objs.h:80
bool operator==(const EmCaloObj &other) const
Definition: layer1_objs.h:74
ap_uint< BITWIDTH > pack() const
Definition: layer1_objs.h:179
bool operator>(const TkObj &other) const
Definition: layer1_objs.h:146
ret
prodAgent to be discontinued
ap_int< 10 > phi_t
Definition: datatypes.h:26
float floatPt() const
Definition: layer1_objs.h:36
float floatDxy() const
Definition: layer1_objs.h:258
bool operator==(const MuObj &other) const
Definition: layer1_objs.h:223
bool operator>(const HadCaloObj &other) const
Definition: layer1_objs.h:21
static HadCaloObj unpack(const ap_uint< BITWIDTH > &src)
Definition: layer1_objs.h:54
tkdphi_t hwDPhi
Definition: layer1_objs.h:215
int intPhi() const
Definition: layer1_objs.h:163
phi_t hwVtxPhi() const
Definition: layer1_objs.h:137
float floatEta() const
Definition: layer1_objs.h:168
void clear()
Definition: layer1_objs.h:149
void unpack_bool_from_bits(const U &u, unsigned int &start, bool &data)
Definition: bit_encoding.h:27
int intVtxPhi() const
Definition: layer1_objs.h:248
static const int BITWIDTH
Definition: layer1_objs.h:99
int intPhi() const
Definition: layer1_objs.h:93
float floatVtxPhi() const
Definition: layer1_objs.h:256
int intEta() const
Definition: layer1_objs.h:34
float floatDPhi() const
Definition: layer1_objs.h:171
ap_uint< 6 > emid_t
Definition: datatypes.h:36
bool operator>(const MuObj &other) const
Definition: layer1_objs.h:229
int intVtxPhi() const
Definition: layer1_objs.h:165
int intVtxEta() const
Definition: layer1_objs.h:164
glbphi_t hwVtxPhi() const
Definition: layer1_objs.h:220
float floatPtErr() const
Definition: layer1_objs.h:95
static const int BITWIDTH
Definition: layer1_objs.h:43
ap_int< 11 > glbphi_t
Definition: datatypes.h:30
bool operator==(const TkObj &other) const
Definition: layer1_objs.h:140
ap_int< 10 > eta_t
Definition: datatypes.h:25
bool operator<(const TkObj &other) const
Definition: layer1_objs.h:147
float floatEta(eta_t eta)
Definition: datatypes.h:157
ap_int< 6 > tkdeta_t
Definition: datatypes.h:27
ap_uint< BITWIDTH > pack() const
Definition: layer1_objs.h:262
float floatDxy(dxy_t dxy)
Definition: datatypes.h:164
static MuObj unpack(const ap_uint< BITWIDTH > &src)
Definition: layer1_objs.h:276
int intCharge() const
Definition: layer1_objs.h:166
void pack_into_bits(U &u, unsigned int &start, const T &data)
Definition: bit_encoding.h:8
void clear()
Definition: layer1_objs.h:298
int intEta() const
Definition: layer1_objs.h:245
bool isPFTight() const
Definition: layer1_objs.h:136
float floatPt(pt_t pt)
Definition: datatypes.h:152
int intPt() const
Definition: layer1_objs.h:161
float floatZ0() const
Definition: layer1_objs.h:174
float floatVtxEta() const
Definition: layer1_objs.h:172
float floatDxy() const
Definition: layer1_objs.h:175
int intPhi() const
Definition: layer1_objs.h:246
float floatPhi() const
Definition: layer1_objs.h:97
int intVtxEta() const
Definition: layer1_objs.h:247
bool operator==(const PVObj &other) const
Definition: layer1_objs.h:296
float floatPhi() const
Definition: layer1_objs.h:169
ap_uint< 3 > hwQuality
Definition: layer1_objs.h:219
ap_int< 10 > z0_t
Definition: datatypes.h:32
static const int BITWIDTH
Definition: layer1_objs.h:260
void clear()
Definition: layer1_objs.h:232
bool isPFLoose() const
Definition: layer1_objs.h:135
int intPt(pt_t pt)
Definition: datatypes.h:155
ap_uint< BITWIDTH > pack() const
Definition: layer1_objs.h:303
ap_ufixed< 14, 12, AP_TRN, AP_SAT > pt_t
Definition: datatypes.h:21
float floatDPhi() const
Definition: layer1_objs.h:254
glbeta_t hwVtxEta() const
Definition: layer1_objs.h:221
bool operator==(const HadCaloObj &other) const
Definition: layer1_objs.h:16
ap_uint< BITWIDTH > pack() const
Definition: layer1_objs.h:100
float floatPhi() const
Definition: layer1_objs.h:252
eta_t hwVtxEta() const
Definition: layer1_objs.h:138
int intPt() const
Definition: layer1_objs.h:244
float floatPt() const
Definition: layer1_objs.h:250
float floatVtxEta() const
Definition: layer1_objs.h:255
int intPhi() const
Definition: layer1_objs.h:35
static EmCaloObj unpack(const ap_uint< BITWIDTH > &src)
Definition: layer1_objs.h:110
bool operator>(const EmCaloObj &other) const
Definition: layer1_objs.h:79
bool operator<(const MuObj &other) const
Definition: layer1_objs.h:230
float floatDEta() const
Definition: layer1_objs.h:253
ap_uint< 7 > tkdphi_t
Definition: datatypes.h:28
tkdphi_t hwDPhi
Definition: layer1_objs.h:128
int intPt() const
Definition: layer1_objs.h:32
glbphi_t hwPhi
Definition: layer1_objs.h:213
static TkObj unpack(const ap_uint< BITWIDTH > &src)
Definition: layer1_objs.h:193
float floatPhi(phi_t phi)
Definition: datatypes.h:158
int intPtErr() const
Definition: layer1_objs.h:91
void unpack_from_bits(const U &u, unsigned int &start, T &data)
Definition: bit_encoding.h:15
float floatDEta() const
Definition: layer1_objs.h:170
int intPt() const
Definition: layer1_objs.h:90
void clear(EGIsoObj &c)
Definition: egamma.h:82
ap_int< 8 > dxy_t
Definition: datatypes.h:33
bool hwIsEM() const
Definition: layer1_objs.h:41
float floatEta() const
Definition: layer1_objs.h:96
ap_uint< BITWIDTH > pack() const
Definition: layer1_objs.h:44
float floatPt() const
Definition: layer1_objs.h:94
tkdeta_t hwDEta
Definition: layer1_objs.h:214
float floatVtxPhi() const
Definition: layer1_objs.h:173
static const int BITWIDTH
Definition: layer1_objs.h:302
static const int BITWIDTH
Definition: layer1_objs.h:177
int intEta() const
Definition: layer1_objs.h:92
float floatEta() const
Definition: layer1_objs.h:38
tkdeta_t hwDEta
Definition: layer1_objs.h:127
ap_int< 12 > glbeta_t
Definition: datatypes.h:29
float floatEmPt() const
Definition: layer1_objs.h:37
glbeta_t hwEta
Definition: layer1_objs.h:212
void pack_bool_into_bits(U &u, unsigned int &start, bool data)
Definition: bit_encoding.h:22
int intEmPt() const
Definition: layer1_objs.h:33
Definition: datatypes.h:19