46 int iter, iterMax = 20;
51 double M0, Mx, My, Mz, Mxy, Mxx, Myy, Mxz, Myz, Mzz, Mxz2, Myz2, Cov_xy;
52 double A0,A1,
A2,A22,A3,A33,
epsilon=0.000000000001;
53 double Dy,xnew,xold,ynew,yold=100000000000.;
61 const double copt = 0.2;
62 const double zero = 0.0001;
63 const double SigmaMin = 0.18;
64 double amax = -100000;
75 if(fRobust < 1 || fRobust > 2){
85 for(
int i = 0; i < nofHits; i++) {
91 for(
int i = 0; i < nofHits; i++){
92 if (a[i] > amax) amax = a[i];
93 if (a[i] < amin) amin = a[i];
96 for(
int i = 0; i < nofHits; i++) w.push_back(1.);
98 for(
int riter = 0; riter < riterMax; riter++){
102 for(
int i = 0; i < nofHits; i++) {
112 Mxx=Myy=Mxy=Mxz=Myz=Mzz=0.;
114 for (
int i = 0; i < nofHits; i++) {
135 Cov_xy = Mxx*Myy - Mxy*Mxy;
140 A2 = - 3.*Mz*Mz - Mzz;
141 A1 = Mzz*Mz + 4.*Cov_xy*Mz - Mxz2 - Myz2 - Mz*Mz*Mz;
142 A0 = Mxz2*Myy + Myz2*Mxx - Mzz*Cov_xy - 2.*Mxz*Myz*Mxy+Mz*Mz*Cov_xy;
150 for (iter=0; iter<iterMax; iter++) {
151 ynew = A0 + xnew*(A1 + xnew*(A2 + xnew*A3));
153 if (fabs(ynew)>fabs(yold)) {
158 Dy = A1 + xnew*(A22 + xnew*A33);
160 xnew = xold - ynew/
Dy;
162 if (fabs((xnew-xold)/xnew) <
epsilon)
break;
165 if (iter == iterMax-1) {
176 DET = xnew*xnew - xnew*Mz + Cov_xy;
177 centerX = (Mxz*(Myy-xnew) - Myz*Mxy)/DET/2.;
178 centerY = (Myz*(Mxx-xnew) - Mxz*Mxy)/DET/2.;
179 radius = sqrt(centerX * centerX + centerY * centerY - GAM);
180 centerX = (Mxz*(Myy - xnew) - Myz*Mxy)/DET/2. + Mx;
181 centerY = (Myz*(Mxx - xnew) - Mxz*Mxy)/DET/2. + My;
183 if(riter < riterMax - 1){
184 for(
int i = 0; i < nofHits; i++){
185 dist = sqrt(pow((centerX - x[i]), 2) + pow((centerY - y[i]), 2)) -
radius;
190 for(
int i = 0; i < d.size(); i++){
191 sig1 += w[i]*d[i]*d[i];
194 sigma = sqrt(sig1/sig2);
195 if(sigma < SigmaMin) sigma = SigmaMin;
201 for(
int i = 0; i < d.size(); i++){
204 weight = pow((1 - pow((d[i]/ctsigma), 2)), 2);
205 if(weight < zero) weight =
zero;
214 weight /= 1 + copt*exp(pow((d[i]/sigma), 2));
215 if(weight < zero) weight =
zero;