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

A point estimate (base class for the Estimate) More...

#include <Estimate.h>

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

Public Member Functions

Constructors
 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
 
Operators
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)
 
Modifiers
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.
 
Estimate getters
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
 
MPI (de-)serialisation
std::vector< std::string > serializeSources () const noexcept
 
void deserializeSources (const std::vector< std::string > &data)
 

Detailed Description

A point estimate (base class for the Estimate)

This class is used internally by YODA to centralise the storage of static statistical results or estimators. Each estimate is made up of a value and an error map. The error map uses the source of uncertainty as the keys and the (possibly asymmetric) uncertainty pair as the values. The empty string is interpreted as the total uncertainty.

Definition at line 29 of file Estimate.h.

Constructor & Destructor Documentation

◆ Estimate() [1/5]

YODA::Estimate::Estimate ( )
inline

Default constructor of a new distribution.

Definition at line 36 of file Estimate.h.

36{ reset(); }
void reset() noexcept
Reset the internal values.
Definition Estimate.h:194

References reset().

◆ Estimate() [2/5]

YODA::Estimate::Estimate ( double  v,
std::map< std::string, std::pair< double, double > > &  errors 
)
inline

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

Principally designed for internal persistency use.

Definition at line 42 of file Estimate.h.

43 : _value(v), _error(errors) { }

◆ Estimate() [3/5]

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

Alternative constructor to set an Estimate with value and uncertainty.

Definition at line 47 of file Estimate.h.

48 : _value(v) { setErr(e, source); }
void setErr(const std::pair< double, double > &err, const std::string &source="")
Set a signed uncertainty component.
Definition Estimate.h:165

References setErr().

◆ Estimate() [4/5]

YODA::Estimate::Estimate ( const Estimate toCopy)
inline

Copy constructor

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

Definition at line 53 of file Estimate.h.

53 {
54 _value = toCopy._value;
55 _error = toCopy._error;
56 }

◆ Estimate() [5/5]

YODA::Estimate::Estimate ( Estimate &&  toMove)
inline

Move constructor

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

Definition at line 61 of file Estimate.h.

61 {
62 _value = std::move(toMove._value);
63 _error = std::move(toMove._error);
64 }

Member Function Documentation

◆ add()

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

Add two Estimates.

Definition at line 95 of file Estimate.h.

95 {
96 setVal(val() + toAdd.val());
97 std::smatch match;
98 const std::regex re(pat_uncorr);
99 for (const std::string& src : toAdd.sources()) {
100 if (!hasSource(src)) setErr(toAdd.errDownUp(src), src);
101 else if (std::regex_search(src, match, re)) {
102 // treat as uncorrelated between AOs:
103 // add in quadrature
104 const auto [l_dn,l_up] = errDownUp(src);
105 const auto [r_dn,r_up] = toAdd.errDownUp(src);
106 const double new_dn = std::sqrt(l_dn*l_dn + r_dn*r_dn);
107 const double new_up = std::sqrt(l_up*l_up + r_up*r_up);
108 setErr({-new_dn,new_up}, src);
109 }
110 else {
111 // treat as correlated between AOs: add linearly
112 const auto [l_dn,l_up] = errDownUp(src);
113 const auto [r_dn,r_up] = toAdd.errDownUp(src);
114 setErr({l_dn+r_dn, l_up+r_up}, src);
115 }
116 }
117 return *this;
118 }
std::vector< std::string > sources() const noexcept
Definition Estimate.h:408
double val() const noexcept
The central value.
Definition Estimate.h:238
void setVal(const double val) noexcept
Alias for setValue.
Definition Estimate.h:162
std::pair< double, double > errDownUp(const std::string &source="") const
The signed absolute error on the central value.
Definition Estimate.h:244
bool hasSource(const std::string &key) const noexcept
Definition Estimate.h:414

References errDownUp(), hasSource(), setErr(), setVal(), sources(), and val().

Referenced by YODA::Estimate0D::add(), YODA::Estimate0D::add(), and operator+=().

