CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MicroGMTMatchQualLUT.cc
Go to the documentation of this file.
1 #include "../interface/MicroGMTMatchQualLUT.h"
2 #include "TMath.h"
3 
5  m_dEtaRedMask(0), m_dPhiRedMask(0), m_dEtaRedInWidth(0), m_dPhiRedInWidth(0), m_etaScale(0), m_phiScale(0), m_cancelType(cancelType)
6 {
7  edm::ParameterSet config = iConfig.getParameter<edm::ParameterSet>(prefix+"MatchQualLUTSettings");
8  m_dPhiRedInWidth = config.getParameter<int>("deltaPhiRed_in_width");
9  m_dEtaRedInWidth = config.getParameter<int>("deltaEtaRed_in_width");
10 
11  m_totalInWidth = m_dPhiRedInWidth + m_dEtaRedInWidth;
12 
13  m_dEtaRedMask = (1 << m_dEtaRedInWidth) - 1;
14  m_dPhiRedMask = (1 << (m_totalInWidth - 1)) - m_dEtaRedMask - 1;
15 
18 
19  m_phiScale = 2*TMath::Pi()/576.0;
20  m_etaScale = 0.010875;
21 
22  std::string m_fname = config.getParameter<std::string>("filename");
23  if (m_fname != std::string("")) {
24  load(m_fname);
25  } else {
26  initialize();
27  }
28 }
29 
31 {
32 
33 }
34 
35 
36 int
37 l1t::MicroGMTMatchQualLUT::lookup(int dEtaRed, int dPhiRed) const
38 {
39  // normalize these two to the same scale and then calculate?
40  if (m_initialized) {
41  return m_contents.at(hashInput(checkedInput(dEtaRed, m_dEtaRedInWidth), checkedInput(dPhiRed, m_dPhiRedInWidth)));
42  }
43  double dEta = dEtaRed*m_etaScale;
44  double dPhi = dPhiRed*m_phiScale;
45 
46  double dR = std::sqrt(dEta*dEta + dPhi*dPhi);
47 
48  int retVal = dR < 0.1 ? 1 : 0;
49  // should we need customisation for the different track finder cancellations:
50  // switch (m_cancelType) {
51  // case bmtf_bmtf:
52  // retVal = dR < 0.1 ? 1 : 0;
53  // case default:
54  // retVal = dR < 0.1 ? 1 : 0
55  // }
56 
57  return retVal;
58 }
59 int
61  if (m_initialized) {
62  return m_contents.at(in);
63  }
64 
65  int dEtaRed = 0;
66  int dPhiRed = 0;
67  unHashInput(in, dEtaRed, dPhiRed);
68  return lookup(dEtaRed, dPhiRed);
69 }
70 
71 int
72 l1t::MicroGMTMatchQualLUT::hashInput(int dEtaRed, int dPhiRed) const
73 {
74 
75  int result = 0;
76  result += dEtaRed;
77  result += dPhiRed << m_dEtaRedInWidth;
78  return result;
79 }
80 
81 void
82 l1t::MicroGMTMatchQualLUT::unHashInput(int input, int& dEtaRed, int& dPhiRed) const
83 {
84  dEtaRed = input & m_dEtaRedMask;
85  dPhiRed = (input & m_dPhiRedMask) >> m_dEtaRedInWidth;
86 }
const double Pi
T getParameter(std::string const &) const
unsigned m_totalInWidth
Definition: MicroGMTLUT.h:35
std::vector< MicroGMTConfiguration::input_t > m_inputs
Definition: MicroGMTLUT.h:37
static std::string const input
Definition: EdmProvDump.cc:43
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
T sqrt(T t)
Definition: SSEVec.h:48
tuple result
Definition: query.py:137
std::string m_fname
Definition: MicroGMTLUT.h:39
int lookup(int dEta, int dPhi) const
void unHashInput(int input, int &dEta, int &dPhi) const
void load(const std::string &inFileName)
Definition: MicroGMTLUT.cc:18
int hashInput(int dEta, int dPhi) const
virtual int lookupPacked(int in) const