CMS 3D CMS Logo

Public Member Functions | Protected Attributes | Static Protected Attributes

L1GctUnsignedInt< nBits > Class Template Reference

Definition of unsigned integer types with overflow. More...

#include <L1GctUnsignedInt.h>

Inheritance diagram for L1GctUnsignedInt< nBits >:
L1GctJetCount< nBits >

List of all members.

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
L1GctUnsignedIntoperator= (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

Detailed Description

template<int nBits>
class L1GctUnsignedInt< nBits >

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 https://www.parashift.com/c++-faq-lite/templates.html#faq-35.12

Author:
Jim Brooke & Greg Heath
Date:
May 2006

Definition at line 29 of file L1GctUnsignedInt.h.


Constructor & Destructor Documentation

template<int nBits>
L1GctUnsignedInt< nBits >::L1GctUnsignedInt ( )

Construct an unsigned integer with initial value zero.

Definition at line 86 of file L1GctUnsignedInt.h.

References reset().

                                          {

  m_nBits = nBits>0 && nBits<MAX_NBITS ? nBits : 16 ;
  this->reset();
}
template<int nBits>
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);
}
template<int nBits>
L1GctUnsignedInt< nBits >::~L1GctUnsignedInt ( )

Destructor.

Definition at line 101 of file L1GctUnsignedInt.h.

{

}
template<int nBits>
template<int mBits>
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().

                                                                            {
  m_nBits = nBits>0 && nBits<MAX_NBITS ? nBits : 16 ;
  this->setValue( rhs.value() );
  this->setOverFlow( this->overFlow() || rhs.overFlow() );
}

Member Function Documentation

template<int nBits>
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;

}
template<int nBits>
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().

                                                                      {
  
  this->setValue(value);
  return *this;

}
template<int nBits>
bool L1GctUnsignedInt< nBits >::overFlow ( ) const [inline]
template<int nBits>
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; }
template<int nBits>
void L1GctUnsignedInt< nBits >::setOverFlow ( bool  oflow) [inline]
template<int nBits>
void L1GctUnsignedInt< nBits >::setValue ( unsigned  value)
template<int nBits>
int L1GctUnsignedInt< nBits >::size ( void  ) const [inline]

return number of bits

Definition at line 59 of file L1GctUnsignedInt.h.

{ return m_nBits; }
template<int nBits>
unsigned L1GctUnsignedInt< nBits >::value ( void  ) const [inline]

Member Data Documentation

template<int nBits>
int L1GctUnsignedInt< nBits >::m_nBits [protected]
template<int nBits>
bool L1GctUnsignedInt< nBits >::m_overFlow [protected]
template<int nBits>
unsigned L1GctUnsignedInt< nBits >::m_value [protected]
template<int nBits>
const int L1GctUnsignedInt< nBits >::MAX_NBITS = 24 [static, protected]

Definition at line 78 of file L1GctUnsignedInt.h.