yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis 2.0.0
YODA::BinnedStorage< BinContentT, AxisT > Class Template Reference

BinnedStorage, stores the bins and coordinates access to them. More...

#include <BinnedStorage.h>

Inheritance diagram for YODA::BinnedStorage< BinContentT, AxisT >:
YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... > YODA::DbnStorage< DbnN, AxisT... > YODA::DbnStorage< 1, AxisT > YODA::DbnStorage< 2, AxisT > YODA::DbnStorage< 2, AxisT1, AxisT2 > YODA::DbnStorage< 3, AxisT1, AxisT2 > YODA::DbnStorage< 3, AxisT1, AxisT2, AxisT3 > YODA::DbnStorage< 4, AxisT1, AxisT2, AxisT3 > YODA::DbnStorage< DbnN, AxisT >

Public Types

using BinningType = BinningT
 
using BinType = BinT
 
using BinDimension = std::integral_constant< size_t, sizeof...(AxisT)>
 

Public Member Functions

Constructors
 BinnedStorage ()
 Nullary constructor for unique pointers etc.
 
 BinnedStorage (const BinningT &binning)
 Constructs BinnedStorage from Binning.
 
 BinnedStorage (BinningT &&binning)
 Constructs BinnedStorage from Binning. Rvalue.
 
 BinnedStorage (const std::vector< AxisT > &... edges)
 Constructs binning from an adapter and vectors of axes' edges.
 
 BinnedStorage (std::vector< AxisT > &&... edges)
 Constructs binning from an adapter and Rvalue vectors of axes' edges.
 
 BinnedStorage (std::initializer_list< AxisT > &&... edges)
 Constructs binning from an adapter and Rvalue initializer lists of axes' edges.
 
 BinnedStorage (const Axis< AxisT > &... axes)
 Constructs binning from an adapter and a sequence of axes.
 
 BinnedStorage (Axis< AxisT > &&... axes)
 Constructs binning from an adapter and a sequence of Rvalue axes.
 
 BinnedStorage (const BinnedStorage &other)
 Copy constructor.
 
 BinnedStorage (BinnedStorage &&other)
 Move constructor.
 
Methods
size_t dim () const noexcept
 Total dimension of the object ( = number of axes + content)
 
BinTbin (size_t idx) noexcept
 Returns reference to the bin at idx.
 
const BinTbin (size_t idx) const noexcept
 Returns Bin at idx.
 
BinTbin (const std::array< size_t, sizeof...(AxisT)> &idxLocal) noexcept
 Bin access using local bin indices.
 
const BinTbin (const std::array< size_t, sizeof...(AxisT)> &idxLocal) const noexcept
 Bin access using local bin indices.
 
BinTbinAt (typename BinningT::EdgeTypesTuple &&coords) noexcept
 Returns reference to the bin at coordinates.
 
const BinTbinAt (typename BinningT::EdgeTypesTuple &&coords) const noexcept
 Returns reference to the bin at coordinates (const version).
 
void set (typename BinningT::EdgeTypesTuple &&coords, BinContentT &&content) noexcept
 Sets the bin corresponding to coords with an rvalue content.
 
void set (typename BinningT::EdgeTypesTuple &&coords, const BinContentT &content) noexcept
 Sets the bin corresponding to coords with content.
 
void set (const size_t binIdx, BinContentT &&content) noexcept
 Sets the bin corresponding to binIndex with an rvalue content.
 
void set (const size_t binIdx, const BinContentT &content) noexcept
 Sets the bin corresponding to binIndex with content.
 
std::vector< size_t > calcIndicesToSkip (const bool includeOverflows, const bool includeMaskedBins) const noexcept
 Calculates indices of bins which are marked or located in the overflow.
 
BinsVecWrapper< BinsVecTbins (const bool includeOverflows=false, const bool includeMaskedBins=false) noexcept
 Returns bins vector wrapper, which skips masked elements when iterated over.
 
const BinsVecWrapper< const BinsVecTbins (const bool includeOverflows=false, const bool includeMaskedBins=false) const noexcept
 Const version.
 

Protected Types

using BinningT = Binning< std::decay_t< decltype(std::declval< Axis< AxisT > >())>... >
 Convenience alias to be used in constructor.
 
using BinT = Bin< sizeof...(AxisT), BinContentT, BinningT >
 
using BinsVecT = std::vector< BinT >
 
using BaseT = BinnedStorage< BinContentT, AxisT... >
 

Utilities

const BinningTbinning () const noexcept
 Returns dimension underlying binning object reference.
 
size_t binDim () const noexcept
 Returns dimension of binning.
 
size_t numBins (const bool includeOverflows=false, const bool includeMaskedBins=false) const noexcept
 Number of bins in the BinnedStorage.
 
size_t numBinsAt (const size_t axisN, const bool includeOverflows=false) const noexcept
 Number of bins in the BinnedStorage.
 
void reset () noexcept
 Reset the BinnedStorage.
 
void clearBins () noexcept
 Deletes all bins and creates empty new ones.
 
void maskBins (const std::vector< size_t > &indicesToMask, const bool status=true) noexcept
 Mask a range of bins.
 
void maskBin (const size_t indexToMask, const bool status=true) noexcept
 Mask a bin at a given index.
 
