yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis 2.0.2
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
 Error for unfound or broken AnalysisObject annotations. 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...
 
class  GridError
 Error to throw when a slicing is requested on a non-slicable state of an object. 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  LockError
 Error for modification of a data object where filling has already begun. More...
 
class  LogBinEstimator
 Logarithmic bin estimator. More...
 
class  LogicError
 Error for places where it should not have been possible to get to! More...
 
class  LowStatsError
 Errors relating to insufficient (effective) statistics. 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.
 
Scatter1D mkScatter (const Counter &c)
 Make a Scatter1D representation of a Histo1D.
 
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 Histo1D to a Scatter2D 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 Histo1D to a Scatter2D 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 >
Num add_quad (Num a, Num b)
 Named number-type addition in quadrature operation.
 
template<typename Num >
Num add_quad (Num a, Num b, Num c)
 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.
 
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-8)
 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 1225 of file BinnedEstimate.h.

◆ BinnedEstimate2D

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

Definition at line 1228 of file BinnedEstimate.h.

◆ BinnedEstimate3D

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

Definition at line 1231 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 1249 of file BinnedEstimate.h.

◆ Estimate2D

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

Definition at line 1250 of file BinnedEstimate.h.

◆ Estimate3D

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

Definition at line 1251 of file BinnedEstimate.h.

◆ EstimateND

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

Definition at line 1245 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()

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 1270 of file BinnedDbn.h.

1270 {
1271 return dbn.mkEstimate() + est;
1272 }
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(), operator+(), operator+(), operator+(), and operator+().

◆ add_quad() [1/2]

template<typename Num >
Num YODA::add_quad ( Num  a,
Num  b 
)
inline

Named number-type addition in quadrature operation.

Definition at line 222 of file MathUtils.h.

222 {
223 return sqrt(a*a + b*b);
224 }

Referenced by divide().

◆ add_quad() [2/2]

template<typename Num >
Num YODA::add_quad ( Num  a,
Num  b,
Num  c 
)
inline

Named number-type addition in quadrature operation.

Definition at line 228 of file MathUtils.h.

228 {
229 return sqrt(a*a + b*b + c*c);
230 }

◆ 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 1201 of file BinnedDbn.h.

1201 {
1202 return (a-b) / (a+b);
1203 }

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

1194 {
1195 return divde(subtract(a-b, pat_uncorr), add(a+b, pat_uncorr), pat_uncorr);
1196 }
BinnedEstimate< AxisT... > add(const BinnedDbn< DbnN, AxisT... > &dbn, const BinnedEstimate< AxisT... > &est)
Calculate the addition of a BinnedDbn with a BinnedEstimate.
Definition BinnedDbn.h:1270
BinnedEstimate< AxisT... > subtract(const BinnedDbn< DbnN, AxisT... > &dbn, const BinnedEstimate< AxisT... > &est)
Calculate the subtraction of a BinnedEstimate from a BinnedDbn.
Definition BinnedDbn.h:1302

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:34

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 527 of file MathUtils.h.

527 {
528 const double cov = covariance(sample1, sample2);
529 const double var1 = covariance(sample1, sample1);
530 const double var2 = covariance(sample2, sample2);
531 const double correlation = cov/sqrt(var1*var2);
532 const double corr_strength = correlation*sqrt(var2/var1);
533 return corr_strength;
534 }
double covariance(const std::vector< int > &sample1, const std::vector< int > &sample2)
Calculate the covariance (variance) between two samples.
Definition MathUtils.h:512
double correlation(const std::vector< int > &sample1, const std::vector< int > &sample2)
Calculate the correlation strength between two samples.
Definition MathUtils.h:527

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 512 of file MathUtils.h.