◆ deserializeSources()

void YODA::Estimate::deserializeSources ( const std::vector< std::string > &  data)
inline

Definition at line 482 of file Estimate.h.

482 {
483
484 const size_t nErrs = numErrs();
485 if (data.size() != nErrs)
486 throw UserError("Expected " + std::to_string(nErrs) + " error source labels!");
487
488 for (size_t i = 0; i < data.size(); ++i) {
489 const std::string name("source" + std::to_string(i+1));
490 if (!_error.count(name))
491 throw UserError("Key names have already been updated!");
492 renameSource(name, data[i]);
493 }
494
495 }
size_t numErrs() const noexcept
Definition Estimate.h:418
void renameSource(const std::string &old_label, const std::string &new_label)
Replace a source label in the error breakdown.
Definition Estimate.h:219

References numErrs(), and renameSource().

◆ err()

std::pair< double, double > YODA::Estimate::err ( const std::string &  source = "") const
inline

Convenience alias for errorDownUp(source)

Definition at line 252 of file Estimate.h.

252 {
253 return errDownUp(source);
254 }

References errDownUp().

Referenced by set(), set(), setErr(), and setErr().

◆ errAvg()

double YODA::Estimate::errAvg ( const std::string &  source = "") const
inline

The average uncertainty component.

Definition at line 282 of file Estimate.h.

282 {
283 return _average(errDownUp(source));
284 }

References errDownUp().

◆ errDown()

double YODA::Estimate::errDown ( const std::string &  source = "") const
inline

The signed error due to the systematic downward variation.

Definition at line 272 of file Estimate.h.

272 {
273 return errDownUp(source).first;
274 }

References errDownUp().

Referenced by YODA::divide().

◆ errDownUp()

std::pair< double, double > YODA::Estimate::errDownUp ( const std::string &  source = "") const
inline

The signed absolute error on the central value.

Note
first/second element corresponds to systematic down/up variation

Definition at line 244 of file Estimate.h.

244 {
245 const size_t count = _error.count(source);
246 if (!count)
247 throw RangeError("Error map has no such key: "+source);
248 return _error.at(source);
249 }

Referenced by add(), err(), errAvg(), errDown(), errNegPos(), errUp(), relErrDownUp(), and subtract().

◆ errNeg()

double YODA::Estimate::errNeg ( const std::string &  source = "") const
inline

The signed negative uncertainty component.

Definition at line 262 of file Estimate.h.

262 {
263 return errNegPos(source).first;
264 }
std::pair< double, double > errNegPos(std::string source="") const
The signed negative and positive uncertainty component.
Definition Estimate.h:257

References errNegPos().

Referenced by valMin().

◆ errNegPos()

std::pair< double, double > YODA::Estimate::errNegPos ( std::string  source = "") const
inline

The signed negative and positive uncertainty component.

Definition at line 257 of file Estimate.h.

257 {
258 return _downUp2NegPos( errDownUp(source) );
259 }

References errDownUp().

Referenced by errNeg(), and errPos().

◆ errPos()

double YODA::Estimate::errPos ( const std::string &  source = "") const
inline

The signed positive uncertainty component.

Definition at line 267 of file Estimate.h.

267 {
268 return errNegPos(source).second;
269 }

References errNegPos().

Referenced by valMax().

◆ errUp()

double YODA::Estimate::errUp ( const std::string &  source = "") const
inline

The signed error due to the systematic upward variation.

Definition at line 277 of file Estimate.h.

277 {
278 return errDownUp(source).second;
279 }

References errDownUp().

Referenced by YODA::divide().

◆ hasSource()

bool YODA::Estimate::hasSource ( const std::string &  key) const
inlinenoexcept

Definition at line 414 of file Estimate.h.

414 {
415 return _error.count(key);
416 }

Referenced by add(), YODA::divide(), renameSource(), and subtract().

◆ numErrs()

size_t YODA::Estimate::numErrs ( ) const
inlinenoexcept

