Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-10-12 04:20:53

0001 #ifndef L1Trigger_Phase2L1GT_L1GTEvaluationInterface_h
0002 #define L1Trigger_Phase2L1GT_L1GTEvaluationInterface_h
0003 
0004 #include "DataFormats/L1Trigger/interface/P2GTCandidate.h"
0005 
0006 #include <ap_int.h>
0007 
0008 #include <array>
0009 #include <cstddef>
0010 #include <cstdint>
0011 
0012 /**
0013  *  Source: CMS level-1 trigger interface specification: Global trigger
0014  **/
0015 namespace l1t {
0016 
0017   template <typename A, typename... Args>
0018   A l1t_pack_int(const Args&... args) {
0019     A result = 0;
0020     std::size_t shift = 0;
0021     (
0022         [&result, &shift](const auto& arg) {
0023           result(shift + arg.width - 1, shift) = arg;
0024           shift += arg.width;
0025         }(args),
0026         ...);
0027 
0028     return result;
0029   }
0030 
0031   struct L1TGT_BaseInterface {
0032     virtual std::size_t packed_width() const = 0;
0033     virtual P2GTCandidate to_GTObject() const = 0;
0034     virtual ~L1TGT_BaseInterface() {}
0035   };
0036 
0037   template <std::size_t N>
0038   struct L1TGT_Interface : public L1TGT_BaseInterface {
0039     virtual ap_uint<N> pack() const = 0;
0040 
0041     static constexpr std::size_t WIDTH = N;
0042 
0043     std::size_t packed_width() const override { return WIDTH; }
0044   };
0045 
0046   template <std::size_t N>
0047   struct L1TGT_Common3Vector : public L1TGT_Interface<N> {
0048     ap_uint<1> valid;
0049     ap_uint<16> pT;
0050     ap_int<13> phi;
0051     ap_int<14> eta;
0052 
0053     L1TGT_Common3Vector(int valid = 0, int pT = 0, int phi = 0, int eta = 0)
0054         : valid(valid), pT(pT), phi(phi), eta(eta) {};
0055 
0056     virtual ap_uint<44> pack_common() const { return l1t_pack_int<ap_uint<44>>(valid, pT, phi, eta); }
0057 
0058     ap_uint<N> pack() const override { return pack_common(); }
0059 
0060     static L1TGT_Common3Vector from_GTObject(const P2GTCandidate& gtObject) {
0061       return L1TGT_Common3Vector(1, gtObject.hwPT(), gtObject.hwPhi(), gtObject.hwEta());
0062     }
0063 
0064     P2GTCandidate to_GTObject() const override {
0065       P2GTCandidate gt_object;
0066       gt_object.setHwPT(pT);
0067       gt_object.setHwPhi(phi);
0068       gt_object.setHwEta(eta);
0069 
0070       return gt_object;
0071     }
0072   };
0073 
0074   struct L1TGT_CommonSum : public L1TGT_Interface<64> {
0075     ap_uint<1> valid;
0076     ap_uint<16> pT;
0077     ap_int<13> phi;
0078     ap_uint<16> scalarSumPT;
0079 
0080     L1TGT_CommonSum(int valid = 0, int pT = 0, int phi = 0, int scalarSumPT = 0)
0081         : valid(valid), pT(pT), phi{phi}, scalarSumPT(scalarSumPT) {}
0082 
0083     ap_uint<46> pack_common() const { return l1t_pack_int<ap_uint<46>>(valid, pT, phi, scalarSumPT); }
0084 
0085     ap_uint<64> pack() const override { return pack_common(); }
0086 
0087     static L1TGT_CommonSum from_GTObject(const P2GTCandidate& gtObject) {
0088       return L1TGT_CommonSum(1, gtObject.hwPT(), gtObject.hwPhi(), gtObject.hwScalarSumPT());
0089     }
0090 
0091     P2GTCandidate to_GTObject() const override {
0092       P2GTCandidate gt_object;
0093       gt_object.setHwPT(pT);
0094       gt_object.setHwPhi(phi);
0095       gt_object.setHwScalarSumPT(scalarSumPT);
0096 
0097       return gt_object;
0098     }
0099   };
0100 
0101   // Global Calorimeter Trigger
0102 
0103   struct L1TGT_GCT_EgammaNonIsolated6p6 : public L1TGT_Common3Vector<64> {
0104     using L1TGT_Common3Vector::L1TGT_Common3Vector;
0105   };
0106 
0107   struct L1TGT_GCT_EgammaIsolated6p6 : public L1TGT_Common3Vector<64> {
0108     using L1TGT_Common3Vector::L1TGT_Common3Vector;
0109   };
0110 
0111   struct L1TGT_GCT_jet6p6 : public L1TGT_Common3Vector<64> {
0112     using L1TGT_Common3Vector::L1TGT_Common3Vector;
0113   };
0114 
0115   struct L1TGT_GCT_tau6p6 : public L1TGT_Common3Vector<64> {
0116     ap_uint<10> seed_pT;
0117 
0118     L1TGT_GCT_tau6p6(int valid = 0, int pT = 0, int phi = 0, int eta = 0, int seed_pT = 0)
0119         : L1TGT_Common3Vector(valid, pT, phi, eta), seed_pT(seed_pT) {}
0120 
0121     ap_uint<WIDTH> pack() const override {
0122       return l1t_pack_int<ap_uint<WIDTH>>(L1TGT_Common3Vector::pack_common(), seed_pT);
0123     }
0124 
0125     static L1TGT_GCT_tau6p6 from_GTObject(const P2GTCandidate& gtObject) {
0126       return L1TGT_GCT_tau6p6(1, gtObject.hwPT(), gtObject.hwPhi(), gtObject.hwEta(), gtObject.hwSeed_pT());
0127     }
0128 
0129     P2GTCandidate to_GTObject() const override {
0130       P2GTCandidate gt_object(L1TGT_Common3Vector::to_GTObject());
0131       gt_object.setHwSeed_pT(seed_pT);
0132 
0133       return gt_object;
0134     }
0135   };
0136 
0137   struct L1TGT_GCT_Sum2 : public L1TGT_CommonSum {
0138     using L1TGT_CommonSum::L1TGT_CommonSum;
0139   };
0140 
0141   // Global Muon Trigger
0142 
0143   struct L1TGT_GMT_PromptDisplacedMuon : public L1TGT_Common3Vector<64> {
0144     ap_uint<5> z0;
0145     ap_int<7> d0;
0146     ap_uint<1> charge;
0147     ap_uint<4> qualityScore;
0148 
0149     L1TGT_GMT_PromptDisplacedMuon(int valid = 0,
0150                                   int pT = 0,
0151                                   int phi = 0,
0152                                   int eta = 0,
0153                                   int z0 = 0,
0154                                   int d0 = 0,
0155                                   int charge = 0,
0156                                   int qualityScore = 0)
0157         : L1TGT_Common3Vector(valid, pT, phi, eta), z0(z0), d0(d0), charge(charge), qualityScore(qualityScore) {}
0158 
0159     ap_uint<WIDTH> pack() const override {
0160       return l1t_pack_int<ap_uint<WIDTH>>(L1TGT_Common3Vector::pack_common(), z0, d0, charge, qualityScore);
0161     }
0162 
0163     static L1TGT_GMT_PromptDisplacedMuon from_GTObject(const P2GTCandidate& gtObject) {
0164       return L1TGT_GMT_PromptDisplacedMuon(1,
0165                                            gtObject.hwPT(),
0166                                            gtObject.hwPhi(),
0167                                            gtObject.hwEta(),
0168                                            gtObject.hwZ0() >> 12,
0169                                            gtObject.hwD0() >> 5,
0170                                            gtObject.hwCharge(),
0171                                            gtObject.hwQualityScore());
0172     }
0173 
0174     P2GTCandidate to_GTObject() const override {
0175       P2GTCandidate gt_object(L1TGT_Common3Vector::to_GTObject());
0176       gt_object.setHwZ0(static_cast<int>(z0) << 12);
0177       gt_object.setHwD0(static_cast<int>(d0) << 5);
0178       gt_object.setHwCharge(charge);
0179       gt_object.setHwQualityScore(qualityScore);
0180 
0181       return gt_object;
0182     }
0183   };
0184 
0185   struct L1TGT_GMT_TrackMatchedmuon : public L1TGT_Common3Vector<96> {
0186     ap_int<10> z0;
0187     ap_int<10> d0;
0188     ap_uint<1> charge;
0189     ap_uint<6> qualityFlags;
0190     ap_uint<6> isolationPT;
0191     ap_uint<4> beta;
0192 
0193     L1TGT_GMT_TrackMatchedmuon(int valid = 0,
0194                                int pT = 0,
0195                                int phi = 0,
0196                                int eta = 0,
0197                                int z0 = 0,
0198                                int d0 = 0,
0199                                int charge = 0,
0200                                int qualityFlags = 0,
0201                                int isolationPT = 0,
0202                                int beta = 0)
0203         : L1TGT_Common3Vector(valid, pT, phi, eta),
0204           z0(z0),
0205           d0(d0),
0206           charge(charge),
0207           qualityFlags(qualityFlags),
0208           isolationPT(isolationPT),
0209           beta(beta) {}
0210 
0211     ap_uint<WIDTH> pack() const override {
0212       return l1t_pack_int<ap_uint<WIDTH>>(
0213           L1TGT_Common3Vector::pack_common(), z0, d0, charge, qualityFlags, isolationPT, beta);
0214     }
0215 
0216     static L1TGT_GMT_TrackMatchedmuon from_GTObject(const P2GTCandidate& gtObject) {
0217       return L1TGT_GMT_TrackMatchedmuon(1,
0218                                         gtObject.hwPT(),
0219                                         gtObject.hwPhi(),
0220                                         gtObject.hwEta(),
0221                                         gtObject.hwZ0() >> 7,
0222                                         gtObject.hwD0() >> 2,
0223                                         gtObject.hwCharge(),
0224                                         gtObject.hwQualityFlags(),
0225                                         gtObject.hwIsolationPT(),
0226                                         gtObject.hwBeta());
0227     }
0228 
0229     P2GTCandidate to_GTObject() const override {
0230       P2GTCandidate gt_object(L1TGT_Common3Vector::to_GTObject());
0231       gt_object.setHwZ0(static_cast<int>(z0) << 7);
0232       gt_object.setHwD0(static_cast<int>(d0) << 2);
0233       gt_object.setHwCharge(charge);
0234       gt_object.setHwQualityFlags(static_cast<int>(qualityFlags));
0235       gt_object.setHwIsolationPT(static_cast<int>(isolationPT));
0236       gt_object.setHwBeta(beta);
0237 
0238       return gt_object;
0239     }
0240   };
0241 
0242   struct L1TGT_GMT_TopoObject : public L1TGT_Interface<64> {
0243     ap_uint<1> valid;
0244     ap_uint<8> pT;  // TODO
0245     ap_int<8> eta;
0246     ap_int<8> phi;
0247     ap_uint<8> mass;
0248     ap_uint<6> qualityFlags;
0249     // ap_uint<16> /* Index of 3 prongs */;
0250     // ap_uint<3> /* Some other quality */;
0251 
0252     L1TGT_GMT_TopoObject(int valid = 0, int pT = 0, int phi = 0, int eta = 0, int mass = 0, int qualityFlags = 0)
0253         : valid(valid), pT(pT), eta(eta), phi(phi), mass(mass), qualityFlags(qualityFlags) {}
0254 
0255     ap_uint<WIDTH> pack() const override {
0256       return l1t_pack_int<ap_uint<WIDTH>>(valid, pT, eta, phi, mass, qualityFlags);
0257     }
0258 
0259     static L1TGT_GMT_TopoObject from_GTObject(const P2GTCandidate& gtObject) {
0260       return L1TGT_GMT_TopoObject(1,
0261                                   gtObject.hwPT() / 5,
0262                                   gtObject.hwPhi() >> 5,
0263                                   gtObject.hwEta() >> 5,
0264                                   gtObject.hwMass(),
0265                                   gtObject.hwQualityFlags());
0266     }
0267 
0268     P2GTCandidate to_GTObject() const override {
0269       P2GTCandidate gt_object;
0270       gt_object.setHwPT(static_cast<int>(pT) * 5);  // TODO
0271       gt_object.setHwPhi(static_cast<int>(phi) << 5);
0272       gt_object.setHwEta(static_cast<int>(eta) << 5);
0273       gt_object.setHwMass(mass);
0274       gt_object.setHwQualityFlags(qualityFlags);
0275 
0276       return gt_object;
0277     }
0278   };
0279 
0280   // Global Track Trigger
0281 
0282   struct L1TGT_GTT_PromptJet : public L1TGT_Common3Vector<128> {
0283     ap_int<10> z0;
0284     ap_uint<5> number_of_tracks;
0285     ap_uint<4> number_of_displaced_tracks;
0286 
0287     L1TGT_GTT_PromptJet(int valid = 0,
0288                         int pT = 0,
0289                         int phi = 0,
0290                         int eta = 0,
0291                         int z0 = 0,
0292                         int number_of_tracks = 0,
0293                         int number_of_displaced_tracks = 0)
0294         : L1TGT_Common3Vector(valid, pT, phi, eta),
0295           z0(z0),
0296           number_of_tracks(number_of_tracks),
0297           number_of_displaced_tracks(number_of_displaced_tracks) {}
0298 
0299     ap_uint<WIDTH> pack() const override {
0300       return l1t_pack_int<ap_uint<WIDTH>>(
0301           L1TGT_Common3Vector::pack_common(), z0, number_of_tracks, number_of_displaced_tracks);
0302     }
0303 
0304     static L1TGT_GTT_PromptJet from_GTObject(const P2GTCandidate& gtObject) {
0305       return L1TGT_GTT_PromptJet(1,
0306                                  gtObject.hwPT(),
0307                                  gtObject.hwPhi(),
0308                                  gtObject.hwEta(),
0309                                  gtObject.hwZ0() >> 7,
0310                                  gtObject.hwNumber_of_tracks(),
0311                                  gtObject.hwNumber_of_displaced_tracks());
0312     }
0313 
0314     P2GTCandidate to_GTObject() const override {
0315       P2GTCandidate gt_object(L1TGT_Common3Vector::to_GTObject());
0316       gt_object.setHwZ0(static_cast<int>(z0) << 7);
0317       gt_object.setHwNumber_of_tracks(number_of_tracks);
0318       gt_object.setHwNumber_of_displaced_tracks(number_of_displaced_tracks);
0319 
0320       return gt_object;
0321     }
0322   };
0323 
0324   struct L1TGT_GTT_DisplacedJet : public L1TGT_Common3Vector<128> {
0325     ap_int<10> z0;
0326     ap_uint<5> number_of_tracks;
0327     ap_uint<4> number_of_displaced_tracks;
0328 
0329     L1TGT_GTT_DisplacedJet(int valid = 0,
0330                            int pT = 0,
0331                            int phi = 0,
0332                            int eta = 0,
0333                            int z0 = 0,
0334                            int number_of_tracks = 0,
0335                            int number_of_displaced_tracks = 0)
0336         : L1TGT_Common3Vector(valid, pT, phi, eta),
0337           z0(z0),
0338           number_of_tracks(number_of_tracks),
0339           number_of_displaced_tracks(number_of_displaced_tracks) {}
0340 
0341     ap_uint<WIDTH> pack() const override {
0342       return l1t_pack_int<ap_uint<WIDTH>>(
0343           L1TGT_Common3Vector::pack_common(), z0, number_of_tracks, number_of_displaced_tracks);
0344     }
0345 
0346     static L1TGT_GTT_DisplacedJet from_GTObject(const P2GTCandidate& gtObject) {
0347       return L1TGT_GTT_DisplacedJet(1,
0348                                     gtObject.hwPT(),
0349                                     gtObject.hwPhi(),
0350                                     gtObject.hwEta(),
0351                                     gtObject.hwZ0() >> 7,
0352                                     gtObject.hwNumber_of_tracks(),
0353                                     gtObject.hwNumber_of_displaced_tracks());
0354     }
0355 
0356     P2GTCandidate to_GTObject() const override {
0357       P2GTCandidate gt_object(L1TGT_Common3Vector::to_GTObject());
0358       gt_object.setHwZ0(static_cast<int>(z0) << 7);
0359       gt_object.setHwNumber_of_tracks(number_of_tracks);
0360       gt_object.setHwNumber_of_displaced_tracks(number_of_displaced_tracks);
0361 
0362       return gt_object;
0363     }
0364   };
0365 
0366   struct L1TGT_GTT_Sum : public L1TGT_CommonSum {
0367     using L1TGT_CommonSum::L1TGT_CommonSum;
0368   };
0369 
0370   struct L1TGT_GTT_HadronicTau : public L1TGT_Common3Vector<96> {
0371     ap_uint<10> seed_pT;
0372     ap_int<10> seed_z0;
0373     ap_uint<1> charge;
0374     ap_uint<2> type;
0375 
0376     L1TGT_GTT_HadronicTau(int valid = 0,
0377                           int pT = 0,
0378                           int phi = 0,
0379                           int eta = 0,
0380                           int seed_pT = 0,
0381                           int seed_z0 = 0,
0382                           int charge = 0,
0383                           int type = 0)
0384         : L1TGT_Common3Vector(valid, pT, phi, eta), seed_pT(seed_pT), seed_z0(seed_z0), charge(charge), type(type) {}
0385 
0386     ap_uint<WIDTH> pack() const override {
0387       return l1t_pack_int<ap_uint<WIDTH>>(L1TGT_Common3Vector::pack_common(), seed_pT, seed_z0, charge, type);
0388     }
0389 
0390     static L1TGT_GTT_HadronicTau from_GTObject(const P2GTCandidate& gtObject) {
0391       return L1TGT_GTT_HadronicTau(1,
0392                                    gtObject.hwPT(),
0393                                    gtObject.hwPhi(),
0394                                    gtObject.hwEta(),
0395                                    gtObject.hwSeed_pT(),
0396                                    gtObject.hwSeed_z0(),
0397                                    gtObject.hwCharge(),
0398                                    gtObject.hwType());
0399     }
0400 
0401     P2GTCandidate to_GTObject() const override {
0402       P2GTCandidate gt_object(L1TGT_Common3Vector::to_GTObject());
0403       gt_object.setHwSeed_pT(seed_pT);
0404       gt_object.setHwSeed_z0(seed_z0);
0405       gt_object.setHwCharge(charge);
0406       gt_object.setHwType(type);
0407 
0408       return gt_object;
0409     }
0410   };
0411 
0412   struct L1TGT_GTT_LightMeson : public L1TGT_Common3Vector<96> {
0413     ap_int<10> z0;
0414     //ap_uint<10> /* candidate mass */;
0415     //ap_uint<2> /* candidate type */;
0416     //ap_uint<3> /* nbr of tracks */;
0417 
0418     L1TGT_GTT_LightMeson(int valid = 0, int pT = 0, int phi = 0, int eta = 0, int z0 = 0)
0419         : L1TGT_Common3Vector(valid, pT, phi, eta), z0(z0) {}
0420 
0421     ap_uint<WIDTH> pack() const override {
0422       return l1t_pack_int<ap_uint<WIDTH>>(L1TGT_Common3Vector::pack_common(), z0);
0423     }
0424 
0425     static L1TGT_GTT_LightMeson from_GTObject(const P2GTCandidate& gtObject) {
0426       return L1TGT_GTT_LightMeson(1, gtObject.hwPT(), gtObject.hwPhi(), gtObject.hwEta(), gtObject.hwZ0() >> 7);
0427     }
0428 
0429     P2GTCandidate to_GTObject() const override {
0430       P2GTCandidate gt_object(L1TGT_Common3Vector::to_GTObject());
0431       gt_object.setHwZ0(static_cast<int>(z0) << 7);
0432 
0433       return gt_object;
0434     }
0435   };
0436 
0437   struct L1TGT_GTT_Track : public L1TGT_Interface<96> {
0438     //TODO
0439 
0440     L1TGT_GTT_Track() {};
0441 
0442     ap_uint<WIDTH> pack() const override { return ap_uint<WIDTH>(0); }
0443 
0444     static L1TGT_GTT_Track from_GTObject(const P2GTCandidate& gtObject) { return L1TGT_GTT_Track(); }
0445 
0446     P2GTCandidate to_GTObject() const override { return P2GTCandidate(); }
0447   };
0448 
0449   struct L1TGT_GTT_PrimaryVert : public L1TGT_Interface<64> {
0450     ap_uint<1> valid;
0451     ap_int<15> z0;
0452     ap_uint<8> number_of_tracks_in_pv;
0453     ap_uint<12> sum_pT_pv;
0454     ap_uint<3> qualityScore;
0455     ap_uint<10> number_of_tracks_not_in_pv;
0456     // ap_uint<15> /* unassigned */;
0457 
0458     L1TGT_GTT_PrimaryVert(int valid = 0,
0459                           int z0 = 0,
0460                           int number_of_tracks_in_pv = 0,
0461                           int sum_pT_pv = 0,
0462                           int qualityScore = 0,
0463                           int number_of_tracks_not_in_pv = 0)
0464         : valid(valid),
0465           z0(z0),
0466           number_of_tracks_in_pv(number_of_tracks_in_pv),
0467           sum_pT_pv(sum_pT_pv),
0468           qualityScore(qualityScore),
0469           number_of_tracks_not_in_pv(number_of_tracks_not_in_pv) {}
0470 
0471     ap_uint<WIDTH> pack() const override {
0472       return l1t_pack_int<ap_uint<WIDTH>>(
0473           valid, z0, number_of_tracks_in_pv, sum_pT_pv, qualityScore, number_of_tracks_not_in_pv);
0474     }
0475 
0476     static L1TGT_GTT_PrimaryVert from_GTObject(const P2GTCandidate& gtObject) {
0477       return L1TGT_GTT_PrimaryVert(1,
0478                                    gtObject.hwZ0() / 5,
0479                                    gtObject.hwNumber_of_tracks_in_pv(),
0480                                    gtObject.hwSum_pT_pv(),
0481                                    gtObject.hwQualityScore(),
0482                                    gtObject.hwNumber_of_tracks_not_in_pv());
0483     }
0484 
0485     P2GTCandidate to_GTObject() const override {
0486       P2GTCandidate gt_object;
0487       gt_object.setHwZ0(static_cast<int>(z0) * 5);
0488       gt_object.setHwNumber_of_tracks_in_pv(number_of_tracks_in_pv);
0489       gt_object.setHwSum_pT_pv(sum_pT_pv);
0490       gt_object.setHwQualityScore(qualityScore);
0491       gt_object.setHwNumber_of_tracks_not_in_pv(number_of_tracks_not_in_pv);
0492 
0493       return gt_object;
0494     }
0495   };
0496 
0497   // Correlator Layer-2
0498 
0499   struct L1TGT_CL2_Jet : public L1TGT_Common3Vector<128> {
0500     ap_int<10> z0;
0501 
0502     L1TGT_CL2_Jet(int valid = 0, int pT = 0, int phi = 0, int eta = 0, int z0 = 0)
0503         : L1TGT_Common3Vector(valid, pT, phi, eta), z0(z0) {}
0504 
0505     ap_uint<WIDTH> pack() const override {
0506       return l1t_pack_int<ap_uint<WIDTH>>(L1TGT_Common3Vector::pack_common(), z0);
0507     }
0508 
0509     static L1TGT_CL2_Jet from_GTObject(const P2GTCandidate& gtObject) {
0510       return L1TGT_CL2_Jet(1, gtObject.hwPT(), gtObject.hwPhi(), gtObject.hwEta(), gtObject.hwZ0() >> 7);
0511     }
0512 
0513     P2GTCandidate to_GTObject() const override {
0514       P2GTCandidate gt_object(L1TGT_Common3Vector::to_GTObject());
0515       gt_object.setHwZ0(static_cast<int>(z0) << 7);
0516 
0517       return gt_object;
0518     }
0519   };
0520 
0521   struct L1TGT_CL2_Sum : public L1TGT_CommonSum {
0522     using L1TGT_CommonSum::L1TGT_CommonSum;
0523   };
0524 
0525   struct L1TGT_CL2_Tau : public L1TGT_Common3Vector<96> {
0526     ap_uint<10> seed_pT;
0527     ap_int<10> seed_z0;
0528     ap_uint<1> charge;
0529     ap_uint<2> type;
0530     //ap_uint<10> /* MVA Id / Isol */;
0531     //ap_uint<2> /* Id vs Mu */;
0532     //ap_uint<2> /* Id vs Mu */;
0533 
0534     L1TGT_CL2_Tau(int valid = 0,
0535                   int pT = 0,
0536                   int phi = 0,
0537                   int eta = 0,
0538                   int seed_pT = 0,
0539                   int seed_z0 = 0,
0540                   int charge = 0,
0541                   int type = 0)
0542         : L1TGT_Common3Vector(valid, pT, phi, eta), seed_pT(seed_pT), seed_z0(seed_z0), charge(charge), type(type) {}
0543 
0544     ap_uint<WIDTH> pack() const override {
0545       return l1t_pack_int<ap_uint<WIDTH>>(L1TGT_Common3Vector::pack_common(), seed_pT, seed_z0, charge, type);
0546     }
0547 
0548     static L1TGT_CL2_Tau from_GTObject(const P2GTCandidate& gtObject) {
0549       return L1TGT_CL2_Tau(1,
0550                            gtObject.hwPT(),
0551                            gtObject.hwPhi(),
0552                            gtObject.hwEta(),
0553                            gtObject.hwSeed_pT(),
0554                            gtObject.hwSeed_z0(),
0555                            gtObject.hwCharge(),
0556                            gtObject.hwType());
0557     }
0558 
0559     P2GTCandidate to_GTObject() const override {
0560       P2GTCandidate gt_object(L1TGT_Common3Vector::to_GTObject());
0561       gt_object.setHwSeed_pT(seed_pT);
0562       gt_object.setHwSeed_z0(seed_z0);
0563       gt_object.setHwCharge(charge);
0564       gt_object.setHwType(type);
0565 
0566       return gt_object;
0567     }
0568   };
0569 
0570   struct L1TGT_CL2_Electron : public L1TGT_Common3Vector<96> {
0571     ap_uint<4> qualityFlags;
0572     ap_uint<11> isolationPT;
0573     ap_uint<1> charge;
0574     ap_int<10> z0;
0575 
0576     L1TGT_CL2_Electron(int valid = 0,
0577                        int pT = 0,
0578                        int phi = 0,
0579                        int eta = 0,
0580                        int qualityFlags = 0,
0581                        int isolationPT = 0,
0582                        int charge = 0,
0583                        int z0 = 0)
0584         : L1TGT_Common3Vector(valid, pT, phi, eta),
0585           qualityFlags(qualityFlags),
0586           isolationPT(isolationPT),
0587           charge(charge),
0588           z0(z0) {}
0589 
0590     ap_uint<WIDTH> pack() const override {
0591       return l1t_pack_int<ap_uint<WIDTH>>(L1TGT_Common3Vector::pack_common(), qualityFlags, isolationPT, charge, z0);
0592     }
0593 
0594     static L1TGT_CL2_Electron from_GTObject(const P2GTCandidate& gtObject) {
0595       return L1TGT_CL2_Electron(1,
0596                                 gtObject.hwPT(),
0597                                 gtObject.hwPhi(),
0598                                 gtObject.hwEta(),
0599                                 gtObject.hwQualityFlags(),
0600                                 gtObject.hwIsolationPT(),
0601                                 gtObject.hwCharge(),
0602                                 gtObject.hwZ0() >> 7);
0603     }
0604 
0605     P2GTCandidate to_GTObject() const override {
0606       P2GTCandidate gt_object(L1TGT_Common3Vector::to_GTObject());
0607       gt_object.setHwQualityFlags(qualityFlags);
0608       gt_object.setHwIsolationPT(isolationPT);
0609       gt_object.setHwCharge(charge);
0610       gt_object.setHwZ0(static_cast<int>(z0) << 7);
0611 
0612       return gt_object;
0613     }
0614   };
0615 
0616   struct L1TGT_CL2_Photon : public L1TGT_Common3Vector<96> {
0617     ap_uint<4> qualityFlags;
0618     ap_uint<11> isolationPT;
0619 
0620     L1TGT_CL2_Photon(int valid = 0, int pT = 0, int phi = 0, int eta = 0, int qualityFlags = 0, int isolationPT = 0)
0621         : L1TGT_Common3Vector(valid, pT, phi, eta), qualityFlags(qualityFlags), isolationPT(isolationPT) {}
0622 
0623     ap_uint<WIDTH> pack() const override {
0624       return l1t_pack_int<ap_uint<WIDTH>>(L1TGT_Common3Vector::pack_common(), qualityFlags, isolationPT);
0625     }
0626 
0627     static L1TGT_CL2_Photon from_GTObject(const P2GTCandidate& gtObject) {
0628       return L1TGT_CL2_Photon(
0629           1, gtObject.hwPT(), gtObject.hwPhi(), gtObject.hwEta(), gtObject.hwQualityFlags(), gtObject.hwIsolationPT());
0630     }
0631 
0632     P2GTCandidate to_GTObject() const override {
0633       P2GTCandidate gt_object(L1TGT_Common3Vector::to_GTObject());
0634       gt_object.setHwQualityFlags(qualityFlags);
0635       gt_object.setHwIsolationPT(isolationPT);
0636 
0637       return gt_object;
0638     }
0639   };
0640 }  // namespace l1t
0641 
0642 #endif  // L1Trigger_Phase2L1GT_L1GTEvaluationInterface_h