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;
48 std::cout <<
"&fidpointvec: " << std::endl;
49 for (
count_t i = 0;
i != fidpointvec.size();
i++)
50 std::cout <<
i <<
": " << fidpointvec[
i] << std::endl;
51 std::cout <<
"&fidpoints_: " << std::endl;
57 ROOT::Math::SMatrix<value_t, nMsrmts, nLcD>
A;
60 A(0, 2) = +fidpointvec[0].x();
61 A(0, 3) = +fidpointvec[0].y();
64 A(1, 2) = +fidpointvec[0].y();
65 A(1, 3) = -fidpointvec[0].x();
68 A(2, 2) = +fidpointvec[1].x();
69 A(2, 3) = +fidpointvec[1].y();
72 A(3, 2) = +fidpointvec[1].y();
73 A(3, 3) = -fidpointvec[1].x();
76 A(4, 2) = +fidpointvec[2].x();
77 A(4, 3) = +fidpointvec[2].y();
80 A(5, 2) = +fidpointvec[2].y();
81 A(5, 3) = -fidpointvec[2].x();
84 A(6, 2) = +fidpointvec[3].x();
85 A(6, 3) = +fidpointvec[3].y();
88 A(7, 2) = +fidpointvec[3].y();
89 A(7, 3) = -fidpointvec[3].x();
95 ROOT::Math::SMatrix<value_t, nMsrmts, nMsrmts> W;
99 W(0, 0) = sigma_x2inv;
100 W(1, 1) = sigma_y2inv;
101 W(2, 2) = sigma_x2inv;
102 W(3, 3) = sigma_y2inv;
103 W(4, 4) = sigma_x2inv;
104 W(5, 5) = sigma_y2inv;
105 W(6, 6) = sigma_x2inv;
106 W(7, 7) = sigma_y2inv;
112 ROOT::Math::SMatrix<value_t, nLcD, nLcD> ATWA;
113 ATWA = ROOT::Math::Transpose(A) * W *
A;
116 ROOT::Math::SMatrix<value_t, nLcD, nLcD> ATWAi;
118 ATWAi = ATWA.Inverse(ifail);
120 std::cout <<
"Problem singular - fit impossible." << std::endl;
125 std::cout <<
"ATWA-1: \n" << ATWAi << ifail << std::endl;
129 ROOT::Math::SVector<value_t, nMsrmts>
y;
143 ROOT::Math::SVector<value_t, nLcD>
a;
144 a = ATWAi * ROOT::Math::Transpose(A) * W *
y;
145 chi2_ = ROOT::Math::Dot(y, W * y) - ROOT::Math::Dot(a, ROOT::Math::Transpose(A) * W * y);
147 std::cout <<
"a: " << a <<
" S= " <<
sqrt(a[2] * a[2] + a[3] * a[3]) <<
" phi= " << atan(a[3] / a[2])
148 <<
" chi2= " <<
chi2_ << std::endl;
149 std::cout <<
"A*a: " << A * a << std::endl;
151 a_.assign(a.begin(), a.end());
233 ROOT::Math::SVector<value_t, 4> mod1, mod2;
246 ROOT::Math::SMatrix<value_t, 4, 4> M1, M2;
283 ROOT::Math::SVector<value_t, 4> mod_tr1, mod_tr2;
290 fidpointvec.push_back(
coord_t(mod_tr1(0), mod_tr1(1)));
291 fidpointvec.push_back(
coord_t(mod_tr1(2), mod_tr1(3)));
292 fidpointvec.push_back(
coord_t(mod_tr2(0), mod_tr2(1)));
293 fidpointvec.push_back(
coord_t(mod_tr2(2), mod_tr2(3)));
300 throw std::logic_error(
301 "SurveyPxbImageLocalFit::getLocalParameters(): Fit is not valid. Call doFit(...) before calling this "
308 throw std::logic_error(
309 "SurveyPxbImageLocalFit::getChi2(): Fit is not valid. Call doFit(...) before calling this function.");
315 throw std::range_error(
"SurveyPxbImageLocalFit::setLocalDerivsToZero(j): j out of range.");
322 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)
static const count_t nLcD
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
ROOT::Math::SMatrix< pede_deriv_t, nMsrmts, nGlD > globalDerivsMatrix_
Matrix with global derivs.
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
ROOT::Math::SMatrix< pede_deriv_t, nMsrmts, nLcD > localDerivsMatrix_
Matrix with local derivs.
void setGlobalDerivsToZero(count_t i)