512 {
513 const double mean1 = mean(sample1);
514 const double mean2 = mean(sample2);
515 const size_t N = sample1.size();
516 double cov = 0.0;
517 for (size_t i = 0; i < N; i++) {
518 const double cov_i = (sample1[i] - mean1)*(sample2[i] - mean2);
519 cov += cov_i;
520 }
521 if (N > 1) return cov/(N-1);
522 else return 0.0;
523 }
double mean(const std::vector< int > &sample)
Calculate the mean of a sample.
Definition MathUtils.h:391

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 1334 of file BinnedDbn.h.

1334 {
1335 return dbn.mkEstimate() / est;
1336 }

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 1092 of file BinnedDbn.h.

1092 {
1093
1094 if (numer != denom) {
1095 throw BinningError("Arithmetic operation requires compatible binning!");
1096 }
1097
1098 BinnedEstimate<AxisT...> rtn = numer.mkEstimate();
1099 if (numer.path() == denom.path()) rtn.setPath(numer.path());
1100 if (rtn.hasAnnotation("ScaledBy")) rtn.rmAnnotation("ScaledBy");
1101
1102 for (const auto& b_num : numer.bins(true, true)) {
1103 const size_t idx = b_num.index();
1104 const auto& b_den = denom.bin(idx);
1105 double v, e;
1106 if (!b_den.effNumEntries()) {
1107 v = std::numeric_limits<double>::quiet_NaN();
1108 e = std::numeric_limits<double>::quiet_NaN();
1109 }
1110 else {
1111 if constexpr(DbnN > sizeof...(AxisT)) {
1112 v = b_num.mean(DbnN) / b_den.mean(DbnN);
1113 const double e_num = b_num.effNumEntries()? b_num.relStdErr(DbnN) : 0;
1114 const double e_den = b_den.effNumEntries()? b_den.relStdErr(DbnN) : 0;
1115 e = fabs(v) * sqrt(sqr(e_num) + sqr(e_den));
1116 }
1117 else {
1118 v = b_num.sumW() / b_den.sumW();
1119 const double e_num = b_num.sumW()? b_num.relErrW() : 0;
1120 const double e_den = b_den.sumW()? b_den.relErrW() : 0;
1121 e = fabs(v) * sqrt(sqr(e_num) + sqr(e_den));
1122 }
1123 }
1124 rtn.bin(idx).set(v, {-e, e}); // @todo put "stats" as source?
1125 }
1126 rtn.maskBins(denom.maskedBins(), true);
1127
1128 return rtn;
1129 }
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
NUM sqr(NUM a)
Named number-type squaring operation.
Definition MathUtils.h:216

References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), 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 1112 of file BinnedEstimate.h.

1113 {
1114 if (numer != denom) {
1115 throw BinningError("Arithmetic operation requires compatible binning!");
1116 }
1117
1118 BinnedEstimate<AxisT...> rtn(numer.binning());
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 rtn.bin(idx) = divide(b_num, denom.bin(idx), pat_uncorr);
1125 }
1126 rtn.maskBins(denom.maskedBins(), true);
1127
1128 return rtn;
1129 }
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
Num add_quad(Num a, Num b)
Named number-type addition in quadrature operation.
Definition MathUtils.h:222

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:1092

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 1162 of file BinnedDbn.h.

1162 {
1163
1164 if (accepted != total) {
1165 throw BinningError("Arithmetic operation requires compatible binning!");
1166 }
1167
1168 BinnedEstimate<AxisT...> rtn = divide(accepted, total);
1169
1170 for (const auto& b_acc : accepted.bins(true, true)) {
1171 const auto& b_tot = total.bin(b_acc.index());
1172 auto& b_rtn = rtn.bin(b_acc.index());
1173
1174 // Check that the numerator is consistent with being a subset of the denominator
1176 if (b_acc.numEntries() > b_tot.numEntries())
1177 throw UserError("Attempt to calculate an efficiency when the numerator is not a subset of the denominator: "
1178 + Utils::toStr(b_acc.numEntries()) + " entries / " + Utils::toStr(b_tot.numEntries()) + " entries");
1179
1180 // If no entries on the denominator, set eff = err = 0 and move to the next bin
1181 double eff = std::numeric_limits<double>::quiet_NaN();
1182 double err = std::numeric_limits<double>::quiet_NaN();
1183 try {
1184 if (b_tot.sumW()) {
1185 eff = b_rtn.val();
1186 err = sqrt(abs( ((1-2*eff)*b_acc.sumW2() + sqr(eff)*b_tot.sumW2()) / sqr(b_tot.sumW()) ));
1187 }
1188 } catch (const LowStatsError& e) {
1189 //
1190 }
1191
1192 b_rtn.setErr({-err, err}); // @todo put "stats" as source?
1193 }
1194 return rtn;
1195 }

