CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MicroGMTRankPtQualLUT.cc
Go to the documentation of this file.
2 
4  const unsigned ptFactor,
5  const unsigned qualFactor)
6  : MicroGMTLUT(),
7  m_ptMask(0),
8  m_qualMask(0),
9  m_ptInWidth(9),
10  m_qualInWidth(4),
11  m_ptFactor(ptFactor),
12  m_qualFactor(qualFactor) {
14  m_outWidth = 10;
15 
16  m_ptMask = (1 << m_ptInWidth) - 1;
17  m_qualMask = ((1 << m_qualInWidth) - 1) << m_ptInWidth;
18 
21 
22  if (fname != std::string("")) {
23  load(fname);
24  } else {
25  initialize();
26  }
27 }
28 
30  : MicroGMTLUT(lut), m_ptMask(0), m_qualMask(0), m_ptInWidth(9), m_qualInWidth(4), m_ptFactor(0), m_qualFactor(0) {
32  m_outWidth = 10;
33 
34  m_ptMask = (1 << m_ptInWidth) - 1;
35  m_qualMask = ((1 << m_qualInWidth) - 1) << m_ptInWidth;
36 
39 
40  m_initialized = true;
41 }
42 
43 int l1t::MicroGMTRankPtQualLUT::lookup(int pt, int qual) const {
44  // normalize these two to the same scale and then calculate?
45  if (m_initialized) {
46  return data((unsigned)hashInput(checkedInput(pt, m_ptInWidth), checkedInput(qual, m_qualInWidth)));
47  }
48 
49  int result = 0;
50  result = pt * m_ptFactor + qual * m_qualFactor;
51  // normalize to out width
52  return result;
53 }
54 
56  if (m_initialized) {
57  return data((unsigned)in);
58  }
59 
60  int pt = 0;
61  int qual = 0;
62  unHashInput(in, pt, qual);
63  return lookup(pt, qual);
64 }
65 
66 int l1t::MicroGMTRankPtQualLUT::hashInput(int pt, int qual) const {
67  int result = 0;
68  result += pt;
69  result += qual << m_ptInWidth;
70  return result;
71 }
72 
73 void l1t::MicroGMTRankPtQualLUT::unHashInput(int input, int& pt, int& qual) const {
74  pt = input & m_ptMask;
75  qual = (input & m_qualMask) >> m_ptInWidth;
76 }
unsigned m_totalInWidth
Definition: MicroGMTLUT.h:34
int load(const std::string &inFileName)
Definition: MicroGMTLUT.cc:15
std::vector< MicroGMTConfiguration::input_t > m_inputs
Definition: MicroGMTLUT.h:36
static std::string const input
Definition: EdmProvDump.cc:47
tuple result
Definition: mps_fire.py:311
int hashInput(int pt, int qual) const
int lookup(int pt, int qual) const
int lookupPacked(int in) const override
Definition: LUT.h:29
string fname
main script
unsigned m_outWidth
Definition: MicroGMTLUT.h:35
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
void unHashInput(int input, int &pt, int &qual) const