Definition of unsigned integer types with overflow. More...
#include <L1GctUnsignedInt.h>
Public Member Functions | |
L1GctUnsignedInt () | |
Construct an unsigned integer with initial value zero. | |
L1GctUnsignedInt (unsigned value) | |
Construct an unsigned integer and check for overFlow. | |
template<int mBits> | |
L1GctUnsignedInt (const L1GctUnsignedInt< mBits > &rhs) | |
Copy contructor to move data between representations with different numbers of bits. | |
L1GctUnsignedInt | operator+ (const L1GctUnsignedInt &rhs) const |
add two numbers | |
L1GctUnsignedInt & | operator= (int value) |
overload = operator | |
bool | overFlow () const |
access overflow | |
void | reset () |
reset value and overflow to zero | |
void | setOverFlow (bool oflow) |
set the overflow bit | |
void | setValue (unsigned value) |
Set value from unsigned. | |
int | size () const |
return number of bits | |
unsigned | value () const |
access value as unsigned | |
~L1GctUnsignedInt () | |
Destructor. | |
Protected Attributes | |
int | m_nBits |
bool | m_overFlow |
unsigned | m_value |
Static Protected Attributes | |
static const int | MAX_NBITS = 24 |
Definition of unsigned integer types with overflow.
This file defines the template class L1GctUnsignedInt. It is used to store energy values that are represented in a given number of bits in hardware. The type has a built-in overFlow that is set if the value to be represented is outside the allowed range for that number of bits. This type represents unsigned integers; signed integers are represented by L1GctTwosComplement. Functions are defined to add two values, and to copy data into a different number of bits.
this header file contains method definitions because these are template classes see http://www.parashift.com/c++-faq-lite/templates.html#faq-35.12
Definition at line 29 of file L1GctUnsignedInt.h.
L1GctUnsignedInt< nBits >::L1GctUnsignedInt | ( | ) |
L1GctUnsignedInt< nBits >::L1GctUnsignedInt | ( | unsigned | value | ) |
Construct an unsigned integer and check for overFlow.
Definition at line 93 of file L1GctUnsignedInt.h.
References reco::JetExtendedAssociation::setValue().
{ m_nBits = nBits>0 && nBits<MAX_NBITS ? nBits : 16 ; m_overFlow = false; this->setValue(value); }
L1GctUnsignedInt< nBits >::~L1GctUnsignedInt | ( | ) |
L1GctUnsignedInt< nBits >::L1GctUnsignedInt | ( | const L1GctUnsignedInt< mBits > & | rhs | ) |
Copy contructor to move data between representations with different numbers of bits.
Definition at line 110 of file L1GctUnsignedInt.h.
References L1GctUnsignedInt< nBits >::overFlow(), reco::JetExtendedAssociation::setValue(), and L1GctUnsignedInt< nBits >::value().
L1GctUnsignedInt< nBits > L1GctUnsignedInt< nBits >::operator+ | ( | const L1GctUnsignedInt< nBits > & | rhs | ) | const |
add two numbers
Definition at line 133 of file L1GctUnsignedInt.h.
References L1GctUnsignedInt< nBits >::overFlow(), L1GctUnsignedInt< nBits >::setOverFlow(), L1GctUnsignedInt< nBits >::setValue(), groupFilesInBlocks::temp, L1GctUnsignedInt< nBits >::value(), and relativeConstraints::value.
{ // temporary variable for storing the result (need to set its size) L1GctUnsignedInt<nBits> temp; unsigned sum; bool ofl; // do the addition here sum = this->value() + rhs.value(); ofl = this->overFlow() || rhs.overFlow(); //fill the temporary argument temp.setValue(sum); temp.setOverFlow(temp.overFlow() || ofl); // return the temporary return temp; }
L1GctUnsignedInt< nBits > & L1GctUnsignedInt< nBits >::operator= | ( | int | value | ) |
overload = operator
Reimplemented in L1GctJetCount< nBits >, L1GctJetCount< kHfCountBits >, and L1GctJetCount< kHfEtSumBits >.
Definition at line 156 of file L1GctUnsignedInt.h.
References reco::JetExtendedAssociation::setValue().
bool L1GctUnsignedInt< nBits >::overFlow | ( | ) | const [inline] |
access overflow
Definition at line 56 of file L1GctUnsignedInt.h.
Referenced by L1GctJetFinderBase::doEtSums(), L1GctJetFinderBase::doHtSums(), L1GctJetFinderBase::etComponentForJetFinder(), L1GctJetCount< nBits >::L1GctJetCount(), L1GctUnsignedInt< nBits >::L1GctUnsignedInt(), L1GctMet::metVector(), L1GctUnsignedInt< nBits >::operator+(), L1GctJetCount< nBits >::operator+(), L1GctWheelEnergyFpga::process(), L1GctGlobalEnergyAlgos::process(), and L1GctJetLeafCard::process().
{ return m_overFlow; }
void L1GctUnsignedInt< nBits >::reset | ( | void | ) | [inline] |
reset value and overflow to zero
Definition at line 44 of file L1GctUnsignedInt.h.
Referenced by L1GctJetFinderBase::hfTowerSumsType::reset(), L1GctJetLeafCard::resetProcessor(), L1GctGlobalEnergyAlgos::resetProcessor(), and L1GctWheelEnergyFpga::resetProcessor().
{ m_value = static_cast<unsigned>(0); m_overFlow = false; }
void L1GctUnsignedInt< nBits >::setOverFlow | ( | bool | oflow | ) | [inline] |
set the overflow bit
Reimplemented in L1GctJetCount< nBits >, L1GctJetCount< kHfCountBits >, and L1GctJetCount< kHfEtSumBits >.
Definition at line 50 of file L1GctUnsignedInt.h.
Referenced by L1GctJetFinderBase::doEtSums(), L1GctJetFinderBase::doHtSums(), L1GctMet::metVector(), L1GctUnsignedInt< nBits >::operator+(), L1GctGlobalEnergyAlgos::process(), L1GctGlobalEnergyAlgos::setInputWheelEt(), and L1GctGlobalEnergyAlgos::setInputWheelHt().
{ m_overFlow = oflow; }
void L1GctUnsignedInt< nBits >::setValue | ( | unsigned | value | ) |
Set value from unsigned.
Reimplemented in L1GctJetCount< nBits >, L1GctJetCount< kHfCountBits >, and L1GctJetCount< kHfEtSumBits >.
Definition at line 118 of file L1GctUnsignedInt.h.
Referenced by L1GctJetFinderBase::doEtSums(), L1GctJetFinderBase::doHtSums(), L1GctMet::metVector(), L1GctUnsignedInt< nBits >::operator+(), L1GctWheelEnergyFpga::process(), L1GctGlobalEnergyAlgos::process(), L1GctJetLeafCard::process(), L1GctGlobalEnergyAlgos::setInputWheelEt(), and L1GctGlobalEnergyAlgos::setInputWheelHt().
int L1GctUnsignedInt< nBits >::size | ( | void | ) | const [inline] |
unsigned L1GctUnsignedInt< nBits >::value | ( | void | ) | const [inline] |
access value as unsigned
Definition at line 53 of file L1GctUnsignedInt.h.
Referenced by L1GctJetFinderBase::etComponentForJetFinder(), L1GctJetCount< nBits >::L1GctJetCount(), L1GctUnsignedInt< nBits >::L1GctUnsignedInt(), L1GctUnsignedInt< nBits >::operator+(), L1GctJetCount< nBits >::operator+(), L1GctGlobalEnergyAlgos::process(), and L1GctGlobalHfSumAlgos::process().
{ return m_value; }
int L1GctUnsignedInt< nBits >::m_nBits [protected] |
Definition at line 70 of file L1GctUnsignedInt.h.
Referenced by L1GctUnsignedInt< L1GctInternEtSum::kTotEtOrHtNBits >::size().
bool L1GctUnsignedInt< nBits >::m_overFlow [protected] |
unsigned L1GctUnsignedInt< nBits >::m_value [protected] |
Definition at line 73 of file L1GctUnsignedInt.h.
Referenced by L1GctUnsignedInt< L1GctInternEtSum::kTotEtOrHtNBits >::reset(), and L1GctUnsignedInt< L1GctInternEtSum::kTotEtOrHtNBits >::value().
const int L1GctUnsignedInt< nBits >::MAX_NBITS = 24 [static, protected] |
Definition at line 78 of file L1GctUnsignedInt.h.