void maskSlice (const size_t dim, const size_t idx, const bool status=true)
 Mask a slice of the binning at local bin index idx along axis dimesnion dim.
 
void maskBinAt (typename BinningT::EdgeTypesTuple &&coords, const bool status=true) noexcept
 Mask a bin at a given set of corrdinates.
 
bool isMasked (const size_t binIndex) const noexcept
 
std::vector< size_t > maskedBins () const noexcept
 
bool isVisible (const size_t binIndex) const noexcept
 
template<size_t... AxisNs, class RetT = void>
auto mergeBins (std::decay_t< decltype(AxisNs, std::declval< std::pair< size_t, size_t > >())>... mergeRanges) noexcept -> std::enable_if_t< MetaUtils::is_detected_v< MetaUtils::operatorTraits::addition_assignment_t, BinContentT >, RetT >
 Merge bins from A to B at G axis.
 
template<size_t axisN, template< typename... > typename BinnedT, typename Func , typename = std::enable_if_t< (axisN < sizeof...(AxisT) && sizeof...(AxisT)>=2) >>
auto mkBinnedSlices (Func &&how2add, const bool includeOverflows=false) const
 Split this BinnedStorage into a vector of BinnedStorages along axisN.
 
BinnedStorageoperator= (const BinnedStorage &other) noexcept
 Copy assignment.
 
BinnedStorageoperator= (BinnedStorage &&other) noexcept
 Move assignment.
 
bool operator== (const BinnedStorage &other) const noexcept
 Compares BinnedStorages for equality, e.g. dimensions of underlying binnings and all axes edges are equal.
 
bool operator!= (const BinnedStorage &other) const noexcept
 Compares BinnedStorages for inequality.
 
void fillBins () noexcept
 Fills bins with wrapped BinContent objects.
 
void fillBins (const BinsVecT &bins) noexcept
 
void fillBins (BinsVecT &&bins) noexcept
 

Detailed Description

template<typename BinContentT, typename... AxisT>
class YODA::BinnedStorage< BinContentT, AxisT >

BinnedStorage, stores the bins and coordinates access to them.

Definition at line 114 of file BinnedStorage.h.

Member Typedef Documentation

◆ BaseT

template<typename BinContentT , typename... AxisT>
using YODA::BinnedStorage< BinContentT, AxisT >::BaseT = BinnedStorage<BinContentT, AxisT...>
protected

Definition at line 121 of file BinnedStorage.h.

◆ BinDimension

template<typename BinContentT , typename... AxisT>
using YODA::BinnedStorage< BinContentT, AxisT >::BinDimension = std::integral_constant<size_t, sizeof...(AxisT)>

Definition at line 127 of file BinnedStorage.h.

◆ BinningT

template<typename BinContentT , typename... AxisT>
using YODA::BinnedStorage< BinContentT, AxisT >::BinningT = Binning<std::decay_t<decltype(std::declval<Axis<AxisT> >())>...>
protected

Convenience alias to be used in constructor.

Definition at line 118 of file BinnedStorage.h.

◆ BinningType

template<typename BinContentT , typename... AxisT>
using YODA::BinnedStorage< BinContentT, AxisT >::BinningType = BinningT

Definition at line 125 of file BinnedStorage.h.

◆ BinsVecT

template<typename BinContentT , typename... AxisT>
using YODA::BinnedStorage< BinContentT, AxisT >::BinsVecT = std::vector<BinT>
protected

Definition at line 120 of file BinnedStorage.h.

◆ BinT

template<typename BinContentT , typename... AxisT>
using YODA::BinnedStorage< BinContentT, AxisT >::BinT = Bin<sizeof...(AxisT), BinContentT, BinningT>
protected

Definition at line 119 of file BinnedStorage.h.

◆ BinType

template<typename BinContentT , typename... AxisT>
using YODA::BinnedStorage< BinContentT, AxisT >::BinType = BinT

Definition at line 126 of file BinnedStorage.h.

Constructor & Destructor Documentation

◆ BinnedStorage() [1/10]

template<typename BinContentT , typename... AxisT>
YODA::BinnedStorage< BinContentT, AxisT >::BinnedStorage ( )
inline

Nullary constructor for unique pointers etc.

Definition at line 134 of file BinnedStorage.h.

134 : _binning(std::vector<AxisT>{}...) {
135 fillBins();
136 }
void fillBins() noexcept
Fills bins with wrapped BinContent objects.

◆ BinnedStorage() [2/10]

template<typename BinContentT , typename... AxisT>
YODA::BinnedStorage< BinContentT, AxisT >::BinnedStorage ( const BinningT binning)
inline

Constructs BinnedStorage from Binning.

Definition at line 139 of file BinnedStorage.h.

139 : _binning(binning) {
140 fillBins();
141 }
const BinningT & binning() const noexcept
Returns dimension underlying binning object reference.

References YODA::BinnedStorage< BinContentT, AxisT >::fillBins().

◆ BinnedStorage() [3/10]

template<typename BinContentT , typename... AxisT>
YODA::BinnedStorage< BinContentT, AxisT >::BinnedStorage ( BinningT &&  binning)
inline

Constructs BinnedStorage from Binning. Rvalue.

Definition at line 144 of file BinnedStorage.h.

