4 #include <boost/cstdint.hpp>
97 std::ostream& operator<<(std::ostream& s, const L1GctTwosComplement<nBits>&
data);
102 m_nBits = nBits>0 && nBits<MAX_NBITS ? nBits : 16 ;
109 m_nBits = nBits>0 && nBits<MAX_NBITS ? nBits : 16 ;
117 m_nBits = nBits>0 && nBits<MAX_NBITS ? nBits : 16 ;
127 m_nBits = nBits>0 && nBits<MAX_NBITS ? nBits : 16 ;
128 this->setRaw( rhs.
raw() );
129 this->setOverFlow( this->overFlow() || rhs.
overFlow() );
135 m_data =
static_cast<uint32_t
>(0);
142 checkOverFlow(raw, m_data, m_overFlow);
148 int chkValue, posValue;
153 if (chkValue<-MAX_VALUE) { chkValue = -MAX_VALUE; m_overFlow =
true; }
154 if (chkValue>=MAX_VALUE) { chkValue = MAX_VALUE-1; m_overFlow =
true; }
157 posValue = chkValue<0 ? chkValue + (1<<MAX_NBITS) : chkValue ;
158 raw =
static_cast<uint32_t
>(posValue);
169 maxValueInNbits = 1<<(m_nBits-1);
170 value =
static_cast<int>(m_data);
171 result = value < maxValueInNbits ? value : value - (1<<MAX_NBITS) ;
186 sum = this->raw() + rhs.
raw();
187 ofl = this->overFlow() || rhs.
overFlow();
220 uint32_t signBit = 1<<(m_nBits-1);
221 uint32_t signExtendBits = (
static_cast<uint32_t
>(MAX_VALUE)-signBit)<<1;
223 uint32_t mskRawValue = rawValue & ((1<<MAX_NBITS)-1);
227 if ((mskRawValue&signBit)==0) {
228 value = mskRawValue & ~signExtendBits;
230 value = mskRawValue | signExtendBits;
232 ofl = value != mskRawValue;
241 std::ostream& operator<<(std::ostream& s, const L1GctTwosComplement<nBits>&
data) {
243 s <<
"L1GctTwosComplement<" <<
data.size() <<
"> raw : " <<
data.raw() <<
", " <<
"value : " <<
data.value();
244 if (
data.overFlow()) {
s <<
" Overflow set! "; }
bool overFlow() const
access overflow
void setOverFlow(bool oflow)
set the overflow bit
void setRaw(uint32_t raw)
set the raw data
uint32_t raw() const
access raw data
~L1GctTwosComplement()
Destructor.
bool setValue(Container &, const reco::JetBaseRef &, const JetExtendedData &)
associate jet with value. Returns false and associate nothing if jet is already associated ...
Definition of signed integer types with overflow.
static const int MAX_VALUE
void setValue(int value)
set value from signed int
void checkOverFlow(uint32_t rawValue, uint32_t &maskValue, bool &overFlow)
L1GctTwosComplement()
Construct a signed integer with initial value zero.
int value() const
access value as signed int
L1GctTwosComplement operator-() const
overload unary - (negation) operator
int size() const
return number of bits
void reset()
reset value and overflow to zero
L1GctTwosComplement operator+(const L1GctTwosComplement &rhs) const
add two numbers of the same size
void reset(double vett[256])
static const int MAX_NBITS
L1GctTwosComplement & operator=(int value)
overload = operator