yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis 2.1.0
YODA::DbnStorage< DbnN, AxisT > Class Template Reference

All histograms can be instantiated through this alias. More...

#include <BinnedDbn.h>

Inheritance diagram for YODA::DbnStorage< DbnN, AxisT >:
YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... > YODA::AnalysisObject YODA::Fillable YODA::BinnedStorage< BinContentT, AxisT >

Public Types

using BaseT = FillableStorage< DbnN, Dbn< DbnN >, AxisT... >
 
using BinningT = typename BaseT::BinningT
 
using BinT = typename BaseT::BinT
 
using BinType = typename BaseT::BinT
 
using FillType = typename BaseT::FillType
 
- Public Types inherited from YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >
using FillType = FillCoordsT
 Type of the fill coordinates.
 
using FillDimension = std::integral_constant< size_t, FillDim >
 Fill dimension.
 
using FillAdapterT = std::function< void(BinT &, FillCoordsT &&, double, double)>
 Adapter type (type of lambda used to access stored object).
 
- Public Types inherited from YODA::BinnedStorage< BinContentT, AxisT >
using BinningType = BinningT
 
using BinType = BinT
 
using BinDimension = std::integral_constant< size_t, sizeof...(AxisT)>
 
- Public Types inherited from YODA::AnalysisObject
typedef std::map< std::string, std::string > Annotations
 Collection type for annotations, as a string-string map.
 

Public Member Functions

Constructors
 DbnStorage ()
 Nullary constructor for unique pointers etc.
 
 DbnStorage (std::vector< AxisT > &&... binsEdges, const std::string &path="", const std::string &title="")
 Constructor giving explicit bin edges as rvalue reference.
 
 DbnStorage (const std::vector< AxisT > &... binsEdges, const std::string &path="", const std::string &title="")
 Constructor giving explicit bin edges as lvalue const reference.
 
 DbnStorage (std::initializer_list< AxisT > &&... binsEdges, const std::string &path="", const std::string &title="")
 Constructor giving explicit bin edges as initializer list.
 
template<typename EdgeT = double, typename = enable_if_all_CAxisT<EdgeT, AxisT...>>
 DbnStorage (const std::vector< size_t > &nBins, const std::vector< std::pair< EdgeT, EdgeT > > &limitsLowUp, const std::string &path="", const std::string &title="")
 Constructor giving range and number of bins.
 
 DbnStorage (const Axis< AxisT > &... axes, const std::string &path="", const std::string &title="")
 Constructor given a sequence of axes.
 
 DbnStorage (Axis< AxisT > &&... axes, const std::string &path="", const std::string &title="")
 Constructor given a sequence of rvalue axes.
 
 DbnStorage (const BinningT &binning, const std::string &path="", const std::string &title="")
 Constructor given a BinningT (needed for type reductions)
 
 DbnStorage (BinningT &&binning, const std::string &path="", const std::string &title="")
 Constructor given an rvalue BinningT.
 
template<typename EdgeT = double, typename = enable_if_all_CAxisT<EdgeT, AxisT...>>
 DbnStorage (const ScatterND< sizeof...(AxisT)+1 > &s, const std::string &path="", const std::string &title="")
 Constructor given a scatter.
 
 DbnStorage (const DbnStorage &other, const std::string &path="")
 Copy constructor.
 
 DbnStorage (DbnStorage &&other, const std::string &path="")
 Move constructor.
 
DbnStorage clone () const noexcept
 Make a copy on the stack.
 
DbnStoragenewclone () const noexcept
 Make a copy on the heap.
 
Transformations
virtual int fill (FillType &&coords, const double weight=1.0, const double fraction=1.0)
 Triggers fill adapter on the bin corresponding to coords.
 
void scaleW (const double scalefactor) noexcept
 Rescale as if all fill weights had been different by factor scalefactor.
 
void scale (const size_t i, const double scalefactor) noexcept
 Rescale as if all fill weights had been different by factor scalefactor along dimension i.
 
void normalize (const double normto=1.0, const bool includeOverflows=true)
 Normalize the (visible) histo "volume" to the normto value.
 
template<size_t axisN>
void rebinBy (unsigned int n, size_t begin=1, size_t end=UINT_MAX)
 Merge every group of n bins, from start to end inclusive.
 
template<size_t axisN>
void rebin (unsigned int n, size_t begin=1, size_t end=UINT_MAX)
 Overloaded alias for rebinBy.
 
template<size_t axisN>
void rebinTo (const std::vector< typename BinningT::template getAxisT< axisN >::EdgeT > &newedges)
 Rebin to the given list of bin edges.
 
template<size_t axisN>
void rebin (const std::vector< typename BinningT::template getAxisT< axisN >::EdgeT > &newedges)
 Overloaded alias for rebinTo.
 
DbnStorageoperator= (const DbnStorage &dbn) noexcept
 Copy assignment.
 
DbnStorageoperator= (DbnStorage &&dbn) noexcept
 Move assignment.
 
DbnStorageoperator+= (const DbnStorage &dbn)
 Add two DbnStorages.
 
DbnStorageoperator+= (DbnStorage &&dbn)
 
DbnStorageoperator-= (const DbnStorage &dbn)
 Subtract one DbnStorages from another one.
 
DbnStorageoperator-= (DbnStorage &&dbn)
 
Reset methods
void reset () noexcept
 Reset the histogram.
 
Binning info.
size_t fillDim () const noexcept
 Fill-dimension of this data object.
 
size_t dim () const noexcept
 Total dimension of the object (number of axes + filled value)
 
template<size_t I, typename E = typename BinningT::template getEdgeT<I>>
std::vector< E > edges (const bool includeOverflows=false) const noexcept
 Returns the edges of axis N by value.
 
template<size_t I, typename E = typename BinningT::template getEdgeT<I>>
std::enable_if_t< std::is_floating_point< E >::value, std::vector< E > > widths (const bool includeOverflows=false) const noexcept
 Templated version to get bin widths of axis N by reference.
 
template<size_t I, typename E = typename BinningT::template getEdgeT<I>>
std::enable_if_t< std::is_floating_point< E >::value, E > min () const noexcept
 Get the lowest non-overflow edge of the axis.
 
template<size_t I, typename E = typename BinningT::template getEdgeT<I>>
std::enable_if_t< std::is_floating_point< E >::value, E > max () const noexcept
 Get the highest non-overflow edge of the axis.
 
Whole histo data
double integral (const bool includeOverflows=true) const noexcept
 Get the total volume of the histogram.
 
double integralError (const bool includeOverflows=true) const noexcept
 Get the total volume error of the histogram.
 
double integralTo (const size_t binIndex) const noexcept
 Get the total volume of the histogram.
 
double integralRange (const size_t binIndex1, size_t binIndex2) const
 Calculates the integrated volume of the histogram between global bins binindex1 and binIndex2.
 
double integralRangeError (const size_t binIndex1, size_t binIndex2) const
 Calculates the integrated volume error of the histogram between global bins binindex1 and binIndex2.
 
double numEntries (const bool includeOverflows=true) const noexcept
 Get the number of fills (fractional fills are possible).
 
double effNumEntries (const bool includeOverflows=true) const noexcept
 Get the effective number of fills.
 
double sumW (const bool includeOverflows=true) const noexcept
 Calculates sum of weights in histo.
 
double sumW2 (const bool includeOverflows=true) const noexcept
 Calculates sum of squared weights in histo.
 
double sumWA (const size_t dim, const bool includeOverflows=true) const
 Calculates first moment along axis dim in histo.
 
double sumWA2 (const size_t dim, const bool includeOverflows=true) const
 Calculates second moment along axis dim in histo.
 
template<size_t dim = DbnN, typename = std::enable_if_t<(dim >= 2)>>
double crossTerm (const size_t A1, const size_t A2, const bool includeOverflows=true) const
 Calculates cross-term along axes A1 and A2 in histo.
 
double mean (size_t axisN, const bool includeOverflows=true) const noexcept
 Calculates the mean value at axis.
 
double variance (size_t axisN, const bool includeOverflows=true) const noexcept
 Calculates the variance at axis.
 
double stdDev (size_t axisN, const bool includeOverflows=true) const noexcept
 Calculates the standard deviation at axis.
 
double stdErr (size_t axisN, const bool includeOverflows=true) const noexcept
 Calculates the standard error at axis.
 
double rms (size_t axisN, const bool includeOverflows=true) const noexcept
 Calculates the RMS at axis.
 
double dVol (const bool includeOverflows=true) const noexcept
 
double density (const bool includeOverflows=true) const noexcept
 Get the total density of the histogram.
 
double densityError (const bool includeOverflows=true) const noexcept
 Get the total density error of the histogram.
 
double densitySum (const bool includeOverflows=true) const noexcept
 Returns the sum of the bin densities.
 
double maxDensity (const bool includeOverflows=true) const noexcept
 Returns the largest density in any of the bins.
 
MPI (de-)serialisation
size_t lengthContent (bool=false) const noexcept
 Length of serialized content vector for MPI reduce operations.
 
std::vector< double > serializeContent (bool=false) const noexcept
 Content serialisation for MPI reduce operations.
 
void deserializeContent (const std::vector< double > &data)
 Content deserialisation for MPI reduce operations.
 
Type reductions
BinnedEstimate< AxisT... > mkEstimate (const std::string &path="", const std::string &source="", const bool divbyvol=true, const double overflowsWidth=-1.0) const
 Produce a BinnedEstimate from a DbnStorage.
 
template<size_t axisN, typename = std::enable_if_t< (axisN < sizeof...(AxisT)) >>
auto mkEstimates (const std::string &path="", const std::string source="", const bool divbyvol=true, const bool includeOverflows=false, const double overflowsWidth=-1.0)
 Produce a BinnedEstimate for each bin along axis axisN and return as a vector.
 
auto mkScatter (const std::string &path="", const bool divbyvol=true, const bool usefocus=false, const bool includeOverflows=false, const bool includeMaskedBins=false, const double overflowsWidth=-1.0) const
 Produce a ScatterND from a DbnStorage.
 
