CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | 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 >

Public Member Functions

 L1GctJetCount ()
 Construct a counter and initialise its value to zero. More...
 
 L1GctJetCount (unsigned value)
 Construct a counter, checking for overFlow. More...
 
template<int mBits>
 L1GctJetCount (const L1GctJetCount< mBits > &rhs)
 Copy contructor to move data between representations with different numbers of bits. More...
 
L1GctJetCount operator+ (const L1GctJetCount &rhs) const
 add two numbers More...
 
L1GctJetCountoperator++ ()
 Define increment operators, since this is a counter. More...
 
L1GctJetCount operator++ (int)
 
L1GctJetCountoperator= (int value)
 overload = operator More...
 
void setOverFlow (bool oflow)
 set the overflow bit More...
 
void setValue (unsigned value)
 Set value from unsigned. More...
 
 ~L1GctJetCount ()
 Destructor. More...
 
- Public Member Functions inherited from L1GctUnsignedInt< nBits >
 L1GctUnsignedInt ()
 Construct an unsigned integer with initial value zero. More...
 
 L1GctUnsignedInt (unsigned value)
 Construct an unsigned integer and check for overFlow. More...
 
template<int mBits>
 L1GctUnsignedInt (const L1GctUnsignedInt< mBits > &rhs)
 Copy contructor to move data between representations with different numbers of bits. More...
 
L1GctUnsignedInt operator+ (const L1GctUnsignedInt &rhs) const
 add two numbers More...
 
L1GctUnsignedIntoperator= (int value)
 overload = operator More...
 
bool overFlow () const
 access overflow More...
 
void reset ()
 reset value and overflow to zero More...
 
void setOverFlow (bool oflow)
 set the overflow bit More...
 
void setValue (unsigned value)
 Set value from unsigned. More...
 
int size () const
 return number of bits More...
 
unsigned value () const
 access value as unsigned More...
 
 ~L1GctUnsignedInt ()
 Destructor. More...
 

Additional Inherited Members

- Protected Attributes inherited from L1GctUnsignedInt< nBits >
int m_nBits
 
bool m_overFlow
 
unsigned m_value
 
- Static Protected Attributes inherited from L1GctUnsignedInt< nBits >
static const int MAX_NBITS = 24
 

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 http://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.

Definition of unsigned integer types with overflow.
template<int nBits>
L1GctJetCount< nBits >::L1GctJetCount ( unsigned  value)

Construct a counter, checking for overFlow.

Definition at line 68 of file L1GctJetCount.h.

Definition of unsigned integer types with overflow.
unsigned value() const
access value as unsigned
template<int nBits>
L1GctJetCount< nBits >::~L1GctJetCount ( )

Destructor.

Definition at line 71 of file L1GctJetCount.h.

71 {}
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().

77  {
78  this->m_nBits = nBits>0 && nBits<this->MAX_NBITS ? nBits : 16 ;
79  this->setValue( rhs.value() );
80  this->setOverFlow( this->overFlow() || rhs.overFlow() );
81 }
void setOverFlow(bool oflow)
set the overflow bit
Definition: L1GctJetCount.h:97
void setValue(unsigned value)
Set value from unsigned.
Definition: L1GctJetCount.h:84
unsigned value() const
access value as unsigned
static const int MAX_NBITS
bool overFlow() const
access 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.

125  {
126 
127  // temporary variable for storing the result (need to set its size)
129 
130  unsigned sum;
131  bool ofl;
132 
133  // do the addition here
134  sum = this->value() + rhs.value();
135  ofl = this->overFlow() || rhs.overFlow();
136 
137  //fill the temporary argument
138  temp.setValue(sum);
139  temp.setOverFlow(temp.overFlow() || ofl);
140 
141  // return the temporary
142  return temp;
143 
144 }
Definition of unsigned integer types with increment and overflow.
Definition: L1GctJetCount.h:31
void setOverFlow(bool oflow)
set the overflow bit
Definition: L1GctJetCount.h:97
void setValue(unsigned value)
Set value from unsigned.
Definition: L1GctJetCount.h:84
unsigned value() const
access value as unsigned
bool overFlow() const
access overflow
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().

106  {
107 
108  this->setValue(this->m_value+1);
109  return *this;
110 }
void setValue(unsigned value)
Set value from unsigned.
Definition: L1GctJetCount.h:84
template<int nBits>
L1GctJetCount< nBits > L1GctJetCount< nBits >::operator++ ( int  )

Definition at line 114 of file L1GctJetCount.h.

References L1GctJetCount< nBits >::setOverFlow(), reco::JetExtendedAssociation::setValue(), and groupFilesInBlocks::temp.

114  {
115 
117  temp.setOverFlow(this->m_overFlow);
118  this->setValue(this->m_value+1);
119  return temp;
120 }
Definition of unsigned integer types with increment and overflow.
Definition: L1GctJetCount.h:31
void setValue(unsigned value)
Set value from unsigned.
Definition: L1GctJetCount.h:84
template<int nBits>
L1GctJetCount< nBits > & L1GctJetCount< nBits >::operator= ( int  value)

overload = operator

Definition at line 148 of file L1GctJetCount.h.

References reco::JetExtendedAssociation::setValue().

148  {
149 
150  this->setValue(value);
151  return *this;
152 
153 }
void setValue(unsigned value)
Set value from unsigned.
Definition: L1GctJetCount.h:84
unsigned value() const
access value as unsigned
template<int nBits>
void L1GctJetCount< nBits >::setOverFlow ( bool  oflow)

set the overflow bit

Definition at line 97 of file L1GctJetCount.h.

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

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

Set value from unsigned.

Definition at line 84 of file L1GctJetCount.h.

References relativeConstraints::value.

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

85 {
86  // check for overflow
87  if (value >= (static_cast<unsigned>((1<<this->m_nBits) - 1)) ) {
88  this->m_overFlow = true;
89  this->m_value = ((1<<this->m_nBits) - 1);
90  } else {
91  this->m_value = value;
92  }
93 
94 }
unsigned value() const
access value as unsigned