yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis 2.0.3
YODA Namespace Reference

Anonymous namespace to limit visibility. More...

Namespaces

namespace  YODAConcepts
 

Classes

class  AnalysisObject
 AnalysisObject is the base class for histograms and scatters. More...
 
class  AnnotationError
 Errors relating to insufficient (effective) statistics. More...
 
class  AOReader
 
class  AOReader< BinnedDbn< DbnN, AxisT... > >
 
class  AOReader< BinnedEstimate< AxisT... > >
 
class  AOReader< Counter >
 
class  AOReader< Estimate0D >
 
class  AOReader< ScatterND< N > >
 
class  AOReaderBase
 
struct  ArithmeticWrapper
 Arithmetic wrapper to emulate inheritance from arithmetic types. More...
 
class  Axis
 Discrete axis with edges of non-floating-point-type. More...
 
class  Axis< T, isCAxis< T > >
 Continuous axis with floating-point-type edges. More...
 
class  Bin
 generic Bin version that derives from BinBase More...
 
class  Bin< 1, T, BinningT >
 CRTP specialisation in 1D. More...
 
class  Bin< 2, T, BinningT >
 CRTP specialisation in 2D. More...
 
class  Bin< 3, T, BinningT >
 CRTP specialisation in 3D. More...
 
class  BinBase
 Bin base class consisting of mix of histogram bin content and space characteristics of this bin (widths, min, max, mid, etc...) More...
 
struct  BinEstimator
 Bin estimator. More...
 
class  BinnedDbn
 User-facing BinnedDbn class in arbitrary dimension. More...
 
class  BinnedDbn< 1, AxisT >
 Specialisation of the BinnedDbn for a 1D histogram. More...
 
class  BinnedDbn< 2, AxisT >
 Specialisation of the BinnedDbn for a 1D profile. More...
 
class  BinnedDbn< 2, AxisT1, AxisT2 >
 Specialisation of the BinnedDbn for a 2D histogram. More...
 
class  BinnedDbn< 3, AxisT1, AxisT2 >
 Specialisation of the BinnedDbn for a 2D profile. More...
 
class  BinnedDbn< 3, AxisT1, AxisT2, AxisT3 >
 Specialisation of the BinnedDbn for a 3D histogram. More...
 
class  BinnedDbn< 4, AxisT1, AxisT2, AxisT3 >
 Specialisation of the BinnedDbn for a 2D profile. More...
 
class  BinnedEstimate
 Forward declaration. More...
 
class  BinnedEstimate< AxisT >
 Specialisation of the BinnedEstimate for a 1D histogram. More...
 
class  BinnedEstimate< AxisT1, AxisT2 >
 Specialisation of the BinnedEstimate for a 2D BinnedEstimate. More...
 
class  BinnedEstimate< AxisT1, AxisT2, AxisT3 >
 Specialisation of the BinnedEstimate for a 3D BinnedEstimate. More...
 
class  BinnedStorage
 BinnedStorage, stores the bins and coordinates access to them. More...
 
class  Binning
 
class  BinningError
 Error for general binning problems. More...
 
class  BinsVecWrapper
 Vector wrapper used to interact with bins vectors. Able to hide overflow and hidden bins. More...
 
struct  CIterable
 
struct  CIterable< T, std::void_t< decltype(std::declval< typename T::const_iterator >())> >
 
struct  CmpFloats
 Functor to compare two floating point numbers and return whether they are fuzzily equivalent. More...
 
class  Counter
 A weighted counter. More...
 
class  Dbn
 User-facing Dbn class inheriting from DbnBase. More...
 
class  Dbn< 0 >
 Partial template specialisation for Dbn0D. More...
 
class  Dbn< 1 >
 Partial template specialisation with CRTP for x-methods. More...
 
class  Dbn< 2 >
 Partial template specialisation with CRTP for x- and y-methods. More...
 
class  Dbn< 3 >
 Partial template specialisation with CRTP for x-, y- and z-methods. More...
 
class  DbnBase
 A 1D distribution. More...
 
class  DbnStorage
 All histograms can be instantiated through this alias. More...
 
struct  defaultAdapter
 Type to adapter mapping used when user didn't provide type adapter. More...
 
struct  defaultAdapter< DbnN, BinT< N, Dbn< DbnN >, BinningT > >
 Default fill adapter for binned type Dbn<N> More...
 
struct  defaultAdapter< FillDim, BinT< N, double, BinningT > >
 Default fill adapter for binned type double. More...
 
struct  Derefable
 SFINAE definition of dereferenceability trait, cf. Boost has_dereference. More...
 
struct  Derefable< T, std::void_t< decltype(*std::declval< T >())> >
 
struct  DerefableToAO
 SFINAE struct to check for dereferencing to an AnalysisObject (reference) at compile time. More...
 
struct  DerefableToAO< T, typename std::conditional< std::is_base_of< AnalysisObject, typename std::decay< decltype(*std::declval< T >()) >::type >::value, AnalysisObject, void >::type >
 
class  Estimate
 A point estimate (base class for the Estimate) More...
 
class  Estimate0D
 An estimate in 0D. More...
 
class  EstimateStorage
 EstimateStorage convenience class based on BinnedStorage. More...
 
class  Exception
 Generic unspecialised YODA runtime error. More...
 
class  Fillable
 A base class for all fillable objects. More...
 
class  FillableStorage
 FillableStorage, introduces FillAdapterT on top of BinnedStorage base class. More...
 
struct  hasFillDim
 
struct  hasFillDim< T, std::void_t< decltype(typename T::FillDim{})> >
 
struct  Iterable
 
struct  Iterable< T, std::void_t< std::decay_t< decltype(std::begin(std::declval< const T & >()))>, std::decay_t< decltype(std::end(std::declval< const T & >()))> > >
 
struct  LinBinEstimator
 Linear bin estimator. More...
 
class  LogBinEstimator
 Logarithmic bin estimator. More...
 
class  LogicError
 Error for places where it should not have been possible to get to! More...
 
class  Point
 Base class for all Point*Ds, providing generic access to their numerical properties. More...
 
class  PointBase
 The base for an N-dimensional data point to be contained in a Scatter<N> More...
 
class  PointND
 
class  PointND< 1 >
 A 1D data point to be contained in a Scatter1D. More...
 
class  PointND< 2 >
 A 2D data point to be contained in a Scatter2D. More...
 
class  PointND< 3 >
 A 3D data point to be contained in a Scatter3D. More...
 
struct  Pushable
 
struct  Pushable< T, VAL, std::void_t< decltype(std::declval< T >().push_back(std::declval< VAL >()))> >
 
class  RangeError
 Error for e.g. use of invalid bin ranges. More...
 
class  Reader
 Pure virtual base class for various output writers. More...
 
class  ReaderFLAT
 Persistency reader from YODA flat text data format. More...
 
class  ReadError
 Error for file reading errors. More...
 
class  ReaderYODA
 Persistency reader from YODA text data format. More...
 
class  Scatter
 A base class for common operations on scatter types (Scatter1D, etc.) More...
 
class  ScatterND
 A generic data type which is just a collection of n-dim data points with errors. More...
 
class  Transformation
 
struct  TypeID
 Returns the type ID as a character sequence. More...
 
struct  TypeID< std::string >
 Specialisation for type string. More...
 
class  UserError
 Error for problems introduced outside YODA, to put it nicely. More...
 
class  WeightError
 Errors relating to event/bin weights. More...
 
class  Weights
 A named, vectorised generalisation of an event weight. More...
 
class  WriteError
 Error for file writing errors. More...
 
class  Writer
 Pure virtual base class for various output writers. More...
 
class  WriterFLAT
 Persistency writer for flat text format. More...
 
class  WriterYODA
 Persistency writer for YODA flat text format. More...
 
class  WriterYODA1
 Persistency writer for YODA flat text format. More...
 
struct  XAxisMixin
 CRTP mixin introducing convenience aliases along X axis. More...
 
struct  XBinMixin
 CRTP mixin introducing convenience aliases along X axis. More...
 
struct  XDbnMixin
 CRTP mixin introducing convenience aliases along X axis. More...
 
struct  XDirectionMixin
 CRTP mixin introducing convenience aliases along X axis. More...
 
struct  XStatsMixin
 CRTP mixin introducing convenience aliases to access statistics along X axis. More...
 
struct  YAxisMixin
 CRTP mixin introducing convenience aliases along Y axis. More...
 
struct  YBinMixin
 CRTP mixin introducing convenience aliases along Y axis. More...
 
struct  YDbnMixin
 CRTP mixin introducing convenience aliases along Y axis. More...
 
struct  YDirectionMixin
 CRTP mixin introducing convenience aliases along Y axis. More...
 
struct  YStatsMixin
 CRTP mixin introducing convenience aliases to access statistics along Y axis. More...
 
struct  ZAxisMixin
 CRTP mixin introducing convenience aliases along Z axis. More...
 
struct  ZBinMixin
 CRTP mixin introducing convenience aliases along Z axis. More...
 
struct  ZDbnMixin
 CRTP mixin introducing convenience aliases along Z axis. More...
 
struct  ZDirectionMixin
 CRTP mixin introducing convenience aliases along Z axis. More...
 
struct  ZStatsMixin
 CRTP mixin introducing convenience aliases to access statistics along Z axis. More...
 

Typedefs

using AO = AnalysisObject
 Convenience alias.
 
using Dbn0D = Dbn< 0 >
 User-friendly aliases.
 
using Dbn1D = Dbn< 1 >
 
using Dbn2D = Dbn< 2 >
 
using Dbn3D = Dbn< 3 >
 
template<typename A1 >
using BinnedHisto1D = BinnedHisto< A1 >
 Define dimension-specific short-hands (Cython sugar)
 
template<typename A1 , typename A2 >
using BinnedHisto2D = BinnedHisto< A1, A2 >
 
template<typename A1 , typename A2 , typename A3 >
using BinnedHisto3D = BinnedHisto< A1, A2, A3 >
 
template<size_t N>
using HistoND = typename HistoMaker< std::make_index_sequence< N > >::type
 
using Histo1D = BinnedHisto< double >
 User-friendly familiar names (continuous axes only)
 
using Histo2D = BinnedHisto< double, double >
 
using Histo3D = BinnedHisto< double, double, double >
 
using Point1D = PointND< 1 >
 User-familiar alias.
 
using Point2D = PointND< 2 >
 
using Point3D = PointND< 3 >
 
using Point4D = PointND< 4 >
 
template<typename A1 >
using BinnedProfile1D = BinnedProfile< A1 >
 Define dimension-specific short-hands (Cython sugar)
 
template<typename A1 , typename A2 >
using BinnedProfile2D = BinnedProfile< A1, A2 >
 
template<typename A1 , typename A2 , typename A3 >
using BinnedProfile3D = BinnedProfile< A1, A2, A3 >
 
template<size_t N>
using ProfileND = typename ProfileMaker< std::make_index_sequence< N > >::type
 User-friendly name for the N-dimensional profile with all-continuous axes.
 
using Profile1D = BinnedProfile< double >
 User-friendly familiar names (continuous axes only)
 
using Profile2D = BinnedProfile< double, double >
 
using Profile3D = BinnedProfile< double, double, double >
 
Define dimension-specific short-hands
template<typename... AxisTypes>
using BinnedHisto = BinnedDbn< sizeof...(AxisTypes), AxisTypes... >
 
template<typename... AxisTypes>
using BinnedProfile = BinnedDbn< sizeof...(AxisTypes)+1, AxisTypes... >
 
Convenience aliases
template<typename A1 >
using BinnedEstimate1D = BinnedEstimate< A1 >
 Define dimension-specific short-hands (Cython sugar)
 
template<typename A1 , typename A2 >
using BinnedEstimate2D = BinnedEstimate< A1, A2 >
 
template<typename A1 , typename A2 , typename A3 >
using BinnedEstimate3D = BinnedEstimate< A1, A2, A3 >
 
template<size_t N>
using EstimateND = typename EstimateMaker< std::make_index_sequence< N > >::type
 
using Estimate1D = BinnedEstimate< double >
 
using Estimate2D = BinnedEstimate< double, double >
 
using Estimate3D = BinnedEstimate< double, double, double >
 
User friendly aliases
using Scatter1D = ScatterND< 1 >
 
using Scatter2D = ScatterND< 2 >
 
using Scatter3D = ScatterND< 3 >
 
using Scatter4D = ScatterND< 4 >
 
using S1D = Scatter1D
 
using S2D = Scatter2D
 
using S3D = Scatter3D
 
using S4D = Scatter4D
 
Convenient aliases
template<size_t N>
using Trf = Transformation< N >
 
Helper methods to probe continuous/discrete axis properties.
template<typename... EdgeT>
using all_CAxes = typename std::conjunction< std::is_floating_point< EdgeT >... >
 
template<typename... EdgeT>
using enable_if_all_CAxisT = std::enable_if_t< all_CAxes< EdgeT... >::value >
 Checks if all edge types are continuous.
 
template<typename EdgeT >
using enable_if_CAxisT = std::enable_if_t< std::is_floating_point< EdgeT >::value, EdgeT >
 Checks if edge type is continuous and returns edge type.
 
template<typename EdgeT >
using enable_if_DAxisT = std::enable_if_t<!std::is_floating_point< EdgeT >::value, EdgeT >
 Checks if edge type is discrete and returns edge type.
 

Enumerations

enum  Sign { MINUS = -1 , ZERO = 0 , PLUS = 1 }
 Enum for signs of numbers. More...
 

Functions

template<typename CoordT >
double nullifyIfDiscCoord (CoordT &&, std::false_type, double null=0.0)
 Nullifies coordinate if it is discrete.
 
template<typename CoordT >
double nullifyIfDiscCoord (CoordT &&coord, std::true_type, double=0.0)
 
template<typename... Args>
bool containsNan (const std::tuple< Args... > &coords)
 Checks if a coordinate tuple has a nan.
 
std::string version ()
 Namespaced version string function.
 
template<size_t N>
DbnBase< N > operator+ (DbnBase< N > first, const DbnBase< N > &second)
 Add two DbnBases.
 
template<size_t N>
DbnBase< N > operator+ (DbnBase< N > first, DbnBase< N > &&second)
 Add two DbnBases.
 
template<size_t N>
DbnBase< N > operator- (DbnBase< N > first, const DbnBase< N > &second)
 Subtract one DbnBase from another one.
 
template<size_t N>
DbnBase< N > operator- (DbnBase< N > first, DbnBase< N > &&second)
 Subtract one DbnBase from another one.
 
ReadermkReader (const std::string &format_name)
 Factory function to make a reader object by format name or a filename.
 
std::string getLibPath ()
 Get the path to the directory containing libYODA.
 
std::string getDataPath ()
 Get the path to the installed share/YODA/ data directory.
 
std::vector< std::string > getYodaDataPath ()
 YODA data paths.
 
std::ostream & operator<< (std::ostream &out, const Weights &w)
 Standard text representaion.
 
WritermkWriter (const std::string &format_name)
 Factory function to make a writer object by format name or a filename.
 
Combining BinnedDbn objects: global operators
template<size_t DbnN, typename... AxisT>
BinnedDbn< DbnN, AxisT... > operator+ (BinnedDbn< DbnN, AxisT... > first, BinnedDbn< DbnN, AxisT... > &&second)
 Add two BinnedDbn objects.
 
template<size_t DbnN, typename... AxisT>
BinnedDbn< DbnN, AxisT... > operator+ (BinnedDbn< DbnN, AxisT... > first, const BinnedDbn< DbnN, AxisT... > &second)
 
template<size_t DbnN, typename... AxisT>
BinnedDbn< DbnN, AxisT... > operator- (BinnedDbn< DbnN, AxisT... > first, BinnedDbn< DbnN, AxisT... > &&second)
 Subtract one BinnedDbn object from another.
 
template<size_t DbnN, typename... AxisT>
BinnedDbn< DbnN, AxisT... > operator- (BinnedDbn< DbnN, AxisT... > first, const BinnedDbn< DbnN, AxisT... > &second)
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > divide (const BinnedDbn< DbnN, AxisT... > &numer, const BinnedDbn< DbnN, AxisT... > &denom)
 Divide two BinnedDbn objects.
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > operator/ (const BinnedDbn< DbnN, AxisT... > &numer, const BinnedDbn< DbnN, AxisT... > &denom)
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > operator/ (const BinnedDbn< DbnN, AxisT... > &numer, BinnedDbn< DbnN, AxisT... > &&denom)
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > operator/ (BinnedDbn< DbnN, AxisT... > &&numer, const BinnedDbn< DbnN, AxisT... > &denom)
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > operator/ (BinnedDbn< DbnN, AxisT... > &&numer, BinnedDbn< DbnN, AxisT... > &&denom)
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > efficiency (const BinnedDbn< DbnN, AxisT... > &accepted, const BinnedDbn< DbnN, AxisT... > &total)
 Calculate a binned efficiency ratio of two BinnedDbn objects.
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > asymm (const BinnedDbn< DbnN, AxisT... > &a, const BinnedDbn< DbnN, AxisT... > &b)
 Calculate the asymmetry (a-b)/(a+b) of two BinnedDbn objects.
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > mkIntegral (const BinnedDbn< DbnN, AxisT... > &histo, const bool includeOverflows=true)
 Convert a BinnedDbn to a BinnedEstimate representing the integral of the histogram.
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > mkIntegralEff (const BinnedDbn< DbnN, AxisT... > &histo, const bool includeOverflows=true)
 Convert a BinnedDbn to a BinnedEstimate where each bin is a fraction of the total.
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > add (const BinnedDbn< DbnN, AxisT... > &dbn, const BinnedEstimate< AxisT... > &est)
 Calculate the addition of a BinnedDbn with a BinnedEstimate.
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > operator+ (const BinnedDbn< DbnN, AxisT... > &dbn, const BinnedEstimate< AxisT... > &est)
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > operator+ (BinnedDbn< DbnN, AxisT... > &&dbn, const BinnedEstimate< AxisT... > &est)
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > operator+ (const BinnedDbn< DbnN, AxisT... > &dbn, BinnedEstimate< AxisT... > &&est)
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > operator+ (BinnedDbn< DbnN, AxisT... > &&dbn, BinnedEstimate< AxisT... > &&est)
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > subtract (const BinnedDbn< DbnN, AxisT... > &dbn, const BinnedEstimate< AxisT... > &est)
 Calculate the subtraction of a BinnedEstimate from a BinnedDbn.
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > operator- (const BinnedDbn< DbnN, AxisT... > &dbn, const BinnedEstimate< AxisT... > &est)
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > operator- (BinnedDbn< DbnN, AxisT... > &&dbn, const BinnedEstimate< AxisT... > &est)
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > operator- (const BinnedDbn< DbnN, AxisT... > &dbn, BinnedEstimate< AxisT... > &&est)
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > operator- (BinnedDbn< DbnN, AxisT... > &&dbn, BinnedEstimate< AxisT... > &&est)
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > divide (const BinnedDbn< DbnN, AxisT... > &dbn, const BinnedEstimate< AxisT... > &est)
 Calculate the division of a BinnedDbn and a BinnedEstimate.
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > operator/ (const BinnedDbn< DbnN, AxisT... > &dbn, const BinnedEstimate< AxisT... > &est)
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > operator/ (BinnedDbn< DbnN, AxisT... > &&dbn, const BinnedEstimate< AxisT... > &est)
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > operator/ (const BinnedDbn< DbnN, AxisT... > &dbn, BinnedEstimate< AxisT... > &&est)
 
