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 
4 l1t::MicroGMTMatchQualLUT::MicroGMTMatchQualLUT (const std::string& fname, const double maxDR, cancel_t cancelType) : MicroGMTLUT(), m_dEtaRedMask(0), m_dPhiRedMask(0), m_dEtaRedInWidth(4), m_dPhiRedInWidth(3), m_etaScale(0), m_phiScale(0), m_maxDR(maxDR), m_cancelType(cancelType)
5 {
7  m_outWidth = 1;
8 
9  m_dPhiRedMask = (1 << m_dPhiRedInWidth) - 1;
11 
14 
15  m_phiScale = 2*TMath::Pi()/576.0;
16  m_etaScale = 0.010875;
17 
18  if (fname != std::string("")) {
19  load(fname);
20  } else {
21  initialize();
22  }
23 }
24 
25 int
26 l1t::MicroGMTMatchQualLUT::lookup(int dEtaRed, int dPhiRed) const
27 {
28  // normalize these two to the same scale and then calculate?
29  if (m_initialized) {
30  return data((unsigned)hashInput(checkedInput(dEtaRed, m_dEtaRedInWidth), checkedInput(dPhiRed, m_dPhiRedInWidth)));
31  }
32  double dEta = dEtaRed*m_etaScale;
33  double dPhi = dPhiRed*m_phiScale;
34 
35  double dR = std::sqrt(dEta*dEta + dPhi*dPhi);
36 
37  int retVal = dR < m_maxDR ? 1 : 0;
38  // should we need customisation for the different track finder cancellations:
39  // switch (m_cancelType) {
40  // case bmtf_bmtf:
41  // retVal = dR < 0.1 ? 1 : 0;
42  // case default:
43  // retVal = dR < 0.1 ? 1 : 0
44  // }
45 
46  return retVal;
47 }
48 
49 int
51 {
52  if (m_initialized) {
53  return data((unsigned)in);
54  }
55 
56  int dEtaRed = 0;
57  int dPhiRed = 0;
58  unHashInput(in, dEtaRed, dPhiRed);
59  return lookup(dEtaRed, dPhiRed);
60 }
61 
62 int
63 l1t::MicroGMTMatchQualLUT::hashInput(int dEtaRed, int dPhiRed) const
64 {
65 
66  int result = 0;
67  result += dPhiRed;
68  result += dEtaRed << m_dPhiRedInWidth;
69  return result;
70 }
71 
72 void
73 l1t::MicroGMTMatchQualLUT::unHashInput(int input, int& dEtaRed, int& dPhiRed) const
74 {
75  dPhiRed = input & m_dPhiRedMask;
76  dEtaRed = (input & m_dEtaRedMask) >> m_dPhiRedInWidth;
77 }
const double Pi
unsigned m_totalInWidth
Definition: MicroGMTLUT.h:33
int load(const std::string &inFileName)
Definition: MicroGMTLUT.cc:14
std::vector< MicroGMTConfiguration::input_t > m_inputs
Definition: MicroGMTLUT.h:35
static std::string const input
Definition: EdmProvDump.cc:44
tuple result
Definition: mps_fire.py:95
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
T sqrt(T t)
Definition: SSEVec.h:18
int lookup(int dEta, int dPhi) const
void unHashInput(int input, int &dEta, int &dPhi) const
int hashInput(int dEta, int dPhi) const
string fname
main script
unsigned m_outWidth
Definition: MicroGMTLUT.h:34
virtual int lookupPacked(int in) const