Definition at line 418 of file Estimate.h.

418 {
419 return _error.size();
420 }

Referenced by deserializeSources(), and YODA::Estimate0D::mkInert().

◆ operator+=()

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

Definition at line 120 of file Estimate.h.

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

References add().

◆ operator-=()

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

Definition at line 149 of file Estimate.h.

149 {
150 return subtract(toSubtract);
151 }
Estimate & subtract(const Estimate &toSubtract, const std::string &pat_uncorr="^stat|^uncor")
Subtract one Estimate from another.
Definition Estimate.h:125

References subtract().

◆ operator=() [1/2]

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

Copy assignment

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

Definition at line 69 of file Estimate.h.

69 {
70 if (this != &toCopy) {
71 _value = toCopy._value;
72 _error = toCopy._error;
73 }
74 return *this;
75 }

Referenced by YODA::Estimate0D::operator=(), and YODA::Estimate0D::operator=().

◆ operator=() [2/2]

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

Move assignment

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

Definition at line 80 of file Estimate.h.

80 {
81 if (this != &toMove) {
82 _value = std::move(toMove._value);
83 _error = std::move(toMove._error);
84 }
85 return *this;
86 }

◆ quadSum()

std::pair< double, double > YODA::Estimate::quadSum ( ) const
inlinenoexcept

Get the quadrature sum of uncertainty components.

Note
The first element is for the negative error, the second element for the positive error.

Definition at line 330 of file Estimate.h.

330 {
331 // interpret as { neg , pos } quad sums
332 std::pair<double, double> ret = { 0., 0. };
333 for (const auto& item : _error) {
334 const auto [dn,up] = _downUp2NegPos(item.second);
335 ret.first += dn*dn;
336 ret.second += up*up;
337 }
338 return { - std::sqrt(ret.first), std::sqrt(ret.second) };
339 }

Referenced by YODA::Estimate0D::mkScatter(), quadSumAvg(), quadSumNeg(), quadSumPos(), and totalErr().

◆ quadSumAvg()

double YODA::Estimate::quadSumAvg ( ) const
inlinenoexcept

The average uncertainty component.

Definition at line 350 of file Estimate.h.

350 {
351 return _average(quadSum());
352 }
std::pair< double, double > quadSum() const noexcept
Get the quadrature sum of uncertainty components.
Definition Estimate.h:330

References quadSum().

◆ quadSumNeg()

double YODA::Estimate::quadSumNeg ( ) const
inlinenoexcept

Definition at line 341 of file Estimate.h.

341 {
342 return quadSum().first;
343 }

References quadSum().

◆ quadSumPos()

double YODA::Estimate::quadSumPos ( ) const
inlinenoexcept

Definition at line 345 of file Estimate.h.

345 {
346 return quadSum().second;
347 }

References quadSum().

◆ relErr()

std::pair< double, double > YODA::Estimate::relErr ( const std::string &  source = "") const
inline

Convenience alias for relErrDownUp.

Definition at line 295 of file Estimate.h.

295 {
296 return relErrDownUp(source);
297 }
std::pair< double, double > relErrDownUp(const std::string &source="") const
The relative error on the central value.
Definition Estimate.h:287

References relErrDownUp().

Referenced by relErrDown(), and relErrUp().

◆ relErrAvg()

double YODA::Estimate::relErrAvg ( const std::string &  source = "") const
inline

The average uncertainty component.

Definition at line 310 of file Estimate.h.

310 {
311 return _average(relErrDownUp(source));
312 }

References relErrDownUp().

◆ relErrDown()

double YODA::Estimate::relErrDown ( const std::string &  source = "") const
inline

The relative negative on the central value.

Definition at line 300 of file Estimate.h.

300 {
301 return relErr(source).first;
302 }
std::pair< double, double > relErr(const std::string &source="") const
Convenience alias for relErrDownUp.
Definition Estimate.h:295

References relErr().

Referenced by YODA::divide().

