CMS 3D CMS Logo

Public Member Functions

L1GctJetCount< nBits > Class Template Reference

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

#include <L1GctJetCount.h>

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

List of all members.

Public Member Functions

 L1GctJetCount ()
 Construct a counter and initialise its value to zero.
 L1GctJetCount (unsigned value)
 Construct a counter, checking for overFlow.
template<int mBits>
 L1GctJetCount (const L1GctJetCount< mBits > &rhs)
 Copy contructor to move data between representations with different numbers of bits.
L1GctJetCount operator+ (const L1GctJetCount &rhs) const
 add two numbers
L1GctJetCount operator++ (int)
L1GctJetCountoperator++ ()
 Define increment operators, since this is a counter.
L1GctJetCountoperator= (int value)
 overload = operator
void setOverFlow (bool oflow)
 set the overflow bit
void setValue (unsigned value)
 Set value from unsigned.
 ~L1GctJetCount ()
 Destructor.

Detailed Description

template<int nBits>
class L1GctJetCount< nBits >

Definition of unsigned integer types with increment and overflow.

This file defines the template class L1GctJetCount. It is used to store energy values that are represented in a given number of bits in hardware. The value is set to the maximum (all bits set to '1') to represent an overFlow condition, if the number to be represented is outside the allowed range for that number of bits. The counters are unsigned integers. Functions are defined to increment the counter, 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 31 of file L1GctJetCount.h.


Constructor & Destructor Documentation

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

Construct a counter and initialise its value to zero.

Definition at line 65 of file L1GctJetCount.h.

template<int nBits>
L1GctJetCount< nBits >::L1GctJetCount ( unsigned  value)

Construct a counter, checking for overFlow.

Definition at line 68 of file L1GctJetCount.h.

template<int nBits>
L1GctJetCount< nBits >::~L1GctJetCount ( )

Destructor.

Definition at line 71 of file L1GctJetCount.h.

{}
template<int nBits>
template<int mBits>
L1GctJetCount< nBits >::L1GctJetCount ( const L1GctJetCount< mBits > &  rhs)

Copy contructor to move data between representations with different numbers of bits.

Definition at line 77 of file L1GctJetCount.h.

References L1GctUnsignedInt< nBits >::overFlow(), reco::JetExtendedAssociation::setValue(), and L1GctUnsignedInt< nBits >::value().

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

Member Function Documentation

template<int nBits>
L1GctJetCount< nBits > L1GctJetCount< nBits >::operator+ ( const L1GctJetCount< nBits > &  rhs) const

add two numbers

Definition at line 125 of file L1GctJetCount.h.

References L1GctUnsignedInt< nBits >::overFlow(), L1GctJetCount< nBits >::setOverFlow(), L1GctJetCount< nBits >::setValue(), groupFilesInBlocks::temp, L1GctUnsignedInt< nBits >::value(), and relativeConstraints::value.

                                                                      {

  // temporary variable for storing the result (need to set its size)
  L1GctJetCount<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>
L1GctJetCount< nBits > & L1GctJetCount< nBits >::operator++ ( void  )

Define increment operators, since this is a counter.

Definition at line 106 of file L1GctJetCount.h.

References reco::JetExtendedAssociation::setValue().

                                  {

  this->setValue(this->m_value+1);
  return *this;
}
template<int nBits>
L1GctJetCount< nBits > L1GctJetCount< nBits >::operator++ ( int  )
template<int nBits>
L1GctJetCount< nBits > & L1GctJetCount< nBits >::operator= ( int  value)

overload = operator

Reimplemented from L1GctUnsignedInt< nBits >.

Definition at line 148 of file L1GctJetCount.h.

References reco::JetExtendedAssociation::setValue().

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

}
template<int nBits>
void L1GctJetCount< nBits >::setOverFlow ( bool  oflow)

set the overflow bit

Reimplemented from L1GctUnsignedInt< nBits >.

Definition at line 97 of file L1GctJetCount.h.

Referenced by L1GctJetCount< nBits >::operator+(), and L1GctJetCount< nBits >::operator++().

{
  this->m_overFlow = oflow;
  if (oflow) { this->m_value = ((1<<this->m_nBits) - 1); }
}
template<int nBits>
void L1GctJetCount< nBits >::setValue ( unsigned  value)

Set value from unsigned.

Reimplemented from L1GctUnsignedInt< nBits >.

Definition at line 84 of file L1GctJetCount.h.

References relativeConstraints::value.

Referenced by L1GctJetCount< nBits >::operator+().

{
  // check for overflow
  if (value >= (static_cast<unsigned>((1<<this->m_nBits) - 1)) ) {
    this->m_overFlow = true;
    this->m_value = ((1<<this->m_nBits) - 1);
  } else {
    this->m_value = value;
  }

}