Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:54:29

0001 //-------------------------------------------------
0002 //
0003 //   Class: L1MuGMTLFMatchQualLUT
0004 //
0005 //
0006 //
0007 //   Author :
0008 //   H. Sakulin            HEPHY Vienna
0009 //
0010 //   Migrated to CMSSW:
0011 //   I. Mikulec
0012 //
0013 //--------------------------------------------------
0014 
0015 //-----------------------
0016 // This Class's Header --
0017 //-----------------------
0018 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTLFMatchQualLUT.h"
0019 
0020 //---------------
0021 // C++ Headers --
0022 //---------------
0023 
0024 //#include <iostream>
0025 
0026 //-------------------------------
0027 // Collaborating Class Headers --
0028 //-------------------------------
0029 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTConfig.h"
0030 #include "CondFormats/L1TObjects/interface/L1MuGMTScales.h"
0031 #include "CondFormats/L1TObjects/interface/L1MuPacking.h"
0032 
0033 //-------------------
0034 // InitParameters  --
0035 //-------------------
0036 
0037 void L1MuGMTLFMatchQualLUT::InitParameters() {
0038   m_EtaWeights[0] = L1MuGMTConfig::getEtaWeightBarrel();
0039   m_PhiWeights[0] = L1MuGMTConfig::getPhiWeightBarrel();
0040   m_EtaPhiThresholds[0] = L1MuGMTConfig::getEtaPhiThresholdBarrel();
0041 
0042   m_EtaWeights[1] = L1MuGMTConfig::getEtaWeightEndcap();
0043   m_PhiWeights[1] = L1MuGMTConfig::getPhiWeightEndcap();
0044   m_EtaPhiThresholds[1] = L1MuGMTConfig::getEtaPhiThresholdEndcap();
0045 
0046   for (int i = 2; i < 6; i++) {
0047     m_EtaWeights[i] = L1MuGMTConfig::getEtaWeightCOU();
0048     m_PhiWeights[i] = L1MuGMTConfig::getPhiWeightCOU();
0049     m_EtaPhiThresholds[i] = L1MuGMTConfig::getEtaPhiThresholdCOU();
0050   }
0051 }
0052 
0053 //------------------------
0054 // The Lookup Function  --
0055 //------------------------
0056 
0057 unsigned L1MuGMTLFMatchQualLUT::TheLookupFunction(int idx, unsigned delta_eta, unsigned delta_phi) const {
0058   // idx is DTRPC, CSCRPC, DTCSC, CSCDT, CSCbRPC, DTfRPC
0059   // INPUTS:  delta_eta(4) delta_phi(3)
0060   // OUTPUTS: mq(6)
0061 
0062   const L1MuGMTScales* theGMTScales = L1MuGMTConfig::getGMTScales();
0063 
0064   float deta = theGMTScales->getDeltaEtaScale(idx)->getCenter(delta_eta);
0065   float dphi = theGMTScales->getDeltaPhiScale()->getCenter(delta_phi);
0066 
0067   // check out-of range code
0068   L1MuSignedPacking<4> EtaPacking;
0069   int delta_eta_signed = EtaPacking.idxFromPacked(delta_eta);
0070   L1MuSignedPacking<3> PhiPacking;
0071   int delta_phi_signed = PhiPacking.idxFromPacked(delta_phi);
0072 
0073   bool dphi_outofrange = (delta_phi_signed == -4);
0074 
0075   // limit delta-phi even further    **FIXME: make this configurable
0076   if (delta_phi_signed >= 3 || delta_phi_signed <= -3)
0077     dphi_outofrange = true;
0078 
0079   // check out-of range code
0080   bool deta_outofrange = (delta_eta_signed == -8);
0081 
0082   // limit delta-eta even further    **FIXME: make this configurable
0083   if (delta_eta_signed >= 7 || delta_eta_signed <= -7)
0084     deta_outofrange = true;
0085 
0086   double delta_etaphi = sqrt(m_EtaWeights[idx] * deta * deta + m_PhiWeights[idx] * dphi * dphi);
0087 
0088   //    cout << "MQ LUT       : delta_phi = " << dphi
0089   //         << ", delta_eta = " << deta
0090   //         << ", delta_etaphi = " << delta_etaphi
0091   //         << endl;
0092 
0093   int matchqual = 0;
0094   if (dphi_outofrange || deta_outofrange || delta_etaphi > m_EtaPhiThresholds[idx]) {
0095     matchqual = 0;
0096   } else {
0097     double mq = 64. * (m_EtaPhiThresholds[idx] - delta_etaphi) / m_EtaPhiThresholds[idx];
0098     matchqual = static_cast<int>(mq);
0099   }
0100 
0101   if (matchqual > 63)
0102     matchqual = 63;
0103   return matchqual;
0104 }