CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Attributes | Friends
L1GctLut< NAddressBits, NDataBits > Class Template Referenceabstract

Base class for LookUp Tables. More...

#include <L1GctLut.h>

Public Member Functions

uint16_t lutValue (const uint16_t lutAddress) const
 Access the look-up table contents for a given Address. More...
 
template<int KAddressBits, int KDataBits>
int operator!= (const L1GctLut< KAddressBits, KDataBits > &rhsLut) const
 Inequality check between look-up tables. More...
 
template<int KAddressBits, int KDataBits>
int operator== (const L1GctLut< KAddressBits, KDataBits > &rhsLut) const
 Equality check between look-up tables. More...
 
uint16_t operator[] (const uint16_t lutAddress) const
 Access the look-up table contents for a given Address. More...
 
void setTerse ()
 
bool setupOk ()
 
void setVerbose ()
 control output messages More...
 
virtual ~L1GctLut ()
 

Static Public Attributes

static const uint16_t MAX_ADDRESS_BITMASK = (1 << NAddressBits) - 1
 
static const uint16_t MAX_DATA_BITMASK = (1 << NDataBits) - 1
 

Protected Member Functions

template<int KAddressBits, int KDataBits>
bool equalityCheck (const L1GctLut< KAddressBits, KDataBits > &c) const
 
 L1GctLut ()
 
virtual uint16_t value (const uint16_t lutAddress) const =0
 

Protected Attributes

bool m_setupOk
 
bool m_verbose
 

Private Member Functions

std::string printHeader () const
 
std::string printLine (const int add) const
 

Static Private Attributes

static const int printWidth = 16
 

Friends

std::ostream & operator<< (std::ostream &os, const L1GctLut< NAddressBits, NDataBits > &lut)
 Overload << operator. More...
 

Detailed Description

template<int NAddressBits, int NDataBits>
class L1GctLut< NAddressBits, NDataBits >

Base class for LookUp Tables.

Author
Greg Heath
Date
Feb 2007

Definition at line 19 of file L1GctLut.h.

Constructor & Destructor Documentation

◆ ~L1GctLut()

template<int NAddressBits, int NDataBits>
L1GctLut< NAddressBits, NDataBits >::~L1GctLut ( )
virtual

Definition at line 99 of file L1GctLut.h.

99 {}

◆ L1GctLut()

template<int NAddressBits, int NDataBits>
L1GctLut< NAddressBits, NDataBits >::L1GctLut ( )
protected

Definition at line 96 of file L1GctLut.h.

96 : m_setupOk(false) {}
bool m_setupOk
Definition: L1GctLut.h:77

Member Function Documentation

◆ equalityCheck()

template<int NAddressBits, int NDataBits>
template<int KAddressBits, int KDataBits>
bool L1GctLut< NAddressBits, NDataBits >::equalityCheck ( const L1GctLut< KAddressBits, KDataBits > &  c) const
protected

Definition at line 112 of file L1GctLut.h.

Referenced by L1GctLut< 16, 12 >::operator!=(), and L1GctLut< 16, 12 >::operator==().

112  {
113  if (KAddressBits == NAddressBits && KDataBits == NDataBits) {
114  bool match = true;
115  for (uint16_t address = 0; address <= MAX_ADDRESS_BITMASK; address++) {
116  if (this->lutValue(address) != rhsLut.lutValue(address)) {
117  match = false;
118  break;
119  }
120  }
121  return match;
122  } else {
123  return false;
124  }
125 }
uint16_t lutValue(const uint16_t lutAddress) const
Access the look-up table contents for a given Address.
Definition: L1GctLut.h:102
static const uint16_t MAX_ADDRESS_BITMASK
Definition: L1GctLut.h:21
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10

◆ lutValue()

template<int NAddressBits, int NDataBits>
uint16_t L1GctLut< NAddressBits, NDataBits >::lutValue ( const uint16_t  lutAddress) const

Access the look-up table contents for a given Address.

Definition at line 102 of file L1GctLut.h.

Referenced by L1GctLut< 16, 12 >::equalityCheck(), L1GctLut< 16, 12 >::operator[](), and L1GctMet::useHtMissLutAlgo().