template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > operator/ (BinnedDbn< DbnN, AxisT... > &&dbn, BinnedEstimate< AxisT... > &&est)
 
template<size_t DbnN, typename... AxisT, typename... Args, typename = std::enable_if_t<(DbnN == sizeof...(AxisT)+1 && (std::is_same_v<BinnedDbn<DbnN, AxisT...>, Args> && ...))>>
ScatterND< sizeof...(Args)+1 > zipProfiles (const BinnedDbn< DbnN, AxisT... > &p1, Args &&... others, const std::string &path="")
 Zip profile objects of the same type into a combined scatter object.
 
Combining BinnedEstimates: global operators
template<typename... AxisT>
BinnedEstimate< AxisT... > operator+ (BinnedEstimate< AxisT... > first, const BinnedEstimate< AxisT... > &second)
 Add two BinnedEstimates.
 
template<typename... AxisT>
BinnedEstimate< AxisT... > operator+ (BinnedEstimate< AxisT... > first, BinnedEstimate< AxisT... > &&second)
 Add two BinnedEstimates.
 
template<typename... AxisT>
BinnedEstimate< AxisT... > operator- (BinnedEstimate< AxisT... > first, const BinnedEstimate< AxisT... > &second)
 Subtract two BinnedEstimates.
 
template<typename... AxisT>
BinnedEstimate< AxisT... > operator- (BinnedEstimate< AxisT... > first, BinnedEstimate< AxisT... > &&second)
 Subtract two BinnedEstimates.
 
template<typename... AxisT>
BinnedEstimate< AxisT... > divide (const BinnedEstimate< AxisT... > &numer, const BinnedEstimate< AxisT... > &denom, const std::string &pat_uncorr="^stat|^uncor")
 Divide two BinnedEstimates.
 
template<typename... AxisT>
BinnedEstimate< AxisT... > operator/ (const BinnedEstimate< AxisT... > &numer, const BinnedEstimate< AxisT... > &denom)
 Divide two BinnedEstimates.
 
template<typename... AxisT>
BinnedEstimate< AxisT... > operator/ (BinnedEstimate< AxisT... > &&numer, const BinnedEstimate< AxisT... > &denom)
 Divide two BinnedEstimates.
 
template<typename... AxisT>
BinnedEstimate< AxisT... > operator/ (const BinnedEstimate< AxisT... > &numer, BinnedEstimate< AxisT... > &&denom)
 Divide two BinnedEstimates.
 
template<typename... AxisT>
BinnedEstimate< AxisT... > operator/ (BinnedEstimate< AxisT... > &&numer, BinnedEstimate< AxisT... > &&denom)
 Divide two BinnedEstimates.
 
template<typename... AxisT>
BinnedEstimate< AxisT... > efficiency (const BinnedEstimate< AxisT... > &accepted, const BinnedEstimate< AxisT... > &total, const std::string &pat_uncorr="^stat|^uncor")
 Calculate a binned efficiency ratio of two BinnedEstimate objects.
 
template<typename... AxisT>
BinnedEstimate< AxisT... > asymm (const BinnedEstimate< AxisT... > &a, const BinnedEstimate< AxisT... > &b, const std::string &pat_uncorr="^stat|^uncor")
 Calculate the asymmetry (a-b)/(a+b) of two BinnedDbn objects.
 
Generalised transformations
template<typename... AxisT>
void transform (BinnedEstimate< AxisT... > &est, const Trf< 1 > &fn)
 
template<typename... AxisT, typename FN >
void transform (BinnedEstimate< AxisT... > &est, const FN &fn)
 
void transform (Estimate0D &est, const Trf< 1 > &fn)
 
template<typename FN >
void transform (Estimate0D &est, const FN &fn)
 
template<size_t N>
void transform (ScatterND< N > &s, const Trf< N > &fn, const size_t i)
 
template<size_t N, typename FN >
void transform (ScatterND< N > &s, const FN &fn, const size_t i)
 
template<size_t N, typename FN >
void transformX (ScatterND< N > &s, const FN &fn)
 
template<size_t N, typename FN >
void transformY (ScatterND< N > &s, const FN &fn)
 
template<size_t N, typename FN >
void transformZ (ScatterND< N > &s, const FN &fn)
 
Combining counters: global operators
Counter operator+ (Counter first, const Counter &second)
 Add two counters.
 
Counter operator+ (Counter first, Counter &&second)
 Add two counters.
 
Counter operator- (Counter first, const Counter &second)
 Subtract two counters.
 
Counter operator- (Counter first, Counter &&second)
 Subtract two counters.
 
Estimate0D divide (const Counter &numer, const Counter &denom)
 Divide two counters, with an uncorrelated error treatment.
 
Estimate0D operator/ (const Counter &numer, const Counter &denom)
 Divide two Counter objects.
 
Estimate0D operator/ (Counter &&numer, const Counter &denom)
 Divide two Counter objects.
 
Estimate0D operator/ (const Counter &numer, Counter &&denom)
 Divide two Counter objects.
 
Estimate0D operator/ (Counter &&numer, Counter &&denom)
 Divide two Counter objects.
 
Estimate0D efficiency (const Counter &accepted, const Counter &total)
 Calculate an efficiency ratio of two counters.
 
Global operators for Estimate objects
Estimate operator+ (Estimate lhs, const Estimate &rhs)
 Add two Estimate objects.
 
Estimate operator+ (Estimate lhs, Estimate &&rhs)
 Add two Estimate objects.
 
Estimate operator- (Estimate lhs, const Estimate &rhs)
 Subtract two Estimate objects.
 
Estimate operator- (Estimate lhs, Estimate &&rhs)
 Subtract two Estimate objects.
 
Estimate divide (const Estimate &numer, const Estimate &denom, const std::string &pat_uncorr="^stat|^uncor")
 Divide two Estimate objects.
 
Estimate operator/ (const Estimate &numer, const Estimate &denom)
 Divide two Estimate objects.
 
Estimate operator/ (Estimate &&numer, const Estimate &denom)
 Divide two Estimate objects.
 
Estimate operator/ (const Estimate &numer, Estimate &&denom)
 Divide two Estimate objects.
 
Estimate operator/ (Estimate &&numer, Estimate &&denom)
 Divide two Estimate objects.
 
Estimate efficiency (const Estimate &accepted, const Estimate &total, const std::string &pat_uncorr="^stat|^uncor")
 Divide two Estimate objects using binomial statistics.
 
Global operators for Estimate0D objects
Estimate0D operator+ (Estimate0D lhs, const Estimate0D &rhs)
 Add two Estimate0D objects.
 
Estimate0D operator+ (Estimate0D lhs, Estimate0D &&rhs)
 Add two Estimate0D objects.
 
Estimate0D operator- (Estimate0D lhs, const Estimate0D &rhs)
 Subtract two Estimate0D objects.
 
Estimate0D operator- (Estimate0D lhs, Estimate0D &&rhs)
 Subtract two Estimate0D objects.
 
Estimate0D divide (const Estimate0D &numer, const Estimate0D &denom, const std::string &pat_uncorr="^stat|^uncor")
 Divide two Estimate0D objects.
 
Estimate0D operator/ (const Estimate0D &numer, const Estimate0D &denom)
 Divide two Estimate0D objects.
 
Estimate0D operator/ (Estimate0D &&numer, const Estimate0D &denom)
 Divide two Estimate0D objects.
 
Estimate0D operator/ (const Estimate0D &numer, Estimate0D &&denom)
 Divide two Estimate0D objects.
 
Estimate0D operator/ (Estimate0D &&numer, Estimate0D &&denom)
 Divide two Estimate0D objects.
 
Estimate0D efficiency (const Estimate0D &accepted, const Estimate0D &total, const std::string &pat_uncorr="^stat|^uncor")
 Divide two Estimate0D objects using binomial statistics.
 
Writer functions to files (with automatic format detection)
void write (const std::string &filename, const AnalysisObject &ao, int precision=-1)
 Write out object ao to file filename.
 
template<typename RANGE >
void write (const std::string &filename, const RANGE &aos, int precision=-1)
 Write out a collection of objects objs to file filename.
 
template<typename AOITER >
void write (const std::string &filename, const AOITER &begin, const AOITER &end, int precision=-1)
 
Writer functions to streams (with explicit format specification)
void write (std::ostream &os, const AnalysisObject &ao, const std::string &fmt, int precision=-1)
 Write out object ao to stream os with format fmt.
 
template<typename RANGE >
void write (std::ostream &os, const RANGE &aos, const std::string &fmt, int precision=-1)
 Write out a collection of objects objs to file filename.
 
template<typename AOITER >
void write (std::ostream &os, const AOITER &begin, const AOITER &end, const std::string &fmt, int precision=-1)
 
Reader functions from files (with automatic format detection)
void read (const std::string &filename, std::vector< AnalysisObject * > &aos, const std::string &match="", const std::string &unmatch="")
 Read in a collection of objects objs from file filename.
 
std::vector< AnalysisObject * > read (const std::string &filename, const std::string &match="", const std::string &unmatch="")
 Read in a collection of objects from file filename.
 
Reader functions from streams (with explicit format specification)
void read (std::istream &is, std::vector< AnalysisObject * > &aos, const std::string &fmt, const std::string &match="", const std::string &unmatch="")
 Read in a collection of objects objs from stream is, expecting format fmt.
 
std::vector< AnalysisObject * > read (std::istream &is, const std::string &fmt, const std::string &match="", const std::string &unmatch="")
 Read in a collection of objects from stream is, expecting format fmt.
 
Comparison operators
template<size_t N>
bool operator== (const PointBase< N > &a, const PointBase< N > &b)
 Equality test.
 
template<size_t N>
bool operator!= (const PointBase< N > &a, const PointBase< N > &b)
 Inequality test.
 
template<size_t N>
bool operator< (const PointBase< N > &a, const PointBase< N > &b)
 Less-than operator used to sort points.
 
template<size_t N>
bool operator<= (const PointBase< N > &a, const PointBase< N > &b)
 Less-than-or-equals operator used to sort points.
 
template<size_t N>
bool operator> (const PointBase< N > &a, const PointBase< N > &b)
 Greater-than operator used to sort points.
 
template<size_t N>
bool operator>= (const PointBase< N > &a, const PointBase< N > &b)
 Greater-than-or-equals operator used to sort points.
 
Combining scatters by merging sets of points
template<int N>
ScatterND< N > combine (ScatterND< N > a, const ScatterND< N > &b)
 
template<int N>
ScatterND< N > combine (ScatterND< N > a, ScatterND< N > &&b)
 
template<int N>
ScatterND< N > combine (const std::vector< ScatterND< N > > &scatters)
 
template<int N>
ScatterND< N > combine (std::vector< ScatterND< N > > &&scatters)
 
Helper methods to stringify edge types
template<typename A , typename... As>
std::string mkAxisConfig ()
 Helper function to construct the axis config.
 
template<ssize_t DbnN, typename A , typename... As>
std::string mkTypeString ()
 Helper function to construct the BinnedDbn and BinnedEstimate type names.
 
template<typename A , typename... As>
std::string mkTypeString ()
 Same as above, but for non-Dbn bin contents.
 
Miscellaneous numerical helpers
template<typename NUM >
NUM sqr (NUM a)
 Named number-type squaring operation.
 
template<typename... Num>
std::enable_if_t< std::conjunction_v< std::is_arithmetic< Num >... >, double > add_quad (Num ... vals)
 Named number-type addition in quadrature operation.
 
int sign (double val)
 Find the sign of a number.
 
int sign (int val)
 Find the sign of a number.
 
int sign (long val)
 Find the sign of a number.
 
double subtract (double a, double b, double tolerance=1e-5)
 Subtract two numbers with FP fuzziness.
 
double add (double a, double b, double tolerance=1e-5)
 Add two numbers with FP fuzziness.
 
Binning helper functions
std::vector< double > linspace (size_t nbins, double xmin, double xmax, bool include_end=true)
 Make a list of nbins + 1 values uniformly spaced between xmin and xmax inclusive.
 
std::vector< double > logspace (size_t nbins, double xmin, double xmax, bool include_end=true)
 Make a list of nbins + 1 values uniformly spaced in log(x) between xmin and xmax inclusive.
 
std::vector< double > pdfspace (size_t nbins, double xmin, double xmax, std::function< double(double)> &fn, size_t nsample=10000)
 Make a list of nbins + 1 values spaced with density ~ f(x) between xmin and end inclusive.
 
template<typename NUM >
int index_between (const NUM &val, const std::vector< NUM > &binedges)
 Return the bin index of the given value, val, given a vector of bin edges.
 
Statistics functions
double effNumEntries (const double sumW, const double sumW2)
 Calculate the effective number of entries of a sample.
 
double effNumEntries (const std::vector< double > &weights)
 Calculate the effective number of entries of a sample.
 
double mean (const std::vector< int > &sample)
 Calculate the mean of a sample.
 
double mean (const double sumWX, const double sumW)
 Calculate the weighted mean of a sample.
 
double mean (const std::vector< double > &sample, const std::vector< double > &weights)
 Calculate the weighted mean of a sample.
 
double variance (const double sumWX, const double sumW, const double sumWX2, const double sumW2)
 Calculate the weighted variance of a sample.
 
double variance (const std::vector< double > &sample, const std::vector< double > &weights)
 Calculate the weighted variance of a sample.
 
double stdDev (const double sumWX, const double sumW, const double sumWX2, const double sumW2)
 Calculate the weighted standard deviation of a sample.
 
double stdDev (const std::vector< double > &sample, const std::vector< double > &weights)
 Calculate the weighted variance of a sample.
 
double stdErr (const double sumWX, const double sumW, const double sumWX2, const double sumW2)
 Calculate the weighted standard error of a sample.
 
double stdErr (const std::vector< double > &sample, const std::vector< double > &weights)
 Calculate the weighted variance of a sample.
 
double RMS (const double sumWX2, const double sumW, const double sumW2)
 Calculate the weighted RMS of a sample.
 
double RMS (const std::vector< double > &sample, const std::vector< double > &weights)
 Calculate the weighted RMS of a sample.
 
double covariance (const std::vector< int > &sample1, const std::vector< int > &sample2)
 Calculate the covariance (variance) between two samples.
 
double correlation (const std::vector< int > &sample1, const std::vector< int > &sample2)
 Calculate the correlation strength between two samples.
 
double naiveChi2 (const std::vector< double > &sample1, const std::vector< double > &sample2, const std::vector< double > &s1errors=std::vector< double >{}, const std::vector< double > &s2errors=std::vector< double >{})
 Calculate the error-weighted chi2 statistic between two samples.
 
double naiveChi2reduced (const std::vector< double > &sample1, const std::vector< double > &sample2, const std::vector< double > &s1errors=std::vector< double >{}, const std::vector< double > &s2errors=std::vector< double >{})
 Calculate the error-weighted reduced chi2 statistic between two samples.
 
Combining weights: global operators
Weights operator+ (const Weights &first, const Weights &second)
 Add two weights.
 
Weights operator- (const Weights &first, const Weights &second)
 Subtract two weights.
 
Weights operator* (const Weights &first, const Weights &second)
 Multiply two weights.
 
Weights operator/ (const Weights &numer, const Weights &denom)
 Divide two weights.
 
Weights operator* (double a, const Weights &w)
 Multiply by a double.
 
Weights operator* (const Weights &w, double a)
 Multiply by a double.
 
Weights operator/ (const Weights &w, double a)
 Divide by a double.
 
Weights operator/ (double a, const Weights &w)
 

Variables

const size_t SEARCH_SIZElc = 16
 
const size_t BISECT_LINEAR_THRESHOLDlc = 32
 
static const double MAXDOUBLE = DBL_MAX
 
static const double MAXINT = INT_MAX
 
static const double PI = M_PI
 A pre-defined value of $ \pi $.
 
static const double TWOPI = 2*M_PI
 A pre-defined value of $ 2\pi $.
 
static const double HALFPI = M_PI_2
 A pre-defined value of $ \pi/2 $.
 
template<typename... T>
constexpr bool isIterable = std::conjunction<Iterable<T>...>::value
 
template<typename... T>
constexpr bool isCIterable = std::conjunction<CIterable<T>...>::value
 
static const int YODA_FORMAT_VERSION = 3
 

Ranges and intervals

enum  RangeBoundary { OPEN =0 , SOFT =0 , CLOSED =1 , HARD =1 }
 
template<typename NUM >
bool inRange (NUM value, NUM low, NUM high, RangeBoundary lowbound=CLOSED, RangeBoundary highbound=OPEN)
 Determine if value is in the range low to high, for floating point numbers.
 
template<typename NUM >
bool inRange (NUM value, std::pair< NUM, NUM > lowhigh, RangeBoundary lowbound=CLOSED, RangeBoundary highbound=OPEN)
 Alternative version of inRange for doubles, which accepts a pair for the range arguments.
 
bool inRange (int value, int low, int high, RangeBoundary lowbound=CLOSED, RangeBoundary highbound=CLOSED)
 Determine if value is in the range low to high, for integer types.
 
bool inRange (int value, std::pair< int, int > lowhigh, RangeBoundary lowbound=CLOSED, RangeBoundary highbound=OPEN)
 Alternative version of inRange for ints, which accepts a pair for the range arguments.
 

Comparison functions for safe (floating point) equality tests

static std::function< bool(const double, const double)> fuzzyEqComp
 Comparator wrapper to use with STL algorithms, e.g. std::equal etc.
 
template<typename NUM >
std::enable_if_t< std::is_floating_point_v< NUM >, bool > isZero (NUM val, double tolerance=1e-5)
 Compare a number to zero.
 
template<typename NUM >
std::enable_if_t< std::is_integral_v< NUM >, bool > isZero (NUM val, double=1e-5)
 Compare a number to zero.
 
template<typename NUM >
std::enable_if_t< std::is_floating_point_v< NUM >, bool > isNaN (NUM val)
 Check if a number is NaN.
 
template<typename NUM >
std::enable_if_t< std::is_floating_point_v< NUM >, bool > notNaN (NUM val)
 Check if a number is non-NaN.
 
template<typename N1 , typename N2 >
std::enable_if_t< std::is_arithmetic_v< N1 > &&std::is_arithmetic_v< N2 > &&(std::is_floating_point_v< N1 >||std::is_floating_point_v< N2 >), bool > fuzzyEquals (N1 a, N2 b, double tolerance=1e-5)
 Compare two numbers for equality with a degree of fuzziness.
 
