CMS 3D CMS Logo

egamma.h
Go to the documentation of this file.
1 #ifndef DataFormats_L1TParticleFlow_egamma_h
2 #define DataFormats_L1TParticleFlow_egamma_h
3 
7 
8 namespace l1ct {
9 
10  struct EGIsoObj {
12  glbeta_t hwEta; // at calo face
16 
17  int intPt() const { return Scales::intPt(hwPt); }
18  int intEta() const { return hwEta.to_int(); }
19  int intPhi() const { return hwPhi.to_int(); }
20  int intQual() const { return hwQual.to_int(); }
21  int intIso() const { return hwIso.to_int(); }
22 
23  float floatPt() const { return Scales::floatPt(hwPt); }
24  float floatEta() const { return Scales::floatEta(hwEta); }
25  float floatPhi() const { return Scales::floatPhi(hwPhi); }
26  float floatIso() const { return Scales::floatIso(hwIso); }
27 
28  inline bool operator==(const EGIsoObj &other) const {
29  return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi && hwQual == other.hwQual &&
30  hwIso == other.hwIso;
31  }
32 
33  inline bool operator>(const EGIsoObj &other) const { return hwPt > other.hwPt; }
34  inline bool operator<(const EGIsoObj &other) const { return hwPt < other.hwPt; }
35 
36  inline void clear() {
37  hwPt = 0;
38  hwEta = 0;
39  hwPhi = 0;
40  hwQual = 0;
41  hwIso = 0;
42  }
43 
45  inline ap_uint<BITWIDTH> pack() const {
46  ap_uint<BITWIDTH> ret;
47  unsigned int start = 0;
53  return ret;
54  }
55  inline static EGIsoObj unpack(const ap_uint<BITWIDTH> &src) {
56  EGIsoObj ret;
57  ret.initFromBits(src);
58  return ret;
59  }
60 
61  inline void initFromBits(const ap_uint<BITWIDTH> &src) {
62  unsigned int start = 0;
68  }
69 
70  l1gt::Photon toGT() const {
71  l1gt::Photon pho;
72  pho.valid = hwPt != 0;
73  pho.v3.pt = CTtoGT_pt(hwPt);
74  pho.v3.phi = CTtoGT_phi(hwPhi);
75  pho.v3.eta = CTtoGT_eta(hwEta);
76  pho.qualityFlags = hwQual;
77  pho.isolationPT = hwIso;
78  return pho;
79  }
80  };
81 
82  inline void clear(EGIsoObj &c) { c.clear(); }
83 
84  struct EGIsoEleObj : public EGIsoObj {
85  // WARNING: for whatever reason, maybe connected with datamember alignment,
86  // in 2019.2 synthesis fails if DEta & DPhi are put before Z0 & Dxy
91  bool hwCharge;
92 
93  glbphi_t hwVtxPhi() const { return hwCharge ? hwPhi + hwDPhi : hwPhi - hwDPhi; }
94  glbeta_t hwVtxEta() const { return hwEta + hwDEta; }
95 
96  inline bool operator==(const EGIsoEleObj &other) const {
97  return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi && hwQual == other.hwQual &&
98  hwIso == other.hwIso && hwDEta == other.hwDEta && hwDPhi == other.hwDPhi && hwZ0 == other.hwZ0 &&
99  hwIDScore == other.hwIDScore && hwCharge == other.hwCharge;
100  }
101 
102  inline bool operator>(const EGIsoEleObj &other) const { return hwPt > other.hwPt; }
103  inline bool operator<(const EGIsoEleObj &other) const { return hwPt < other.hwPt; }
104 
105  inline void clear() {
106  hwPt = 0;
107  hwEta = 0;
108  hwPhi = 0;
109  hwQual = 0;
110  hwIso = 0;
111  hwDEta = 0;
112  hwDPhi = 0;
113  hwZ0 = 0;
114  hwIDScore = 0;
115  hwCharge = false;
116  }
117 
118  int intCharge() const { return hwCharge ? +1 : -1; }
119  float floatDEta() const { return Scales::floatEta(hwDEta); }
120  float floatDPhi() const { return Scales::floatPhi(hwDPhi); }
121  float floatVtxEta() const { return Scales::floatEta(hwVtxEta()); }
122  float floatVtxPhi() const { return Scales::floatPhi(hwVtxPhi()); }
123  float floatZ0() const { return Scales::floatZ0(hwZ0); }
124  float floatIDScore() const { return Scales::floatIDScore(hwIDScore); }
125 
126  static const int BITWIDTH =
128  inline ap_uint<BITWIDTH> pack() const {
129  ap_uint<BITWIDTH> ret;
130  unsigned int start = 0;
141  return ret;
142  }
143  inline static EGIsoEleObj unpack(const ap_uint<BITWIDTH> &src) {
145  ret.initFromBits(src);
146  return ret;
147  }
148 
149  inline void initFromBits(const ap_uint<BITWIDTH> &src) {
150  unsigned int start = 0;
161  }
162 
164  l1gt::Electron ele;
165  ele.valid = hwPt != 0;
166  ele.v3.pt = CTtoGT_pt(hwPt);
167  ele.v3.phi = CTtoGT_phi(hwVtxPhi());
168  ele.v3.eta = CTtoGT_eta(hwVtxEta());
169  ele.qualityFlags = hwQual;
170  // NOTE: GT: 0 = positive, 1 = negative, CT: 0 = negative, 1 = positive
171  ele.charge = (!hwCharge) & ele.valid;
172  ele.z0(l1ct::z0_t::width - 1, 0) = hwZ0(l1ct::z0_t::width - 1, 0);
173  ele.isolationPT = hwIso;
174  return ele;
175  }
176  };
177 
178  inline void clear(EGIsoEleObj &c) { c.clear(); }
179 } // namespace l1ct
180 #endif
Definition: start.py:1
float floatVtxPhi() const
Definition: egamma.h:122
egquality_t qualityFlags
Definition: gt_datatypes.h:312
glbphi_t hwVtxPhi() const
Definition: egamma.h:93
l1gt::Electron toGT() const
Definition: egamma.h:163
tkdeta_t hwDEta
Definition: egamma.h:88
float floatDEta() const
Definition: egamma.h:119
float floatZ0(z0_t z0)
Definition: datatypes.h:170
ret
prodAgent to be discontinued
l1gt::eta_t CTtoGT_eta(glbeta_t x)
Definition: gt_datatypes.h:371
void clear()
Definition: egamma.h:36
bool operator>(const EGIsoObj &other) const
Definition: egamma.h:33
ap_uint< BITWIDTH > pack() const
Definition: egamma.h:45
float floatIDScore(id_score_t score)
Definition: datatypes.h:177
float floatIDScore() const
Definition: egamma.h:124
pt_t hwPt
Definition: egamma.h:11
void unpack_bool_from_bits(const U &u, unsigned int &start, bool &data)
Definition: bit_encoding.h:27
iso_t isolationPT
Definition: gt_datatypes.h:313
int intCharge() const
Definition: egamma.h:118
bool operator<(const EGIsoObj &other) const
Definition: egamma.h:34
float floatEta() const
Definition: egamma.h:24
float floatVtxEta() const
Definition: egamma.h:121
int intIso() const
Definition: egamma.h:21
ap_int< 11 > glbphi_t
Definition: datatypes.h:19
float floatZ0() const
Definition: egamma.h:123
float floatDPhi() const
Definition: egamma.h:120
float floatPt() const
Definition: egamma.h:23
int intPt() const
Definition: egamma.h:17
bool operator<(const EGIsoEleObj &other) const
Definition: egamma.h:103
float floatEta(eta_t eta)
Definition: datatypes.h:164
ap_int< 6 > tkdeta_t
Definition: datatypes.h:16
static const int BITWIDTH
Definition: egamma.h:126
ap_ufixed< 11, 9, AP_TRN, AP_SAT > iso_t
Definition: datatypes.h:39
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:153
static const int BITWIDTH
Definition: egamma.h:44
ap_uint< BITWIDTH > pack() const
Definition: egamma.h:128
void initFromBits(const ap_uint< BITWIDTH > &src)
Definition: egamma.h:149
static EGIsoEleObj unpack(const ap_uint< BITWIDTH > &src)
Definition: egamma.h:143
ap_fixed< 10, 1, AP_RND_CONV, AP_SAT > id_score_t
Definition: datatypes.h:36
egquality_t qualityFlags
Definition: gt_datatypes.h:260
l1gt::Photon toGT() const
Definition: egamma.h:70
bool operator>(const EGIsoEleObj &other) const
Definition: egamma.h:102
glbeta_t hwVtxEta() const
Definition: egamma.h:94
glbeta_t hwEta
Definition: egamma.h:12
ThreeVector v3
Definition: gt_datatypes.h:259
float floatIso() const
Definition: egamma.h:26
ap_int< 10 > z0_t
Definition: datatypes.h:21
tkdphi_t hwDPhi
Definition: egamma.h:89
float floatPhi() const
Definition: egamma.h:25
int intPt(pt_t pt)
Definition: datatypes.h:156
ap_ufixed< 14, 12, AP_TRN, AP_SAT > pt_t
Definition: datatypes.h:10
int intPhi() const
Definition: egamma.h:19
void initFromBits(const ap_uint< BITWIDTH > &src)
Definition: egamma.h:61
int intQual() const
Definition: egamma.h:20
ThreeVector v3
Definition: gt_datatypes.h:311
valid_t valid
Definition: gt_datatypes.h:310
bool operator==(const EGIsoEleObj &other) const
Definition: egamma.h:96
l1gt::phi_t CTtoGT_phi(glbphi_t x)
Definition: gt_datatypes.h:376
egquality_t hwQual
Definition: egamma.h:14
ap_uint< 7 > tkdphi_t
Definition: datatypes.h:17
void clear()
Definition: egamma.h:105
int intEta() const
Definition: egamma.h:18
bool operator==(const EGIsoObj &other) const
Definition: egamma.h:28
ap_uint< 1 > charge
Definition: gt_datatypes.h:261
float floatPhi(phi_t phi)
Definition: datatypes.h:165
void unpack_from_bits(const U &u, unsigned int &start, T &data)
Definition: bit_encoding.h:15
l1gt::pt_t CTtoGT_pt(pt_t x)
Definition: gt_datatypes.h:365
void clear(EGIsoObj &c)
Definition: egamma.h:82
glbphi_t hwPhi
Definition: egamma.h:13
float floatIso(iso_t iso)
Definition: datatypes.h:173
ap_uint< 4 > egquality_t
Definition: datatypes.h:30
ap_int< 12 > glbeta_t
Definition: datatypes.h:18
id_score_t hwIDScore
Definition: egamma.h:90
iso_t hwIso
Definition: egamma.h:15
void pack_bool_into_bits(U &u, unsigned int &start, bool data)
Definition: bit_encoding.h:22
static EGIsoObj unpack(const ap_uint< BITWIDTH > &src)
Definition: egamma.h:55
Definition: datatypes.h:8