CMS 3D CMS Logo

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 
22 {
24  m_outWidth = 10;
25 
26  m_ptMask = (1 << m_ptInWidth) - 1;
27  m_qualMask = ((1 << m_qualInWidth) - 1) << m_ptInWidth;
28 
31 
32  m_initialized = true;
33 }
34 
35 int
37 {
38  // normalize these two to the same scale and then calculate?
39  if (m_initialized) {
40  return data((unsigned)hashInput(checkedInput(pt, m_ptInWidth), checkedInput(qual, m_qualInWidth)));
41  }
42 
43  int result = 0;
44  result = pt * m_ptFactor + qual * m_qualFactor;
45  // normalize to out width
46  return result;
47 }
48 
49 int
51 {
52  if (m_initialized) {
53  return data((unsigned)in);
54  }
55 
56  int pt = 0;
57  int qual = 0;
58  unHashInput(in, pt, qual);
59  return lookup(pt, qual);
60 }
61 
62 int
64 {
65 
66  int result = 0;
67  result += pt;
68  result += qual << m_ptInWidth;
69  return result;
70 }
71 
72 void
73 l1t::MicroGMTRankPtQualLUT::unHashInput(int input, int& pt, int& qual) const
74 {
75  pt = input & m_ptMask;
76  qual = (input & m_qualMask) >> m_ptInWidth;
77 }
unsigned m_totalInWidth
Definition: MicroGMTLUT.h:34
int lookupPacked(int in) const override
int load(const std::string &inFileName)
Definition: MicroGMTLUT.cc:21
int checkedInput(unsigned in, unsigned maxWidth) const
Definition: MicroGMTLUT.cc:62
std::vector< MicroGMTConfiguration::input_t > m_inputs
Definition: MicroGMTLUT.h:36
static std::string const input
Definition: EdmProvDump.cc:44
int hashInput(int pt, int qual) const
int lookup(int pt, int qual) const
Definition: LUT.h:29
string fname
main script
unsigned m_outWidth
Definition: MicroGMTLUT.h:35
int data(unsigned int address) const
Definition: LUT.h:46
void unHashInput(int input, int &pt, int &qual) const