L1Trigger
GlobalCaloTrigger
src
L1GctJetCount.h
Go to the documentation of this file.
1
#ifndef L1GCTJETCOUNT_H
2
#define L1GCTJETCOUNT_H
3
4
#include "
L1Trigger/GlobalCaloTrigger/src/L1GctUnsignedInt.h
"
5
#include "
L1Trigger/GlobalCaloTrigger/src/L1GctTwosComplement.h
"
6
7
#include <ostream>
8
29
template
<
int
nBits>
30
class
L1GctJetCount
:
public
L1GctUnsignedInt
<nBits> {
31
public
:
33
L1GctJetCount
();
35
L1GctJetCount
(
unsigned
value
);
37
~L1GctJetCount
();
38
40
template
<
int
mBits>
41
L1GctJetCount
(
const
L1GctJetCount<mBits>
& rhs);
42
44
void
setValue
(
unsigned
value
);
45
47
void
setOverFlow
(
bool
oflow);
48
50
L1GctJetCount
&
operator++
();
51
L1GctJetCount
operator++
(
int
);
52
54
L1GctJetCount
operator+
(
const
L1GctJetCount
& rhs)
const
;
55
57
L1GctJetCount
&
operator=
(
int
value
);
58
};
59
60
template
<
int
nBits>
61
L1GctJetCount<nBits>::L1GctJetCount
() :
L1GctUnsignedInt
<nBits>() {}
62
63
template
<
int
nBits>
64
L1GctJetCount<nBits>::L1GctJetCount
(
unsigned
value
) :
L1GctUnsignedInt
<nBits>(
value
) {}
65
66
template
<
int
nBits>
67
L1GctJetCount<nBits>::~L1GctJetCount
() {}
68
69
// copy contructor to move data between
70
// representations with different numbers of bits
71
template
<
int
nBits>
72
template
<
int
mBits>
73
L1GctJetCount<nBits>::L1GctJetCount
(
const
L1GctJetCount<mBits>
& rhs) {
74
this->m_nBits = nBits > 0 && nBits < this->MAX_NBITS ? nBits : 16;
75
this->
setValue
(rhs.
value
());
76
this->setOverFlow(this->overFlow() || rhs.
overFlow
());
77
}
78
79
template
<
int
nBits>
80
void
L1GctJetCount<nBits>::setValue
(
unsigned
value
) {
81
// check for overflow
82
if
(
value
>= (static_cast<unsigned>((1 << this->m_nBits) - 1))) {
83
this->m_overFlow =
true
;
84
this->m_value = ((1 << this->m_nBits) - 1);
85
}
else
{
86
this->m_value =
value
;
87
}
88
}
89
90
template
<
int
nBits>
91
void
L1GctJetCount<nBits>::setOverFlow
(
bool
oflow) {
92
this->m_overFlow = oflow;
93
if
(oflow) {
94
this->m_value = ((1 << this->m_nBits) - 1);
95
}
96
}
97
98
// increment operators
99
template
<
int
nBits>
100
L1GctJetCount<nBits>
&
L1GctJetCount<nBits>::operator++
() {
101
this->
setValue
(this->m_value + 1);
102
return
*
this
;
103
}
104
105
template
<
int
nBits>
106
L1GctJetCount<nBits>
L1GctJetCount<nBits>::operator++
(
int
) {
107
L1GctJetCount<nBits>
temp
(this->m_value);
108
temp
.setOverFlow(this->m_overFlow);
109
this->
setValue
(this->m_value + 1);
110
return
temp
;
111
}
112
113
// add two jet counts
114
template
<
int
nBits>
115
L1GctJetCount<nBits>
L1GctJetCount<nBits>::operator+
(
const
L1GctJetCount<nBits>
& rhs)
const
{
116
// temporary variable for storing the result (need to set its size)
117
L1GctJetCount<nBits>
temp
;
118
119
unsigned
sum;
120
bool
ofl;
121
122
// do the addition here
123
sum = this->
value
() + rhs.
value
();
124
ofl = this->overFlow() || rhs.
overFlow
();
125
126
//fill the temporary argument
127
temp
.setValue(sum);
128
temp
.setOverFlow(
temp
.overFlow() || ofl);
129
130
// return the temporary
131
return
temp
;
132
}
133
134
// overload assignment by int
135
template
<
int
nBits>
136
L1GctJetCount<nBits>
&
L1GctJetCount<nBits>::operator=
(
int
value
) {
137
this->
setValue
(value);
138
return
*
this
;
139
}
140
141
// overload ostream<<
142
template
<
int
nBits>
143
std::ostream&
operator<<
(std::ostream&
s
,
const
L1GctJetCount<nBits>
&
data
) {
144
s
<<
"L1GctJetCount value : "
<<
data
.value();
145
if
(
data
.overFlow()) {
146
s
<<
" Overflow set! "
;
147
}
148
149
return
s
;
150
}
151
152
// removed typedefs for slc4 compilation
153
155
//typedef L1GctJetCount<5> L1GctJcFinalType;
157
//typedef L1GctJetCount<3> L1GctJcWheelType;
158
159
#endif
L1GctJetCount::setOverFlow
void setOverFlow(bool oflow)
set the overflow bit
Definition:
L1GctJetCount.h:91
L1GctJetCount::operator++
L1GctJetCount & operator++()
Define increment operators, since this is a counter.
Definition:
L1GctJetCount.h:100
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.h
L1GctJetCount::operator+
L1GctJetCount operator+(const L1GctJetCount &rhs) const
add two numbers
Definition:
L1GctJetCount.h:115
L1GctUnsignedInt::value
unsigned value() const
access value as unsigned
Definition:
L1GctUnsignedInt.h:53
L1GctJetCount::L1GctJetCount
L1GctJetCount()
Construct a counter and initialise its value to zero.
Definition:
L1GctJetCount.h:61
groupFilesInBlocks.temp
list temp
Definition:
groupFilesInBlocks.py:142
alignCSCRings.s
s
Definition:
alignCSCRings.py:92
L1GctTwosComplement.h
L1GctJetCount::~L1GctJetCount
~L1GctJetCount()
Destructor.
Definition:
L1GctJetCount.h:67
value
Definition:
value.py:1
L1GctJetCount::setValue
void setValue(unsigned value)
Set value from unsigned.
Definition:
L1GctJetCount.h:80
L1GctUnsignedInt
Definition of unsigned integer types with overflow.
Definition:
L1GctUnsignedInt.h:27
L1GctJetCount::operator=
L1GctJetCount & operator=(int value)
overload = operator
Definition:
L1GctJetCount.h:136
relativeConstraints.value
value
Definition:
relativeConstraints.py:53
L1GctUnsignedInt::overFlow
bool overFlow() const
access overflow
Definition:
L1GctUnsignedInt.h:56
data
char data[epos_bytes_allocation]
Definition:
EPOS_Wrapper.h:79
operator<<
std::ostream & operator<<(std::ostream &s, const L1GctJetCount< nBits > &data)
Definition:
L1GctJetCount.h:143
L1GctJetCount
Definition of unsigned integer types with increment and overflow.
Definition:
L1GctJetCount.h:30
Generated for CMSSW Reference Manual by
1.8.16