Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
src
L1Trigger
GlobalCaloTrigger
src
L1GctUnsignedInt.h
Go to the documentation of this file.
1
#ifndef L1GCTUNSIGNEDINT_H
2
#define L1GCTUNSIGNEDINT_H
3
4
#include <boost/cstdint.hpp>
5
#include <ostream>
6
28
template
<
int
nBits>
29
class
L1GctUnsignedInt
{
30
31
public
:
32
34
L1GctUnsignedInt
();
36
L1GctUnsignedInt
(
unsigned
value
);
38
~L1GctUnsignedInt
();
39
41
template
<
int
mBits>
L1GctUnsignedInt
(
const
L1GctUnsignedInt<mBits>
& rhs);
42
44
void
reset
() {
m_value
=
static_cast<
unsigned
>
(0);
m_overFlow
=
false
; }
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
69
// number of bits
70
int
m_nBits
;
71
72
// value
73
unsigned
m_value
;
74
75
// overflow
76
bool
m_overFlow
;
77
78
static
const
int
MAX_NBITS
= 24;
79
80
};
81
82
template
<
int
nBits>
83
std::ostream& operator<<(std::ostream& s, const L1GctUnsignedInt<nBits>&
data
);
84
85
template
<
int
nBits>
86
L1GctUnsignedInt<nBits>::L1GctUnsignedInt
() {
87
88
m_nBits = nBits>0 && nBits<MAX_NBITS ? nBits : 16 ;
89
this->
reset
();
90
}
91
92
template
<
int
nBits>
93
L1GctUnsignedInt<nBits>::L1GctUnsignedInt
(
unsigned
value
) {
94
95
m_nBits = nBits>0 && nBits<MAX_NBITS ? nBits : 16 ;
96
m_overFlow =
false
;
97
this->
setValue
(value);
98
}
99
100
template
<
int
nBits>
101
L1GctUnsignedInt<nBits>::~L1GctUnsignedInt
()
102
{
103
104
}
105
106
// copy contructor to move data between
107
// representations with different numbers of bits
108
template
<
int
nBits>
109
template
<
int
mBits>
110
L1GctUnsignedInt<nBits>::L1GctUnsignedInt
(
const
L1GctUnsignedInt<mBits>
& rhs) {
111
m_nBits = nBits>0 && nBits<MAX_NBITS ? nBits : 16 ;
112
this->
setValue
( rhs.
value
() );
113
this->setOverFlow( this->overFlow() || rhs.
overFlow
() );
114
}
115
116
// set value, checking for overflow
117
template
<
int
nBits>
118
void
L1GctUnsignedInt<nBits>::setValue
(
unsigned
value
)
119
{
120
// check for overflow
121
if
(value >= (static_cast<unsigned>(1<<m_nBits)) ) {
122
m_overFlow =
true
;
123
}
124
125
// set value with bitmask
126
m_value = value & ((1<<m_nBits) - 1);
127
128
}
129
130
// add two unsigneds
131
template
<
int
nBits>
132
L1GctUnsignedInt<nBits>
133
L1GctUnsignedInt<nBits>::operator+
(
const
L1GctUnsignedInt<nBits>
&rhs)
const
{
134
135
// temporary variable for storing the result (need to set its size)
136
L1GctUnsignedInt<nBits>
temp
;
137
138
unsigned
sum;
139
bool
ofl;
140
141
// do the addition here
142
sum = this->
value
() + rhs.
value
();
143
ofl = this->overFlow() || rhs.
overFlow
();
144
145
//fill the temporary argument
146
temp.
setValue
(sum);
147
temp.
setOverFlow
(temp.
overFlow
() || ofl);
148
149
// return the temporary
150
return
temp
;
151
152
}
153
154
// overload assignment by int
155
template
<
int
nBits>
156
L1GctUnsignedInt<nBits>
&
L1GctUnsignedInt<nBits>::operator=
(
int
value
) {
157
158
this->
setValue
(value);
159
return
*
this
;
160
161
}
162
163
164
// overload ostream<<
165
template
<
int
nBits>
166
std::ostream& operator<<(std::ostream& s, const L1GctUnsignedInt<nBits>&
data
) {
167
168
s
<<
"L1GctUnsignedInt value : "
<<
data
.value();
169
if
(
data
.overFlow()) {
s
<<
" Overflow set! "
; }
170
171
return
s
;
172
173
}
174
175
176
#endif
177
L1GctUnsignedInt::setOverFlow
void setOverFlow(bool oflow)
set the overflow bit
Definition:
L1GctUnsignedInt.h:50
relativeConstraints.value
tuple value
Definition:
relativeConstraints.py:54
groupFilesInBlocks.temp
temp
Definition:
groupFilesInBlocks.py:140
L1GctUnsignedInt
Definition of unsigned integer types with overflow.
Definition:
L1GctUnsignedInt.h:29
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::m_value
unsigned m_value
Definition:
L1GctUnsignedInt.h:73
L1GctUnsignedInt::value
unsigned value() const
access value as unsigned
Definition:
L1GctUnsignedInt.h:53
L1GctUnsignedInt::m_overFlow
bool m_overFlow
Definition:
L1GctUnsignedInt.h:76
L1GctUnsignedInt::MAX_NBITS
static const int MAX_NBITS
Definition:
L1GctUnsignedInt.h:78
L1GctUnsignedInt::~L1GctUnsignedInt
~L1GctUnsignedInt()
Destructor.
Definition:
L1GctUnsignedInt.h:101
alignCSCRings.s
list s
Definition:
alignCSCRings.py:91
L1GctUnsignedInt::L1GctUnsignedInt
L1GctUnsignedInt()
Construct an unsigned integer with initial value zero.
Definition:
L1GctUnsignedInt.h:86
L1GctUnsignedInt::size
int size() const
return number of bits
Definition:
L1GctUnsignedInt.h:59
L1GctUnsignedInt::reset
void reset()
reset value and overflow to zero
Definition:
L1GctUnsignedInt.h:44
L1GctUnsignedInt::operator+
L1GctUnsignedInt operator+(const L1GctUnsignedInt &rhs) const
add two numbers
Definition:
L1GctUnsignedInt.h:133
data
char data[epos_bytes_allocation]
Definition:
EPOS_Wrapper.h:82
L1GctUnsignedInt::setValue
void setValue(unsigned value)
Set value from unsigned.
Definition:
L1GctUnsignedInt.h:118
L1GctUnsignedInt::operator=
L1GctUnsignedInt & operator=(int value)
overload = operator
Definition:
L1GctUnsignedInt.h:156
L1GctUnsignedInt::overFlow
bool overFlow() const
access overflow
Definition:
L1GctUnsignedInt.h:56
reset
void reset(double vett[256])
Definition:
TPedValues.cc:11
L1GctUnsignedInt::m_nBits
int m_nBits
Definition:
L1GctUnsignedInt.h:70
Generated for CMSSW Reference Manual by
1.8.5