◆ relErrDownUp()

std::pair< double, double > YODA::Estimate::relErrDownUp ( const std::string &  source = "") const
inline

The relative error on the central value.

Definition at line 287 of file Estimate.h.

287 {
288 auto [dn,up] = errDownUp(source);
289 dn = _value != 0 ? dn/fabs(_value) : std::numeric_limits<double>::quiet_NaN();
290 up = _value != 0 ? up/fabs(_value) : std::numeric_limits<double>::quiet_NaN();
291 return {dn,up};
292 }

References errDownUp().

Referenced by relErr(), and relErrAvg().

◆ relErrUp()

double YODA::Estimate::relErrUp ( const std::string &  source = "") const
inline

The relative positive on the central value.

Definition at line 305 of file Estimate.h.

305 {
306 return relErr(source).second;
307 }

References relErr().

Referenced by YODA::divide().

◆ relTotalErr()

std::pair< double, double > YODA::Estimate::relTotalErr ( ) const
inlinenoexcept

The relative negative/positive total uncertainty on the central value.

Definition at line 386 of file Estimate.h.

386 {
387 auto [neg,pos] = totalErr();
388 neg = _value != 0 ? neg/fabs(_value) : std::numeric_limits<double>::quiet_NaN();
389 pos = _value != 0 ? pos/fabs(_value) : std::numeric_limits<double>::quiet_NaN();
390 return {neg,pos};
391 }
std::pair< double, double > totalErr() const noexcept
The total uncertainty.
Definition Estimate.h:358

References totalErr().

Referenced by relTotalErrAvg(), relTotalErrNeg(), and relTotalErrPos().

◆ relTotalErrAvg()

double YODA::Estimate::relTotalErrAvg ( ) const
inlinenoexcept

The average uncertainty component.

Definition at line 404 of file Estimate.h.

404 {
405 return _average(relTotalErr());
406 }
std::pair< double, double > relTotalErr() const noexcept
The relative negative/positive total uncertainty on the central value.
Definition Estimate.h:386

References relTotalErr().

Referenced by YODA::efficiency().

◆ relTotalErrNeg()

double YODA::Estimate::relTotalErrNeg ( ) const
inlinenoexcept

The relative negative total uncertainty on the central value.

Definition at line 394 of file Estimate.h.

394 {
395 return relTotalErr().first;
396 }

References relTotalErr().

◆ relTotalErrPos()

double YODA::Estimate::relTotalErrPos ( ) const
inlinenoexcept

The relative positive total uncertainty on the central value.

Definition at line 399 of file Estimate.h.

399 {
400 return relTotalErr().second;
401 }

References relTotalErr().

◆ renameSource()

void YODA::Estimate::renameSource ( const std::string &  old_label,
const std::string &  new_label 
)
inline

Replace a source label in the error breakdown.

Definition at line 219 of file Estimate.h.

219 {
220 if (!hasSource(old_label)) {
221 throw UserError("Error map has no such key: "+old_label);
222 }
223 auto entry = _error.extract(old_label);
224 entry.key() = new_label;
225 _error.insert(std::move(entry));
226 }

References hasSource().

Referenced by deserializeSources(), and YODA::Estimate0D::mkInert().

◆ reset()

void YODA::Estimate::reset ( )
inlinenoexcept

Reset the internal values.

Definition at line 194 of file Estimate.h.

194 {
195 _value = std::numeric_limits<double>::quiet_NaN();
196 _error.clear();
197 }

Referenced by Estimate(), and YODA::Estimate0D::reset().

◆ scale() [1/2]

void YODA::Estimate::scale ( const double  scalefactor)
inlinenoexcept

Rescale as if value and uncertainty had been different by factor scalefactor.

Definition at line 201 of file Estimate.h.

201 {
202 _value *= scalefactor;
203 for (auto& item : _error) {
204 item.second = { item.second.first * scalefactor, item.second.second * scalefactor };
205 }
206 }

Referenced by transform().

◆ scale() [2/2]

