/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/MdcPatRec/MdcRecoUtil/MdcRecoUtil-00-01-08/MdcRecoUtil/BesError.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: BesError.h,v 1.5 2010/03/25 09:55:57 zhangy Exp $
00004 //
00005 // Description:
00006 //      A wrapper for a covariance matrix.  A covariance matrix is
00007 //      a symmetric n X n matrix.  Change in chisq from point
00008 //      covariance matrix was determined is just
00009 //
00010 //      diff * covariance^-1 * diff_transpose
00011 //
00012 //      which is implemented in a similarity transform in HepSymMatrix
00013 //      the method determineChisq carries this calculation out and requires
00014 //      the result to be a scalar.
00015 //      
00016 //
00017 // Environment:
00018 //      Software developed for the BaBar Detector at the SLAC B-Factory.
00019 //
00020 // Author List:
00021 //      Forest Rouse                Jan 1996
00022 //      Victoria Novotny            Aug 1996
00023 //
00024 // Copyright Information:
00025 //      Copyright (C) 1996
00026 // 
00027 // History:
00028 //      Migration for BESIII MDC
00029 //
00030 //------------------------------------------------------------------------
00031 #ifndef BESERROR_HH
00032 #define BESERROR_HH
00033 
00034 #include <iostream>
00035 #include <math.h>
00036 
00037 #include "CLHEP/Matrix/Vector.h"
00038 #include "CLHEP/Matrix/Matrix.h"
00039 #include "CLHEP/Matrix/SymMatrix.h"
00040 #include "CLHEP/Vector/Rotation.h"
00041 #include "CLHEP/Vector/LorentzRotation.h"
00042 
00043 
00044 using namespace CLHEP;
00045 
00046 class BesError : public HepSymMatrix {
00047 
00048 public:
00049 
00050   static const double chisqUndef;
00051   BesError() : HepSymMatrix() {}
00052 
00053   BesError(int n) : HepSymMatrix(n, 0)                          {}
00054 
00055   // autocast copy constructor.  HepSymMatrix's promoted back
00056   // into BesError matrices.
00057 
00058   BesError( const HepSymMatrix &p ) : HepSymMatrix(p)           {}
00059 
00060   // new constructors for this class
00061   BesError(const BesError& v) : HepSymMatrix() {*this = v;}
00062 
00063   BesError& operator=(const BesError& v)
00064     {
00065           if (this != &v) {
00066             HepSymMatrix::operator=(v);
00067       }
00068       return *this;
00069     }
00070 
00071   BesError& operator=(const HepSymMatrix& v)
00072     {
00073           if (this != &v) {
00074             HepSymMatrix::operator=(v);
00075       }
00076       return *this;
00077     }
00078 
00079   // destructor MAY be needed later
00080   // virtual ~BesError() {};
00081 
00082   //----------------------------------------------------------------------
00083   // determineChisq
00084   //    Compute v^T * V^(-1)*v - ie the chisq for this covariance
00085   //    matrix and the difference vector v.
00086   //----------------------------------------------------------------------
00087 
00088   double determineChisq(const HepVector& diff) const; 
00089 
00090   // Get right signature for all operations performed on BesError matrices
00091   // that should (and will) result in BesError matrices.  These include
00092   // similarity transforms, transpose, inverse, matrix multiplication,
00093   // addition, and subtraction.  HepSymMatrix's as a result of operations
00094   // are promoted back into BesError matrices if we start out
00095   // with BesError matrices in the first place. (See copy constructors)
00096 
00097   BesError& operator *= (double t)
00098     { return (BesError&) HepSymMatrix::operator*=(t); }
00099 
00100   BesError& operator /= (double t)
00101     {return (BesError&) HepSymMatrix::operator/=(t); }
00102 
00103   BesError& operator += (const BesError& m2)
00104     {
00105       HepSymMatrix::operator+=(m2);
00106       return *this;
00107     }
00108 
00109   BesError& operator -= (const BesError& m2)
00110     {
00111       HepSymMatrix::operator-=(m2);
00112       return *this;
00113     }
00114 
00115   BesError operator - ()
00116     { BesError temp(*this); 
00117       return temp; }
00118   // does nothing -- covariance Matrices have never negative entries on the 
00119   // main diagonal
00120 
00121   // Implement the signature for operators I also inherit
00122   BesError& operator += (const HepSymMatrix& m2)
00123     {
00124       HepSymMatrix::operator+=(m2);
00125       return *this;
00126     }
00127 
00128   BesError& operator -= (const HepSymMatrix& m2)
00129     {
00130       HepSymMatrix::operator-=(m2);
00131       return *this;
00132     }
00133 
00134   BesError operator - () const
00135     { BesError temp(*this); 
00136     return temp;}
00137 
00138   BesError& operator += (const HepDiagMatrix& m2)
00139     {
00140       HepSymMatrix::operator+=(m2);
00141       return *this;
00142     }
00143 
00144   BesError& operator -= (const HepDiagMatrix& m2)
00145     {
00146       HepSymMatrix::operator-=(m2);
00147       return *this;
00148     }
00149 
00150   BesError similarity(const HepRotation& rot) const;
00151   BesError similarity(const HepLorentzRotation& rot) const;
00152   // When feasible implement R * covMatrix * R_transpose (= R^-1)
00153 
00154   BesError similarity(const BesError& E);
00155   // implement E * covMatrix * E
00156 
00157   BesError similarity(const HepMatrix& m1) const
00158     {
00159       BesError mret(m1.num_row());
00160       mret.similarityWith(*this, m1);
00161       return mret;
00162     }
00163 
00164   BesError& similarityWith(const BesError& m, const HepMatrix& m1);
00165 
00166   // provide call ups to base classes similarity methods not implemented
00167   // here
00168   double similarity(const HepVector &v) const
00169        { return this->HepSymMatrix::similarity( v ); }
00170   HepSymMatrix similarity(const HepSymMatrix &m1) const
00171        { return this->HepSymMatrix::similarity( m1 ); }
00172 
00173 private:
00174     
00175   friend BesError operator*(double t, const BesError& m1);
00176 
00177   friend BesError operator*(const BesError& m1, double t);
00178 
00179   friend BesError operator/(double t, const BesError& m1);
00180 
00181   friend BesError operator/(const BesError& m1, double t);
00182 
00183   friend BesError operator+(const BesError& m1, const BesError& m2);
00184  
00185   friend BesError operator-(const BesError& m1, const BesError& m2);
00186   
00187   friend std::ostream& operator<<(std::ostream& out, const BesError& mat);
00188   friend std::istream& operator>>(std::istream& in, BesError& mat);
00189   
00190 };
00191 
00192 #endif
00193 
00194 
00195 
00196 
00197 
00198 

Generated on Tue Nov 29 23:13:31 2016 for BOSS_7.0.2 by  doxygen 1.4.7