144 : _binning(std::move(binning)) {
145 fillBins();
146 }

References YODA::BinnedStorage< BinContentT, AxisT >::fillBins().

◆ BinnedStorage() [4/10]

template<typename BinContentT , typename... AxisT>
YODA::BinnedStorage< BinContentT, AxisT >::BinnedStorage ( const std::vector< AxisT > &...  edges)
inline

Constructs binning from an adapter and vectors of axes' edges.

Definition at line 149 of file BinnedStorage.h.

149 : _binning(edges...) {
150 fillBins();
151 }

References YODA::BinnedStorage< BinContentT, AxisT >::fillBins().

◆ BinnedStorage() [5/10]

template<typename BinContentT , typename... AxisT>
YODA::BinnedStorage< BinContentT, AxisT >::BinnedStorage ( std::vector< AxisT > &&...  edges)
inline

Constructs binning from an adapter and Rvalue vectors of axes' edges.

Definition at line 154 of file BinnedStorage.h.

154 : _binning(std::move(edges)...) {
155 fillBins();
156 }

References YODA::BinnedStorage< BinContentT, AxisT >::fillBins().

◆ BinnedStorage() [6/10]

template<typename BinContentT , typename... AxisT>
YODA::BinnedStorage< BinContentT, AxisT >::BinnedStorage ( std::initializer_list< AxisT > &&...  edges)
inline

Constructs binning from an adapter and Rvalue initializer lists of axes' edges.

Definition at line 159 of file BinnedStorage.h.

159 : _binning(std::vector<AxisT>{edges}...) {
160 fillBins();
161 }

◆ BinnedStorage() [7/10]

template<typename BinContentT , typename... AxisT>
YODA::BinnedStorage< BinContentT, AxisT >::BinnedStorage ( const Axis< AxisT > &...  axes)
inline

Constructs binning from an adapter and a sequence of axes.

Definition at line 164 of file BinnedStorage.h.

164 : _binning(axes...) {
165 fillBins();
166 }

References YODA::BinnedStorage< BinContentT, AxisT >::fillBins().

◆ BinnedStorage() [8/10]

template<typename BinContentT , typename... AxisT>
YODA::BinnedStorage< BinContentT, AxisT >::BinnedStorage ( Axis< AxisT > &&...  axes)
inline

Constructs binning from an adapter and a sequence of Rvalue axes.

Definition at line 169 of file BinnedStorage.h.

169 : _binning(std::move(axes)...) {
170 fillBins();
171 }

References YODA::BinnedStorage< BinContentT, AxisT >::fillBins().

◆ BinnedStorage() [9/10]

template<typename BinContentT , typename... AxisT>
YODA::BinnedStorage< BinContentT, AxisT >::BinnedStorage ( const BinnedStorage< BinContentT, AxisT > &  other)
inline

Copy constructor.

Definition at line 174 of file BinnedStorage.h.

174 : _binning(other._binning) {
175 fillBins(other._bins);
176 }

References YODA::BinnedStorage< BinContentT, AxisT >::fillBins().

◆ BinnedStorage() [10/10]

template<typename BinContentT , typename... AxisT>
YODA::BinnedStorage< BinContentT, AxisT >::BinnedStorage ( BinnedStorage< BinContentT, AxisT > &&  other)
inline

Move constructor.

Definition at line 179 of file BinnedStorage.h.

179 : _binning(std::move(other._binning)) {
180 fillBins(std::move(other._bins));
181 }

References YODA::BinnedStorage< BinContentT, AxisT >::fillBins().

Member Function Documentation

◆ bin() [1/4]

template<typename BinContentT , typename... AxisT>
const BinT & YODA::BinnedStorage< BinContentT, AxisT >::bin ( const std::array< size_t, sizeof...(AxisT)> &  idxLocal) const
inlinenoexcept

Bin access using local bin indices.

Definition at line 215 of file BinnedStorage.h.

215 {
216 return bin( _binning.localToGlobalIndex(idxLocal) );
217 }
BinT & bin(size_t idx) noexcept
Returns reference to the bin at idx.

References YODA::BinnedStorage< BinContentT, AxisT >::bin().

◆ bin() [2/4]

template<typename BinContentT , typename... AxisT>
BinT & YODA::BinnedStorage< BinContentT, AxisT >::bin ( const std::array< size_t, sizeof...(AxisT)> &  idxLocal)
inlinenoexcept

Bin access using local bin indices.

Definition at line 210 of file BinnedStorage.h.

210 {
211 return bin( _binning.localToGlobalIndex(idxLocal) );
212 }

References YODA::BinnedStorage< BinContentT, AxisT >::bin().

◆ bin() [3/4]

template<typename BinContentT , typename... AxisT>
const BinT & YODA::BinnedStorage< BinContentT, AxisT >::bin ( size_t  idx) const
inlinenoexcept

Returns Bin at idx.

Definition at line 205 of file BinnedStorage.h.

205 {
206 return _bins.at(idx);
207 }

◆ bin() [4/4]

template<typename BinContentT , typename... AxisT>
BinT & YODA::BinnedStorage< BinContentT, AxisT >::bin ( size_t  idx)
inlinenoexcept

Returns reference to the bin at idx.