template<typename N1 , typename N2 >
std::enable_if_t< std::is_integral_v< N1 > &&std::is_integral_v< N2 >, bool > fuzzyEquals (N1 a, N2 b, double)
 Compare two numbers for equality with a degree of fuzziness.
 
template<typename N1 , typename N2 >
std::enable_if_t< std::is_arithmetic_v< N1 > &&std::is_arithmetic_v< N2 >, bool > fuzzyGtrEquals (N1 a, N2 b, double tolerance=1e-5)
 Compare two numbers for >= with a degree of fuzziness.
 
template<typename N1 , typename N2 >
std::enable_if_t< std::is_arithmetic_v< N1 > &&std::is_arithmetic_v< N2 >, bool > fuzzyLessEquals (N1 a, N2 b, double tolerance=1e-5)
 Compare two floating point numbers for <= with a degree of fuzziness.
 
double approx (double a, int n=5)
 Returns a number floored at the nth decimal place.
 

Detailed Description

Anonymous namespace to limit visibility.

Todo:
Add SFINAE math type stuff (see Rivet) and add inrange() and inrange_closed_closed() etc. aliases cf. MCUtils

Typedef Documentation

◆ all_CAxes

template<typename... EdgeT>
using YODA::all_CAxes = typedef typename std::conjunction<std::is_floating_point<EdgeT>...>

Definition at line 18 of file BinningUtils.h.

◆ AO

using YODA::AO = typedef AnalysisObject

Convenience alias.

Definition at line 360 of file AnalysisObject.h.

◆ BinnedEstimate1D

template<typename A1 >
using YODA::BinnedEstimate1D = typedef BinnedEstimate<A1>

Define dimension-specific short-hands (Cython sugar)

Definition at line 1222 of file BinnedEstimate.h.

◆ BinnedEstimate2D

template<typename A1 , typename A2 >
using YODA::BinnedEstimate2D = typedef BinnedEstimate<A1, A2>

Definition at line 1225 of file BinnedEstimate.h.

◆ BinnedEstimate3D

template<typename A1 , typename A2 , typename A3 >
using YODA::BinnedEstimate3D = typedef BinnedEstimate<A1, A2, A3>

Definition at line 1228 of file BinnedEstimate.h.

◆ BinnedHisto

template<typename... AxisTypes>
using YODA::BinnedHisto = typedef BinnedDbn<sizeof...(AxisTypes), AxisTypes...>

Definition at line 97 of file BinnedDbn.h.

◆ BinnedHisto1D

template<typename A1 >
using YODA::BinnedHisto1D = typedef BinnedHisto<A1>

Define dimension-specific short-hands (Cython sugar)

Definition at line 331 of file Histo.h.

◆ BinnedHisto2D

template<typename A1 , typename A2 >
using YODA::BinnedHisto2D = typedef BinnedHisto<A1, A2>

Definition at line 334 of file Histo.h.

◆ BinnedHisto3D

template<typename A1 , typename A2 , typename A3 >
using YODA::BinnedHisto3D = typedef BinnedHisto<A1, A2, A3>

Definition at line 337 of file Histo.h.

◆ BinnedProfile

template<typename... AxisTypes>
using YODA::BinnedProfile = typedef BinnedDbn<sizeof...(AxisTypes)+1, AxisTypes...>

Definition at line 100 of file BinnedDbn.h.

◆ BinnedProfile1D

template<typename A1 >
using YODA::BinnedProfile1D = typedef BinnedProfile<A1>

Define dimension-specific short-hands (Cython sugar)

Definition at line 326 of file Profile.h.

◆ BinnedProfile2D

template<typename A1 , typename A2 >
using YODA::BinnedProfile2D = typedef BinnedProfile<A1, A2>

Definition at line 329 of file Profile.h.

◆ BinnedProfile3D

template<typename A1 , typename A2 , typename A3 >
using YODA::BinnedProfile3D = typedef BinnedProfile<A1, A2, A3>

Definition at line 332 of file Profile.h.

◆ Dbn0D

using YODA::Dbn0D = typedef Dbn<0>

User-friendly aliases.

Definition at line 775 of file Dbn.h.

◆ Dbn1D

using YODA::Dbn1D = typedef Dbn<1>

Definition at line 776 of file Dbn.h.

◆ Dbn2D

using YODA::Dbn2D = typedef Dbn<2>

Definition at line 777 of file Dbn.h.

◆ Dbn3D

using YODA::Dbn3D = typedef Dbn<3>

Definition at line 778 of file Dbn.h.

◆ enable_if_all_CAxisT

template<typename... EdgeT>
using YODA::enable_if_all_CAxisT = typedef std::enable_if_t<all_CAxes<EdgeT...>::value>

Checks if all edge types are continuous.

Definition at line 22 of file BinningUtils.h.

◆ enable_if_CAxisT

template<typename EdgeT >
using YODA::enable_if_CAxisT = typedef std::enable_if_t<std::is_floating_point<EdgeT>::value, EdgeT>

Checks if edge type is continuous and returns edge type.

Definition at line 26 of file BinningUtils.h.

◆ enable_if_DAxisT

template<typename EdgeT >
using YODA::enable_if_DAxisT = typedef std::enable_if_t<!std::is_floating_point<EdgeT>::value, EdgeT>

Checks if edge type is discrete and returns edge type.

Definition at line 30 of file BinningUtils.h.

◆ Estimate1D

using YODA::Estimate1D = typedef BinnedEstimate<double>

Definition at line 1246 of file BinnedEstimate.h.

◆ Estimate2D

using YODA::Estimate2D = typedef BinnedEstimate<double,double>

Definition at line 1247 of file BinnedEstimate.h.

◆ Estimate3D

using YODA::Estimate3D = typedef BinnedEstimate<double,double,double>

Definition at line 1248 of file BinnedEstimate.h.

◆ EstimateND

template<size_t N>
using YODA::EstimateND = typedef typename EstimateMaker<std::make_index_sequence<N> >::type

Definition at line 1242 of file BinnedEstimate.h.

◆ Histo1D

using YODA::Histo1D = typedef BinnedHisto<double>

User-friendly familiar names (continuous axes only)

Definition at line 354 of file Histo.h.

◆ Histo2D

using YODA::Histo2D = typedef BinnedHisto<double,double>

Definition at line 355 of file Histo.h.

◆ Histo3D

using YODA::Histo3D = typedef BinnedHisto<double,double,double>

Definition at line 356 of file Histo.h.

◆ HistoND

template<size_t N>
using YODA::HistoND = typedef typename HistoMaker<std::make_index_sequence<N> >::type

Definition at line 351 of file Histo.h.

◆ Point1D

using YODA::Point1D = typedef PointND<1>

User-familiar alias.

Definition at line 715 of file Point.h.

◆ Point2D

using YODA::Point2D = typedef PointND<2>

Definition at line 716 of file Point.h.

◆ Point3D

using YODA::Point3D = typedef PointND<3>

Definition at line 717 of file Point.h.

◆ Point4D

using YODA::Point4D = typedef PointND<4>

Definition at line 718 of file Point.h.

◆ Profile1D

using YODA::Profile1D = typedef BinnedProfile<double>

User-friendly familiar names (continuous axes only)

Definition at line 350 of file Profile.h.

◆ Profile2D

using YODA::Profile2D = typedef BinnedProfile<double,double>

Definition at line 351 of file Profile.h.

◆ Profile3D

using YODA::Profile3D = typedef BinnedProfile<double,double,double>

Definition at line 352 of file Profile.h.

◆ ProfileND

template<size_t N>
using YODA::ProfileND = typedef typename ProfileMaker<std::make_index_sequence<N> >::type

User-friendly name for the N-dimensional profile with all-continuous axes.

Definition at line 347 of file Profile.h.

◆ S1D

using YODA::S1D = typedef Scatter1D

Definition at line 906 of file Scatter.h.

◆ S2D

using YODA::S2D = typedef Scatter2D

Definition at line 907 of file Scatter.h.

◆ S3D

using YODA::S3D = typedef Scatter3D

Definition at line 908 of file Scatter.h.

◆ S4D

using YODA::S4D = typedef Scatter4D

Definition at line 909 of file Scatter.h.

◆ Scatter1D

using YODA::Scatter1D = typedef ScatterND<1>

Definition at line 902 of file Scatter.h.

◆ Scatter2D

using YODA::Scatter2D = typedef ScatterND<2>

Definition at line 903 of file Scatter.h.

◆ Scatter3D

using YODA::Scatter3D = typedef ScatterND<3>

Definition at line 904 of file Scatter.h.

◆ Scatter4D

using YODA::Scatter4D = typedef ScatterND<4>

Definition at line 905 of file Scatter.h.

◆ Trf

template<size_t N>
using YODA::Trf = typedef Transformation<N>

Definition at line 128 of file Transformation.h.

Enumeration Type Documentation

◆ RangeBoundary

Represents whether an interval is open (non-inclusive) or closed (inclusive).

For example, the interval $ [0, \pi) $ is closed (an inclusive boundary) at 0, and open (a non-inclusive boundary) at $ \pi $.

Enumerator
OPEN 
SOFT 
CLOSED 
HARD 

Definition at line 156 of file MathUtils.h.

156{ OPEN=0, SOFT=0, CLOSED=1, HARD=1 };
@ CLOSED
Definition MathUtils.h:156
@ OPEN
Definition MathUtils.h:156
@ HARD
Definition MathUtils.h:156
@ SOFT
Definition MathUtils.h:156

◆ Sign

enum YODA::Sign

Enum for signs of numbers.

Enumerator
MINUS 
ZERO 
PLUS 

Definition at line 51 of file MathUtils.h.

51{ MINUS = -1, ZERO = 0, PLUS = 1 };
@ ZERO
Definition MathUtils.h:51
@ PLUS
Definition MathUtils.h:51
@ MINUS
Definition MathUtils.h:51

Function Documentation

◆ add() [1/2]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::add ( const BinnedDbn< DbnN, AxisT... > &  dbn,
const BinnedEstimate< AxisT... > &  est 
)
inline

Calculate the addition of a BinnedDbn with a BinnedEstimate.

Definition at line 1285 of file BinnedDbn.h.

1285 {
1286 return dbn.mkEstimate() + est;
1287 }
BinnedEstimate< AxisT... > mkEstimate(const std::string &path="", const std::string &source="", const bool divbyvol=true) const
Produce a BinnedEstimate from a DbnStorage.
Definition BinnedDbn.h:754

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

Referenced by asymm(), efficiency(), efficiency(), operator+(), operator+(), operator+(), and operator+().

◆ add() [2/2]

double YODA::add ( double  a,
double  b,
double  tolerance = 1e-5 
)
inline

Add two numbers with FP fuzziness.

Definition at line 253 of file MathUtils.h.

253 {
254 return subtract(a,-b,tolerance);
255 }
BinnedEstimate< AxisT... > subtract(const BinnedDbn< DbnN, AxisT... > &dbn, const BinnedEstimate< AxisT... > &est)
Calculate the subtraction of a BinnedEstimate from a BinnedDbn.
Definition BinnedDbn.h:1317

References subtract().

◆ add_quad()

template<typename... Num>
std::enable_if_t< std::conjunction_v< std::is_arithmetic< Num >... >, double > YODA::add_quad ( Num ...  vals)
inline

Named number-type addition in quadrature operation.

Definition at line 223 of file MathUtils.h.

223 {
224 return sqrt((0.0 + ... + sqr(vals)));
225 }
NUM sqr(NUM a)
Named number-type squaring operation.
Definition MathUtils.h:216

References sqr().

Referenced by divide().

◆ approx()

double YODA::approx ( double  a,
int  n = 5 
)
inline

Returns a number floored at the nth decimal place.

Definition at line 140 of file MathUtils.h.

140 {
141 double roundTo = pow(10.0,n);
142 a *= roundTo;
143 a = floor(a);
144 return a/roundTo;
145 }

◆ asymm() [1/2]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::asymm ( const BinnedDbn< DbnN, AxisT... > &  a,
const BinnedDbn< DbnN, AxisT... > &  b 
)
inline

Calculate the asymmetry (a-b)/(a+b) of two BinnedDbn objects.

Definition at line 1216 of file BinnedDbn.h.

1216 {
1217 return (a-b) / (a+b);
1218 }

◆ asymm() [2/2]

template<typename... AxisT>
BinnedEstimate< AxisT... > YODA::asymm ( const BinnedEstimate< AxisT... > &  a,
const BinnedEstimate< AxisT... > &  b,
const std::string &  pat_uncorr = "^stat|^uncor" 
)
inline

Calculate the asymmetry (a-b)/(a+b) of two BinnedDbn objects.

Definition at line 1189 of file BinnedEstimate.h.

1191 {
1192 return divde(subtract(a-b, pat_uncorr), add(a+b, pat_uncorr), pat_uncorr);
1193 }
BinnedEstimate< AxisT... > add(const BinnedDbn< DbnN, AxisT... > &dbn, const BinnedEstimate< AxisT... > &est)
Calculate the addition of a BinnedDbn with a BinnedEstimate.
Definition BinnedDbn.h:1285

References add(), and subtract().

◆ combine() [1/4]

template<int N>
ScatterND< N > YODA::combine ( const std::vector< ScatterND< N > > &  scatters)
inline

Definition at line 804 of file Scatter.h.

804 {
805 ScatterND<N> rtn;
806 rtn.combineWith(scatters);
807 return rtn;
808 }
A generic data type which is just a collection of n-dim data points with errors.
Definition Scatter.h:154
ScatterND< N > & combineWith(const ScatterND< N > &other)
Definition Scatter.h:568

References YODA::ScatterND< N >::combineWith().

◆ combine() [2/4]

template<int N>
ScatterND< N > YODA::combine ( ScatterND< N >  a,
const ScatterND< N > &  b 
)
inline

Definition at line 792 of file Scatter.h.

792 {
793 a.combineWith(b);
794 return a;
795 }

References YODA::ScatterND< N >::combineWith().

◆ combine() [3/4]

template<int N>
ScatterND< N > YODA::combine ( ScatterND< N >  a,
ScatterND< N > &&  b 
)
inline

Definition at line 798 of file Scatter.h.

798 {
799 a.combineWith(std::move(b));
800 return a;
801 }

References YODA::ScatterND< N >::combineWith().

◆ combine() [4/4]

template<int N>
ScatterND< N > YODA::combine ( std::vector< ScatterND< N > > &&  scatters)
inline

Definition at line 811 of file Scatter.h.

811 {
812 ScatterND<N> rtn;
813 rtn.combineWith(std::move(scatters));
814 return rtn;
815 }

References YODA::ScatterND< N >::combineWith().

◆ containsNan()

template<typename... Args>
bool YODA::containsNan ( const std::tuple< Args... > &  coords)
inline

Checks if a coordinate tuple has a nan.

Definition at line 30 of file Binning.h.

30 {
31 std::array<size_t, sizeof...(Args)> hasNan{};
32 auto checkCoords = [&hasNan, &coords](auto I) {
33 using isContinuous = typename std::is_floating_point<typename std::tuple_element_t<I, std::tuple<Args...>>>;
34
35 hasNan[I] = size_t(std::isnan(nullifyIfDiscCoord(std::move(std::get<I>(coords)),
36 std::integral_constant<bool,
37 isContinuous::value>{})));
38 };
39
40 MetaUtils::staticFor<sizeof...(Args)>(checkCoords);
41
42 return std::any_of(hasNan.begin(), hasNan.end(), [ ](const bool i) { return i; } );
43 }
constexpr void staticFor(Func &&f)
Used to apply functor on tuple. Calls lambda with integral constant, which can be used to query tuple...
Definition MetaUtils.h:35

References nullifyIfDiscCoord(), and MetaUtils::staticFor().

Referenced by YODA::FillableStorage< FillDim, BinContentT, AxisT >::fill().

◆ correlation()

double YODA::correlation ( const std::vector< int > &  sample1,
const std::vector< int > &  sample2 
)
inline

Calculate the correlation strength between two samples.

Definition at line 533 of file MathUtils.h.

533 {
534 const double cov = covariance(sample1, sample2);
535 const double var1 = covariance(sample1, sample1);
536 const double var2 = covariance(sample2, sample2);
537 const double correlation = cov/sqrt(var1*var2);
538 const double corr_strength = correlation*sqrt(var2/var1);
539 return corr_strength;
540 }
double covariance(const std::vector< int > &sample1, const std::vector< int > &sample2)
Calculate the covariance (variance) between two samples.
Definition MathUtils.h:518
double correlation(const std::vector< int > &sample1, const std::vector< int > &sample2)
Calculate the correlation strength between two samples.
Definition MathUtils.h:533

References correlation(), and covariance().

Referenced by correlation().

◆ covariance()

double YODA::covariance ( const std::vector< int > &  sample1,
const std::vector< int > &  sample2 
)
inline

Calculate the covariance (variance) between two samples.

Definition at line 518 of file MathUtils.h.

518 {
519 const double mean1 = mean(sample1);
520 const double mean2 = mean(sample2);
521 const size_t N = sample1.size();
522 double cov = 0.0;
523 for (size_t i = 0; i < N; i++) {
524 const double cov_i = (sample1[i] - mean1)*(sample2[i] - mean2);
525 cov += cov_i;
526 }
527 if (N > 1) return cov/(N-1);
528 else return 0.0;
529 }
double mean(const std::vector< int > &sample)
Calculate the mean of a sample.
Definition MathUtils.h:397

References mean().

Referenced by correlation().

◆ divide() [1/6]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::divide ( const BinnedDbn< DbnN, AxisT... > &  dbn,
const BinnedEstimate< AxisT... > &  est 
)
inline

Calculate the division of a BinnedDbn and a BinnedEstimate.

Definition at line 1349 of file BinnedDbn.h.

1349 {
1350 return dbn.mkEstimate() / est;
1351 }

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

◆ divide() [2/6]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::divide ( const BinnedDbn< DbnN, AxisT... > &  numer,
const BinnedDbn< DbnN, AxisT... > &  denom 
)
inline

Divide two BinnedDbn objects.

Definition at line 1112 of file BinnedDbn.h.

