ATLAS Offline Software
Loading...
Searching...
No Matches
StatVal.h
Go to the documentation of this file.
1/* emacs: this is -*- c++ -*- */
14
15
16#ifndef RESPLOT_STATVAL_H
17#define RESPLOT_STATVAL_H
18
19#include <iostream>
20#include <iomanip>
21#include <cmath>
22
23
25
26class StatVal {
27
28public:
29
30 double value;
31 double error;
32
33 StatVal() : value(0), error(0) { }
34 StatVal(double v) : value(v) { error=( v>=0 ? sqrt(v) : sqrt(-v) ); }
35 StatVal(double v, double e) : value(v), error(e) { }
36
37
38 // operator for StatVal*=double
39 StatVal operator*=(const double& d) { value*=d; error*=d; return (*this); }
40 // operator for StatVal*double (for double*StatVal see later)
41 StatVal operator*(const double& d) const { return StatVal(d*value, d*error); }
42 // StatVal/double
43 StatVal operator/(const double& d) const { return StatVal(value/d, error/d); }
44
45 // can't be bothered with the rest...
46
47};
48
49
50// operator for double*StatVal
51inline StatVal operator*(double d, const StatVal& sv) { return sv*d; }
52
53// streamer;
54inline std::ostream& operator<<(std::ostream& s, const StatVal& sv) {
55 return s << sv.value << "+-" << sv.error;
56}
57
58
59
60
61#endif /* RESPLOT_STATVAL_H */
62
std::ostream & operator<<(std::ostream &s, const StatVal &sv)
Definition StatVal.h:54
StatVal operator*(double d, const StatVal &sv)
Definition StatVal.h:51
simple struct to hold a value and it's associated uncertainty.
Definition StatVal.h:26
StatVal(double v)
Definition StatVal.h:34
StatVal operator*(const double &d) const
Definition StatVal.h:41
StatVal(double v, double e)
Definition StatVal.h:35
StatVal operator/(const double &d) const
Definition StatVal.h:43
double value
Definition StatVal.h:30
StatVal()
Definition StatVal.h:33
StatVal operator*=(const double &d)
Definition StatVal.h:39