Note
Bin position is calculated using this pattern: x + y*width + z*width*height + w*width*height*depth + ... where (x,y,z) are bin positions on three different axes, and width, height, and depth are length of these axes. Axes are queried for position (translating coordinates in positions) in the order of axes specification in Binning template instantiation.

Definition at line 200 of file BinnedStorage.h.

200 {
201 return _bins.at(idx);
202 }

Referenced by YODA::EstimateStorage< AxisT >::add(), YODA::AOReader< BinnedDbn< DbnN, AxisT... > >::assemble(), YODA::AOReader< BinnedEstimate< AxisT... > >::assemble(), YODA::BinnedDbn< 2, AxisT1, AxisT2 >::bin(), YODA::BinnedDbn< 3, AxisT1, AxisT2, AxisT3 >::bin(), YODA::BinnedDbn< 3, AxisT1, AxisT2 >::bin(), YODA::BinnedDbn< 4, AxisT1, AxisT2, AxisT3 >::bin(), YODA::BinnedDbn< 2, AxisT1, AxisT2 >::bin(), YODA::BinnedDbn< 3, AxisT1, AxisT2, AxisT3 >::bin(), YODA::BinnedDbn< 3, AxisT1, AxisT2 >::bin(), YODA::BinnedDbn< 4, AxisT1, AxisT2, AxisT3 >::bin(), YODA::BinnedDbn< 2, AxisT1, AxisT2 >::bin(), YODA::BinnedDbn< 3, AxisT1, AxisT2 >::bin(), YODA::BinnedDbn< 2, AxisT1, AxisT2 >::bin(), YODA::BinnedDbn< 3, AxisT1, AxisT2 >::bin(), YODA::BinnedDbn< 3, AxisT1, AxisT2, AxisT3 >::bin(), YODA::BinnedDbn< 4, AxisT1, AxisT2, AxisT3 >::bin(), YODA::BinnedDbn< 3, AxisT1, AxisT2, AxisT3 >::bin(), YODA::BinnedDbn< 4, AxisT1, AxisT2, AxisT3 >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::binAt(), YODA::BinnedStorage< BinContentT, AxisT >::binAt(), YODA::DbnStorage< DbnN, AxisT >::deserializeContent(), YODA::divide(), YODA::divide(), YODA::efficiency(), YODA::efficiency(), YODA::DbnStorage< DbnN, AxisT >::integralRange(), YODA::DbnStorage< DbnN, AxisT >::integralRangeError(), YODA::DbnStorage< DbnN, AxisT >::operator+=(), YODA::FillableStorage< FillDim, BinContentT, AxisT >::operator+=(), YODA::DbnStorage< DbnN, AxisT >::operator+=(), YODA::DbnStorage< DbnN, AxisT >::operator-=(), YODA::FillableStorage< FillDim, BinContentT, AxisT >::operator-=(), YODA::DbnStorage< DbnN, AxisT >::operator-=(), YODA::DbnStorage< DbnN, AxisT >::scale(), YODA::DbnStorage< DbnN, AxisT >::scaleW(), YODA::DbnStorage< DbnN, AxisT >::serializeContent(), YODA::EstimateStorage< AxisT >::subtract(), YODA::WriterYODA1::writeHisto1D(), and YODA::WriterYODA1::writeProfile1D().

◆ binAt() [1/2]

template<typename BinContentT , typename... AxisT>
const BinT & YODA::BinnedStorage< BinContentT, AxisT >::binAt ( typename BinningT::EdgeTypesTuple &&  coords) const
inlinenoexcept

Returns reference to the bin at coordinates (const version).

Definition at line 226 of file BinnedStorage.h.

226 {
227 const size_t binIdx = _binning.globalIndexAt(coords);
228 return bin(binIdx);
229 }

References YODA::BinnedStorage< BinContentT, AxisT >::bin().

◆ binAt() [2/2]

◆ binDim()

template<typename BinContentT , typename... AxisT>
size_t YODA::BinnedStorage< BinContentT, AxisT >::binDim ( ) const
inlinenoexcept

Returns dimension of binning.

Definition at line 326 of file BinnedStorage.h.

326 {
327 return _binning.dim();
328 }

◆ binning()

template<typename BinContentT , typename... AxisT>
const BinningT & YODA::BinnedStorage< BinContentT, AxisT >::binning ( ) const
inlinenoexcept

Returns dimension underlying binning object reference.

Definition at line 321 of file BinnedStorage.h.

321 {
322 return _binning;
323 }

Referenced by YODA::divide(), YODA::efficiency(), and YODA::BinnedStorage< BinContentT, AxisT >::mergeBins().

◆ bins() [1/2]

template<typename BinContentT , typename... AxisT>
const BinsVecWrapper< const BinsVecT > YODA::BinnedStorage< BinContentT, AxisT >::bins ( const bool  includeOverflows = false,
const bool  includeMaskedBins = false 
) const
inlinenoexcept

Const version.

Note
Here, includeoverflows refers to the return value, i.e. the default value false implies that calcIndicesToSkip should return an array of under/overflow indices

Definition at line 309 of file BinnedStorage.h.

310 {
311 return BinsVecWrapper<const BinsVecT>(_bins,
312 calcIndicesToSkip(includeOverflows, includeMaskedBins));
313 }
std::vector< size_t > calcIndicesToSkip(const bool includeOverflows, const bool includeMaskedBins) const noexcept
Calculates indices of bins which are marked or located in the overflow.