1112 {
1113
1114 if (numer != denom) {
1115 throw BinningError("Arithmetic operation requires compatible binning!");
1116 }
1117
1118 BinnedEstimate<AxisT...> rtn = numer.mkEstimate();
1119 if (numer.path() == denom.path()) rtn.setPath(numer.path());
1120 if (rtn.hasAnnotation("ScaledBy")) rtn.rmAnnotation("ScaledBy");
1121
1122 for (const auto& b_num : numer.bins(true, true)) {
1123 const size_t idx = b_num.index();
1124 const auto& b_den = denom.bin(idx);
1125 double v, e;
1126 if (isZero(b_den.effNumEntries())) {
1127 v = std::numeric_limits<double>::quiet_NaN();
1128 e = std::numeric_limits<double>::quiet_NaN();
1129 }
1130 else {
1131 if constexpr(DbnN > sizeof...(AxisT)) {
1132 v = b_num.mean(DbnN) / b_den.mean(DbnN);
1133 const double e_num = isZero(b_num.effNumEntries())? 0 : b_num.relStdErr(DbnN);
1134 const double e_den = isZero(b_den.effNumEntries())? 0 : b_den.relStdErr(DbnN);
1135 e = fabs(v) * sqrt(sqr(e_num) + sqr(e_den));
1136 }
1137 else {
1138 v = b_num.sumW() / b_den.sumW();
1139 const double e_num = isZero(b_num.effNumEntries())? 0 : b_num.relErrW();
1140 const double e_den = isZero(b_den.effNumEntries())? 0 : b_den.relErrW();
1141 e = fabs(v) * sqrt(sqr(e_num) + sqr(e_den));
1142 }
1143 }
1144 rtn.bin(idx).set(v, {-e, e}); // @todo put "stats" as source?
1145 }
1146 rtn.maskBins(denom.maskedBins(), true);
1147
1148 return rtn;
1149 }
const std::string path() const
Get the AO path.
BinT & bin(size_t idx) noexcept
Returns reference to the bin at idx.
std::vector< size_t > maskedBins() const noexcept
Error for general binning problems.
Definition Exceptions.h:27
std::enable_if_t< std::is_floating_point_v< NUM >, bool > isZero(NUM val, double tolerance=1e-5)
Compare a number to zero.
Definition MathUtils.h:63

References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), isZero(), YODA::BinnedStorage< BinContentT, AxisT >::maskedBins(), YODA::DbnStorage< DbnN, AxisT >::mkEstimate(), YODA::AnalysisObject::path(), and sqr().

Referenced by divide(), divide(), efficiency(), efficiency(), efficiency(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), and operator/().

◆ divide() [3/6]

template<typename... AxisT>
BinnedEstimate< AxisT... > YODA::divide ( const BinnedEstimate< AxisT... > &  numer,
const BinnedEstimate< AxisT... > &  denom,
const std::string &  pat_uncorr = "^stat|^uncor" 
)
inline

Divide two BinnedEstimates.

Definition at line 1109 of file BinnedEstimate.h.

1110 {
1111 if (numer != denom) {
1112 throw BinningError("Arithmetic operation requires compatible binning!");
1113 }
1114
1115 BinnedEstimate<AxisT...> rtn(numer.binning());
1116 if (numer.path() == denom.path()) rtn.setPath(numer.path());
1117 if (rtn.hasAnnotation("ScaledBy")) rtn.rmAnnotation("ScaledBy");
1118
1119 for (const auto& b_num : numer.bins(true, true)) {
1120 const size_t idx = b_num.index();
1121 rtn.bin(idx) = divide(b_num, denom.bin(idx), pat_uncorr);
1122 }
1123 rtn.maskBins(denom.maskedBins(), true);
1124
1125 return rtn;
1126 }
const BinningT & binning() const noexcept
Returns dimension underlying binning object reference.

References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::binning(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), divide(), YODA::BinnedStorage< BinContentT, AxisT >::maskedBins(), and YODA::AnalysisObject::path().

◆ divide() [4/6]

Estimate0D YODA::divide ( const Counter numer,
const Counter denom 
)

Divide two counters, with an uncorrelated error treatment.

Todo:
Add skipnullpts extra optional arg

Definition at line 19 of file Counter.cc.

19 {
20 Estimate0D rtn;
21 if (numer.path() == denom.path()) rtn.setPath(numer.path());
22 if (rtn.hasAnnotation("ScaledBy")) rtn.rmAnnotation("ScaledBy");
23 if (denom.val() != 0) {
24 const double val = numer.val() / denom.val();
25 const double err = val * add_quad(numer.relErr(), denom.relErr());
26 rtn.set(val, {-err, err});
27 }
28 return rtn;
29 }
void setPath(const std::string &path)
void rmAnnotation(const std::string &name)
Delete an annotation by name.
bool hasAnnotation(const std::string &name) const
Check if an annotation is defined.
double relErr() const
Definition Counter.h:198
double val(bool=false) const
Get the value.
Definition Counter.h:189
An estimate in 0D.
Definition Estimate0D.h:24
void set(const double val, const std::pair< double, double > &err, const std::string source="")
Set both central value and uncertainty component.
Definition Estimate.h:181
std::enable_if_t< std::conjunction_v< std::is_arithmetic< Num >... >, double > add_quad(Num ... vals)
Named number-type addition in quadrature operation.
Definition MathUtils.h:223

References add_quad(), YODA::AnalysisObject::hasAnnotation(), YODA::AnalysisObject::path(), YODA::Counter::relErr(), YODA::AnalysisObject::rmAnnotation(), YODA::Estimate::set(), YODA::AnalysisObject::setPath(), and YODA::Counter::val().

◆ divide() [5/6]

Estimate YODA::divide ( const Estimate numer,
const Estimate denom,
const std::string &  pat_uncorr = "^stat|^uncor" 
)
inline

Divide two Estimate objects.

Definition at line 686 of file Estimate.h.

687 {
688
689 Estimate rtn;
690 if (denom.val()) rtn.setVal(numer.val() / denom.val());
691 const double newVal = rtn.val();
692
693 // get error sources
694 std::vector<std::string> sources = numer.sources();
695 std::vector<std::string> tmp = denom.sources();
696 sources.insert(std::end(sources),
697 std::make_move_iterator(std::begin(tmp)),
698 std::make_move_iterator(std::end(tmp)));
699 std::sort(sources.begin(), sources.end());
700 sources.erase( std::unique(sources.begin(), sources.end()), sources.end() );
701
702 std::smatch match;
703 const std::regex re(pat_uncorr, std::regex_constants::icase);
704 for (const std::string& src : sources) {
705 if (std::regex_search(src, match, re)) {
706 // treat as uncorrelated between AOs:
707 // add relative errors in quadrature
708 double n_dn = 0.0, n_up = 0.0;
709 if (numer.hasSource(src)) {
710 n_dn = numer.relErrDown(src);
711 n_up = numer.relErrUp(src);
712 }
713 double d_dn = 0.0, d_up = 0.0;
714 if (denom.hasSource(src)) {
715 d_dn = denom.relErrDown(src);
716 d_up = denom.relErrUp(src);
717 }
718 const double new_dn = fabs(newVal) * std::sqrt(n_dn*n_dn + d_dn*d_dn);
719 const double new_up = fabs(newVal) * std::sqrt(n_up*n_up + d_up*d_up);
720 rtn.setErr({-new_dn,new_up}, src);
721 }
722 else {
723 // treat as correlated between AOs:
724 // work out correlated ratio: R+dR = (N+dN)/(D+dD)
725 double n_dn = numer.val(), n_up = numer.val();
726 if (numer.hasSource(src)) {
727 n_dn += numer.errDown(src);
728 n_up += numer.errUp(src);
729 }
730 double d_dn = denom.val(), d_up = denom.val();
731 if (denom.hasSource(src)) {
732 d_dn += denom.errDown(src);
733 d_up += denom.errUp(src);
734 }
735 double new_dn = std::numeric_limits<double>::quiet_NaN();
736 double new_up = std::numeric_limits<double>::quiet_NaN();
737 if (d_dn) new_dn = n_dn / d_dn - newVal;
738 if (d_up) new_up = n_up / d_up - newVal;
739 rtn.setErr({new_dn, new_up}, src);
740 }
741 }
742
743 return rtn;
744 }
A point estimate (base class for the Estimate)
Definition Estimate.h:29
void setErr(const std::pair< double, double > &err, const std::string &source="")
Set a signed uncertainty component.
Definition Estimate.h:165
std::vector< std::string > sources() const noexcept
The list of error source names.
Definition Estimate.h:487
double errDown(const std::string &source="") const
The signed error due to the systematic downward variation.
Definition Estimate.h:283
double relErrUp(const std::string &source="") const
The relative positive error with respect to the central value.
Definition Estimate.h:322
double errUp(const std::string &source="") const
The signed error due to the systematic upward variation.
Definition Estimate.h:288
double val() const noexcept
The central value.
Definition Estimate.h:249
void setVal(const double val) noexcept
Alias for setValue.
Definition Estimate.h:162
double relErrDown(const std::string &source="") const
The relative negative error with respect to the central value.
Definition Estimate.h:317
bool hasSource(const std::string &key) const noexcept
Returns true/false if the error map contains key.
Definition Estimate.h:494

References YODA::Estimate::errDown(), YODA::Estimate::errUp(), YODA::Estimate::hasSource(), YODA::Estimate::relErrDown(), YODA::Estimate::relErrUp(), YODA::Estimate::setErr(), YODA::Estimate::setVal(), YODA::Estimate::sources(), and YODA::Estimate::val().

◆ divide() [6/6]

Estimate0D YODA::divide ( const Estimate0D numer,
const Estimate0D denom,
const std::string &  pat_uncorr = "^stat|^uncor" 
)
inline

Divide two Estimate0D objects.

Definition at line 326 of file Estimate0D.h.

327 {
328 Estimate0D rtn = divide(static_cast<const Estimate&>(numer),
329 static_cast<const Estimate&>(denom), pat_uncorr);
330 if (rtn.hasAnnotation("ScaledBy")) rtn.rmAnnotation("ScaledBy");
331 if (numer.path() == denom.path()) rtn.setPath(numer.path());
332 return rtn;
333 }
BinnedEstimate< AxisT... > divide(const BinnedDbn< DbnN, AxisT... > &numer, const BinnedDbn< DbnN, AxisT... > &denom)
Divide two BinnedDbn objects.
Definition BinnedDbn.h:1112

References divide(), YODA::AnalysisObject::hasAnnotation(), YODA::AnalysisObject::path(), YODA::AnalysisObject::rmAnnotation(), and YODA::AnalysisObject::setPath().

◆ efficiency() [1/5]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::efficiency ( const BinnedDbn< DbnN, AxisT... > &  accepted,
const BinnedDbn< DbnN, AxisT... > &  total 
)
inline

Calculate a binned efficiency ratio of two BinnedDbn objects.

Note
An efficiency is not the same thing as a standard division of two BinnedDbn objects: the errors are treated as correlated via binomial statistics.
Note
Neither effNumEntries nor sumW are guaranteed to satisfy num <= den for general weights!

Definition at line 1182 of file BinnedDbn.h.

1182 {
1183
1184 if (accepted != total) {
1185 throw BinningError("Arithmetic operation requires compatible binning!");
1186 }
1187
1188 BinnedEstimate<AxisT...> rtn = divide(accepted, total);
1189
1190 for (const auto& b_acc : accepted.bins(true, true)) {
1191 const auto& b_tot = total.bin(b_acc.index());
1192 auto& b_rtn = rtn.bin(b_acc.index());
1193
1194 // Check that the numerator is consistent with being a subset of the denominator
1196 if (b_acc.numEntries() > b_tot.numEntries())
1197 throw UserError("Attempt to calculate an efficiency when the numerator is not a subset of the denominator: "
1198 + Utils::toStr(b_acc.numEntries()) + " entries / " + Utils::toStr(b_tot.numEntries()) + " entries");
1199
1200 // If no entries on the denominator, set eff = err = 0 and move to the next bin
1201 double eff = std::numeric_limits<double>::quiet_NaN();
1202 double err = std::numeric_limits<double>::quiet_NaN();
1203 if (!isZero(b_tot.effNumEntries())) {
1204 eff = b_rtn.val();
1205 err = sqrt(fabs( add((1.0-2.0*eff)*b_acc.sumW2(), sqr(eff)*b_tot.sumW2()) / sqr(b_tot.sumW()) ));
1206 }
1207 b_rtn.setErr({-err, err}); // @todo put "stats" as source?
1208 }
1209 return rtn;
1210 }

References add(), YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), divide(), isZero(), and sqr().

Referenced by efficiency(), and efficiency().

◆ efficiency() [2/5]

template<typename... AxisT>
BinnedEstimate< AxisT... > YODA::efficiency ( const BinnedEstimate< AxisT... > &  accepted,
const BinnedEstimate< AxisT... > &  total,
const std::string &  pat_uncorr = "^stat|^uncor" 
)
inline

Calculate a binned efficiency ratio of two BinnedEstimate objects.

Note
An efficiency is not the same thing as a standard division of two BinnedEstimate objects: the errors are treated as correlated via binomial statistics.

Definition at line 1163 of file BinnedEstimate.h.

1164 {
1165
1166 if (accepted != total) {
1167 throw BinningError("Arithmetic operation requires compatible binning!");
1168 }
1169
1170 BinnedEstimate<AxisT...> rtn(accepted.binning());
1171
1172 for (const auto& b_acc : accepted.bins(true, true)) {
1173 Estimate est;
1174 const size_t idx = b_acc.index();
1175 try {
1176 est = efficiency(b_acc, total.bin(idx), pat_uncorr);
1177 } catch (const UserError& e) {
1178 //
1179 }
1180 rtn.bin(idx).set(est);
1181 }
1182 return rtn;
1183 }

References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::binning(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), and efficiency().

◆ efficiency() [3/5]

Estimate0D YODA::efficiency ( const Counter accepted,
const Counter total 
)

Calculate an efficiency ratio of two counters.

Todo:
Add divide functions/operators on pointers

Note that an efficiency is not the same thing as a standard division of two histograms: the errors must be treated as correlated

Todo:
Add skipnullpts extra optional arg
Todo:
Provide optional alt behaviours to fill with NaN or remove the invalid point, or...
Todo:
Todo:
Or throw a LowStatsError exception if h.effNumEntries() (or sumW()?) == 0?
Todo:
Provide optional alt behaviours to fill with NaN or remove the invalid point, or...
Todo:
Todo:
Or throw a LowStatsError exception if h.effNumEntries() (or sumW()?) == 0?

Definition at line 34 of file Counter.cc.

34 {
35 Estimate0D tmp = divide(accepted, total);
36
37 // Check that the numerator is consistent with being a subset of the denominator (NOT effNumEntries here!)
38 if (accepted.numEntries() > total.numEntries() || accepted.sumW() > total.sumW())
39 throw UserError("Attempt to calculate an efficiency when the numerator is not a subset of the denominator");
40
41 // If no entries on the denominator, set eff = err = 0 and move to the next bin
44 double eff = std::numeric_limits<double>::quiet_NaN();
45 double err = std::numeric_limits<double>::quiet_NaN();
46 if (total.sumW() != 0) {
47 eff = accepted.sumW() / total.sumW(); //< Actually this is already calculated by the division...
48 err = sqrt(abs( ((1-2*eff)*accepted.sumW2() + sqr(eff)*total.sumW2()) / sqr(total.sumW()) ));
49 }
50
51 tmp.set(eff, {-err, err});
52 return tmp;
53 }
double sumW2(bool=false) const
Get the sum of squared weights.
Definition Counter.h:186
double numEntries(bool=false) const
Get the number of fills.
Definition Counter.h:177
double sumW(bool=false) const
Get the sum of weights.
Definition Counter.h:183
Error for problems introduced outside YODA, to put it nicely.
Definition Exceptions.h:86

References divide(), YODA::Counter::numEntries(), YODA::Estimate::set(), sqr(), YODA::Counter::sumW(), and YODA::Counter::sumW2().

◆ efficiency() [4/5]

Estimate YODA::efficiency ( const Estimate accepted,
const Estimate total,
const std::string &  pat_uncorr = "^stat|^uncor" 
)
inline

Divide two Estimate objects using binomial statistics.

Check that the numerator is consistent with being a subset of the denominator

Todo:
Need to check that bins are all positive? Integral could be zero due to large +ve/-ve in different bins :O

Definition at line 767 of file Estimate.h.

768 {
769
773 const double acc_val = accepted.val();
774 const double tot_val = total.val();
775 if (acc_val > tot_val)
776 throw UserError("Attempt to calculate an efficiency when the numerator is not a subset of the denominator: "
777 + Utils::toStr(acc_val) + " / " + Utils::toStr(tot_val));
778
779 Estimate rtn = divide(accepted, total, pat_uncorr);
780
781 // get error sources
782 std::vector<std::string> sources = accepted.sources();
783 std::vector<std::string> tmp = total.sources();
784 sources.insert(std::end(sources),
785 std::make_move_iterator(std::begin(tmp)),
786 std::make_move_iterator(std::end(tmp)));
787 std::sort(sources.begin(), sources.end());
788 sources.erase( std::unique(sources.begin(), sources.end()), sources.end() );
789
790 // set binomial error for uncorrelated error sources
791 std::smatch match;
792 const double eff = rtn.val();
793 const std::regex re(pat_uncorr, std::regex_constants::icase);
794 for (const std::string& src : sources) {
795 double err = std::numeric_limits<double>::quiet_NaN();
796 if (!tot_val) {
797 rtn.setErr({-err,err}, src);
798 continue;
799 }
800 else if (std::regex_search(src, match, re)) {
801 const double acc_err = accepted.relTotalErrAvg();
802 const double tot_err = total.totalErrAvg();
803 err = sqrt(std::abs( add((1.0-2.0*eff)*sqr(acc_err), sqr(eff)*sqr(tot_err)) / sqr(tot_val) ));
804 rtn.setErr({-err,err}, src);
805 continue;
806 }
807 }
808
809 return rtn;
810 }
double totalErrAvg(const std::string &pat_match="") const
The average of the total downward/upward uncertainty shifts, which are taken to be the signed quadrat...
Definition Estimate.h:429
double relTotalErrAvg(const std::string &pat_match="") const noexcept
The relative average of the quad-sum-based total downward/upward uncertainty components.
Definition Estimate.h:476

References add(), divide(), YODA::Estimate::relTotalErrAvg(), YODA::Estimate::setErr(), YODA::Estimate::sources(), sqr(), YODA::Estimate::totalErrAvg(), and YODA::Estimate::val().

◆ efficiency() [5/5]

Estimate0D YODA::efficiency ( const Estimate0D accepted,
const Estimate0D total,
const std::string &  pat_uncorr = "^stat|^uncor" 
)
inline

Divide two Estimate0D objects using binomial statistics.

Definition at line 356 of file Estimate0D.h.

357 {
358 Estimate0D rtn = efficiency(static_cast<const Estimate&>(accepted),
359 static_cast<const Estimate&>(total), pat_uncorr);
360 if (rtn.hasAnnotation("ScaledBy")) rtn.rmAnnotation("ScaledBy");
361 if (accepted.path() == total.path()) rtn.setPath(total.path());
362 return rtn;
363 }
BinnedEstimate< AxisT... > efficiency(const BinnedDbn< DbnN, AxisT... > &accepted, const BinnedDbn< DbnN, AxisT... > &total)
Calculate a binned efficiency ratio of two BinnedDbn objects.
Definition BinnedDbn.h:1182

References efficiency(), YODA::AnalysisObject::hasAnnotation(), YODA::AnalysisObject::path(), YODA::AnalysisObject::rmAnnotation(), and YODA::AnalysisObject::setPath().

◆ effNumEntries() [1/2]

double YODA::effNumEntries ( const double  sumW,
const double  sumW2 
)
inline

Calculate the effective number of entries of a sample.

