ATLAS Offline Software
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
CaloBinDescriptor< T > Class Template Reference

Data object containing bin descriptions. More...

#include <CaloBinDescriptor.h>

Collaboration diagram for CaloBinDescriptor< T >:

Public Member Functions

 CaloBinDescriptor ()
 Default constructor generates empty bin descriptor. More...
 
 CaloBinDescriptor (const CaloBinDescriptor &theBins)
 Explicit copy constructor. More...
 
CaloBinDescriptoroperator= (const CaloBinDescriptor &theBins)
 Assignment. More...
 
 CaloBinDescriptor (const std::vector< T > &theBins)
 Construct with variable sized bins. More...
 
 CaloBinDescriptor (size_t nBins, const T &lowerLimit, const T &upperLimit)
 Construct with regular bins. More...
 
 ~CaloBinDescriptor ()
 Default constructor. More...
 
size_t getNumberOfBins () const
 Retrieve the number of bins. More...
 
lowerBound () const
 Retrieve the lower value range boundary. More...
 
upperBound () const
 Retrieve the upper value range boundary. More...
 
lowerBinEdge (size_t theIndex) const
 Retrieve the lower bin edge of a given bin. More...
 
upperBinEdge (size_t theIndex) const
 Retrieve the upper bin edge of a given bin. More...
 
binWidth (size_t theIndex) const
 Retrieve the bin width of a given bin. More...
 
const std::vector< T > & getBinning () const
 Direct Access to the vector describing the binning. More...
 
size_t getIndex (const T &theData) const
 Get the index for a iven value. More...
 
bool outOfRange (size_t theIndex) const
 Tests if given index is out of valid range. More...
 
size_t outOfRangeMarker () const
 Returns the value of the out-of-range marker. More...
 

Private Attributes

std::vector< T > m_bins
 Bin store. More...
 

Static Private Attributes

static const size_t m_outOfRange = size_t(-1)
 Out-of-range marker (convention) More...
 

Detailed Description

template<typename T>
class CaloBinDescriptor< T >

Data object containing bin descriptions.

Author
Peter Loch loch@.nosp@m.phys.nosp@m.ics.a.nosp@m.rizo.nosp@m.na.ed.nosp@m.u
Date
April 1, 2005
Version
0

This data object stores the description of bins for any data type T with support for simple arithmatic (operators +,-,*,/) and valid comparators (operators >,=>,<,<=). The bins can be equidistant or variable.

Definition at line 11 of file CaloBinDescriptor.h.

Constructor & Destructor Documentation

◆ CaloBinDescriptor() [1/4]

template<typename T >
CaloBinDescriptor< T >::CaloBinDescriptor ( )
inline

Default constructor generates empty bin descriptor.

Definition at line 16 of file CaloBinDescriptor.h.

16 { m_bins.clear(); };

◆ CaloBinDescriptor() [2/4]

template<typename T >
CaloBinDescriptor< T >::CaloBinDescriptor ( const CaloBinDescriptor< T > &  theBins)
explicit

Explicit copy constructor.

Definition at line 122 of file CaloBinDescriptor.h.

123  : m_bins (theBins.m_bins)
124 {
125 }

◆ CaloBinDescriptor() [3/4]

template<typename T >
CaloBinDescriptor< T >::CaloBinDescriptor ( const std::vector< T > &  theBins)

Construct with variable sized bins.

Parameters
theBinsreference to vector of bin boundaries with n+1 entries for n bins;
Note
There is no consistency check performed on the bin delimiters. Any invalid sequence of delimiters, i.e. not ordered increasing in value, will lead to unexpected index mapping.

Definition at line 140 of file CaloBinDescriptor.h.

141  : m_bins (theBins)
142 {
143 }

◆ CaloBinDescriptor() [4/4]

template<typename T >
CaloBinDescriptor< T >::CaloBinDescriptor ( size_t  nBins,
const T &  lowerLimit,
const T &  upperLimit 
)

Construct with regular bins.

Parameters
nBinsnumber of bins
lowerLimitlower limit of value range
upperLimitupper limit of value range
Note
Invalid input (nbins = 0, lowerLimit >= upperLimit) will lead to empty (unusable) bin descriptor.

The input parameters are internally converted into a vector of lower bin boundaries (first n entries) and the upper limit of the value range (n+1 entry).

Definition at line 146 of file CaloBinDescriptor.h.

148 {
149  if ( lowerEdge < upperEdge && nBins > 0 )
150  {
151  double fBin =lowerEdge;
152  double dBin = ( upperEdge - lowerEdge ) / (double)nBins;
153  while ( fBin <= ( upperEdge + dBin/2. ) )
154  {
155  m_bins.push_back(fBin);
156  fBin += dBin;
157  }
158  }
159  else
160  {
161  m_bins.clear();
162  }
163 }

◆ ~CaloBinDescriptor()

template<typename T >
CaloBinDescriptor< T >::~CaloBinDescriptor ( )
inline

Default constructor.

Definition at line 46 of file CaloBinDescriptor.h.

46 { };

Member Function Documentation

◆ binWidth()

template<typename T >
T CaloBinDescriptor< T >::binWidth ( size_t  theIndex) const
inline

Retrieve the bin width of a given bin.

Parameters
theIndexbin index \( i \in [1,n] \) for \( n \) bins.