References YODA::BinnedStorage< BinContentT, AxisT >::calcIndicesToSkip().

◆ bins() [2/2]

template<typename BinContentT , typename... AxisT>
BinsVecWrapper< BinsVecT > YODA::BinnedStorage< BinContentT, AxisT >::bins ( const bool  includeOverflows = false,
const bool  includeMaskedBins = false 
)
inlinenoexcept

Returns bins vector wrapper, which skips masked elements when iterated over.

Note
Here, includeoverflows refers to the return value, i.e. the default value false implies that calcIndicesToSkip should return an array of under/overflow indices

Definition at line 298 of file BinnedStorage.h.

299 {
300 return BinsVecWrapper<BinsVecT>(_bins,
301 calcIndicesToSkip(includeOverflows, includeMaskedBins));
302 }

References YODA::BinnedStorage< BinContentT, AxisT >::calcIndicesToSkip().

Referenced by YODA::DbnStorage< DbnN, AxisT >::crossTerm(), YODA::DbnStorage< DbnN, AxisT >::densitySum(), YODA::divide(), YODA::divide(), YODA::DbnStorage< DbnN, AxisT >::dVol(), YODA::efficiency(), YODA::efficiency(), YODA::DbnStorage< DbnN, AxisT >::effNumEntries(), YODA::BinnedStorage< BinContentT, AxisT >::fillBins(), YODA::BinnedStorage< BinContentT, AxisT >::fillBins(), YODA::DbnStorage< DbnN, AxisT >::maxDensity(), YODA::DbnStorage< DbnN, AxisT >::mean(), YODA::DbnStorage< DbnN, AxisT >::mkEstimate(), YODA::DbnStorage< DbnN, AxisT >::mkHisto(), YODA::EstimateStorage< AxisT >::mkInert(), YODA::mkIntegral(), YODA::DbnStorage< DbnN, AxisT >::mkScatter(), YODA::DbnStorage< DbnN, AxisT >::numEntries(), YODA::DbnStorage< DbnN, AxisT >::rms(), YODA::DbnStorage< DbnN, AxisT >::stdErr(), YODA::DbnStorage< DbnN, AxisT >::sumW(), YODA::DbnStorage< DbnN, AxisT >::sumW2(), YODA::DbnStorage< DbnN, AxisT >::sumWA(), YODA::DbnStorage< DbnN, AxisT >::sumWA2(), YODA::transform(), YODA::DbnStorage< DbnN, AxisT >::variance(), YODA::WriterYODA1::writeHisto1D(), YODA::WriterYODA1::writeHisto2D(), YODA::WriterYODA1::writeProfile1D(), and YODA::WriterYODA1::writeProfile2D().

◆ calcIndicesToSkip()

template<typename BinContentT , typename... AxisT>
std::vector< size_t > YODA::BinnedStorage< BinContentT, AxisT >::calcIndicesToSkip ( const bool  includeOverflows,
const bool  includeMaskedBins 
) const
inlinenoexcept

Calculates indices of bins which are marked or located in the overflow.

Definition at line 259 of file BinnedStorage.h.

259 {
260
261 // if there are no bins, exit early
262 if (!_binning.numBins(!includeOverflows, !includeMaskedBins)) return {};
263
264 std::vector<size_t> indicesToSkip;
265
266 // define a lambda
267 auto appendIndicesVec = [&indicesToSkip](std::vector<size_t>&& indicesVec) {
268 indicesToSkip.insert(std::end(indicesToSkip),
269 std::make_move_iterator(std::begin(indicesVec)),
270 std::make_move_iterator(std::end(indicesVec)));
271 };
272
273 // only calculate the masked indices when
274 // the masked bins are to be skipped over
275 if(!includeOverflows) {
276 appendIndicesVec(_binning.calcOverflowBinsIndices());
277 }
278
279 if (!includeMaskedBins) {
280 appendIndicesVec(_binning.maskedBins());
281 }
282
283 // sort and remove duplicates
284 std::sort(indicesToSkip.begin(), indicesToSkip.end());
285 indicesToSkip.erase( std::unique(indicesToSkip.begin(), indicesToSkip.end()),
286 indicesToSkip.end() );
287
288 return indicesToSkip;
289 }

Referenced by YODA::BinnedStorage< BinContentT, AxisT >::bins(), and YODA::BinnedStorage< BinContentT, AxisT >::bins().

◆ clearBins()

template<typename BinContentT , typename... AxisT>
void YODA::BinnedStorage< BinContentT, AxisT >::clearBins ( )
inlinenoexcept

Deletes all bins and creates empty new ones.

Note
Bins marked as masked will remain masked

Definition at line 350 of file BinnedStorage.h.

350 {
351 _bins.clear();
352 fillBins();
353 }

References YODA::BinnedStorage< BinContentT, AxisT >::fillBins().

Referenced by YODA::BinnedStorage< BinContentT, AxisT >::reset().

◆ dim()

template<typename BinContentT , typename... AxisT>
size_t YODA::BinnedStorage< BinContentT, AxisT >::dim ( ) const
inlinenoexcept

