95 std::ostream& operator<<(std::ostream& s, const L1GctTwosComplement<nBits>&
data);
100 m_nBits = nBits > 0 && nBits < MAX_NBITS ? nBits : 16;
107 m_nBits = nBits > 0 && nBits < MAX_NBITS ? nBits : 16;
115 m_nBits = nBits > 0 && nBits < MAX_NBITS ? nBits : 16;
125 m_nBits = nBits > 0 && nBits < MAX_NBITS ? nBits : 16;
126 this->setRaw(rhs.
raw());
127 this->setOverFlow(this->overFlow() || rhs.
overFlow());
133 m_data =
static_cast<uint32_t
>(0);
140 checkOverFlow(raw, m_data, m_overFlow);
146 int chkValue, posValue;
151 if (chkValue < -MAX_VALUE) {
152 chkValue = -MAX_VALUE;
155 if (chkValue >= MAX_VALUE) {
156 chkValue = MAX_VALUE - 1;
161 posValue = chkValue < 0 ? chkValue + (1 << MAX_NBITS) : chkValue;
162 raw =
static_cast<uint32_t
>(posValue);
173 maxValueInNbits = 1 << (m_nBits - 1);
174 value =
static_cast<int>(m_data);
188 sum = this->raw() + rhs.
raw();
189 ofl = this->overFlow() || rhs.
overFlow();
193 temp.setOverFlow(
temp.overFlow() || ofl);
218 uint32_t signBit = 1 << (m_nBits - 1);
219 uint32_t signExtendBits = (
static_cast<uint32_t
>(MAX_VALUE) - signBit) << 1;
221 uint32_t mskRawValue = rawValue & ((1 << MAX_NBITS) - 1);
225 if ((mskRawValue & signBit) == 0) {
226 value = mskRawValue & ~signExtendBits;
228 value = mskRawValue | signExtendBits;
230 ofl =
value != mskRawValue;
238 std::ostream& operator<<(std::ostream& s, const L1GctTwosComplement<nBits>&
data) {
239 s <<
"L1GctTwosComplement<" <<
data.size() <<
"> raw : " <<
data.raw() <<
", " 240 <<
"value : " <<
data.value();
241 if (
data.overFlow()) {
242 s <<
" Overflow set! ";
void setOverFlow(bool oflow)
set the overflow bit
void setRaw(uint32_t raw)
set the raw data
L1GctTwosComplement operator+(const L1GctTwosComplement &rhs) const
add two numbers of the same size
int value() const
access value as signed int
~L1GctTwosComplement()
Destructor.
bool setValue(Container &, const reco::JetBaseRef &, const JetExtendedData &)
associate jet with value. Returns false and associate nothing if jet is already associated ...
uint32_t raw() const
access raw data
Definition of signed integer types with overflow.
static const int MAX_VALUE
void setValue(int value)
set value from signed int
L1GctTwosComplement operator-() const
overload unary - (negation) operator
void checkOverFlow(uint32_t rawValue, uint32_t &maskValue, bool &overFlow)
L1GctTwosComplement()
Construct a signed integer with initial value zero.
char data[epos_bytes_allocation]
void reset()
reset value and overflow to zero
int size() const
return number of bits
bool overFlow() const
access overflow
void reset(double vett[256])
static const int MAX_NBITS
L1GctTwosComplement & operator=(int value)
overload = operator