102  {
103  if (!m_setupOk)
104  return (uint16_t)0;
105  uint16_t address = (lutAddress & MAX_ADDRESS_BITMASK);
106  uint16_t data = (value(address) & MAX_DATA_BITMASK);
107  return data;
108 }
virtual uint16_t value(const uint16_t lutAddress) const =0
static const uint16_t MAX_ADDRESS_BITMASK
Definition: L1GctLut.h:21
static const uint16_t MAX_DATA_BITMASK
Definition: L1GctLut.h:22
bool m_setupOk
Definition: L1GctLut.h:77
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ operator!=()

template<int NAddressBits, int NDataBits>
template<int KAddressBits, int KDataBits>
int L1GctLut< NAddressBits, NDataBits >::operator!= ( const L1GctLut< KAddressBits, KDataBits > &  rhsLut) const
inline

Inequality check between look-up tables.

Definition at line 59 of file L1GctLut.h.

59  {
60  return !equalityCheck(rhsLut);
61  }
bool equalityCheck(const L1GctLut< KAddressBits, KDataBits > &c) const
Definition: L1GctLut.h:112

◆ operator==()

template<int NAddressBits, int NDataBits>
template<int KAddressBits, int KDataBits>
int L1GctLut< NAddressBits, NDataBits >::operator== ( const L1GctLut< KAddressBits, KDataBits > &  rhsLut) const
inline

Equality check between look-up tables.

Definition at line 53 of file L1GctLut.h.

53  {
54  return equalityCheck(rhsLut);
55  }
bool equalityCheck(const L1GctLut< KAddressBits, KDataBits > &c) const
Definition: L1GctLut.h:112

◆ operator[]()

template<int NAddressBits, int NDataBits>
uint16_t L1GctLut< NAddressBits, NDataBits >::operator[] ( const uint16_t  lutAddress) const
inline

Access the look-up table contents for a given Address.

Definition at line 49 of file L1GctLut.h.

49 { return lutValue(lutAddress); }
uint16_t lutValue(const uint16_t lutAddress) const
Access the look-up table contents for a given Address.
Definition: L1GctLut.h:102

◆ printHeader()

template<int NAddressBits, int NDataBits>
std::string L1GctLut< NAddressBits, NDataBits >::printHeader ( ) const
private

Definition at line 128 of file L1GctLut.h.

Referenced by ntuplePrintersDiff.SeedPrinter::diff(), ntuplePrintersDiff.TrackPrinter::diff(), ntuplePrintersDiff.SeedPrinter::printSeed(), and ntuplePrintersDiff.TrackPrinter::printTrack().

128  {
129  std::stringstream ss;
130  ss << std::hex << std::showbase;
131  ss << std::setw(8) << "|";
132  for (int a = 0; ((a < printWidth) && (a <= MAX_ADDRESS_BITMASK)); ++a) {
133  ss << std::setw(7) << a;
134  }
135  ss << std::endl;
136  ss << std::setfill('-') << std::setw(8) << "+";
137  for (int a = 0; ((a < printWidth) && (a <= MAX_ADDRESS_BITMASK)); ++a) {
138  ss << std::setw(7) << "-";
139  }
140  ss << std::endl;
141 
142  return ss.str();
143 }
static const uint16_t MAX_ADDRESS_BITMASK
Definition: L1GctLut.h:21
static const int printWidth
Definition: L1GctLut.h:82
double a
Definition: hdecay.h:121

◆ printLine()

template<int NAddressBits, int NDataBits>
std::string L1GctLut< NAddressBits, NDataBits >::printLine ( const int  add) const
private

Definition at line 146 of file L1GctLut.h.

