CMS 3D CMS Logo

pf.h
Go to the documentation of this file.
1 #ifndef DataFormats_L1TParticleFlow_pf_h
2 #define DataFormats_L1TParticleFlow_pf_h
3 
6 
7 namespace l1ct {
8 
9  struct PFCommonObj {
11  eta_t hwEta; // relative to the region center, at calo
12  phi_t hwPhi; // relative to the region center, at calo
14 
15  int intPt() const { return Scales::intPt(hwPt); }
16  int intEta() const { return hwEta.to_int(); }
17  int intPhi() const { return hwPhi.to_int(); }
18  float floatPt() const { return Scales::floatPt(hwPt); }
19  float floatEta() const { return Scales::floatEta(hwEta); }
20  float floatPhi() const { return Scales::floatPhi(hwPhi); }
21  int intId() const { return hwId.rawId(); }
22  int oldId() const { return hwPt > 0 ? hwId.oldId() : 0; }
23  int pdgId() const { return hwId.pdgId(); }
24  int intCharge() const { return hwId.intCharge(); }
25 
27  template <typename U>
28  inline void pack_common(U &out, unsigned int &start) const {
33  }
34  template <typename U>
35  inline void unpack_common(const U &src, unsigned int &start) {
40  }
41  };
42 
43  struct PFChargedObj : public PFCommonObj {
44  // WARNING: for whatever reason, maybe connected with datamember alignment,
45  // in 2019.2 synthesis fails if DEta & DPhi are put before Z0 & Dxy
48  tkdeta_t hwDEta; // relative to the region center, at calo
49  tkdphi_t hwDPhi; // relative to the region center, at calo
51 
52  phi_t hwVtxPhi() const { return hwId.chargeOrNull() ? hwPhi + hwDPhi : hwPhi - hwDPhi; }
53  eta_t hwVtxEta() const { return hwEta + hwDEta; }
54 
55  inline bool operator==(const PFChargedObj &other) const {
56  return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi && hwId == other.hwId &&
57  hwDEta == other.hwDEta && hwDPhi == other.hwDPhi && hwZ0 == other.hwZ0 && hwDxy == other.hwDxy &&
58  hwTkQuality == other.hwTkQuality;
59  }
60 
61  inline bool operator>(const PFChargedObj &other) const { return hwPt > other.hwPt; }
62  inline bool operator<(const PFChargedObj &other) const { return hwPt < other.hwPt; }
63 
64  inline void clear() {
65  hwPt = 0;
66  hwEta = 0;
67  hwPhi = 0;
68  hwId.clear();
69  hwDEta = 0;
70  hwDPhi = 0;
71  hwZ0 = 0;
72  hwDxy = 0;
73  hwTkQuality = 0;
74  }
75 
76  int intVtxEta() const { return hwVtxEta().to_int(); }
77  int intVtxPhi() const { return hwVtxPhi().to_int(); }
78  float floatDEta() const { return Scales::floatEta(hwDEta); }
79  float floatDPhi() const { return Scales::floatPhi(hwDPhi); }
80  float floatVtxEta() const { return Scales::floatEta(hwVtxEta()); }
81  float floatVtxPhi() const { return Scales::floatPhi(hwVtxPhi()); }
82  float floatZ0() const { return Scales::floatZ0(hwZ0); }
83  float floatDxy() const { return Scales::floatDxy(hwDxy); }
84 
85  static const int BITWIDTH =
87  inline ap_uint<BITWIDTH> pack() const {
88  ap_uint<BITWIDTH> ret;
89  unsigned int start = 0;
96  return ret;
97  }
98  inline static PFChargedObj unpack(const ap_uint<BITWIDTH> &src) {
100  unsigned int start = 0;
101  ret.unpack_common(src, start);
102  unpack_from_bits(src, start, ret.hwDEta);
103  unpack_from_bits(src, start, ret.hwDPhi);
104  unpack_from_bits(src, start, ret.hwZ0);
105  unpack_from_bits(src, start, ret.hwDxy);
106  unpack_from_bits(src, start, ret.hwTkQuality);
107  return ret;
108  }
109  };
110  inline void clear(PFChargedObj &c) { c.clear(); }
111 
112  struct PFNeutralObj : public PFCommonObj {
115  ap_uint<6> hwPUID;
116 
117  inline bool operator==(const PFNeutralObj &other) const {
118  return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi && hwId == other.hwId &&
119  hwEmPt == other.hwEmPt && hwEmID == other.hwEmID && hwPUID == other.hwPUID;
120  }
121 
122  inline bool operator>(const PFNeutralObj &other) const { return hwPt > other.hwPt; }
123  inline bool operator<(const PFNeutralObj &other) const { return hwPt < other.hwPt; }
124 
125  inline void clear() {
126  hwPt = 0;
127  hwEta = 0;
128  hwPhi = 0;
129  hwId.clear();
130  hwEmPt = 0;
131  hwEmID = 0;
132  hwPUID = 0;
133  }
134 
135  int intEmPt() const { return Scales::intPt(hwEmPt); }
136  float floatEmPt() const { return Scales::floatPt(hwEmPt); }
137 
139  inline ap_uint<BITWIDTH> pack() const {
140  ap_uint<BITWIDTH> ret;
141  unsigned int start = 0;
146  return ret;
147  }
148  inline static PFNeutralObj unpack(const ap_uint<BITWIDTH> &src) {
150  unsigned int start = 0;
151  ret.unpack_common(src, start);
152  unpack_from_bits(src, start, ret.hwEmPt);
153  unpack_from_bits(src, start, ret.hwEmID);
154  unpack_from_bits(src, start, ret.hwPUID);
155  return ret;
156  }
157  };
158 
159  inline void clear(PFNeutralObj &c) { c.clear(); }
160 
161  struct PFRegion {
168 
169  inline int intEtaCenter() const { return hwEtaCenter.to_int(); }
170  inline int intPhiCenter() const { return hwPhiCenter.to_int(); }
171  inline float floatEtaCenter() const { return Scales::floatEta(hwEtaCenter); }
172  inline float floatPhiCenter() const { return Scales::floatPhi(hwPhiCenter); }
173  inline float floatEtaHalfWidth() const { return Scales::floatEta(hwEtaHalfWidth); }
174  inline float floatPhiHalfWidth() const { return Scales::floatPhi(hwPhiHalfWidth); }
175  inline float floatEtaExtra() const { return Scales::floatEta(hwEtaExtra); }
176  inline float floatPhiExtra() const { return Scales::floatPhi(hwPhiExtra); }
177  inline float floatPhiHalfWidthExtra() const { return floatPhiHalfWidth() + floatPhiExtra(); }
178  inline float floatEtaMin() const { return Scales::floatEta(glbeta_t(hwEtaCenter - hwEtaHalfWidth)); }
179  inline float floatEtaMax() const { return Scales::floatEta(glbeta_t(hwEtaCenter + hwEtaHalfWidth)); }
180  inline float floatEtaMinExtra() const {
182  }
183  inline float floatEtaMaxExtra() const {
185  }
186 
187  inline glbeta_t hwGlbEta(eta_t hwEta) const { return hwEtaCenter + hwEta; }
188  inline glbeta_t hwGlbEta(glbeta_t hwEta) const { return hwEtaCenter + hwEta; }
189  inline glbphi_t hwGlbPhi(glbphi_t hwPhi) const {
190  ap_int<glbphi_t::width + 1> ret = hwPhiCenter + hwPhi;
191  if (ret > Scales::INTPHI_PI)
192  return ret - Scales::INTPHI_TWOPI;
193  else if (ret <= -Scales::INTPHI_PI)
194  return ret + Scales::INTPHI_TWOPI;
195  else
196  return ret;
197  }
198 
199  template <typename T>
200  inline glbeta_t hwGlbEtaOf(const T &t) const {
201  return hwGlbEta(t.hwEta);
202  }
203  template <typename T>
204  inline glbphi_t hwGlbPhiOf(const T &t) const {
205  return hwGlbPhi(t.hwPhi);
206  }
207 
208  inline float floatGlbEta(eta_t hwEta) const { return Scales::floatEta(hwGlbEta(hwEta)); }
209  inline float floatGlbPhi(phi_t hwPhi) const { return Scales::floatPhi(hwGlbPhi(hwPhi)); }
210  inline float floatGlbEta(glbeta_t hwEta) const { return Scales::floatEta(hwGlbEta(hwEta)); }
211  inline float floatGlbPhi(glbphi_t hwPhi) const { return Scales::floatPhi(hwGlbPhi(hwPhi)); }
212 
213  template <typename T>
214  inline float floatGlbEtaOf(const T &t) const {
215  return floatGlbEta(t.hwEta);
216  }
217  template <typename T>
218  inline float floatGlbPhiOf(const T &t) const {
219  return floatGlbPhi(t.hwPhi);
220  }
221 
222  inline bool isFiducial(eta_t hwEta, phi_t hwPhi) const {
223  return hwEta <= hwEtaHalfWidth && hwEta > -hwEtaHalfWidth && hwPhi <= hwPhiHalfWidth && hwPhi > -hwPhiHalfWidth;
224  }
225  template <typename ET, typename PT> // forcing down to eta_t and phi_t may have overflows & crops
226  inline bool isInside(ET hwEta, PT hwPhi) const {
227  return hwEta <= hwEtaHalfWidth + hwEtaExtra && hwEta >= -hwEtaHalfWidth - hwEtaExtra &&
228  hwPhi <= hwPhiHalfWidth + hwPhiExtra && hwPhi >= -hwPhiHalfWidth - hwPhiExtra;
229  }
230 
231  template <typename T>
232  inline bool isFiducial(const T &t) const {
233  return isFiducial(t.hwEta, t.hwPhi);
234  }
235  template <typename T>
236  inline bool isInside(const T &t) const {
237  return isInside(t.hwEta, t.hwPhi);
238  }
239 
241  inline ap_uint<BITWIDTH> pack() const {
242  ap_uint<BITWIDTH> ret;
243  unsigned int start = 0;
250  return ret;
251  }
252  inline static PFRegion unpack(const ap_uint<BITWIDTH> &src) {
253  PFRegion ret;
254  unsigned int start = 0;
255  unpack_from_bits(src, start, ret.hwEtaCenter);
256  unpack_from_bits(src, start, ret.hwPhiCenter);
257  unpack_from_bits(src, start, ret.hwEtaHalfWidth);
258  unpack_from_bits(src, start, ret.hwPhiHalfWidth);
259  unpack_from_bits(src, start, ret.hwEtaExtra);
260  unpack_from_bits(src, start, ret.hwPhiExtra);
261  return ret;
262  }
263  };
264 
265 } // namespace l1ct
266 
267 #endif
int intId() const
Definition: pf.h:21
glbphi_t hwGlbPhi(glbphi_t hwPhi) const
Definition: pf.h:189
Definition: start.py:1
float floatGlbEtaOf(const T &t) const
Definition: pf.h:214
ap_uint< 3 > tkquality_t
Definition: datatypes.h:32
tkdeta_t hwDEta
Definition: pf.h:48
void unpack_common(const U &src, unsigned int &start)
Definition: pf.h:35
glbeta_t hwGlbEta(eta_t hwEta) const
Definition: pf.h:187
constexpr int INTPHI_PI
Definition: datatypes.h:149
float floatZ0(z0_t z0)
Definition: datatypes.h:172
bool operator>(const PFChargedObj &other) const
Definition: pf.h:61
eta_t hwEtaHalfWidth
Definition: pf.h:164
glbeta_t hwEtaCenter
Definition: pf.h:162
float floatEtaMinExtra() const
Definition: pf.h:180
bool isInside(ET hwEta, PT hwPhi) const
Definition: pf.h:226
int intPhi() const
Definition: pf.h:17
#define PT
int oldId() const
Definition: pf.h:22
void clear()
Definition: pf.h:64
bool operator<(const PFChargedObj &other) const
Definition: pf.h:62
ret
prodAgent to be discontinued
static const int BITWIDTH
Definition: pf.h:240
ap_int< 10 > phi_t
Definition: datatypes.h:24
static PFChargedObj unpack(const ap_uint< BITWIDTH > &src)
Definition: pf.h:98
float floatVtxEta() const
Definition: pf.h:80
void pack_common(U &out, unsigned int &start) const
Definition: pf.h:28
tkdphi_t hwDPhi
Definition: pf.h:49
int intEta() const
Definition: pf.h:16
eta_t hwEta
Definition: pf.h:11
int rawId() const
Definition: datatypes.h:70
float floatPhi() const
Definition: pf.h:20
float floatPhiExtra() const
Definition: pf.h:176
float floatGlbEta(eta_t hwEta) const
Definition: pf.h:208
float floatEtaExtra() const
Definition: pf.h:175
glbeta_t hwGlbEta(glbeta_t hwEta) const
Definition: pf.h:188
ParticleID hwId
Definition: pf.h:13
bool isInside(const T &t) const
Definition: pf.h:236
eta_t hwEtaExtra
Definition: pf.h:166
ap_uint< 6 > emid_t
Definition: datatypes.h:34
int intEtaCenter() const
Definition: pf.h:169
phi_t hwVtxPhi() const
Definition: pf.h:52
bool operator==(const PFNeutralObj &other) const
Definition: pf.h:117
float floatPhiHalfWidthExtra() const
Definition: pf.h:177
phi_t hwPhi
Definition: pf.h:12
tkquality_t hwTkQuality
Definition: pf.h:50
int oldId() const
Definition: datatypes.h:124
ap_int< 11 > glbphi_t
Definition: datatypes.h:28
float floatEtaCenter() const
Definition: pf.h:171
ap_int< 10 > eta_t
Definition: datatypes.h:23
z0_t hwZ0
Definition: pf.h:46
float floatEta(eta_t eta)
Definition: datatypes.h:166
ap_int< 6 > tkdeta_t
Definition: datatypes.h:25
int pdgId() const
Definition: datatypes.h:102
int intCharge() const
Definition: pf.h:24
float floatEtaMax() const
Definition: pf.h:179
float floatDxy(dxy_t dxy)
Definition: datatypes.h:173
float floatEtaHalfWidth() const
Definition: pf.h:173
void pack_into_bits(U &u, unsigned int &start, const T &data)
Definition: bit_encoding.h:8
int intPt() const
Definition: pf.h:15
float floatPt(pt_t pt)
Definition: datatypes.h:161
static const int BITWIDTH
Definition: pf.h:138
float floatVtxPhi() const
Definition: pf.h:81
static const int _PFCOMMON_BITWIDTH
Definition: pf.h:26
float floatGlbPhi(phi_t hwPhi) const
Definition: pf.h:209
bool operator<(const PFNeutralObj &other) const
Definition: pf.h:123
int intVtxEta() const
Definition: pf.h:76
float floatDPhi() const
Definition: pf.h:79
int intPhiCenter() const
Definition: pf.h:170
float floatZ0() const
Definition: pf.h:82
ap_int< 10 > z0_t
Definition: datatypes.h:30
ap_uint< 6 > hwPUID
Definition: pf.h:115
ap_uint< 3 > bits
Definition: datatypes.h:50
float floatPhiCenter() const
Definition: pf.h:172
float floatDEta() const
Definition: pf.h:78
int intPt(pt_t pt)
Definition: datatypes.h:164
glbphi_t hwPhiCenter
Definition: pf.h:163
ap_ufixed< 14, 12, AP_TRN, AP_SAT > pt_t
Definition: datatypes.h:19
int pdgId() const
Definition: pf.h:23
float floatEta() const
Definition: pf.h:19
ap_uint< BITWIDTH > pack() const
Definition: pf.h:139
bool isFiducial(const T &t) const
Definition: pf.h:232
float floatEmPt() const
Definition: pf.h:136
static PFRegion unpack(const ap_uint< BITWIDTH > &src)
Definition: pf.h:252
float floatPt() const
Definition: pf.h:18
bool isFiducial(eta_t hwEta, phi_t hwPhi) const
Definition: pf.h:222
ap_uint< BITWIDTH > pack() const
Definition: pf.h:241
void clear()
Definition: pf.h:125
float floatGlbPhi(glbphi_t hwPhi) const
Definition: pf.h:211
dxy_t hwDxy
Definition: pf.h:47
int intVtxPhi() const
Definition: pf.h:77
float floatGlbEta(glbeta_t hwEta) const
Definition: pf.h:210
ap_uint< BITWIDTH > pack() const
Definition: pf.h:87
float floatEtaMin() const
Definition: pf.h:178
int intCharge() const
Definition: datatypes.h:92
bool operator>(const PFNeutralObj &other) const
Definition: pf.h:122
ap_uint< 7 > tkdphi_t
Definition: datatypes.h:26
glbphi_t hwGlbPhiOf(const T &t) const
Definition: pf.h:204
constexpr int INTPHI_TWOPI
Definition: datatypes.h:150
static const int BITWIDTH
Definition: pf.h:85
pt_t hwEmPt
Definition: pf.h:113
static PFNeutralObj unpack(const ap_uint< BITWIDTH > &src)
Definition: pf.h:148
float floatPhi(phi_t phi)
Definition: datatypes.h:167
void unpack_from_bits(const U &u, unsigned int &start, T &data)
Definition: bit_encoding.h:15
#define ET
float floatPhiHalfWidth() const
Definition: pf.h:174
phi_t hwPhiExtra
Definition: pf.h:167
bool operator==(const PFChargedObj &other) const
Definition: pf.h:55
void clear(EGIsoObj &c)
Definition: egamma.h:82
glbeta_t hwGlbEtaOf(const T &t) const
Definition: pf.h:200
ap_int< 8 > dxy_t
Definition: datatypes.h:31
emid_t hwEmID
Definition: pf.h:114
long double T
pt_t hwPt
Definition: pf.h:10
int intEmPt() const
Definition: pf.h:135
float floatEtaMaxExtra() const
Definition: pf.h:183
ap_int< 12 > glbeta_t
Definition: datatypes.h:27
eta_t hwVtxEta() const
Definition: pf.h:53
float floatDxy() const
Definition: pf.h:83
float floatGlbPhiOf(const T &t) const
Definition: pf.h:218
phi_t hwPhiHalfWidth
Definition: pf.h:165
bool chargeOrNull() const
Definition: datatypes.h:87
Definition: datatypes.h:17