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
23namespace Resplot {
24
26
27class StatVal {
28
29public:
30
31 double value;
32 double error;
33
34 StatVal() : value(0), error(0) { }
35 StatVal(double v) : value(v) { error=( v>=0 ? sqrt(v) : sqrt(-v) ); }
36 StatVal(double v, double e) : value(v), error(e) { }
37
38
39 // operator for StatVal*=double
40 StatVal operator*=(const double& d) { value*=d; error*=d; return (*this); }
41 // operator for StatVal*double (for double*StatVal see later)
42 StatVal operator*(const double& d) const { return StatVal(d*value, d*error); }
43 // StatVal/double
44 StatVal operator/(const double& d) const { return StatVal(value/d, error/d); }
45
46 // can't be bothered with the rest...
47
48};
49
50
51// operator for double*StatVal
52inline StatVal operator*(double d, const StatVal& sv) { return sv*d; }
53
54// streamer;
55inline std::ostream& operator<<(std::ostream& s, const StatVal& sv) {
56 return s << sv.value << "+-" << sv.error;
57}
58
59
60}
61
62#endif /* RESPLOT_STATVAL_H */
63
simple struct to hold a value and it's associated uncertainty.
Definition StatVal.h:27
StatVal operator*=(const double &d)
Definition StatVal.h:40
StatVal(double v, double e)
Definition StatVal.h:36
StatVal operator*(const double &d) const
Definition StatVal.h:42
StatVal operator/(const double &d) const
Definition StatVal.h:44
StatVal(double v)
Definition StatVal.h:35
std::ostream & operator<<(std::ostream &s, const StatVal &sv)
Definition StatVal.h:55