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 
4  edm::ParameterSet config = iConfig.getParameter<edm::ParameterSet>("SortRankLUTSettings");
5  m_ptInWidth = config.getParameter<int>("pT_in_width");
6  m_qualInWidth = config.getParameter<int>("qual_in_width");
7 
8  m_totalInWidth = m_ptInWidth + m_qualInWidth;
9 
10  m_ptMask = (1 << m_ptInWidth) - 1;
11  m_qualMask = (1 << (m_totalInWidth - 1)) - m_ptMask - 1;
12 
14  std::string m_fname = config.getParameter<std::string>("filename");
15  if (m_fname != std::string("")) {
16  load(m_fname);
17  } else {
18  initialize();
19  }
20 }
21 
22 l1t::MicroGMTRankPtQualLUT::MicroGMTRankPtQualLUT () : MicroGMTLUT(), m_ptMask(0), m_qualMask(0), m_ptInWidth(9), m_qualInWidth(4)
23 {
24  m_ptMask = (1 << m_ptInWidth) - 1;
25  m_qualMask = (1 << (m_totalInWidth - 1)) - m_ptMask - 1;
26  m_outWidth = 10;
28 }
29 
31 {
32 
33 }
34 
35 int
37 {
38  // normalize these two to the same scale and then calculate?
39  if (m_initialized) {
40  return m_contents.at(hashInput(checkedInput(pt, m_ptInWidth), checkedInput(qual, m_qualInWidth)));
41  }
42 
43  int result = 0;
44  result = pt + (qual << 2);
45  // normalize to out width
46  return result;
47 }
48 
49 int
51  if (m_initialized) {
52  return m_contents.at(in);
53  }
54 
55  int pt = 0;
56  int qual = 0;
57  unHashInput(in, pt, qual);
58  return lookup(pt, qual);
59 }
60 
61 int
63 {
64 
65  int result = 0;
66  result += pt;
67  result += qual << m_ptInWidth;
68  return result;
69 }
70 
71 void
72 l1t::MicroGMTRankPtQualLUT::unHashInput(int input, int& pt, int& qual) const
73 {
74  pt = input & m_ptMask;
75  qual = (input & m_qualMask) >> m_ptInWidth;
76 }
T getParameter(std::string const &) const
unsigned m_totalInWidth
Definition: MicroGMTLUT.h:35
virtual int lookupPacked(int in) const
std::vector< MicroGMTConfiguration::input_t > m_inputs
Definition: MicroGMTLUT.h:37
static std::string const input
Definition: EdmProvDump.cc:43
int hashInput(int pt, int qual) const
int lookup(int pt, int qual) const
tuple result
Definition: query.py:137
std::string m_fname
Definition: MicroGMTLUT.h:39
void load(const std::string &inFileName)
Definition: MicroGMTLUT.cc:18
unsigned m_outWidth
Definition: MicroGMTLUT.h:36
void unHashInput(int input, int &pt, int &qual) const