Main Page
Namespaces
Classes
Package Documentation
L1Trigger
GlobalCaloTrigger
src
L1GctLut.h
Go to the documentation of this file.
1
#ifndef L1GCTLUT_H_
2
#define L1GCTLUT_H_
3
4
#include <boost/cstdint.hpp>
//for uint16_t
5
6
#include <iomanip>
7
#include <sstream>
8
19
template
<
int
NAddressBits,
int
NDataBits>
20
class
L1GctLut
21
{
22
public
:
23
static
const
uint16_t
MAX_ADDRESS_BITMASK
;
24
static
const
uint16_t
MAX_DATA_BITMASK
;
25
26
virtual
~L1GctLut
();
27
29
friend
std::ostream& operator << (std::ostream& os, const L1GctLut<NAddressBits, NDataBits>&
lut
)
30
{
31
//----------------------------------------------------------------------------------------
32
// Define the code here for the friend template function to get around
33
// compiler/linker problems when instantiating the template class.
34
// See http://www.parashift.com/c++-faq-lite/templates.html#faq-35.16
35
static
const
int
maxAddress=
L1GctLut<NAddressBits, NDataBits>::MAX_ADDRESS_BITMASK
;
36
static
const
int
width
=
L1GctLut<NAddressBits, NDataBits>::printWidth
;
37
38
os <<
lut
.printHeader();
39
40
for
(
int
a
=0;
a
<=maxAddress;
a
+=
width
) {
41
os <<
lut
.printLine(
a
);
42
}
43
return
os;
44
// End of friend function definition
45
//----------------------------------------------------------------------------------------
46
}
47
49
uint16_t
lutValue
(
const
uint16_t lutAddress)
const
;
50
52
uint16_t
operator[]
(
const
uint16_t lutAddress)
const
{
return
lutValue
(lutAddress); }
53
55
template
<
int
KAddressBits,
int
KDataBits>
56
int
operator==
(
const
L1GctLut<KAddressBits, KDataBits>
& rhsLut)
const
{
return
equalityCheck
(rhsLut); }
57
59
template
<
int
KAddressBits,
int
KDataBits>
60
int
operator!=
(
const
L1GctLut<KAddressBits, KDataBits>
& rhsLut)
const
{
return
!
equalityCheck
(rhsLut); }
61
62
bool
setupOk
() {
return
m_setupOk
; }
63
65
void
setVerbose
() {
m_verbose
=
true
; }
66
void
setTerse
() {
m_verbose
=
false
; }
67
68
protected
:
69
70
L1GctLut
();
71
72
virtual
uint16_t
value
(
const
uint16_t lutAddress)
const
=0;
73
74
template
<
int
KAddressBits,
int
KDataBits>
75
bool
equalityCheck
(
const
L1GctLut<KAddressBits, KDataBits>
&
c
)
const
;
76
77
bool
m_setupOk
;
78
bool
m_verbose
;
79
80
private
:
81
82
// For use by the friend function to print the lut contents
83
static
const
int
printWidth
;
84
std::string
printHeader
()
const
;
85
std::string
printLine
(
const
int
add
)
const
;
86
87
};
88
89
template
<
int
NAddressBits,
int
NDataBits>
90
const
uint16_t
L1GctLut<NAddressBits, NDataBits>::MAX_ADDRESS_BITMASK
= (1 << NAddressBits) - 1;
91
template
<
int
NAddressBits,
int
NDataBits>
92
const
uint16_t
L1GctLut<NAddressBits, NDataBits>::MAX_DATA_BITMASK
= (1 << NDataBits) - 1;
93
94
template
<
int
NAddressBits,
int
NDataBits>
95
const
int
L1GctLut<NAddressBits, NDataBits>::printWidth
= 16;
96
97
template
<
int
NAddressBits,
int
NDataBits>
98
L1GctLut<NAddressBits, NDataBits>::L1GctLut
() :
m_setupOk
(
false
) {}
99
100
template
<
int
NAddressBits,
int
NDataBits>
101
L1GctLut<NAddressBits, NDataBits>::~L1GctLut
() {}
102
103
template
<
int
NAddressBits,
int
NDataBits>
104
uint16_t
L1GctLut<NAddressBits, NDataBits>::lutValue
(
const
uint16_t lutAddress)
const
105
{
106
if
(!
m_setupOk
)
return
(uint16_t) 0;
107
uint16_t address=(lutAddress &
MAX_ADDRESS_BITMASK
);
108
uint16_t
data
=(
value
(address) &
MAX_DATA_BITMASK
);
109
return
data
;
110
}
111
112
template
<
int
NAddressBits,
int
NDataBits>
113
template
<
int
KAddressBits,
int
KDataBits>
114
bool
L1GctLut<NAddressBits, NDataBits>::equalityCheck
(
const
L1GctLut<KAddressBits, KDataBits>
& rhsLut)
const
115
{
116
if
(KAddressBits==NAddressBits && KDataBits==NDataBits) {
117
bool
match
=
true
;
118
for
(uint16_t address=0; address<=
MAX_ADDRESS_BITMASK
; address++) {
119
if
(this->
lutValue
(address)!=rhsLut.
lutValue
(address)) { match =
false
;
break
; }
120
}
121
return
match
;
122
}
else
{
123
return
false
;
124
}
125
}
126
127
template
<
int
NAddressBits,
int
NDataBits>
128
std::string
L1GctLut<NAddressBits, NDataBits>::printHeader
()
const
129
{
130
std::stringstream ss;
131
ss << std::hex << std::showbase;
132
ss << std::setw(8) <<
"|"
;
133
for
(
int
a
=0; ((
a
<
printWidth
) && (
a
<=
MAX_ADDRESS_BITMASK
)); ++
a
) {
134
ss << std::setw(7) <<
a
;
135
}
136
ss << std::endl;
137
ss << std::setfill(
'-'
) << std::setw(8) <<
"+"
;
138
for
(
int
a
=0; ((
a
<
printWidth
) && (
a
<=
MAX_ADDRESS_BITMASK
)); ++
a
) {
139
ss << std::setw(7) <<
"-"
;
140
}
141
ss << std::endl;
142
143
return
ss.str();
144
}
145
146
template
<
int
NAddressBits,
int
NDataBits>
147
std::string
L1GctLut<NAddressBits, NDataBits>::printLine
(
const
int
add
)
const
148
{
149
std::stringstream ss;
150
ss << std::hex << std::showbase;
151
int
a
=
add
;
152
ss << std::setw(7) << a <<
"|"
;
153
for
(
int
c
=0; ((
c
<
printWidth
) && (a<=
MAX_ADDRESS_BITMASK
)); ++
c
) {
154
uint16_t address =
static_cast<
uint16_t
>
(a++);
155
ss << std::setw(7) <<
lutValue
(address);
156
}
157
ss << std::endl;
158
159
return
ss.str();
160
}
161
162
#endif
/*L1GCTLUT_H_*/
L1GctLut::setVerbose
void setVerbose()
control output messages
Definition:
L1GctLut.h:65
L1GctLut::L1GctLut
L1GctLut()
Definition:
L1GctLut.h:98
L1GctLut::printLine
std::string printLine(const int add) const
Definition:
L1GctLut.h:147
L1GctLut::setupOk
bool setupOk()
Definition:
L1GctLut.h:62
funct::false
false
Definition:
Factorize.h:35
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:255
EnergyCorrector.c
c
Definition:
EnergyCorrector.py:43
Clusterizer1DCommons::add
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
Definition:
Clusterizer1DCommons.h:26
L1GctLut::m_verbose
bool m_verbose
Definition:
L1GctLut.h:78
L1GctLut::operator[]
uint16_t operator[](const uint16_t lutAddress) const
Access the look-up table contents for a given Address.
Definition:
L1GctLut.h:52
L1GctLut::MAX_ADDRESS_BITMASK
static const uint16_t MAX_ADDRESS_BITMASK
Definition:
L1GctLut.h:23
L1GctLut::printWidth
static const int printWidth
Definition:
L1GctLut.h:83
L1GctLut
Base class for LookUp Tables.
Definition:
L1GctLut.h:20
L1GctLut::~L1GctLut
virtual ~L1GctLut()
Definition:
L1GctLut.h:101
L1GctLut::operator==
int operator==(const L1GctLut< KAddressBits, KDataBits > &rhsLut) const
Equality check between look-up tables.
Definition:
L1GctLut.h:56
L1GctLut::setTerse
void setTerse()
Definition:
L1GctLut.h:66
L1GctLut::equalityCheck
bool equalityCheck(const L1GctLut< KAddressBits, KDataBits > &c) const
Definition:
L1GctLut.h:114
L1GctLut::value
virtual uint16_t value(const uint16_t lutAddress) const =0
L1GctLut::MAX_DATA_BITMASK
static const uint16_t MAX_DATA_BITMASK
Definition:
L1GctLut.h:24
ApeEstimator_cff.width
width
Definition:
ApeEstimator_cff.py:24
L1GctLut::m_setupOk
bool m_setupOk
Definition:
L1GctLut.h:77
data
char data[epos_bytes_allocation]
Definition:
EPOS_Wrapper.h:82
L1GctLut::lutValue
uint16_t lutValue(const uint16_t lutAddress) const
Access the look-up table contents for a given Address.
Definition:
L1GctLut.h:104
a
double a
Definition:
hdecay.h:121
L1GctLut::operator!=
int operator!=(const L1GctLut< KAddressBits, KDataBits > &rhsLut) const
Inequality check between look-up tables.
Definition:
L1GctLut.h:60
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition:
Utils.h:10
L1GctLut::printHeader
std::string printHeader() const
Definition:
L1GctLut.h:128
lumiPlot.lut
lut
Definition:
lumiPlot.py:244
Generated for CMSSW Reference Manual by
1.8.11