Returns 0 if theIndex out of range. A valid return is positive definit.

Definition at line 196 of file CaloBinDescriptor.h.

197 {
198  return theIndex < m_bins.size()-2
199  ? m_bins[theIndex+1] - m_bins[theIndex]
200  : 0.;
201 }

◆ getBinning()

template<typename T >
const std::vector< T > & CaloBinDescriptor< T >::getBinning
inline

Direct Access to the vector describing the binning.

Definition at line 204 of file CaloBinDescriptor.h.

205 {
206  return m_bins;
207 }

◆ getIndex()

template<typename T >
size_t CaloBinDescriptor< T >::getIndex ( const T &  theData) const

Get the index for a iven value.

Parameters
theDatainput value to be tested

Returns 0 if theData is smaller than the lower value range boundary, and outOfRangeMarker if theData is bigger than the upper value range boundary.

Definition at line 210 of file CaloBinDescriptor.h.

211 {
212  size_t theIndex = 0;
213  while ( theIndex < this->getNumberOfBins() && theData > m_bins[theIndex] )
214  {
215  theIndex++;
216  }
217  return theIndex < this->getNumberOfBins() ? theIndex : m_outOfRange;
218 }

◆ getNumberOfBins()

template<typename T >
size_t CaloBinDescriptor< T >::getNumberOfBins
inline

Retrieve the number of bins.

Returns 0 for empty bin descriptor.

Definition at line 166 of file CaloBinDescriptor.h.

167 {
168  return m_bins.size()-1;
169 }

◆ lowerBinEdge()

template<typename T >
T CaloBinDescriptor< T >::lowerBinEdge ( size_t  theIndex) const
inline

Retrieve the lower bin edge of a given bin.

Parameters
theIndexbin index \( i \in [1,n] \) for \( n \) bins.

Returns 0 if theIndex out of range.

Warning
0 is a valid return as well.

Definition at line 184 of file CaloBinDescriptor.h.

185 {
186  return theIndex < m_bins.size()-2 ? m_bins[theIndex] : 0.;
187 }

◆ lowerBound()

template<typename T >
T CaloBinDescriptor< T >::lowerBound
inline

Retrieve the lower value range boundary.

Definition at line 172 of file CaloBinDescriptor.h.

173 {
174  return m_bins.size() > 0 ? *(m_bins.begin()) : 0.;
175 }

◆ operator=()

template<typename T >
CaloBinDescriptor< T > & CaloBinDescriptor< T >::operator= ( const CaloBinDescriptor< T > &  theBins)

Assignment.

Definition at line 129 of file CaloBinDescriptor.h.

130 {
131  if (this != &theBins)
132  m_bins = theBins.m_bins;
133  return *this;
134 }

◆ outOfRange()

template<typename T >
bool CaloBinDescriptor< T >::outOfRange ( size_t  theIndex) const
inline

Tests if given index is out of valid range.

Parameters
theIndexinput index to be tested

Returns true if theIndex within range.

Definition at line 221 of file CaloBinDescriptor.h.

222 {
223  return theIndex != m_outOfRange
224  ? theIndex < this->getNumberOfBins()
225  : true;
226 }

◆ outOfRangeMarker()

template<typename T >
size_t CaloBinDescriptor< T >::outOfRangeMarker
inline

Returns the value of the out-of-range marker.

Definition at line 229 of file CaloBinDescriptor.h.

230 {
231  return m_outOfRange;
232 }

◆ upperBinEdge()

template<typename T >
T CaloBinDescriptor< T >::upperBinEdge ( size_t  theIndex) const
inline

Retrieve the upper bin edge of a given bin.

Parameters
theIndexbin index \( i \in [1,n] \) for \( n \) bins.

Returns 0 if theIndex out of range.

Warning
0 is a valid return as well.

Definition at line 190 of file CaloBinDescriptor.h.

191 {
192  return theIndex < m_bins.size()-1 ? m_bins[theIndex+1] : 0;
193 }

◆ upperBound()

template<typename T >
T CaloBinDescriptor< T >::upperBound
inline

Retrieve the upper value range boundary.

Definition at line 178 of file CaloBinDescriptor.h.

179 {
180  return m_bins.size() > 0 ? *(--(m_bins.end())) : 0.;
181 }

Member Data Documentation

◆ m_bins

template<typename T >
std::vector<T> CaloBinDescriptor< T >::m_bins
private

Bin store.

n+1 entries for n bins.

Definition at line 115 of file CaloBinDescriptor.h.

◆ m_outOfRange

template<typename T >
const size_t CaloBinDescriptor< T >::m_outOfRange = size_t(-1)
staticprivate

Out-of-range marker (convention)

Definition at line 118 of file CaloBinDescriptor.h.


The documentation for this class was generated from the following file:
CaloBinDescriptor::m_bins
std::vector< T > m_bins
Bin store.
Definition: CaloBinDescriptor.h:115
dumpTgcDigiJitter.nBins
list nBins
Definition: dumpTgcDigiJitter.py:29
CaloBinDescriptor::m_outOfRange
static const size_t m_outOfRange
Out-of-range marker (convention)
Definition: CaloBinDescriptor.h:118
CaloBinDescriptor::getNumberOfBins
size_t getNumberOfBins() const
Retrieve the number of bins.
Definition: CaloBinDescriptor.h:166