CMS 3D CMS Logo

L1GTEvaluationInterface.h
Go to the documentation of this file.
1 #ifndef L1Trigger_Phase2L1GT_L1GTEvaluationInterface_h
2 #define L1Trigger_Phase2L1GT_L1GTEvaluationInterface_h
3 
5 
6 #include <ap_int.h>
7 
8 #include <array>
9 #include <cstddef>
10 #include <cstdint>
11 
15 namespace l1t {
16 
17  template <typename A, typename... Args>
18  A l1t_pack_int(const Args&... args) {
19  A result = 0;
20  std::size_t shift = 0;
21  (
22  [&result, &shift](const auto& arg) {
23  result(shift + arg.width - 1, shift) = arg;
24  shift += arg.width;
25  }(args),
26  ...);
27 
28  return result;
29  }
30 
31  template <typename A, typename... Args>
32  A l1t_unpack_int(const A& packed, Args&&... args) {
33  A temp = packed;
34  (
35  [&temp](auto&& arg) {
36  arg = temp(arg.width - 1, 0);
37  temp >>= arg.width;
38  }(std::forward<Args>(args)),
39  ...);
40  return temp;
41  }
42 
44  virtual std::size_t packed_width() const = 0;
45  virtual P2GTCandidate to_GTObject() const = 0;
46  virtual ~L1TGT_BaseInterface() {}
47  };
48 
49  template <std::size_t N>
51  virtual ap_uint<N> pack() const = 0;
52  virtual ap_uint<N> unpack(const ap_uint<N>&) = 0;
53 
54  static constexpr std::size_t WIDTH = N;
55 
56  std::size_t packed_width() const override { return WIDTH; }
57  };
58 
59  template <std::size_t N>
60  struct L1TGT_Common3Vector : public L1TGT_Interface<N> {
61  ap_uint<1> valid;
62  ap_uint<16> pT;
63  ap_int<13> phi;
64  ap_int<14> eta;
65 
66  L1TGT_Common3Vector(int valid = 0, int pT = 0, int phi = 0, int eta = 0)
67  : valid(valid), pT(pT), phi(phi), eta(eta){};
68 
69  virtual ap_uint<44> pack_common() const { return l1t_pack_int<ap_uint<44>>(valid, pT, phi, eta); }
70 
71  ap_uint<N> pack() const override { return pack_common(); }
72 
73  ap_uint<N> unpack(const ap_uint<N>& packed) override { return l1t_unpack_int(packed, valid, pT, phi, eta); }
74 
75  P2GTCandidate to_GTObject() const override {
76  P2GTCandidate gt_object;
77  gt_object.setHwPT(pT);
78  gt_object.setHwPhi(phi);
79  gt_object.setHwEta(eta);
80 
81  return gt_object;
82  }
83  };
84 
85  template <std::size_t N>
86  struct L1TGT_CommonSum : public L1TGT_Interface<N> {
87  ap_uint<1> valid;
88  ap_uint<16> pT;
89  ap_int<13> phi;
90  ap_uint<16> scalar_sum_pT;
91 
92  L1TGT_CommonSum(int valid = 0, int pT = 0, int phi = 0, int scalar_sum_pT = 0)
94 
95  ap_uint<46> pack_common() const { return l1t_pack_int<ap_uint<46>>(valid, pT, phi, scalar_sum_pT); }
96 
97  ap_uint<N> pack() const override { return pack_common(); }
98 
99  ap_uint<N> unpack(const ap_uint<N>& packed) override {
100  return l1t_unpack_int(packed, valid, pT, phi, scalar_sum_pT);
101  }
102 
103  P2GTCandidate to_GTObject() const override {
104  P2GTCandidate gt_object;
105  gt_object.setHwPT(pT);
106  gt_object.setHwPhi(phi);
107  gt_object.setHwSca_sum(scalar_sum_pT);
108 
109  return gt_object;
110  }
111  };
112 
113  // Global Calorimeter Trigger
114 
117  };
118 
121  };
122 
123  struct L1TGT_GCT_jet6p6 : public L1TGT_Common3Vector<64> {
125  };
126 
127  struct L1TGT_GCT_tau6p6 : public L1TGT_Common3Vector<64> {
128  ap_uint<10> seed_pT;
129 
130  L1TGT_GCT_tau6p6(int valid = 0, int pT = 0, int phi = 0, int eta = 0, int seed_pT = 0)
132 
133  ap_uint<WIDTH> pack() const override {
134  return l1t_pack_int<ap_uint<WIDTH>>(L1TGT_Common3Vector::pack_common(), seed_pT);
135  }
136 
137  ap_uint<WIDTH> unpack(const ap_uint<WIDTH>& packed) override {
139  }
140 
141  P2GTCandidate to_GTObject() const override {
143  gt_object.setHwSeed_pT(seed_pT);
144 
145  return gt_object;
146  }
147  };
148 
149  struct L1TGT_GCT_Sum2 : public L1TGT_CommonSum<64> {
151  };
152 
153  // Global Muon Trigger
154 
156  ap_uint<5> z0;
157  ap_int<7> d0;
158  ap_uint<1> charge;
159  ap_uint<4> qual;
160 
162  int valid = 0, int pT = 0, int phi = 0, int eta = 0, int z0 = 0, int d0 = 0, int charge = 0, int qual = 0)
164 
165  ap_uint<WIDTH> pack() const override {
166  return l1t_pack_int<ap_uint<WIDTH>>(L1TGT_Common3Vector::pack_common(), z0, d0, charge, qual);
167  }
168 
169  ap_uint<WIDTH> unpack(const ap_uint<WIDTH>& packed) override {
171  }
172 
173  P2GTCandidate to_GTObject() const override {
175  gt_object.setHwZ0(static_cast<int>(z0) << 5);
176  gt_object.setHwD0(static_cast<int>(d0) << 5);
177  gt_object.setHwCharge(charge);
178  gt_object.setHwQual(qual);
179 
180  return gt_object;
181  }
182  };
183 
185  ap_int<10> z0;
186  ap_int<10> d0;
187  ap_uint<1> charge;
188  ap_uint<8> qual;
189  ap_uint<4> iso;
190  ap_uint<4> beta;
191 
193  int pT = 0,
194  int phi = 0,
195  int eta = 0,
196  int z0 = 0,
197  int d0 = 0,
198  int charge = 0,
199  int qual = 0,
200  int iso = 0,
201  int beta = 0)
203 
204  ap_uint<WIDTH> pack() const override {
205  return l1t_pack_int<ap_uint<WIDTH>>(L1TGT_Common3Vector::pack_common(), z0, d0, charge, qual, iso, beta);
206  }
207 
208  ap_uint<WIDTH> unpack(const ap_uint<WIDTH>& packed) override {
210  }
211 
212  P2GTCandidate to_GTObject() const override {
214  gt_object.setHwZ0(z0);
215  gt_object.setHwD0(static_cast<int>(d0) << 2);
216  gt_object.setHwCharge(charge);
217  gt_object.setHwQual(qual);
218  gt_object.setHwIso(static_cast<int>(iso) << 7);
219  gt_object.setHwBeta(beta);
220 
221  return gt_object;
222  }
223  };
224 
225  struct L1TGT_GMT_TopoObject : public L1TGT_Interface<64> {
226  ap_uint<1> valid;
227  ap_uint<8> pT; // TODO
228  ap_int<8> eta;
229  ap_int<8> phi;
230  ap_uint<8> mass;
231  ap_uint<6> qual;
232  // ap_uint<16> /* Index of 3 prongs */;
233  // ap_uint<3> /* Some other quality */;
234 
235  L1TGT_GMT_TopoObject(int valid = 0, int pT = 0, int phi = 0, int eta = 0, int mass = 0, int qual = 0)
236  : valid(valid), pT(pT), eta(eta), phi(phi), mass(mass), qual(qual) {}
237 
238  ap_uint<WIDTH> pack() const override { return l1t_pack_int<ap_uint<WIDTH>>(valid, pT, eta, phi, mass, qual); }
239 
240  ap_uint<WIDTH> unpack(const ap_uint<WIDTH>& packed) override {
241  return l1t_unpack_int(packed, valid, pT, eta, phi, mass, qual);
242  }
243 
244  P2GTCandidate to_GTObject() const override {
245  P2GTCandidate gt_object;
246  gt_object.setHwPT(static_cast<int>(pT) * 5); // TODO
247  gt_object.setHwPhi(static_cast<int>(phi) << 5);
248  gt_object.setHwEta(static_cast<int>(eta) << 5);
249  gt_object.setHwMass(mass);
250  gt_object.setHwQual(qual);
251 
252  return gt_object;
253  }
254  };
255 
256  // Global Track Trigger
257 
259  ap_int<10> z0;
260  ap_uint<5> number_of_tracks;
261  // ap_uint<5> /* unassigned */;
262 
263  L1TGT_GTT_PromptJet(int valid = 0, int pT = 0, int phi = 0, int eta = 0, int z0 = 0, int number_of_tracks = 0)
265 
266  ap_uint<WIDTH> pack() const override {
267  return l1t_pack_int<ap_uint<WIDTH>>(L1TGT_Common3Vector::pack_common(), z0, number_of_tracks);
268  }
269 
270  ap_uint<WIDTH> unpack(const ap_uint<WIDTH>& packed) override {
271  return l1t_unpack_int<ap_uint<WIDTH>>(L1TGT_Common3Vector::unpack(packed), z0, number_of_tracks);
272  }
273 
274  P2GTCandidate to_GTObject() const override {
276  gt_object.setHwZ0(z0);
278 
279  return gt_object;
280  }
281  };
282 
284  ap_int<10> z0;
285  ap_uint<5> number_of_tracks;
286  // ap_uint<5> /* unassigned */;
287  ap_int<12> d0;
288 
290  int valid = 0, int pT = 0, int phi = 0, int eta = 0, int z0 = 0, int number_of_tracks = 0, int d0 = 0)
292 
293  ap_uint<WIDTH> pack() const override {
294  return l1t_pack_int<ap_uint<WIDTH>>(L1TGT_Common3Vector::pack_common(), z0, number_of_tracks, ap_uint<5>(0), d0);
295  }
296 
297  ap_uint<WIDTH> unpack(const ap_uint<WIDTH>& packed) override {
298  return l1t_unpack_int<ap_uint<WIDTH>>(
299  L1TGT_Common3Vector::unpack(packed), z0, number_of_tracks, ap_uint<5>(0), d0);
300  }
301 
302  P2GTCandidate to_GTObject() const override {
304  gt_object.setHwZ0(z0);
306  gt_object.setHwD0(d0);
307 
308  return gt_object;
309  }
310  };
311 
312  struct L1TGT_GTT_Sum : public L1TGT_CommonSum<64> {
314  };
315 
317  ap_uint<10> seed_pT;
318  ap_int<10> seed_z0;
319  ap_uint<1> charge;
320  ap_uint<2> type;
321 
323  int pT = 0,
324  int phi = 0,
325  int eta = 0,
326  int seed_pT = 0,
327  int seed_z0 = 0,
328  int charge = 0,
329  int type = 0)
331 
332  ap_uint<WIDTH> pack() const override {
333  return l1t_pack_int<ap_uint<WIDTH>>(L1TGT_Common3Vector::pack_common(), seed_pT, seed_z0, charge, type);
334  }
335 
336  ap_uint<WIDTH> unpack(const ap_uint<WIDTH>& packed) override {
338  }
339 
340  P2GTCandidate to_GTObject() const override {
342  gt_object.setHwSeed_pT(seed_pT);
343  gt_object.setHwSeed_z0(seed_z0);
344  gt_object.setHwCharge(charge);
345  gt_object.setHwType(type);
346 
347  return gt_object;
348  }
349  };
350 
352  ap_int<10> z0;
353  //ap_uint<10> /* candidate mass */;
354  //ap_uint<2> /* candidate type */;
355  //ap_uint<3> /* nbr of tracks */;
356 
357  L1TGT_GTT_LightMeson(int valid = 0, int pT = 0, int phi = 0, int eta = 0, int z0 = 0)
358  : L1TGT_Common3Vector(valid, pT, phi, eta), z0(z0) {}
359 
360  ap_uint<WIDTH> pack() const override {
361  return l1t_pack_int<ap_uint<WIDTH>>(L1TGT_Common3Vector::pack_common(), z0);
362  }
363 
364  ap_uint<WIDTH> unpack(const ap_uint<WIDTH>& packed) override {
366  }
367 
368  P2GTCandidate to_GTObject() const override {
370  gt_object.setHwZ0(z0);
371 
372  return gt_object;
373  }
374  };
375 
377  ap_uint<1> valid;
378  ap_int<15> z0;
380  ap_uint<12> sum_pT_pv;
381  ap_uint<3> qual;
383  // ap_uint<15> /* unassigned */;
384 
386  int z0 = 0,
387  int number_of_tracks_in_pv = 0,
388  int sum_pT_pv = 0,
389  int qual = 0,
391  : valid(valid),
392  z0(z0),
395  qual(qual),
397 
398  ap_uint<WIDTH> pack() const override {
399  return l1t_pack_int<ap_uint<WIDTH>>(
400  valid, z0 /*, number_of_tracks_in_pv, sum_pT_pv, qual, number_of_tracks_not_in_pv */); // TODO: Maybe later
401  }
402 
403  ap_uint<WIDTH> unpack(const ap_uint<WIDTH>& packed) override {
405  }
406 
407  P2GTCandidate to_GTObject() const override {
408  P2GTCandidate gt_object;
409  gt_object.setHwZ0(z0);
411  gt_object.setHwSum_pT_pv(sum_pT_pv);
412  gt_object.setHwQual(qual);
414 
415  return gt_object;
416  }
417  };
418 
419  // Correlator Layer-2
420 
421  struct L1TGT_CL2_Jet : public L1TGT_Common3Vector<128> {
422  ap_int<10> z0;
423 
424  L1TGT_CL2_Jet(int valid = 0, int pT = 0, int phi = 0, int eta = 0, int z0 = 0)
425  : L1TGT_Common3Vector(valid, pT, phi, eta), z0(z0) {}
426 
427  ap_uint<WIDTH> pack() const override {
428  return l1t_pack_int<ap_uint<WIDTH>>(L1TGT_Common3Vector::pack_common(), z0);
429  }
430 
431  ap_uint<WIDTH> unpack(const ap_uint<WIDTH>& packed) override {
433  }
434 
435  P2GTCandidate to_GTObject() const override {
437  gt_object.setHwZ0(z0);
438 
439  return gt_object;
440  }
441  };
442 
443  struct L1TGT_CL2_Sum : public L1TGT_CommonSum<64> {
445  };
446 
447  struct L1TGT_CL2_Tau : public L1TGT_Common3Vector<96> {
448  ap_uint<10> seed_pT;
449  ap_int<10> seed_z0;
450  ap_uint<1> charge;
451  ap_uint<2> type;
452  //ap_uint<10> /* MVA Id / Isol */;
453  //ap_uint<2> /* Id vs Mu */;
454  //ap_uint<2> /* Id vs Mu */;
455 
457  int pT = 0,
458  int phi = 0,
459  int eta = 0,
460  int seed_pT = 0,
461  int seed_z0 = 0,
462  int charge = 0,
463  int type = 0)
465 
466  ap_uint<WIDTH> pack() const override {
467  return l1t_pack_int<ap_uint<WIDTH>>(L1TGT_Common3Vector::pack_common(), seed_pT, seed_z0, charge, type);
468  }
469 
470  ap_uint<WIDTH> unpack(const ap_uint<WIDTH>& packed) override {
472  }
473 
474  P2GTCandidate to_GTObject() const override {
476  gt_object.setHwSeed_pT(seed_pT);
477  gt_object.setHwSeed_z0(seed_z0);
478  gt_object.setHwCharge(charge);
479  gt_object.setHwType(type);
480 
481  return gt_object;
482  }
483  };
484 
486  ap_uint<4> qual;
487  ap_uint<11> iso;
488  ap_uint<1> charge;
489  ap_int<10> z0;
490 
492  int valid = 0, int pT = 0, int phi = 0, int eta = 0, int qual = 0, int iso = 0, int charge = 0, int z0 = 0)
494 
495  ap_uint<WIDTH> pack() const override {
496  return l1t_pack_int<ap_uint<WIDTH>>(L1TGT_Common3Vector::pack_common(), qual, iso, charge, z0);
497  }
498 
499  ap_uint<WIDTH> unpack(const ap_uint<WIDTH>& packed) override {
501  }
502 
503  P2GTCandidate to_GTObject() const override {
505  gt_object.setHwQual(qual);
506  gt_object.setHwIso(iso);
507  gt_object.setHwCharge(charge);
508  gt_object.setHwZ0(z0);
509 
510  return gt_object;
511  }
512  };
513 
514  struct L1TGT_CL2_Photon : public L1TGT_Common3Vector<96> {
515  ap_uint<4> qual;
516  ap_uint<11> iso;
517 
518  L1TGT_CL2_Photon(int valid = 0, int pT = 0, int phi = 0, int eta = 0, int qual = 0, int iso = 0)
520 
521  ap_uint<WIDTH> pack() const override {
522  return l1t_pack_int<ap_uint<WIDTH>>(L1TGT_Common3Vector::pack_common(), qual, iso);
523  }
524 
525  ap_uint<WIDTH> unpack(const ap_uint<WIDTH>& packed) override {
527  }
528 
529  P2GTCandidate to_GTObject() const override {
531  gt_object.setHwQual(qual);
532  gt_object.setHwIso(iso);
533 
534  return gt_object;
535  }
536  };
537 } // namespace l1t
538 
539 #endif // L1Trigger_Phase2L1GT_L1GTEvaluationInterface_h
P2GTCandidate to_GTObject() const override
ap_uint< WIDTH > pack() const override
void setHwD0(hwD0_t hwD0)
L1TGT_CL2_Photon(int valid=0, int pT=0, int phi=0, int eta=0, int qual=0, int iso=0)
L1TGT_GTT_PromptJet(int valid=0, int pT=0, int phi=0, int eta=0, int z0=0, int number_of_tracks=0)
virtual ap_uint< 44 > pack_common() const
void setHwType(hwType_t hwType)
ap_uint< WIDTH > pack() const override
P2GTCandidate to_GTObject() const override
ap_uint< WIDTH > unpack(const ap_uint< WIDTH > &packed) override
L1TGT_CL2_Jet(int valid=0, int pT=0, int phi=0, int eta=0, int z0=0)
ap_uint< WIDTH > unpack(const ap_uint< WIDTH > &packed) override
P2GTCandidate to_GTObject() const override
void setHwBeta(hwBeta_t hwBeta)
ap_uint< WIDTH > pack() const override
L1TGT_GCT_tau6p6(int valid=0, int pT=0, int phi=0, int eta=0, int seed_pT=0)
void setHwIso(hwIso_t hwIso)
L1TGT_GMT_PromptDisplacedMuon(int valid=0, int pT=0, int phi=0, int eta=0, int z0=0, int d0=0, int charge=0, int qual=0)
void setHwNumber_of_tracks_in_pv(hwNumber_of_tracks_in_pv_t hwNumber_of_tracks_in_pv)
P2GTCandidate to_GTObject() const override
ap_uint< WIDTH > pack() const override
L1TGT_CL2_Electron(int valid=0, int pT=0, int phi=0, int eta=0, int qual=0, int iso=0, int charge=0, int z0=0)
L1TGT_GTT_LightMeson(int valid=0, int pT=0, int phi=0, int eta=0, int z0=0)
ap_uint< WIDTH > pack() const override
ap_uint< WIDTH > pack() const override
delete x;
Definition: CaloConfig.h:22
ap_uint< N > unpack(const ap_uint< N > &packed) override
A arg
Definition: Factorize.h:31
L1TGT_CL2_Tau(int valid=0, int pT=0, int phi=0, int eta=0, int seed_pT=0, int seed_z0=0, int charge=0, int type=0)
void setHwSum_pT_pv(hwSum_pT_pv_t hwSum_pT_pv)
ap_uint< WIDTH > unpack(const ap_uint< WIDTH > &packed) override
ap_uint< 46 > pack_common() const
P2GTCandidate to_GTObject() const override
void setHwSca_sum(hwSca_sum_t hwSca_sum)
A l1t_pack_int(const Args &... args)
P2GTCandidate to_GTObject() const override
ap_uint< WIDTH > unpack(const ap_uint< WIDTH > &packed) override
void setHwEta(hwEta_t hwEta)
Definition: P2GTCandidate.h:99
ap_uint< WIDTH > pack() const override
void setHwMass(hwMass_t hwMass)
ap_uint< WIDTH > pack() const override
ap_uint< WIDTH > unpack(const ap_uint< WIDTH > &packed) override
void setHwPT(hwPT_t hwPT)
Definition: P2GTCandidate.h:97
ap_uint< WIDTH > unpack(const ap_uint< WIDTH > &packed) override
P2GTCandidate to_GTObject() const override
P2GTCandidate to_GTObject() const override
static constexpr std::size_t WIDTH
virtual P2GTCandidate to_GTObject() const =0
virtual std::size_t packed_width() const =0
void setHwQual(hwQual_t hwQual)
P2GTCandidate to_GTObject() const override
L1TGT_GMT_TopoObject(int valid=0, int pT=0, int phi=0, int eta=0, int mass=0, int qual=0)
ap_uint< WIDTH > unpack(const ap_uint< WIDTH > &packed) override
ap_uint< WIDTH > pack() const override
ap_uint< WIDTH > unpack(const ap_uint< WIDTH > &packed) override
ap_uint< WIDTH > pack() const override
ap_uint< WIDTH > pack() const override
#define N
Definition: blowfish.cc:9
void setHwSeed_z0(hwSeed_z0_t hwSeed_z0)
ap_uint< N > pack() const override
P2GTCandidate to_GTObject() const override
ap_uint< WIDTH > unpack(const ap_uint< WIDTH > &packed) override
L1TGT_GTT_DisplacedJet(int valid=0, int pT=0, int phi=0, int eta=0, int z0=0, int number_of_tracks=0, int d0=0)
void setHwNumber_of_tracks_not_in_pv(hwNumber_of_tracks_not_in_pv_t hwNumber_of_tracks_not_in_pv)
L1TGT_GTT_PrimaryVert(int valid=0, int z0=0, int number_of_tracks_in_pv=0, int sum_pT_pv=0, int qual=0, int number_of_tracks_not_in_pv=0)
void setHwSeed_pT(hwSeed_pT_t hwSeed_pT)
P2GTCandidate to_GTObject() const override
P2GTCandidate to_GTObject() const override
ap_uint< WIDTH > pack() const override
ap_uint< WIDTH > unpack(const ap_uint< WIDTH > &packed) override
L1TGT_CommonSum(int valid=0, int pT=0, int phi=0, int scalar_sum_pT=0)
P2GTCandidate to_GTObject() const override
virtual ap_uint< N > pack() const =0
ap_uint< WIDTH > unpack(const ap_uint< WIDTH > &packed) override
L1TGT_Common3Vector(int valid=0, int pT=0, int phi=0, int eta=0)
ap_uint< WIDTH > unpack(const ap_uint< WIDTH > &packed) override
L1TGT_GMT_TrackMatchedmuon(int valid=0, int pT=0, int phi=0, int eta=0, int z0=0, int d0=0, int charge=0, int qual=0, int iso=0, int beta=0)
static unsigned int const shift
ap_uint< N > pack() const override
ap_uint< WIDTH > unpack(const ap_uint< WIDTH > &packed) override
virtual ap_uint< N > unpack(const ap_uint< N > &)=0
Definition: APVGainStruct.h:7
std::size_t packed_width() const override
P2GTCandidate to_GTObject() const override
L1TGT_GTT_HadronicTau(int valid=0, int pT=0, int phi=0, int eta=0, int seed_pT=0, int seed_z0=0, int charge=0, int type=0)
void setHwCharge(hwCharge_t hwCharge)
ap_uint< WIDTH > pack() const override
void setHwZ0(hwZ0_t hwZ0)
void setHwNumber_of_tracks(hwNumber_of_tracks_t hwNumber_of_tracks)
void setHwPhi(hwPhi_t hwPhi)
Definition: P2GTCandidate.h:98
A l1t_unpack_int(const A &packed, Args &&... args)
ap_uint< N > unpack(const ap_uint< N > &packed) override
P2GTCandidate to_GTObject() const override