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