template<size_t N = DbnN, typename = std::enable_if_t< (N == sizeof...(AxisT)+1) >>
BinnedHisto< AxisT... > mkHisto (const std::string &path="") const
 Produce a BinnedHisto from BinnedProfile.
 
template<size_t axisN, typename = std::enable_if_t< (axisN < sizeof...(AxisT)) >>
auto mkMarginalProfile (const std::string &path="") const
 Produce a BinnedProfile from a DbnStorage.
 
template<size_t axisN, typename = std::enable_if_t< (axisN < sizeof...(AxisT)) >>
auto mkMarginalHisto (const std::string &path="") const
 Produce a BinnedHisto from a DbnStorage.
 
template<size_t axisN, typename = std::enable_if_t< (axisN < sizeof...(AxisT) && sizeof...(AxisT)>=2 && DbnN > sizeof...(AxisT)) >>
auto mkProfiles (const std::string &path="", const bool includeOverflows=false) const
 Split into vector of BinnedProfile along axis axisN.
 
template<size_t axisN, typename = std::enable_if_t< (axisN < sizeof...(AxisT) && sizeof...(AxisT)>=2) >>
auto mkHistos (const std::string &path="", const bool includeOverflows=false) const
 Split into vector of BinnedHisto along axis axisN.
 
BinnedEstimate< AxisT... > mkBinnedEffNumEntries (const std::string &path="", const std::string &source="", const bool includeOverflows=true, const bool divbyvol=true, const double overflowsWidth=-1.0)
 Convert the BinnedDbn to a BinnedEstimate representing the effective number of entries in each bin.
 
AnalysisObjectmkInert (const std::string &path="", const std::string &source="") const noexcept
 Return an inert version of the analysis object (e.g. scatter, estimate)
 
- Public Member Functions inherited from YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >
 FillableStorage (FillAdapterT adapter=AdapterWrapperT()._adapter)
 Nullary constructor for unique pointers etc.
 
 FillableStorage (const BinningT &binning, FillAdapterT adapter=AdapterWrapperT()._adapter)
 Constructs FillableStorage from Binning.
 
 FillableStorage (BinningT &&binning, FillAdapterT adapter=AdapterWrapperT()._adapter)
 Constructs FillableStorage from Binning. Rvalue.
 
 FillableStorage (const std::vector< AxisT > &... edges, FillAdapterT adapter=AdapterWrapperT()._adapter)
 Constructs binning from an adapter and vectors of axes' edges.
 
 FillableStorage (std::vector< AxisT > &&... edges, FillAdapterT adapter=AdapterWrapperT()._adapter)
 Constructs binning from an adapter and Rvalue vectors of axes' edges.
 
 FillableStorage (const Axis< AxisT > &... axes, FillAdapterT adapter=AdapterWrapperT()._adapter)
 Constructs binning from an adapter and a sequence of axes.
 
 FillableStorage (Axis< AxisT > &&... axes, FillAdapterT adapter=AdapterWrapperT()._adapter)
 Constructs binning from an adapter and a sequence of Rvalue axes.
 
 FillableStorage (const FillableStorage &other)
 Copy constructor.
 
 FillableStorage (FillableStorage &&other)
 Move constructor.
 
int fill (FillCoordsT &&coords, std::index_sequence< Is... >, const double weight=1.0, const double fraction=1.0) noexcept
 Triggers fill adapter on the bin corresponding to coords.
 
int fill (FillCoordsT &&coords, const double weight=1.0, const double fraction=1.0) noexcept
 Triggers fill adapter on the bin corresponding to coords.
 
size_t fillDim () const
 Returns the dimension of the filling tuple.
 
size_t nanCount () const
 
double nanSumW () const
 
double nanSumW2 () const
 
void setNanLog (size_t count, double sumw, double sumw2)
 
void reset () noexcept
 Reset the Fillable.
 
FillableStorageoperator= (const FillableStorage &other) noexcept
 Copy assignment.
 
FillableStorageoperator= (FillableStorage &&other) noexcept
 Move assignment.
 
FillableStorageoperator+= (const FillableStorage &other)
 Add another BinnedStorage to this one.
 
FillableStorageoperator-= (const FillableStorage &other)
 Subtract another BinnedStorage from this one.
 
- Public Member Functions inherited from YODA::BinnedStorage< BinContentT, AxisT >
 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.
 
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.
 
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.
 
- Public Member Functions inherited from YODA::AnalysisObject
 AnalysisObject ()
 Default constructor.
 
 AnalysisObject (const std::string &type, const std::string &path, const std::string &title="")
 Constructor giving a type, a path and an optional title.
 
 AnalysisObject (const std::string &type, const std::string &path, const AnalysisObject &ao, const std::string &title="")
 Constructor giving a type, a path, another AO to copy annotation from, and an optional title.
 
virtual ~AnalysisObject ()
 Default destructor.
 
virtual AnalysisObjectoperator= (const AnalysisObject &ao) noexcept
 Default copy assignment operator.
 
std::vector< std::string > annotations () const
 
bool hasAnnotation (const std::string &name) const
 Check if an annotation is defined.
 
const std::string & annotation (const std::string &name) const
 Get an annotation by name (as a string)
 
const std::string & annotation (const std::string &name, const std::string &defaultreturn) const
 Get an annotation by name (as a string) with a default in case the annotation is not found.
 
template<typename T >
const T annotation (const std::string &name) const
 Get an annotation by name (copied to another type)
 
template<typename T >
const T annotation (const std::string &name, const T &defaultreturn) const
 Get an annotation by name (copied to another type) with a default in case the annotation is not found.
 
template<typename T >
void setAnnotation (const std::string &name, const T &value)
 Add or set an annotation by name (templated for remaining types)
 
void setAnnotations (const Annotations &anns)
 Set all annotations at once.
 
template<typename T >
void addAnnotation (const std::string &name, const T &value)
 Add or set an annotation by name.
 
void rmAnnotation (const std::string &name)
 Delete an annotation by name.
 
void clearAnnotations ()
 Delete an annotation by name.
 
const std::string title () const
 Get the AO title.
 
void setTitle (const std::string &title)
 Set the AO title.
 
const std::string path () const
 Get the AO path.
 
void setPath (const std::string &path)
 
const std::string name () const
 
virtual std::string type () const
 Get name of the analysis object type.
 
size_t lengthMeta (const bool skipPath=true, const bool skipTitle=true) const noexcept
 Length of serialized meta-data vector for MPI reduce operations.
 
std::vector< std::string > serializeMeta (const bool skipPath=true, const bool skipTitle=true) const noexcept
 Meta-data serialisation for MPI reduce operations.
 
virtual void deserializeMeta (const std::vector< std::string > &data, const bool resetPath=false, const bool resetTitle=false)
 Mate-data deserialisation for MPI reduce operations.
 
- Public Member Functions inherited from YODA::Fillable
virtual ~Fillable ()=default
 Virtual destructor for inheritance.
 

Additional Inherited Members

- Protected Types inherited from YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >
using BaseT = BinnedStorage< Dbn< DbnN >, AxisT... >
 Convenience alias to be used in constructor.
 
using BinningT = typename BaseT::BinningT
 
using BinT = Bin< sizeof...(AxisT), Dbn< DbnN >, BinningT >
 
using AdapterWrapperT = defaultAdapter< FillDim, BinT >
 
using FillableT = FillableStorage< FillDim, Dbn< DbnN >, AxisT... >
 
using FillCoordsT = decltype(std::tuple_cat(std::declval< typename BinningT::EdgeTypesTuple >(), dblPadding(std::make_index_sequence< FillDim-sizeof...(AxisT)>{})))
 
- Protected Types inherited from YODA::BinnedStorage< BinContentT, AxisT >
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... >
 
- Protected Member Functions inherited from YODA::BinnedStorage< BinContentT, AxisT >
void fillBins () noexcept
 Fills bins with wrapped BinContent objects.
 
void fillBins (const BinsVecT &bins) noexcept
 
void fillBins (BinsVecT &&bins) noexcept
 

Detailed Description

template<size_t DbnN, typename... AxisT>
class YODA::DbnStorage< DbnN, AxisT >

All histograms can be instantiated through this alias.

Histogram convenience class based on FillableStorage.

Since objects with continuous axes are by far the most commonly used type in practice, we define convenient short-hand aliases HistoND/ProfileND for with only continuous axes, along with the familar types Histo1D, Profile2D, etc.

Note
We use this abstraction layer to implement the bulk once and only once. The user-facing BinnedDbn type(s) will inherit all their methods from this base class along with a few axis-specifc mixins.
Alias generates index sequence later used to create a parameter pack consisting of axis types to instantiate the Binning template.

Definition at line 120 of file BinnedDbn.h.

Member Typedef Documentation

◆ BaseT

template<size_t DbnN, typename... AxisT>
using YODA::DbnStorage< DbnN, AxisT >::BaseT = FillableStorage<DbnN, Dbn<DbnN>, AxisT...>

Definition at line 124 of file BinnedDbn.h.

◆ BinningT

template<size_t DbnN, typename... AxisT>
using YODA::DbnStorage< DbnN, AxisT >::BinningT = typename BaseT::BinningT

Definition at line 125 of file BinnedDbn.h.

◆ BinT

template<size_t DbnN, typename... AxisT>
using YODA::DbnStorage< DbnN, AxisT >::BinT = typename BaseT::BinT

Definition at line 126 of file BinnedDbn.h.

◆ BinType

template<size_t DbnN, typename... AxisT>
using YODA::DbnStorage< DbnN, AxisT >::BinType = typename BaseT::BinT

Definition at line 127 of file BinnedDbn.h.

◆ FillType

template<size_t DbnN, typename... AxisT>
using YODA::DbnStorage< DbnN, AxisT >::FillType = typename BaseT::FillType

Definition at line 128 of file BinnedDbn.h.

Constructor & Destructor Documentation

◆ DbnStorage() [1/12]

template<size_t DbnN, typename... AxisT>
YODA::DbnStorage< DbnN, AxisT >::DbnStorage ( )
inline

Nullary constructor for unique pointers etc.

