ValueErr.h File Reference

#include <Rtypes.h>
#include <TMath.h>
#include <iostream>
#include <fstream>

Go to the source code of this file.

Classes

class  ValueErr< T >

Typedefs

typedef ValueErr< double > DoubleErr
typedef ValueErr< float > FloatErr

Functions

template<class T >
std::ifstream & operator>> (std::ifstream &ins, ValueErr< T > &x)
template<class T >
std::ostream & operator<< (std::ostream &outs, const ValueErr< T > &x)
template<class T >
ValueErr< T > operator+ (const T &lhs, const ValueErr< T > &rhs)
template<class T >
ValueErr< T > operator+ (const ValueErr< T > &lhs, const T &rhs)
template<class T >
ValueErr< T > operator+ (const ValueErr< T > &lhs, const ValueErr< T > &rhs)
template<class T >
ValueErr< T > operator- (const T &lhs, const ValueErr< T > &rhs)
template<class T >
ValueErr< T > operator- (const ValueErr< T > &lhs, const T &rhs)
template<class T >
ValueErr< T > operator- (const ValueErr< T > &lhs, const ValueErr< T > &rhs)
template<class T >
ValueErr< T > operator* (const T &lhs, const ValueErr< T > &rhs)
template<class T >
ValueErr< T > operator* (const ValueErr< T > &lhs, const T &rhs)
template<class T >
ValueErr< T > operator* (const ValueErr< T > &lhs, const ValueErr< T > &rhs)
template<class T >
ValueErr< T > operator/ (const T &lhs, const ValueErr< T > &rhs)
template<class T >
ValueErr< T > operator/ (const ValueErr< T > &lhs, const T &rhs)
template<class T >
ValueErr< T > operator/ (const ValueErr< T > &lhs, const ValueErr< T > &rhs)

Variables

const float kValueErr_Big = 1e19

Typedef Documentation

typedef ValueErr<double> DoubleErr

Definition at line 117 of file Calibrator/HEAD/ValueErr.h.

typedef ValueErr<float> FloatErr

Definition at line 118 of file Calibrator/HEAD/ValueErr.h.


Function Documentation

template<class T >
ValueErr<T> operator* ( const ValueErr< T > &  lhs,
const ValueErr< T > &  rhs 
) [inline]

Definition at line 167 of file Calibrator/HEAD/ValueErr.h.

References ValueErr< T >::GetFracError2(), ValueErr< T >::GetValue(), kValueErr_Big, and ValueErr< T >::valueErr2().

00168 {
00169   T x = lhs.GetValue() * rhs.GetValue();
00170   T err2;
00171   if(x!=0) 
00172     err2 = x*x * ( lhs.GetFracError2() + rhs.GetFracError2() );
00173   else 
00174     err2 = kValueErr_Big;  // FIXME: could use some presciption here.
00175   return ValueErr<T>::valueErr2(x,err2);
00176 }

template<class T >
ValueErr<T> operator* ( const ValueErr< T > &  lhs,
const T &  rhs 
) [inline]

Definition at line 163 of file Calibrator/HEAD/ValueErr.h.

References ValueErr< T >::GetError(), ValueErr< T >::GetValue(), and ValueErr< T >::valueErr2().

00164 { return ValueErr<T>::valueErr2(lhs.GetValue() * rhs, lhs.GetError()*rhs*rhs); }

template<class T >
ValueErr<T> operator* ( const T &  lhs,
const ValueErr< T > &  rhs 
) [inline]

Definition at line 159 of file Calibrator/HEAD/ValueErr.h.

References ValueErr< T >::GetError2(), ValueErr< T >::GetValue(), and ValueErr< T >::valueErr2().

00160 { return ValueErr<T>::valueErr2(lhs * rhs.GetValue(), rhs.GetError2()*lhs*lhs); }

template<class T >
ValueErr<T> operator+ ( const ValueErr< T > &  lhs,
const ValueErr< T > &  rhs 
) [inline]

Definition at line 133 of file Calibrator/HEAD/ValueErr.h.

References ValueErr< T >::GetError2(), ValueErr< T >::GetValue(), and ValueErr< T >::valueErr2().