void YODA::Estimate::scale ( const Trf< 1 > &  trf)
inline

Generalised transformations with functors.

Definition at line 209 of file Estimate.h.

209 {
210 trf.transform(_value, _error);
211 }

References YODA::Transformation< N, Args >::transform().

◆ serializeSources()

std::vector< std::string > YODA::Estimate::serializeSources ( ) const
inlinenoexcept

Definition at line 478 of file Estimate.h.

478 {
479 return sources();
480 }

References sources().

◆ set() [1/2]

void YODA::Estimate::set ( const double  val,
const double  err,
const std::string &  source = "" 
)
inline

Set both central value and uncertainty component.

Definition at line 188 of file Estimate.h.

188 {
189 setVal(val);
190 setErr(err, source);
191 }
std::pair< double, double > err(const std::string &source="") const
Convenience alias for errorDownUp(source)
Definition Estimate.h:252

References err(), setErr(), setVal(), and val().

◆ set() [2/2]

void YODA::Estimate::set ( const double  val,
const std::pair< double, double > &  err,
const std::string  source = "" 
)
inline

Set both central value and uncertainty component.

Definition at line 181 of file Estimate.h.

181 {
182 setVal(val);
183 setErr(err, source);
184 }

References err(), setErr(), setVal(), and val().

Referenced by YODA::divide(), YODA::efficiency(), and YODA::Counter::mkEstimate().

◆ setErr() [1/2]

void YODA::Estimate::setErr ( const double  err,
const std::string &  source = "" 
)
inline

Set a symmetric uncertainty component.

Note
The down-component will be set to -|err| and the up-component will be set to +|err|.

Definition at line 176 of file Estimate.h.

176 {
177 setErr({-fabs(err),fabs(err)}, source);
178 }

References err(), and setErr().

◆ setErr() [2/2]

void YODA::Estimate::setErr ( const std::pair< double, double > &  err,
const std::string &  source = "" 
)
inline

Set a signed uncertainty component.

Definition at line 165 of file Estimate.h.

165 {
166 const std::string& s = Utils::toUpper(source);
167 if (s == "TOTAL")
168 throw UserError("Use empty string for the total uncertainty!");
169 _error[source] = err;
170 }

References err().

Referenced by add(), YODA::divide(), YODA::efficiency(), Estimate(), set(), set(), setErr(), and subtract().

◆ setVal()

void YODA::Estimate::setVal ( const double  val)
inlinenoexcept

Alias for setValue.

Definition at line 162 of file Estimate.h.

162{ setValue(val); }
void setValue(const double value) noexcept
Set the central value of this estimator.
Definition Estimate.h:159

References setValue(), and val().

Referenced by add(), YODA::divide(), set(), set(), and subtract().

◆ setValue()

void YODA::Estimate::setValue ( const double  value)
inlinenoexcept

Set the central value of this estimator.

Definition at line 159 of file Estimate.h.

159{ _value = value; }

Referenced by setVal().

◆ sources()

std::vector< std::string > YODA::Estimate::sources ( ) const
inlinenoexcept

Definition at line 408 of file Estimate.h.

408 {
409 std::vector<std::string> keys;
410 for (const auto& item : _error) keys.push_back(item.first);
411 return keys;
412 }

Referenced by add(), YODA::divide(), YODA::efficiency(), serializeSources(), and subtract().

◆ subtract()

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

Subtract one Estimate from another.

Definition at line 125 of file Estimate.h.

