yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis 2.0.2
YODA::BinBase< T, BinningT > Class Template Reference

Bin base class consisting of mix of histogram bin content and space characteristics of this bin (widths, min, max, mid, etc...) More...

#include <Bin.h>

Inheritance diagram for YODA::BinBase< T, BinningT >:
YODA::Bin< N, T, BinningT > YODA::Bin< 1, T, BinningT > YODA::Bin< 2, T, BinningT > YODA::Bin< 3, T, BinningT >

Public Member Functions

Constructors
 BinBase ()=delete
 
 BinBase (const BinBase &rhs)=default
 
 BinBase (BinBase &&rhs)=default
 
 BinBase (size_t binIndex, const BinningT &binning)
 
 BinBase (const T &storedVal, size_t binIndex, const BinningT &binning)
 Setting constructor.
 
 BinBase (T &&storedVal, size_t binIndex, const BinningT &binning)
 
 BinBase (const BinBase &other, const BinningT &binning)
 
BinBaseoperator= (BaseT &&rhs) noexcept
 Assignment operator of an rvalue content type.
 
BinBaseoperator= (const BaseT &rhs) noexcept
 Assignment operator of a content type.
 
BinBaseoperator= (const BinBase &rhs) noexcept
 Copy assignment operator.
 
BinBaseoperator= (BinBase &&rhs) noexcept
 Move assignment operator.
 
Utility methods
const T & raw () const noexcept
 return stored content
 
size_t index () const noexcept
 return stored index
 
bool isMasked () const noexcept
 
bool isVisible () const noexcept
 
Bin space characteristics
double dVol () const noexcept
 Differential volume of this bin (i.e. product of bin widths)
 
template<size_t dimNum>
enable_if_CAxisT< axisEdgeT< dimNum > > width () const noexcept
 Width of this bin along a specific axis.
 
template<size_t dimNum>
enable_if_CAxisT< axisEdgeT< dimNum > > max () const noexcept
 Maximum of this bin interval.
 
template<size_t dimNum>
enable_if_CAxisT< axisEdgeT< dimNum > > min () const noexcept
 Minimum of this bin interval.
 
template<size_t dimNum>
enable_if_CAxisT< axisEdgeT< dimNum > > mid () const noexcept
 Middle of this bin interval.
 
template<size_t dimNum>
enable_if_DAxisT< axisEdgeT< dimNum > > edge () const noexcept
 Edge of this bin.
 

Protected Types

Utilities
using isArithmetic = std::conditional_t< std::is_arithmetic< T >::value, std::true_type, std::false_type >
 
using BaseT = std::conditional_t< isArithmetic::value, ArithmeticWrapper< T >, T >
 
template<size_t axisNum>
using axisEdgeT = typename BinningT::template getAxisT< axisNum >::EdgeT
 

Detailed Description

template<typename T, typename BinningT>
class YODA::BinBase< T, BinningT >

Bin base class consisting of mix of histogram bin content and space characteristics of this bin (widths, min, max, mid, etc...)