Note
The setting of optional path/title is not possible here in order to avoid overload ambiguity for brace-initialised constructors.

Definition at line 138 of file BinnedDbn.h.

138: BaseT(), AnalysisObject(mkTypeString<DbnN, AxisT...>(), "") { }
AnalysisObject()
Default constructor.
FillableStorage< DbnN, Dbn< DbnN >, AxisT... > BaseT
Definition BinnedDbn.h:124

Referenced by YODA::DbnStorage< DbnN, AxisT >::clone(), and YODA::DbnStorage< DbnN, AxisT >::newclone().

◆ DbnStorage() [2/12]

template<size_t DbnN, typename... AxisT>
YODA::DbnStorage< DbnN, AxisT >::DbnStorage ( std::vector< AxisT > &&...  binsEdges,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor giving explicit bin edges as rvalue reference.

Discrete axes have as many edges as bins. Continuous axes have number of edges = number of bins + 1, the last one being the upper bound of the last bin.

Definition at line 145 of file BinnedDbn.h.

147 : BaseT(Axis<AxisT>(std::move(binsEdges))...),
148 AnalysisObject(mkTypeString<DbnN, AxisT...>(), path, title) { }
const std::string title() const
Get the AO title.
const std::string path() const
Get the AO path.

◆ DbnStorage() [3/12]

template<size_t DbnN, typename... AxisT>
YODA::DbnStorage< DbnN, AxisT >::DbnStorage ( const std::vector< AxisT > &...  binsEdges,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor giving explicit bin edges as lvalue const reference.

Discrete axes have as many edges as bins. Continuous axes have bins.size()+1 edges, the last one being the upper bound of the last bin.

Definition at line 155 of file BinnedDbn.h.

157 : BaseT(Axis<AxisT>(binsEdges)...),
158 AnalysisObject(mkTypeString<DbnN, AxisT...>(), path, title) { }

◆ DbnStorage() [4/12]

template<size_t DbnN, typename... AxisT>
YODA::DbnStorage< DbnN, AxisT >::DbnStorage ( std::initializer_list< AxisT > &&...  binsEdges,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor giving explicit bin edges as initializer list.

Discrete axes have as many edges as bins. Continuous axes have number of edges = number of bins + 1, the last one being the upper bound of the last bin.

Definition at line 165 of file BinnedDbn.h.

167 : BaseT(Axis<AxisT>(std::move(binsEdges))...),
168 AnalysisObject(mkTypeString<DbnN, AxisT...>(), path, title) { }

◆ DbnStorage() [5/12]

template<size_t DbnN, typename... AxisT>
template<typename EdgeT = double, typename = enable_if_all_CAxisT<EdgeT, AxisT...>>
YODA::DbnStorage< DbnN, AxisT >::DbnStorage ( const std::vector< size_t > &  nBins,
const std::vector< std::pair< EdgeT, EdgeT > > &  limitsLowUp,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor giving range and number of bins.

Note
This constructor is only supported for objects with purely continous axes. It is also the only place where the index sequence sequence is actually needed.

Definition at line 175 of file BinnedDbn.h.

177 : BaseT( _mkBinning(nBins, limitsLowUp, std::make_index_sequence<sizeof...(AxisT)>{}) ),
178 AnalysisObject(mkTypeString<DbnN, AxisT...>(), path, title) { }

◆ DbnStorage() [6/12]

template<size_t DbnN, typename... AxisT>
YODA::DbnStorage< DbnN, AxisT >::DbnStorage ( const Axis< AxisT > &...  axes,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor given a sequence of axes.

Definition at line 181 of file BinnedDbn.h.

182 : BaseT(axes...), AnalysisObject(mkTypeString<DbnN, AxisT...>(), path, title) { }

◆ DbnStorage() [7/12]

template<size_t DbnN, typename... AxisT>
YODA::DbnStorage< DbnN, AxisT >::DbnStorage ( Axis< AxisT > &&...  axes,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor given a sequence of rvalue axes.

Definition at line 185 of file BinnedDbn.h.

186 : BaseT(std::move(axes)...), AnalysisObject(mkTypeString<DbnN, AxisT...>(), path, title) { }

◆ DbnStorage() [8/12]

template<size_t DbnN, typename... AxisT>
YODA::DbnStorage< DbnN, AxisT >::DbnStorage ( const BinningT binning,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor given a BinningT (needed for type reductions)

Definition at line 189 of file BinnedDbn.h.

190 : BaseT(binning), AnalysisObject(mkTypeString<DbnN, AxisT...>(), path, title) { }
const BinningT & binning() const noexcept
Returns dimension underlying binning object reference.

◆ DbnStorage() [9/12]

template<size_t DbnN, typename... AxisT>
YODA::DbnStorage< DbnN, AxisT >::DbnStorage ( BinningT &&  binning,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor given an rvalue BinningT.

Definition at line 193 of file BinnedDbn.h.

194 : BaseT(std::move(binning)), AnalysisObject(mkTypeString<DbnN, AxisT...>(), path, title) { }

◆ DbnStorage() [10/12]

template<size_t DbnN, typename... AxisT>
template<typename EdgeT = double, typename = enable_if_all_CAxisT<EdgeT, AxisT...>>
YODA::DbnStorage< DbnN, AxisT >::DbnStorage ( const ScatterND< sizeof...(AxisT)+1 > &  s,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor given a scatter.

Definition at line 198 of file BinnedDbn.h.

199 : BaseT(_mkBinning(s, std::make_index_sequence<sizeof...(AxisT)>{})),
200 AnalysisObject(mkTypeString<DbnN, AxisT...>(), path, title) { }

◆ DbnStorage() [11/12]

template<size_t DbnN, typename... AxisT>
YODA::DbnStorage< DbnN, AxisT >::DbnStorage ( const DbnStorage< DbnN, AxisT > &  other,
const std::string &  path = "" 
)
inline

Copy constructor.

Todo:
Also allow title setting from the constructor?

Definition at line 205 of file BinnedDbn.h.

205 : BaseT(other),
206 AnalysisObject(mkTypeString<DbnN, AxisT...>(), path!=""? path : other.path(), other, other.title()) { }

◆ DbnStorage() [12/12]

template<size_t DbnN, typename... AxisT>
YODA::DbnStorage< DbnN, AxisT >::DbnStorage ( DbnStorage< DbnN, AxisT > &&  other,
const std::string &  path = "" 
)
inline

Move constructor.

Todo:
Also allow title setting from the constructor?

Definition at line 211 of file BinnedDbn.h.

211 : BaseT(std::move(other)),
212 AnalysisObject(mkTypeString<DbnN, AxisT...>(), path!=""? path : other.path(), other, other.title()) { }

Member Function Documentation

◆ clone()

template<size_t DbnN, typename... AxisT>
DbnStorage YODA::DbnStorage< DbnN, AxisT >::clone ( ) const
inlinenoexcept

Make a copy on the stack.

Definition at line 215 of file BinnedDbn.h.

215 {
216 return DbnStorage(*this);
217 }
DbnStorage()
Nullary constructor for unique pointers etc.
Definition BinnedDbn.h:138

References YODA::DbnStorage< DbnN, AxisT >::DbnStorage().

◆ crossTerm()

template<size_t DbnN, typename... AxisT>
template<size_t dim = DbnN, typename = std::enable_if_t<(dim >= 2)>>
double YODA::DbnStorage< DbnN, AxisT >::crossTerm ( const size_t  A1,
const size_t  A2,
const bool  includeOverflows = true 
) const
inline

Calculates cross-term along axes A1 and A2 in histo.

Definition at line 562 of file BinnedDbn.h.

562 {
563 if (A1 >= DbnN || A2 >= DbnN) throw RangeError("Invalid axis int, must be in range 0..dim-1");
564 if (A1 >= A2) throw RangeError("Indices need to be different for cross term");
565 double sumw = 0;
566 for (const auto& b : BaseT::bins(includeOverflows))
567 sumw += b.crossTerm(A1, A2);
568 return sumw;
569 }
BinsVecWrapper< BinsVecT > bins(const bool includeOverflows=false, const bool includeMaskedBins=false) noexcept
Returns bins vector wrapper, which skips masked elements when iterated over.
double crossTerm(const size_t A1, const size_t A2, const bool includeOverflows=true) const
Calculates cross-term along axes A1 and A2 in histo.
Definition BinnedDbn.h:562

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

Referenced by YODA::WriterYODA1::writeHisto2D(), and YODA::WriterYODA1::writeProfile2D().

◆ density()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::density ( const bool  includeOverflows = true) const
inlinenoexcept

Get the total density of the histogram.

Definition at line 616 of file BinnedDbn.h.

616 {
617 const double vol = dVol(includeOverflows);
618 if (vol) return integral(includeOverflows) / vol;
619 return std::numeric_limits<double>::quiet_NaN();
620 }
double dVol(const bool includeOverflows=true) const noexcept
Definition BinnedDbn.h:608
double integral(const bool includeOverflows=true) const noexcept
Get the total volume of the histogram.
Definition BinnedDbn.h:468

References YODA::DbnStorage< DbnN, AxisT >::dVol(), and YODA::DbnStorage< DbnN, AxisT >::integral().

◆ densityError()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::densityError ( const bool  includeOverflows = true) const
inlinenoexcept

Get the total density error of the histogram.

Definition at line 623 of file BinnedDbn.h.

623 {
624 const double vol = dVol(includeOverflows);
625 if (vol) return integralError(includeOverflows) / vol;
626 return std::numeric_limits<double>::quiet_NaN();
627 }
double integralError(const bool includeOverflows=true) const noexcept
Get the total volume error of the histogram.
Definition BinnedDbn.h:473

References YODA::DbnStorage< DbnN, AxisT >::dVol(), and YODA::DbnStorage< DbnN, AxisT >::integralError().

◆ densitySum()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::densitySum ( const bool  includeOverflows = true) const
inlinenoexcept

Returns the sum of the bin densities.

Definition at line 630 of file BinnedDbn.h.

630 {
631 double rho = 0.0;
632 for (const auto& b : BaseT::bins(includeOverflows))
633 rho += b.sumW() / b.dVol();
634 return rho;
635 }
double sumW(const bool includeOverflows=true) const noexcept
Calculates sum of weights in histo.
Definition BinnedDbn.h:527

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

◆ deserializeContent()

template<size_t DbnN, typename... AxisT>
void YODA::DbnStorage< DbnN, AxisT >::deserializeContent ( const std::vector< double > &  data)
inlinevirtual

Content deserialisation for MPI reduce operations.

Implements YODA::AnalysisObject.

Definition at line 772 of file BinnedDbn.h.

772 {
773
774 constexpr size_t dbnSize = Dbn<DbnN>::DataSize::value;
775 const size_t nBins = BaseT::numBins(true, true);
776 if (data.size() != nBins * dbnSize)
777 throw UserError("Length of serialized data should be "
778 + std::to_string(nBins * dbnSize)+"!");
779
780 const auto itr = data.cbegin();
781 for (size_t i = 0; i < nBins; ++i) {
782 auto first = itr + i*dbnSize;
783 auto last = first + dbnSize;
784 BaseT::bin(i)._deserializeContent(std::vector<double>{first, last});
785 }
786
787 }
BinT & bin(size_t idx) noexcept
Returns reference to the bin at idx.
size_t numBins(const bool includeOverflows=false, const bool includeMaskedBins=false) const noexcept
Number of bins in the BinnedStorage.

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

◆ dim()

template<size_t DbnN, typename... AxisT>
size_t YODA::DbnStorage< DbnN, AxisT >::dim ( ) const
inlinevirtualnoexcept

Total dimension of the object (number of axes + filled value)

Implements YODA::AnalysisObject.

Definition at line 422 of file BinnedDbn.h.

422{ return sizeof...(AxisT) + 1; }

Referenced by YODA::DbnStorage< DbnN, AxisT >::sumWA(), and YODA::DbnStorage< DbnN, AxisT >::sumWA2().

◆ dVol()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::dVol ( const bool  includeOverflows = true) const
inlinenoexcept

Definition at line 608 of file BinnedDbn.h.

608 {
609 double vol = 0.0;
610 for (const auto& b : BaseT::bins(includeOverflows))
611 vol += b.dVol();
612 return vol;
613 }

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

Referenced by YODA::DbnStorage< DbnN, AxisT >::density(), and YODA::DbnStorage< DbnN, AxisT >::densityError().

◆ edges()

template<size_t DbnN, typename... AxisT>
template<size_t I, typename E = typename BinningT::template getEdgeT<I>>
std::vector< E > YODA::DbnStorage< DbnN, AxisT >::edges ( const bool  includeOverflows = false) const
inlinenoexcept

Returns the edges of axis N by value.

Definition at line 429 of file BinnedDbn.h.

429 {
430 return BaseT::_binning.template edges<I>(includeOverflows);
431 }

◆ effNumEntries()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::effNumEntries ( const bool  includeOverflows = true) const
inlinevirtualnoexcept

Get the effective number of fills.

Implements YODA::Fillable.

Definition at line 519 of file BinnedDbn.h.

519 {
520 double n = 0;
521 for (const auto& b : BaseT::bins(includeOverflows))
522 n += b.effNumEntries();
523 return n;
524 }
double effNumEntries(const bool includeOverflows=true) const noexcept
Get the effective number of fills.
Definition BinnedDbn.h:519

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

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

◆ fill()

template<size_t DbnN, typename... AxisT>
virtual int YODA::DbnStorage< DbnN, AxisT >::fill ( FillType &&  coords,
const double  weight = 1.0,
const double  fraction = 1.0 
)
inlinevirtual

Triggers fill adapter on the bin corresponding to coords.

Note
Accepts coordinates only as rvalue tuple. The tuple members are then moved (bringing tuple member to unspecified state) later in adapters.

Definition at line 234 of file BinnedDbn.h.

234 {
235 return BaseT::fill(std::move(coords), std::make_index_sequence<sizeof...(AxisT)>{}, weight, fraction);
236 }
int fill(FillCoordsT &&coords, std::index_sequence< Is... >, const double weight=1.0, const double fraction=1.0) noexcept
Triggers fill adapter on the bin corresponding to coords.

References YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::fill().

◆ fillDim()

template<size_t DbnN, typename... AxisT>
size_t YODA::DbnStorage< DbnN, AxisT >::fillDim ( ) const
inlinevirtualnoexcept

Fill-dimension of this data object.

Implements YODA::Fillable.

Definition at line 419 of file BinnedDbn.h.

419{ return BaseT::fillDim(); }
size_t fillDim() const
Returns the dimension of the filling tuple.

References YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::fillDim().

◆ integral()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::integral ( const bool  includeOverflows = true) const
inlinenoexcept

Get the total volume of the histogram.

Definition at line 468 of file BinnedDbn.h.

468 {
469 return sumW(includeOverflows);
470 }

References YODA::DbnStorage< DbnN, AxisT >::sumW().

Referenced by YODA::DbnStorage< DbnN, AxisT >::density(), YODA::mkIntegralEff(), YODA::DbnStorage< DbnN, AxisT >::normalize(), YODA::WriterYODA1::writeHisto1D(), and YODA::WriterYODA1::writeHisto2D().

◆ integralError()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::integralError ( const bool  includeOverflows = true) const
inlinenoexcept

Get the total volume error of the histogram.

Definition at line 473 of file BinnedDbn.h.

473 {
474 return sqrt(sumW2(includeOverflows));
475 }
double sumW2(const bool includeOverflows=true) const noexcept
Calculates sum of squared weights in histo.
Definition BinnedDbn.h:535

References YODA::DbnStorage< DbnN, AxisT >::sumW2().

Referenced by YODA::DbnStorage< DbnN, AxisT >::densityError(), and YODA::mkIntegralEff().

◆ integralRange()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::integralRange ( const size_t  binIndex1,
size_t  binIndex2 
) const
inline

Calculates the integrated volume of the histogram between global bins binindex1 and binIndex2.

Definition at line 484 of file BinnedDbn.h.

484 {
485 assert(binIndex2 >= binIndex1);
486 if (binIndex1 >= BaseT::numBins(true)) throw RangeError("binindex1 is out of range");
487 if (binIndex2 >= BaseT::numBins(true)) throw RangeError("binindex2 is out of range");
488 double sumw = 0;
489 for (size_t idx = binIndex1; idx <= binIndex2; ++idx) {
490 if (BaseT::bin(idx).isMasked()) continue;
491 sumw += BaseT::bin(idx).sumW();
492 }
493 return sumw;
494 }
bool isMasked(const size_t binIndex) const noexcept

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

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

◆ integralRangeError()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::integralRangeError ( const size_t  binIndex1,
size_t  binIndex2 
) const
inline

Calculates the integrated volume error of the histogram between global bins binindex1 and binIndex2.

Definition at line 498 of file BinnedDbn.h.

498 {
499 assert(binIndex2 >= binIndex1);
500 if (binIndex1 >= BaseT::numBins(true)) throw RangeError("binindex1 is out of range");
501 if (binIndex2 >= BaseT::numBins(true)) throw RangeError("binindex2 is out of range");
502 double sumw2 = 0;
503 for (size_t idx = binIndex1; idx <= binIndex2; ++idx) {
504 if (BaseT::bin(idx).isMasked()) continue;
505 sumw2 += BaseT::bin(idx).sumW2();
506 }
507 return sumw2;
508 }

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

◆ integralTo()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::integralTo ( const size_t  binIndex) const
inlinenoexcept

Get the total volume of the histogram.

Definition at line 478 of file BinnedDbn.h.

478 {
479 return integralRange(0, binIndex);
480 }
double integralRange(const size_t binIndex1, size_t binIndex2) const
Calculates the integrated volume of the histogram between global bins binindex1 and binIndex2.
Definition BinnedDbn.h:484

References YODA::DbnStorage< DbnN, AxisT >::integralRange().

◆ lengthContent()

template<size_t DbnN, typename... AxisT>
size_t YODA::DbnStorage< DbnN, AxisT >::lengthContent ( bool  fixed_length = false) const
inlinevirtualnoexcept

Length of serialized content vector for MPI reduce operations.

Implements YODA::AnalysisObject.

Definition at line 755 of file BinnedDbn.h.

755 {
756 return BaseT::numBins(true, true) * Dbn<DbnN>::DataSize::value;
757 }

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

◆ max()

template<size_t DbnN, typename... AxisT>
template<size_t I, typename E = typename BinningT::template getEdgeT<I>>
std::enable_if_t< std::is_floating_point< E >::value, E > YODA::DbnStorage< DbnN, AxisT >::max ( ) const
inlinenoexcept

Get the highest non-overflow edge of the axis.

Note
This method is only supported for continuous axes

Definition at line 457 of file BinnedDbn.h.

457 {
458 return BaseT::_binning.template max<I>();
459 }

◆ maxDensity()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::maxDensity ( const bool  includeOverflows = true) const
inlinenoexcept

Returns the largest density in any of the bins.

Definition at line 638 of file BinnedDbn.h.

638 {
639 std::vector<double> vals;
640 for (auto& b : BaseT::bins(includeOverflows))
641 vals.emplace_back(b.sumW() / b.dVol());
642 return *max_element(vals.begin(), vals.end());
643 }

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

◆ mean()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::mean ( size_t  axisN,
const bool  includeOverflows = true 
) const
inlinenoexcept

Calculates the mean value at axis.

Definition at line 572 of file BinnedDbn.h.

572 {
573 Dbn<DbnN> dbn;
574 for (const auto& b : BaseT::bins(includeOverflows))
575 dbn += b;
576 return dbn.mean(axisN+1);
577 }

References YODA::BinnedStorage< BinContentT, AxisT >::bins(), and YODA::DbnBase< N >::mean().

◆ min()

template<size_t DbnN, typename... AxisT>
template<size_t I, typename E = typename BinningT::template getEdgeT<I>>
std::enable_if_t< std::is_floating_point< E >::value, E > YODA::DbnStorage< DbnN, AxisT >::min ( ) const
inlinenoexcept

Get the lowest non-overflow edge of the axis.

Note
This method is only supported for continuous axes

Definition at line 449 of file BinnedDbn.h.

449 {
450 return BaseT::_binning.template min<I>();
451 }

◆ mkBinnedEffNumEntries()

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::DbnStorage< DbnN, AxisT >::mkBinnedEffNumEntries ( const std::string &  path = "",
const std::string &  source = "",
const bool  includeOverflows = true,
const bool  divbyvol = true,
const double  overflowsWidth = -1.0 
)
inline

Convert the BinnedDbn to a BinnedEstimate representing the effective number of entries in each bin.

Note
The overflowsWidth argument will be applied to all bins outside the visible bin range.

Definition at line 1085 of file BinnedDbn.h.

1089 {
1090
1091 BinnedEstimate<AxisT...> rtn = mkEstimate(path);
1092
1093 for (const auto& b : BaseT::bins(includeOverflows)) {
1094 double scale = 1.0;
1095 if (divbyvol) {
1096 scale = (overflowsWidth > 0. && !b.isVisible())? overflowsWidth : b.dVol();
1097 }
1098 const double effN = b.effNumEntries() / scale;
1099 const double err = effN * b.relErrW() / scale;
1100 rtn.bin(b.index()).set(effN, {-err, err}, source);
1101 }
1102
1103 return rtn;
1104 }
BinnedEstimate< AxisT... > mkEstimate(const std::string &path="", const std::string &source="", const bool divbyvol=true, const double overflowsWidth=-1.0) const
Produce a BinnedEstimate from a DbnStorage.
Definition BinnedDbn.h:800
void scale(const size_t i, const double scalefactor) noexcept
Rescale as if all fill weights had been different by factor scalefactor along dimension i.
Definition BinnedDbn.h:247

References YODA::BinnedStorage< BinContentT, AxisT >::bins(), YODA::DbnStorage< DbnN, AxisT >::mkEstimate(), YODA::AnalysisObject::path(), and YODA::DbnStorage< DbnN, AxisT >::scale().

◆ mkEstimate()

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::DbnStorage< DbnN, AxisT >::mkEstimate ( const std::string &  path = "",
const std::string &  source = "",
const bool  divbyvol = true,
const double  overflowsWidth = -1.0 
) const
inline

Produce a BinnedEstimate from a DbnStorage.

The binning remains unchanged.

Note
The overflowsWidth argument will be applied to all bins outside the visible bin range.

Definition at line 800 of file BinnedDbn.h.

803 {
804
805 // @todo Should we check BaseT::nanCount() and report?
806 BinnedEstimate<AxisT...> rtn(BaseT::_binning);
807 for (const std::string& a : annotations()) {
808 if (a != "Type") rtn.setAnnotation(a, annotation(a));
809 }
810 rtn.setAnnotation("Path", path);
811
812 if (BaseT::nanCount()) {
813 const double nanc = BaseT::nanCount();
814 const double nanw = BaseT::nanSumW();
815 const double frac = nanc / (nanc + numEntries());
816 const double wtot = nanw + effNumEntries();
817 rtn.setAnnotation("NanFraction", frac);
818 if (wtot) rtn.setAnnotation("WeightedNanFraction", nanw/wtot);
819 }
820
821 for (const auto& b : BaseT::bins(true, true)) {
822 if (overflowsWidth <= 0. && !b.isVisible()) continue;
823 if constexpr(DbnN > sizeof...(AxisT)) {
824 rtn.bin(b.index()).setVal(b.mean(DbnN));
825 if (b.numEntries()) { // only set uncertainty for filled Dbns
826 rtn.bin(b.index()).setErr(b.stdErr(DbnN), source);
827 }
828 }
829 else {
830 const double scale = divbyvol? (b.isVisible()? b.dVol() : overflowsWidth) : 1.0;
831 rtn.bin(b.index()).setVal(b.sumW() / scale);
832 if (b.numEntries()) { // only set uncertainty for filled Dbns
833 rtn.bin(b.index()).setErr(b.errW() / scale, source);
834 }
835 }
836 }
837
838 return rtn;
839 }
std::vector< std::string > annotations() const
const std::string & annotation(const std::string &name) const
Get an annotation by name (as a string)
double numEntries(const bool includeOverflows=true) const noexcept
Get the number of fills (fractional fills are possible).
Definition BinnedDbn.h:511

References YODA::AnalysisObject::annotation(), YODA::AnalysisObject::annotations(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), YODA::DbnStorage< DbnN, AxisT >::effNumEntries(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanCount(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanSumW(), YODA::DbnStorage< DbnN, AxisT >::numEntries(), YODA::AnalysisObject::path(), and YODA::DbnStorage< DbnN, AxisT >::scale().

Referenced by YODA::add(), YODA::divide(), YODA::divide(), YODA::DbnStorage< DbnN, AxisT >::mkBinnedEffNumEntries(), YODA::DbnStorage< DbnN, AxisT >::mkEstimates(), YODA::DbnStorage< DbnN, AxisT >::mkInert(), YODA::mkIntegral(), YODA::DbnStorage< DbnN, AxisT >::mkScatter(), and YODA::subtract().

◆ mkEstimates()

template<size_t DbnN, typename... AxisT>
template<size_t axisN, typename = std::enable_if_t< (axisN < sizeof...(AxisT)) >>
auto YODA::DbnStorage< DbnN, AxisT >::mkEstimates ( const std::string &  path = "",
const std::string  source = "",
const bool  divbyvol = true,
const bool  includeOverflows = false,
const double  overflowsWidth = -1.0 
)
inline

Produce a BinnedEstimate for each bin along axis axisN and return as a vector.

The binning dimension is reduced by one unit.

Note
The overflowsWidth argument will be applied to all bins outside the visible bin range.

Definition at line 849 of file BinnedDbn.h.

851 {
852
853 BinnedEstimate<AxisT...> est = mkEstimate(path, source, divbyvol, overflowsWidth);
854 return est.template mkEstimates<axisN>(path, includeOverflows);
855 }

References YODA::DbnStorage< DbnN, AxisT >::mkEstimate(), and YODA::AnalysisObject::path().

◆ mkHisto()

template<size_t DbnN, typename... AxisT>
template<size_t N = DbnN, typename = std::enable_if_t< (N == sizeof...(AxisT)+1) >>
BinnedHisto< AxisT... > YODA::DbnStorage< DbnN, AxisT >::mkHisto ( const std::string &  path = "") const
inline

Produce a BinnedHisto from BinnedProfile.

The binning remains unchanged, but the fill dimension is reduced by one unit.

Definition at line 893 of file BinnedDbn.h.

893 {
894
895 BinnedHisto<AxisT...> rtn(BaseT::_binning);
896 rtn.setNanLog(BaseT::nanCount(), BaseT::nanSumW(), BaseT::nanSumW2());
897 for (const std::string& a : annotations()) {
898 if (a != "Type") rtn.setAnnotation(a, annotation(a));
899 }
900 rtn.setAnnotation("Path", path);
901
902 for (const auto& b : BaseT::bins(true)) {
903 rtn.bin(b.index()) += b.template reduce<N-1>();
904 }
905
906 return rtn;
907 }
BinnedDbn< sizeof...(AxisTypes), AxisTypes... > BinnedHisto
Definition BinnedDbn.h:102

References YODA::AnalysisObject::annotation(), YODA::AnalysisObject::annotations(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanCount(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanSumW(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanSumW2(), and YODA::AnalysisObject::path().

Referenced by YODA::DbnStorage< DbnN, AxisT >::mkHistos(), and YODA::DbnStorage< DbnN, AxisT >::mkMarginalHisto().

◆ mkHistos()

template<size_t DbnN, typename... AxisT>
template<size_t axisN, typename = std::enable_if_t< (axisN < sizeof...(AxisT) && sizeof...(AxisT)>=2) >>
auto YODA::DbnStorage< DbnN, AxisT >::mkHistos ( const std::string &  path = "",
const bool  includeOverflows = false 
) const
inline

Split into vector of BinnedHisto along axis axisN.

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

Note
Requires at least two binning dimensions.

Definition at line 1054 of file BinnedDbn.h.

1054 {
1055
1056 if constexpr (DbnN != sizeof...(AxisT)) {
1057 // Case 1: BP(N+1) -> BH(N+1) -> BHN
1058 return mkHisto().template mkHistos<axisN>(path, includeOverflows);
1059 }
1060 else {
1061 // Case 2: BH(N+1) -> BHN
1062
1063 // Need to provide a prescription for how to add the two bin contents
1064 auto how2add = [](auto& pivot, const BinType& toCopy) { pivot = toCopy.template reduce<axisN>(); };
1065 auto rtn = BaseT::template mkBinnedSlices<axisN,BinnedHisto>(how2add, includeOverflows);
1066 for (const std::string& a : annotations()) {
1067 if (a == "Type") continue;
1068 for (size_t i = 0; i < rtn.size(); ++i) {
1069 rtn[i].setAnnotation(a, annotation(a));
1070 }
1071 }
1072 for (size_t i = 0; i < rtn.size(); ++i) {
1073 rtn[i].setAnnotation("Path", path);
1074 }
1075 return rtn;
1076 }
1077 }
typename BaseT::BinT BinType
Definition BinnedDbn.h:127
BinnedHisto< AxisT... > mkHisto(const std::string &path="") const
Produce a BinnedHisto from BinnedProfile.
Definition BinnedDbn.h:893

References YODA::AnalysisObject::annotation(), YODA::AnalysisObject::annotations(), YODA::DbnStorage< DbnN, AxisT >::mkHisto(), and YODA::AnalysisObject::path().

◆ mkInert()

template<size_t DbnN, typename... AxisT>
AnalysisObject * YODA::DbnStorage< DbnN, AxisT >::mkInert ( const std::string &  path = "",
const std::string &  source = "" 
) const
inlinevirtualnoexcept

Return an inert version of the analysis object (e.g. scatter, estimate)

Reimplemented from YODA::AnalysisObject.

Definition at line 1108 of file BinnedDbn.h.

1109 {
1110 return mkEstimate(path, source).newclone();
1111 }

References YODA::DbnStorage< DbnN, AxisT >::mkEstimate(), YODA::AnalysisObject::newclone(), and YODA::AnalysisObject::path().

◆ mkMarginalHisto()

template<size_t DbnN, typename... AxisT>
template<size_t axisN, typename = std::enable_if_t< (axisN < sizeof...(AxisT)) >>
auto YODA::DbnStorage< DbnN, AxisT >::mkMarginalHisto ( const std::string &  path = "") const
inline

Produce a BinnedHisto from a DbnStorage.

Case 1: BinnedProfile(N+1)D -> BinnedHistoND The binning dimension is reduced by one unit, and the fill dimension is reduced by two units.

Case 2: BinnedHisto(N+1)D -> BinnedHisto Both fill and binning dimension are reduced by one unit.

Todo:
use a parameter pack and allow marginalising over multiple axes?
Note
Binning iteratively shrinks, so the next bin slice to merge will always be the next.

Definition at line 975 of file BinnedDbn.h.

975 {
976
977 if constexpr (DbnN != sizeof...(AxisT)) {
978 // Case 1: BP(N+1) -> BH(N+1) -> BHN
979 return mkHisto().template mkMarginalHisto<axisN>(path);
980 }
981 else {
982 // Case 2: BH(N+1) -> BHN
983
984 auto rtn = BaseT::template _mkBinnedT<BinnedHisto>(BaseT::_binning.template _getAxesExcept<axisN>());
985 rtn.setNanLog(BaseT::nanCount(), BaseT::nanSumW(), BaseT::nanSumW2());
986 for (const std::string& a : annotations()) {
987 if (a != "Type") rtn.setAnnotation(a, annotation(a));
988 }
989 rtn.setAnnotation("Path", path);
990
991 auto collapseStorageBins =
992 [&oldBinning = BaseT::_binning, &oldBins = BaseT::_bins, &rtn](auto I, auto dbnRed) {
993
994 auto collapse = [&oldBins, &rtn](const auto& binsIndicesToMerge, auto axis) {
995 assert(rtn.numBins(true) == binsIndicesToMerge.size());
996
997 // for any given pivot, add the content
998 // from the old slice to the new slice
999 for (size_t i = 0; i < rtn.numBins(true); ++i) {
1000 auto& pivotBin = rtn.bin(i);
1001 auto& binToAppend = oldBins[binsIndicesToMerge[i]];
1002 pivotBin += binToAppend.template reduce<axis>();
1003 }
1004 };
1005
1006 // get bin slice for any given bin along the axis that is to be
1007 // collapsed, then copy the values into the new binning
1008 ssize_t nBinRowsToBeMerged = oldBinning.numBinsAt(I);
1009 while (nBinRowsToBeMerged--) {
1012 collapse(oldBinning.sliceIndices(I, nBinRowsToBeMerged), dbnRed);
1013 }
1014 };
1015 // collapse Dbn along axisN
1016 auto dbnRed = std::integral_constant<size_t, axisN>();
1017 (void)collapseStorageBins(std::integral_constant<std::size_t, axisN>(), dbnRed);
1018
1019 return rtn;
1020 }
1021 }

References YODA::AnalysisObject::annotation(), YODA::AnalysisObject::annotations(), YODA::DbnStorage< DbnN, AxisT >::mkHisto(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanCount(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanSumW(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanSumW2(), and YODA::AnalysisObject::path().

◆ mkMarginalProfile()

template<size_t DbnN, typename... AxisT>
template<size_t axisN, typename = std::enable_if_t< (axisN < sizeof...(AxisT)) >>
auto YODA::DbnStorage< DbnN, AxisT >::mkMarginalProfile ( const std::string &  path = "") const
inline

Produce a BinnedProfile from a DbnStorage.

Case 1: BinnedHisto(N+1)D -> BinnedProfileND The fill dimension remains the same, but the binning is reduced by one dimension.

Case 2: BinnedProfile(N+1)D -> BinnedProfileND Both fill and binning dimmensions are reduced by one unit.

Todo:
use a parameter pack and allow marginalising over multiple axes?
Note
Binning iteratively shrinks, so the next bin slice to merge will always be the next.

If the calling object is a histogram, we can just copy the Dbn<N>, otherwise we need to collapse an axis first in order to produce a Dbn<N-1>.

Note
Dbn axes are 0-indexed, so asking to reduce DbnN doesn't reduce anything.

Definition at line 921 of file BinnedDbn.h.

921 {
922
923 auto rtn = BaseT::template _mkBinnedT<BinnedProfile>(BaseT::_binning.template _getAxesExcept<axisN>());
924 rtn.setNanLog(BaseT::nanCount(), BaseT::nanSumW(), BaseT::nanSumW2());
925 for (const std::string& a : annotations()) {
926 if (a != "Type") rtn.setAnnotation(a, annotation(a));
927 }
928 rtn.setAnnotation("Path", path);
929
930 auto collapseStorageBins =
931 [&oldBinning = BaseT::_binning, &oldBins = BaseT::_bins, &rtn](auto I, auto dbnRed) {
932
933 auto collapse = [&oldBins, &rtn](const auto& binsIndicesToMerge, auto axis) {
934 assert(rtn.numBins(true) == binsIndicesToMerge.size());
935
936 // for any given pivot, add the content
937 // from the old slice to the new slice
938 for (size_t i = 0; i < rtn.numBins(true); ++i) {
939 auto& pivotBin = rtn.bin(i);
940 auto& binToAppend = oldBins[binsIndicesToMerge[i]];
941 pivotBin += binToAppend.template reduce<axis>();
942 }
943 };
944
945 // get bin slice for any given bin along the axis that is to be
946 // collapsed, then copy the values into the new binning
947 ssize_t nBinRowsToBeMerged = oldBinning.numBinsAt(I);
948 while (nBinRowsToBeMerged--) {
951 collapse(oldBinning.sliceIndices(I, nBinRowsToBeMerged), dbnRed);
952 }
953 };
957 auto dbnRed = std::integral_constant<size_t, (sizeof...(AxisT) == DbnN)? DbnN : axisN>();
958 (void)collapseStorageBins(std::integral_constant<std::size_t, axisN>(), dbnRed);
959
960 return rtn;
961 }

References YODA::AnalysisObject::annotation(), YODA::AnalysisObject::annotations(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanCount(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanSumW(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanSumW2(), and YODA::AnalysisObject::path().

◆ mkProfiles()

template<size_t DbnN, typename... AxisT>
template<size_t axisN, typename = std::enable_if_t< (axisN < sizeof...(AxisT) && sizeof...(AxisT)>=2 && DbnN > sizeof...(AxisT)) >>
auto YODA::DbnStorage< DbnN, AxisT >::mkProfiles ( const std::string &  path = "",
const bool  includeOverflows = false 
) const
inline

Split into vector of BinnedProfile along axis axisN.

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

Note
Requires at least two binning dimensions.

Definition at line 1031 of file BinnedDbn.h.

1031 {
1032
1033 // Need to provide a prescription for how to add the two bin contents
1034 auto how2add = [](auto& pivot, const BinType& toCopy) { pivot = toCopy.template reduce<axisN>(); };
1035 auto rtn = BaseT::template mkBinnedSlices<axisN, BinnedProfile>(how2add, includeOverflows);
1036 for (const std::string& a : annotations()) {
1037 if (a == "Type") continue;
1038 for (size_t i = 0; i < rtn.size(); ++i) {
1039 rtn[i].setAnnotation(a, annotation(a));
1040 }
1041 }
1042 for (size_t i = 0; i < rtn.size(); ++i) {
1043 rtn[i].setAnnotation("Path", path);
1044 }
1045 return rtn;
1046 }

References YODA::AnalysisObject::annotation(), YODA::AnalysisObject::annotations(), and YODA::AnalysisObject::path().

◆ mkScatter()

template<size_t DbnN, typename... AxisT>
auto YODA::DbnStorage< DbnN, AxisT >::mkScatter ( const std::string &  path = "",
const bool  divbyvol = true,
const bool  usefocus = false,
const bool  includeOverflows = false,
const bool  includeMaskedBins = false,
const double  overflowsWidth = -1.0 
) const
inline

Produce a ScatterND from a DbnStorage.

Note
The overflowsWidth argument will be applied to all bins outside the visible bin range.

Definition at line 862 of file BinnedDbn.h.

866 {
867 const BinnedEstimate<AxisT...> est = mkEstimate("", "", divbyvol, overflowsWidth);
868 ScatterND<sizeof...(AxisT)+1> rtn = est.mkScatter(path, "", includeOverflows, includeMaskedBins);
869 if (usefocus) {
870 size_t idx = 0;
871 for (const auto& b : BaseT::bins(includeOverflows, includeMaskedBins)) {
872 auto shiftIfContinuous = [&rtn, &b, &idx](auto I) {
873 using isContinuous = typename BinningT::template is_CAxis<I>;
874 if constexpr (isContinuous::value) {
875 const double oldMax = rtn.point(idx).max(I);
876 const double oldMin = rtn.point(idx).min(I);
877 const double newVal = b.mean(I+1);
878 rtn.point(idx).set(I, newVal, newVal - oldMin, oldMax - newVal);
879 }
880 };
881 MetaUtils::staticFor<BinningT::Dimension::value>(shiftIfContinuous);
882 ++idx;
883 }
884 }
885 return rtn;
886 }

References YODA::BinnedStorage< BinContentT, AxisT >::bins(), YODA::DbnStorage< DbnN, AxisT >::mkEstimate(), YODA::AnalysisObject::path(), and YODA::ScatterND< N >::point().

◆ newclone()

template<size_t DbnN, typename... AxisT>
DbnStorage * YODA::DbnStorage< DbnN, AxisT >::newclone ( ) const
inlinevirtualnoexcept

Make a copy on the heap.

Implements YODA::AnalysisObject.

Definition at line 220 of file BinnedDbn.h.

220 {
221 return new DbnStorage(*this);
222 }

References YODA::DbnStorage< DbnN, AxisT >::DbnStorage().

◆ normalize()

template<size_t DbnN, typename... AxisT>
void YODA::DbnStorage< DbnN, AxisT >::normalize ( const double  normto = 1.0,
const bool  includeOverflows = true 
)
inline

Normalize the (visible) histo "volume" to the normto value.

If includeoverflows is true, the original normalisation is computed with the overflow bins included, so that the resulting visible normalisation can be less than normto. This is probably what you want.

Definition at line 260 of file BinnedDbn.h.

260 {
261 const double oldintegral = integral(includeOverflows);
262 if (oldintegral == 0) throw WeightError("Attempted to normalize a histogram with null area");
263 scaleW(normto / oldintegral);
264 }
void scaleW(const double scalefactor) noexcept
Rescale as if all fill weights had been different by factor scalefactor.
Definition BinnedDbn.h:239

References YODA::DbnStorage< DbnN, AxisT >::integral(), and YODA::DbnStorage< DbnN, AxisT >::scaleW().

◆ numEntries()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::numEntries ( const bool  includeOverflows = true) const
inlinevirtualnoexcept

Get the number of fills (fractional fills are possible).

Implements YODA::Fillable.

Definition at line 511 of file BinnedDbn.h.

511 {
512 double n = 0;
513 for (const auto& b : BaseT::bins(includeOverflows))
514 n += b.numEntries();
515 return n;
516 }

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

Referenced by YODA::DbnStorage< DbnN, AxisT >::mkEstimate(), YODA::WriterYODA1::writeHisto1D(), YODA::WriterYODA1::writeHisto2D(), YODA::WriterYODA1::writeProfile1D(), and YODA::WriterYODA1::writeProfile2D().

◆ operator+=() [1/2]

template<size_t DbnN, typename... AxisT>
DbnStorage & YODA::DbnStorage< DbnN, AxisT >::operator+= ( const DbnStorage< DbnN, AxisT > &  dbn)
inline

Add two DbnStorages.

Note
Adding DbnStorages will unset any ScaledBy attribute from previous calls to scale or normalize.
Todo:
What happens if two storages disagree on masked bins?

Definition at line 354 of file BinnedDbn.h.

354 {
355 if (*this != dbn)
356 throw BinningError("Arithmetic operation requires compatible binning!");
357 if (AO::hasAnnotation("ScaledBy")) AO::rmAnnotation("ScaledBy");
358 for (size_t i = 0; i < BaseT::numBins(true, true); ++i) {
359 BaseT::bin(i) += dbn.bin(i);
360 }
361 BaseT::maskBins(dbn.maskedBins(), true);
362 return *this;
363 }
void rmAnnotation(const std::string &name)
Delete an annotation by name.
bool hasAnnotation(const std::string &name) const
Check if an annotation is defined.
void maskBins(const std::vector< size_t > &indicesToMask, const bool status=true) noexcept
Mask a range of bins.

References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::AnalysisObject::hasAnnotation(), YODA::BinnedStorage< BinContentT, AxisT >::maskBins(), YODA::BinnedStorage< BinContentT, AxisT >::maskedBins(), YODA::BinnedStorage< BinContentT, AxisT >::numBins(), and YODA::AnalysisObject::rmAnnotation().

◆ operator+=() [2/2]

template<size_t DbnN, typename... AxisT>
DbnStorage & YODA::DbnStorage< DbnN, AxisT >::operator+= ( DbnStorage< DbnN, AxisT > &&  dbn)
inline

Definition at line 365 of file BinnedDbn.h.

365 {
366 if (*this != dbn)
367 throw BinningError("Arithmetic operation requires compatible binning!");
368 if (AO::hasAnnotation("ScaledBy")) AO::rmAnnotation("ScaledBy");
369 for (size_t i = 0; i < BaseT::numBins(true, true); ++i) {
370 BaseT::bin(i) += std::move(dbn.bin(i));
371 }
372 BaseT::maskBins(dbn.maskedBins(), true);
373 return *this;
374 }

References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::AnalysisObject::hasAnnotation(), YODA::BinnedStorage< BinContentT, AxisT >::maskBins(), YODA::BinnedStorage< BinContentT, AxisT >::numBins(), and YODA::AnalysisObject::rmAnnotation().

◆ operator-=() [1/2]

template<size_t DbnN, typename... AxisT>
DbnStorage & YODA::DbnStorage< DbnN, AxisT >::operator-= ( const DbnStorage< DbnN, AxisT > &  dbn)
inline

Subtract one DbnStorages from another one.

Note
Subtracting DbnStorages will unset any ScaledBy attribute from previous calls to scale or normalize.

Definition at line 381 of file BinnedDbn.h.

381 {
382 if (*this != dbn)
383 throw BinningError("Arithmetic operation requires compatible binning!");
384 if (AO::hasAnnotation("ScaledBy")) AO::rmAnnotation("ScaledBy");
385 for (size_t i = 0; i < BaseT::numBins(true, true); ++i) {
386 BaseT::bin(i) -= dbn.bin(i);
387 }
388 BaseT::maskBins(dbn.maskedBins(), true);
389 return *this;
390 }

References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::AnalysisObject::hasAnnotation(), YODA::BinnedStorage< BinContentT, AxisT >::maskBins(), YODA::BinnedStorage< BinContentT, AxisT >::maskedBins(), YODA::BinnedStorage< BinContentT, AxisT >::numBins(), and YODA::AnalysisObject::rmAnnotation().

◆ operator-=() [2/2]

template<size_t DbnN, typename... AxisT>
DbnStorage & YODA::DbnStorage< DbnN, AxisT >::operator-= ( DbnStorage< DbnN, AxisT > &&  dbn)
inline

Definition at line 392 of file BinnedDbn.h.

392 {
393 if (*this != dbn)
394 throw BinningError("Arithmetic operation requires compatible binning!");
395 if (AO::hasAnnotation("ScaledBy")) AO::rmAnnotation("ScaledBy");
396 for (size_t i = 0; i < BaseT::numBins(true, true); ++i) {
397 BaseT::bin(i) -= std::move(dbn.bin(i));
398 }
399 BaseT::maskBins(dbn.maskedBins(), true);
400 return *this;
401 }

References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::AnalysisObject::hasAnnotation(), YODA::BinnedStorage< BinContentT, AxisT >::maskBins(), YODA::BinnedStorage< BinContentT, AxisT >::numBins(), and YODA::AnalysisObject::rmAnnotation().

◆ operator=() [1/2]

template<size_t DbnN, typename... AxisT>
DbnStorage & YODA::DbnStorage< DbnN, AxisT >::operator= ( const DbnStorage< DbnN, AxisT > &  dbn)
inlinenoexcept

Copy assignment.

Definition at line 330 of file BinnedDbn.h.

330 {
331 if (this != &dbn) {
334 }
335 return *this;
336 }
virtual AnalysisObject & operator=(const AnalysisObject &ao) noexcept
Default copy assignment operator.
FillableStorage & operator=(const FillableStorage &other) noexcept
Copy assignment.

References YODA::AnalysisObject::operator=(), and YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::operator=().

◆ operator=() [2/2]

template<size_t DbnN, typename... AxisT>
DbnStorage & YODA::DbnStorage< DbnN, AxisT >::operator= ( DbnStorage< DbnN, AxisT > &&  dbn)
inlinenoexcept

Move assignment.

Definition at line 339 of file BinnedDbn.h.

339 {
340 if (this != &dbn) {
342 BaseT::operator = (std::move(dbn));
343 }
344 return *this;
345 }

References YODA::AnalysisObject::operator=(), and YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::operator=().

◆ rebin() [1/2]

template<size_t DbnN, typename... AxisT>
template<size_t axisN>
void YODA::DbnStorage< DbnN, AxisT >::rebin ( const std::vector< typename BinningT::template getAxisT< axisN >::EdgeT > &  newedges)
inline

Overloaded alias for rebinTo.

Definition at line 325 of file BinnedDbn.h.

325 {
326 rebinTo<axisN>(newedges);
327 }

◆ rebin() [2/2]

template<size_t DbnN, typename... AxisT>
template<size_t axisN>
void YODA::DbnStorage< DbnN, AxisT >::rebin ( unsigned int  n,
size_t  begin = 1,
size_t  end = UINT_MAX 
)
inline

Overloaded alias for rebinBy.

Definition at line 292 of file BinnedDbn.h.

292 {
293 rebinBy<axisN>(n, begin, end);
294 }

◆ rebinBy()

template<size_t DbnN, typename... AxisT>
template<size_t axisN>
void YODA::DbnStorage< DbnN, AxisT >::rebinBy ( unsigned int  n,
size_t  begin = 1,
size_t  end = UINT_MAX 
)
inline

Merge every group of n bins, from start to end inclusive.

If the number of bins is not a multiple of n, the last m < n bins on the RHS will also be merged, as the closest possible approach to factor
rebinning everywhere.

Note
Only visible bins are being rebinned. Underflow (index = 0) and overflow (index = numBins() + 1) are not included.

Definition at line 276 of file BinnedDbn.h.

276 {
277 if (n < 1) throw UserError("Rebinning requested in groups of 0!");
278 if (!begin) throw UserError("Visible bins start with index 1!");
279 if (end > BaseT::numBinsAt(axisN)+1) end = BaseT::numBinsAt(axisN) + 1;
280 for (size_t m = begin; m < end; ++m) {
281 if (m > BaseT::numBinsAt(axisN)+1) break; // nothing to be done
282 const size_t myend = (m+n-1 < BaseT::numBinsAt(axisN)+1) ? m+n-1 : BaseT::numBinsAt(axisN);
283 if (myend > m) {
284 BaseT::template mergeBins<axisN>({m, myend});
285 end -= myend-m; //< reduce upper index by the number of removed bins
286 }
287 }
288 }
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().

◆ rebinTo()

template<size_t DbnN, typename... AxisT>
template<size_t axisN>
void YODA::DbnStorage< DbnN, AxisT >::rebinTo ( const std::vector< typename BinningT::template getAxisT< axisN >::EdgeT > &  newedges)
inline

Rebin to the given list of bin edges.

Definition at line 298 of file BinnedDbn.h.

298 {
299 if (newedges.size() < 2)
300 throw UserError("Requested rebinning to an edge list which defines no bins");
301 using thisAxisT = typename BinningT::template getAxisT<axisN>;
302 using thisEdgeT = typename thisAxisT::EdgeT;
303 // get list of shared edges
304 thisAxisT& oldAxis = BaseT::_binning.template axis<axisN>();
305 const thisAxisT newAxis(newedges);
306 const std::vector<thisEdgeT> eshared = oldAxis.sharedEdges(newAxis);
307 if (eshared.size() != newAxis.edges().size())
308 throw BinningError("Requested rebinning to incompatible edges");
309 // loop over new lower bin edges (= first bin index of merge range)
310 for (size_t begin = 0; begin < eshared.size() - 1; ++begin) {
311 // find index of upper edge along old axis
312 // (subtracting 1 gives index of last bin to be merged)
313 size_t end = oldAxis.index(eshared[begin+1]) - 1;
314 // if the current edge is the last visible edge before the overflow
315 // merge the remaining bins into the overflow
316 if (begin == newAxis.numBins(true)-1) end = oldAxis.numBins(true)-1;
317 // merge this range
318 if (end > begin) BaseT::template mergeBins<axisN>({begin, end});
319 if (eshared.size() == oldAxis.edges().size()) break; // we're done
320 }
321 }

◆ reset()

template<size_t DbnN, typename... AxisT>
void YODA::DbnStorage< DbnN, AxisT >::reset ( )
inlinevirtualnoexcept

Reset the histogram.

Keep the binning but set all bin contents and related quantities to zero

Implements YODA::AnalysisObject.

Definition at line 411 of file BinnedDbn.h.

411{ BaseT::reset(); }

References YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::reset().

◆ rms()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::rms ( size_t  axisN,
const bool  includeOverflows = true 
) const
inlinenoexcept

Calculates the RMS at axis.

Definition at line 601 of file BinnedDbn.h.

601 {
602 Dbn<DbnN> dbn;
603 for (const auto& b : BaseT::bins(includeOverflows))
604 dbn += b;
605 return dbn.RMS(axisN+1);
606 }

References YODA::BinnedStorage< BinContentT, AxisT >::bins(), and YODA::DbnBase< N >::RMS().

◆ scale()

template<size_t DbnN, typename... AxisT>
void YODA::DbnStorage< DbnN, AxisT >::scale ( const size_t  i,
const double  scalefactor 
)
inlinenoexcept

Rescale as if all fill weights had been different by factor scalefactor along dimension i.

Definition at line 247 of file BinnedDbn.h.

247 {
248 setAnnotation("ScaledBy", annotation<double>("ScaledBy", 1.0) * scalefactor);
249 for (auto& bin : BaseT::_bins) {
250 bin.scale(i, scalefactor);
251 }
252 }
void setAnnotation(const std::string &name, const T &value)
Add or set an annotation by name (templated for remaining types)

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

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

◆ scaleW()

template<size_t DbnN, typename... AxisT>
void YODA::DbnStorage< DbnN, AxisT >::scaleW ( const double  scalefactor)
inlinevirtualnoexcept

Rescale as if all fill weights had been different by factor scalefactor.

Implements YODA::Fillable.

Definition at line 239 of file BinnedDbn.h.

239 {
240 setAnnotation("ScaledBy", annotation<double>("ScaledBy", 1.0) * scalefactor);
241 for (auto& bin : BaseT::_bins) {
242 bin.scaleW(scalefactor);
243 }
244 }

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

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

◆ serializeContent()

template<size_t DbnN, typename... AxisT>
std::vector< double > YODA::DbnStorage< DbnN, AxisT >::serializeContent ( bool  fixed_length = false) const
inlinevirtualnoexcept

Content serialisation for MPI reduce operations.

Implements YODA::AnalysisObject.

Definition at line 759 of file BinnedDbn.h.

759 {
760 std::vector<double> rtn;
761 const size_t nBins = BaseT::numBins(true, true);
762 rtn.reserve(nBins * Dbn<DbnN>::DataSize::value);
763 for (size_t i = 0; i < nBins; ++i) {
764 std::vector<double> bdata = BaseT::bin(i)._serializeContent();
765 rtn.insert(std::end(rtn),
766 std::make_move_iterator(std::begin(bdata)),
767 std::make_move_iterator(std::end(bdata)));
768 }
769 return rtn;
770 }

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

◆ stdDev()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::stdDev ( size_t  axisN,
const bool  includeOverflows = true 
) const
inlinenoexcept

Calculates the standard deviation at axis.

Definition at line 588 of file BinnedDbn.h.

588 {
589 return std::sqrt(variance(axisN, includeOverflows));
590 }
double variance(size_t axisN, const bool includeOverflows=true) const noexcept
Calculates the variance at axis.
Definition BinnedDbn.h:580

References YODA::DbnStorage< DbnN, AxisT >::variance().

◆ stdErr()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::stdErr ( size_t  axisN,
const bool  includeOverflows = true 
) const
inlinenoexcept

Calculates the standard error at axis.

Definition at line 593 of file BinnedDbn.h.

593 {
594 Dbn<DbnN> dbn;
595 for (const auto& b : BaseT::bins(includeOverflows))
596 dbn += b;
597 return dbn.stdErr(axisN+1);
598 }

References YODA::BinnedStorage< BinContentT, AxisT >::bins(), and YODA::DbnBase< N >::stdErr().

◆ sumW()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::sumW ( const bool  includeOverflows = true) const
inlinevirtualnoexcept

Calculates sum of weights in histo.

Implements YODA::Fillable.

Definition at line 527 of file BinnedDbn.h.

527 {
528 double sumw = 0;
529 for (const auto& b : BaseT::bins(includeOverflows))
530 sumw += b.sumW();
531 return sumw;
532 }

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

Referenced by YODA::DbnStorage< DbnN, AxisT >::integral(), YODA::WriterYODA1::writeHisto1D(), YODA::WriterYODA1::writeHisto2D(), YODA::WriterYODA1::writeProfile1D(), and YODA::WriterYODA1::writeProfile2D().

◆ sumW2()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::sumW2 ( const bool  includeOverflows = true) const
inlinevirtualnoexcept

Calculates sum of squared weights in histo.

Implements YODA::Fillable.

Definition at line 535 of file BinnedDbn.h.

535 {
536 double sumw2 = 0;
537 for (const auto& b : BaseT::bins(includeOverflows))
538 sumw2 += b.sumW2();
539 return sumw2;
540 }

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

Referenced by YODA::DbnStorage< DbnN, AxisT >::integralError(), YODA::WriterYODA1::writeHisto1D(), YODA::WriterYODA1::writeHisto2D(), YODA::WriterYODA1::writeProfile1D(), and YODA::WriterYODA1::writeProfile2D().

◆ sumWA()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::sumWA ( const size_t  dim,
const bool  includeOverflows = true 
) const
inline

Calculates first moment along axis dim in histo.

Definition at line 543 of file BinnedDbn.h.

543 {
544 if (dim >= DbnN) throw RangeError("Invalid axis int, must be in range 0..dim-1");
545 double sumwa = 0;
546 for (const auto& b : BaseT::bins(includeOverflows))
547 sumwa += b.sumW(dim+1);
548 return sumwa;
549 }
size_t dim() const noexcept
Total dimension of the object (number of axes + filled value)
Definition BinnedDbn.h:422

References YODA::BinnedStorage< BinContentT, AxisT >::bins(), and YODA::DbnStorage< DbnN, AxisT >::dim().

Referenced by YODA::WriterYODA1::writeHisto1D(), YODA::WriterYODA1::writeHisto2D(), YODA::WriterYODA1::writeProfile1D(), and YODA::WriterYODA1::writeProfile2D().

◆ sumWA2()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::sumWA2 ( const size_t  dim,
const bool  includeOverflows = true 
) const
inline

Calculates second moment along axis dim in histo.

Definition at line 552 of file BinnedDbn.h.

552 {
553 if (dim >= DbnN) throw RangeError("Invalid axis int, must be in range 0..dim-1");
554 double sumwa2 = 0;
555 for (const auto& b : BaseT::bins(includeOverflows))
556 sumwa2 += b.sumW2(dim+1);
557 return sumwa2;
558 }

References YODA::BinnedStorage< BinContentT, AxisT >::bins(), and YODA::DbnStorage< DbnN, AxisT >::dim().

Referenced by YODA::WriterYODA1::writeHisto1D(), YODA::WriterYODA1::writeHisto2D(), YODA::WriterYODA1::writeProfile1D(), and YODA::WriterYODA1::writeProfile2D().

◆ variance()

template<size_t DbnN, typename... AxisT>
double YODA::DbnStorage< DbnN, AxisT >::variance ( size_t  axisN,
const bool  includeOverflows = true 
) const
inlinenoexcept

Calculates the variance at axis.

Definition at line 580 of file BinnedDbn.h.

580 {
581 Dbn<DbnN> dbn;
582 for (const auto& b : BaseT::bins(includeOverflows))
583 dbn += b;
584 return dbn.variance(axisN+1);
585 }

References YODA::BinnedStorage< BinContentT, AxisT >::bins(), and YODA::DbnBase< N >::variance().

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

◆ widths()

template<size_t DbnN, typename... AxisT>
template<size_t I, typename E = typename BinningT::template getEdgeT<I>>
std::enable_if_t< std::is_floating_point< E >::value, std::vector< E > > YODA::DbnStorage< DbnN, AxisT >::widths ( const bool  includeOverflows = false) const
inlinenoexcept

Templated version to get bin widths of axis N by reference.

Overflows are included depending on includeOverflows Needed by axis-specific version from AxisMixin

Note
This version is only supported for continuous axes.

Definition at line 441 of file BinnedDbn.h.

441 {
442 return BaseT::_binning.template widths<I>(includeOverflows);
443 }

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