CMS 3D CMS Logo

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...
 
template<int mBits>
 L1GctJetCount (const L1GctJetCount< mBits > &rhs)
 Copy contructor to move data between representations with different numbers of bits. More...
 
 L1GctJetCount (unsigned value)
 Construct a counter, checking for overFlow. 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...
 
template<int mBits>
 L1GctUnsignedInt (const L1GctUnsignedInt< mBits > &rhs)
 Copy contructor to move data between representations with different numbers of bits. More...
 
 L1GctUnsignedInt (unsigned value)
 Construct an unsigned integer and check for overFlow. 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 30 of file L1GctJetCount.h.

Constructor & Destructor Documentation

◆ L1GctJetCount() [1/3]

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

Construct a counter and initialise its value to zero.

Definition at line 61 of file L1GctJetCount.h.

◆ L1GctJetCount() [2/3]

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

Construct a counter, checking for overFlow.

Definition at line 64 of file L1GctJetCount.h.

◆ ~L1GctJetCount()

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

Destructor.

Definition at line 67 of file L1GctJetCount.h.

67 {}

◆ L1GctJetCount() [3/3]

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 73 of file L1GctJetCount.h.

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

Member Function Documentation

◆ operator+()

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

add two numbers

Definition at line 115 of file L1GctJetCount.h.

115  {
116  // temporary variable for storing the result (need to set its size)
118 
119  unsigned sum;
120  bool ofl;
121 
122  // do the addition here
123  sum = this->value() + rhs.value();
124  ofl = this->overFlow() || rhs.overFlow();
125 
126  //fill the temporary argument
127  temp.setValue(sum);
128  temp.setOverFlow(temp.overFlow() || ofl);
129 
130  // return the temporary
131  return temp;
132 }

◆ operator++() [1/2]

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

Define increment operators, since this is a counter.

Definition at line 100 of file L1GctJetCount.h.

100  {
101  this->setValue(this->m_value + 1);
102  return *this;
103 }

◆ operator++() [2/2]

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

Definition at line 106 of file L1GctJetCount.h.

106  {
108  temp.setOverFlow(this->m_overFlow);
109  this->setValue(this->m_value + 1);
110  return temp;
111 }

◆ operator=()

template<int nBits>
L1GctJetCount< nBits > & L1GctJetCount< nBits >::operator= ( int  value)

overload = operator

Definition at line 136 of file L1GctJetCount.h.

136  {
137  this->setValue(value);
138  return *this;
139 }

◆ setOverFlow()

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

set the overflow bit

Definition at line 91 of file L1GctJetCount.h.

91  {
92  this->m_overFlow = oflow;
93  if (oflow) {
94  this->m_value = ((1 << this->m_nBits) - 1);
95  }
96 }

◆ setValue()

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

Set value from unsigned.

Definition at line 80 of file L1GctJetCount.h.

80  {
81  // check for overflow
82  if (value >= (static_cast<unsigned>((1 << this->m_nBits) - 1))) {
83  this->m_overFlow = true;
84  this->m_value = ((1 << this->m_nBits) - 1);
85  } else {
86  this->m_value = value;
87  }
88 }
L1GctJetCount::setOverFlow
void setOverFlow(bool oflow)
set the overflow bit
Definition: L1GctJetCount.h:91
L1GctUnsignedInt::m_nBits
int m_nBits
Definition: L1GctUnsignedInt.h:69
L1GctUnsignedInt::value
unsigned value() const
access value as unsigned
Definition: L1GctUnsignedInt.h:53
L1GctUnsignedInt::m_value
unsigned m_value
Definition: L1GctUnsignedInt.h:72
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
value
Definition: value.py:1
L1GctUnsignedInt::m_overFlow
bool m_overFlow
Definition: L1GctUnsignedInt.h:75
L1GctJetCount::setValue
void setValue(unsigned value)
Set value from unsigned.
Definition: L1GctJetCount.h:80
L1GctUnsignedInt
Definition of unsigned integer types with overflow.
Definition: L1GctUnsignedInt.h:27
L1GctUnsignedInt::MAX_NBITS
static const int MAX_NBITS
Definition: L1GctUnsignedInt.h:77
L1GctUnsignedInt::overFlow
bool overFlow() const
access overflow
Definition: L1GctUnsignedInt.h:56
L1GctJetCount
Definition of unsigned integer types with increment and overflow.
Definition: L1GctJetCount.h:30