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.quality = hwQual;
77  pho.isolation = 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
88  tkdeta_t hwDEta; // relative to the region center, at calo
89  tkdphi_t hwDPhi; // relative to the region center, at calo
90  bool hwCharge;
91 
92  phi_t hwVtxPhi() const { return hwCharge ? hwPhi + hwDPhi : hwPhi - hwDPhi; }
93  eta_t hwVtxEta() const { return hwEta + hwDEta; }
94 
95  inline bool operator==(const EGIsoEleObj &other) const {
96  return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi && hwQual == other.hwQual &&
97  hwIso == other.hwIso && hwDEta == other.hwDEta && hwDPhi == other.hwDPhi && hwZ0 == other.hwZ0 &&
98  hwCharge == other.hwCharge;
99  }
100 
101  inline bool operator>(const EGIsoEleObj &other) const { return hwPt > other.hwPt; }
102  inline bool operator<(const EGIsoEleObj &other) const { return hwPt < other.hwPt; }
103 
104  inline void clear() {
105  hwPt = 0;
106  hwEta = 0;
107  hwPhi = 0;
108  hwQual = 0;
109  hwIso = 0;
110  hwDEta = 0;
111  hwDPhi = 0;
112  hwZ0 = 0;
113  hwCharge = false;
114  }
115 
116  int intCharge() const { return hwCharge ? +1 : -1; }
117  float floatDEta() const { return Scales::floatEta(hwDEta); }
118  float floatDPhi() const { return Scales::floatPhi(hwDPhi); }
119  float floatVtxEta() const { return Scales::floatEta(hwVtxEta()); }
120  float floatVtxPhi() const { return Scales::floatPhi(hwVtxPhi()); }
121  float floatZ0() const { return Scales::floatZ0(hwZ0); }
122 
124  inline ap_uint<BITWIDTH> pack() const {
125  ap_uint<BITWIDTH> ret;
126  unsigned int start = 0;
136  return ret;
137  }
138  inline static EGIsoEleObj unpack(const ap_uint<BITWIDTH> &src) {
140  ret.initFromBits(src);
141  return ret;
142  }
143 
144  inline void initFromBits(const ap_uint<BITWIDTH> &src) {
145  unsigned int start = 0;
155  }
156 
158  l1gt::Electron ele;
159  ele.valid = hwPt != 0;
160  ele.v3.pt = CTtoGT_pt(hwPt);
161  ele.v3.phi = CTtoGT_phi(hwPhi);
162  ele.v3.eta = CTtoGT_eta(hwEta);
163  ele.quality = hwQual;
164  ele.charge = hwCharge;
165  ele.z0 = hwZ0;
166  ele.isolation = hwIso;
167  return ele;
168  }
169  };
170 
171  inline void clear(EGIsoEleObj &c) { c.clear(); }
172 } // namespace l1ct
173 #endif
Definition: start.py:1
float floatVtxPhi() const
Definition: egamma.h:120
egquality_t quality
Definition: gt_datatypes.h:212
l1gt::Electron toGT() const
Definition: egamma.h:157
tkdeta_t hwDEta
Definition: egamma.h:88
float floatDEta() const
Definition: egamma.h:117
float floatZ0(z0_t z0)
Definition: datatypes.h:163
ret
prodAgent to be discontinued
l1gt::eta_t CTtoGT_eta(glbeta_t x)
Definition: gt_datatypes.h:264
ap_int< 10 > phi_t
Definition: datatypes.h:26
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
eta_t hwVtxEta() const
Definition: egamma.h:93
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
int intCharge() const
Definition: egamma.h:116
bool operator<(const EGIsoObj &other) const
Definition: egamma.h:34
float floatEta() const
Definition: egamma.h:24
float floatVtxEta() const
Definition: egamma.h:119
int intIso() const
Definition: egamma.h:21
ap_int< 11 > glbphi_t
Definition: datatypes.h:30
float floatZ0() const
Definition: egamma.h:121
float floatDPhi() const
Definition: egamma.h:118
float floatPt() const
Definition: egamma.h:23
int intPt() const
Definition: egamma.h:17
ap_int< 10 > eta_t
Definition: datatypes.h:25
bool operator<(const EGIsoEleObj &other) const
Definition: egamma.h:102
float floatEta(eta_t eta)
Definition: datatypes.h:157
ap_int< 6 > tkdeta_t
Definition: datatypes.h:27
static const int BITWIDTH
Definition: egamma.h:123
ap_ufixed< 11, 9, AP_TRN, AP_SAT > iso_t
Definition: datatypes.h:43
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:152
static const int BITWIDTH
Definition: egamma.h:44
ap_uint< BITWIDTH > pack() const
Definition: egamma.h:124
void initFromBits(const ap_uint< BITWIDTH > &src)
Definition: egamma.h:144
static EGIsoEleObj unpack(const ap_uint< BITWIDTH > &src)
Definition: egamma.h:138
l1gt::Photon toGT() const
Definition: egamma.h:70
bool operator>(const EGIsoEleObj &other) const
Definition: egamma.h:101
glbeta_t hwEta
Definition: egamma.h:12
ThreeVector v3
Definition: gt_datatypes.h:211
phi_t hwVtxPhi() const
Definition: egamma.h:92
float floatIso() const
Definition: egamma.h:26
ap_int< 10 > z0_t
Definition: datatypes.h:32
tkdphi_t hwDPhi
Definition: egamma.h:89
float floatPhi() const
Definition: egamma.h:25
int intPt(pt_t pt)
Definition: datatypes.h:155
ap_ufixed< 14, 12, AP_TRN, AP_SAT > pt_t
Definition: datatypes.h:21
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:233
valid_t valid
Definition: gt_datatypes.h:232
bool operator==(const EGIsoEleObj &other) const
Definition: egamma.h:95
l1gt::phi_t CTtoGT_phi(glbphi_t x)
Definition: gt_datatypes.h:269
egquality_t hwQual
Definition: egamma.h:14
ap_uint< 7 > tkdphi_t
Definition: datatypes.h:28
void clear()
Definition: egamma.h:104
egquality_t quality
Definition: gt_datatypes.h:234
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:213
float floatPhi(phi_t phi)
Definition: datatypes.h:158
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:258
void clear(EGIsoObj &c)
Definition: egamma.h:82
glbphi_t hwPhi
Definition: egamma.h:13
float floatIso(iso_t iso)
Definition: datatypes.h:166
ap_uint< 4 > egquality_t
Definition: datatypes.h:41
ap_int< 12 > glbeta_t
Definition: datatypes.h:29
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:19