References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), divide(), 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 1166 of file BinnedEstimate.h.

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

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:100

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( ((1-2*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 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:1162

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 375 of file MathUtils.h.

375 {
376 if (isZero(sumW2)) return 0;
377 return sqr(sumW) / sumW2;
378 }
std::enable_if_t< std::is_floating_point_v< NUM >, bool > isZero(NUM val, double tolerance=1e-8)
Compare a number to zero.
Definition MathUtils.h:63

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 381 of file MathUtils.h.

381 {
382 double sumW = 0.0, sumW2 = 0.0;
383 for (size_t i = 0; i < weights.size(); ++i) {
384 sumW += weights[i];
385 sumW2 += sqr(weights[i]);
386 }
387 return effNumEntries(sumW, sumW2);
388 }

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(), and operator==().

◆ 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 355 of file MathUtils.h.

355 {
356 if (!inRange(val, binedges.front(), binedges.back())) return -1; //< Out of histo range
357 int index = -1;
358 for (size_t i = 1; i < binedges.size(); ++i) {
359 if (val < binedges[i]) {
360 index = i-1;
361 break;
362 }
363 }
364 assert(inRange(index, -1, binedges.size()-1));
365 return index;
366 }
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-8 
)
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 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 261 of file MathUtils.h.

261 {
262 if (xmax < xmin) throw RangeError("xmax should not be smaller than xmin!");
263 if (nbins == 0) throw RangeError("Requested number of bins is 0!");
264 std::vector<double> rtn;
265 const double interval = (xmax-xmin)/static_cast<double>(nbins);
266 for (size_t i = 0; i < nbins; ++i) {
267 rtn.push_back(xmin + i*interval);
268 }
269 assert(rtn.size() == nbins);
270 if (include_end) rtn.push_back(xmax); // exact xmax, not result of n * interval
271 return rtn;
272 }
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 280 of file MathUtils.h.

280 {
281 if (xmax < xmin) throw RangeError("xmax should not be smaller than xmin!");
282 if (xmin < 0) throw RangeError("xmin should not be negative!");
283 if (nbins == 0) throw RangeError("Requested number of bins is 0!");
284 const double logxmin = std::log(xmin);
285 const double logxmax = std::log(xmax);
286 const std::vector<double> logvals = linspace(nbins, logxmin, logxmax);
287 assert(logvals.size() == nbins+1);
288 std::vector<double> rtn; rtn.reserve(logvals.size());
289 rtn.push_back(xmin);
290 for (size_t i = 1; i < logvals.size()-1; ++i) {
291 rtn.push_back(std::exp(logvals[i]));
292 }
293 assert(rtn.size() == nbins);
294 if (include_end) rtn.push_back(xmax);
295 return rtn;
296 }
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:261

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 400 of file MathUtils.h.

400 {
401 return sumW? sumWX / sumW : std::numeric_limits<double>::quiet_NaN();
402 }

◆ 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 405 of file MathUtils.h.

406 {
407 if (sample.size() != weights.size()) throw RangeError("Inputs should have equal length!");
408 double sumWX = 0., sumW = 0.;
409 for (size_t i = 0; i < sample.size(); ++i) {
410 sumW += weights[i];
411 sumWX += weights[i]*sample[i];
412 }
413 return mean(sumWX, sumW);
414 }

References mean().

◆ mean() [3/3]

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

Calculate the mean of a sample.

Definition at line 391 of file MathUtils.h.

391 {
392 double mean = 0.0;
393 for (size_t i=0; i<sample.size(); ++i) {
394 mean += sample[i];
395 }
396 return mean/sample.size();
397 }

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 Histo1D to a Scatter2D 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 1216 of file BinnedDbn.h.

1216 {
1217
1218 BinnedEstimate<AxisT...> rtn = histo.mkEstimate();
1219
1220 double sumW = 0.0, sumW2 = 0.0;
1221 for (const auto& b : histo.bins(includeOverflows)) {
1222 sumW += b.sumW();
1223 sumW2 += b.sumW2();
1224 const double e = sqrt(sumW2);
1225 rtn.bin(b.index()).set(sumW, {-e, e});
1226 }
1227
1228 return rtn;
1229 }
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 Histo1D to a Scatter2D 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 1245 of file BinnedDbn.h.

1245 {
1246
1247 BinnedEstimate<AxisT...> rtn = mkIntegral(histo, includeOverflows);
1248 const double integral = histo.integral(includeOverflows);
1249
1250 // If the integral is empty, the (integrated) efficiency values may as well all be zero, so return here
1254 if (!integral) return rtn;
1255
1256 const double integral_err = histo.integralError(includeOverflows);
1257 for (const auto& b : rtn.bins(includeOverflows)) {
1258 const double eff = b.val() / integral;
1259 const double err = sqrt(std::abs( ((1-2*eff)*sqr(b.relTotalErrAvg()) + sqr(eff)*sqr(integral_err)) / sqr(integral) ));
1260 b.set(eff, {-err,err});
1261 }
1262
1263 return rtn;
1264 }
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 Histo1D to a Scatter2D representing the integral of the histogram.
Definition BinnedDbn.h:1216

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().

◆ mkScatter()

Scatter1D YODA::mkScatter ( const Counter c)

Make a Scatter1D representation of a Histo1D.

Definition at line 8 of file Scatter.cc.

8 {
9 Scatter1D rtn;
10 for (const std::string& a : c.annotations())
11 rtn.setAnnotation(a, c.annotation(a));
12 rtn.setAnnotation("Type", c.type()); // might override the copied ones
13 Point1D pt(c.val(), c.err());
14 rtn.addPoint(pt);
15 return rtn;
16 }
virtual std::string type() const
Get name of the analysis object type.
void setAnnotation(const std::string &name, const T &value)
Add or set an annotation by name (templated for remaining types)
double err() const
Definition Counter.h:193
A 1D data point to be contained in a Scatter1D.
Definition Point.h:555
ScatterND< N > & addPoint(const PointND< N > &pt)
Insert a new point.
Definition Scatter.h:379

References YODA::ScatterND< N >::addPoint(), YODA::AnalysisObject::annotation(), YODA::AnalysisObject::annotations(), YODA::Counter::err(), YODA::AnalysisObject::setAnnotation(), YODA::AnalysisObject::type(), and YODA::Counter::val().

◆ 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 543 of file MathUtils.h.

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

◆ 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 573 of file MathUtils.h.

574 {},
575 const std::vector<double>& s2errors = std::vector<double>{}) {
576 if (sample1.empty()) throw RangeError("Inputs should not have 0 length!");
577 return naiveChi2(sample1, sample2, s1errors, s2errors)/sample1.size();
578 }
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:543

◆ 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 1294 of file BinnedDbn.h.

1294 {
1295 return add(std::move(dbn), std::move(est));
1296 }

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 1282 of file BinnedDbn.h.

1282 {
1283 return add(std::move(dbn), est);
1284 }

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 1060 of file BinnedDbn.h.

1060 {
1061 first += std::move(second);
1062 return first;
1063 }

◆ 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 1067 of file BinnedDbn.h.

1067 {
1068 first += second;
1069 return first;
1070 }

◆ operator+() [5/17]

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

Add two BinnedEstimates.

Definition at line 1087 of file BinnedEstimate.h.

1087 {
1088 first += std::move(second);
1089 return first;
1090 }

◆ operator+() [6/17]

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

Add two BinnedEstimates.

Definition at line 1078 of file BinnedEstimate.h.

1078 {
1079 first += second;
1080 return first;
1081 }

◆ 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 1288 of file BinnedDbn.h.

1288 {
1289 return add(dbn, std::move(est));
1290 }

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 1276 of file BinnedDbn.h.

1276 {
1277 return add(dbn, est);
1278 }

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 1326 of file BinnedDbn.h.

1326 {
1327 return subtract(std::move(dbn), std::move(est));
1328 }

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 1314 of file BinnedDbn.h.

1314 {
1315 return subtract(std::move(dbn), est);
1316 }

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 1076 of file BinnedDbn.h.

1076 {
1077 first -= std::move(second);
1078 return first;
1079 }

◆ 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 1083 of file BinnedDbn.h.

1083 {
1084 first -= second;
1085 return first;
1086 }

◆ operator-() [5/17]

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

Subtract two BinnedEstimates.

Definition at line 1104 of file BinnedEstimate.h.

1104 {
1105 first -= std::move(second);
1106 return first;
1107 }

◆ operator-() [6/17]

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

Subtract two BinnedEstimates.

Definition at line 1096 of file BinnedEstimate.h.

1096 {
1097 first -= second;
1098 return first;
1099 }

◆ 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 1320 of file BinnedDbn.h.

1320 {
1321 return subtract(dbn, std::move(est));
1322 }

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 1308 of file BinnedDbn.h.

1308 {
1309 return subtract(dbn, est);
1310 }

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 1358 of file BinnedDbn.h.

1358 {
1359 return divide(std::move(dbn), std::move(est));
1360 }

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 1346 of file BinnedDbn.h.

1346 {
1347 return divide(std::move(dbn), est);
1348 }

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 1151 of file BinnedDbn.h.

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

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 1145 of file BinnedDbn.h.

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

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

1155 {
1156 return divide(std::move(numer), std::move(denom));
1157 }

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

1141 {
1142 return divide(std::move(numer), denom);
1143 }

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 1352 of file BinnedDbn.h.

1352 {
1353 return divide(dbn, std::move(est));
1354 }

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 1340 of file BinnedDbn.h.

1340 {
1341 return divide(dbn, est);
1342 }

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 1139 of file BinnedDbn.h.

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

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 1133 of file BinnedDbn.h.

1133 {
1134 return divide(numer, denom);
1135 }

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

1148 {
1149 return divide(numer, std::move(denom));
1150 }

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

1134 {
1135 return divide(numer, denom);
1136 }

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 322 of file MathUtils.h.

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

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 489 of file MathUtils.h.

489 {
490 // Weighted RMS defined as
491 // rms = sqrt(sum{w x^2} / sum{w})
492 const double effN = effNumEntries(sumW, sumW2);
493 if (effN == 0) return std::numeric_limits<double>::quiet_NaN();
494 const double meanSq = sumWX2 / sumW;
495 return std::sqrt(meanSq);
496 }
double effNumEntries(const double sumW, const double sumW2)
Calculate the effective number of entries of a sample.
Definition MathUtils.h:375

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 499 of file MathUtils.h.

500 {
501 if (sample.size() != weights.size()) throw RangeError("Inputs should have equal length!");
502 double sumWX2 = 0., sumW = 0., sumW2 = 0.;
503 for (size_t i = 0; i < sample.size(); ++i) {
504 sumW += weights[i];
505 sumW2 += sqr(weights[i]);
506 sumWX2 += weights[i]*sqr(sample[i]);
507 }
508 return RMS(sumWX2, sumW, sumW2);
509 }

References RMS(), and sqr().

◆ sign() [1/3]

int YODA::sign ( double  val)
inline

Find the sign of a number.

Definition at line 233 of file MathUtils.h.

233 {
234 if (isZero(val)) return ZERO;
235 const int valsign = (val > 0) ? PLUS : MINUS;
236 return valsign;
237 }

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

◆ sign() [2/3]

int YODA::sign ( int  val)
inline

Find the sign of a number.

Definition at line 240 of file MathUtils.h.

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

References MINUS, PLUS, and ZERO.

◆ sign() [3/3]

int YODA::sign ( long  val)
inline

Find the sign of a number.

Definition at line 246 of file MathUtils.h.

246 {
247 if (val == 0) return ZERO;
248 return (val > 0) ? PLUS : MINUS;
249 }

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 458 of file MathUtils.h.

459 {
460 return std::sqrt(variance(sumWX, sumW, sumWX2, sumW2));
461 }
double variance(const double sumWX, const double sumW, const double sumWX2, const double sumW2)
Calculate the weighted variance of a sample.
Definition MathUtils.h:421

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 464 of file MathUtils.h.

465 {
466 return std::sqrt(variance(sample, weights));
467 }

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 470 of file MathUtils.h.

471 {
472 const double effN = effNumEntries(sumW, sumW2);
473 if (effN == 0) return std::numeric_limits<double>::quiet_NaN();
474 const double var = variance(sumWX, sumW, sumWX2, sumW2);
475 return std::sqrt(var / effN);
476 }

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 479 of file MathUtils.h.

480 {
481 if (sample.size() != weights.size()) throw RangeError("Inputs should have equal length!");
482 const double effN = effNumEntries(weights);
483 if (effN == 0) return std::numeric_limits<double>::quiet_NaN();
484 const double var = variance(sample, weights);
485 return std::sqrt(var / effN);
486 }

References effNumEntries(), and variance().

◆ subtract()

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 1302 of file BinnedDbn.h.

1302 {
1303 return dbn.mkEstimate() - est;
1304 }

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

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

◆ transform() [1/6]

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

Definition at line 1213 of file BinnedEstimate.h.

1213 {
1214 transform(est, Trf<1>(fn));
1215 }
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 1206 of file BinnedEstimate.h.

1206 {
1207 for (auto& b : est.bins(true, true)) {
1208 b.transform(fn);
1209 }
1210 }

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 421 of file MathUtils.h.

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

References sqr().

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 439 of file MathUtils.h.

440 {
441 if (sample.size() != weights.size()) throw RangeError("Inputs should have equal length!");
442 if (fuzzyLessEquals(effNumEntries(weights), 1.0)) {
443 //throw LowStatsError("Requested variance of a distribution with only one effective entry");
444 return std::numeric_limits<double>::quiet_NaN();
445 }
446 double sumWX = 0., sumW = 0.;
447 double sumWX2 = 0., sumW2 = 0.;
448 for (size_t i = 0; i < sample.size(); ++i) {
449 sumW += weights[i];
450 sumWX += weights[i]*sample[i];
451 sumW2 += sqr(weights[i]);
452 sumWX2 += weights[i]*sqr(sample[i]);
453 }
454 return variance(sumWX, sumW, sumWX2, sumW2);
455 }
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 1374 of file BinnedDbn.h.

1375 {
1376
1377 // Check profiles have the same binning
1378 if ( !((p1 == others) && ...) )
1379 throw BinningError("Requested zipping of profiles with incompatible binning!");
1380
1381 // Construct resulting Scatter whose coordinates
1382 // are given by the unbinned means
1383 constexpr size_t N = sizeof...(Args)+1;
1384 ScatterND<N> rtn;
1385 rtn.setAnnotation("Path", path);
1386 for (const auto& b1 : p1.bins()) {
1387 typename ScatterND<N>::NdVal vals = { b1.mean(DbnN), others.bin(b1.binIndex()).mean(DbnN) ... };
1388 typename ScatterND<N>::NdVal errs = { b1.stdErr(DbnN), others.bin(b1.binIndex()).stdErr(DbnN) ... };
1389 rtn.addPoint(vals, errs);
1390 }
1391 return rtn;
1392 }
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.