36static const char rscid[] =
"$Id: BesError.cxx,v 1.2 2009/12/23 02:59:56 zhangy Exp $";
42#include "CLHEP/Matrix/Matrix.h"
43#include "MdcRecoUtil/BesError.h"
50 HepMatrix mat( 3, 3 );
51 mat( 1, 1 ) = rot.xx();
52 mat( 1, 2 ) = rot.xy();
53 mat( 1, 3 ) = rot.xz();
54 mat( 2, 1 ) = rot.yx();
55 mat( 2, 2 ) = rot.yy();
56 mat( 2, 3 ) = rot.yz();
57 mat( 3, 1 ) = rot.zx();
58 mat( 3, 2 ) = rot.zy();
59 mat( 3, 3 ) = rot.zz();
66 HepMatrix mat( 4, 4 );
67 mat( 1, 1 ) = rot.xx();
68 mat( 1, 2 ) = rot.xy();
69 mat( 1, 3 ) = rot.xz();
70 mat( 1, 4 ) = rot.xt();
71 mat( 2, 1 ) = rot.yx();
72 mat( 2, 2 ) = rot.yy();
73 mat( 2, 3 ) = rot.yz();
74 mat( 2, 4 ) = rot.yt();
75 mat( 3, 1 ) = rot.zx();
76 mat( 3, 2 ) = rot.zy();
77 mat( 3, 3 ) = rot.zz();
78 mat( 3, 4 ) = rot.zt();
79 mat( 4, 1 ) = rot.tx();
80 mat( 4, 2 ) = rot.ty();
81 mat( 4, 3 ) = rot.tz();
82 mat( 4, 4 ) = rot.tt();
89 BesError mret( HepSymMatrix::similarity( E ) );
94 assert( num_row() ==
m1.num_row() );
95 HepMatrix temp =
m1 * mat;
98 for (
int r = 0; r < num_row(); r++ )
100 for (
int c = 0; c <= r; c++ )
103 for (
int k = 0; k <
m1.num_col(); k++ ) { tmp += temp[r][k] *
m1[c][k]; }
104 ( *this )[r][c] = tmp;
118 HepMatrix dMat( diff.num_row(), 1 );
120 for (
int i = 0; i < diff.num_row(); i++ ) dMat[i][0] = diff[i];
122 double chisq = ( inverse( ierr ).similarityT( dMat ) )[0][0];
124 if ( ierr == 0 )
return chisq;
129 out <<
"Bes Covariance Matrix:";
130 out << (HepSymMatrix&)mat;
137 while ( isspace( nextChar ) ) { nextChar = in.get(); }
138 in.putback( nextChar );
140 if ( EOF != nextChar )
142 if ( !isdigit( nextChar ) )
145 const int DUMMY_SIZE = 1000;
146 char dummy[DUMMY_SIZE];
147 in.getline( dummy, DUMMY_SIZE );
150 for (
int row = 1; row <= mat.num_row(); ++row )
152 for (
int col = 1; col <= mat.num_col(); ++col ) { in >> mat( row, col ); }
ostream & operator<<(ostream &out, const BesError &mat)
BesError operator-(const BesError &m1, const BesError &m2)
BesError operator+(const BesError &m1, const BesError &m2)
BesError operator*(double t, const BesError &m1)
BesError operator/(double t, const BesError &m1)
istream & operator>>(istream &in, BesError &mat)
BesError & similarityWith(const BesError &m, const HepMatrix &m1)
static const double chisqUndef
BesError similarity(const HepRotation &rot) const
double determineChisq(const HepVector &diff) const