src
L1Trigger
GlobalCaloTrigger
interface
L1GctUnsignedInt.h
Go to the documentation of this file.
1
#ifndef L1GCTUNSIGNEDINT_H
2
#define L1GCTUNSIGNEDINT_H
3
4
#include <ostream>
5
26
template
<
int
nBits>
27
class
L1GctUnsignedInt
{
28
public
:
30
L1GctUnsignedInt
();
32
L1GctUnsignedInt
(
unsigned
value
);
34
~L1GctUnsignedInt
();
35
37
template
<
int
mBits>
38
L1GctUnsignedInt
(
const
L1GctUnsignedInt<mBits>
& rhs);
39
41
void
reset
() {
42
m_value
=
static_cast<
unsigned
>
(0);
43
m_overFlow
=
false
;
44
}
45
47
void
setValue
(
unsigned
value
);
48
50
void
setOverFlow
(
bool
oflow) {
m_overFlow
= oflow; }
51
53
unsigned
value
()
const
{
return
m_value
; }
54
56
bool
overFlow
()
const
{
return
m_overFlow
; }
57
59
int
size
()
const
{
return
m_nBits
; }
60
62
L1GctUnsignedInt
operator+
(
const
L1GctUnsignedInt
& rhs)
const
;
63
65
L1GctUnsignedInt
&
operator=
(
int
value
);
66
67
protected
:
68
// number of bits
69
int
m_nBits
;
70
71
// value
72
unsigned
m_value
;
73
74
// overflow
75
bool
m_overFlow
;
76
77
static
const
int
MAX_NBITS
= 24;
78
};
79
80
template
<
int
nBits>
81
std::ostream& operator<<(std::ostream& s, const L1GctUnsignedInt<nBits>&
data
);
82
83
template
<
int
nBits>
84
L1GctUnsignedInt<nBits>::L1GctUnsignedInt
() {
85
m_nBits = nBits > 0 && nBits < MAX_NBITS ? nBits : 16;
86
this->
reset
();
87
}
88
89
template
<
int
nBits>
90
L1GctUnsignedInt<nBits>::L1GctUnsignedInt
(
unsigned
value
) {
91
m_nBits = nBits > 0 && nBits < MAX_NBITS ? nBits : 16;
92
m_overFlow =
false
;
93
this->
setValue
(value);
94
}
95
96
template
<
int
nBits>
97
L1GctUnsignedInt<nBits>::~L1GctUnsignedInt
() {}
98
99
// copy contructor to move data between
100
// representations with different numbers of bits
101
template
<
int
nBits>
102
template
<
int
mBits>
103
L1GctUnsignedInt<nBits>::L1GctUnsignedInt
(
const
L1GctUnsignedInt<mBits>
& rhs) {
104
m_nBits = nBits > 0 && nBits < MAX_NBITS ? nBits : 16;
105
this->
setValue
(rhs.
value
());
106
this->setOverFlow(this->overFlow() || rhs.
overFlow
());
107
}
108
109
// set value, checking for overflow
110
template
<
int
nBits>
111
void
L1GctUnsignedInt<nBits>::setValue
(
unsigned
value
) {
112
// check for overflow
113
if
(
value
>= (static_cast<unsigned>(1 << m_nBits))) {
114
m_overFlow =
true
;
115
}
116
117
// set value with bitmask
118
m_value =
value
& ((1 << m_nBits) - 1);
119
}
120
121
// add two unsigneds
122
template
<
int
nBits>
123
L1GctUnsignedInt<nBits>
L1GctUnsignedInt<nBits>::operator+
(
const
L1GctUnsignedInt<nBits>
& rhs)
const
{
124
// temporary variable for storing the result (need to set its size)
125
L1GctUnsignedInt<nBits>
temp
;
126
127
unsigned
sum;
128
bool
ofl;
129
130
// do the addition here
131
sum = this->
value
() + rhs.
value
();
132
ofl = this->overFlow() || rhs.
overFlow
();
133
134
//fill the temporary argument
135
temp
.setValue(sum);
136
temp
.setOverFlow(
temp
.overFlow() || ofl);
137
138
// return the temporary
139
return
temp
;
140
}
141
142
// overload assignment by int
143
template
<
int
nBits>
144
L1GctUnsignedInt<nBits>
&
L1GctUnsignedInt<nBits>::operator=
(
int
value
) {
145
this->
setValue
(value);
146
return
*
this
;
147
}
148
149
// overload ostream<<
150
template
<
int
nBits>
151
std::ostream& operator<<(std::ostream& s, const L1GctUnsignedInt<nBits>&
data
) {
152
s
<<
"L1GctUnsignedInt value : "
<<
data
.value();
153
if
(
data
.overFlow()) {
154
s
<<
" Overflow set! "
;
155
}
156
157
return
s
;
158
}
159
160
#endif
L1GctUnsignedInt::setOverFlow
void setOverFlow(bool oflow)
set the overflow bit
Definition:
L1GctUnsignedInt.h:50
L1GctUnsignedInt::value
unsigned value() const
access value as unsigned
Definition:
L1GctUnsignedInt.h:53
alignCSCRings.s
s
Definition:
alignCSCRings.py:92
groupFilesInBlocks.temp
list temp
Definition:
groupFilesInBlocks.py:142
L1GctUnsignedInt
Definition of unsigned integer types with overflow.
Definition:
L1GctUnsignedInt.h:27
reco::JetExtendedAssociation::setValue
bool setValue(Container &, const reco::JetBaseRef &, const JetExtendedData &)
associate jet with value. Returns false and associate nothing if jet is already associated ...
Definition:
JetExtendedAssociation.cc:44
L1GctUnsignedInt::overFlow
bool overFlow() const
access overflow
Definition:
L1GctUnsignedInt.h:56
L1GctUnsignedInt::m_value
unsigned m_value
Definition:
L1GctUnsignedInt.h:72
L1GctUnsignedInt::m_overFlow
bool m_overFlow
Definition:
L1GctUnsignedInt.h:75
L1GctUnsignedInt::MAX_NBITS
static const int MAX_NBITS
Definition:
L1GctUnsignedInt.h:77
L1GctUnsignedInt::size
int size() const
return number of bits
Definition:
L1GctUnsignedInt.h:59
value
Definition:
value.py:1
L1GctUnsignedInt::~L1GctUnsignedInt
~L1GctUnsignedInt()
Destructor.
Definition:
L1GctUnsignedInt.h:97
relativeConstraints.value
value
Definition:
relativeConstraints.py:53
L1GctUnsignedInt::L1GctUnsignedInt
L1GctUnsignedInt()
Construct an unsigned integer with initial value zero.
Definition:
L1GctUnsignedInt.h:84
L1GctUnsignedInt::reset
void reset()
reset value and overflow to zero
Definition:
L1GctUnsignedInt.h:41
data
char data[epos_bytes_allocation]
Definition:
EPOS_Wrapper.h:80
L1GctUnsignedInt::setValue
void setValue(unsigned value)
Set value from unsigned.
Definition:
L1GctUnsignedInt.h:111
L1GctUnsignedInt::operator=
L1GctUnsignedInt & operator=(int value)
overload = operator
Definition:
L1GctUnsignedInt.h:144
L1GctUnsignedInt::operator+
L1GctUnsignedInt operator+(const L1GctUnsignedInt &rhs) const
add two numbers
Definition:
L1GctUnsignedInt.h:123
reset
void reset(double vett[256])
Definition:
TPedValues.cc:11
L1GctUnsignedInt::m_nBits
int m_nBits
Definition:
L1GctUnsignedInt.h:69
Generated for CMSSW Reference Manual by
1.8.14