#include <L1Trigger/GlobalCaloTrigger/src/L1GctUnsignedInt.h>
Public Member Functions | |
template<int mBits> | |
L1GctUnsignedInt (const L1GctUnsignedInt< mBits > &rhs) | |
Copy contructor to move data between representations with different numbers of bits. | |
L1GctUnsignedInt (unsigned value) | |
Construct an unsigned integer and check for overFlow. | |
L1GctUnsignedInt () | |
Construct an unsigned integer with initial value zero. | |
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 |
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 https://www.parashift.com/c++-faq-lite/templates.html#faq-35.12
Definition at line 29 of file L1GctUnsignedInt.h.
L1GctUnsignedInt< nBits >::L1GctUnsignedInt | ( | ) | [inline] |
Construct an unsigned integer with initial value zero.
Definition at line 86 of file L1GctUnsignedInt.h.
References L1GctUnsignedInt< nBits >::m_nBits, L1GctUnsignedInt< nBits >::MAX_NBITS, and L1GctUnsignedInt< nBits >::reset().
00086 { 00087 00088 m_nBits = nBits>0 && nBits<MAX_NBITS ? nBits : 16 ; 00089 this->reset(); 00090 }
L1GctUnsignedInt< nBits >::L1GctUnsignedInt | ( | unsigned | value | ) | [inline] |
Construct an unsigned integer and check for overFlow.
Definition at line 93 of file L1GctUnsignedInt.h.
References L1GctUnsignedInt< nBits >::m_nBits, L1GctUnsignedInt< nBits >::m_overFlow, L1GctUnsignedInt< nBits >::MAX_NBITS, and L1GctUnsignedInt< nBits >::setValue().
00093 { 00094 00095 m_nBits = nBits>0 && nBits<MAX_NBITS ? nBits : 16 ; 00096 m_overFlow = false; 00097 this->setValue(value); 00098 }
L1GctUnsignedInt< nBits >::~L1GctUnsignedInt | ( | ) | [inline] |
L1GctUnsignedInt< nBits >::L1GctUnsignedInt | ( | const L1GctUnsignedInt< mBits > & | rhs | ) | [inline] |
Copy contructor to move data between representations with different numbers of bits.
Definition at line 110 of file L1GctUnsignedInt.h.
References L1GctUnsignedInt< nBits >::m_nBits, L1GctUnsignedInt< nBits >::MAX_NBITS, L1GctUnsignedInt< nBits >::overFlow(), L1GctUnsignedInt< nBits >::setOverFlow(), L1GctUnsignedInt< nBits >::setValue(), and L1GctUnsignedInt< nBits >::value().
00110 { 00111 m_nBits = nBits>0 && nBits<MAX_NBITS ? nBits : 16 ; 00112 this->setValue( rhs.value() ); 00113 this->setOverFlow( this->overFlow() || rhs.overFlow() ); 00114 }
L1GctUnsignedInt< nBits > L1GctUnsignedInt< nBits >::operator+ | ( | const L1GctUnsignedInt< nBits > & | rhs | ) | const [inline] |
add two numbers
Definition at line 133 of file L1GctUnsignedInt.h.
References L1GctUnsignedInt< nBits >::overFlow(), L1GctUnsignedInt< nBits >::setOverFlow(), L1GctUnsignedInt< nBits >::setValue(), sum(), pyDBSRunClass::temp, and L1GctUnsignedInt< nBits >::value().
00133 { 00134 00135 // temporary variable for storing the result (need to set its size) 00136 L1GctUnsignedInt<nBits> temp; 00137 00138 unsigned sum; 00139 bool ofl; 00140 00141 // do the addition here 00142 sum = this->value() + rhs.value(); 00143 ofl = this->overFlow() || rhs.overFlow(); 00144 00145 //fill the temporary argument 00146 temp.setValue(sum); 00147 temp.setOverFlow(temp.overFlow() || ofl); 00148 00149 // return the temporary 00150 return temp; 00151 00152 }
L1GctUnsignedInt< nBits > & L1GctUnsignedInt< nBits >::operator= | ( | int | value | ) | [inline] |
overload = operator
Reimplemented in L1GctJetCount< nBits >, L1GctJetCount< 3 >, L1GctJetCount< kHfCountBits >, and L1GctJetCount< kHfEtSumBits >.
Definition at line 156 of file L1GctUnsignedInt.h.
References L1GctUnsignedInt< nBits >::setValue().
bool L1GctUnsignedInt< nBits >::overFlow | ( | ) | const [inline] |
access overflow
Definition at line 56 of file L1GctUnsignedInt.h.
References L1GctUnsignedInt< nBits >::m_overFlow.
Referenced by L1GctJetFinderBase::calcEtStrip(), L1GctJetFinderBase::calcHtStrip(), L1GctJetLeafCard::etValueForJetFinder(), L1GctJetCount< nBits >::L1GctJetCount(), L1GctUnsignedInt< nBits >::L1GctUnsignedInt(), L1GctMet::metVector(), L1GctUnsignedInt< nBits >::operator+(), L1GctJetCount< nBits >::operator+(), and L1GctGlobalEnergyAlgos::process().
00056 { return m_overFlow; }
void L1GctUnsignedInt< nBits >::reset | ( | void | ) | [inline] |
reset value and overflow to zero
Definition at line 44 of file L1GctUnsignedInt.h.
References L1GctUnsignedInt< nBits >::m_overFlow, and L1GctUnsignedInt< nBits >::m_value.
Referenced by L1GctUnsignedInt< nBits >::L1GctUnsignedInt(), L1GctJetLeafCard::process(), L1GctJetFinderBase::hfTowerSumsType::reset(), L1GctJetLeafCard::resetProcessor(), L1GctWheelJetFpga::resetProcessor(), L1GctGlobalEnergyAlgos::resetProcessor(), L1GctJetCounter::resetProcessor(), and L1GctWheelEnergyFpga::resetProcessor().
00044 { 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< 3 >, L1GctJetCount< kHfCountBits >, and L1GctJetCount< kHfEtSumBits >.
Definition at line 50 of file L1GctUnsignedInt.h.
References L1GctUnsignedInt< nBits >::m_overFlow.
Referenced by L1GctJetFinderBase::calcEtStrip(), L1GctJetFinderBase::calcHtStrip(), L1GctUnsignedInt< nBits >::L1GctUnsignedInt(), L1GctMet::metVector(), L1GctUnsignedInt< nBits >::operator+(), L1GctGlobalEnergyAlgos::setInputWheelEt(), and L1GctGlobalEnergyAlgos::setInputWheelHt().
00050 { m_overFlow = oflow; }
void L1GctUnsignedInt< nBits >::setValue | ( | unsigned | value | ) | [inline] |
Set value from unsigned.
Reimplemented in L1GctJetCount< nBits >, L1GctJetCount< 3 >, L1GctJetCount< kHfCountBits >, and L1GctJetCount< kHfEtSumBits >.
Definition at line 118 of file L1GctUnsignedInt.h.
References L1GctUnsignedInt< nBits >::m_nBits, L1GctUnsignedInt< nBits >::m_overFlow, and L1GctUnsignedInt< nBits >::m_value.
Referenced by L1GctUnsignedInt< nBits >::L1GctUnsignedInt(), L1GctMet::metVector(), L1GctUnsignedInt< nBits >::operator+(), L1GctUnsignedInt< nBits >::operator=(), L1GctGlobalEnergyAlgos::process(), L1GctGlobalEnergyAlgos::setInputWheelEt(), and L1GctGlobalEnergyAlgos::setInputWheelHt().
00119 { 00120 // check for overflow 00121 if (value >= (static_cast<unsigned>(1<<m_nBits)) ) { 00122 m_overFlow = true; 00123 } 00124 00125 // set value with bitmask 00126 m_value = value & ((1<<m_nBits) - 1); 00127 00128 }
int L1GctUnsignedInt< nBits >::size | ( | void | ) | const [inline] |
return number of bits
Definition at line 59 of file L1GctUnsignedInt.h.
References L1GctUnsignedInt< nBits >::m_nBits.
00059 { return m_nBits; }
unsigned L1GctUnsignedInt< nBits >::value | ( | void | ) | const [inline] |
access value as unsigned
Definition at line 53 of file L1GctUnsignedInt.h.
References L1GctUnsignedInt< nBits >::m_value.
Referenced by L1GctJetLeafCard::etValueForJetFinder(), L1GctJetCount< nBits >::L1GctJetCount(), L1GctUnsignedInt< nBits >::L1GctUnsignedInt(), L1GctUnsignedInt< nBits >::operator+(), L1GctJetCount< nBits >::operator+(), L1GctGlobalEnergyAlgos::process(), and L1GctGlobalHfSumAlgos::process().
00053 { return m_value; }
int L1GctUnsignedInt< nBits >::m_nBits [protected] |
Definition at line 70 of file L1GctUnsignedInt.h.
Referenced by L1GctJetCount< nBits >::L1GctJetCount(), L1GctUnsignedInt< nBits >::L1GctUnsignedInt(), L1GctJetCount< nBits >::setOverFlow(), L1GctUnsignedInt< nBits >::setValue(), L1GctJetCount< nBits >::setValue(), and L1GctUnsignedInt< nBits >::size().
bool L1GctUnsignedInt< nBits >::m_overFlow [protected] |
Definition at line 76 of file L1GctUnsignedInt.h.
Referenced by L1GctUnsignedInt< nBits >::L1GctUnsignedInt(), L1GctUnsignedInt< nBits >::overFlow(), L1GctUnsignedInt< nBits >::reset(), L1GctJetCount< nBits >::setOverFlow(), L1GctUnsignedInt< nBits >::setOverFlow(), L1GctUnsignedInt< nBits >::setValue(), and L1GctJetCount< nBits >::setValue().
unsigned L1GctUnsignedInt< nBits >::m_value [protected] |
Definition at line 73 of file L1GctUnsignedInt.h.
Referenced by L1GctUnsignedInt< nBits >::reset(), L1GctJetCount< nBits >::setOverFlow(), L1GctUnsignedInt< nBits >::setValue(), L1GctJetCount< nBits >::setValue(), and L1GctUnsignedInt< nBits >::value().
const int L1GctUnsignedInt< nBits >::MAX_NBITS = 24 [static, protected] |
Definition at line 78 of file L1GctUnsignedInt.h.
Referenced by L1GctJetCount< nBits >::L1GctJetCount(), and L1GctUnsignedInt< nBits >::L1GctUnsignedInt().