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

EstimateStorage convenience class based on BinnedStorage. More...

#include <BinnedEstimate.h>

Inheritance diagram for YODA::EstimateStorage< AxisT >:
YODA::BinnedStorage< Estimate, AxisT... > YODA::AnalysisObject YODA::BinnedEstimate< AxisT >

Public Types

using BinType = BinT
 
- Public Types inherited from YODA::BinnedStorage< Estimate, 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
 EstimateStorage (const std::string &path="", const std::string &title="")
 Nullary constructor for unique pointers etc.
 
 EstimateStorage (std::vector< AxisT > &&... binsEdges, const std::string &path="", const std::string &title="")
 Constructor giving explicit bin edges as rvalue reference.
 
 EstimateStorage (const std::vector< AxisT > &... binsEdges, const std::string &path="", const std::string &title="")
 Constructor giving explicit bin edges as lvalue reference.
 
 EstimateStorage (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...>>
 EstimateStorage (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.
 
 EstimateStorage (const BinningT &binning, const std::string &path="", const std::string &title="")
 Constructor given a binning type.
 
 EstimateStorage (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...>>
 EstimateStorage (const ScatterND< sizeof...(AxisT)+1 > &s, const std::string &path="", const std::string &title="")
 Constructor given a scatter.
 
 EstimateStorage (const EstimateStorage &other, const std::string &path="")
 Copy constructor.
 
 EstimateStorage (EstimateStorage &&other, const std::string &path="")
 Move constructor.
 
EstimateStorage clone () const noexcept
 Make a copy on the stack.
 
EstimateStoragenewclone () const noexcept
 Make a copy on the heap.
 
Transformations
void scale (const double scalefactor) noexcept
 Rescale as if all fill weights had been different by factor scalefactor.
 
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.
 
void reset () noexcept
 Reset the EstimateStorage.
 
EstimateStorageoperator= (const EstimateStorage &est) noexcept
 Copy assignment.
 
EstimateStorageoperator= (EstimateStorage &&est) noexcept
 Move assignment.
 
EstimateStorageadd (const EstimateStorage &est, const std::string &pat_uncorr="^stat|^uncor")
 Add two EstimateStorages.
 
EstimateStorageoperator+= (const EstimateStorage &est)
 
EstimateStorageadd (EstimateStorage &&est, const std::string &pat_uncorr="^stat|^uncor")
 Add two (rvalue) EstimateStorages.
 
EstimateStorageoperator+= (EstimateStorage &&est)
 
EstimateStoragesubtract (const EstimateStorage &est, const std::string &pat_uncorr="^stat|^uncor")
 Subtract one EstimateStorages from another one.
 
EstimateStorageoperator-= (const EstimateStorage &est)
 
EstimateStoragesubtract (EstimateStorage &&est, const std::string &pat_uncorr="^stat|^uncor")
 Subtract one (rvalue) EstimateStorages from another one.
 
EstimateStorageoperator-= (EstimateStorage &&est)
 
Binning info.
size_t dim () const noexcept
 Total dimension of the object (number of axes + estimate)
 
template<size_t I, typename E = typename BinningT::template getEdgeT<I>>
std::vector< E > edges (const bool includeOverflows=false) const noexcept
 Templated version to get edges of axis N by value. +-inf edges are included.
 
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 value.
 
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 EstimateStorage data
std::vector< double > vals (const bool includeOverflows=false, const bool includeMaskedBins=false) const
 Get list of central values.
 
std::vector< std::string > sources () const
 Get list of error sources.
 
double areaUnderCurve (const bool includeBinVol=true, const bool includeOverflows=false, const bool includeMaskedBins=false) const
 Calculate the volume underneath the EstimateStorage.
 
double auc (const bool includeBinVol=true, const bool includeOverflows=false, const bool includeMaskedBins=false) const
 Convenient alias for areaUnderCurve()
 
std::vector< std::vector< double > > covarianceMatrix (const bool ignoreOffDiagonalTerms=false, const bool includeOverflows=false, const bool includeMaskedBins=false, const std::string &pat_uncorr="^stat|^uncor") const
 Construct a covariance matrix from the error breakdown.
 
Type reductions
auto mkScatter (const std::string &path="", const std::string &pat_match="", const bool includeOverflows=false, const bool includeMaskedBins=false) const
 Produce a ScatterND from a EstimateStorage.
 
template<size_t axisN, typename = std::enable_if_t< (axisN < sizeof...(AxisT) && sizeof...(AxisT)>=2) >>
auto mkEstimates (const std::string &path="", const bool includeOverflows=false) const
 Split into vector of BinnedEstimates along axisN.
 
AnalysisObjectmkInert (const std::string &path="", const std::string &source="") const noexcept
 Method returns clone of the estimate with streamlined error source.
 
MPI (de-)serialisation
size_t lengthContent (bool fixed_length=false) const noexcept
 Length of serialized content vector for MPI reduce operations.
 
std::vector< double > serializeContent (bool fixed_length=false) const noexcept
 Content serialisation for MPI reduce operations.
 
void deserializeContent (const std::vector< double > &data)
 Content deserialisation for MPI reduce operations.
 
- Public Member Functions inherited from YODA::BinnedStorage< Estimate, 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, Estimate &&content) noexcept
 Sets the bin corresponding to coords with an rvalue content.
 
void set (typename BinningT::EdgeTypesTuple &&coords, const Estimate &content) noexcept
 Sets the bin corresponding to coords with content.
 
void set (const size_t binIdx, Estimate &&content) noexcept
 Sets the bin corresponding to binIndex with an rvalue content.
 
void set (const size_t binIdx, const Estimate &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
 
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, Estimate >, RetT >
 Merge bins from A to B at G axis.
 
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
 Mate-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.
 

Protected Types

using BaseT = BinnedStorage< Estimate, AxisT... >
 
using BinningT = typename BaseT::BinningT
 
using BinT = typename BaseT::BinT
 
- Protected Types inherited from YODA::BinnedStorage< Estimate, AxisT... >
using BinningT = Binning< std::decay_t< decltype(std::declval< Axis< AxisT > >())>... >
 Convenience alias to be used in constructor.
 
using BinT = Bin< sizeof...(AxisT), Estimate, BinningT >
 
using BinsVecT = std::vector< BinT >
 
using BaseT = BinnedStorage< Estimate, AxisT... >
 

Additional Inherited Members

- Protected Member Functions inherited from YODA::BinnedStorage< Estimate, AxisT... >
void fillBins () noexcept
 Fills bins with wrapped BinContent objects.
 
void fillBins (const BinsVecT &bins) noexcept
 
void fillBins (BinsVecT &&bins) noexcept
 

Detailed Description

template<typename... AxisT>
class YODA::EstimateStorage< AxisT >

EstimateStorage convenience class based on BinnedStorage.

Note
We use this abstraction layer to implement the bulk once and only once. The user-facing BinnedEstimate type will inherit all its methods from this base class along with a few axis-specifc mixins.

Definition at line 75 of file BinnedEstimate.h.

Member Typedef Documentation

◆ BaseT

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

Definition at line 80 of file BinnedEstimate.h.

◆ BinningT

template<typename... AxisT>
using YODA::EstimateStorage< AxisT >::BinningT = typename BaseT::BinningT
protected

Definition at line 81 of file BinnedEstimate.h.

◆ BinT

template<typename... AxisT>
using YODA::EstimateStorage< AxisT >::BinT = typename BaseT::BinT
protected

Definition at line 82 of file BinnedEstimate.h.

◆ BinType

template<typename... AxisT>
using YODA::EstimateStorage< AxisT >::BinType = BinT

Definition at line 86 of file BinnedEstimate.h.

Constructor & Destructor Documentation

◆ EstimateStorage() [1/10]

template<typename... AxisT>
YODA::EstimateStorage< AxisT >::EstimateStorage ( const std::string &  path = "",
const std::string &  title = "" 
)
inline

Nullary constructor for unique pointers etc.

Definition at line 93 of file BinnedEstimate.h.

94 : BaseT(), AnalysisObject(mkTypeString<AxisT...>(), path, title) { }
const std::string title() const
Get the AO title.
const std::string path() const
Get the AO path.
AnalysisObject()
Default constructor.
BinnedStorage< Estimate, AxisT... > BaseT

◆ EstimateStorage() [2/10]

template<typename... AxisT>
YODA::EstimateStorage< AxisT >::EstimateStorage ( 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 bins.size()+1 edges, the last one being the upper bound of the last bin.

Definition at line 101 of file BinnedEstimate.h.

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

◆ EstimateStorage() [3/10]

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

Constructor giving explicit bin edges as lvalue 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 109 of file BinnedEstimate.h.

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

◆ EstimateStorage() [4/10]

template<typename... AxisT>
YODA::EstimateStorage< AxisT >::EstimateStorage ( 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 bins.size()+1 edges, the last one being the upper bound of the last bin.

Definition at line 117 of file BinnedEstimate.h.

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

◆ EstimateStorage() [5/10]

template<typename... AxisT>
template<typename EdgeT = double, typename = enable_if_all_CAxisT<EdgeT, AxisT...>>
YODA::EstimateStorage< AxisT >::EstimateStorage ( 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.

Definition at line 122 of file BinnedEstimate.h.

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

◆ EstimateStorage() [6/10]

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

Constructor given a binning type.

Definition at line 130 of file BinnedEstimate.h.

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

◆ EstimateStorage() [7/10]

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

Constructor given an rvalue BinningT.

Definition at line 134 of file BinnedEstimate.h.

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

◆ EstimateStorage() [8/10]

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

Constructor given a scatter.

Definition at line 139 of file BinnedEstimate.h.

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

◆ EstimateStorage() [9/10]

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

Copy constructor.

Todo:
Also allow title setting from the constructor?

Definition at line 146 of file BinnedEstimate.h.

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

◆ EstimateStorage() [10/10]

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

Move constructor.

Todo:
Also allow title setting from the constructor?

Definition at line 152 of file BinnedEstimate.h.

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

Member Function Documentation

◆ add() [1/2]

template<typename... AxisT>
EstimateStorage & YODA::EstimateStorage< AxisT >::add ( const EstimateStorage< AxisT > &  est,
const std::string &  pat_uncorr = "^stat|^uncor" 
)
inline

Add two EstimateStorages.

Note
Adding EstimateStorages will unset any ScaledBy attribute from previous calls to scale or normalize.

Definition at line 346 of file BinnedEstimate.h.

347 {
348 if (*this != est)
349 throw BinningError("Arithmetic operation requires compatible binning!");
350 if (AO::hasAnnotation("ScaledBy")) AO::rmAnnotation("ScaledBy");
351 for (size_t i = 0; i< BaseT::numBins(true, true); ++i) {
352 BaseT::bin(i).add(est.bin(i), pat_uncorr);
353 }
354 BaseT::maskBins(est.maskedBins(), true);
355 return *this;
356 }
void rmAnnotation(const std::string &name)
Delete an annotation by name.
bool hasAnnotation(const std::string &name) const
Check if an annotation is defined.
BinT & bin(size_t idx) noexcept
Returns reference to the bin at idx.
void maskBins(const std::vector< size_t > &indicesToMask, const bool status=true) noexcept
Mask a range of bins.
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(), YODA::BinnedStorage< Estimate, AxisT... >::bin(), YODA::AnalysisObject::hasAnnotation(), YODA::BinnedStorage< Estimate, AxisT... >::maskBins(), YODA::BinnedStorage< BinContentT, AxisT >::maskedBins(), YODA::BinnedStorage< Estimate, AxisT... >::numBins(), and YODA::AnalysisObject::rmAnnotation().

Referenced by YODA::EstimateStorage< AxisT >::operator+=(), and YODA::EstimateStorage< AxisT >::operator+=().

◆ add() [2/2]

template<typename... AxisT>
EstimateStorage & YODA::EstimateStorage< AxisT >::add ( EstimateStorage< AxisT > &&  est,
const std::string &  pat_uncorr = "^stat|^uncor" 
)
inline

Add two (rvalue) EstimateStorages.

Note
Adding EstimateStorages will unset any ScaledBy attribute from previous calls to scale or normalize.

Definition at line 366 of file BinnedEstimate.h.

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

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

◆ areaUnderCurve()

template<typename... AxisT>
double YODA::EstimateStorage< AxisT >::areaUnderCurve ( const bool  includeBinVol = true,
const bool  includeOverflows = false,
const bool  includeMaskedBins = false 
) const
inline

Calculate the volume underneath the EstimateStorage.

Note
overflow bins have infinite bin width

Definition at line 507 of file BinnedEstimate.h.

509 {
510 double ret = 0.;
511 for (const auto& b : BaseT::bins(includeOverflows, includeMaskedBins)) {
512 const double val = fabs(b.val());
513 const double vol = includeBinVol? b.dVol() : 1.0;
514 if (std::isfinite(vol)) ret += val*vol; // aggregate bin volume
515 }
516 return ret;
517 }
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< Estimate, AxisT... >::bins().

Referenced by YODA::EstimateStorage< AxisT >::auc().

◆ auc()

template<typename... AxisT>
double YODA::EstimateStorage< AxisT >::auc ( const bool  includeBinVol = true,
const bool  includeOverflows = false,
const bool  includeMaskedBins = false 
) const
inline

Convenient alias for areaUnderCurve()

Definition at line 520 of file BinnedEstimate.h.

522 {
523 return areaUnderCurve(includeBinVol, includeOverflows, includeMaskedBins);
524 }
double areaUnderCurve(const bool includeBinVol=true, const bool includeOverflows=false, const bool includeMaskedBins=false) const
Calculate the volume underneath the EstimateStorage.

References YODA::EstimateStorage< AxisT >::areaUnderCurve().

◆ clone()

template<typename... AxisT>
EstimateStorage YODA::EstimateStorage< AxisT >::clone ( ) const
inlinenoexcept

Make a copy on the stack.

Definition at line 156 of file BinnedEstimate.h.

156 {
157 return EstimateStorage(*this);
158 }
EstimateStorage(const std::string &path="", const std::string &title="")
Nullary constructor for unique pointers etc.

◆ covarianceMatrix()

template<typename... AxisT>
std::vector< std::vector< double > > YODA::EstimateStorage< AxisT >::covarianceMatrix ( const bool  ignoreOffDiagonalTerms = false,
const bool  includeOverflows = false,
const bool  includeMaskedBins = false,
const std::string &  pat_uncorr = "^stat|^uncor" 
) const
inline

Construct a covariance matrix from the error breakdown.

Definition at line 529 of file BinnedEstimate.h.

532 {
533 const size_t nBins = BaseT::numBins(includeOverflows,includeMaskedBins);
534 std::vector<std::vector<double> > covM(nBins);
535
536 // initialise cov matrix to be the right shape
537 for (size_t i = 0; i < nBins; ++i) {
538 covM[i] = std::vector<double>(nBins, 0.0);
539 }
540
541 const std::vector<std::string> error_sources = sources();
542
543 // nominal-only case, i.e. total uncertainty, labelled as empty string
544 if (error_sources.size() == 1 && error_sources[0] == "") {
545 size_t i = 0;
546 for (const auto& b : BaseT::bins(includeOverflows,includeMaskedBins)) {
547 covM[i][i] = b.hasSource("")? sqr(0.5*(b.err("").first+b.err("").second)) : 1.0;
548 ++i;
549 }
550 return covM;
551 }
552
553 // more interesting case where we actually have some uncertainty breakdown!
554 std::smatch match;
555 const std::regex re(pat_uncorr, std::regex_constants::icase);
556 for (const std::string& sname : error_sources) {
557 if (sname == "") continue;
558 std::vector<double> systErrs(nBins, 0.0);
559 size_t k = 0;
560 for (const auto& b : BaseT::bins(includeOverflows,includeMaskedBins)) {
561 if (b.hasSource(sname)) {
562 const auto& errs = b.err(sname); // dn-up pair
563 systErrs[k] = 0.5 *( fabs(errs.first)+fabs(errs.second));
564 }
565 ++k;
566 }
567 const bool skipOffDiag = (ignoreOffDiagonalTerms
568 || std::regex_search(sname, match, re));
569 for (size_t i = 0; i < nBins; ++i) {
570 for (size_t j = 0; j < nBins; ++j) {
571 if (skipOffDiag && i != j) continue;
572 covM[i][j] += systErrs[i]*systErrs[j];
573 }
574 }
575 }
576
577 return covM;
578 }
std::vector< std::string > sources() const
Get list of error sources.
NUM sqr(NUM a)
Named number-type squaring operation.
Definition MathUtils.h:216

References YODA::BinnedStorage< Estimate, AxisT... >::bins(), YODA::BinnedStorage< Estimate, AxisT... >::numBins(), YODA::EstimateStorage< AxisT >::sources(), and YODA::sqr().

◆ deserializeContent()

template<typename... AxisT>
void YODA::EstimateStorage< AxisT >::deserializeContent ( const std::vector< double > &  data)
inlinevirtual

Content deserialisation for MPI reduce operations.

Implements YODA::AnalysisObject.

Definition at line 714 of file BinnedEstimate.h.

714 {
715
716 const size_t nBins = BaseT::numBins(true, true);
717 const size_t minLen = 2*nBins;
718 if (data.size() < minLen)
719 throw UserError("Length of serialized data should be at least " + std::to_string(minLen)+"!");
720
721 size_t i = 0;
722 auto itr = data.cbegin();
723 const auto itrEnd = data.cend();
724 const bool fixedLen = data.size() == 2*minLen;
725 while (itr != itrEnd) {
726 // for estimates, the first element represents the central,
727 // the subsequent value represents the number of error pairs
728 const size_t nErrs = fixedLen? 1 : (*(itr + 1) + 0.5); // add 0.5 to avoid rounding issues
729 auto last = itr + 2*(nErrs+1); // last element + 1
730 BaseT::bin(i)._deserializeContent(std::vector<double>{itr, last}, fixedLen);
731 // update for next iteration
732 itr = last;
733 ++i;
734 }
735 }

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

◆ dim()

template<typename... AxisT>
size_t YODA::EstimateStorage< AxisT >::dim ( ) const
inlinevirtualnoexcept

Total dimension of the object (number of axes + estimate)

Implements YODA::AnalysisObject.

Definition at line 427 of file BinnedEstimate.h.

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

◆ edges()

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

Templated version to get edges of axis N by value. +-inf edges are included.

Note
Needed by axis-specific verison from AxisMixin

Definition at line 437 of file BinnedEstimate.h.

437 {
438 return BaseT::_binning.template edges<I>(includeOverflows);
439 }

◆ lengthContent()

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

Length of serialized content vector for MPI reduce operations.

Implements YODA::AnalysisObject.

Definition at line 691 of file BinnedEstimate.h.

691 {
692 size_t rtn = 0;
693 for (const auto& bin : BaseT::bins(true, true)) {
694 rtn += bin._lengthContent(fixed_length);
695 }
696 return rtn;
697 }

References YODA::BinnedStorage< Estimate, AxisT... >::bin(), and YODA::BinnedStorage< Estimate, AxisT... >::bins().

◆ max()

template<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::EstimateStorage< 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 465 of file BinnedEstimate.h.

465 {
466 return BaseT::_binning.template max<I>();
467 }

◆ min()

template<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::EstimateStorage< 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 457 of file BinnedEstimate.h.

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

◆ mkEstimates()

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

Split into vector of BinnedEstimates along axisN.

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

Note
Requires at least two binning dimensions.

Definition at line 651 of file BinnedEstimate.h.

651 {
652
653 // Need to provide a prescription for how to add the two bin contents
654 auto how2add = [](auto& pivot, const BinType& toCopy) { pivot = toCopy; };
655 auto rtn = BaseT::template mkBinnedSlices<axisN, BinnedEstimate>(how2add, includeOverflows);
656 for (const std::string& a : annotations()) {
657 if (a == "Type") continue;
658 for (size_t i = 0; i < rtn.size(); ++i) {
659 rtn[i].setAnnotation(a, annotation(a));
660 }
661 }
662 for (size_t i = 0; i < rtn.size(); ++i) {
663 rtn[i].setAnnotation("Path", path);
664 }
665
666 return rtn;
667 }
std::vector< std::string > annotations() const
const std::string & annotation(const std::string &name) const
Get an annotation by name (as a string)

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

◆ mkInert()

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

Method returns clone of the estimate with streamlined error source.

Reimplemented from YODA::AnalysisObject.

Definition at line 671 of file BinnedEstimate.h.

672 {
673 EstimateStorage* rtn = newclone();
674 rtn->setPath(path);
675 for (auto& b : rtn->bins(true, true)) {
676 if (b.numErrs() == 1) {
677 try {
678 b.renameSource("", source);
679 }
680 catch (YODA::UserError& e) { }
681 }
682 }
683 return rtn;
684 }
EstimateStorage * newclone() const noexcept
Make a copy on the heap.
Error for problems introduced outside YODA, to put it nicely.
Definition Exceptions.h:100

References YODA::BinnedStorage< BinContentT, AxisT >::bins(), YODA::EstimateStorage< AxisT >::newclone(), YODA::AnalysisObject::path(), and YODA::AnalysisObject::setPath().

◆ mkScatter()

template<typename... AxisT>
auto YODA::EstimateStorage< AxisT >::mkScatter ( const std::string &  path = "",
const std::string &  pat_match = "",
const bool  includeOverflows = false,
const bool  includeMaskedBins = false 
) const
inline

Produce a ScatterND from a EstimateStorage.

Definition at line 586 of file BinnedEstimate.h.

588 {
589
590 constexpr size_t N = sizeof...(AxisT);
591
592 ScatterND<N+1> rtn;
593 for (const std::string& a : annotations()) {
594 if (a != "Type") rtn.setAnnotation(a, annotation(a));
595 }
596 rtn.setAnnotation("Path", path);
597
598 const bool incOF = all_CAxes<AxisT...>::value && includeOverflows;
599 for (const auto& b : BaseT::bins(incOF, includeMaskedBins)) {
600
601 // Create the vector of coordinates
602 Utils::ndarray<double, N+1> vals;
603 // first fill bin centres, use bin index if axis non-arithmetic
604 auto indexIfDiscrete = [&vals, &b](auto I) {
605 using isContinuous = typename BinningT::template is_CAxis<I>;
606 using isArithmetic = typename BinningT::template is_Arithmetic<I>;
607 vals[I] = coordPicker<I>(b, std::integral_constant<bool, isArithmetic::value>{},
608 std::integral_constant<bool, isContinuous::value>{});
609 };
610 MetaUtils::staticFor<BinningT::Dimension::value>(indexIfDiscrete);
611 // then fill bin content
612 vals[N] = b.val();
613
614 // Create the vector of error pairs, use 0 if axis not continuous
615 Utils::ndarray<std::pair<double,double>, N+1> errs;
616 auto nullifyDiscrete = [&errs, &vals, &b](auto I) {
617 using isContinuous = typename BinningT::template is_CAxis<I>;
618 errs[I] = nullifyIfDisc<I>(b, vals[I], std::integral_constant<bool, isContinuous::value>{});
619 };
620 MetaUtils::staticFor<BinningT::Dimension::value>(nullifyDiscrete);
621 const double tot = fabs(b.totalErrPos(pat_match)); // use positive error component
622 errs[N] = { tot, tot };
623
624 // Add the PointND
625 rtn.addPoint( PointND<N+1>(vals, errs) );
626 }
627
628 // Decorate output scatter with the discrete edges
629 const BinningT& binning = BaseT::_binning;
630 auto decorateEdges = [&rtn, &binning](auto I) {
631 using isContinuous = typename BinningT::template is_CAxis<I>;
632 if constexpr( !isContinuous::value ) {
633 const auto& axis = binning.template axis<I>();
634 if (axis.numBins()) {
635 std::stringstream ss;
636 axis._renderYODA(ss);
637 rtn.setAnnotation("EdgesA" + std::to_string(I+1), ss.str());
638 }
639 }
640 };
641 MetaUtils::staticFor<BinningT::Dimension::value>(decorateEdges);
642
643 return rtn;
644 }
std::vector< double > vals(const bool includeOverflows=false, const bool includeMaskedBins=false) const
Get list of central values.
typename BaseT::BinningT BinningT
typename std::conjunction< std::is_floating_point< EdgeT >... > all_CAxes

References YODA::ScatterND< N >::addPoint(), YODA::AnalysisObject::annotation(), YODA::AnalysisObject::annotations(), YODA::BinnedStorage< Estimate, AxisT... >::binning(), YODA::BinnedStorage< Estimate, AxisT... >::bins(), YODA::AnalysisObject::path(), YODA::AnalysisObject::setAnnotation(), and YODA::EstimateStorage< AxisT >::vals().

◆ newclone()

template<typename... AxisT>
EstimateStorage * YODA::EstimateStorage< AxisT >::newclone ( ) const
inlinevirtualnoexcept

Make a copy on the heap.

Implements YODA::AnalysisObject.

Definition at line 161 of file BinnedEstimate.h.

161 {
162 return new EstimateStorage(*this);
163 }

Referenced by YODA::EstimateStorage< AxisT >::mkInert().

◆ operator+=() [1/2]

template<typename... AxisT>
EstimateStorage & YODA::EstimateStorage< AxisT >::operator+= ( const EstimateStorage< AxisT > &  est)
inline

Definition at line 358 of file BinnedEstimate.h.

358 {
359 return add(est);
360 }
EstimateStorage & add(const EstimateStorage &est, const std::string &pat_uncorr="^stat|^uncor")
Add two EstimateStorages.

References YODA::EstimateStorage< AxisT >::add().

◆ operator+=() [2/2]

template<typename... AxisT>
EstimateStorage & YODA::EstimateStorage< AxisT >::operator+= ( EstimateStorage< AxisT > &&  est)
inline

Definition at line 378 of file BinnedEstimate.h.

378 {
379 return add(std::move(est));
380 }

References YODA::EstimateStorage< AxisT >::add().

◆ operator-=() [1/2]

template<typename... AxisT>
EstimateStorage & YODA::EstimateStorage< AxisT >::operator-= ( const EstimateStorage< AxisT > &  est)
inline

Definition at line 399 of file BinnedEstimate.h.

399 {
400 return subtract(est);
401 }
EstimateStorage & subtract(const EstimateStorage &est, const std::string &pat_uncorr="^stat|^uncor")
Subtract one EstimateStorages from another one.

References YODA::EstimateStorage< AxisT >::subtract().

◆ operator-=() [2/2]

template<typename... AxisT>
EstimateStorage & YODA::EstimateStorage< AxisT >::operator-= ( EstimateStorage< AxisT > &&  est)
inline

Definition at line 416 of file BinnedEstimate.h.

416 {
417 return subtract(std::move(est));
418 }

References YODA::EstimateStorage< AxisT >::subtract().

◆ operator=() [1/2]

template<typename... AxisT>
EstimateStorage & YODA::EstimateStorage< AxisT >::operator= ( const EstimateStorage< AxisT > &  est)
inlinenoexcept

Copy assignment.

Definition at line 325 of file BinnedEstimate.h.

325 {
326 if (this != &est) {
329 }
330 return *this;
331 }
virtual AnalysisObject & operator=(const AnalysisObject &ao) noexcept
Default copy assignment operator.
BinnedStorage & operator=(const BinnedStorage &other) noexcept
Copy assignment.

References YODA::AnalysisObject::operator=(), and YODA::BinnedStorage< Estimate, AxisT... >::operator=().

◆ operator=() [2/2]

template<typename... AxisT>
EstimateStorage & YODA::EstimateStorage< AxisT >::operator= ( EstimateStorage< AxisT > &&  est)
inlinenoexcept

Move assignment.

Definition at line 334 of file BinnedEstimate.h.

334 {
335 if (this != &est) {
337 BaseT::operator = (std::move(est));
338 }
339 return *this;
340 }

References YODA::AnalysisObject::operator=(), and YODA::BinnedStorage< Estimate, AxisT... >::operator=().

◆ rebin() [1/2]

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

Overloaded alias for rebinTo.

Definition at line 315 of file BinnedEstimate.h.

315 {
316 rebinTo<axisN>(std::move(newedges));
317 }

◆ rebin() [2/2]

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

Overloaded alias for rebinBy.

Definition at line 282 of file BinnedEstimate.h.

282 {
283 rebinBy<axisN>(n, begin, end);
284 }

◆ rebinBy()

template<typename... AxisT>
template<size_t axisN>
void YODA::EstimateStorage< 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 266 of file BinnedEstimate.h.

266 {
267 if (n < 1) throw UserError("Rebinning requested in groups of 0!");
268 if (!begin) throw UserError("Visible bins start with index 1!");
269 if (end > BaseT::numBinsAt(axisN)+1) end = BaseT::numBinsAt(axisN) + 1;
270 for (size_t m = begin; m < end; ++m) {
271 if (m > BaseT::numBinsAt(axisN)+1) break; // nothing to be done
272 const size_t myend = (m+n-1 < BaseT::numBinsAt(axisN)+1) ? m+n-1 : BaseT::numBinsAt(axisN);
273 if (myend > m) {
274 BaseT::template mergeBins<axisN>({m, myend});
275 end -= myend-m; //< reduce upper index by the number of removed bins
276 }
277 }
278 }
size_t numBinsAt(const size_t axisN, const bool includeOverflows=false) const noexcept
Number of bins in the BinnedStorage.

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

◆ rebinTo()

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

Rebin to the given list of bin edges.

Definition at line 288 of file BinnedEstimate.h.

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

◆ reset()

template<typename... AxisT>
void YODA::EstimateStorage< AxisT >::reset ( )
inlinevirtualnoexcept

Reset the EstimateStorage.

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

Implements YODA::AnalysisObject.

Definition at line 322 of file BinnedEstimate.h.

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

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

◆ scale()

template<typename... AxisT>
void YODA::EstimateStorage< AxisT >::scale ( const double  scalefactor)
inlinenoexcept

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

Definition at line 249 of file BinnedEstimate.h.

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

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

◆ serializeContent()

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

Content serialisation for MPI reduce operations.

Implements YODA::AnalysisObject.

Definition at line 699 of file BinnedEstimate.h.

699 {
700 std::vector<double> rtn;
701 const size_t nBins = BaseT::numBins(true, true);
702 rtn.reserve(nBins * 4);
703 for (size_t i = 0; i < nBins; ++i) {
704 const auto& b = BaseT::bin(i);
705 std::vector<double> bdata = b._serializeContent(fixed_length);
706 rtn.insert(std::end(rtn),
707 std::make_move_iterator(std::begin(bdata)),
708 std::make_move_iterator(std::end(bdata)));
709 }
710 return rtn;
711 }

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

◆ sources()

template<typename... AxisT>
std::vector< std::string > YODA::EstimateStorage< AxisT >::sources ( ) const
inline

Get list of error sources.

Definition at line 487 of file BinnedEstimate.h.

487 {
488 // Assemble union of error sources, as it's not guaranteed
489 // that every bin has the same error breakdown
490 std::vector<std::string> rtn;
491
492 for (const auto& b : BaseT::bins(true)) {
493 std::vector<std::string> keys = b.sources();
494 rtn.insert(std::end(rtn),
495 std::make_move_iterator(std::begin(keys)),
496 std::make_move_iterator(std::end(keys)));
497 }
498 std::sort(rtn.begin(), rtn.end());
499 rtn.erase( std::unique(rtn.begin(), rtn.end()), rtn.end() );
500
501 return rtn;
502 }

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

Referenced by YODA::EstimateStorage< AxisT >::covarianceMatrix().

◆ subtract() [1/2]

template<typename... AxisT>
EstimateStorage & YODA::EstimateStorage< AxisT >::subtract ( const EstimateStorage< AxisT > &  est,
const std::string &  pat_uncorr = "^stat|^uncor" 
)
inline

Subtract one EstimateStorages from another one.

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

Definition at line 387 of file BinnedEstimate.h.

388 {
389 if (*this != est)
390 throw BinningError("Arithmetic operation requires compatible binning!");
391 if (AO::hasAnnotation("ScaledBy")) AO::rmAnnotation("ScaledBy");
392 for (size_t i = 0; i< BaseT::numBins(true, true); ++i) {
393 BaseT::bin(i).subtract(est.bin(i), pat_uncorr);
394 }
395 BaseT::maskBins(est.maskedBins(), true);
396 return *this;
397 }

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

Referenced by YODA::EstimateStorage< AxisT >::operator-=(), and YODA::EstimateStorage< AxisT >::operator-=().

◆ subtract() [2/2]

template<typename... AxisT>
EstimateStorage & YODA::EstimateStorage< AxisT >::subtract ( EstimateStorage< AxisT > &&  est,
const std::string &  pat_uncorr = "^stat|^uncor" 
)
inline

Subtract one (rvalue) EstimateStorages from another one.

Definition at line 404 of file BinnedEstimate.h.

405 {
406 if (*this != est)
407 throw BinningError("Arithmetic operation requires compatible binning!");
408 if (AO::hasAnnotation("ScaledBy")) AO::rmAnnotation("ScaledBy");
409 for (size_t i = 0; i< BaseT::numBins(true, true); ++i) {
410 BaseT::bin(i) -= std::move(est.bin(i), pat_uncorr);
411 }
412 BaseT::maskBins(est.maskedBins(), true);
413 return *this;
414 }

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

◆ vals()

template<typename... AxisT>
std::vector< double > YODA::EstimateStorage< AxisT >::vals ( const bool  includeOverflows = false,
const bool  includeMaskedBins = false 
) const
inline

Get list of central values.

Definition at line 476 of file BinnedEstimate.h.

477 {
478 std::vector<double> rtn;
479 rtn.reserve(BaseT::numBins(includeOverflows, includeMaskedBins));
480 for (const auto& b : BaseT::bins(includeOverflows, includeMaskedBins)) {
481 rtn.push_back(b.val());
482 }
483 return rtn;
484 }

References YODA::BinnedStorage< Estimate, AxisT... >::bins(), and YODA::BinnedStorage< Estimate, AxisT... >::numBins().

Referenced by YODA::EstimateStorage< AxisT >::mkScatter().

◆ widths()

template<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::EstimateStorage< AxisT >::widths ( const bool  includeOverflows = false) const
inlinenoexcept

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

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 449 of file BinnedEstimate.h.

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

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