FairRoot/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 {
35  public:
36 
37  // Constructors: The fCovariance and the fValue are 0.0 unless specified:
38  RhoDoubleErr() : fValue ( 0.0 ), fCovariance ( 0.0 ) {};
39  RhoDoubleErr ( Double_t val ) : fValue ( val ), fCovariance ( 0.0 ) {};
40  RhoDoubleErr ( Double_t val, Double_t cov ) : fValue ( val ), fCovariance ( cov ) {};
41 
42  // Copy Constructor
43  RhoDoubleErr ( const RhoDoubleErr& );
44 
45  // Destructor
46  virtual ~RhoDoubleErr() {}
47 
48  // Assignment operator:
50 
51  // Accessors (const)
52  Double_t Value() const {
53  return fValue;
54  }
55  Double_t Covariance() const {
56  return fCovariance;
57  }
58  Double_t DetermineChisq ( Double_t ref ) const;
59 
60  RhoDoubleErr operator-(); // value() -> -value(), covariance() unaffected
63 
64  // NOTE: (a * b).covariance() is
65  // b^2 * a.covariance() + a^2 * b.covariance()
67 
68  // NOTE: (a / b).covariance() is
69  // a.covariance() / b^2 + b.covariance() * a^2 / b^4
71 
72  // modifiers:
73  void SetValue ( Double_t val ) {
74  fValue = val;
75  }
76  void SetCovariance ( Double_t cov ) {
77  fCovariance = cov;
78  }
79 
84 
85  // needed for RWTValOrderedVector
86  Bool_t operator == ( const RhoDoubleErr& other ) const {
87  return ( fValue == other.fValue && fCovariance == other.fCovariance );
88  }
89  Bool_t operator < ( const RhoDoubleErr& other ) const {
90  return ( fValue < other.fValue );
91  }
92 
93 
94  private:
95  // Data members
98 
99  public:
100  ClassDef ( RhoDoubleErr,1 ) // holds a Double_t and its error squared
101 };
102 
103 std::ostream& operator<< ( std::ostream& stream, const RhoDoubleErr& bde );
104 
105 #endif
void SetCovariance(Double_t cov)
Definition: RhoDoubleErr.h:76
Double_t val[nBoxes][nFEBox]
Definition: createCalib.C:11
void SetValue(Double_t val)
Definition: RhoDoubleErr.h:73
RhoDoubleErr operator+(const RhoDoubleErr &)
RhoDoubleErr & operator*=(const RhoDoubleErr &)
Bool_t operator==(const RhoDoubleErr &other) const
Definition: RhoDoubleErr.h:86
RhoDoubleErr & operator+=(const RhoDoubleErr &)
Double_t fCovariance
Definition: RhoDoubleErr.h:97
RhoDoubleErr(Double_t val)
Definition: RhoDoubleErr.h:39
virtual ~RhoDoubleErr()
Definition: RhoDoubleErr.h:46
RhoDoubleErr(Double_t val, Double_t cov)
Definition: RhoDoubleErr.h:40
Double_t Covariance() const
Definition: RhoDoubleErr.h:55
Double_t
std::ostream & operator<<(std::ostream &stream, const RhoDoubleErr &bde)
RhoDoubleErr operator*(const RhoDoubleErr &)
Bool_t operator<(const RhoDoubleErr &other) const
Definition: RhoDoubleErr.h:89
Double_t fValue
Definition: RhoDoubleErr.h:96
RhoDoubleErr operator/(const RhoDoubleErr &)
Double_t DetermineChisq(Double_t ref) const
RhoDoubleErr operator-()
RhoDoubleErr & operator-=(const RhoDoubleErr &)
RhoDoubleErr & operator/=(const RhoDoubleErr &)
Double_t Value() const
Definition: RhoDoubleErr.h:52
RhoDoubleErr & operator=(const RhoDoubleErr &)