Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:31

0001 #include "L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/muonGmtToL1ct_ref.h"
0002 
0003 #ifdef CMSSW_GIT_HASH
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0006 
0007 l1ct::GMTMuonDecoderEmulator::GMTMuonDecoderEmulator(const edm::ParameterSet &iConfig)
0008     : z0Scale_(iConfig.getParameter<double>("z0Scale")), dxyScale_(iConfig.getParameter<double>("dxyScale")) {}
0009 
0010 edm::ParameterSetDescription l1ct::GMTMuonDecoderEmulator::getParameterSetDescription() {
0011   edm::ParameterSetDescription description;
0012   description.add<double>("z0Scale", 1.875);
0013   description.add<double>("dxyScale", 3.85);
0014   return description;
0015 }
0016 
0017 #endif
0018 
0019 l1ct::GMTMuonDecoderEmulator::GMTMuonDecoderEmulator(float z0Scale, float dxyScale)
0020     : z0Scale_(z0Scale), dxyScale_(dxyScale) {}
0021 
0022 l1ct::GMTMuonDecoderEmulator::~GMTMuonDecoderEmulator() {}
0023 
0024 l1ct::MuObjEmu l1ct::GMTMuonDecoderEmulator::decode(const ap_uint<64> &in) const {
0025   typedef ap_ufixed<13, 8, AP_TRN, AP_SAT> gmt_pt_t;
0026 
0027   const int etaPhi_common_bits = 4, etaPhi_extra_bits = 12 - etaPhi_common_bits;
0028   const int etaPhi_scale = l1ct::Scales::INTPHI_PI >> etaPhi_common_bits;
0029   const int etaPhi_offs = 1 << (etaPhi_extra_bits - 1);
0030 
0031   const int z0_scale = std::round(z0Scale_ / l1ct::Scales::Z0_LSB);
0032   const int dxy_scale = std::round(dxyScale_ / l1ct::Scales::DXY_LSB);
0033 
0034   bool gmt_valid = in[0], gmt_chg = in[56];
0035   ap_uint<13> gmt_ipt = in(16, 1);
0036   ap_int<13> gmt_phi = in(29, 17);
0037   ap_int<14> gmt_eta = in(43, 30);
0038   ap_int<5> gmt_z0 = in(48, 44);
0039   ap_int<7> gmt_d0 = in(55, 49);
0040   ap_uint<4> gmt_qual = in(60, 57);
0041 
0042   gmt_pt_t gmt_pt;
0043   gmt_pt(gmt_pt_t::width - 1, 0) = gmt_ipt(gmt_pt_t::width - 1, 0);  // copy the bits

0044 
0045   l1ct::MuObjEmu out;
0046   out.clear();
0047   if (gmt_valid && gmt_pt != 0) {
0048     // add a shift in order to get the proper rounding

0049     out.hwPt = gmt_pt + gmt_pt_t(l1ct::Scales::INTPT_LSB / 2);
0050 
0051     out.hwEta = (gmt_eta * etaPhi_scale + etaPhi_offs) >> etaPhi_extra_bits;
0052     out.hwPhi = (gmt_phi * etaPhi_scale + etaPhi_offs) >> etaPhi_extra_bits;
0053     out.hwDEta = 0;
0054     out.hwDPhi = 0;
0055 
0056     out.hwCharge = !gmt_chg;
0057 
0058     out.hwZ0 = gmt_z0 * z0_scale;
0059     out.hwDxy = gmt_d0 * dxy_scale;
0060 
0061     out.hwQuality = gmt_qual(3, 1);  // drop lowest bit

0062   }
0063 
0064   return out;
0065 }