146  {
147  std::stringstream ss;
148  ss << std::hex << std::showbase;
149  int a = add;
150  ss << std::setw(7) << a << "|";
151  for (int c = 0; ((c < printWidth) && (a <= MAX_ADDRESS_BITMASK)); ++c) {
152  uint16_t address = static_cast<uint16_t>(a++);
153  ss << std::setw(7) << lutValue(address);
154  }
155  ss << std::endl;
156 
157  return ss.str();
158 }
uint16_t lutValue(const uint16_t lutAddress) const
Access the look-up table contents for a given Address.
Definition: L1GctLut.h:102
static const uint16_t MAX_ADDRESS_BITMASK
Definition: L1GctLut.h:21
static const int printWidth
Definition: L1GctLut.h:82
void add(std::map< std::string, TH1 *> &h, TH1 *hist)
double a
Definition: hdecay.h:121

◆ setTerse()

template<int NAddressBits, int NDataBits>
void L1GctLut< NAddressBits, NDataBits >::setTerse ( )
inline

Definition at line 67 of file L1GctLut.h.

67 { m_verbose = false; }
bool m_verbose
Definition: L1GctLut.h:78

◆ setupOk()

template<int NAddressBits, int NDataBits>
bool L1GctLut< NAddressBits, NDataBits >::setupOk ( )
inline

Definition at line 63 of file L1GctLut.h.

63 { return m_setupOk; }
bool m_setupOk
Definition: L1GctLut.h:77

◆ setVerbose()

template<int NAddressBits, int NDataBits>
void L1GctLut< NAddressBits, NDataBits >::setVerbose ( )
inline

control output messages

Definition at line 66 of file L1GctLut.h.

66 { m_verbose = true; }
bool m_verbose
Definition: L1GctLut.h:78

◆ value()

template<int NAddressBits, int NDataBits>
virtual uint16_t L1GctLut< NAddressBits, NDataBits >::value ( const uint16_t  lutAddress) const
protectedpure virtual

Friends And Related Function Documentation

◆ operator<<

template<int NAddressBits, int NDataBits>
std::ostream& operator<< ( std::ostream &  os,
const L1GctLut< NAddressBits, NDataBits > &  lut 
)
friend

Overload << operator.

Definition at line 27 of file L1GctLut.h.

27  {
28  //----------------------------------------------------------------------------------------
29  // Define the code here for the friend template function to get around
30  // compiler/linker problems when instantiating the template class.
31  // See http://www.parashift.com/c++-faq-lite/templates.html#faq-35.16
32  static const int maxAddress = L1GctLut<NAddressBits, NDataBits>::MAX_ADDRESS_BITMASK;
34 
35  os << lut.printHeader();
36 
37  for (int a = 0; a <= maxAddress; a += width) {
38  os << lut.printLine(a);
39  }
40  return os;
41  // End of friend function definition
42  //----------------------------------------------------------------------------------------
43  }
std::string printLine(const int add) const
Definition: L1GctLut.h:146
Base class for LookUp Tables.
Definition: L1GctLut.h:19
std::string printHeader() const
Definition: L1GctLut.h:128
double a
Definition: hdecay.h:121

Member Data Documentation

◆ m_setupOk

template<int NAddressBits, int NDataBits>
bool L1GctLut< NAddressBits, NDataBits >::m_setupOk
protected

Definition at line 77 of file L1GctLut.h.

Referenced by L1GctLut< 16, 12 >::setupOk().

◆ m_verbose

template<int NAddressBits, int NDataBits>
bool L1GctLut< NAddressBits, NDataBits >::m_verbose
protected

Definition at line 78 of file L1GctLut.h.

Referenced by L1GctLut< 16, 12 >::setTerse(), and L1GctLut< 16, 12 >::setVerbose().

◆ MAX_ADDRESS_BITMASK

template<int NAddressBits, int NDataBits>
const uint16_t L1GctLut< NAddressBits, NDataBits >::MAX_ADDRESS_BITMASK = (1 << NAddressBits) - 1
static

Definition at line 21 of file L1GctLut.h.

◆ MAX_DATA_BITMASK

template<int NAddressBits, int NDataBits>
const uint16_t L1GctLut< NAddressBits, NDataBits >::MAX_DATA_BITMASK = (1 << NDataBits) - 1
static

Definition at line 22 of file L1GctLut.h.

◆ printWidth

template<int NAddressBits, int NDataBits>
const int L1GctLut< NAddressBits, NDataBits >::printWidth = 16
staticprivate

Definition at line 82 of file L1GctLut.h.