00134 {
00135   T value = ( lhs.GetValue()  + rhs.GetValue());
00136   T err2  = ( lhs.GetError2() + rhs.GetError2() );
00137   return ValueErr<T>::valueErr2(value,err2);
00138 }

template<class T >
ValueErr<T> operator+ ( const ValueErr< T > &  lhs,
const T &  rhs 
) [inline]
template<class T >
ValueErr<T> operator+ ( const T &  lhs,
const ValueErr< T > &  rhs 
) [inline]
template<class T >
ValueErr<T> operator- ( const ValueErr< T > &  lhs,
const ValueErr< T > &  rhs 
) [inline]

Definition at line 150 of file Calibrator/HEAD/ValueErr.h.

References ValueErr< T >::GetError2(), ValueErr< T >::GetValue(), and ValueErr< T >::valueErr2().

00151 {
00152   T value = ( lhs.GetValue() - rhs.GetValue() );
00153   T err2  = ( lhs.GetError2() + rhs.GetError2());
00154   return ValueErr<T>::valueErr2(value,err2);
00155 }

template<class T >
ValueErr<T> operator- ( const ValueErr< T > &  lhs,
const T &  rhs 
) [inline]
template<class T >
ValueErr<T> operator- ( const T &  lhs,
const ValueErr< T > &  rhs 
) [inline]
template<class T >
ValueErr<T> operator/ ( const ValueErr< T > &  lhs,
const ValueErr< T > &  rhs 
) [inline]

Definition at line 189 of file Calibrator/HEAD/ValueErr.h.

References ValueErr< T >::GetError2(), ValueErr< T >::GetValue(), and ValueErr< T >::valueErr2().

00190 {
00191   // Note: doesn't trap rhs=0 (i.e. divide-by-zero)
00192   T x = lhs.GetValue();
00193   T y = rhs.GetValue();
00194   T f = x/y;
00195   T y2 = y*y;
00196   T x2 = x*x;
00197   // err = x/y * sqrt( dx2/x2 + dy2/y2)    // This works, but has a div-by-zero for x=0
00198   T err2 = ( lhs.GetError2()/y2  + rhs.GetError2()*x2/(y2*y2) ); // This is ok for y!=0
00199 
00200   return ValueErr<T>::valueErr2(f,err2);
00201 }

template<class T >
ValueErr<T> operator/ ( const ValueErr< T > &  lhs,
const T &  rhs 
) [inline]

Definition at line 185 of file Calibrator/HEAD/ValueErr.h.

References ValueErr< T >::GetError2(), ValueErr< T >::GetValue(), and ValueErr< T >::valueErr2().

00186 { return ValueErr<T>::valueErr2(lhs.GetValue() / rhs, lhs.GetError2()/(rhs*rhs)); }

template<class T >
ValueErr<T> operator/ ( const T &  lhs,
const ValueErr< T > &  rhs 
) [inline]

Definition at line 181 of file Calibrator/HEAD/ValueErr.h.

References ValueErr< T >::GetError2(), ValueErr< T >::GetValue(), ValueErr< T >::GetValue2(), and ValueErr< T >::valueErr2().

00182 { return ValueErr<T>::valueErr2(lhs / rhs.GetValue(), lhs * lhs * rhs.GetError2() / (rhs.GetValue2()*rhs.GetValue2() )); }

template<class T >
std::ostream& operator<< ( std::ostream &  outs,
const ValueErr< T > &  x 
) [inline]

Definition at line 28 of file Calibrator/HEAD/ValueErr.cxx.

00029 {
00030   outs << x.GetValue() << kPlusMinus << x.GetError();
00031   return outs;
00032 }

template<class T >
std::ifstream& operator>> ( std::ifstream &  ins,
ValueErr< T > &  x 
) [inline]

Definition at line 17 of file Calibrator/HEAD/ValueErr.cxx.

00018 {
00019   T value;
00020   T error;
00021   ins >> value >> error;
00022   x.Set(value,error);
00023   return ins;
00024 }


Variable Documentation

const float kValueErr_Big = 1e19

Generated on 12 Mar 2019 for loon by  doxygen 1.6.1