CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MicroGMTRankPtQualLUT.cc
Go to the documentation of this file.
1 #include "../interface/MicroGMTRankPtQualLUT.h"
2 
3 l1t::MicroGMTRankPtQualLUT::MicroGMTRankPtQualLUT (const std::string& fname, const unsigned ptFactor, const unsigned qualFactor) : MicroGMTLUT(), m_ptMask(0), m_qualMask(0), m_ptInWidth(9), m_qualInWidth(4), m_ptFactor(ptFactor), m_qualFactor(qualFactor)
4 {
6  m_outWidth = 10;
7 
8  m_ptMask = (1 << m_ptInWidth) - 1;
9  m_qualMask = ((1 << m_qualInWidth) - 1) << m_ptInWidth;
10 
13 
14  if (fname != std::string("")) {
15  load(fname);
16  } else {
17  initialize();
18  }
19 }
20 
21 int
23 {
24  // normalize these two to the same scale and then calculate?
25  if (m_initialized) {
26  return data((unsigned)hashInput(checkedInput(pt, m_ptInWidth), checkedInput(qual, m_qualInWidth)));
27  }
28 
29  int result = 0;
30  result = pt * m_ptFactor + qual * m_qualFactor;
31  // normalize to out width
32  return result;
33 }
34 
35 int
37 {
38  if (m_initialized) {
39  return data((unsigned)in);
40  }
41 
42  int pt = 0;
43  int qual = 0;
44  unHashInput(in, pt, qual);
45  return lookup(pt, qual);
46 }
47 
48 int
50 {
51 
52  int result = 0;
53  result += pt;
54  result += qual << m_ptInWidth;
55  return result;
56 }
57 
58 void
59 l1t::MicroGMTRankPtQualLUT::unHashInput(int input, int& pt, int& qual) const
60 {
61  pt = input & m_ptMask;
62  qual = (input & m_qualMask) >> m_ptInWidth;
63 }
unsigned m_totalInWidth
Definition: MicroGMTLUT.h:33
int load(const std::string &inFileName)
Definition: MicroGMTLUT.cc:14
virtual int lookupPacked(int in) const
std::vector< MicroGMTConfiguration::input_t > m_inputs
Definition: MicroGMTLUT.h:35
static std::string const input
Definition: EdmProvDump.cc:44
int hashInput(int pt, int qual) const
int lookup(int pt, int qual) const
tuple result
Definition: query.py:137
string fname
main script
unsigned m_outWidth
Definition: MicroGMTLUT.h:34
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void unHashInput(int input, int &pt, int &qual) const