PandaRoot
RhoDoubleErr.h
Go to the documentation of this file.
1 #ifndef RHODOUBLEERR_H
2 #define RHODOUBLEERR_H
3 // //
5 // RhoDoubleErr //
6 // //
7 // Double w/ error //
8 // //
9 // Author: Marcel Kunze, RUB, Nov. 99 //
10 // Copyright (C) 1999-2001, Ruhr-University Bochum. //
11 // Ralf Kliemt, HIM/GSI Feb.2013 (Cleanup & Restructuring) //
12 // //
14 
15 // Description:
16 // Class TDoubleErr holds a Double_t and its error squared,
17 // the equivalent of a TVectorErr with one dimension.
18 //
19 // determineChisq(Double_t ref) returns (ref-value())^2 / covariance().
20 // If the covariance() <= 0 then returns TError::chisqUndef.
21 //
22 // The mathematical operators can be used to correctly take into account
23 // error propagation through simple mathematical operations. Beware of
24 // operations whose covariance may not be the same as the one which
25 // results from a sequence of simple operations. For example, a*a will give
26 // the wrong covariance, since the algorithm assumes that the two arguments
27 // of the operator* are independent.
28 
29 #include "TBuffer.h"
30 #include "TObject.h"
31 #include "RhoError.h" // for chisqUndef only
32 
33 class RhoDoubleErr : public TObject {
34  public:
35  // Constructors: The fCovariance and the fValue are 0.0 unless specified:
36  RhoDoubleErr() : fValue(0.0), fCovariance(0.0){};
37  RhoDoubleErr(Double_t val) : fValue(val), fCovariance(0.0){};
38  RhoDoubleErr(Double_t val, Double_t cov) : fValue(val), fCovariance(cov){};
39 
40  // Copy Constructor
41  RhoDoubleErr(const RhoDoubleErr &);
42 
43  // Destructor
44  virtual ~RhoDoubleErr() {}
45 
46  // Assignment operator:
48 
49  // Accessors (const)
50  Double_t Value() const { return fValue; }
51  Double_t Covariance() const { return fCovariance; }
52  Double_t DetermineChisq(Double_t ref) const;
53 
54  RhoDoubleErr operator-(); // value() -> -value(), covariance() unaffected
57 
58  // NOTE: (a * b).covariance() is
59  // b^2 * a.covariance() + a^2 * b.covariance()
61 
62  // NOTE: (a / b).covariance() is
63  // a.covariance() / b^2 + b.covariance() * a^2 / b^4
65 
66  // modifiers:
67  void SetValue(Double_t val) { fValue = val; }
68  void SetCovariance(Double_t cov) { fCovariance = cov; }
69 
74 
75  // needed for RWTValOrderedVector
76  Bool_t operator==(const RhoDoubleErr &other) const { return (fValue == other.fValue && fCovariance == other.fCovariance); }
77  Bool_t operator<(const RhoDoubleErr &other) const { return (fValue < other.fValue); }
78 
79  private:
80  // Data members
81  Double_t fValue;
82  Double_t fCovariance;
83 
84  public:
85  ClassDef(RhoDoubleErr, 1) // holds a Double_t and its error squared
86 };
87 
88 std::ostream &operator<<(std::ostream &stream, const RhoDoubleErr &bde);
89 
90 #endif
void SetCovariance(Double_t cov)
Definition: RhoDoubleErr.h:68
Bool_t operator==(const RhoDoubleErr &other) const
Definition: RhoDoubleErr.h:76
RhoDoubleErr & operator/=(const RhoDoubleErr &)
void SetValue(Double_t val)
Definition: RhoDoubleErr.h:67
RhoDoubleErr operator+(const RhoDoubleErr &)
RhoDoubleErr & operator=(const RhoDoubleErr &)
RhoDoubleErr(Double_t val)
Definition: RhoDoubleErr.h:37
Bool_t operator<(const RhoDoubleErr &other) const
Definition: RhoDoubleErr.h:77
virtual ~RhoDoubleErr()
Definition: RhoDoubleErr.h:44
RhoDoubleErr(Double_t val, Double_t cov)
Definition: RhoDoubleErr.h:38
RhoDoubleErr & operator+=(const RhoDoubleErr &)
std::ostream & operator<<(std::ostream &stream, const RhoDoubleErr &bde)
Double_t DetermineChisq(Double_t ref) const
RhoDoubleErr operator*(const RhoDoubleErr &)
RhoDoubleErr operator/(const RhoDoubleErr &)
RhoDoubleErr & operator*=(const RhoDoubleErr &)
RhoDoubleErr & operator-=(const RhoDoubleErr &)
RhoDoubleErr operator-()
Double_t Value() const
Definition: RhoDoubleErr.h:50
Double_t Covariance() const
Definition: RhoDoubleErr.h:51