#include #ifndef USE_SSE2 // Matrix class without SIMD instructions class DMatrix2x2{ public: DMatrix2x2(){ mA[0][0]=mA[0][1]=mA[1][0]=mA[1][1]=0.; } ~DMatrix2x2(){}; DMatrix2x2(double d11, double d12, double d21, double d22){ mA[0][0]=d11; mA[0][1]=d12; mA[1][0]=d21; mA[1][1]=d22; } // Access by row and column double &operator() (int row, int col){ return mA[row][col]; } double operator() (int row, int col) const{ return mA[row][col]; } // Assignment operator DMatrix2x2 &operator=(const DMatrix2x2 &m1){ mA[0][0]=m1(0,0); mA[1][0]=m1(1,0); mA[0][1]=m1(0,1); mA[1][1]=m1(1,1); return *this; } // unary minus DMatrix2x2 operator-() const{ return DMatrix2x2(-mA[0][0],-mA[0][1],-mA[1][0],-mA[1][1]); } // Matrix multiplication: (2x2) x (2x2) DMatrix2x2 operator*(const DMatrix2x2 &m2){ return DMatrix2x2(mA[0][0]*m2(0,0)+mA[0][1]*m2(1,0), mA[0][0]*m2(0,1)+mA[0][1]*m2(1,1), mA[1][0]*m2(0,0)+mA[1][1]*m2(1,0), mA[1][0]*m2(0,1)+mA[1][1]*m2(1,1)); } // Matrix multiplication: (2x2) x (2x1) DMatrix2x1 operator*(const DMatrix2x1 &m2){ return DMatrix2x1(mA[0][0]*m2(0)+mA[0][1]*m2(1), mA[1][0]*m2(0)+mA[1][1]*m2(1)); } // Matrix addition DMatrix2x2 operator+(const DMatrix2x2 &m2){ return DMatrix2x2(mA[0][0]+m2(0,0),mA[0][1]+m2(0,1),mA[1][0]+m2(1,0), mA[1][1]+m2(1,1)); } // Matrix subtraction DMatrix2x2 operator-(const DMatrix2x2 &m2){ return DMatrix2x2(mA[0][0]-m2(0,0),mA[0][1]-m2(0,1),mA[1][0]-m2(1,0), mA[1][1]-m2(1,1)); } // Matrix inversion DMatrix2x2 Invert(){ double one_over_det=1./(mA[0][0]*mA[1][1]-mA[0][1]*mA[1][0]); return DMatrix2x2(one_over_det*mA[1][1],-one_over_det*mA[0][1], -one_over_det*mA[1][0],one_over_det*mA[0][0]); } // Compute the determinant double Determinant(){ return mA[0][0]*mA[1][1]-mA[0][1]*mA[1][0]; } //Compute the chi2 contribution for a pair of hits with residual R and covariance "this" double Chi2(const DMatrix2x1 &R) const{ return ( (R(0)*R(0)*mA[1][1]-R(0)*R(1)*(mA[0][1]+mA[1][0]) +R(1)*R(1)*mA[0][0])/ (mA[0][0]*mA[1][1]-mA[0][1]*mA[1][0])); } void Print(){ cout << "DMatrix2x2:" <