Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "L1Trigger/L1TMuon/interface/MicroGMTMatchQualLUT.h"
0002 #include "TMath.h"
0003 
0004 l1t::MicroGMTMatchQualSimpleLUT::MicroGMTMatchQualSimpleLUT(
0005     const std::string& fname, const double maxDR, const double fEta, const double fPhi, cancel_t cancelType)
0006     : MicroGMTMatchQualLUT() {
0007   m_dEtaRedInWidth = 5;
0008   m_dPhiRedInWidth = 3;
0009   m_maxDR = maxDR;
0010   m_fEta = fEta;
0011   m_fPhi = fPhi;
0012   m_cancelType = cancelType;
0013 
0014   m_totalInWidth = m_dPhiRedInWidth + m_dEtaRedInWidth;
0015   m_outWidth = 1;
0016 
0017   m_dPhiRedMask = (1 << m_dPhiRedInWidth) - 1;
0018   m_dEtaRedMask = ((1 << m_dEtaRedInWidth) - 1) << m_dPhiRedInWidth;
0019 
0020   m_inputs.push_back(MicroGMTConfiguration::DELTA_ETA_RED);
0021   m_inputs.push_back(MicroGMTConfiguration::DELTA_PHI_RED);
0022 
0023   m_phiScale = 2 * TMath::Pi() / 576.0;
0024   m_etaScale = 0.010875;
0025 
0026   if (fname != std::string("")) {
0027     load(fname);
0028   } else {
0029     initialize();
0030   }
0031 }
0032 
0033 l1t::MicroGMTMatchQualSimpleLUT::MicroGMTMatchQualSimpleLUT(l1t::LUT* lut, cancel_t cancelType)
0034     : MicroGMTMatchQualLUT(lut) {
0035   m_dEtaRedInWidth = 5;
0036   m_dPhiRedInWidth = 3;
0037   m_cancelType = cancelType;
0038 
0039   m_totalInWidth = m_dPhiRedInWidth + m_dEtaRedInWidth;
0040   m_outWidth = 1;
0041 
0042   m_dPhiRedMask = (1 << m_dPhiRedInWidth) - 1;
0043   m_dEtaRedMask = ((1 << m_dEtaRedInWidth) - 1) << m_dPhiRedInWidth;
0044 
0045   m_inputs.push_back(MicroGMTConfiguration::DELTA_ETA_RED);
0046   m_inputs.push_back(MicroGMTConfiguration::DELTA_PHI_RED);
0047 
0048   m_phiScale = 2 * TMath::Pi() / 576.0;
0049   m_etaScale = 0.010875;
0050 
0051   m_initialized = true;
0052 }
0053 
0054 int l1t::MicroGMTMatchQualSimpleLUT::lookup(int etaFine, int dEtaRed, int dPhiRed) const  // etaFine will be ignored
0055 {
0056   // normalize these two to the same scale and then calculate?
0057   if (m_initialized) {
0058     return data((unsigned)hashInput(checkedInput(dEtaRed, m_dEtaRedInWidth), checkedInput(dPhiRed, m_dPhiRedInWidth)));
0059   }
0060   double dEta = m_fEta * dEtaRed * m_etaScale;
0061   double dPhi = m_fPhi * dPhiRed * m_phiScale;
0062   double dR = std::sqrt(dEta * dEta + dPhi * dPhi);
0063 
0064   int retVal = dR <= m_maxDR ? 1 : 0;
0065 
0066   return retVal;
0067 }
0068 
0069 int l1t::MicroGMTMatchQualSimpleLUT::lookupPacked(int in) const {
0070   if (m_initialized) {
0071     return data((unsigned)in);
0072   }
0073 
0074   int dEtaRed = 0;
0075   int dPhiRed = 0;
0076   unHashInput(in, dEtaRed, dPhiRed);
0077   return lookup(0, dEtaRed, dPhiRed);
0078 }
0079 
0080 int l1t::MicroGMTMatchQualSimpleLUT::hashInput(int dEtaRed, int dPhiRed) const {
0081   int result = 0;
0082   result += dPhiRed;
0083   result += dEtaRed << m_dPhiRedInWidth;
0084   return result;
0085 }
0086 
0087 void l1t::MicroGMTMatchQualSimpleLUT::unHashInput(int input, int& dEtaRed, int& dPhiRed) const {
0088   dPhiRed = input & m_dPhiRedMask;
0089   dEtaRed = (input & m_dEtaRedMask) >> m_dPhiRedInWidth;
0090 }