@@ -27,6 +27,8 @@ namespace l1gt {
2727 // While bitwise identical to the l1ct::z0_t value, we store z0 in mm to profit of ap_fixed goodies
2828 typedef ap_fixed<10 , 9 , AP_RND_CONV, AP_SAT> z0_t ; // NOTE: mm instead of cm!!!
2929 typedef ap_ufixed<8 , 1 , AP_RND, AP_SAT> id_proba_t ; // for IDs bounded in range [0-1]
30+ typedef ap_ufixed<10 , 1 , AP_RND, AP_SAT> n_prong_score_t ;
31+ typedef ap_ufixed<17 , 15 , AP_RND_CONV, AP_SAT> mass2_t ;
3032 typedef ap_uint<1 > valid_t ;
3133
3234 // E/gamma fields
@@ -48,6 +50,7 @@ namespace l1gt {
4850 inline float floatEta (eta_t eta) { return eta.to_float () * ETAPHI_LSB; }
4951 inline float floatPhi (phi_t phi) { return phi.to_float () * ETAPHI_LSB; }
5052 inline float floatZ0 (z0_t z0) { return z0.to_float () * Z0_UNITS; }
53+ inline float floatMassSq (mass2_t massSq) { return massSq.to_float (); }
5154 } // namespace Scales
5255
5356 struct ThreeVector {
@@ -151,8 +154,90 @@ namespace l1gt {
151154 return unpack_ap (bits);
152155 }
153156
157+ inline static Jet unpack (const std::array<long long unsigned int , 2 > &src) {
158+ // unpack from two 64b ints
159+ ap_uint<BITWIDTH> bits;
160+ bits (63 , 0 ) = src[0 ];
161+ bits (127 , 64 ) = src[1 ];
162+ return unpack_ap (bits);
163+ }
164+
154165 }; // struct Jet
155166
167+ struct WideJet {
168+ valid_t valid;
169+ ThreeVector v3;
170+ z0_t z0;
171+ n_prong_score_t hwNProngScore;
172+ mass2_t hwMassSq;
173+
174+ inline bool operator ==(const WideJet &other) const {
175+ return valid == other.valid && z0 == other.z0 && hwNProngScore == other.hwNProngScore &&
176+ hwMassSq == other.hwMassSq && v3 == other.v3 ;
177+ }
178+
179+ static const int BITWIDTH = 128 ;
180+ inline ap_uint<BITWIDTH> pack_ap () const {
181+ ap_uint<BITWIDTH> ret = 0 ;
182+ unsigned int start = 0 ;
183+ pack_into_bits (ret, start, valid);
184+ pack_into_bits (ret, start, v3.pack ());
185+ pack_into_bits (ret, start, z0);
186+ pack_into_bits (ret, start, hwNProngScore);
187+ start = 64 ; // Start second word
188+ pack_into_bits (ret, start, hwMassSq);
189+ return ret;
190+ }
191+
192+ inline std::array<uint64_t , 2 > pack () const {
193+ std::array<uint64_t , 2 > packed;
194+ ap_uint<BITWIDTH> bits = this ->pack_ap ();
195+ packed[0 ] = bits (63 , 0 );
196+ packed[1 ] = bits (127 , 64 );
197+ return packed;
198+ }
199+
200+ inline static WideJet unpack_ap (const ap_uint<BITWIDTH> &src) {
201+ WideJet ret;
202+ ret.initFromBits (src);
203+ return ret;
204+ }
205+
206+ inline void initFromBits (const ap_uint<BITWIDTH> &src) {
207+ unsigned int start = 0 ;
208+ unpack_from_bits (src, start, valid);
209+ unpack_from_bits (src, start, v3.pt );
210+ unpack_from_bits (src, start, v3.phi );
211+ unpack_from_bits (src, start, v3.eta );
212+ unpack_from_bits (src, start, z0);
213+ unpack_from_bits (src, start, hwNProngScore);
214+ start = 64 ; // Start second word
215+ unpack_from_bits (src, start, hwMassSq);
216+ }
217+
218+ inline static WideJet unpack (const std::array<uint64_t , 2 > &src) {
219+ ap_uint<BITWIDTH> bits;
220+ bits (63 , 0 ) = src[0 ];
221+ bits (127 , 64 ) = src[1 ];
222+ return unpack_ap (bits);
223+ }
224+
225+ inline static WideJet unpack (long long unsigned int &src) {
226+ // unpack from single 64b int
227+ ap_uint<BITWIDTH> bits = src;
228+ return unpack_ap (bits);
229+ }
230+
231+ inline static WideJet unpack (const std::array<long long unsigned int , 2 > &src) {
232+ // unpack from two 64b ints
233+ ap_uint<BITWIDTH> bits;
234+ bits (63 , 0 ) = src[0 ];
235+ bits (127 , 64 ) = src[1 ];
236+ return unpack_ap (bits);
237+ }
238+
239+ }; // struct WideJet
240+
156241 struct Sum {
157242 valid_t valid;
158243 pt_t vector_pt;
@@ -394,6 +479,8 @@ namespace l1ct {
394479 return x * Scales::ETAPHI_CTtoGT_SCALE;
395480 }
396481
482+ inline l1gt::mass2_t CTtoGT_massSq (mass2_t x) { return (l1gt::mass2_t )x; }
483+
397484} // namespace l1ct
398485
399486#endif
0 commit comments