Total dimension of the object ( = number of axes + content)

Definition at line 189 of file BinnedStorage.h.

189 {
190 return sizeof...(AxisT) + 1;
191 }

Referenced by YODA::BinnedStorage< BinContentT, AxisT >::maskSlice().

◆ fillBins() [1/3]

◆ fillBins() [2/3]

template<typename BinContentT , typename... AxisT>
void YODA::BinnedStorage< BinContentT, AxisT >::fillBins ( BinsVecT &&  bins)
inlineprotectednoexcept

Definition at line 552 of file BinnedStorage.h.

552 {
553 _bins.clear();
554 _bins.reserve(_binning.numBins());
555 for (auto&& b : bins) {
556 _bins.emplace_back(std::move(b), _binning);
557 }
558 }
BinsVecWrapper< BinsVecT > bins(const bool includeOverflows=false, const bool includeMaskedBins=false) noexcept
Returns bins vector wrapper, which skips masked elements when iterated over.

References YODA::BinnedStorage< BinContentT, AxisT >::bins().

◆ fillBins() [3/3]

template<typename BinContentT , typename... AxisT>
void YODA::BinnedStorage< BinContentT, AxisT >::fillBins ( const BinsVecT bins)
inlineprotectednoexcept

Definition at line 544 of file BinnedStorage.h.

544 {
545 _bins.clear();
546 _bins.reserve(_binning.numBins());
547 for (const auto& b : bins) {
548 _bins.emplace_back(b, _binning);
549 }
550 }

References YODA::BinnedStorage< BinContentT, AxisT >::bins().

◆ isMasked()

template<typename BinContentT , typename... AxisT>
bool YODA::BinnedStorage< BinContentT, AxisT >::isMasked ( const size_t  binIndex) const
inlinenoexcept

Definition at line 375 of file BinnedStorage.h.

375 {
376 return _binning.isMasked(binIndex);
377 }

Referenced by YODA::DbnStorage< DbnN, AxisT >::integralRange(), and YODA::DbnStorage< DbnN, AxisT >::integralRangeError().

◆ isVisible()

template<typename BinContentT , typename... AxisT>
bool YODA::BinnedStorage< BinContentT, AxisT >::isVisible ( const size_t  binIndex) const
inlinenoexcept

Definition at line 383 of file BinnedStorage.h.

383 {
384 return _binning.isVisible(binIndex);
385 }

◆ maskBin()

template<typename BinContentT , typename... AxisT>
void YODA::BinnedStorage< BinContentT, AxisT >::maskBin ( const size_t  indexToMask,
const bool  status = true 
)
inlinenoexcept

◆ maskBinAt()

template<typename BinContentT , typename... AxisT>
void YODA::BinnedStorage< BinContentT, AxisT >::maskBinAt ( typename BinningT::EdgeTypesTuple &&  coords,
const bool  status = true 
)
inlinenoexcept

Mask a bin at a given set of corrdinates.

Definition at line 371 of file BinnedStorage.h.

371 {
372 _binning.maskBinAt(coords, status);
373 }

◆ maskBins()

template<typename BinContentT , typename... AxisT>
void YODA::BinnedStorage< BinContentT, AxisT >::maskBins ( const std::vector< size_t > &  indicesToMask,
const bool  status = true 
)
inlinenoexcept

Mask a range of bins.

Definition at line 356 of file BinnedStorage.h.

356 {
357 _binning.maskBins(indicesToMask, status);
358 }

Referenced by YODA::DbnStorage< DbnN, AxisT >::operator+=(), YODA::DbnStorage< DbnN, AxisT >::operator+=(), YODA::DbnStorage< DbnN, AxisT >::operator-=(), and YODA::DbnStorage< DbnN, AxisT >::operator-=().

◆ maskedBins()

template<typename BinContentT , typename... AxisT>
std::vector< size_t > YODA::BinnedStorage< BinContentT, AxisT >::maskedBins ( ) const
inlinenoexcept

◆ maskSlice()

template<typename BinContentT , typename... AxisT>
void YODA::BinnedStorage< BinContentT, AxisT >::maskSlice ( const size_t  dim,
const size_t  idx,
const bool  status = true 
)
inline

Mask a slice of the binning at local bin index idx along axis dimesnion dim.

Definition at line 366 of file BinnedStorage.h.

366 {
367 _binning.maskSlice(dim, idx, status);
368 }
size_t dim() const noexcept
Total dimension of the object ( = number of axes + content)

References YODA::BinnedStorage< BinContentT, AxisT >::dim().

◆ mergeBins()

template<typename BinContentT , typename... AxisT>
template<size_t... AxisNs, class RetT = void>
auto YODA::BinnedStorage< BinContentT, AxisT >::mergeBins ( std::decay_t< decltype(AxisNs, std::declval< std::pair< size_t, size_t > >())>...  mergeRanges) -> std::enable_if_t<MetaUtils::is_detected_v<MetaUtils::operatorTraits::addition_assignment_t, BinContentT>, RetT>
inlinenoexcept

Merge bins from A to B at G axis.

Parameters
mergeRangesCall using following form mergeBins<1,2>({0, 5}, {3, 4}).
Note
Only works when the BinContentT has += operator. Otherwise merge operation would make little sense since there will be no effects on the binning except it's shrinking (no statistical strengthening).
Merging unmasks previously masked bins.
RetT to make enable_if work.
Note
Binning iteratively shrinks, so the next bin slice to merge will always be the next.

