test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MicroGMTMatchQualSimpleLUT.cc
Go to the documentation of this file.
1 #include "../interface/MicroGMTMatchQualLUT.h"
2 #include "TMath.h"
3 
4 l1t::MicroGMTMatchQualSimpleLUT::MicroGMTMatchQualSimpleLUT (const std::string& fname, const double maxDR, const double fEta, const double fPhi, cancel_t cancelType) : MicroGMTMatchQualLUT()
5 {
8  m_maxDR = maxDR;
9  m_fEta = fEta;
10  m_fPhi = fPhi;
11  m_cancelType = cancelType;
12 
14  m_outWidth = 1;
15 
16  m_dPhiRedMask = (1 << m_dPhiRedInWidth) - 1;
18 
21 
22  m_phiScale = 2*TMath::Pi()/576.0;
23  m_etaScale = 0.010875;
24 
25  if (fname != std::string("")) {
26  load(fname);
27  } else {
28  initialize();
29  }
30 }
31 
33 {
34  m_dEtaRedInWidth = 5;
35  m_dPhiRedInWidth = 3;
36  m_cancelType = cancelType;
37 
39  m_outWidth = 1;
40 
41  m_dPhiRedMask = (1 << m_dPhiRedInWidth) - 1;
43 
46 
47  m_phiScale = 2*TMath::Pi()/576.0;
48  m_etaScale = 0.010875;
49 
50  m_initialized = true;
51 }
52 
53 int
54 l1t::MicroGMTMatchQualSimpleLUT::lookup(int etaFine, int dEtaRed, int dPhiRed) const // etaFine will be ignored
55 {
56  // normalize these two to the same scale and then calculate?
57  if (m_initialized) {
58  return data((unsigned)hashInput(checkedInput(dEtaRed, m_dEtaRedInWidth), checkedInput(dPhiRed, m_dPhiRedInWidth)));
59  }
60  double dEta = m_fEta*dEtaRed*m_etaScale;
61  double dPhi = m_fPhi*dPhiRed*m_phiScale;
62  double dR = std::sqrt(dEta*dEta + dPhi*dPhi);
63 
64  int retVal = dR <= m_maxDR ? 1 : 0;
65 
66  return retVal;
67 }
68 
69 int
71 {
72  if (m_initialized) {
73  return data((unsigned)in);
74  }
75 
76  int dEtaRed = 0;
77  int dPhiRed = 0;
78  unHashInput(in, dEtaRed, dPhiRed);
79  return lookup(0, dEtaRed, dPhiRed);
80 }
81 
82 int
83 l1t::MicroGMTMatchQualSimpleLUT::hashInput(int dEtaRed, int dPhiRed) const
84 {
85 
86  int result = 0;
87  result += dPhiRed;
88  result += dEtaRed << m_dPhiRedInWidth;
89  return result;
90 }
91 
92 void
93 l1t::MicroGMTMatchQualSimpleLUT::unHashInput(int input, int& dEtaRed, int& dPhiRed) const
94 {
95  dPhiRed = input & m_dPhiRedMask;
96  dEtaRed = (input & m_dEtaRedMask) >> m_dPhiRedInWidth;
97 }
const double Pi
unsigned m_totalInWidth
Definition: MicroGMTLUT.h:34
int hashInput(int dEta, int dPhi) const
int load(const std::string &inFileName)
Definition: MicroGMTLUT.cc:21
std::vector< MicroGMTConfiguration::input_t > m_inputs
Definition: MicroGMTLUT.h:36
static std::string const input
Definition: EdmProvDump.cc:44
tuple result
Definition: mps_fire.py:84
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
T sqrt(T t)
Definition: SSEVec.h:18
tuple lut
Definition: lumiPlot.py:244
int lookup(int etaFine, int dEta, int dPhi) const
Definition: LUT.h:29
string fname
main script
unsigned m_outWidth
Definition: MicroGMTLUT.h:35
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void unHashInput(int input, int &dEta, int &dPhi) const