Definition at line 381 of file MathUtils.h.

381 {
382 if (isZero(sumW2)) return 0;
383 return sqr(sumW) / sumW2;
384 }

References isZero(), and sqr().

Referenced by effNumEntries(), YODA::DbnBase< N >::relErrW(), YODA::DbnBase< N >::relStdErr(), RMS(), stdErr(), stdErr(), and variance().

◆ effNumEntries() [2/2]

double YODA::effNumEntries ( const std::vector< double > &  weights)
inline

Calculate the effective number of entries of a sample.

Definition at line 387 of file MathUtils.h.

387 {
388 double sumW = 0.0, sumW2 = 0.0;
389 for (size_t i = 0; i < weights.size(); ++i) {
390 sumW += weights[i];
391 sumW2 += sqr(weights[i]);
392 }
393 return effNumEntries(sumW, sumW2);
394 }

References effNumEntries(), and sqr().

◆ fuzzyEquals() [1/2]

template<typename N1 , typename N2 >
std::enable_if_t< std::is_arithmetic_v< N1 > &&std::is_arithmetic_v< N2 > &&(std::is_floating_point_v< N1 >||std::is_floating_point_v< N2 >), bool > YODA::fuzzyEquals ( N1  a,
N2  b,
double  tolerance = 1e-5 
)
inline

Compare two numbers for equality with a degree of fuzziness.

This version for floating point types (if any argument is FP) has a degree of fuzziness expressed by the fractional tolerance parameter, for floating point safety.

Definition at line 96 of file MathUtils.h.

96 {
97 const double absavg = (std::abs(a) + std::abs(b))/2.0;
98 const double absdiff = std::abs(a - b);
99 const bool rtn = (isZero(a) && isZero(b)) || absdiff < tolerance*absavg;
100 return rtn;
101 }

References isZero().

Referenced by YODA::Axis< T, isCAxis< T > >::Axis(), fuzzyGtrEquals(), fuzzyLessEquals(), YODA::Axis< T, isCAxis< T > >::hasSameEdges(), operator==(), and subtract().

◆ fuzzyEquals() [2/2]

template<typename N1 , typename N2 >
std::enable_if_t< std::is_integral_v< N1 > &&std::is_integral_v< N2 >, bool > YODA::fuzzyEquals ( N1  a,
N2  b,
double   
)
inline

Compare two numbers for equality with a degree of fuzziness.

Simpler SFINAE template specialisation for integers, since there is no FP precision issue.

Definition at line 110 of file MathUtils.h.

110 { //< NB. unused tolerance parameter for ints, still needs a default value!
111 return a == b;
112 }

◆ fuzzyGtrEquals()

template<typename N1 , typename N2 >
std::enable_if_t< std::is_arithmetic_v< N1 > &&std::is_arithmetic_v< N2 >, bool > YODA::fuzzyGtrEquals ( N1  a,
N2  b,
double  tolerance = 1e-5 
)
inline

Compare two numbers for >= with a degree of fuzziness.

The tolerance parameter on the equality test is as for fuzzyEquals.

Definition at line 125 of file MathUtils.h.

125 {
126 return a > b || fuzzyEquals(a, b, tolerance);
127 }
std::enable_if_t< std::is_arithmetic_v< N1 > &&std::is_arithmetic_v< N2 > &&(std::is_floating_point_v< N1 >||std::is_floating_point_v< N2 >), bool > fuzzyEquals(N1 a, N2 b, double tolerance=1e-5)
Compare two numbers for equality with a degree of fuzziness.
Definition MathUtils.h:96

References fuzzyEquals().

Referenced by YODA::Axis< T, isCAxis< T > >::Axis().

◆ fuzzyLessEquals()

template<typename N1 , typename N2 >
std::enable_if_t< std::is_arithmetic_v< N1 > &&std::is_arithmetic_v< N2 >, bool > YODA::fuzzyLessEquals ( N1  a,
N2  b,
double  tolerance = 1e-5 
)
inline

Compare two floating point numbers for <= with a degree of fuzziness.

The tolerance parameter on the equality test is as for fuzzyEquals.

Definition at line 135 of file MathUtils.h.

135 {
136 return a < b || fuzzyEquals(a, b, tolerance);
137 }

References fuzzyEquals().

Referenced by variance().

◆ getDataPath()

string YODA::getDataPath ( )

Get the path to the installed share/YODA/ data directory.

Definition at line 26 of file Paths.cc.

26 {
27 BrInitError error;
28 br_init_lib(&error);
29 char* temp = br_find_data_dir(DEFAULTDATADIR);
30 const string sharedir(temp);
31 free(temp);
32 return sharedir + "/YODA";
33 }
#define br_find_data_dir
Definition binreloc.h:47
BrInitError
Definition binreloc.h:22
#define br_init_lib
Definition binreloc.h:41

References br_find_data_dir, and br_init_lib.

Referenced by getYodaDataPath().

◆ getLibPath()

string YODA::getLibPath ( )

Get the path to the directory containing libYODA.

Definition at line 17 of file Paths.cc.

17 {
18 BrInitError error;
19 br_init_lib(&error);
20 char* temp = br_find_lib_dir(DEFAULTLIBDIR);
21 const string libdir(temp);
22 free(temp);
23 return libdir;
24 }
#define br_find_lib_dir
Definition binreloc.h:49

References br_find_lib_dir, and br_init_lib.

◆ getYodaDataPath()

vector< string > YODA::getYodaDataPath ( )

YODA data paths.

Definition at line 35 of file Paths.cc.

35 {
36 vector<string> dirs;
37 // Use the YODA data path variable if set...
38 const char* env = getenv("YODA_DATA_PATH");
39 if (env) dirs = Utils::pathsplit(env);
40 // ... then, unless the path ends in :: ...
41 if (!env || strlen(env) < 2 || string(env).substr(strlen(env)-2) != "::") {
42 // ... fall back to the YODA data install path
43 dirs.push_back(getDataPath());
44 }
45 return dirs;
46 }
std::string getDataPath()
Get the path to the installed share/YODA/ data directory.
Definition Paths.cc:26

References getDataPath().

◆ index_between()

template<typename NUM >
int YODA::index_between ( const NUM &  val,
const std::vector< NUM > &  binedges 
)
inline

Return the bin index of the given value, val, given a vector of bin edges.

NB. The binedges vector must be sorted

Definition at line 361 of file MathUtils.h.

361 {
362 if (!inRange(val, binedges.front(), binedges.back())) return -1; //< Out of histo range
363 int index = -1;
364 for (size_t i = 1; i < binedges.size(); ++i) {
365 if (val < binedges[i]) {
366 index = i-1;
367 break;
368 }
369 }
370 assert(inRange(index, -1, binedges.size()-1));
371 return index;
372 }
bool inRange(NUM value, NUM low, NUM high, RangeBoundary lowbound=CLOSED, RangeBoundary highbound=OPEN)
Determine if value is in the range low to high, for floating point numbers.
Definition MathUtils.h:164

References inRange().

◆ inRange() [1/4]

bool YODA::inRange ( int  value,
int  low,
int  high,
RangeBoundary  lowbound = CLOSED,
RangeBoundary  highbound = CLOSED 
)
inline

Determine if value is in the range low to high, for integer types.

Interval boundary types are defined by lowbound and highbound.

Todo:
Optimise to one-line at compile time?

Definition at line 189 of file MathUtils.h.

190 {
191 if (lowbound == OPEN && highbound == OPEN) {
192 return (value > low && value < high);
193 } else if (lowbound == OPEN && highbound == CLOSED) {
194 return (value > low && value <= high);
195 } else if (lowbound == CLOSED && highbound == OPEN) {
196 return (value >= low && value < high);
197 } else { // if (lowbound == CLOSED && highbound == CLOSED) {
198 return (value >= low && value <= high);
199 }
200 }

References CLOSED, and OPEN.

◆ inRange() [2/4]

bool YODA::inRange ( int  value,
std::pair< int, int >  lowhigh,
RangeBoundary  lowbound = CLOSED,
RangeBoundary  highbound = OPEN 
)
inline

Alternative version of inRange for ints, which accepts a pair for the range arguments.

Definition at line 203 of file MathUtils.h.

204 {
205 return inRange(value, lowhigh.first, lowhigh.second, lowbound, highbound);
206 }

References inRange().

◆ inRange() [3/4]

template<typename NUM >
bool YODA::inRange ( NUM  value,
NUM  low,
NUM  high,
RangeBoundary  lowbound = CLOSED,
RangeBoundary  highbound = OPEN 
)
inline

Determine if value is in the range low to high, for floating point numbers.

Interval boundary types are defined by lowbound and highbound.

Todo:
Optimise to one-line at compile time?

Definition at line 164 of file MathUtils.h.

165 {
166 if (lowbound == OPEN && highbound == OPEN) {
167 return (value > low && value < high);
168 } else if (lowbound == OPEN && highbound == CLOSED) {
169 return (value > low && value <= high);
170 } else if (lowbound == CLOSED && highbound == OPEN) {
171 return (value >= low && value < high);
172 } else { // if (lowbound == CLOSED && highbound == CLOSED) {
173 return (value >= low && value <= high);
174 }
175 }

References CLOSED, and OPEN.

Referenced by index_between(), inRange(), and inRange().

◆ inRange() [4/4]

template<typename NUM >
bool YODA::inRange ( NUM  value,
std::pair< NUM, NUM >  lowhigh,
RangeBoundary  lowbound = CLOSED,
RangeBoundary  highbound = OPEN 
)
inline

Alternative version of inRange for doubles, which accepts a pair for the range arguments.

Definition at line 179 of file MathUtils.h.

180 {
181 return inRange(value, lowhigh.first, lowhigh.second, lowbound, highbound);
182 }

References inRange().

◆ isNaN()

template<typename NUM >
std::enable_if_t< std::is_floating_point_v< NUM >, bool > YODA::isNaN ( NUM  val)
inline

Check if a number is NaN.

Definition at line 80 of file MathUtils.h.

80{ return std::isnan(val); }

◆ isZero() [1/2]

template<typename NUM >
std::enable_if_t< std::is_floating_point_v< NUM >, bool > YODA::isZero ( NUM  val,
double  tolerance = 1e-5 
)
inline

Compare a number to zero.

This version for floating point types has a degree of fuzziness expressed by the absolute tolerance parameter, for floating point safety.

Definition at line 63 of file MathUtils.h.

63 {
64 return fabs(val) < tolerance;
65 }

Referenced by divide(), efficiency(), effNumEntries(), fuzzyEquals(), and sign().

◆ isZero() [2/2]

template<typename NUM >
std::enable_if_t< std::is_integral_v< NUM >, bool > YODA::isZero ( NUM  val,
double  = 1e-5 
)
inline

Compare a number to zero.

SFINAE template specialisation for integers, since there is no FP precision issue.

Definition at line 73 of file MathUtils.h.

73 {
74 return val==0;
75 }

◆ linspace()

std::vector< double > YODA::linspace ( size_t  nbins,
double  xmin,
double  xmax,
bool  include_end = true 
)
inline

Make a list of nbins + 1 values uniformly spaced between xmin and xmax inclusive.

Note
The arg ordering and the meaning of the nbins variable is "histogram-like", as opposed to the Numpy/Matlab version.

Definition at line 267 of file MathUtils.h.

267 {
268 if (xmax < xmin) throw RangeError("xmax should not be smaller than xmin!");
269 if (nbins == 0) throw RangeError("Requested number of bins is 0!");
270 std::vector<double> rtn;
271 const double interval = (xmax-xmin)/static_cast<double>(nbins);
272 for (size_t i = 0; i < nbins; ++i) {
273 rtn.push_back(xmin + i*interval);
274 }
275 assert(rtn.size() == nbins);
276 if (include_end) rtn.push_back(xmax); // exact xmax, not result of n * interval
277 return rtn;
278 }
Error for e.g. use of invalid bin ranges.
Definition Exceptions.h:34

Referenced by logspace(), and pdfspace().

◆ logspace()

std::vector< double > YODA::logspace ( size_t  nbins,
double  xmin,
double  xmax,
bool  include_end = true 
)
inline

Make a list of nbins + 1 values uniformly spaced in log(x) between xmin and xmax inclusive.

Note
The arg ordering and the meaning of the nbins variable is "histogram-like", as opposed to the Numpy/Matlab version, and the xmin and xmax arguments are expressed in "normal" space, rather than as the logarithms of the xmin/xmax values as in Numpy/Matlab.

Definition at line 286 of file MathUtils.h.

286 {
287 if (xmax < xmin) throw RangeError("xmax should not be smaller than xmin!");
288 if (xmin < 0) throw RangeError("xmin should not be negative!");
289 if (nbins == 0) throw RangeError("Requested number of bins is 0!");
290 const double logxmin = std::log(xmin);
291 const double logxmax = std::log(xmax);
292 const std::vector<double> logvals = linspace(nbins, logxmin, logxmax);
293 assert(logvals.size() == nbins+1);
294 std::vector<double> rtn; rtn.reserve(logvals.size());
295 rtn.push_back(xmin);
296 for (size_t i = 1; i < logvals.size()-1; ++i) {
297 rtn.push_back(std::exp(logvals[i]));
298 }
299 assert(rtn.size() == nbins);
300 if (include_end) rtn.push_back(xmax);
301 return rtn;
302 }
std::vector< double > linspace(size_t nbins, double xmin, double xmax, bool include_end=true)
Make a list of nbins + 1 values uniformly spaced between xmin and xmax inclusive.
Definition MathUtils.h:267

References linspace().

◆ mean() [1/3]

double YODA::mean ( const double  sumWX,
const double  sumW 
)
inline

Calculate the weighted mean of a sample.

Definition at line 406 of file MathUtils.h.

406 {
407 return sumW? sumWX / sumW : std::numeric_limits<double>::quiet_NaN();
408 }

◆ mean() [2/3]

double YODA::mean ( const std::vector< double > &  sample,
const std::vector< double > &  weights 
)
inline

Calculate the weighted mean of a sample.

Definition at line 411 of file MathUtils.h.

412 {
413 if (sample.size() != weights.size()) throw RangeError("Inputs should have equal length!");
414 double sumWX = 0., sumW = 0.;
415 for (size_t i = 0; i < sample.size(); ++i) {
416 sumW += weights[i];
417 sumWX += weights[i]*sample[i];
418 }
419 return mean(sumWX, sumW);
420 }

References mean().

◆ mean() [3/3]

double YODA::mean ( const std::vector< int > &  sample)
inline

Calculate the mean of a sample.

Definition at line 397 of file MathUtils.h.

397 {
398 double mean = 0.0;
399 for (size_t i=0; i<sample.size(); ++i) {
400 mean += sample[i];
401 }
402 return mean/sample.size();
403 }

References mean().

Referenced by covariance(), YODA::DbnBase< N >::mean(), mean(), mean(), YODA::DbnBase< N >::relStdErr(), YODA::XDbnMixin< Derived >::xMean(), YODA::XStatsMixin< Derived >::xMean(), YODA::YDbnMixin< Derived >::yMean(), YODA::YStatsMixin< Derived >::yMean(), zipProfiles(), YODA::ZDbnMixin< Derived >::zMean(), and YODA::ZStatsMixin< Derived >::zMean().

◆ mkAxisConfig()

template<typename A , typename... As>
std::string YODA::mkAxisConfig ( )

Helper function to construct the axis config.

Definition at line 58 of file BinningUtils.h.

58 {
59 return (std::string(TypeID<A>::name()) + ... + TypeID<As>::name());
60 }
Returns the type ID as a character sequence.

◆ mkIntegral()

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::mkIntegral ( const BinnedDbn< DbnN, AxisT... > &  histo,
const bool  includeOverflows = true 
)
inline

Convert a BinnedDbn to a BinnedEstimate representing the integral of the histogram.

Note
The integral histo errors are calculated as sqrt(binvalue), as if they are uncorrelated. This is not in general true for integral histograms, so if you need accurate errors you should explicitly monitor bin-to-bin correlations.

The includeunderflow param chooses whether the underflow bin is included in the integral numbers as an offset.

Definition at line 1231 of file BinnedDbn.h.

1231 {
1232
1233 BinnedEstimate<AxisT...> rtn = histo.mkEstimate();
1234
1235 double sumW = 0.0, sumW2 = 0.0;
1236 for (const auto& b : histo.bins(includeOverflows)) {
1237 sumW += b.sumW();
1238 sumW2 += b.sumW2();
1239 const double e = sqrt(sumW2);
1240 rtn.bin(b.index()).set(sumW, {-e, e});
1241 }
1242
1243 return rtn;
1244 }
Forward declaration.

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

Referenced by mkIntegralEff().

◆ mkIntegralEff()

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::mkIntegralEff ( const BinnedDbn< DbnN, AxisT... > &  histo,
const bool  includeOverflows = true 
)
inline

Convert a BinnedDbn to a BinnedEstimate where each bin is a fraction of the total.

Note
This sounds weird: let's explain a bit more! Sometimes we want to take a histo h, make an integral histogram H from it, and then divide H by the total integral of h, such that every bin in H represents the cumulative efficiency of that bin as a fraction of the total. I.e. an integral histo, scaled by 1/total_integral and with binomial errors.

The includeunderflow param behaves as for toIntegral, and applies to both the initial integration and the integral used for the scaling. The includeoverflow param applies only to obtaining the scaling factor.

Todo:
Or throw a LowStatsError exception if h.effNumEntries() == 0?
Todo:
Todo:
Provide optional alt behaviours
Todo:
Todo:
Need to check that bins are all positive? Integral could be zero due to large +ve/-ve in different bins :O

Definition at line 1260 of file BinnedDbn.h.

1260 {
1261
1262 BinnedEstimate<AxisT...> rtn = mkIntegral(histo, includeOverflows);
1263 const double integral = histo.integral(includeOverflows);
1264
1265 // If the integral is empty, the (integrated) efficiency values may as well all be zero, so return here
1269 if (!integral) return rtn;
1270
1271 const double integral_err = histo.integralError(includeOverflows);
1272 for (const auto& b : rtn.bins(includeOverflows)) {
1273 const double eff = b.val() / integral;
1274 const double err = sqrt(std::abs( ((1-2*eff)*sqr(b.relTotalErrAvg()) + sqr(eff)*sqr(integral_err)) / sqr(integral) ));
1275 b.set(eff, {-err,err});
1276 }
1277
1278 return rtn;
1279 }
double integralError(const bool includeOverflows=true) const noexcept
Get the total volume error of the histogram.
Definition BinnedDbn.h:468
double integral(const bool includeOverflows=true) const noexcept
Get the total volume of the histogram.
Definition BinnedDbn.h:463
BinnedEstimate< AxisT... > mkIntegral(const BinnedDbn< DbnN, AxisT... > &histo, const bool includeOverflows=true)
Convert a BinnedDbn to a BinnedEstimate representing the integral of the histogram.
Definition BinnedDbn.h:1231