125 {
126 setVal(val() - toSubtract.val());
127 std::smatch match;
128 const std::regex re(pat_uncorr);
129 for (const std::string& src : toSubtract.sources()) {
130 if (!hasSource(src)) setErr(toSubtract.errDownUp(src), src);
131 else if (std::regex_search(src, match, re)) {
132 // treat as uncorrelated between AOs: add in quadrature
133 const auto [l_dn,l_up] = errDownUp(src);
134 const auto [r_dn,r_up] = toSubtract.errDownUp(src);
135 const double new_dn = std::sqrt(l_dn*l_dn + r_dn*r_dn);
136 const double new_up = std::sqrt(l_up*l_up + r_up*r_up);
137 setErr({-new_dn,new_up}, src);;
138 }
139 else {
140 // treat as correlated between AOs: add linearly
141 const auto [l_dn,l_up] = errDownUp(src);
142 const auto [r_dn,r_up] = toSubtract.errDownUp(src);
143 setErr({l_dn+r_dn, l_up+r_up}, src);
144 }
145 }
146 return *this;
147 }

References errDownUp(), hasSource(), setErr(), setVal(), sources(), and val().

Referenced by operator-=(), YODA::Estimate0D::subtract(), and YODA::Estimate0D::subtract().

◆ totalErr()

std::pair< double, double > YODA::Estimate::totalErr ( ) const
inlinenoexcept

The total uncertainty.

Note
If the user didn't specify a total uncertainty using the empty string, the sum in quadrature is returned.

Definition at line 358 of file Estimate.h.

358 {
359 // check if the user specified the total uncertainty
360 if (_error.count("")) return _downUp2NegPos(_error.at(""));
361 // otherwise return quadrature sum
362 return quadSum();
363 }

References quadSum().

Referenced by relTotalErr(), totalErrAvg(), totalErrNeg(), and totalErrPos().

◆ totalErrAvg()

double YODA::Estimate::totalErrAvg ( ) const
inline

The average total uncertainty.

Definition at line 376 of file Estimate.h.

376 {
377 return _average(totalErr());
378 }

References totalErr().

Referenced by YODA::efficiency(), and valueErr().

◆ totalErrNeg()

double YODA::Estimate::totalErrNeg ( ) const
inlinenoexcept

The negative total uncertainty.

Definition at line 366 of file Estimate.h.

366 {
367 return totalErr().first;
368 }

References totalErr().

◆ totalErrPos()

double YODA::Estimate::totalErrPos ( ) const
inlinenoexcept

The positive total uncertainty.

Definition at line 371 of file Estimate.h.

371 {
372 return totalErr().second;
373 }

References totalErr().

◆ transform()

void YODA::Estimate::transform ( const Trf< 1 > &  trf)
inline

Generalised transformations with functors.

Definition at line 214 of file Estimate.h.

214 {
215 scale(trf);
216 }
void scale(const double scalefactor) noexcept
Rescale as if value and uncertainty had been different by factor scalefactor.
Definition Estimate.h:201

References scale().

Referenced by YODA::transform().

◆ val()

double YODA::Estimate::val ( ) const
inlinenoexcept

The central value.

Definition at line 238 of file Estimate.h.

238{ return _value; }

Referenced by add(), YODA::divide(), YODA::efficiency(), YODA::Estimate0D::mkScatter(), set(), set(), setVal(), subtract(), valMax(), and valMin().

◆ valMax()

double YODA::Estimate::valMax ( const std::string &  source = "") const
inline

The maximal shift of the central value according to systematic variation source

Definition at line 316 of file Estimate.h.

316 {
317 return val() + errPos(source);
318 }
double errPos(const std::string &source="") const
The signed positive uncertainty component.
Definition Estimate.h:267

References errPos(), and val().

◆ valMin()

double YODA::Estimate::valMin ( const std::string &  source = "") const
inline

The minimal shift of the central value according to systematic variation source

Definition at line 322 of file Estimate.h.

322 {
323 return val() + errNeg(source);
324 }
double errNeg(const std::string &source="") const
The signed negative uncertainty component.
Definition Estimate.h:262

References errNeg(), and val().

◆ valueErr()

double YODA::Estimate::valueErr ( ) const
inline

The unsigned average total uncertainty.

Definition at line 381 of file Estimate.h.

381 {
382 return fabs(totalErrAvg());
383 }
double totalErrAvg() const
The average total uncertainty.
Definition Estimate.h:376

References totalErrAvg().


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