File indexing completed on 2023-03-17 11:13:16
0001 #include "L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/muonGmtToL1ct_ref.h"
0002
0003 #ifdef CMSSW_GIT_HASH
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005
0006 l1ct::GMTMuonDecoderEmulator::GMTMuonDecoderEmulator(const edm::ParameterSet &iConfig)
0007 : z0Scale_(iConfig.getParameter<double>("z0Scale")), dxyScale_(iConfig.getParameter<double>("dxyScale")) {}
0008
0009 #endif
0010
0011 l1ct::GMTMuonDecoderEmulator::GMTMuonDecoderEmulator(float z0Scale, float dxyScale)
0012 : z0Scale_(z0Scale), dxyScale_(dxyScale) {}
0013
0014 l1ct::GMTMuonDecoderEmulator::~GMTMuonDecoderEmulator() {}
0015
0016 l1ct::MuObjEmu l1ct::GMTMuonDecoderEmulator::decode(const ap_uint<64> &in) const {
0017 typedef ap_ufixed<13, 8, AP_TRN, AP_SAT> gmt_pt_t;
0018
0019 const int etaPhi_common_bits = 4, etaPhi_extra_bits = 12 - etaPhi_common_bits;
0020 const int etaPhi_scale = l1ct::Scales::INTPHI_PI >> etaPhi_common_bits;
0021 const int etaPhi_offs = 1 << (etaPhi_extra_bits - 1);
0022
0023 const int z0_scale = std::round(z0Scale_ / l1ct::Scales::Z0_LSB);
0024 const int dxy_scale = std::round(dxyScale_ / l1ct::Scales::DXY_LSB);
0025
0026 bool gmt_valid = in[0], gmt_chg = in[56];
0027 ap_uint<13> gmt_ipt = in(16, 1);
0028 ap_int<13> gmt_phi = in(29, 17);
0029 ap_int<14> gmt_eta = in(43, 30);
0030 ap_int<5> gmt_z0 = in(48, 44);
0031 ap_int<7> gmt_d0 = in(55, 49);
0032 ap_uint<4> gmt_qual = in(60, 57);
0033
0034 gmt_pt_t gmt_pt;
0035 gmt_pt(gmt_pt_t::width - 1, 0) = gmt_ipt(gmt_pt_t::width - 1, 0);
0036
0037 l1ct::MuObjEmu out;
0038 out.clear();
0039 if (gmt_valid && gmt_pt != 0) {
0040
0041 out.hwPt = gmt_pt + gmt_pt_t(l1ct::Scales::INTPT_LSB / 2);
0042
0043 out.hwEta = (gmt_eta * etaPhi_scale + etaPhi_offs) >> etaPhi_extra_bits;
0044 out.hwPhi = (gmt_phi * etaPhi_scale + etaPhi_offs) >> etaPhi_extra_bits;
0045 out.hwDEta = 0;
0046 out.hwDPhi = 0;
0047
0048 out.hwCharge = !gmt_chg;
0049
0050 out.hwZ0 = gmt_z0 * z0_scale;
0051 out.hwDxy = gmt_d0 * dxy_scale;
0052
0053 out.hwQuality = gmt_qual(3, 1);
0054 }
0055
0056 return out;
0057 }