9 : _hough_space(nullptr),_cur_zoom(0)
27 float x = hitpos3d[0];
28 float y = hitpos3d[1];
29 float z = hitpos3d[2];
32 float z0_min = z0_range[0];
33 float z0_max = z0_range[1];
34 float kappa_min = kappa_phi_d_ranges[0];
35 float kappa_max = kappa_phi_d_ranges[1];
36 float phi_min = kappa_phi_d_ranges[2];
37 float phi_max = kappa_phi_d_ranges[3];
39 float cosphi_min = cos(phi_min);
40 float cosphi_max = cos(phi_max);
41 float sinphi_min = sin(phi_min);
42 float sinphi_max = sin(phi_max);
44 if (phi_max -phi_min >
M_PI) {
51 float d_min = kappa_phi_d_ranges[4];
52 float d_max = kappa_phi_d_ranges[5];
59 float dzdl[4]={-999,-999,-999,-999};
60 for (
int icase=0; icase<2; icase++){
63 d= d_min; dx=d*cosphi_min; dy=d*sinphi_min;k=kappa_min;
66 d= d_max; dx=d*cosphi_max; dy=d*sinphi_max;k=kappa_max;
70 float D = sqrt(pow(x-dx,2)+pow(y-dy,2));
71 float a = k*D/2.;
float a2 = a*
a;
73 if (a > .999) {a = 0.999; s = 2*asin(a)/
k; }
74 else if (a < 0.01){ s = D + a2*D/6. + 3/40.*a2*a2*D + 5/112.*a2*a2*a2;}
75 else { s = 2*asin(a)/
k;}
79 dzdl[0] = pow(z-z0_max,2)/(pow(z-z0_max,2)+s*
s);
80 dzdl[0] = sqrt(dzdl[0]);
81 if (z < z0_max) dzdl[0] *= -1;
82 dzdl[1] = pow(z-z0_min,2)/(pow(z-z0_min,2)+s*
s);
83 dzdl[1] = sqrt(dzdl[1]);
84 if (z < z0_min) dzdl[1] *= -1;
90 dzdl[2] = pow(z-z0_max,2)/(pow(z-z0_max,2)+s*
s);
91 dzdl[2] = sqrt(dzdl[2]);
92 if (z < z0_max) dzdl[2] *= -1;
93 dzdl[3] = pow(z-z0_min,2)/(pow(z-z0_min,2)+s*
s);
94 dzdl[3] = sqrt(dzdl[3]);
95 if (z < z0_min) dzdl[3] *= -1;
106 float dzdl_min = -999;
107 float dzdl_max = -999;
115 for (
int i = 1; i<4; i++) {
116 if (dzdl_min > dzdl[i])
120 for (
int j = 1; j<4; j++) {
121 if (dzdl_max < dzdl[j])
130 dzdl_range[0] = dzdl_min;
131 dzdl_range[1] = dzdl_max;
138 float x = hitpos2d[0];
139 float y = hitpos2d[1];
140 float hitphi= atan2(y,x);
141 if (hitphi < 0.) hitphi += 2.*
M_PI;
143 float kmin = kappa_d_ranges[0];
144 float kmax = kappa_d_ranges[1];
145 float dmin = kappa_d_ranges[2];
146 float dmax = kappa_d_ranges[3];
151 float D, Dinv, ak, hk, hksq, xk1, xk2, yk1,yk2;
152 float phi[8] = {-999,-999,-999,-999,-999,-999,-999,-999};
154 for (
int icase=0; icase<4; icase++ ){
173 ak = (2.*d + d*d*k + D*D*
k)/2.*Dinv;
174 hksq = pow(d*k+1.,2) - ak*ak;
177 xk1 = (ak*x + hk*
y)*Dinv;
178 xk2 = (ak*x - hk*
y)*Dinv;
179 yk1 = (ak*y - hk*
x)*Dinv;
180 yk2 = (ak*y + hk*
x)*Dinv;
189 phi[0]= atan2(yk1,xk1);
190 if (phi[0]<0.) phi[0]+= 2.*
M_PI;
191 phi[1]= atan2(yk2,xk2);
192 if (phi[1]<0.) phi[1]+= 2.*
M_PI;
201 phi[2]=atan2(yk1,xk1);
202 if (phi[2]<0.) phi[2]+= 2.*
M_PI;
203 phi[3]= atan2(yk2,xk2);
204 if (phi[3]<0.) phi[3]+= 2.*
M_PI;
213 phi[4]=atan2(yk1,xk1);
214 if (phi[4]<0.) phi[4]+= 2.*
M_PI;
215 phi[5]=atan2(yk2,xk2);
216 if (phi[5]<0.) phi[5]+= 2.*
M_PI;
225 phi[6]=atan2(yk1,xk1);
226 if (phi[6]<0.) phi[6]+= 2.*
M_PI;
227 phi[7]=atan2(yk2,xk2);
228 if (phi[7]<0.) phi[7]+= 2.*
M_PI;
237 float piover2=
M_PI/2.;
238 float threepiover2=3.*
M_PI/2.;
239 bool first = (phi[0]<piover2) || (phi[2]<piover2) || (phi[4]<piover2 || (phi[6]<piover2));
240 bool fourth = (phi[0]>threepiover2) || (phi[2]>threepiover2) || (phi[4]>threepiover2) || (phi[6]>threepiover2);
242 if (first && fourth){
243 if (phi[0]>threepiover2) phi[0] -=
twopi;
244 if (phi[2]>threepiover2) phi[2] -=
twopi;
245 if (phi[4]>threepiover2) phi[4] -=
twopi;
246 if (phi[6]>threepiover2) phi[6] -=
twopi;
249 float phi_r_min = phi[0];
250 for (
int i =1; i<4; i++){
251 if(phi[2*i]<phi_r_min) phi_r_min= phi[2*i];
253 float phi_r_max = phi[0];
254 for (
int i =1; i<4; i++){
255 if(phi[2*i]>phi_r_max) phi_r_max=phi[2*i];
258 phi_r_range[0] = phi_r_min;
259 phi_r_range[1] = phi_r_max;
262 first = (phi[1]<piover2) || (phi[3]<piover2) || (phi[5]<piover2 || (phi[7]<piover2));
263 fourth = (phi[1]>threepiover2) || (phi[3]>threepiover2) || (phi[5]>threepiover2) || (phi[7]>threepiover2);
265 if (first && fourth){
266 if (phi[1]>threepiover2) phi[1] -=
twopi;
267 if (phi[3]>threepiover2) phi[3] -=
twopi;
268 if (phi[5]>threepiover2) phi[5] -=
twopi;
269 if (phi[7]>threepiover2) phi[7] -=
twopi;
272 float phi_l_min = phi[1];
273 for (
int i =1; i<4; i++){
274 if(phi[2*i+1]<phi_l_min) phi_l_min= phi[2*i+1];
276 float phi_l_max = phi[1];
277 for (
int i =1; i<4; i++){
278 if(phi[2*i+1]>phi_l_max) phi_l_max=phi[2*i+1];
281 phi_l_range[0] = phi_l_min;
282 phi_l_range[1] = phi_l_max;
293 float x = hitpos2d[0];
294 float y = hitpos2d[1];
295 float hitphi= atan2(y,x);
296 if (hitphi < 0.) hitphi += 2.*
M_PI;
298 float kmin = kappa_d_ranges[0];
299 float kmax = kappa_d_ranges[1];
300 float dmin = kappa_d_ranges[2];
301 float dmax = kappa_d_ranges[3];
304 float D, Dinv, ak, hk=0., hksq, xk1, xk2, xk, yk1,yk2, yk;
307 for (
int icase=0; icase<4; icase++ ){
326 ak = (2.*d + d*d*k + D*D*
k)/(2.*D);
327 hksq = pow(d*k+1.,2) - ak*ak;
330 xk1 = (ak*x + hk*
y)*Dinv;
331 xk2 = (ak*x - hk*
y)*Dinv;
332 yk1 = (ak*y - hk*
x)*Dinv;
333 yk2 = (ak*y + hk*
x)*Dinv;
336 cross = x*yk1 - y*xk1;
337 if (cross*helicity>0){
350 phi[0]= atan2(yk,xk);
351 if (phi[0]<0.) phi[0]+= 2.*
M_PI;
359 phi[1]= atan2(yk,xk);
360 if (phi[1]<0.) phi[1]+= 2.*
M_PI;
369 if (phi[2]<0.) phi[2]+= 2.*
M_PI;
378 if (phi[3]<0.) phi[3]+= 2.*
M_PI;
385 phi_next_range[0] = phi[1];
386 phi_next_range[1] = phi[3];
389 float piover2=
M_PI/2.;
390 float threepiover2=3.*
M_PI/2.;
391 bool first = (phi[0]<piover2) || (phi[1]<piover2) || (phi[2]<piover2 || (phi[3]<piover2));
392 bool fourth = (phi[0]>threepiover2) || (phi[1]>threepiover2) || (phi[2]>threepiover2) || (phi[3]>threepiover2);
394 if (first && fourth){
395 if (phi[0]>threepiover2) phi[0] -=
twopi;
396 if (phi[1]>threepiover2) phi[1] -=
twopi;
397 if (phi[2]>threepiover2) phi[2] -=
twopi;
398 if (phi[3]>threepiover2) phi[3] -=
twopi;
401 float phi_min = phi[0];
402 for (
int i =0; i<4; i++){
403 if(phi[i]<phi_min) phi_min= phi[i];
405 float phi_max = phi[0];
406 for (
int i =0; i<4; i++){
407 if(phi[i]>phi_max) phi_max=phi[i];
410 phi_range[0] = phi_min;
411 phi_range[1] = phi_max;
418 float x = hitpos2d[0];
419 float y = hitpos2d[1];
420 float hitphi= atan2(y,x);
421 if (hitphi < 0.) hitphi += 2.*
M_PI;
424 float kmax = kappa_d_ranges[1];
425 float dmin = kappa_d_ranges[2];
426 float dmax = kappa_d_ranges[3];
429 float D, Dinv, ak, hk=0., hksq, xk1, xk2, xk, yk1,yk2, yk;
433 for (
int icase=0; icase<2; icase++ ){
446 ak = (2.*d + d*d*k + D*D*
k)/(2.*D);
447 hksq = pow(d*k+1.,2) - ak*ak;
450 xk1 = (ak*x + hk*
y)*Dinv;
451 xk2 = (ak*x - hk*
y)*Dinv;
452 yk1 = (ak*y - hk*
x)*Dinv;
453 yk2 = (ak*y + hk*
x)*Dinv;
456 cross = x*yk1 - y*xk1;
457 if (cross*helicity>0){
470 phi[0]= atan2(yk,xk);
471 if (phi[0]<0.) phi[0]+= 2.*
M_PI;
479 phi[1]= atan2(yk,xk);
480 if (phi[1]<0.) phi[1]+= 2.*
M_PI;
488 phi_next_range[0] = phi[0];
489 phi_next_range[1] = phi[1];
490 phi[2] = phi_prev_range[0];
491 phi[3] = phi_prev_range[1];
494 float piover2=
M_PI/2.;
495 float threepiover2=3.*
M_PI/2.;
496 bool first = (phi[0]<piover2) || (phi[1]<piover2) || (phi[2]<piover2 || (phi[3]<piover2));
497 bool fourth = (phi[0]>threepiover2) || (phi[1]>threepiover2) || (phi[2]>threepiover2) || (phi[3]>threepiover2);
499 if (first && fourth){
500 if (phi[0]>threepiover2) phi[0] -=
twopi;
501 if (phi[1]>threepiover2) phi[1] -=
twopi;
502 if (phi[2]>threepiover2) phi[2] -=
twopi;
503 if (phi[3]>threepiover2) phi[3] -=
twopi;
506 float phi_min = phi[0];
507 for (
int i =0; i<4; i++){
508 if(phi[i]<phi_min) phi_min= phi[i];
510 float phi_max = phi[0];
511 for (
int i =0; i<4; i++){
512 if(phi[i]>phi_max) phi_max=phi[i];
515 phi_range[0] = phi_min;
516 phi_range[1] = phi_max;