Definition at line 399 of file BinnedStorage.h.

402 {
403 auto mergeStorageBins =
404 [&binning = BaseT::_binning, &binStorage = BaseT::_bins](auto I, const auto& mergeRangePair){
405 assert(mergeRangePair.first < mergeRangePair.second);
406 const auto& pivotBinsIndices = binning.sliceIndices(I, mergeRangePair.first);
407
408 auto append = [&binStorage, &pivotBinsIndices](const auto& binsIndicesToMerge){
409 assert(pivotBinsIndices.size() == binsIndicesToMerge.size());
410 //for (const auto& k : binsIndicesToMerge) std::cout << k << std::endl;
411 //for (const auto& k : pivotBinsIndices) std::cout << k << std::endl;
412
413 // first merge the bins based on old set of indices
414 // unless the bins are masked
415 for (size_t i = 0; i < pivotBinsIndices.size(); i++) {
416 auto& pivotBin = binStorage[pivotBinsIndices[i]];
417 auto& binToAppend = binStorage[binsIndicesToMerge[i]];
418 pivotBin += binToAppend;
419 }
420 // then erase the bins (which will change the set of indices)
421 binStorage.erase(
422 std::remove_if(binStorage.begin(), binStorage.end(), [&](const auto& b) {
423 return std::find(binsIndicesToMerge.begin(), binsIndicesToMerge.end(), b.index()) != binsIndicesToMerge.end();
424 }), binStorage.end());
425 };
426
427 ssize_t nBinRowsToBeMerged = mergeRangePair.second - mergeRangePair.first;
428
429 size_t currBinRowIdx = mergeRangePair.first;
430 size_t nextBinRowIdx = mergeRangePair.first + 1;
431 //std::cout << nBinRowsToBeMerged << " " << currBinRowIdx << " " << nextBinRowIdx << std::endl;
432
433 while(nBinRowsToBeMerged--) {
436 append(binning.sliceIndices(I, nextBinRowIdx));
437 binning.template mergeBins<I>({currBinRowIdx, nextBinRowIdx});
438 }
439 };
440
441 ((void)mergeStorageBins(std::integral_constant<std::size_t, AxisNs>(), mergeRanges), ...);
442
443 }
std::vector< size_t > sliceIndices(std::vector< std::pair< size_t, std::vector< size_t > > >) const noexcept
Calculates indices of bins located in the specified slices.
Definition Binning.h:574

References YODA::BinnedStorage< BinContentT, AxisT >::binning(), and YODA::Binning< Axes >::sliceIndices().

◆ mkBinnedSlices()

template<typename BinContentT , typename... AxisT>
template<size_t axisN, template< typename... > typename BinnedT, typename Func , typename = std::enable_if_t< (axisN < sizeof...(AxisT) && sizeof...(AxisT)>=2) >>
auto YODA::BinnedStorage< BinContentT, AxisT >::mkBinnedSlices ( Func &&  how2add,
const bool  includeOverflows = false 
) const
inline

Split this BinnedStorage into a vector of BinnedStorages along axisN.

The binning dimension of the returned objects are reduced by one unit.

Note
Requires at least two binning dimensions.

Definition at line 452 of file BinnedStorage.h.

452 {
453
454 size_t vecN = BaseT::numBinsAt(axisN, includeOverflows);
455 auto binnedSlice = _mkBinnedT<BinnedT>(_binning.template _getAxesExcept<axisN>());
456 std::vector<decltype(binnedSlice)> rtn(vecN, binnedSlice);
457 for (size_t i = 0; i < vecN; ++i) {
458
459 auto mkSlice = [&oldBins = _bins, &how2add, &binnedSlice = rtn[i]](const auto& indicesToCopy) {
460 assert(binnedSlice.numBins(true) == indicesToCopy.size());
461
462 // for any given pivot, add the content
463 // from the old slice to the new slice
464 for (size_t i = 0; i < binnedSlice.numBins(true); ++i) {
465 auto& pivotBin = binnedSlice.bin(i);
466 auto& binToCopy = oldBins[indicesToCopy[i]];
467 how2add(pivotBin, binToCopy);
468 }
469 };
470
471 // get bin slice for any given bin i along the axis that is to be
472 // sliced, then make the estimates for the new binning
473 mkSlice(_binning.sliceIndices(axisN, i + !includeOverflows));
474
475 }
476 return rtn;
477 }
size_t numBinsAt(const size_t axisN, const bool includeOverflows=false) const noexcept
Number of bins in the BinnedStorage.

References YODA::BinnedStorage< BinContentT, AxisT... >::numBinsAt().

◆ numBins()

template<typename BinContentT , typename... AxisT>
size_t YODA::BinnedStorage< BinContentT, AxisT >::numBins ( const bool  includeOverflows = false,
const bool  includeMaskedBins = false 
) const
inlinenoexcept

◆ numBinsAt()

template<typename BinContentT , typename... AxisT>
size_t YODA::BinnedStorage< BinContentT, AxisT >::numBinsAt ( const size_t  axisN,
const bool  includeOverflows = false 
) const
inlinenoexcept