References YODA::DbnStorage< DbnN, AxisT >::integral(), YODA::DbnStorage< DbnN, AxisT >::integralError(), mkIntegral(), and sqr().

◆ mkReader()

Reader & YODA::mkReader ( const std::string &  format_name)

Factory function to make a reader object by format name or a filename.

<

Todo:
Improve/remove... .ydat?

<

Todo:
Improve/remove... .ydat?

Definition at line 15 of file Reader.cc.

15 {
16 // Determine the format from the string (a file or file extension)
17 const size_t lastdot = name.find_last_of(".");
18 string fmt = Utils::toLower(lastdot == string::npos ? name : name.substr(lastdot+1));
19 if (fmt == "gz") {
20 #ifndef HAVE_LIBZ
21 throw UserError("YODA was compiled without zlib support: can't read " + name);
22 #endif
23 const size_t lastbutonedot = (lastdot == string::npos) ? string::npos : name.find_last_of(".", lastdot-1);
24 fmt = Utils::toLower(lastbutonedot == string::npos ? name : name.substr(lastbutonedot+1));
25 }
26 // Create the appropriate Reader
27 if (Utils::startswith(fmt, "yoda")) return ReaderYODA::create();
28 if (Utils::startswith(fmt, "dat" )) return ReaderFLAT::create();
29 if (Utils::startswith(fmt, "flat")) return ReaderFLAT::create();
30 throw UserError("Format cannot be identified from string '" + name + "'");
31 }

References YODA::ReaderFLAT::create(), and YODA::ReaderYODA::create().

Referenced by read(), and read().

◆ mkTypeString() [1/2]

template<ssize_t DbnN, typename A , typename... As>
std::string YODA::mkTypeString ( )

Helper function to construct the BinnedDbn and BinnedEstimate type names.

Definition at line 65 of file BinningUtils.h.

65 {
66
67 constexpr size_t N = sizeof...(As)+1;
68
69 if constexpr (all_CAxes<A, As...>::value) {
70 if constexpr (DbnN < 0) {
71 return "Estimate"+std::to_string(N)+"D";
72 }
73 if constexpr (DbnN == N+1) {
74 return "Profile"+std::to_string(N)+"D";
75 }
76 if constexpr (DbnN == N) {
77 return "Histo"+std::to_string(N)+"D";
78 }
79 }
80
81 std::string type = "Binned";
82 if (DbnN < 0) type += "Estimate";
83 else if (DbnN == N) type += "Histo";
84 else if (DbnN == N+1) type += "Profile";
85 else type += "Dbn" + std::to_string(DbnN);
86
87 std::string axes = (TypeID<A>::name() + ... + (std::string{","} + TypeID<As>::name()));
88
89 return (type + "<" + axes + ">");
90 }
typename std::conjunction< std::is_floating_point< EdgeT >... > all_CAxes

References YODA::TypeID< T >::name().

Referenced by mkTypeString().

◆ mkTypeString() [2/2]

template<typename A , typename... As>
std::string YODA::mkTypeString ( )

Same as above, but for non-Dbn bin contents.

Definition at line 94 of file BinningUtils.h.

94{ return mkTypeString<-1, A, As...>(); }
std::string mkTypeString()
Helper function to construct the BinnedDbn and BinnedEstimate type names.

References mkTypeString().

◆ mkWriter()

Writer & YODA::mkWriter ( const std::string &  format_name)

Factory function to make a writer object by format name or a filename.

<

Todo:
Improve/remove... .ydat?

<

Todo:
Improve/remove... .ydat?

Definition at line 25 of file Writer.cc.

25 {
26 // Determine the format from the string (a file or file extension)
27 const size_t lastdot = name.find_last_of(".");
28 string fmt = Utils::toLower(lastdot == string::npos ? name : name.substr(lastdot+1));
29 const bool compress = (fmt == "gz");
30 //cout << "***" << compress << endl;
31 if (compress) {
32 #ifndef HAVE_LIBZ
33 throw UserError("YODA was compiled without zlib support: can't write " + name);
34 #endif
35 const size_t lastbutonedot = (lastdot == string::npos) ? string::npos : name.find_last_of(".", lastdot-1);
36 fmt = Utils::toLower(lastbutonedot == string::npos ? name : name.substr(lastbutonedot+1));
37 }
38 // Create the appropriate Writer
39 Writer* w = nullptr;
40 if (Utils::startswith(fmt, "yoda")) w = &WriterYODA::create();
41 if (Utils::startswith(fmt, "dat" )) w = &WriterFLAT::create();
42 if (Utils::startswith(fmt, "flat")) w = &WriterFLAT::create();
43 if (!w) throw UserError("Format cannot be identified from string '" + name + "'");
44 w->useCompression(compress);
45 return *w;
46 }

References YODA::WriterFLAT::create(), YODA::WriterYODA::create(), and YODA::Writer::useCompression().

Referenced by write(), write(), write(), write(), write(), and write().

◆ naiveChi2()

double YODA::naiveChi2 ( const std::vector< double > &  sample1,
const std::vector< double > &  sample2,
const std::vector< double > &  s1errors = std::vector<double>{},
const std::vector< double > &  s2errors = std::vector<double>{} 
)
inline

Calculate the error-weighted chi2 statistic between two samples.

Note
This calculation is rather naive as it neglects the error breakdowns that may be available for the curves being compared. More sophisticated comparisons will require a separate analysis based on the Estimate objects utilising the full covariance information.

Definition at line 549 of file MathUtils.h.

550 {},
551 const std::vector<double>& s2errors = std::vector<double>{}) {
552 if (sample1.size() != sample2.size()) {
553 throw RangeError("Inputs should have equal length!");
554 }
555 if (s1errors.size() && sample1.size() != s1errors.size()) {
556 throw RangeError("Inputs should have equal length!");
557 }
558 if (s2errors.size() && sample2.size() != s2errors.size()) {
559 throw RangeError("Inputs should have equal length!");
560 }
561 const size_t N = sample1.size();
562 double chi2 = 0.0;
563 for (size_t i = 0; i < N; ++i) {
564 double temp = sqr(sample1[i] - sample2[i]);
565 if (s1errors.size()) {
566 temp /= sqr(s1errors[i]) + sqr(s2errors[i]);
567 }
568 chi2 += temp;
569 }
570 return chi2;
571 }

◆ naiveChi2reduced()

double YODA::naiveChi2reduced ( const std::vector< double > &  sample1,
const std::vector< double > &  sample2,
const std::vector< double > &  s1errors = std::vector<double>{},
const std::vector< double > &  s2errors = std::vector<double>{} 
)
inline

Calculate the error-weighted reduced chi2 statistic between two samples.

Note
This calculation is rather naive as it neglects the error breakdowns that may be available for the curves being compared. More sophisticated comparisons will require a separate analysis based on the Estimate objects utilising the full covariance information.

Definition at line 579 of file MathUtils.h.

580 {},
581 const std::vector<double>& s2errors = std::vector<double>{}) {
582 if (sample1.empty()) throw RangeError("Inputs should not have 0 length!");
583 return naiveChi2(sample1, sample2, s1errors, s2errors)/sample1.size();
584 }
double naiveChi2(const std::vector< double > &sample1, const std::vector< double > &sample2, const std::vector< double > &s1errors=std::vector< double >{}, const std::vector< double > &s2errors=std::vector< double >{})
Calculate the error-weighted chi2 statistic between two samples.
Definition MathUtils.h:549

◆ notNaN()

template<typename NUM >
std::enable_if_t< std::is_floating_point_v< NUM >, bool > YODA::notNaN ( NUM  val)
inline

Check if a number is non-NaN.

Definition at line 85 of file MathUtils.h.

85{ return !std::isnan(val); }

◆ nullifyIfDiscCoord() [1/2]

template<typename CoordT >
double YODA::nullifyIfDiscCoord ( CoordT &&  ,
std::false_type  ,
double  null = 0.0 
)

Nullifies coordinate if it is discrete.

Definition at line 19 of file Binning.h.

19 {
20 return null;
21 }

Referenced by containsNan().

◆ nullifyIfDiscCoord() [2/2]

template<typename CoordT >
double YODA::nullifyIfDiscCoord ( CoordT &&  coord,
std::true_type  ,
double  = 0.0 
)

Definition at line 24 of file Binning.h.

24 {
25 return std::forward<CoordT>(coord);
26 }

◆ operator!=()

template<size_t N>
bool YODA::operator!= ( const PointBase< N > &  a,
const PointBase< N > &  b 
)
inline

Inequality test.

Definition at line 505 of file Point.h.

505 {
506 return !(a == b);
507 }

◆ operator*() [1/3]

Weights YODA::operator* ( const Weights first,
const Weights second 
)
inline

Multiply two weights.

Definition at line 268 of file Weights.h.

268 {
269 Weights tmp = first;
270 tmp *= second;
271 return tmp;
272 }
A named, vectorised generalisation of an event weight.
Definition Weights.h:22

◆ operator*() [2/3]

Weights YODA::operator* ( const Weights w,
double  a 
)
inline

Multiply by a double.

Definition at line 290 of file Weights.h.

290 {
291 return a * w;
292 }

◆ operator*() [3/3]

Weights YODA::operator* ( double  a,
const Weights w 
)
inline

Multiply by a double.

Definition at line 283 of file Weights.h.

283 {
284 Weights tmp = w;
285 tmp *= a;
286 return tmp;
287 }

◆ operator+() [1/17]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator+ ( BinnedDbn< DbnN, AxisT... > &&  dbn,
BinnedEstimate< AxisT... > &&  est 
)
inline

Definition at line 1309 of file BinnedDbn.h.

1309 {
1310 return add(std::move(dbn), std::move(est));
1311 }

References add().

◆ operator+() [2/17]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator+ ( BinnedDbn< DbnN, AxisT... > &&  dbn,
const BinnedEstimate< AxisT... > &  est 
)
inline

Definition at line 1297 of file BinnedDbn.h.

1297 {
1298 return add(std::move(dbn), est);
1299 }

References add().

◆ operator+() [3/17]

template<size_t DbnN, typename... AxisT>
BinnedDbn< DbnN, AxisT... > YODA::operator+ ( BinnedDbn< DbnN, AxisT... >  first,
BinnedDbn< DbnN, AxisT... > &&  second 
)
inline

Add two BinnedDbn objects.

Definition at line 1080 of file BinnedDbn.h.

1080 {
1081 first += std::move(second);
1082 return first;
1083 }

◆ operator+() [4/17]

template<size_t DbnN, typename... AxisT>
BinnedDbn< DbnN, AxisT... > YODA::operator+ ( BinnedDbn< DbnN, AxisT... >  first,
const BinnedDbn< DbnN, AxisT... > &  second 
)
inline

Definition at line 1087 of file BinnedDbn.h.

1087 {
1088 first += second;
1089 return first;
1090 }

◆ operator+() [5/17]

template<typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator+ ( BinnedEstimate< AxisT... >  first,
BinnedEstimate< AxisT... > &&  second 
)
inline

Add two BinnedEstimates.

Definition at line 1084 of file BinnedEstimate.h.

1084 {
1085 first += std::move(second);
1086 return first;
1087 }

◆ operator+() [6/17]

template<typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator+ ( BinnedEstimate< AxisT... >  first,
const BinnedEstimate< AxisT... > &  second 
)
inline

Add two BinnedEstimates.

Definition at line 1075 of file BinnedEstimate.h.

1075 {
1076 first += second;
1077 return first;
1078 }

◆ operator+() [7/17]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator+ ( const BinnedDbn< DbnN, AxisT... > &  dbn,
BinnedEstimate< AxisT... > &&  est 
)
inline

Definition at line 1303 of file BinnedDbn.h.

1303 {
1304 return add(dbn, std::move(est));
1305 }

References add().

◆ operator+() [8/17]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator+ ( const BinnedDbn< DbnN, AxisT... > &  dbn,
const BinnedEstimate< AxisT... > &  est 
)
inline

Definition at line 1291 of file BinnedDbn.h.

1291 {
1292 return add(dbn, est);
1293 }

References add().

◆ operator+() [9/17]

Weights YODA::operator+ ( const Weights first,
const Weights second 
)
inline

Add two weights.

Definition at line 254 of file Weights.h.

254 {
255 Weights tmp = first;
256 tmp += second;
257 return tmp;
258 }

◆ operator+() [10/17]

Counter YODA::operator+ ( Counter  first,
const Counter second 
)
inline

Add two counters.

Definition at line 369 of file Counter.h.

369 {
370 first += second;
371 return first;
372 }

◆ operator+() [11/17]

Counter YODA::operator+ ( Counter  first,
Counter &&  second 
)
inline

Add two counters.

Definition at line 375 of file Counter.h.

375 {
376 first += std::move(second);
377 return first;
378 }

◆ operator+() [12/17]

template<size_t N>
DbnBase< N > YODA::operator+ ( DbnBase< N >  first,
const DbnBase< N > &  second 
)
inline

Add two DbnBases.

Definition at line 608 of file Dbn.h.

608 {
609 first += second;
610 return first;
611 }

◆ operator+() [13/17]

template<size_t N>
DbnBase< N > YODA::operator+ ( DbnBase< N >  first,
DbnBase< N > &&  second 
)
inline

Add two DbnBases.

Definition at line 615 of file Dbn.h.

615 {
616 first += std::move(second);
617 return first;
618 }

◆ operator+() [14/17]

Estimate YODA::operator+ ( Estimate  lhs,
const Estimate rhs 
)
inline

Add two Estimate objects.

Definition at line 662 of file Estimate.h.

662 {
663 lhs += rhs;
664 return lhs;
665 }

◆ operator+() [15/17]

Estimate YODA::operator+ ( Estimate  lhs,
Estimate &&  rhs 
)
inline

Add two Estimate objects.

Definition at line 668 of file Estimate.h.

668 {
669 lhs += std::move(rhs);
670 return lhs;
671 }

◆ operator+() [16/17]

Estimate0D YODA::operator+ ( Estimate0D  lhs,
const Estimate0D rhs 
)
inline

Add two Estimate0D objects.

Definition at line 302 of file Estimate0D.h.

302 {
303 lhs += rhs;
304 return lhs;
305 }

◆ operator+() [17/17]

Estimate0D YODA::operator+ ( Estimate0D  lhs,
Estimate0D &&  rhs 
)
inline

Add two Estimate0D objects.

Definition at line 308 of file Estimate0D.h.

308 {
309 lhs += std::move(rhs);
310 return lhs;
311 }

◆ operator-() [1/17]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator- ( BinnedDbn< DbnN, AxisT... > &&  dbn,
BinnedEstimate< AxisT... > &&  est 
)
inline

Definition at line 1341 of file BinnedDbn.h.

1341 {
1342 return subtract(std::move(dbn), std::move(est));
1343 }

References subtract().

◆ operator-() [2/17]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator- ( BinnedDbn< DbnN, AxisT... > &&  dbn,
const BinnedEstimate< AxisT... > &  est 
)
inline

Definition at line 1329 of file BinnedDbn.h.

1329 {
1330 return subtract(std::move(dbn), est);
1331 }

References subtract().

◆ operator-() [3/17]

template<size_t DbnN, typename... AxisT>
BinnedDbn< DbnN, AxisT... > YODA::operator- ( BinnedDbn< DbnN, AxisT... >  first,
BinnedDbn< DbnN, AxisT... > &&  second 
)
inline

Subtract one BinnedDbn object from another.

Definition at line 1096 of file BinnedDbn.h.

1096 {
1097 first -= std::move(second);
1098 return first;
1099 }

◆ operator-() [4/17]

template<size_t DbnN, typename... AxisT>
BinnedDbn< DbnN, AxisT... > YODA::operator- ( BinnedDbn< DbnN, AxisT... >  first,
const BinnedDbn< DbnN, AxisT... > &  second 
)
inline

Definition at line 1103 of file BinnedDbn.h.

1103 {
1104 first -= second;
1105 return first;
1106 }

◆ operator-() [5/17]

template<typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator- ( BinnedEstimate< AxisT... >  first,
BinnedEstimate< AxisT... > &&  second 
)
inline

Subtract two BinnedEstimates.

Definition at line 1101 of file BinnedEstimate.h.

1101 {
1102 first -= std::move(second);
1103 return first;
1104 }

◆ operator-() [6/17]

template<typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator- ( BinnedEstimate< AxisT... >  first,
const BinnedEstimate< AxisT... > &  second 
)
inline

Subtract two BinnedEstimates.

Definition at line 1093 of file BinnedEstimate.h.

1093 {
1094 first -= second;
1095 return first;
1096 }

◆ operator-() [7/17]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator- ( const BinnedDbn< DbnN, AxisT... > &  dbn,
BinnedEstimate< AxisT... > &&  est 
)
inline

Definition at line 1335 of file BinnedDbn.h.

1335 {
1336 return subtract(dbn, std::move(est));
1337 }

References subtract().

◆ operator-() [8/17]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator- ( const BinnedDbn< DbnN, AxisT... > &  dbn,
const BinnedEstimate< AxisT... > &  est 
)
inline

Definition at line 1323 of file BinnedDbn.h.

1323 {
1324 return subtract(dbn, est);
1325 }

References subtract().

◆ operator-() [9/17]

Weights YODA::operator- ( const Weights first,
const Weights second 
)
inline

Subtract two weights.

Definition at line 261 of file Weights.h.

261 {
262 Weights tmp = first;
263 tmp -= second;
264 return tmp;
265 }

◆ operator-() [10/17]

Counter YODA::operator- ( Counter  first,
const Counter second 
)
inline

Subtract two counters.

Definition at line 381 of file Counter.h.

381 {
382 first -= second;
383 return first;
384 }

◆ operator-() [11/17]

Counter YODA::operator- ( Counter  first,
Counter &&  second 
)
inline

Subtract two counters.

Definition at line 387 of file Counter.h.

387 {
388 first -= std::move(second);
389 return first;
390 }

◆ operator-() [12/17]

template<size_t N>
DbnBase< N > YODA::operator- ( DbnBase< N >  first,
const DbnBase< N > &  second 
)
inline

Subtract one DbnBase from another one.

Definition at line 622 of file Dbn.h.

622 {
623 first -= second;
624 return first;
625 }

◆ operator-() [13/17]

template<size_t N>
DbnBase< N > YODA::operator- ( DbnBase< N >  first,
DbnBase< N > &&  second 
)
inline

Subtract one DbnBase from another one.

Definition at line 629 of file Dbn.h.

629 {
630 first -= std::move(second);
631 return first;
632 }

◆ operator-() [14/17]

Estimate YODA::operator- ( Estimate  lhs,
const Estimate rhs 
)
inline

Subtract two Estimate objects.

Definition at line 674 of file Estimate.h.

674 {
675 lhs -= rhs;
676 return lhs;
677 }

◆ operator-() [15/17]

Estimate YODA::operator- ( Estimate  lhs,
Estimate &&  rhs 
)
inline

Subtract two Estimate objects.

Definition at line 680 of file Estimate.h.