Note
Since the BinBase class inherits from the content of the histogram bin (to emulate its behavior), an arithmetic wrapper is introduced to inherit from arithmetic types (it's not possible to inherit from fundamental types by default).
We use CRTP to introduce dimension-specific member functions like xWidth(), yMid() to avoid the user having to call e.g. bin(i).width<N>() or similar.

Definition at line 80 of file Bin.h.

Member Typedef Documentation

◆ axisEdgeT

template<typename T , typename BinningT >
template<size_t axisNum>
using YODA::BinBase< T, BinningT >::axisEdgeT = typename BinningT::template getAxisT<axisNum>::EdgeT
protected

Definition at line 93 of file Bin.h.

◆ BaseT

template<typename T , typename BinningT >
using YODA::BinBase< T, BinningT >::BaseT = std::conditional_t<isArithmetic::value, ArithmeticWrapper<T>, T>
protected

Definition at line 89 of file Bin.h.

◆ isArithmetic

template<typename T , typename BinningT >
using YODA::BinBase< T, BinningT >::isArithmetic = std::conditional_t<std::is_arithmetic<T>::value, std::true_type, std::false_type>
protected

Definition at line 86 of file Bin.h.

Constructor & Destructor Documentation

◆ BinBase() [1/7]

template<typename T , typename BinningT >
YODA::BinBase< T, BinningT >::BinBase ( )
delete

◆ BinBase() [2/7]

template<typename T , typename BinningT >
YODA::BinBase< T, BinningT >::BinBase ( const BinBase< T, BinningT > &  rhs)
default

◆ BinBase() [3/7]

template<typename T , typename BinningT >
YODA::BinBase< T, BinningT >::BinBase ( BinBase< T, BinningT > &&  rhs)
default

◆ BinBase() [4/7]

template<typename T , typename BinningT >
YODA::BinBase< T, BinningT >::BinBase ( size_t  binIndex,
const BinningT &  binning 
)
inline

Definition at line 112 of file Bin.h.

113 : _binIndex(binIndex), _binning(&binning) { }

◆ BinBase() [5/7]

template<typename T , typename BinningT >
YODA::BinBase< T, BinningT >::BinBase ( const T &  storedVal,
size_t  binIndex,
const BinningT &  binning 
)
inline

Setting constructor.

Definition at line 116 of file Bin.h.

117 : BaseT(storedVal), _binIndex(binIndex), _binning(&binning) { }
std::conditional_t< isArithmetic::value, ArithmeticWrapper< T >, T > BaseT
Definition Bin.h:90

◆ BinBase() [6/7]

template<typename T , typename BinningT >
YODA::BinBase< T, BinningT >::BinBase ( T &&  storedVal,
size_t  binIndex,
const BinningT &  binning 
)
inline

Definition at line 119 of file Bin.h.

120 : BaseT(std::move(storedVal)), _binIndex(binIndex), _binning(&binning) { }

◆ BinBase() [7/7]

template<typename T , typename BinningT >
YODA::BinBase< T, BinningT >::BinBase ( const BinBase< T, BinningT > &  other,
const BinningT &  binning 
)
inline

Definition at line 122 of file Bin.h.

123 : BaseT(other), _binIndex(other._binIndex), _binning(&binning) { }

Member Function Documentation

◆ dVol()

template<typename T , typename BinningT >
double YODA::BinBase< T, BinningT >::dVol ( ) const
inlinenoexcept

Differential volume of this bin (i.e. product of bin widths)

Definition at line 191 of file Bin.h.

191 {
192 return _binning->dVol(_binIndex);
193 }

Referenced by YODA::Bin< 2, T, BinningT >::dArea(), and YODA::Bin< 1, T, BinningT >::dLen().

◆ edge()

template<typename T , typename BinningT >
template<size_t dimNum>
enable_if_DAxisT< axisEdgeT< dimNum > > YODA::BinBase< T, BinningT >::edge ( ) const
inlinenoexcept

Edge of this bin.

Note
Only supported for discrete axes.

Definition at line 247 of file Bin.h.

247 {
248 const auto& axis = _binning->template axis<dimNum>();
249 size_t binIdx = _binning->globalToLocalIndices(_binIndex)[dimNum];
250 return axis.edge(binIdx);
251 }

◆ index()

template<typename T , typename BinningT >
size_t YODA::BinBase< T, BinningT >::index ( ) const
inlinenoexcept

return stored index

Definition at line 173 of file Bin.h.

173 {
174 return _binIndex;
175 }

◆ isMasked()

template<typename T , typename BinningT >
bool YODA::BinBase< T, BinningT >::isMasked ( ) const
inlinenoexcept

Definition at line 177 of file Bin.h.

177 {
178 return _binning->isMasked(_binIndex);
179 }

◆ isVisible()

template<typename T , typename BinningT >
bool YODA::BinBase< T, BinningT >::isVisible ( ) const
inlinenoexcept

Definition at line 181 of file Bin.h.

181 {
182 return _binning->isVisible(_binIndex);
183 }

◆ max()

template<typename T , typename BinningT >
template<size_t dimNum>
enable_if_CAxisT< axisEdgeT< dimNum > > YODA::BinBase< T, BinningT >::max ( ) const
inlinenoexcept

Maximum of this bin interval.

Note
Only supported for continuous axes.

Definition at line 217 of file Bin.h.

217 {
218 const auto& axis = _binning->template axis<dimNum>();
219 size_t binIdx = _binning->globalToLocalIndices(_binIndex)[dimNum];
220 return axis.max(binIdx);
221 }

◆ mid()

template<typename T , typename BinningT >
template<size_t dimNum>
enable_if_CAxisT< axisEdgeT< dimNum > > YODA::BinBase< T, BinningT >::mid ( ) const
inlinenoexcept

Middle of this bin interval.

Note
Only supported for continuous axes.

Definition at line 237 of file Bin.h.

237 {
238 const auto& axis = _binning->template axis<dimNum>();
239 size_t binIdx = _binning->globalToLocalIndices(_binIndex)[dimNum];
240 return axis.mid(binIdx);
241 }

◆ min()

template<typename T , typename BinningT >
template<size_t dimNum>
enable_if_CAxisT< axisEdgeT< dimNum > > YODA::BinBase< T, BinningT >::min ( ) const
inlinenoexcept

Minimum of this bin interval.

Note
Only supported for continuous axes.

Definition at line 227 of file Bin.h.

227 {
228 const auto& axis = _binning->template axis<dimNum>();
229 size_t binIdx = _binning->globalToLocalIndices(_binIndex)[dimNum];
230 return axis.min(binIdx);
231 }

◆ operator=() [1/4]

template<typename T , typename BinningT >
BinBase & YODA::BinBase< T, BinningT >::operator= ( BaseT &&  rhs)
inlinenoexcept

Assignment operator of an rvalue content type.

Note
Cython is not a fan of perfect forwarding yet

Definition at line 128 of file Bin.h.

128 {
129 //BaseT::operator=(std::forward<BaseT>(rhs));
130 BaseT::operator=(std::move(rhs));
131 return *this;
132 }

◆ operator=() [2/4]

template<typename T , typename BinningT >
BinBase & YODA::BinBase< T, BinningT >::operator= ( BinBase< T, BinningT > &&  rhs)
inlinenoexcept

Move assignment operator.

Note
_binIdx is not altered to keep correct indices while using std::vector<...>().erase() on _bins (bins storage).

Definition at line 155 of file Bin.h.

155 {
156 if (this != &rhs) {
157 BaseT::operator=(std::move(rhs));
158 }
159 return *this;
160 }

◆ operator=() [3/4]

template<typename T , typename BinningT >
BinBase & YODA::BinBase< T, BinningT >::operator= ( const BaseT rhs)
inlinenoexcept

Assignment operator of a content type.

Definition at line 135 of file Bin.h.

135 {
136 BaseT::operator=(rhs);
137 return *this;
138 }

◆ operator=() [4/4]

template<typename T , typename BinningT >
BinBase & YODA::BinBase< T, BinningT >::operator= ( const BinBase< T, BinningT > &  rhs)
inlinenoexcept

Copy assignment operator.

Note
_binIdx is not altered to keep correct indices while using std::vector<...>().erase() on _bins (bins storage).

Definition at line 144 of file Bin.h.

144 {
145 if (this != &rhs) {
146 BaseT::operator=(rhs);
147 }
148 return *this;
149 }

◆ raw()

template<typename T , typename BinningT >
const T & YODA::BinBase< T, BinningT >::raw ( ) const
inlinenoexcept

return stored content

Definition at line 168 of file Bin.h.

168 {
169 return *this;
170 }

◆ width()

template<typename T , typename BinningT >
template<size_t dimNum>
enable_if_CAxisT< axisEdgeT< dimNum > > YODA::BinBase< T, BinningT >::width ( ) const
inlinenoexcept

Width of this bin along a specific axis.

Note
Bin width is the projection of the bin surface (its area) along a specific axis. Therefore, "bin.width()" will not compile: it's not an intrinsic property of the bin. One should always specify along which axis. Convenient short-hands like bin.xWidth() etc. are being defined via CRTP Mixin, though.
Only supported for continuous axes.

Definition at line 207 of file Bin.h.

207 {
208 const auto& axis = _binning->template axis<dimNum>();
209 size_t binIdx = _binning->globalToLocalIndices(_binIndex)[dimNum];
210 return axis.width(binIdx);
211 }

The documentation for this class was generated from the following file: