yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis 2.0.0
YODA::Estimate0D Class Reference

An estimate in 0D. More...

#include <Estimate0D.h>

Inheritance diagram for YODA::Estimate0D:
YODA::Estimate YODA::AnalysisObject

Public Types

using Ptr = std::shared_ptr< Estimate0D >
 
using BaseT = Estimate
 
- Public Types inherited from YODA::AnalysisObject
typedef std::map< std::string, std::string > Annotations
 Collection type for annotations, as a string-string map.
 

Public Member Functions

Constructors
 Estimate0D (const std::string &path="", const std::string &title="")
 Nullary constructor for unique pointers etc.
 
 Estimate0D (double v, std::map< std::string, std::pair< double, double > > &errors, const std::string &path="", const std::string &title="")
 Constructor to set an Estimate0D with a pre-filled state.
 
 Estimate0D (const double v, const std::pair< double, double > &e, const std::string &source="", const std::string &path="", const std::string &title="")
 Alternative constructor to set an Estimate0D with value and uncertainty.
 
 Estimate0D (const Estimate0D &other)
 Copy constructor (needed for clone functions).
 
 Estimate0D (Estimate0D &&other)
 Move constructor.
 
 Estimate0D (const BaseT &other, const std::string &path="", const std::string &title="")
 Copy constructor using base class.
 
 Estimate0D (BaseT &&other, const std::string &path="", const std::string &title="")
 Move constructor using base class.
 
Estimate0D clone () const noexcept
 Make a copy on the stack.
 
Estimate0Dnewclone () const noexcept
 Make a copy on the heap.
 
Operators
Estimate0Doperator= (const Estimate0D &toCopy) noexcept
 
Estimate0Doperator= (Estimate0D &&toMove) noexcept
 Move assignment.
 
Estimate0Dadd (const Estimate0D &toAdd, const std::string &pat_uncorr="^stat|^uncor")
 Add two Estimate0Ds.
 
Estimate0Doperator+= (const Estimate0D &toAdd)
 
Estimate0Dadd (Estimate0D &&toAdd, const std::string &pat_uncorr="^stat|^uncor")
 Add two (rvalue) Estimate0Ds.
 
Estimate0Doperator+= (Estimate0D &&toAdd)
 
Estimate0Dsubtract (const Estimate0D &toSubtract, const std::string &pat_uncorr="^stat|^uncor")
 Subtract two Estimate0Ds.
 
Estimate0Doperator-= (const Estimate0D &toSubtract)
 
Estimate0Dsubtract (Estimate0D &&toSubtract, const std::string &pat_uncorr="^stat|^uncor")
 Subtract two (rvalue) Estimate0Ds.
 
Estimate0Doperator-= (Estimate0D &&toSubtract)
 
Dimensions
size_t dim () const noexcept
 Total dimension of this data object.
 
Modifiers
void reset () noexcept
 Reset the internal values.
 
MPI (de-)serialisation
size_t lengthContent (bool fixed_length=false) const noexcept
 Length of serialized content vector for MPI reduce operations.
 
std::vector< double > serializeContent (bool fixed_length=false) const noexcept
 Content serialisation for MPI reduce operations.
 
void deserializeContent (const std::vector< double > &data)
 Content deserialisation for MPI reduce operations.
 
Type reductions
Scatter1D mkScatter (const std::string &path="") const noexcept
 
AnalysisObjectmkInert (const std::string &path="", const std::string &source="") const noexcept
 Method returns clone of the estimate with streamlined error source.
 
- Public Member Functions inherited from YODA::Estimate
 Estimate ()
 Default constructor of a new distribution.
 
 Estimate (double v, std::map< std::string, std::pair< double, double > > &errors)
 Constructor to set an Estimate with a pre-filled state.
 
 Estimate (const double v, const std::pair< double, double > &e, const std::string &source="")
 Alternative constructor to set an Estimate with value and uncertainty.
 
 Estimate (const Estimate &toCopy)
 
 Estimate (Estimate &&toMove)
 
Estimateoperator= (const Estimate &toCopy) noexcept
 
Estimateoperator= (Estimate &&toMove) noexcept
 
Estimateadd (const Estimate &toAdd, const std::string &pat_uncorr="^stat|^uncor")
 Add two Estimates.
 
Estimateoperator+= (const Estimate &toAdd)
 
Estimatesubtract (const Estimate &toSubtract, const std::string &pat_uncorr="^stat|^uncor")
 Subtract one Estimate from another.
 
Estimateoperator-= (const Estimate &toSubtract)
 
void setValue (const double value) noexcept
 Set the central value of this estimator.
 
void setVal (const double val) noexcept
 Alias for setValue.
 
void setErr (const std::pair< double, double > &err, const std::string &source="")
 Set a signed uncertainty component.
 
void setErr (const double err, const std::string &source="")
 Set a symmetric uncertainty component.
 
void set (const double val, const std::pair< double, double > &err, const std::string source="")
 Set both central value and uncertainty component.
 
void set (const double val, const double err, const std::string &source="")
 Set both central value and uncertainty component.
 
void reset () noexcept
 Reset the internal values.
 
void scale (const double scalefactor) noexcept
 Rescale as if value and uncertainty had been different by factor scalefactor.
 
void scale (const Trf< 1 > &trf)
 Generalised transformations with functors.
 
void transform (const Trf< 1 > &trf)
 Generalised transformations with functors.
 
void renameSource (const std::string &old_label, const std::string &new_label)
 Replace a source label in the error breakdown.
 
double val () const noexcept
 The central value.
 
std::pair< double, double > errDownUp (const std::string &source="") const
 The signed absolute error on the central value.
 
std::pair< double, double > err (const std::string &source="") const
 Convenience alias for errorDownUp(source)
 
std::pair< double, double > errNegPos (std::string source="") const
 The signed negative and positive uncertainty component.
 
double errNeg (const std::string &source="") const
 The signed negative uncertainty component.
 
double errPos (const std::string &source="") const
 The signed positive uncertainty component.
 
double errDown (const std::string &source="") const
 The signed error due to the systematic downward variation.
 
double errUp (const std::string &source="") const
 The signed error due to the systematic upward variation.
 
double errAvg (const std::string &source="") const
 The average uncertainty component.
 
std::pair< double, double > relErrDownUp (const std::string &source="") const
 The relative error on the central value.
 
std::pair< double, double > relErr (const std::string &source="") const
 Convenience alias for relErrDownUp.
 
double relErrDown (const std::string &source="") const
 The relative negative on the central value.
 
double relErrUp (const std::string &source="") const
 The relative positive on the central value.
 
double relErrAvg (const std::string &source="") const
 The average uncertainty component.
 
double valMax (const std::string &source="") const
 
double valMin (const std::string &source="") const
 
std::pair< double, double > quadSum () const noexcept
 Get the quadrature sum of uncertainty components.
 
double quadSumNeg () const noexcept
 
double quadSumPos () const noexcept
 
double quadSumAvg () const noexcept
 The average uncertainty component.
 
std::pair< double, double > totalErr () const noexcept
 The total uncertainty.
 
double totalErrNeg () const noexcept
 The negative total uncertainty.
 
double totalErrPos () const noexcept
 The positive total uncertainty.
 
double totalErrAvg () const
 The average total uncertainty.
 
double valueErr () const
 The unsigned average total uncertainty.
 
std::pair< double, double > relTotalErr () const noexcept
 The relative negative/positive total uncertainty on the central value.
 
double relTotalErrNeg () const noexcept
 The relative negative total uncertainty on the central value.
 
double relTotalErrPos () const noexcept
 The relative positive total uncertainty on the central value.
 
double relTotalErrAvg () const noexcept
 The average uncertainty component.
 
std::vector< std::string > sources () const noexcept
 
bool hasSource (const std::string &key) const noexcept
 
size_t numErrs () const noexcept
 
std::vector< std::string > serializeSources () const noexcept
 
void deserializeSources (const std::vector< std::string > &data)
 
- Public Member Functions inherited from YODA::AnalysisObject
 AnalysisObject ()
 Default constructor.
 
 AnalysisObject (const std::string &type, const std::string &path, const std::string &title="")
 Constructor giving a type, a path and an optional title.
 
 AnalysisObject (const std::string &type, const std::string &path, const AnalysisObject &ao, const std::string &title="")
 Constructor giving a type, a path, another AO to copy annotation from, and an optional title.
 
virtual ~AnalysisObject ()
 Default destructor.
 
virtual AnalysisObjectoperator= (const AnalysisObject &ao) noexcept
 Default copy assignment operator.
 
std::vector< std::string > annotations () const
 
bool hasAnnotation (const std::string &name) const
 Check if an annotation is defined.
 
const std::string & annotation (const std::string &name) const
 Get an annotation by name (as a string)
 
const std::string & annotation (const std::string &name, const std::string &defaultreturn) const
 Get an annotation by name (as a string) with a default in case the annotation is not found.
 
template<typename T >
const T annotation (const std::string &name) const
 Get an annotation by name (copied to another type)
 
template<typename T >
const T annotation (const std::string &name, const T &defaultreturn) const
 Get an annotation by name (copied to another type) with a default in case the annotation is not found.
 
template<typename T >
void setAnnotation (const std::string &name, const T &value)
 Add or set an annotation by name (templated for remaining types)
 
void setAnnotations (const Annotations &anns)
 Set all annotations at once.
 
template<typename T >
void addAnnotation (const std::string &name, const T &value)
 Add or set an annotation by name.
 
void rmAnnotation (const std::string &name)
 Delete an annotation by name.
 
void clearAnnotations ()
 Delete an annotation by name.
 
const std::string title () const
 Get the AO title.
 
void setTitle (const std::string &title)
 Set the AO title.
 
const std::string path () const
 Get the AO path.
 
void setPath (const std::string &path)
 
const std::string name () const
 
virtual std::string type () const
 Get name of the analysis object type.
 
size_t lengthMeta (const bool skipPath=true, const bool skipTitle=true) const noexcept
 Length of serialized meta-data vector for MPI reduce operations.
 
std::vector< std::string > serializeMeta (const bool skipPath=true, const bool skipTitle=true) const noexcept
 Mate-data serialisation for MPI reduce operations.
 
virtual void deserializeMeta (const std::vector< std::string > &data, const bool resetPath=false, const bool resetTitle=false)
 Mate-data deserialisation for MPI reduce operations.
 

Detailed Description

An estimate in 0D.

This class linkes the Estimate class with AnalysisObject, so it can be used as a type reduction for the Counter type.

Definition at line 23 of file Estimate0D.h.

Member Typedef Documentation

◆ BaseT

Definition at line 28 of file Estimate0D.h.

◆ Ptr

using YODA::Estimate0D::Ptr = std::shared_ptr<Estimate0D>

Definition at line 27 of file Estimate0D.h.

Constructor & Destructor Documentation

◆ Estimate0D() [1/7]

YODA::Estimate0D::Estimate0D ( const std::string &  path = "",
const std::string &  title = "" 
)
inline

Nullary constructor for unique pointers etc.

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

Definition at line 41 of file Estimate0D.h.

42 : BaseT(), AnalysisObject("Estimate0D", path, title) { }
const std::string title() const
Get the AO title.
const std::string path() const
Get the AO path.
AnalysisObject()
Default constructor.

◆ Estimate0D() [2/7]

YODA::Estimate0D::Estimate0D ( double  v,
std::map< std::string, std::pair< double, double > > &  errors,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor to set an Estimate0D with a pre-filled state.

Principally designed for internal persistency use.

Definition at line 48 of file Estimate0D.h.

51 : BaseT(v, errors), AnalysisObject("Estimate0D", path, title) { }

◆ Estimate0D() [3/7]

YODA::Estimate0D::Estimate0D ( const double  v,
const std::pair< double, double > &  e,
const std::string &  source = "",
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Alternative constructor to set an Estimate0D with value and uncertainty.

Definition at line 55 of file Estimate0D.h.

57 : BaseT(v, e, source), AnalysisObject("Estimate0D", path, title) { }

◆ Estimate0D() [4/7]

YODA::Estimate0D::Estimate0D ( const Estimate0D other)
inline

Copy constructor (needed for clone functions).

Note
Compiler won't generate this constructor automatically.

Definition at line 62 of file Estimate0D.h.

62 : Estimate(other),
63 AnalysisObject(other.type(), other.path(), other, other.title()) { }
Estimate()
Default constructor of a new distribution.
Definition Estimate.h:36

◆ Estimate0D() [5/7]

YODA::Estimate0D::Estimate0D ( Estimate0D &&  other)
inline

Move constructor.

Definition at line 66 of file Estimate0D.h.

66 : BaseT(std::move(other)),
67 AnalysisObject(other.type(), other.path(), other, other.title()) { }

◆ Estimate0D() [6/7]

YODA::Estimate0D::Estimate0D ( const BaseT other,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Copy constructor using base class.

Definition at line 70 of file Estimate0D.h.

71 : BaseT(other), AnalysisObject("Estimate0D", path, title) { }

◆ Estimate0D() [7/7]

YODA::Estimate0D::Estimate0D ( BaseT &&  other,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Move constructor using base class.

Definition at line 74 of file Estimate0D.h.

75 : BaseT(std::move(other)), AnalysisObject("Estimate0D", path, title) { }

Member Function Documentation

◆ add() [1/2]

Estimate0D & YODA::Estimate0D::add ( const Estimate0D toAdd,
const std::string &  pat_uncorr = "^stat|^uncor" 
)
inline

Add two Estimate0Ds.

Definition at line 114 of file Estimate0D.h.

114 {
115 if (hasAnnotation("ScaledBy")) rmAnnotation("ScaledBy");
116 BaseT::add(toAdd, pat_uncorr);
117 return *this;
118 }
void rmAnnotation(const std::string &name)
Delete an annotation by name.
bool hasAnnotation(const std::string &name) const
Check if an annotation is defined.
Estimate & add(const Estimate &toAdd, const std::string &pat_uncorr="^stat|^uncor")
Add two Estimates.
Definition Estimate.h:95

References YODA::Estimate::add(), YODA::AnalysisObject::hasAnnotation(), and YODA::AnalysisObject::rmAnnotation().

Referenced by operator+=(), and operator+=().

◆ add() [2/2]

Estimate0D & YODA::Estimate0D::add ( Estimate0D &&  toAdd,
const std::string &  pat_uncorr = "^stat|^uncor" 
)
inline

Add two (rvalue) Estimate0Ds.

Definition at line 125 of file Estimate0D.h.

125 {
126 if (hasAnnotation("ScaledBy")) rmAnnotation("ScaledBy");
127 BaseT::add(std::move(toAdd), pat_uncorr);
128 return *this;
129 }

References YODA::Estimate::add(), YODA::AnalysisObject::hasAnnotation(), and YODA::AnalysisObject::rmAnnotation().

◆ clone()

Estimate0D YODA::Estimate0D::clone ( ) const
inlinenoexcept

Make a copy on the stack.

Definition at line 78 of file Estimate0D.h.

78 {
79 return Estimate0D(*this);
80 }
Estimate0D(const std::string &path="", const std::string &title="")
Nullary constructor for unique pointers etc.
Definition Estimate0D.h:41

◆ deserializeContent()

void YODA::Estimate0D::deserializeContent ( const std::vector< double > &  data)
inlinevirtual

Content deserialisation for MPI reduce operations.

Implements YODA::AnalysisObject.

Definition at line 241 of file Estimate0D.h.

241 {
242 BaseT::_deserializeContent(data, data.size() == 4);
243 }

◆ dim()

size_t YODA::Estimate0D::dim ( ) const
inlinevirtualnoexcept

Total dimension of this data object.

Implements YODA::AnalysisObject.

Definition at line 162 of file Estimate0D.h.

162{ return 1; }

◆ lengthContent()

size_t YODA::Estimate0D::lengthContent ( bool  fixed_length = false) const
inlinevirtualnoexcept

Length of serialized content vector for MPI reduce operations.

Implements YODA::AnalysisObject.

Definition at line 233 of file Estimate0D.h.

233 {
234 return BaseT::_lengthContent(fixed_length);
235 }

◆ mkInert()

AnalysisObject * YODA::Estimate0D::mkInert ( const std::string &  path = "",
const std::string &  source = "" 
) const
inlinevirtualnoexcept

Method returns clone of the estimate with streamlined error source.

Reimplemented from YODA::AnalysisObject.

Definition at line 265 of file Estimate0D.h.

266 {
267 Estimate0D* rtn = newclone();
268 rtn->setPath(path);
269 if (rtn->numErrs() == 1) {
270 try {
271 rtn->renameSource("", source);
272 }
273 catch (YODA::UserError& e) { }
274 }
275 return rtn;
276 }
Estimate0D * newclone() const noexcept
Make a copy on the heap.
Definition Estimate0D.h:83
Error for problems introduced outside YODA, to put it nicely.
Definition Exceptions.h:100

References newclone(), YODA::Estimate::numErrs(), YODA::AnalysisObject::path(), YODA::Estimate::renameSource(), and YODA::AnalysisObject::setPath().

◆ mkScatter()

Scatter1D YODA::Estimate0D::mkScatter ( const std::string &  path = "") const
inlinenoexcept

Definition at line 250 of file Estimate0D.h.

250 {
251 Scatter1D rtn;
252 for (const std::string& a : annotations()) {
253 if (a != "Type") rtn.setAnnotation(a, annotation(a));
254 }
255 rtn.setAnnotation("Path", path);
256
257 // Add the PointND
258 const double tot = quadSum().second; // use positive error component
259 rtn.addPoint( Point1D(val(), {tot, tot}) );
260
261 return rtn;
262 }
std::vector< std::string > annotations() const
const std::string & annotation(const std::string &name) const
Get an annotation by name (as a string)
double val() const noexcept
The central value.
Definition Estimate.h:238
std::pair< double, double > quadSum() const noexcept
Get the quadrature sum of uncertainty components.
Definition Estimate.h:330
PointND< 1 > Point1D
User-familiar alias.
Definition Point.h:704
ScatterND< 1 > Scatter1D
Definition Scatter.h:881

References YODA::ScatterND< N >::addPoint(), YODA::AnalysisObject::annotation(), YODA::AnalysisObject::annotations(), YODA::AnalysisObject::path(), YODA::Estimate::quadSum(), YODA::AnalysisObject::setAnnotation(), and YODA::Estimate::val().

◆ newclone()

Estimate0D * YODA::Estimate0D::newclone ( ) const
inlinevirtualnoexcept

Make a copy on the heap.

Implements YODA::AnalysisObject.

Definition at line 83 of file Estimate0D.h.

83 {
84 return new Estimate0D(*this);
85 }

Referenced by YODA::Counter::mkInert(), and mkInert().

◆ operator+=() [1/2]

Estimate0D & YODA::Estimate0D::operator+= ( const Estimate0D toAdd)
inline

Definition at line 120 of file Estimate0D.h.

120 {
121 return add(toAdd);
122 }
Estimate0D & add(const Estimate0D &toAdd, const std::string &pat_uncorr="^stat|^uncor")
Add two Estimate0Ds.
Definition Estimate0D.h:114

References add().

◆ operator+=() [2/2]

Estimate0D & YODA::Estimate0D::operator+= ( Estimate0D &&  toAdd)
inline

Definition at line 131 of file Estimate0D.h.

131 {
132 return add(std::move(toAdd));
133 }

References add().

◆ operator-=() [1/2]

Estimate0D & YODA::Estimate0D::operator-= ( const Estimate0D toSubtract)
inline

Definition at line 142 of file Estimate0D.h.

142 {
143 return subtract(toSubtract);
144 }
Estimate0D & subtract(const Estimate0D &toSubtract, const std::string &pat_uncorr="^stat|^uncor")
Subtract two Estimate0Ds.
Definition Estimate0D.h:136

References subtract().

◆ operator-=() [2/2]

Estimate0D & YODA::Estimate0D::operator-= ( Estimate0D &&  toSubtract)
inline

Definition at line 152 of file Estimate0D.h.

152 {
153 return subtract(std::move(toSubtract));
154 }

References subtract().

◆ operator=() [1/2]

Estimate0D & YODA::Estimate0D::operator= ( const Estimate0D toCopy)
inlinenoexcept

Copy assignment

Sets all the parameters using the ones provided from an existing Estimate0D.

Definition at line 96 of file Estimate0D.h.

96 {
97 if (this != &toCopy) {
99 BaseT::operator = (toCopy);
100 }
101 return *this;
102 }
virtual AnalysisObject & operator=(const AnalysisObject &ao) noexcept
Default copy assignment operator.
Estimate & operator=(const Estimate &toCopy) noexcept
Definition Estimate.h:69

References YODA::AnalysisObject::operator=(), and YODA::Estimate::operator=().

◆ operator=() [2/2]

Estimate0D & YODA::Estimate0D::operator= ( Estimate0D &&  toMove)
inlinenoexcept

Move assignment.

Definition at line 105 of file Estimate0D.h.

105 {
106 if (this != &toMove) {
108 BaseT::operator = (std::move(toMove));
109 }
110 return *this;
111 }

References YODA::AnalysisObject::operator=(), and YODA::Estimate::operator=().

◆ reset()

void YODA::Estimate0D::reset ( )
inlinevirtualnoexcept

Reset the internal values.

Implements YODA::AnalysisObject.

Definition at line 170 of file Estimate0D.h.

170 {
171 BaseT::reset();
172 }
void reset() noexcept
Reset the internal values.
Definition Estimate.h:194

References YODA::Estimate::reset().

◆ serializeContent()

std::vector< double > YODA::Estimate0D::serializeContent ( bool  fixed_length = false) const
inlinevirtualnoexcept

Content serialisation for MPI reduce operations.

Implements YODA::AnalysisObject.

Definition at line 237 of file Estimate0D.h.

237 {
238 return BaseT::_serializeContent(fixed_length);
239 }

◆ subtract() [1/2]

Estimate0D & YODA::Estimate0D::subtract ( const Estimate0D toSubtract,
const std::string &  pat_uncorr = "^stat|^uncor" 
)
inline

Subtract two Estimate0Ds.

Definition at line 136 of file Estimate0D.h.

136 {
137 if (hasAnnotation("ScaledBy")) rmAnnotation("ScaledBy");
138 BaseT::subtract(toSubtract, pat_uncorr);
139 return *this;
140 }
Estimate & subtract(const Estimate &toSubtract, const std::string &pat_uncorr="^stat|^uncor")
Subtract one Estimate from another.
Definition Estimate.h:125

References YODA::AnalysisObject::hasAnnotation(), YODA::AnalysisObject::rmAnnotation(), and YODA::Estimate::subtract().

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

◆ subtract() [2/2]

Estimate0D & YODA::Estimate0D::subtract ( Estimate0D &&  toSubtract,
const std::string &  pat_uncorr = "^stat|^uncor" 
)
inline

Subtract two (rvalue) Estimate0Ds.

Definition at line 147 of file Estimate0D.h.

147 {
148 if (hasAnnotation("ScaledBy")) rmAnnotation("ScaledBy");
149 BaseT::subtract(std::move(toSubtract), pat_uncorr);
150 return *this;
151 }

References YODA::AnalysisObject::hasAnnotation(), YODA::AnalysisObject::rmAnnotation(), and YODA::Estimate::subtract().


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