680 {
681 lhs -= std::move(rhs);
682 return lhs;
683 }

◆ operator-() [16/17]

Estimate0D YODA::operator- ( Estimate0D  lhs,
const Estimate0D rhs 
)
inline

Subtract two Estimate0D objects.

Definition at line 314 of file Estimate0D.h.

314 {
315 lhs -= rhs;
316 return lhs;
317 }

◆ operator-() [17/17]

Estimate0D YODA::operator- ( Estimate0D  lhs,
Estimate0D &&  rhs 
)
inline

Subtract two Estimate0D objects.

Definition at line 320 of file Estimate0D.h.

320 {
321 lhs -= std::move(rhs);
322 return lhs;
323 }

◆ operator/() [1/27]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator/ ( BinnedDbn< DbnN, AxisT... > &&  dbn,
BinnedEstimate< AxisT... > &&  est 
)
inline

Definition at line 1373 of file BinnedDbn.h.

1373 {
1374 return divide(std::move(dbn), std::move(est));
1375 }

References divide().

◆ operator/() [2/27]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator/ ( BinnedDbn< DbnN, AxisT... > &&  dbn,
const BinnedEstimate< AxisT... > &  est 
)
inline

Definition at line 1361 of file BinnedDbn.h.

1361 {
1362 return divide(std::move(dbn), est);
1363 }

References divide().

◆ operator/() [3/27]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator/ ( BinnedDbn< DbnN, AxisT... > &&  numer,
BinnedDbn< DbnN, AxisT... > &&  denom 
)
inline

Definition at line 1171 of file BinnedDbn.h.

1171 {
1172 return divide(std::move(numer), std::move(denom));
1173 }

References divide().

◆ operator/() [4/27]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator/ ( BinnedDbn< DbnN, AxisT... > &&  numer,
const BinnedDbn< DbnN, AxisT... > &  denom 
)
inline

Definition at line 1165 of file BinnedDbn.h.

1165 {
1166 return divide(std::move(numer), denom);
1167 }

References divide().

◆ operator/() [5/27]

template<typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator/ ( BinnedEstimate< AxisT... > &&  numer,
BinnedEstimate< AxisT... > &&  denom 
)
inline

Divide two BinnedEstimates.

Definition at line 1152 of file BinnedEstimate.h.

1152 {
1153 return divide(std::move(numer), std::move(denom));
1154 }

References divide().

◆ operator/() [6/27]

template<typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator/ ( BinnedEstimate< AxisT... > &&  numer,
const BinnedEstimate< AxisT... > &  denom 
)
inline

Divide two BinnedEstimates.

Definition at line 1138 of file BinnedEstimate.h.

1138 {
1139 return divide(std::move(numer), denom);
1140 }

References divide().

◆ operator/() [7/27]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator/ ( const BinnedDbn< DbnN, AxisT... > &  dbn,
BinnedEstimate< AxisT... > &&  est 
)
inline

Definition at line 1367 of file BinnedDbn.h.

1367 {
1368 return divide(dbn, std::move(est));
1369 }

References divide().

◆ operator/() [8/27]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator/ ( const BinnedDbn< DbnN, AxisT... > &  dbn,
const BinnedEstimate< AxisT... > &  est 
)
inline

Definition at line 1355 of file BinnedDbn.h.

1355 {
1356 return divide(dbn, est);
1357 }

References divide().

◆ operator/() [9/27]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator/ ( const BinnedDbn< DbnN, AxisT... > &  numer,
BinnedDbn< DbnN, AxisT... > &&  denom 
)
inline

Definition at line 1159 of file BinnedDbn.h.

1159 {
1160 return divide(numer, std::move(denom));
1161 }

References divide().

◆ operator/() [10/27]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator/ ( const BinnedDbn< DbnN, AxisT... > &  numer,
const BinnedDbn< DbnN, AxisT... > &  denom 
)
inline

Definition at line 1153 of file BinnedDbn.h.

1153 {
1154 return divide(numer, denom);
1155 }

References divide().

◆ operator/() [11/27]

template<typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator/ ( const BinnedEstimate< AxisT... > &  numer,
BinnedEstimate< AxisT... > &&  denom 
)
inline

Divide two BinnedEstimates.

Definition at line 1145 of file BinnedEstimate.h.

1145 {
1146 return divide(numer, std::move(denom));
1147 }

References divide().

◆ operator/() [12/27]

template<typename... AxisT>
BinnedEstimate< AxisT... > YODA::operator/ ( const BinnedEstimate< AxisT... > &  numer,
const BinnedEstimate< AxisT... > &  denom 
)
inline

Divide two BinnedEstimates.

Definition at line 1131 of file BinnedEstimate.h.

1131 {
1132 return divide(numer, denom);
1133 }

References divide().

◆ operator/() [13/27]

Estimate0D YODA::operator/ ( const Counter numer,
const Counter denom 
)
inline

Divide two Counter objects.

Definition at line 396 of file Counter.h.

396 {
397 return divide(numer, denom);
398 }

References divide().

◆ operator/() [14/27]

Estimate0D YODA::operator/ ( const Counter numer,
Counter &&  denom 
)
inline

Divide two Counter objects.

Definition at line 406 of file Counter.h.

406 {
407 return divide(numer, std::move(denom));
408 }

References divide().

◆ operator/() [15/27]

Estimate YODA::operator/ ( const Estimate numer,
const Estimate denom 
)
inline

Divide two Estimate objects.

Definition at line 747 of file Estimate.h.

747 {
748 return divide(numer, denom);
749 }

References divide().

◆ operator/() [16/27]

Estimate YODA::operator/ ( const Estimate numer,
Estimate &&  denom 
)
inline

Divide two Estimate objects.

Definition at line 757 of file Estimate.h.

757 {
758 return divide(numer, std::move(denom));
759 }

References divide().

◆ operator/() [17/27]

Estimate0D YODA::operator/ ( const Estimate0D numer,
const Estimate0D denom 
)
inline

Divide two Estimate0D objects.

Definition at line 336 of file Estimate0D.h.

336 {
337 return divide(numer, denom);
338 }

References divide().

◆ operator/() [18/27]

Estimate0D YODA::operator/ ( const Estimate0D numer,
Estimate0D &&  denom 
)
inline

Divide two Estimate0D objects.

Definition at line 346 of file Estimate0D.h.

346 {
347 return divide(numer, std::move(denom));
348 }

References divide().

◆ operator/() [19/27]

Weights YODA::operator/ ( const Weights numer,
const Weights denom 
)
inline

Divide two weights.

Definition at line 275 of file Weights.h.

275 {
276 Weights tmp = numer;
277 tmp /= denom;
278 return tmp;
279 }

◆ operator/() [20/27]

Weights YODA::operator/ ( const Weights w,
double  a 
)
inline

Divide by a double.

Definition at line 295 of file Weights.h.

295 {
296 Weights tmp = w;
297 tmp /= a;
298 return tmp;
299 }

◆ operator/() [21/27]

Estimate0D YODA::operator/ ( Counter &&  numer,
const Counter denom 
)
inline

Divide two Counter objects.

Definition at line 401 of file Counter.h.

401 {
402 return divide(std::move(numer), denom);
403 }

References divide().

◆ operator/() [22/27]

Estimate0D YODA::operator/ ( Counter &&  numer,
Counter &&  denom 
)
inline

Divide two Counter objects.

Definition at line 411 of file Counter.h.

411 {
412 return divide(std::move(numer), std::move(denom));
413 }

References divide().

◆ operator/() [23/27]

Weights YODA::operator/ ( double  a,
const Weights w 
)
inline

Divide a double by a Weights

Todo:
Is this really needed?

Definition at line 303 of file Weights.h.

303 {
304 Weights tmp(w.keys(), a);
305 tmp /= w;
306 return tmp;
307 }
std::vector< std::string > keys() const
Sorted list of weight keys.
Definition Weights.h:111

References YODA::Weights::keys().

◆ operator/() [24/27]

Estimate YODA::operator/ ( Estimate &&  numer,
const Estimate denom 
)
inline

Divide two Estimate objects.

Definition at line 752 of file Estimate.h.

752 {
753 return divide(std::move(numer), denom);
754 }

References divide().

◆ operator/() [25/27]

Estimate YODA::operator/ ( Estimate &&  numer,
Estimate &&  denom 
)
inline

Divide two Estimate objects.

Definition at line 762 of file Estimate.h.

762 {
763 return divide(std::move(numer), std::move(denom));
764 }

References divide().

◆ operator/() [26/27]

Estimate0D YODA::operator/ ( Estimate0D &&  numer,
const Estimate0D denom 
)
inline

Divide two Estimate0D objects.

Definition at line 341 of file Estimate0D.h.

341 {
342 return divide(std::move(numer), denom);
343 }

References divide().

◆ operator/() [27/27]

Estimate0D YODA::operator/ ( Estimate0D &&  numer,
Estimate0D &&  denom 
)
inline

Divide two Estimate0D objects.

Definition at line 351 of file Estimate0D.h.

351 {
352 return divide(std::move(numer), std::move(denom));
353 }

References divide().

◆ operator<()

template<size_t N>
bool YODA::operator< ( const PointBase< N > &  a,
const PointBase< N > &  b 
)
inline

Less-than operator used to sort points.

Definition at line 512 of file Point.h.

512 {
513 #define LT_IF_NOT_EQ(a,b) { if (!fuzzyEquals(a, b)) return a < b; }
514 for (size_t i = 0; i < N; ++i) {
515 LT_IF_NOT_EQ(a.vals()[i], b.vals()[i]);
516 LT_IF_NOT_EQ(a.errs()[i].first, b.errs()[i].first);
517 LT_IF_NOT_EQ(a.errs()[i].second, b.errs()[i].second);
518 }
519 #undef LT_IF_NOT_EQ
520 return false;
521 }
#define LT_IF_NOT_EQ(a, b)
NdValPair & errs()
Get error values.
Definition Point.h:297
NdVal & vals()
Get the coordinate vector.
Definition Point.h:268

References YODA::PointBase< N >::errs(), LT_IF_NOT_EQ, and YODA::PointBase< N >::vals().

◆ operator<<()

std::ostream & YODA::operator<< ( std::ostream &  out,
const Weights w 
)
inline

Standard text representaion.

Definition at line 313 of file Weights.h.

313 {
314 out << "{ ";
315 for (Weights::const_iterator i = w.begin(); i != w.end(); ++i) {
316 if (i != w.begin()) out << ", ";
317 out << i->first << ": " << i->second;
318 }
319 out << "}";
320 return out;
321 }
std::map< std::string, double >::const_iterator const_iterator
Definition Weights.h:72
iterator end()
Definition Weights.h:75
iterator begin()
Definition Weights.h:73

References YODA::Weights::begin(), and YODA::Weights::end().

◆ operator<=()

template<size_t N>
bool YODA::operator<= ( const PointBase< N > &  a,
const PointBase< N > &  b 
)
inline

Less-than-or-equals operator used to sort points.

Definition at line 525 of file Point.h.

525 {
526 if (a == b) return true;
527 return a < b;
528 }

◆ operator==()

template<size_t N>
bool YODA::operator== ( const PointBase< N > &  a,
const PointBase< N > &  b 
)
inline

Equality test.

Definition at line 493 of file Point.h.

493 {
494 // Compare valitions
495 for (size_t i = 0; i < N; ++i) {
496 if ( !fuzzyEquals(a.vals()[i], b.vals()[i]) ) return false;
497 if ( !fuzzyEquals(a.errs()[i].first, b.errs()[i].first)) return false;
498 if ( !fuzzyEquals(a.errs()[i].second, b.errs()[i].second)) return false;
499 }
500 return true;
501 }

References YODA::PointBase< N >::errs(), fuzzyEquals(), and YODA::PointBase< N >::vals().

◆ operator>()

template<size_t N>
bool YODA::operator> ( const PointBase< N > &  a,
const PointBase< N > &  b 
)
inline

Greater-than operator used to sort points.

Definition at line 532 of file Point.h.

532 {
533 return !(a <= b);
534 }

◆ operator>=()

template<size_t N>
bool YODA::operator>= ( const PointBase< N > &  a,
const PointBase< N > &  b 
)
inline

Greater-than-or-equals operator used to sort points.

Definition at line 538 of file Point.h.

538 {
539 return !(a < b);
540 }

◆ pdfspace()

std::vector< double > YODA::pdfspace ( size_t  nbins,
double  xmin,
double  xmax,
std::function< double(double)> &  fn,
size_t  nsample = 10000 
)
inline

Make a list of nbins + 1 values spaced with density ~ f(x) between xmin and end inclusive.

Todo:
fspace() for uniform sampling from f(x); requires ability to invert fn... how, in general?

The density function fn will be evaluated at nsample uniformly distributed points between xmin and xmax, its integral approximated via the Trapezium Rule and used to normalize the distribution, and nbins + 1 edges then selected to (approximately) divide into bins each containing fraction 1/nbins of the integral.

Note
The function fn does not need to be a normalized pdf, but it should be non-negative. Any negative values returned by fn(x) will be truncated to zero and contribute nothing to the estimated integral and binning density.
The arg ordering and the meaning of the nbins variable is "histogram-like", as opposed to the Numpy/Matlab version, and the xmin and xmax arguments are expressed in "normal" space, rather than in the function-mapped space as with Numpy/Matlab.
The naming of this function differs from the other, Matlab-inspired ones: the bin spacing is uniform in the CDF of the density function given, rather than in the function itself. For most use-cases this is more intuitive.

Definition at line 328 of file MathUtils.h.

328 {
329 const double dx = (xmax-xmin)/(double)nsample;
330 const std::vector<double> xs = linspace(nsample, xmin, xmax);
331 std::vector<double> ys(0, nsample);
332 auto posfn = [&](double x){return std::max(fn(x), 0.0);};
333 std::transform(xs.begin(), xs.end(), ys.begin(), posfn);
334 std::vector<double> areas; areas.reserve(nsample);
335 double areasum = 0;
336 for (size_t i = 0; i < ys.size()-1; ++i) {
337 const double area = (ys[i] + ys[i+1])*dx/2.0;
338 areas[i] = area;
339 areasum += area;
340 }
341 const double df = areasum/(double)nbins;
342 std::vector<double> xedges{xmin}; xedges.reserve(nbins+1);
343 double fsum = 0;
344 for (size_t i = 0; i < nsample-1; ++i) {
345 fsum += areas[i];
346 if (fsum > df) {
347 fsum = 0;
348 xedges.push_back(xs[i+1]);
349 }
350 }
351 xedges.push_back(xmax);
352 assert(xedges.size() == nbins+1);
353 return xedges;
354 }

References linspace().

◆ read() [1/4]

std::vector< AnalysisObject * > YODA::read ( const std::string &  filename,
const std::string &  match = "",
const std::string &  unmatch = "" 
)
inline

Read in a collection of objects from file filename.

This version returns a vector by value, involving copying, and is hence less CPU efficient than the alternative version where a vector is filled by reference. The appropriate format reader will be determined from the filename.

Definition at line 98 of file IO.h.

100 {
101 std::vector<AnalysisObject*> rtn;
102 read(filename, rtn, match, unmatch);
103 return rtn;
104 }
void read(const std::string &filename, std::vector< AnalysisObject * > &aos, const std::string &match="", const std::string &unmatch="")
Read in a collection of objects objs from file filename.
Definition IO.h:85

References read().

◆ read() [2/4]

void YODA::read ( const std::string &  filename,
std::vector< AnalysisObject * > &  aos,
const std::string &  match = "",
const std::string &  unmatch = "" 
)
inline

Read in a collection of objects objs from file filename.

This version fills (actually, appends to) a supplied vector, avoiding copying, and is hence CPU efficient. The appropriate format reader will be determined from the filename.

Todo:
Use SFINAE magic to allow ~arbitrary collection<AnalysisObject*> (with push_back()?) to be passed

Definition at line 85 of file IO.h.

87 {
88 Reader& r = mkReader(filename);
89 r.read(filename, aos, match, unmatch);
90 }
Pure virtual base class for various output writers.
Definition Reader.h:23
std::enable_if_t< YODA::Pushable< CONT, AnalysisObject * >::value > read(std::istream &stream, CONT &aos, const std::string &match="", const std::string &unmatch="")
Read in a collection of objects objs from output stream stream.
Definition Reader.h:50
Reader & mkReader(const std::string &format_name)
Factory function to make a reader object by format name or a filename.
Definition Reader.cc:15

References mkReader(), and YODA::Reader::read().

Referenced by read(), and read().

◆ read() [3/4]

std::vector< AnalysisObject * > YODA::read ( std::istream &  is,
const std::string &  fmt,
const std::string &  match = "",
const std::string &  unmatch = "" 
)
inline

Read in a collection of objects from stream is, expecting format fmt.

This version returns a vector by value, involving copying, and is hence less CPU efficient than the alternative version where a vector is filled by reference.

Definition at line 129 of file IO.h.

131 {
132 std::vector<AnalysisObject*> rtn;
133 read(is, rtn, fmt, match, unmatch);
134 return rtn;
135 }

References read().

◆ read() [4/4]

void YODA::read ( std::istream &  is,
std::vector< AnalysisObject * > &  aos,
const std::string &  fmt,
const std::string &  match = "",
const std::string &  unmatch = "" 
)
inline

Read in a collection of objects objs from stream is, expecting format fmt.

This version fills (actually, appends to) a supplied vector, avoiding copying, and is hence CPU efficient.

Todo:
Use SFINAE magic to allow ~arbitrary collection<AnalysisObject*> (with push_back()?) to be passed

Definition at line 118 of file IO.h.

119 {
120 Reader& r = mkReader(fmt);
121 r.read(is, aos, match, unmatch);
122 }

References mkReader(), and YODA::Reader::read().

◆ RMS() [1/2]

double YODA::RMS ( const double  sumWX2,
const double  sumW,
const double  sumW2 
)
inline

Calculate the weighted RMS of a sample.

Definition at line 495 of file MathUtils.h.

495 {
496 // Weighted RMS defined as
497 // rms = sqrt(sum{w x^2} / sum{w})
498 const double effN = effNumEntries(sumW, sumW2);
499 if (effN == 0) return std::numeric_limits<double>::quiet_NaN();
500 const double meanSq = sumWX2 / sumW;
501 return std::sqrt(meanSq);
502 }
double effNumEntries(const double sumW, const double sumW2)
Calculate the effective number of entries of a sample.
Definition MathUtils.h:381

References effNumEntries().

Referenced by YODA::DbnBase< N >::RMS(), RMS(), YODA::XDbnMixin< Derived >::xRMS(), YODA::YDbnMixin< Derived >::yRMS(), and YODA::ZDbnMixin< Derived >::zRMS().

◆ RMS() [2/2]

double YODA::RMS ( const std::vector< double > &  sample,
const std::vector< double > &  weights 
)
inline

Calculate the weighted RMS of a sample.

Definition at line 505 of file MathUtils.h.

