CMS 3D CMS Logo

MicroGMTMatchQualFineLUT.cc
Go to the documentation of this file.
2 #include "TMath.h"
3 
4 l1t::MicroGMTMatchQualFineLUT::MicroGMTMatchQualFineLUT (const std::string& fname, const double maxDR, const double fEta, const double fEtaCoarse, const double fPhi, cancel_t cancelType) : MicroGMTMatchQualLUT(), m_fEtaCoarse(fEtaCoarse)
5 {
8  m_maxDR = maxDR;
9  m_fEta = fEta;
10  m_fPhi = fPhi;
11  m_cancelType = cancelType;
12 
14  m_outWidth = 1;
15 
16  m_dPhiRedMask = (1 << m_dPhiRedInWidth) - 1;
18  m_etaFineMask = 1 << (m_dEtaRedInWidth + m_dPhiRedInWidth);
19 
23 
24  m_phiScale = 2*TMath::Pi()/576.0;
25  m_etaScale = 0.010875;
26 
27  if (fname != std::string("")) {
28  load(fname);
29  } else {
30  initialize();
31  }
32 }
33 
35 {
36  m_dEtaRedInWidth = 5;
37  m_dPhiRedInWidth = 3;
38  m_cancelType = cancelType;
39 
41  m_outWidth = 1;
42 
43  m_dPhiRedMask = (1 << m_dPhiRedInWidth) - 1;
45  m_etaFineMask = 1 << (m_dEtaRedInWidth + m_dPhiRedInWidth);
46 
50 
51  m_phiScale = 2*TMath::Pi()/576.0;
52  m_etaScale = 0.010875;
53 
54  m_initialized = true;
55 }
56 
57 int
58 l1t::MicroGMTMatchQualFineLUT::lookup(int etaFine, int dEtaRed, int dPhiRed) const
59 {
60  // normalize these two to the same scale and then calculate?
61  if (m_initialized) {
62  return data((unsigned)hashInput(checkedInput(etaFine, 1), checkedInput(dEtaRed, m_dEtaRedInWidth), checkedInput(dPhiRed, m_dPhiRedInWidth)));
63  }
64  double dEta = m_fEtaCoarse*dEtaRed*m_etaScale;
65  if (etaFine > 0) {
66  dEta = m_fEta*dEtaRed*m_etaScale;
67  }
68  double dPhi = m_fPhi*dPhiRed*m_phiScale;
69  double dR = std::sqrt(dEta*dEta + dPhi*dPhi);
70 
71  int retVal = dR <= m_maxDR ? 1 : 0;
72 
73  return retVal;
74 }
75 
76 int
78 {
79  if (m_initialized) {
80  return data((unsigned)in);
81  }
82 
83  int etaFine = 0;
84  int dEtaRed = 0;
85  int dPhiRed = 0;
86  unHashInput(in, etaFine, dEtaRed, dPhiRed);
87  return lookup(etaFine, dEtaRed, dPhiRed);
88 }
89 
90 int
91 l1t::MicroGMTMatchQualFineLUT::hashInput(int etaFine, int dEtaRed, int dPhiRed) const
92 {
93  int result = 0;
94  result += dPhiRed;
95  result += dEtaRed << m_dPhiRedInWidth;
96  result += etaFine << (m_dEtaRedInWidth + m_dPhiRedInWidth);
97  return result;
98 }
99 
100 void
101 l1t::MicroGMTMatchQualFineLUT::unHashInput(int input, int& etaFine, int& dEtaRed, int& dPhiRed) const
102 {
103  dPhiRed = input & m_dPhiRedMask;
104  dEtaRed = (input & m_dEtaRedMask) >> m_dPhiRedInWidth;
105  etaFine = (input & m_etaFineMask) >> (m_dEtaRedInWidth + m_dPhiRedInWidth);
106 }
const double Pi
unsigned m_totalInWidth
Definition: MicroGMTLUT.h:34
int load(const std::string &inFileName)
Definition: MicroGMTLUT.cc:21
int checkedInput(unsigned in, unsigned maxWidth) const
Definition: MicroGMTLUT.cc:62
int lookupPacked(int in) const override
std::vector< MicroGMTConfiguration::input_t > m_inputs
Definition: MicroGMTLUT.h:36
static std::string const input
Definition: EdmProvDump.cc:48
void unHashInput(int input, int &etaFine, int &dEta, int &dPhi) const
int lookup(int etaFine, int dEta, int dPhi) const override
T sqrt(T t)
Definition: SSEVec.h:18
Definition: LUT.h:29
int hashInput(int etaFine, int dEta, int dPhi) const
string fname
main script
unsigned m_outWidth
Definition: MicroGMTLUT.h:35
int data(unsigned int address) const
Definition: LUT.h:46