10 #include "Math/SMatrix.h"
11 #include "Math/SVector.h"
33 const value_t dxr = fidpointvec[3].x()-fidpointvec[2].x();
34 const value_t dyr = fidpointvec[3].y()-fidpointvec[2].y();
35 const value_t gammar = atan(dyr/dxr);
36 const value_t dxl = fidpointvec[1].x()-fidpointvec[0].x();
37 const value_t dyl = fidpointvec[1].y()-fidpointvec[0].y();
38 const value_t gammal = atan(dyl/dxl);
39 const value_t gamma = gammar-gammal;
44 std::cout <<
"gamma: " << gamma <<
" gamma left: " << gammal <<
" gamma right: " << gammar << std::endl;
49 std::cout <<
"&fidpointvec: " << std::endl;
51 std::cout <<
i <<
": " << fidpointvec[
i] << std::endl;
52 std::cout <<
"&fidpoints_: " << std::endl;
58 ROOT::Math::SMatrix<value_t,nMsrmts,nLcD>
A;
59 A(0,0)=1.;
A(0,1)=0;
A(0,2)=+fidpointvec[0].x();
A(0,3)=+fidpointvec[0].y();
60 A(1,0)=0.;
A(1,1)=1;
A(1,2)=+fidpointvec[0].y();
A(1,3)=-fidpointvec[0].x();
61 A(2,0)=1.;
A(2,1)=0;
A(2,2)=+fidpointvec[1].x();
A(2,3)=+fidpointvec[1].y();
62 A(3,0)=0.;
A(3,1)=1;
A(3,2)=+fidpointvec[1].y();
A(3,3)=-fidpointvec[1].x();
63 A(4,0)=1.;
A(4,1)=0;
A(4,2)=+fidpointvec[2].x();
A(4,3)=+fidpointvec[2].y();
64 A(5,0)=0.;
A(5,1)=1;
A(5,2)=+fidpointvec[2].y();
A(5,3)=-fidpointvec[2].x();
65 A(6,0)=1.;
A(6,1)=0;
A(6,2)=+fidpointvec[3].x();
A(6,3)=+fidpointvec[3].y();
66 A(7,0)=0.;
A(7,1)=1;
A(7,2)=+fidpointvec[3].y();
A(7,3)=-fidpointvec[3].x();
72 ROOT::Math::SMatrix<value_t,nMsrmts,nMsrmts> W;
89 ROOT::Math::SMatrix<value_t,nLcD,nLcD> ATWA;
90 ATWA = ROOT::Math::Transpose(A) * W *
A;
93 ROOT::Math::SMatrix<value_t,nLcD,nLcD> ATWAi;
95 ATWAi = ATWA.Inverse(ifail);
98 std::cout <<
"Problem singular - fit impossible." << std::endl;
103 std::cout <<
"ATWA-1: \n" << ATWAi << ifail << std::endl;
107 ROOT::Math::SVector<value_t,nMsrmts>
y;
121 ROOT::Math::SVector<value_t,nLcD>
a;
122 a = ATWAi * ROOT::Math::Transpose(A) * W *
y;
123 chi2_ = ROOT::Math::Dot(y,W*y)-ROOT::Math::Dot(a,ROOT::Math::Transpose(A)*W*y);
126 <<
" S= " <<
sqrt(a[2]*a[2]+a[3]*a[3])
127 <<
" phi= " << atan(a[3]/a[2])
128 <<
" chi2= " <<
chi2_ << std::endl;
129 std::cout <<
"A*a: " << A*a << std::endl;
131 a_.assign(a.begin(),a.end());
207 ROOT::Math::SVector<value_t,4> mod1, mod2;
220 ROOT::Math::SMatrix<value_t,4,4> M1, M2;
233 ROOT::Math::SVector<value_t,4> mod_tr1, mod_tr2;
240 fidpointvec.push_back(
coord_t(mod_tr1(0),mod_tr1(1)));
241 fidpointvec.push_back(
coord_t(mod_tr1(2),mod_tr1(3)));
242 fidpointvec.push_back(
coord_t(mod_tr2(0),mod_tr2(1)));
243 fidpointvec.push_back(
coord_t(mod_tr2(2),mod_tr2(3)));
250 if (!
fitValidFlag_)
throw std::logic_error(
"SurveyPxbImageLocalFit::getLocalParameters(): Fit is not valid. Call doFit(...) before calling this function.");
256 if (!
fitValidFlag_)
throw std::logic_error(
"SurveyPxbImageLocalFit::getChi2(): Fit is not valid. Call doFit(...) before calling this function.");
262 if (!(j <
nLcD))
throw std::range_error(
"SurveyPxbImageLocalFit::setLocalDerivsToZero(j): j out of range.");
269 if (!(j <
nGlD))
throw std::range_error(
"SurveyPxbImageLocalFit::setLocalDerivsToZero(j): j out of range.");
std::vector< coord_t > fidpoint_t
localpars_t getLocalParameters()
returns local parameters after fit
void setLocalDerivsToZero(count_t i)
bool fitValidFlag_
Validity Flag.
Sin< T >::type sin(const T &t)
std::vector< pede_label_t > labelVec2_
value_t sigma_x_
Gaussian errors.
localpars_t a_
Local parameters.
value_t getChi2()
returns the chi^2 of the fit
ROOT::Math::SVector< value_t, nMsrmts > r
Vector of residuals.
Point3DBase< value_t, LocalTag > coord_t
static const count_t nGlD
Cos< T >::type cos(const T &t)
ROOT::Math::SMatrix< pede_deriv_t, nMsrmts, nLcD > localDerivsMatrix_
Matrix with local derivs.
static const count_t nLcD
ROOT::Math::SMatrix< pede_deriv_t, nMsrmts, nGlD > globalDerivsMatrix_
Matrix with global derivs.
std::vector< pede_label_t > labelVec1_
Vector with labels to global derivs.
void doFit(const fidpoint_t &fidpointvec)
Invoke the fit.
value_t chi2_
chi2 of the local fit
std::vector< value_t > localpars_t
std::vector< coord_t > fidpoints_
True position of the fiducial points on a sensor wrt. local frame (u,v)
std::vector< coord_t > measurementVec_
Vector to hold four measurements.
static const count_t nMsrmts
void setGlobalDerivsToZero(count_t i)