506 {
507 if (sample.size() != weights.size()) throw RangeError("Inputs should have equal length!");
508 double sumWX2 = 0., sumW = 0., sumW2 = 0.;
509 for (size_t i = 0; i < sample.size(); ++i) {
510 sumW += weights[i];
511 sumW2 += sqr(weights[i]);
512 sumWX2 += weights[i]*sqr(sample[i]);
513 }
514 return RMS(sumWX2, sumW, sumW2);
515 }

References RMS(), and sqr().

◆ sign() [1/3]

int YODA::sign ( double  val)
inline

Find the sign of a number.

Definition at line 228 of file MathUtils.h.

228 {
229 if (isZero(val)) return ZERO;
230 const int valsign = (val > 0) ? PLUS : MINUS;
231 return valsign;
232 }

References isZero(), MINUS, PLUS, and ZERO.

◆ sign() [2/3]

int YODA::sign ( int  val)
inline

Find the sign of a number.

Definition at line 235 of file MathUtils.h.

235 {
236 if (val == 0) return ZERO;
237 return (val > 0) ? PLUS : MINUS;
238 }

References MINUS, PLUS, and ZERO.

◆ sign() [3/3]

int YODA::sign ( long  val)
inline

Find the sign of a number.

Definition at line 241 of file MathUtils.h.

241 {
242 if (val == 0) return ZERO;
243 return (val > 0) ? PLUS : MINUS;
244 }

References MINUS, PLUS, and ZERO.

◆ sqr()

◆ stdDev() [1/2]

double YODA::stdDev ( const double  sumWX,
const double  sumW,
const double  sumWX2,
const double  sumW2 
)
inline

Calculate the weighted standard deviation of a sample.

Definition at line 464 of file MathUtils.h.

465 {
466 return std::sqrt(variance(sumWX, sumW, sumWX2, sumW2));
467 }
double variance(const double sumWX, const double sumW, const double sumWX2, const double sumW2)
Calculate the weighted variance of a sample.
Definition MathUtils.h:427

References variance().

Referenced by YODA::XDbnMixin< Derived >::xStdDev(), YODA::XStatsMixin< Derived >::xStdDev(), YODA::YDbnMixin< Derived >::yStdDev(), YODA::YStatsMixin< Derived >::yStdDev(), YODA::ZDbnMixin< Derived >::zStdDev(), and YODA::ZStatsMixin< Derived >::zStdDev().

◆ stdDev() [2/2]

double YODA::stdDev ( const std::vector< double > &  sample,
const std::vector< double > &  weights 
)
inline

Calculate the weighted variance of a sample.

Definition at line 470 of file MathUtils.h.

471 {
472 return std::sqrt(variance(sample, weights));
473 }

References variance().

◆ stdErr() [1/2]

double YODA::stdErr ( const double  sumWX,
const double  sumW,
const double  sumWX2,
const double  sumW2 
)
inline

Calculate the weighted standard error of a sample.

Definition at line 476 of file MathUtils.h.

477 {
478 const double effN = effNumEntries(sumW, sumW2);
479 if (effN == 0) return std::numeric_limits<double>::quiet_NaN();
480 const double var = variance(sumWX, sumW, sumWX2, sumW2);
481 return std::sqrt(var / effN);
482 }

References effNumEntries(), and variance().

Referenced by YODA::DbnBase< N >::relStdErr(), YODA::DbnBase< N >::stdErr(), YODA::XDbnMixin< Derived >::xStdErr(), YODA::XStatsMixin< Derived >::xStdErr(), YODA::YDbnMixin< Derived >::yStdErr(), YODA::YStatsMixin< Derived >::yStdErr(), zipProfiles(), YODA::ZDbnMixin< Derived >::zStdErr(), and YODA::ZStatsMixin< Derived >::zStdErr().

◆ stdErr() [2/2]

double YODA::stdErr ( const std::vector< double > &  sample,
const std::vector< double > &  weights 
)
inline

Calculate the weighted variance of a sample.

Definition at line 485 of file MathUtils.h.

486 {
487 if (sample.size() != weights.size()) throw RangeError("Inputs should have equal length!");
488 const double effN = effNumEntries(weights);
489 if (effN == 0) return std::numeric_limits<double>::quiet_NaN();
490 const double var = variance(sample, weights);
491 return std::sqrt(var / effN);
492 }

References effNumEntries(), and variance().

◆ subtract() [1/2]

template<size_t DbnN, typename... AxisT>
BinnedEstimate< AxisT... > YODA::subtract ( const BinnedDbn< DbnN, AxisT... > &  dbn,
const BinnedEstimate< AxisT... > &  est 
)
inline

Calculate the subtraction of a BinnedEstimate from a BinnedDbn.

Definition at line 1317 of file BinnedDbn.h.

1317 {
1318 return dbn.mkEstimate() - est;
1319 }

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

Referenced by add(), asymm(), operator-(), operator-(), operator-(), operator-(), and variance().

◆ subtract() [2/2]

double YODA::subtract ( double  a,
double  b,
double  tolerance = 1e-5 
)
inline

Subtract two numbers with FP fuzziness.

Definition at line 247 of file MathUtils.h.

247 {
248 if (fuzzyEquals(a,b,tolerance)) return 0.;
249 return a - b;
250 }

References fuzzyEquals().

◆ transform() [1/6]

template<typename... AxisT, typename FN >
void YODA::transform ( BinnedEstimate< AxisT... > &  est,
const FN &  fn 
)
inline

Definition at line 1210 of file BinnedEstimate.h.

1210 {
1211 transform(est, Trf<1>(fn));
1212 }
void transform(BinnedEstimate< AxisT... > &est, const Trf< 1 > &fn)

References transform().

◆ transform() [2/6]

template<typename... AxisT>
void YODA::transform ( BinnedEstimate< AxisT... > &  est,
const Trf< 1 > &  fn 
)
inline

Definition at line 1203 of file BinnedEstimate.h.

1203 {
1204 for (auto& b : est.bins(true, true)) {
1205 b.transform(fn);
1206 }
1207 }

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

Referenced by transform(), transform(), transform(), transformX(), transformY(), and transformZ().

◆ transform() [3/6]

template<typename FN >
void YODA::transform ( Estimate0D est,
const FN &  fn 
)
inline

Definition at line 291 of file Estimate0D.h.

291 {
292 transform(est, Trf<1>(fn));
293 }

References transform().

◆ transform() [4/6]

void YODA::transform ( Estimate0D est,
const Trf< 1 > &  fn 
)
inline

Definition at line 286 of file Estimate0D.h.

286 {
287 est.transform(fn);
288 }
void transform(const Trf< 1 > &trf)
Generalised transformations with functors.
Definition Estimate.h:214

References YODA::Estimate::transform().

◆ transform() [5/6]

template<size_t N, typename FN >
void YODA::transform ( ScatterND< N > &  s,
const FN &  fn,
const size_t  i 
)
inline

Definition at line 878 of file Scatter.h.

878 {
879 transform(s, Trf<N>(fn), i);
880 }

References transform().

◆ transform() [6/6]

template<size_t N>
void YODA::transform ( ScatterND< N > &  s,
const Trf< N > &  fn,
const size_t  i 
)
inline

Definition at line 871 of file Scatter.h.

871 {
872 for (auto& p : s.points()) {
873 p.transform(i, fn);
874 }
875 }

References YODA::ScatterND< N >::points().

◆ transformX()

template<size_t N, typename FN >
void YODA::transformX ( ScatterND< N > &  s,
const FN &  fn 
)
inline

Definition at line 883 of file Scatter.h.

883 {
884 transform(s, fn, 0);
885 }

References transform().

◆ transformY()

template<size_t N, typename FN >
void YODA::transformY ( ScatterND< N > &  s,
const FN &  fn 
)
inline

Definition at line 888 of file Scatter.h.

888 {
889 transform(s, fn, 1);
890 }

References transform().

◆ transformZ()

template<size_t N, typename FN >
void YODA::transformZ ( ScatterND< N > &  s,
const FN &  fn 
)
inline

Definition at line 893 of file Scatter.h.

893 {
894 transform(s, fn, 2);
895 }

References transform().

◆ variance() [1/2]

double YODA::variance ( const double  sumWX,
const double  sumW,
const double  sumWX2,
const double  sumW2 
)
inline

Calculate the weighted variance of a sample.

Weighted variance defined as sig2 = ( sum(wx**2) * sum(w) - sum(wx)**2 ) / ( sum(w)**2 - sum(w**2) ) see http://en.wikipedia.org/wiki/Weighted_mean

Todo:
Isn't this sensitive to the overall scale of the weights? Shouldn't it check if den is bigger then num by a set number of orders of magnitude and vice versa?

We take the modulus of the weighted variance since the ratio can be negative with weighted means

Todo:
Is this the correct approach? There is no information online other than "weights are non-negative"...

Definition at line 427 of file MathUtils.h.

428 {
429 const double num = subtract(sumWX2*sumW, sqr(sumWX));
430 const double den = subtract(sqr(sumW), sumW2);
434 // if (fabs(num) < 1e-10 && fabs(den) < 1e-10) {
435 // return std::numeric_limits<double>::quiet_NaN();
436 // }
441 return den? fabs(num/den): std::numeric_limits<double>::quiet_NaN();
442 }

References sqr(), and subtract().

Referenced by stdDev(), stdDev(), stdErr(), stdErr(), YODA::DbnBase< N >::variance(), variance(), YODA::XDbnMixin< Derived >::xVariance(), YODA::XStatsMixin< Derived >::xVariance(), YODA::YDbnMixin< Derived >::yVariance(), YODA::YStatsMixin< Derived >::yVariance(), YODA::ZDbnMixin< Derived >::zVariance(), and YODA::ZStatsMixin< Derived >::zVariance().

◆ variance() [2/2]

double YODA::variance ( const std::vector< double > &  sample,
const std::vector< double > &  weights 
)
inline

Calculate the weighted variance of a sample.

Definition at line 445 of file MathUtils.h.

446 {
447 if (sample.size() != weights.size()) throw RangeError("Inputs should have equal length!");
448 if (fuzzyLessEquals(effNumEntries(weights), 1.0)) {
449 //throw LowStatsError("Requested variance of a distribution with only one effective entry");
450 return std::numeric_limits<double>::quiet_NaN();
451 }
452 double sumWX = 0., sumW = 0.;
453 double sumWX2 = 0., sumW2 = 0.;
454 for (size_t i = 0; i < sample.size(); ++i) {
455 sumW += weights[i];
456 sumWX += weights[i]*sample[i];
457 sumW2 += sqr(weights[i]);
458 sumWX2 += weights[i]*sqr(sample[i]);
459 }
460 return variance(sumWX, sumW, sumWX2, sumW2);
461 }
std::enable_if_t< std::is_arithmetic_v< N1 > &&std::is_arithmetic_v< N2 >, bool > fuzzyLessEquals(N1 a, N2 b, double tolerance=1e-5)
Compare two floating point numbers for <= with a degree of fuzziness.
Definition MathUtils.h:135

References effNumEntries(), fuzzyLessEquals(), sqr(), and variance().

◆ version()

std::string YODA::version ( )
inline

Namespaced version string function.

Definition at line 25 of file YodaConfig.h.

25 {
26 return YODA_VERSION;
27 }
#define YODA_VERSION
Definition YodaConfig.h:19

References YODA_VERSION.

◆ write() [1/6]

void YODA::write ( const std::string &  filename,
const AnalysisObject ao,
int  precision = -1 
)
inline

Write out object ao to file filename.

Definition at line 19 of file IO.h.

19 {
20 Writer& w = mkWriter(filename);
21 if (precision > 0) w.setPrecision(precision);
22 w.write(filename, ao);
23 }
Pure virtual base class for various output writers.
Definition Writer.h:19
void write(const std::string &filename, const AnalysisObject &ao)
Write out object ao to file filename.
Definition Writer.cc:49
void setPrecision(int precision)
Set precision of numerical quantities in this writer's output.
Definition Writer.h:143
Writer & mkWriter(const std::string &format_name)
Factory function to make a writer object by format name or a filename.
Definition Writer.cc:25

References mkWriter(), YODA::Writer::setPrecision(), and YODA::Writer::write().

◆ write() [2/6]

template<typename AOITER >
void YODA::write ( const std::string &  filename,
const AOITER &  begin,
const AOITER &  end,
int  precision = -1 
)
inline

Write out the objects specified by start iterator begin and end iterator end to file filename.

Definition at line 36 of file IO.h.

36 {
37 Writer& w = mkWriter(filename);
38 if (precision > 0) w.setPrecision(precision);
39 w.write(filename, begin, end);
40 }

References mkWriter(), YODA::Writer::setPrecision(), and YODA::Writer::write().

◆ write() [3/6]

template<typename RANGE >
void YODA::write ( const std::string &  filename,
const RANGE &  aos,
int  precision = -1 
)
inline

Write out a collection of objects objs to file filename.

Definition at line 27 of file IO.h.

27 {
28 Writer& w = mkWriter(filename);
29 if (precision > 0) w.setPrecision(precision);
30 w.write(filename, aos);
31 }

References mkWriter(), YODA::Writer::setPrecision(), and YODA::Writer::write().

◆ write() [4/6]

void YODA::write ( std::ostream &  os,
const AnalysisObject ao,
const std::string &  fmt,
int  precision = -1 
)
inline

Write out object ao to stream os with format fmt.

Definition at line 49 of file IO.h.

49 {
50 Writer& w = mkWriter(fmt);
51 if (precision > 0) w.setPrecision(precision);
52 w.write(os, ao);
53 }

References mkWriter(), YODA::Writer::setPrecision(), and YODA::Writer::write().

◆ write() [5/6]

template<typename AOITER >
void YODA::write ( std::ostream &  os,
const AOITER &  begin,
const AOITER &  end,
const std::string &  fmt,
int  precision = -1 
)
inline

Write out the objects specified by start iterator begin and end iterator end to file filename.

Definition at line 66 of file IO.h.

66 {
67 Writer& w = mkWriter(fmt);
68 if (precision > 0) w.setPrecision(precision);
69 w.write(os, begin, end);
70 }

References mkWriter(), YODA::Writer::setPrecision(), and YODA::Writer::write().

◆ write() [6/6]

template<typename RANGE >
void YODA::write ( std::ostream &  os,
const RANGE &  aos,
const std::string &  fmt,
int  precision = -1 
)
inline

Write out a collection of objects objs to file filename.

Definition at line 57 of file IO.h.

57 {
58 Writer& w = mkWriter(fmt);
59 if (precision > 0) w.setPrecision(precision);
60 w.write(os, aos);
61 }

References mkWriter(), YODA::Writer::setPrecision(), and YODA::Writer::write().

◆ zipProfiles()

template<size_t DbnN, typename... AxisT, typename... Args, typename = std::enable_if_t<(DbnN == sizeof...(AxisT)+1 && (std::is_same_v<BinnedDbn<DbnN, AxisT...>, Args> && ...))>>
ScatterND< sizeof...(Args)+1 > YODA::zipProfiles ( const BinnedDbn< DbnN, AxisT... > &  p1,
Args &&...  others,
const std::string &  path = "" 
)

Zip profile objects of the same type into a combined scatter object.

The resulting object has as many points as profile bins and whose central values are given by the means along the unbinned profile axes with means of first profile corresponding to x-coordinate, means of second profile corresponding to y-coordinate etc.

Note
The BinnedDbn objects must be profiles and have the same axis config.

Definition at line 1389 of file BinnedDbn.h.

1390 {
1391
1392 // Check profiles have the same binning
1393 if ( !((p1 == others) && ...) )
1394 throw BinningError("Requested zipping of profiles with incompatible binning!");
1395
1396 // Construct resulting Scatter whose coordinates
1397 // are given by the unbinned means
1398 constexpr size_t N = sizeof...(Args)+1;
1399 ScatterND<N> rtn;
1400 rtn.setAnnotation("Path", path);
1401 for (const auto& b1 : p1.bins()) {
1402 typename ScatterND<N>::NdVal vals = { b1.mean(DbnN), others.bin(b1.binIndex()).mean(DbnN) ... };
1403 typename ScatterND<N>::NdVal errs = { b1.stdErr(DbnN), others.bin(b1.binIndex()).stdErr(DbnN) ... };
1404 rtn.addPoint(vals, errs);
1405 }
1406 return rtn;
1407 }
void setAnnotation(const std::string &name, const T &value)
Add or set an annotation by name (templated for remaining types)
ScatterND< N > & addPoint(const PointND< N > &pt)
Insert a new point.
Definition Scatter.h:379
Utils::ndarray< double, N > NdVal
Definition Scatter.h:191

References YODA::ScatterND< N >::addPoint(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), mean(), YODA::AnalysisObject::setAnnotation(), and stdErr().

Variable Documentation

◆ BISECT_LINEAR_THRESHOLDlc

const size_t YODA::BISECT_LINEAR_THRESHOLDlc = 32

Definition at line 29 of file BinnedAxis.h.

◆ fuzzyEqComp

std::function<bool(const double, const double)> YODA::fuzzyEqComp
static
Initial value:
=
[](const double& lhs, const double& rhs) { return fuzzyEquals(lhs, rhs); }

Comparator wrapper to use with STL algorithms, e.g. std::equal etc.

Definition at line 115 of file MathUtils.h.

116 { return fuzzyEquals(lhs, rhs); };

◆ HALFPI

const double YODA::HALFPI = M_PI_2
static

A pre-defined value of $ \pi/2 $.

Definition at line 48 of file MathUtils.h.

◆ isCIterable

template<typename... T>
constexpr bool YODA::isCIterable = std::conjunction<CIterable<T>...>::value
inlineconstexpr

Definition at line 54 of file Traits.h.

◆ isIterable

template<typename... T>
constexpr bool YODA::isIterable = std::conjunction<Iterable<T>...>::value
inlineconstexpr

Definition at line 44 of file Traits.h.

◆ MAXDOUBLE

const double YODA::MAXDOUBLE = DBL_MAX
static

Pre-defined numeric type limits

Deprecated:
Prefer the standard DBL/INT_MAX

Definition at line 38 of file MathUtils.h.

◆ MAXINT

const double YODA::MAXINT = INT_MAX
static

Definition at line 39 of file MathUtils.h.

◆ PI

const double YODA::PI = M_PI
static

A pre-defined value of $ \pi $.

Definition at line 42 of file MathUtils.h.

◆ SEARCH_SIZElc

const size_t YODA::SEARCH_SIZElc = 16

Definition at line 28 of file BinnedAxis.h.

Referenced by YODA::Axis< T, isCAxis< T > >::index().

◆ TWOPI

const double YODA::TWOPI = 2*M_PI
static

A pre-defined value of $ 2\pi $.

Definition at line 45 of file MathUtils.h.

◆ YODA_FORMAT_VERSION

const int YODA::YODA_FORMAT_VERSION = 3
static

YODA text-format version

  • V1/empty = make-plots annotations style
  • V2 = YAML annotations
  • V3 = YODA2 types

Definition at line 33 of file WriterYODA.cc.