Number of bins in the BinnedStorage.

Note
need "AtAxis" in function name since numBins(1) would be ambiguous otherwise

Definition at line 339 of file BinnedStorage.h.

339 {
340 size_t nOverflows = includeOverflows? 0 : _binning.countOverflowBins(axisN);
341 return _binning.numBinsAt(axisN) - nOverflows;
342 }

Referenced by YODA::DbnStorage< DbnN, AxisT >::rebinBy().

◆ operator!=()

template<typename BinContentT , typename... AxisT>
bool YODA::BinnedStorage< BinContentT, AxisT >::operator!= ( const BinnedStorage< BinContentT, AxisT > &  other) const
inlinenoexcept

Compares BinnedStorages for inequality.

Note
This only checks for compatible binning but not equal content.

Definition at line 509 of file BinnedStorage.h.

509 {
510 return ! operator == (other);
511 }
bool operator==(const BinnedStorage &other) const noexcept
Compares BinnedStorages for equality, e.g. dimensions of underlying binnings and all axes edges are e...

References YODA::BinnedStorage< BinContentT, AxisT >::operator==().

◆ operator=() [1/2]

template<typename BinContentT , typename... AxisT>
BinnedStorage & YODA::BinnedStorage< BinContentT, AxisT >::operator= ( BinnedStorage< BinContentT, AxisT > &&  other)
inlinenoexcept

Move assignment.

Definition at line 490 of file BinnedStorage.h.

490 {
491 if (this != &other) {
492 _binning = std::move(other._binning);
493 fillBins(std::move(other._bins));
494 }
495 return *this;
496 }

References YODA::BinnedStorage< BinContentT, AxisT >::fillBins().

◆ operator=() [2/2]

template<typename BinContentT , typename... AxisT>
BinnedStorage & YODA::BinnedStorage< BinContentT, AxisT >::operator= ( const BinnedStorage< BinContentT, AxisT > &  other)
inlinenoexcept

Copy assignment.

Definition at line 481 of file BinnedStorage.h.

481 {
482 if (this != &other) {
483 _binning = other._binning;
484 fillBins(other._bins);
485 }
486 return *this;
487 }

References YODA::BinnedStorage< BinContentT, AxisT >::fillBins().

◆ operator==()

template<typename BinContentT , typename... AxisT>
bool YODA::BinnedStorage< BinContentT, AxisT >::operator== ( const BinnedStorage< BinContentT, AxisT > &  other) const
inlinenoexcept

Compares BinnedStorages for equality, e.g. dimensions of underlying binnings and all axes edges are equal.

Note
This only checks for compatible binning but not equal content.

Definition at line 502 of file BinnedStorage.h.

502 {
503 return _binning.isCompatible(other._binning);
504 }

Referenced by YODA::BinnedStorage< BinContentT, AxisT >::operator!=().

◆ reset()

template<typename BinContentT , typename... AxisT>
void YODA::BinnedStorage< BinContentT, AxisT >::reset ( )
inlinenoexcept

Reset the BinnedStorage.

Definition at line 345 of file BinnedStorage.h.

345{ clearBins(); }
void clearBins() noexcept
Deletes all bins and creates empty new ones.

References YODA::BinnedStorage< BinContentT, AxisT >::clearBins().

◆ set() [1/4]

template<typename BinContentT , typename... AxisT>
void YODA::BinnedStorage< BinContentT, AxisT >::set ( const size_t  binIdx,
BinContentT &&  content 
)
inlinenoexcept

Sets the bin corresponding to binIndex with an rvalue content.

Note
Cython is not a fan of perfect forwarding yet

Definition at line 248 of file BinnedStorage.h.

248 {
249 _bins[binIdx] = std::move(content);
250 }

◆ set() [2/4]

template<typename BinContentT , typename... AxisT>
void YODA::BinnedStorage< BinContentT, AxisT >::set ( const size_t  binIdx,
const BinContentT &  content 
)
inlinenoexcept

Sets the bin corresponding to binIndex with content.

Definition at line 253 of file BinnedStorage.h.

253 {
254 _bins[binIdx] = content;
255 }

◆ set() [3/4]

template<typename BinContentT , typename... AxisT>
void YODA::BinnedStorage< BinContentT, AxisT >::set ( typename BinningT::EdgeTypesTuple &&  coords,
BinContentT &&  content 
)
inlinenoexcept

Sets the bin corresponding to coords with an rvalue content.

Note
Cython is not a fan of perfext forwarding yet

Definition at line 234 of file BinnedStorage.h.

234 {
235 const size_t binIdx = _binning.globalIndexAt(coords);
236 _bins[binIdx] = std::move(content);
237 }

Referenced by YODA::DbnStorage< DbnN, AxisT >::mkEstimate().

◆ set() [4/4]

template<typename BinContentT , typename... AxisT>
void YODA::BinnedStorage< BinContentT, AxisT >::set ( typename BinningT::EdgeTypesTuple &&  coords,
const BinContentT &  content 
)
inlinenoexcept

Sets the bin corresponding to coords with content.

Definition at line 240 of file BinnedStorage.h.

240 {
241 const size_t binIdx = _binning.globalIndexAt(coords);
242 _bins[binIdx] = content;
243 }

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