Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:49

0001 #include "L1Trigger/L1TMuon/interface/MicroGMTRankPtQualLUT.h"
0002 
0003 l1t::MicroGMTRankPtQualLUT::MicroGMTRankPtQualLUT(const std::string& fname,
0004                                                   const unsigned ptFactor,
0005                                                   const unsigned qualFactor)
0006     : MicroGMTLUT(),
0007       m_ptMask(0),
0008       m_qualMask(0),
0009       m_ptInWidth(9),
0010       m_qualInWidth(4),
0011       m_ptFactor(ptFactor),
0012       m_qualFactor(qualFactor) {
0013   m_totalInWidth = m_ptInWidth + m_qualInWidth;
0014   m_outWidth = 10;
0015 
0016   m_ptMask = (1 << m_ptInWidth) - 1;
0017   m_qualMask = ((1 << m_qualInWidth) - 1) << m_ptInWidth;
0018 
0019   m_inputs.push_back(MicroGMTConfiguration::QUALITY);
0020   m_inputs.push_back(MicroGMTConfiguration::PT);
0021 
0022   if (fname != std::string("")) {
0023     load(fname);
0024   } else {
0025     initialize();
0026   }
0027 }
0028 
0029 l1t::MicroGMTRankPtQualLUT::MicroGMTRankPtQualLUT(l1t::LUT* lut)
0030     : MicroGMTLUT(lut), m_ptMask(0), m_qualMask(0), m_ptInWidth(9), m_qualInWidth(4), m_ptFactor(0), m_qualFactor(0) {
0031   m_totalInWidth = m_ptInWidth + m_qualInWidth;
0032   m_outWidth = 10;
0033 
0034   m_ptMask = (1 << m_ptInWidth) - 1;
0035   m_qualMask = ((1 << m_qualInWidth) - 1) << m_ptInWidth;
0036 
0037   m_inputs.push_back(MicroGMTConfiguration::QUALITY);
0038   m_inputs.push_back(MicroGMTConfiguration::PT);
0039 
0040   m_initialized = true;
0041 }
0042 
0043 int l1t::MicroGMTRankPtQualLUT::lookup(int pt, int qual) const {
0044   // normalize these two to the same scale and then calculate?
0045   if (m_initialized) {
0046     return data((unsigned)hashInput(checkedInput(pt, m_ptInWidth), checkedInput(qual, m_qualInWidth)));
0047   }
0048 
0049   int result = 0;
0050   result = pt * m_ptFactor + qual * m_qualFactor;
0051   // normalize to out width
0052   return result;
0053 }
0054 
0055 int l1t::MicroGMTRankPtQualLUT::lookupPacked(int in) const {
0056   if (m_initialized) {
0057     return data((unsigned)in);
0058   }
0059 
0060   int pt = 0;
0061   int qual = 0;
0062   unHashInput(in, pt, qual);
0063   return lookup(pt, qual);
0064 }
0065 
0066 int l1t::MicroGMTRankPtQualLUT::hashInput(int pt, int qual) const {
0067   int result = 0;
0068   result += pt;
0069   result += qual << m_ptInWidth;
0070   return result;
0071 }
0072 
0073 void l1t::MicroGMTRankPtQualLUT::unHashInput(int input, int& pt, int& qual) const {
0074   pt = input & m_ptMask;
0075   qual = (input & m_qualMask) >> m_ptInWidth;
0076 }