28 theta1 =
atan2(Ycross[0]-Oyy, Xcross[0]- Oxx);
29 theta2 =
atan2(Ycross[1]-Oyy, Xcross[1]- Oxx);
73 a = x1*y2 + y1*x3 + x2*y3 - x3*y2 - x2*y1 - x1*y3;
75 if(
fabs(a)<1.e-10 )
return false;
81 d = -(q1*y2 + y1*q3 + q2*y3 - q3*y2 - q2*y1 - q1*y3);
83 e = -(x1*q2 + q1*x3 + x2*q3 - x3*q2 - x2*q1 - x1*q3);
87 *r_r =
sqrt( (x1-*o_x)*(x1-*o_x) + (y1-*o_y)*(y1-*o_y) );
164 DELTA = Rr*Rr*(vx*vx+vy*vy) - (vx*ay - vy*ax)*(vx*ay - vy*ax);
170 }
else if (AAA == 0.){
172 }
else if (DELTA == 0.){
174 POINTS[0] = C0x - vx*(vx*ax + vy*ay)/AAA;
175 POINTS[1] = C0y - vy*(vx*ax + vy*ay)/AAA;
176 POINTS[2] = C0z - vz*(vx*ax + vy*ay)/AAA;
180 POINTS[0] = C0x - vx*(vx*ax + vy*ay - DELTA)/AAA;
181 POINTS[1] = C0y - vy*(vx*ax + vy*ay - DELTA)/AAA;
182 POINTS[2] = C0z - vz*(vx*ax + vy*ay - DELTA)/AAA;
183 POINTS[3] = C0x - vx*(vx*ax + vy*ay + DELTA)/AAA;
184 POINTS[4] = C0y - vy*(vx*ax + vy*ay + DELTA)/AAA;
185 POINTS[5] = C0z - vz*(vx*ax + vy*ay + DELTA)/AAA;
296 aaa =
sqrt(WDX[i]*WDX[i]+WDY[i]*WDY[i]+ WDZ[i]*WDZ[i]);
305 calculateintersections(Oxx,Oyy,Rr,C0x1,C0y1,C0z1,info[i][3],
310 if(STATUS < 0 )
return;
316 for( ii=0; ii<2; ii++){
319 (POINTS1[j]-C0x1)*(POINTS1[j]-C0x1) +
320 (POINTS1[1+j]-C0y1)*(POINTS1[1+j]-C0y1) +
321 (POINTS1[2+j]-C0z1)*(POINTS1[2+j]-C0z1)
325 Rx = POINTS1[j]-Oxx ;
326 Ry = POINTS1[1+j]-Oyy ;
331 sinTheta = vx1*vx1 + vy1*vy1;
332 if( sinTheta < 1.e-10)
continue;
333 sinTheta =
sqrt(sinTheta);
334 Aellipsis1 = info[
i][3]/sinTheta;
338 sinDelta = 1. - (-Ry*vx1 + Rx*vy1)*(-Ry*vx1 + Rx*vy1)/(Rx*Rx+Ry*Ry);
340 bbb = info[
i][3]*(2.*Rr-info[
i][3]);
341 if(bbb< 1.e-10)
continue;
342 Bmax = 2.*info[
i][3]/
sqrt(bbb);
343 if( sinDelta < 1.e-10) Bellipsis1=Bmax;
344 sinDelta =
sqrt(sinDelta);
345 Bellipsis1 = info[
i][3]/(Rr*sinDelta);
346 if(Bmax<Bellipsis1) Bellipsis1=Bmax;
349 if( distance >= info[i][4] + Aellipsis1) {
350 Z[ii] = 1000000.+distance;
355 S[ii] =
atan2(POINTS1[j+1]-Oyy, POINTS1[j]-Oxx) ;
356 if( S[ii] < 0.) S[ii] +=
TWO_PI;
358 Sdrift[ii]=Bellipsis1;
360 Z[ii] = POINTS1[j+2];
361 Zdrift[ii] = Aellipsis1;
386 Short_t nIntersections,
405 if (nIntersections<2)
return;
410 for( i=0;i<nIntersections;i++){
411 fi[
i] =
atan2(YintersectionList[i]-Oyy,
412 XintersectionList[i]-Oxx);
413 if( fi[i] < 0.) fi[
i] +=
TWO_PI;
414 if( fi[i] > FiStart) fi[
i] -=
TWO_PI;
415 if( fi[i] > FiStart) fi[
i] = FiStart;
418 MergeSort.
Merge_Sort( nIntersections, fi, auxIndex);
419 Xcross[0] = XintersectionList[ auxIndex[nIntersections-1] ];
420 Ycross[0] = YintersectionList[ auxIndex[nIntersections-1] ];
421 Xcross[1] = XintersectionList[ auxIndex[nIntersections-2] ];
422 Ycross[1] = YintersectionList[ auxIndex[nIntersections-2] ];
425 Int_t auxIndex[nIntersections];
427 for( i=0;i<nIntersections;i++){
428 fi[
i] =
atan2(YintersectionList[i]-Oyy,
429 XintersectionList[i]-Oxx);
430 if( fi[i] < 0.) fi[
i] +=
TWO_PI;
431 if( fi[i] < FiStart) fi[
i] +=
TWO_PI;
432 if( fi[i] < FiStart) fi[
i] += FiStart;
435 MergeSort.
Merge_Sort( nIntersections, fi, auxIndex);
436 Xcross[0] = XintersectionList[ auxIndex[0] ];
437 Ycross[0] = YintersectionList[ auxIndex[0] ];
438 Xcross[1] = XintersectionList[ auxIndex[1] ];
439 Ycross[1] = YintersectionList[ auxIndex[1] ];
458 Short_t nIntersections,
469 Int_t auxIndex[nIntersections];
471 Double_t auxX[nIntersections], auxY[nIntersections],
fi[nIntersections];
479 if (nIntersections<2)
return;
482 for( i=0;i<nIntersections;i++){
483 fi[
i] =
atan2(YintersectionList[i]-Oyy,
484 XintersectionList[i]-Oxx);
485 if( fi[i] < 0.) fi[
i] +=
TWO_PI;
486 if( fi[i] > FiStart) fi[
i] -=
TWO_PI;
487 if( fi[i] > FiStart) fi[
i] = FiStart;
490 MergeSort.
Merge_Sort( nIntersections, fi, auxIndex);
491 for( i=0;i<nIntersections;i++){
492 auxX[
i] = XintersectionList[ auxIndex[nIntersections-i-1] ];
493 auxY[
i] = YintersectionList[ auxIndex[nIntersections-i-1] ];
494 FiOrderedList[
i] = fi[nIntersections-i-1];
498 for( i=0;i<nIntersections;i++){
499 fi[
i] =
atan2(YintersectionList[i]-Oyy,
500 XintersectionList[i]-Oxx);
501 if( fi[i] < 0.) fi[
i] +=
TWO_PI;
502 if( fi[i] < FiStart) fi[
i] +=
TWO_PI;
503 if( fi[i] < FiStart) fi[
i] += FiStart;
508 MergeSort.
Merge_Sort( nIntersections, fi, auxIndex);
510 for( i=0;i<nIntersections;i++){
511 auxX[
i] = XintersectionList[ auxIndex[
i] ];
512 auxY[
i] = YintersectionList[ auxIndex[
i] ];
513 FiOrderedList[
i] = fi[
i] ;
519 for( i=0;i<nIntersections;i++){
520 XintersectionList[
i] = auxX[
i];
521 YintersectionList[
i] = auxY[
i];
558 if(
fabs(KAPPA) < 1.e-10){
560 }
else if (
fabs(KAPPA)>1.e10) {
567 if( aaa<-2147483648.) {
568 *nrounds = -2147483647;
569 }
else if (aaa > 2147483647.) {
570 *nrounds = 2147483647;
572 *nrounds = (Int_t) aaa;
575 dis_segments =
TWO_PI*Rr/
sqrt(1.+KAPPA*KAPPA*Rr*Rr);
579 dis1 =
fabs( Rr*S -Rr*KAPPA*ZED - Rr*FI0)/
sqrt( 1.+KAPPA*KAPPA*Rr*Rr);
580 dis1 = fmod(dis1,dis_segments);
581 dis2 = dis_segments-dis1;
if(dis2<0.)dis2=0.;
603 Short_t n_allowed_rounds,
619 boundaries[n_allowed_rounds+3],
628 if(
fabs(KAPPA)<1.e-10) {
629 cout<<
"PdnTrkCTGeometryCalculations::Dist_SZ_bis KAPPA < 1.e-10, returning dist=999999.\t";
651 if(KAPPA>0.) { z2pi = (
TWO_PI-FI0)/KAPPA;
if(z2pi<0.) z2pi=0.;}
else { z2pi = -FI0/KAPPA;}
661 for(i=1; i<n_allowed_rounds+2;i++){
662 boundaries[
i]=z2pi+(i-1)*deltaz;
666 for(i=0; i< n_allowed_rounds+2; i++){
667 z_on_trajectory = (S-FI0+i*
TWO_PI)/KAPPA;
670 if( z_on_trajectory < boundaries[i] || z_on_trajectory > boundaries[i+1] )
continue;
671 dis_new =
fabs(ZED- z_on_trajectory);
674 chosenZ = z_on_trajectory;
682 if(KAPPA>0.) { z2pi = FI0/KAPPA;}
else { z2pi = -(
TWO_PI-FI0)/KAPPA;
if(z2pi<0.) z2pi=0.;}
692 for(i=1; i<n_allowed_rounds+2;i++){
693 boundaries[
i]=-z2pi-(i-1)*deltaz;
697 for(i=0; i< n_allowed_rounds+2; i++){
698 z_on_trajectory = (S-FI0+i*
TWO_PI)/KAPPA;
703 if( z_on_trajectory > boundaries[i] || z_on_trajectory < boundaries[i+1] )
continue;
704 dis_new =
fabs(ZED - z_on_trajectory);
707 chosenZ = z_on_trajectory;
716 chosenS = FI0 + KAPPA* chosenZ;
775 if( tanlow<999998.) {
777 Delta = alfa*alfa + beta*beta*m[
i]*m[
i] - 4.*gamma*m[
i]*m[
i] - 4.*q*q + 4.*m[
i]*q*alfa +
778 + 2.*alfa*beta*m[
i] - 4.*beta*q - 4.*gamma;
781 }
else if (Delta==0.){
782 x1 = 0.5*(-alfa - 2.*m[
i]*q - beta*m[
i] )/(1.+m[i]*m[i]);
784 dist =
fabs(
sqrt( (Oxx-x1)*(Oxx-x1) + (Oyy-y1)*(Oyy-y1) ) - Rr);
787 x1 = 0.5*(-alfa - 2.*m[
i]*q - beta*m[
i] - Delta)/(1.+m[i]*m[i]);
788 x2 = 0.5*(-alfa - 2.*m[
i]*q - beta*m[
i] + Delta)/(1.+m[i]*m[i]);
791 dist1 =
fabs(
sqrt( (Oxx-x1)*(Oxx-x1) + (Oyy-y1)*(Oyy-y1) ) - Rr);
792 dist2 =
fabs(
sqrt( (Oxx-x2)*(Oxx-x2) + (Oyy-y2)*(Oyy-y2) ) - Rr);
800 Delta = beta*beta - 4.*Oxx*Oxx - 4.*Oxx*alfa - 4.*gamma;
804 }
else if (Delta==0.){
805 dist =
fabs(
fabs(Oyy+0.5*beta) - Rr);
808 y1 = -0.5*beta + Delta/2.;
809 y2 = -0.5*beta - Delta/2.;
810 dist1 =
fabs(
fabs(Oyy+0.5*beta + Delta/2.) - Rr);
811 dist2 =
fabs(
fabs(Oyy+0.5*beta - Delta/2.) - Rr);
812 if(dist1<dist2) dist = dist1;
826 if(n!=3) totaldist = -1.;
827 else totaldist = totaldist /
n;
858 bool intersection_inner,
882 a =
sqrt(oX*oX+oY*oY);
886 { *status = -1 ;
return;}
887 if( a >= Rr + Rma || Rr >= a + Rma)
888 { *status = -2;
return;}
890 if( a - Rr >= Rmi ) intersection_inner =
false;
else intersection_inner =
true;
892 if( a + Rr <= Rma || a - Rr >= Rma )
893 intersection_outer =
false;
else intersection_outer =
true;
895 if( (! intersection_inner) && (! intersection_outer) ){
904 FI0 =
atan2(-oY,-oX);
905 if( intersection_outer ){
906 cosFi = (a*a + Rr*Rr - Rma*Rma)/(2.*Rr*a);
907 if(cosFi<-1.) cosFi=-1.;
else if(cosFi>1.) cosFi=1.;
911 if( intersection_inner ){
912 cosfi = (a*a + Rr*Rr - Rmi*Rmi)/(2.*Rr*a);
913 if(cosfi<-1.) cosfi=-1.;
else if(cosfi>1.) cosfi=1.;
918 if( intersection_outer && intersection_inner){
919 *Fi_low_limit=FI0 +
fi;
920 *Fi_up_limit= FI0 +Fi;
922 }
else if (intersection_inner) {
923 *Fi_low_limit=FI0 +
fi;
924 *Fi_up_limit= FI0 -
fi;
926 *Fi_low_limit=FI0 - Fi;
927 *Fi_up_limit= FI0 + Fi;
934 if( intersection_outer && intersection_inner){
935 *Fi_low_limit=FI0 - Fi;
936 *Fi_up_limit= FI0 -
fi;
938 }
else if (intersection_inner) {
939 *Fi_low_limit=FI0 +
fi;
940 *Fi_up_limit= FI0 -
fi;
942 *Fi_low_limit=FI0 - Fi;
943 *Fi_up_limit= FI0 + Fi;
950 if(*Fi_low_limit<0.) {
951 *Fi_low_limit=fmod(*Fi_low_limit,
TWO_PI);
953 }
else if (*Fi_low_limit>=
TWO_PI){
954 *Fi_low_limit=fmod(*Fi_low_limit,
TWO_PI);
956 if(*Fi_up_limit<0.) {
957 *Fi_up_limit=fmod(*Fi_up_limit,
TWO_PI);
959 }
else if (*Fi_up_limit>=
TWO_PI){
960 *Fi_up_limit=fmod(*Fi_up_limit,
TWO_PI);
965 if( *Fi_up_limit < *Fi_low_limit ) *Fi_up_limit +=
TWO_PI;
966 if( *Fi_up_limit < *Fi_low_limit ) *Fi_up_limit = *Fi_low_limit;
1002 bool intersection_inner,
1038 a =
sqrt(oX*oX+oY*oY);
1042 { *status = -1 ;
return;}
1043 if( a >= Rr + Rma || Rr >= a + Rma)
1044 { *status = -2;
return;}
1046 if( a - Rr >= Rmi ) intersection_inner =
false;
else intersection_inner =
true;
1048 if( a + Rr <= Rma || a - Rr >= Rma )
1049 intersection_outer =
false;
else intersection_outer =
true;
1051 if( (! intersection_inner) && (! intersection_outer) ){
1054 Fi_low_limit[0] = 0.;
1062 FI0 =
atan2(-oY,-oX);
1063 if( intersection_outer ){
1064 cosFi = (a*a + Rr*Rr - Rma*Rma)/(2.*Rr*a);
1065 if(cosFi<-1.) cosFi=-1.;
else if(cosFi>1.) cosFi=1.;
1069 if( intersection_inner ){
1070 cosfi = (a*a + Rr*Rr - Rmi*Rmi)/(2.*Rr*a);
1071 if(cosfi<-1.) cosfi=-1.;
else if(cosfi>1.) cosfi=1.;
1075 if( intersection_outer && intersection_inner){
1077 Fi_low_limit[1] = FI0 - Fi;
1078 Fi_up_limit[1] = FI0 -
fi;
1080 Fi_low_limit[0] = FI0 +
fi;
1081 Fi_up_limit[0] = FI0 + Fi;
1083 }
else if (intersection_inner) {
1084 Fi_low_limit[0] = FI0 +
fi;
1085 Fi_up_limit[0] = FI0 -
fi;
1087 Fi_low_limit[1] = -100.;
1088 Fi_up_limit[1] = -100.;
1090 Fi_low_limit[0]=FI0 - Fi;
1091 Fi_up_limit[0]= FI0 + Fi;
1093 Fi_low_limit[1] = -100.;
1094 Fi_up_limit[1] = -100.;
1097 for(
int i=0;
i<2;
i++){
1098 if( Fi_low_limit[
i]<-99.)
continue;
1099 if(Fi_low_limit[
i]<0.) {
1100 Fi_low_limit[
i]=fmod(Fi_low_limit[
i],
TWO_PI);
1102 }
else if (Fi_low_limit[
i]>=
TWO_PI){
1103 Fi_low_limit[
i]=fmod(Fi_low_limit[
i],
TWO_PI);
1105 if(Fi_up_limit[
i]<0.) {
1106 Fi_up_limit[
i]=fmod(Fi_up_limit[
i],
TWO_PI);
1108 }
else if (Fi_up_limit[
i]>=
TWO_PI){
1109 Fi_up_limit[
i]=fmod(Fi_up_limit[
i],
TWO_PI);
1114 if( Fi_up_limit[
i] < Fi_low_limit[
i] ) Fi_up_limit[
i] +=
TWO_PI;
1115 if( Fi_up_limit[i] < Fi_low_limit[i] ) Fi_up_limit[
i] = Fi_low_limit[
i];
1149 a =
sqrt(oX*oX+oY*oY);
1152 if( a >= Rr + Rma || Rr >= a + Rma || a + Rr <= Rma)
return -1;
1155 FI0 =
atan2(-oY,-oX);
1156 cosFi = (a*a + Rr*Rr - Rma*Rma)/(2.*Rr*a);
1157 if(cosFi<-1.) cosFi=-1.;
else if(cosFi>1.) cosFi=1.;
1160 Xcross[0] = oX + Rr*
cos(FI0+Fi);
1161 Ycross[0] = oY + Rr*
sin(FI0+Fi);
1162 Xcross[1] = oX + Rr*
cos(FI0-Fi);
1163 Ycross[1] = oY + Rr*
sin(FI0-Fi);
1186 Short_t nIntersections;
1188 XintersectionList[16],
1189 YintersectionList[16];
1225 flag=IntersectionsWithClosedbiHexagonLeft(
1242 if (!(flag == 0))
return flag;
1243 if( nIntersections<2)
return -1;
1249 FiStart =
atan2( Start[1]-Oyy,Start[0]-Oxx);
1250 if(FiStart<0.) FiStart+=
TWO_PI;
1251 if(FiStart<0.) FiStart =0.;
1259 ChooseEntranceExitbis(
1342 flag=IntersectionsWithClosedbiHexagonLeft(
1359 if (!(flag == 0))
return 0;
1365 FiStart =
atan2( Start[1]-Oyy,Start[0]-Oxx);
1366 if(FiStart<0.) FiStart+=
TWO_PI;
1367 if(FiStart<0.) FiStart =0.;
1378 ChooseEntranceExit3(
1392 return nIntersections;
1415 Short_t nIntersections;
1417 XintersectionList[16],
1418 YintersectionList[16];
1448 flag=IntersectionsWithClosedbiHexagonRight(
1467 if (!(flag == 0))
return flag;
1468 if( nIntersections<2)
return -1;
1474 FiStart =
atan2( Start[1]-Oyy,Start[0]-Oxx);
1475 if(FiStart<0.) FiStart+=
TWO_PI;
1476 if(FiStart<0.) FiStart =0.;
1484 ChooseEntranceExitbis(
1561 flag=IntersectionsWithClosedbiHexagonRight(
1578 if (!(flag == 0))
return 0;
1584 FiStart =
atan2( Start[1]-Oyy,Start[0]-Oxx);
1585 if(FiStart<0.) FiStart+=
TWO_PI;
1586 if(FiStart<0.) FiStart =0.;
1596 ChooseEntranceExit3(
1610 return nIntersections;
1644 Short_t nIntersectionsCircle,
1647 XintersectionList[12],
1648 YintersectionList[12];
1653 Double_t Side_x[] = { -GAP/2., -GAP/2. , -ApotemaMin, -ApotemaMin, -GAP/2., -GAP/2. },
1654 Side_y[] = {
sqrt(Rma*Rma-GAP*GAP/4.), (2.*ApotemaMin-GAP/2.)/
sqrt(3.),
1655 ApotemaMin/
sqrt(3.),
1656 -ApotemaMin/
sqrt(3.),
1657 -(2.*ApotemaMin-GAP/2.)/
sqrt(3.), -
sqrt(Rma*Rma-GAP*GAP/4.)},
1658 a[] = {1., -1./
sqrt(3.), 1., 1./
sqrt(3.), 1.},
1659 b[] = {0., 1., 0., 1., 0.},
1660 c[] = {GAP/2., -2.*ApotemaMin/
sqrt(3.),ApotemaMin, 2.*ApotemaMin/
sqrt(3.), GAP/2.};
1662 nIntersections=IntersectionsWithOpenPolygon(
1683 nIntersectionsCircle=IntersectionsWithGapSemicircle(
1690 &XintersectionList[nIntersections],
1691 &YintersectionList[nIntersections]
1693 nIntersections += nIntersectionsCircle;
1697 if(nIntersections<2)
return -1;
1699 FiStart =
atan2( Start[1]-Oyy,Start[0]-Oxx);
1700 if(FiStart<0.) FiStart+=
TWO_PI;
1701 if(FiStart<0.) FiStart =0.;
1708 ChooseEntranceExitbis(
1758 Short_t nIntersections;
1762 Short_t nIntersectionsCircle;
1776 Double_t Side_x[] = { -GAP/2., -GAP/2. , -ApotemaMin, -ApotemaMin, -GAP/2., -GAP/2. },
1777 Side_y[] = {
sqrt(Rma*Rma-GAP*GAP/4.), (2.*ApotemaMin-GAP/2.)/
sqrt(3.),
1778 ApotemaMin/
sqrt(3.),
1779 -ApotemaMin/
sqrt(3.),
1780 -(2.*ApotemaMin-GAP/2.)/
sqrt(3.), -
sqrt(Rma*Rma-GAP*GAP/4.)},
1781 a[] = {1., -1./
sqrt(3.), 1., 1./
sqrt(3.), 1.},
1782 b[] = {0., 1., 0., 1., 0.},
1783 c[] = {GAP/2., -2.*ApotemaMin/
sqrt(3.),ApotemaMin, 2.*ApotemaMin/
sqrt(3.), GAP/2.};
1785 nIntersections=IntersectionsWithOpenPolygon(
1805 nIntersectionsCircle=IntersectionsWithGapSemicircle(
1812 &XintersectionList[nIntersections],
1813 &YintersectionList[nIntersections]
1815 nIntersections += nIntersectionsCircle;
1819 if(nIntersections==0)
return 0;
1821 FiStart =
atan2( Start[1]-Oyy,Start[0]-Oxx);
1822 if(FiStart<0.) FiStart+=
TWO_PI;
1823 if(FiStart<0.) FiStart =0.;
1831 ChooseEntranceExit3(
1843 return nIntersections;
1878 Short_t nIntersectionsCircle,
1881 XintersectionList[12],
1882 YintersectionList[12];
1887 Double_t Side_x[] = { GAP/2., GAP/2. , ApotemaMin, ApotemaMin, GAP/2., GAP/2. },
1888 Side_y[] = {
sqrt(Rma*Rma-GAP*GAP/4.), (2.*ApotemaMin-GAP/2.)/
sqrt(3.),
1889 ApotemaMin/
sqrt(3.),
1890 -ApotemaMin/
sqrt(3.),
1891 -(2.*ApotemaMin-GAP/2.)/
sqrt(3.), -
sqrt(Rma*Rma-GAP*GAP/4.)},
1892 a[] = {1., 1./
sqrt(3.), 1., -1./
sqrt(3.), 1.},
1893 b[] = {0., 1., 0., 1., 0.},
1894 c[] = {-GAP/2.,-2.*ApotemaMin/
sqrt(3.),-ApotemaMin, 2.*ApotemaMin/
sqrt(3.), -GAP/2.};
1896 nIntersections=IntersectionsWithOpenPolygon(
1916 nIntersectionsCircle=IntersectionsWithGapSemicircle(
1923 &XintersectionList[nIntersections],
1924 &YintersectionList[nIntersections]
1928 nIntersections += nIntersectionsCircle;
1932 if(nIntersections<2)
return -1;
1934 FiStart =
atan2( Start[1]-Oyy,Start[0]-Oxx);
1935 if(FiStart<0.) FiStart+=
TWO_PI;
1936 if(FiStart<0.) FiStart =0.;
1942 ChooseEntranceExitbis(
1994 Short_t nIntersections;
2010 Short_t nIntersectionsCircle;
2016 Double_t Side_x[] = { GAP/2., GAP/2. , ApotemaMin, ApotemaMin, GAP/2., GAP/2. },
2017 Side_y[] = {
sqrt(Rma*Rma-GAP*GAP/4.), (2.*ApotemaMin-GAP/2.)/
sqrt(3.),
2018 ApotemaMin/
sqrt(3.),
2019 -ApotemaMin/
sqrt(3.),
2020 -(2.*ApotemaMin-GAP/2.)/
sqrt(3.), -
sqrt(Rma*Rma-GAP*GAP/4.)},
2021 a[] = {1., 1./
sqrt(3.), 1., -1./
sqrt(3.), 1.},
2022 b[] = {0., 1., 0., 1., 0.},
2023 c[] = {-GAP/2.,-2.*ApotemaMin/
sqrt(3.),-ApotemaMin, 2.*ApotemaMin/
sqrt(3.), -GAP/2.};
2025 nIntersections=IntersectionsWithOpenPolygon(
2044 nIntersectionsCircle=IntersectionsWithGapSemicircle(
2051 &XintersectionList[nIntersections],
2052 &YintersectionList[nIntersections]
2055 nIntersections += nIntersectionsCircle;
2059 if(nIntersections == 0)
return 0;
2061 FiStart =
atan2( Start[1]-Oyy,Start[0]-Oxx);
2062 if(FiStart<0.) FiStart+=
TWO_PI;
2063 if(FiStart<0.) FiStart =0.;
2071 ChooseEntranceExit3(
2083 return nIntersections;
2103 Short_t * Nintersections,
2114 Short_t ipossibility;
2134 cout<<
"from PndTrkCTGeometryCalculations::IntersectionCircle_Segment :"
2135 <<
" this is not the equation of a segment; a = "<<a<<
", b = "
2136 <<b<<
", return false!\n";
2141 distq = ( a*Oxx+ b*Oyy +
c )*( a*Oxx+ b*Oyy + c )/det;
2142 *distance =
sqrt(distq);
2144 length = Rq - distq;
2145 if(length <= 0. )
return false;
2147 length =
sqrt(length);
2151 cperp = - aperp*Oxx - bperp*Oyy;
2155 Xintersection = (-bperp*c + b*cperp)/det;
2156 Yintersection = (-a*cperp + aperp*
c)/det;
2158 length_segmentq = (P1x-P2x)*(P1x-P2x) + (P1y-P2y)*(P1y-P2y);
2160 for(ipossibility=-1;ipossibility<2;ipossibility +=2){
2161 x = Xintersection + ipossibility*length*b/det ;
2162 y = Yintersection - ipossibility*length*a/det ;
2163 if ( (x-P1x)*(x-P1x)+(y-P1y)*(y-P1y) > length_segmentq
2166 (x-P2x)*(x-P2x)+(y-P2y)*(y-P2y) > length_segmentq
2169 XintersectionList[*Nintersections] =
x;
2170 YintersectionList[*Nintersections] =
y;
2171 (*Nintersections)++;
2195 Short_t * Nintersections,
2206 Short_t ipossibility;
2226 cout<<
"from PndTrkCTGeometryCalculations::IntersectionCircle_Segment :"
2227 <<
" this is not the equation of a segment; a = "<<a<<
", b = "
2228 <<b<<
", return false!\n";
2233 distq = ( a*Oxx+ b*Oyy +
c )*( a*Oxx+ b*Oyy + c )/det;
2234 *distance =
sqrt(distq);
2236 length = Rq - distq;
2237 if(length <= 0. )
return false;
2239 length =
sqrt(length);
2243 cperp = - aperp*Oxx - bperp*Oyy;
2247 Xintersection = (-bperp*c + b*cperp)/det;
2248 Yintersection = (-a*cperp + aperp*
c)/det;
2250 length_segmentq = (P1x-P2x)*(P1x-P2x) + (P1y-P2y)*(P1y-P2y);
2252 for(ipossibility=-1;ipossibility<2;ipossibility +=2){
2253 x = Xintersection + ipossibility*length*b/det ;
2254 y = Yintersection - ipossibility*length*a/det ;
2255 if ( (x-P1x)*(x-P1x)+(y-P1y)*(y-P1y) > factor*length_segmentq
2258 (x-P2x)*(x-P2x)+(y-P2y)*(y-P2y) > factor*length_segmentq
2261 XintersectionList[*Nintersections] =
x;
2262 YintersectionList[*Nintersections] =
y;
2263 (*Nintersections)++;
2279 Short_t * Nintersections,
2294 QQ = posizSciTilx*posizSciTilx+posizSciTily*posizSciTily;
2297 if( posizSciTily<0.) SIGN=-1.;
2301 intersect = IntersectionCircle_Segment_forScitil(
2337 Short_t *nIntersections,
2369 b[] = {1., 0., 1., 0., 1., 0., 1., 0.},
2370 c[] = {-2.*Ama/
sqrt(3.),Ama, 2.*Ama/
sqrt(3.),vgap/2.,2.*Ami/
sqrt(3.),Ami, -2.*Ami/
sqrt(3.),vgap/2.},
2378 side_x[] = { -vgap/2., -Ama , -Ama, -vgap/2., -vgap/2., -Ami,
2379 -Ami, -vgap/2., -vgap/2.},
2380 side_y[] = {(-0.5*vgap+2.*Ama)/
sqrt(3.), Ama/
sqrt(3.), -Ama/
sqrt(3.),
2381 -(-0.5*vgap+2.*Ama)/
sqrt(3.), -(-0.5*vgap+2.*Ami)/
sqrt(3.),
2382 -Ami/
sqrt(3.), Ami/
sqrt(3.), (-0.5*vgap+2.*Ami)/
sqrt(3.),
2383 (-0.5*vgap+2.*Ama)/
sqrt(3.) };
2397 for(is=0; is<8; is++){
2398 aaa = (side_x[
is]-Oxx)*(side_x[is]-Oxx)+(side_y[
is]-Oyy)*(side_y[is]-Oyy);
2399 if(aaa>maxdistq) maxdistq=aaa;
2400 aaa = (side_x[is+1]-Oxx)*(side_x[is+1]-Oxx)+(side_y[is+1]-Oyy)*(side_y[is+1]-Oyy);
2401 if(aaa>maxdistq) maxdistq=aaa;
2402 if ( IntersectionCircle_Segment(
2421 for(j=0;j<Nintersections;j++){
2422 XintersectionList[ *nIntersections ] =tempX[j];
2423 YintersectionList[ *nIntersections ] =tempY[j];
2424 (*nIntersections)++;
2433 internal =
internal && IsInternal(Oxx,
2440 internal =
internal && (!IsInternal(Oxx,
2452 if (!
internal)
return -1;
2453 if( maxdistq < Rr*Rr )
return -1;
2479 Short_t *nIntersections,
2512 b[] = {1., 0., 1., 0., 1., 0., 1., 0.},
2513 c[] = {-2.*Ama/
sqrt(3.),-Ama, 2.*Ama/
sqrt(3.),-vgap/2.,2.*Ami/
sqrt(3.),-Ami, -2.*Ami/
sqrt(3.),-vgap/2.},
2521 side_x[] = { vgap/2., Ama , Ama, vgap/2., vgap/2., Ami,
2522 Ami, vgap/2., vgap/2.},
2523 side_y[] = {(-0.5*vgap+2.*Ama)/
sqrt(3.), Ama/
sqrt(3.), -Ama/
sqrt(3.),
2524 -(-0.5*vgap+2.*Ama)/
sqrt(3.), -(-0.5*vgap+2.*Ami)/
sqrt(3.),
2525 -Ami/
sqrt(3.), Ami/
sqrt(3.), (-0.5*vgap+2.*Ami)/
sqrt(3.),
2526 (-0.5*vgap+2.*Ama)/
sqrt(3.) };
2538 for(is=0; is<8; is++){
2539 aaa = (side_x[
is]-Oxx)*(side_x[is]-Oxx)+(side_y[
is]-Oyy)*(side_y[is]-Oyy);
2540 if(aaa>maxdistq) maxdistq=aaa;
2541 aaa = (side_x[is+1]-Oxx)*(side_x[is+1]-Oxx)+(side_y[is+1]-Oyy)*(side_y[is+1]-Oyy);
2542 if(aaa>maxdistq) maxdistq=aaa;
2543 if ( IntersectionCircle_Segment(
2563 for(j=0;j<Nintersections;j++){
2564 XintersectionList[ *nIntersections ] =tempX[j];
2565 YintersectionList[ *nIntersections ] =tempY[j];
2566 (*nIntersections)++;
2575 internal =
internal && IsInternal(Oxx,
2582 internal =
internal && (!IsInternal(Oxx,
2594 if (!
internal)
return -1;
2595 if( maxdistq < Rr*Rr )
return -1;
2616 Short_t nIntersections[2],
2651 b[] = { 1., 0. , 1., 1., 0. , 1. },
2655 Erre[] = {Rmi, Rma},
2663 hexagon_side_x[] = { 0., 1. , 1., 0., -1., -1., 0. },
2664 hexagon_side_y[] = { 2./
sqrt(3.),1./
sqrt(3.),-1./
sqrt(3.),
2681 AtLeast1[
i] =
false;
2682 nIntersections[
i]=0;
2685 for(is=0; is<6; is++){
2686 if ( IntersectionCircle_Segment(a[is],
2689 hexagon_side_x[is]*Erre[i],
2690 hexagon_side_x[is+1]*Erre[i],
2691 hexagon_side_y[is]*Erre[i],
2692 hexagon_side_y[is+1]*Erre[i],
2705 for(j=0;j<Nintersections;j++){
2706 XintersectionList[ nIntersections[
i] ][
i] =tempX[j];
2707 YintersectionList[ nIntersections[
i] ][
i] =tempY[j];
2708 nIntersections[
i]++;
2712 if(mindist[i]>distance) mindist[
i]=distance;
2717 internal[
i] =
internal[
i] && IsInternal(Oxx,
2728 if( (!AtLeast1[0]) && (!AtLeast1[1]) ){
2729 if (!
internal[1])
return -2;
2730 if( Rr > mindist[1])
return -2;
2731 if( !
internal[0])
return 1;
2732 if( mindist[0] >= Rr)
return -1;
2734 }
else if (AtLeast1[0] && AtLeast1[1] ){
2736 }
else if (AtLeast1[0]){
2761 Short_t nIntersectionsCircle;
2778 nIntersectionsCircle=0;
2779 aaa =
sqrt(Oxx*Oxx+Oyy*Oyy);
2783 if( !( aaa >= Rr + Rma || Rr >= aaa + Rma) &&
2784 !( aaa + Rr <= Rma || aaa - Rr >= Rma ) ) {
2788 FI0 =
atan2(-Oyy,-Oxx);
2789 cosFi = (aaa*aaa + Rr*Rr - Rma*Rma)/(2.*Rr*aaa);
2790 if(cosFi<-1.) cosFi=-1.;
else if(cosFi>1.) cosFi=1.;
2796 x1 = Oxx+Rr*
cos(FI0 - Fi);
2797 y1 = Oyy+Rr*
sin(FI0 - Fi);
2798 theta1 =
atan2(y1,x1);
2799 x2 = Oxx+Rr*
cos(FI0 + Fi);
2800 y2 = Oyy+Rr*
sin(FI0 + Fi);
2801 theta2 =
atan2(y2,x2);
2805 Theta2 =
atan2(
sqrt(Rma*Rma-GAP*GAP/4.),GAP/2.);
2806 Theta1 =
atan2( -
sqrt(Rma*Rma-GAP*GAP/4.),GAP/2.);
2807 if( Theta1<= theta1 && theta1 <= Theta2 ){
2808 XintersectionList[nIntersectionsCircle]=x1;
2809 YintersectionList[nIntersectionsCircle]=y1;
2810 nIntersectionsCircle++;
2812 if( Theta1<= theta2 && theta2 <= Theta2 ){
2813 XintersectionList[nIntersectionsCircle]=x2;
2814 YintersectionList[nIntersectionsCircle]=y2;
2815 nIntersectionsCircle++;
2818 Theta2 =
atan2( -
sqrt(Rma*Rma-GAP*GAP/4.),-GAP/2.);
2819 Theta1 =
atan2(
sqrt(Rma*Rma-GAP*GAP/4.),-GAP/2.);
2820 if( Theta1<= theta1 || theta1 <= Theta2 ){
2821 XintersectionList[nIntersectionsCircle]=x1;
2822 YintersectionList[nIntersectionsCircle]=y1;
2823 nIntersectionsCircle++;
2825 if( Theta1<= theta2 || theta2 <= Theta2 ){
2826 XintersectionList[nIntersectionsCircle]=x2;
2827 YintersectionList[nIntersectionsCircle]=y2;
2828 nIntersectionsCircle++;
2836 return nIntersectionsCircle;
2887 for(is=0; is<nSides; is++){
2888 if ( IntersectionCircle_Segment(a[is],
2907 for(j=0;j<Nintersections;j++){
2908 XintersectionList[ nIntersections ] =tempX[j];
2909 YintersectionList[ nIntersections ] =tempY[j];
2920 return nIntersections;
2946 f1 =
atan2(Ycross[0]-Oyy, Xcross[0]-Oxx);
2949 f2 =
atan2(Ycross[1]-Oyy, Xcross[1]-Oxx);
2956 if(f1 > f2 ) f2 +=
TWO_PI;
2957 if(f1 > f2 ) f2 =
f1;
2959 if(f<f2)
return true;
else return false;
2963 if(f<f2)
return true;
else return false;
2966 if(f1 < f2 ) f1 +=
TWO_PI;
2967 if(f1 < f2 ) f1 =
f2;
2969 if(f<f1)
return true;
else return false;
2973 if(f<f1)
return true;
else return false;
3000 (X > -2.33 && X < -1.17 && Y > -2.26 && Y < 2.26 )
3002 (X > 0. && X < 1.21 &&
fabs(Y) < 3.43 &&
fabs(Y) > 1.19)
3004 (X > 2.32 && X < 3.48 &&
fabs(Y) < 1.12)
3028 (X > -2.33 + xmargin && X < -1.17 - xmargin && Y > -2.26 + ymargin && Y < 2.26 - ymargin )
3030 (X > 0. + xmargin && X < 1.21 - xmargin &&
fabs(Y) < 3.43 &&
fabs(Y) > 1.19)
3032 (X > 2.32 + xmargin && X < 3.48 - xmargin &&
fabs(Y) < 1.12 - ymargin)
3055 ( X > 1.17 && X < 2.33 && Y > -2.26 && Y < 2.26 )
3057 ( X < 0. && X > -1.21 &&
fabs(Y) < 3.43 &&
fabs(Y) > 1.19)
3059 ( X < -2.32 && X > -3.48 &&
fabs(Y) < 1.12)
3083 ( X > 1.17 + xmargin && X < 2.33 - xmargin && Y > -2.26 + ymargin && Y < 2.26 - ymargin )
3085 ( X < 0. - xmargin && X > -1.21 + xmargin &&
fabs(Y) < 3.43 - ymargin &&
fabs(Y) > 1.19 + ymargin )
3087 ( X < -2.32 - xmargin && X > -3.48 + xmargin &&
fabs(Y) < 1.12 - ymargin )
3114 ( X > 1.17 && X < 2.33 && Y > -2.26 && Y < 2.26 )
3116 ( X < 0. && X > -1.21 &&
fabs(Y) < 3.43 &&
fabs(Y) > 1.19)
3118 ( X < -2.32 && X > -3.48 &&
fabs(Y) < 1.12)
3143 ( X > 1.17 + xmargin && X < 2.33 - xmargin && Y > -2.26 + ymargin && Y < 2.26 - ymargin )
3145 ( X < 0. - xmargin && X > -1.21 + xmargin &&
fabs(Y) < 3.43 - ymargin &&
fabs(Y) > 1.19 + ymargin )
3147 ( X < -2.32 - xmargin && X > -3.48 + xmargin &&
fabs(Y) < 1.12 - ymargin )
3172 (X > -2.33 && X < -1.17 && Y > -2.26 && Y < 2.26 )
3174 (X > 0. && X < 1.21 &&
fabs(Y) < 3.43 &&
fabs(Y) > 1.19)
3176 (X > 2.32 && X < 3.48 &&
fabs(Y) < 1.12)
3200 (X > -2.33 + xmargin && X < -1.17 - xmargin && Y > -2.26 + ymargin && Y < 2.26 - ymargin )
3202 (X > 0. + xmargin && X < 1.21 - xmargin &&
fabs(Y) < 3.43 &&
fabs(Y) > 1.19)
3204 (X > 2.32 + xmargin && X < 3.48 - xmargin &&
fabs(Y) < 1.12 - ymargin)
3229 (X > -6.96 && X < -5.8 &&
fabs(Y) < 2.31 &&
fabs(Y) > 0.07)
3231 (X > -4.64 && X < -3.48 &&
fabs(Y) < 5.73 &&
fabs(Y) > 0.07)
3233 (X > -2.33 && X < -1.17 &&
fabs(Y) < 6.87 &&
fabs(Y) > 0.07)
3235 (X > 0. && X < 1.16 &&
fabs(Y) < 6.85 &&
fabs(Y) > 1.19)
3237 (X > 2.3 && X < 3.46 &&
fabs(Y) < 5.73 &&
fabs(Y) > 0.07)
3239 (X > 4.64 && X < 5.8 &&
fabs(Y) < 4.59 &&
fabs(Y) > 0.07)
3264 (X > -6.96 + xmargin && X < -5.8 - xmargin &&
fabs(Y) < 2.31 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3266 (X > -4.64 + xmargin && X < -3.48 - xmargin &&
fabs(Y) < 5.73 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3268 (X > -2.33 + xmargin && X < -1.17 - xmargin &&
fabs(Y) < 6.87 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3270 (X > 0. + xmargin && X < 1.16 - xmargin &&
fabs(Y) < 6.85 - ymargin &&
fabs(Y) > 1.19 + ymargin)
3272 (X > 2.3 + xmargin && X < 3.46 - xmargin &&
fabs(Y) < 5.73 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3274 (X > 4.64 + xmargin && X < 5.8 - xmargin &&
fabs(Y) < 4.59 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3303 (-X > -6.96 && -X < -5.8 &&
fabs(Y) < 2.31 &&
fabs(Y) > 0.07)
3305 (-X > -4.64 && -X < -3.48 &&
fabs(Y) < 5.73 &&
fabs(Y) > 0.07)
3307 (-X > -2.33 && -X < -1.17 &&
fabs(Y) < 6.87 &&
fabs(Y) > 0.07)
3309 (-X > 0. && -X < 1.16 &&
fabs(Y) < 6.85 &&
fabs(Y) > 1.19)
3311 (-X > 2.3 && -X < 3.46 &&
fabs(Y) < 5.73 &&
fabs(Y) > 0.07)
3313 (-X > 4.64 && -X < 5.8 &&
fabs(Y) < 4.59 &&
fabs(Y) > 0.07)
3342 (-X > -6.96 + xmargin && -X < -5.8 - xmargin &&
fabs(Y) < 2.31 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3344 (-X > -4.64 + xmargin && -X < -3.48 - xmargin &&
fabs(Y) < 5.73 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3346 (-X > -2.33 + xmargin && -X < -1.17 - xmargin &&
fabs(Y) < 6.87 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3348 (-X > 0. + xmargin && -X < 1.16 - xmargin &&
fabs(Y) < 6.85 - ymargin &&
fabs(Y) > 1.19 + ymargin)
3350 (-X > 2.3 + xmargin && -X < 3.46 - xmargin &&
fabs(Y) < 5.73 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3352 (-X > 4.64 + xmargin && -X < 5.8 - xmargin &&
fabs(Y) < 4.59 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3378 (-X > -6.96 && -X < -5.8 &&
fabs(Y) < 2.31 &&
fabs(Y) > 0.07)
3380 (-X > -4.64 && -X < -3.48 &&
fabs(Y) < 5.73 &&
fabs(Y) > 0.07)
3382 (-X > -2.33 && -X < -1.17 &&
fabs(Y) < 6.87 &&
fabs(Y) > 0.07)
3384 (-X > 0. && -X < 1.16 &&
fabs(Y) < 6.85 &&
fabs(Y) > 1.19)
3386 (-X > 2.3 && -X < 3.46 &&
fabs(Y) < 5.73 &&
fabs(Y) > 0.07)
3388 (-X > 4.64 && -X < 5.8 &&
fabs(Y) < 4.59 &&
fabs(Y) > 0.07)
3417 (-X > -6.96 + xmargin && -X < -5.8 - xmargin &&
fabs(Y) < 2.31 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3419 (-X > -4.64 + xmargin && -X < -3.48 - xmargin &&
fabs(Y) < 5.73 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3421 (-X > -2.33 + xmargin && -X < -1.17 - xmargin &&
fabs(Y) < 6.87 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3423 (-X > 0. + xmargin && -X < 1.16 - xmargin &&
fabs(Y) < 6.85 - ymargin &&
fabs(Y) > 1.19 + ymargin)
3425 (-X > 2.3 + xmargin && -X < 3.46 - xmargin &&
fabs(Y) < 5.73 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3427 (-X > 4.64 + xmargin && -X < 5.8 - xmargin &&
fabs(Y) < 4.59 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3455 (X > -6.96 && X < -5.8 &&
fabs(Y) < 2.31 &&
fabs(Y) > 0.07)
3457 (X > -4.64 && X < -3.48 &&
fabs(Y) < 5.73 &&
fabs(Y) > 0.07)
3459 (X > -2.33 && X < -1.17 &&
fabs(Y) < 6.87 &&
fabs(Y) > 0.07)
3461 (X > 0. && X < 1.16 &&
fabs(Y) < 6.85 &&
fabs(Y) > 1.19)
3463 (X > 2.3 && X < 3.46 &&
fabs(Y) < 5.73 &&
fabs(Y) > 0.07)
3465 (X > 4.64 && X < 5.8 &&
fabs(Y) < 4.59 &&
fabs(Y) > 0.07)
3492 (X > -6.96 + xmargin && X < -5.8 - xmargin &&
fabs(Y) < 2.31 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3494 (X > -4.64 + xmargin && X < -3.48 - xmargin &&
fabs(Y) < 5.73 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3496 (X > -2.33 + xmargin && X < -1.17 - xmargin &&
fabs(Y) < 6.87 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3498 (X > 0. + xmargin && X < 1.16 - xmargin &&
fabs(Y) < 6.85 - ymargin &&
fabs(Y) > 1.19 + ymargin)
3500 (X > 2.3 + xmargin && X < 3.46 - xmargin &&
fabs(Y) < 5.73 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3502 (X > 4.64 + xmargin && X < 5.8 - xmargin &&
fabs(Y) < 4.59 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3530 (X > -6.96 && X < -5.8 &&
fabs(Y) < 2.31 &&
fabs(Y) > 0.07)
3532 (X > -4.64 && X < -3.48 &&
fabs(Y) < 5.73 &&
fabs(Y) > 0.07)
3534 (X > -2.33 && X < -1.17 &&
fabs(Y) < 6.87 &&
fabs(Y) > 0.07)
3536 (X > 0. && X < 1.16 &&
fabs(Y) < 6.85 &&
fabs(Y) > 1.19)
3538 (X > 2.3 && X < 3.46 &&
fabs(Y) < 5.73 &&
fabs(Y) > 0.07)
3540 (X > 4.64 && X < 5.8 &&
fabs(Y) < 4.59 &&
fabs(Y) > 0.07)
3568 (X > -6.96 + xmargin && X < -5.8 - xmargin &&
fabs(Y) < 2.31 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3570 (X > -4.64 + xmargin && X < -3.48 - xmargin &&
fabs(Y) < 5.73 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3572 (X > -2.33 + xmargin && X < -1.17 - xmargin &&
fabs(Y) < 6.87 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3574 (X > 0. + xmargin && X < 1.16 - xmargin &&
fabs(Y) < 6.85 - ymargin &&
fabs(Y) > 1.19 + ymargin)
3576 (X > 2.3 + xmargin && X < 3.46 - xmargin &&
fabs(Y) < 5.73 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3578 (X > 4.64 + xmargin && X < 5.8 - xmargin &&
fabs(Y) < 4.59 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3607 (-X > -6.96 && -X < -5.8 &&
fabs(Y) < 2.31 &&
fabs(Y) > 0.07)
3609 (-X > -4.64 && -X < -3.48 &&
fabs(Y) < 5.73 &&
fabs(Y) > 0.07)
3611 (-X > -2.33 && -X < -1.17 &&
fabs(Y) < 6.87 &&
fabs(Y) > 0.07)
3613 (-X > 0. && -X < 1.16 &&
fabs(Y) < 6.85 &&
fabs(Y) > 1.19)
3615 (-X > 2.3 && -X < 3.46 &&
fabs(Y) < 5.73 &&
fabs(Y) > 0.07)
3617 (-X > 4.64 && -X < 5.8 &&
fabs(Y) < 4.59 &&
fabs(Y) > 0.07)
3645 (-X > -6.96 + xmargin && -X < -5.8 - xmargin &&
fabs(Y) < 2.31 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3647 (-X > -4.64 + xmargin && -X < -3.48 - xmargin &&
fabs(Y) < 5.73 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3649 (-X > -2.33 + xmargin && -X < -1.17 - xmargin &&
fabs(Y) < 6.87 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3651 (-X > 0. + xmargin && -X < 1.16 - xmargin &&
fabs(Y) < 6.85 - ymargin &&
fabs(Y) > 1.19 + ymargin)
3653 (-X > 2.3 + xmargin && -X < 3.46 - xmargin &&
fabs(Y) < 5.73 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3655 (-X > 4.64 + xmargin && -X < 5.8 - xmargin &&
fabs(Y) < 4.59 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3685 (-X > -6.96 && -X < -5.8 &&
fabs(Y) < 2.31 &&
fabs(Y) > 0.07)
3687 (-X > -4.64 && -X < -3.48 &&
fabs(Y) < 5.73 &&
fabs(Y) > 0.07)
3689 (-X > -2.33 && -X < -1.17 &&
fabs(Y) < 6.87 &&
fabs(Y) > 0.07)
3691 (-X > 0. && -X < 1.16 &&
fabs(Y) < 6.85 &&
fabs(Y) > 1.19)
3693 (-X > 2.3 && -X < 3.46 &&
fabs(Y) < 5.73 &&
fabs(Y) > 0.07)
3695 (-X > 4.64 && -X < 5.8 &&
fabs(Y) < 4.59 &&
fabs(Y) > 0.07)
3726 (-X > -6.96 && -X < -5.8 &&
fabs(Y) < 2.31 &&
fabs(Y) > 0.07)
3728 (-X > -4.64 && -X < -3.48 &&
fabs(Y) < 5.73 &&
fabs(Y) > 0.07)
3730 (-X > -2.33 && -X < -1.17 &&
fabs(Y) < 6.87 &&
fabs(Y) > 0.07)
3732 (-X > 0. && -X < 1.16 &&
fabs(Y) < 6.85 &&
fabs(Y) > 1.19)
3734 (-X > 2.3 && -X < 3.46 &&
fabs(Y) < 5.73 &&
fabs(Y) > 0.07)
3736 (-X > 4.64 && -X < 5.8 &&
fabs(Y) < 4.59 &&
fabs(Y) > 0.07)
3763 (X > -6.96 && X < -5.8 &&
fabs(Y) < 2.31 &&
fabs(Y) > 0.07)
3765 (X > -4.64 && X < -3.48 &&
fabs(Y) < 5.73 &&
fabs(Y) > 0.07)
3767 (X > -2.33 && X < -1.17 &&
fabs(Y) < 6.87 &&
fabs(Y) > 0.07)
3769 (X > 0. && X < 1.16 &&
fabs(Y) < 6.85 &&
fabs(Y) > 1.19)
3771 (X > 2.3 && X < 3.46 &&
fabs(Y) < 5.73 &&
fabs(Y) > 0.07)
3773 (X > 4.64 && X < 5.8 &&
fabs(Y) < 4.59 &&
fabs(Y) > 0.07)
3801 (X > -6.96 + xmargin && X < -5.8 - xmargin &&
fabs(Y) < 2.31 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3803 (X > -4.64 + xmargin && X < -3.48 - xmargin &&
fabs(Y) < 5.73 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3805 (X > -2.33 + xmargin && X < -1.17 - xmargin &&
fabs(Y) < 6.87 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3807 (X > 0. + xmargin && X < 1.16 - xmargin &&
fabs(Y) < 6.85 - ymargin &&
fabs(Y) > 1.19 + ymargin)
3809 (X > 2.3 + xmargin && X < 3.46 - xmargin &&
fabs(Y) < 5.73 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3811 (X > 4.64 + xmargin && X < 5.8 - xmargin &&
fabs(Y) < 4.59 - ymargin &&
fabs(Y) > 0.07 + ymargin)
3837 Short_t nintersections;
3840 XintersectionList[8],
3841 YintersectionList[8],
3852 delta = Rr*Rr - (gap-Oxx)*(gap-Oxx);
3854 XintersectionList[0] = gap;
3855 YintersectionList[0] =
sqrt(delta) + Oyy;
3856 XintersectionList[1] = gap;
3857 YintersectionList[1] = -
sqrt(delta) + Oyy;
3862 delta = Rr*Rr - (-gap-Oxx)*(-gap-Oxx);
3864 XintersectionList[nintersections] = -gap;
3865 YintersectionList[nintersections] =
sqrt(delta) + Oyy;
3866 XintersectionList[nintersections+1] = -gap;
3867 YintersectionList[nintersections+1] = -
sqrt(delta) + Oyy;
3873 XintersectionList[nintersections] = Oxx + Rr*
cos(fi0+kappa*gap);
3874 YintersectionList[nintersections] = Oyy + Rr*
sin(fi0+kappa*gap);
3878 XintersectionList[nintersections] = Oxx + Rr*
cos(fi0-kappa*gap);
3879 YintersectionList[nintersections] = Oyy + Rr*
sin(fi0-kappa*gap);
3884 ChooseEntranceExitbis(
3898 for(
int ic=0;ic<nintersections;ic++){
3901 if(
fabs(Ycross[0]) > 4. )
return true;
3921 if( (Xtraslation-Px)*
sin(Theta) + (Py-Ytraslation)*
cos(Theta) >= 0. )
return true;
3944 Short_t & nArcs_populated,
3945 Short_t nHitsInArc[56],
3948 Short_t (* ListHitsInArc) [56]
3975 AllFiOrderedList[56],
3976 AllXOrderedList[56],
3977 AllYOrderedList[56],
3998 Start[0]=Start[1]=Start[2]= 0.;
4012 nIntersections = FindTrackEntranceExitHexagonCircleRight2(
4021 &AllXOrderedList[0],
4022 &AllYOrderedList[0],
4030 half = nIntersections/2;
4031 remainder = nIntersections - 2 * half;
4034 if( remainder != 0 ){
4035 cout<<
"PndTrkCTGeometryCalculations::ListAxialSectorsCrossedbyTrack_and_Hits,after FindTrackEntranceExitHexagonCircleRight2;"
4036 <<
"\n\todd number of intersections : "<<nIntersections<<
", cannot be, return with nArcs_populated=0!\n";
4054 n = FindTrackEntranceExitbiHexagonRight2(
4063 &AllXOrderedList[nIntersections],
4064 &AllYOrderedList[nIntersections],
4065 &AllFiOrderedList[nIntersections]
4071 remainder = n - 2 * half;
4073 if( remainder != 0 ){
4074 cout<<
"PndTrkCTGeometryCalculations::ListAxialSectorsCrossedbyTrack_and_Hits,after FindTrackEntranceExitbiHexagonRight2;"
4075 <<
"\n\todd number of intersections : "<<n<<
", cannot be, return with nArcs_populated=0!\n";
4081 nIntersections +=
n;
4091 n = FindTrackEntranceExitbiHexagonLeft2(
4100 &AllXOrderedList[nIntersections],
4101 &AllYOrderedList[nIntersections],
4102 &AllFiOrderedList[nIntersections]
4107 remainder = n - 2 * half;
4109 if( remainder != 0 ){
4110 cout<<
"PndTrkCTGeometryCalculations::ListAxialSectorsCrossedbyTrack_and_Hits,after FindTrackEntranceExitbiHexagonLeft2;"
4111 <<
"\n\todd number of intersections : "<<n<<
", cannot be, return with nArcs_populated=0!\n";
4122 nIntersections +=
n;
4130 n = FindTrackEntranceExitHexagonCircleLeft2(
4139 &AllXOrderedList[nIntersections],
4140 &AllYOrderedList[nIntersections],
4141 &AllFiOrderedList[nIntersections]
4146 remainder = n - 2 * half;
4148 if( remainder != 0 ){
4149 cout<<
"PndTrkCTGeometryCalculations::ListAxialSectorsCrossedbyTrack_and_Hits,after FindTrackEntranceExitHexagonCircleLeft2;"
4150 <<
"\n\todd number of intersections : "<<n<<
", cannot be, return with nArcs_populated=0!\n";
4159 nIntersections +=
n;
4172 FiStart =
atan2( Start[1]-Oy,Start[0]-Ox);
4173 if(FiStart<0.) FiStart+=
TWO_PI;
4174 if(FiStart<0.) FiStart =0.;
4181 for(i=0;i<
nHits;i++){
4182 fi =
atan2(info[ListHits[i]][1]-Oy, info[ListHits[i]][0]-Ox);
4185 if( fi > FiStart) fi -=
TWO_PI;
4186 if( fi > FiStart) fi = FiStart;
4188 for(jArc=0;jArc<nArcs;jArc++){
4189 if(fi < AllFiOrderedList[2*jArc] && fi>AllFiOrderedList[2*jArc+1])
4191 if( jArc != oldArc ){
4193 nHitsInArc[nArcs_populated] = 1;
4194 ListHitsInArc[0][nArcs_populated ] = ListHits[
i];
4197 ListHitsInArc[ nHitsInArc[nArcs_populated-1] ][ nArcs_populated-1 ] = ListHits[
i];
4198 nHitsInArc[ nArcs_populated-1 ] ++;
4210 for(i=0;i<
nHits;i++){
4211 fi =
atan2(info[ListHits[i]][1]-Oy, info[ListHits[i]][0]-Ox);
4214 if( fi < FiStart) fi +=
TWO_PI;
4215 if( fi < FiStart) fi = FiStart;
4217 for(jArc=0;jArc<nArcs;jArc++){
4218 if(fi > AllFiOrderedList[2*jArc] && fi < AllFiOrderedList[2*jArc+1])
4220 if( jArc != oldArc ){
4222 nHitsInArc[nArcs_populated] = 1;
4223 ListHitsInArc[0][nArcs_populated ] = ListHits[
i];
4226 ListHitsInArc[ nHitsInArc[nArcs_populated-1] ][ nArcs_populated-1 ] = ListHits[
i];
4227 nHitsInArc[ nArcs_populated-1 ] ++;
friend F32vec4 acos(const F32vec4 &a)
const Double_t RSTRAWDETECTORMAX
bool IsInMvdMiniDisk6_97to6_99(Double_t X, Double_t Y)
const Double_t STRAWRESOLUTION
bool IsInMvdMiniDisk9_97to9_99withMargin(Double_t X, Double_t Y, Double_t xmargin, Double_t ymargin)
friend F32vec4 cos(const F32vec4 &a)
bool IsInternal(Double_t Px, Double_t Py, Double_t Xtraslation, Double_t Ytraslation, Double_t Theta)
void FindingParallelTrackAngularRange(Double_t oX, Double_t oY, Double_t Rr, Short_t Charge, Double_t *Fi_low_limit, Double_t *Fi_up_limit, Short_t *status, Double_t Rmin, Double_t Rmax)
void ListAxialSectorsCrossedbyTrack_and_Hits(Double_t Ox, Double_t Oy, Double_t R, Double_t Charge, Short_t nHits, Short_t *ListHits, Double_t info[][7], Short_t &nArcs_populated, Short_t nHitsInArc[56], Short_t(*ListHitsInArc)[56])
Short_t IntersectionsWithClosedPolygon(Double_t Oxx, Double_t Oyy, Double_t Rr, Double_t Rmi, Double_t Rma, Short_t nIntersections[2], Double_t XintersectionList[][2], Double_t YintersectionList[][2])
Short_t IntersectionsWithClosedbiHexagonLeft(Double_t vgap, Double_t Oxx, Double_t Oyy, Double_t Rr, Double_t Ami, Double_t Ama, Short_t *nIntersections, Double_t *XintersectionList, Double_t *YintersectionList)
Short_t FindTrackEntranceExitHexagonCircleLeft2(Double_t Oxx, Double_t Oyy, Double_t Rr, Short_t Charge, Double_t Start[3], Double_t ApotemaMin, Double_t ApotemaMax, Double_t GAP, Double_t XintersectionList[12], Double_t YintersectionList[12], Double_t FiOrderedList[12])
friend F32vec4 sqrt(const F32vec4 &a)
Short_t IntersectionsWithClosedbiHexagonRight(Double_t vgap, Double_t Oxx, Double_t Oyy, Double_t Rr, Double_t Ami, Double_t Ama, Short_t *nIntersections, Double_t *XintersectionList, Double_t *YintersectionList)
bool IsInTargetPipe(Double_t Oxx, Double_t Oyy, Double_t Rr, Double_t fi0, Double_t kappa, Short_t charge, Double_t gap)
void ChooseEntranceExit3(Double_t Oxx, Double_t Oyy, Short_t Charge, Double_t FiStart, Short_t nIntersections, Double_t *XintersectionList, Double_t *YintersectionList, Double_t *FiOrderedList)
void CalculateSandZ(Double_t Oxx, Double_t Oyy, Double_t Rr, Short_t skewnum, Double_t info[][7], Double_t *WDX, Double_t *WDY, Double_t *WDZ, Double_t S[2], Double_t Z[2], Double_t Zdrift[2], Double_t Zerror[2])
bool IsInMvdMiniDisk6_97to6_99withMargin(Double_t X, Double_t Y, Double_t xmargin, Double_t ymargin)
Double_t Dist_SZ(Double_t Rr, Double_t KAPPA, Double_t FI0, Double_t ZED, Double_t S, Int_t *nrounds)
friend F32vec4 sin(const F32vec4 &a)
bool IsInMvdMiniDisk10_41to10_43(Double_t X, Double_t Y)
bool IsInMvdMiniDisk2_41to2_43withMargin(Double_t X, Double_t Y, Double_t xmargin, Double_t ymargin)
Short_t FindTrackEntranceExitHexagonCircleLeft(Double_t Oxx, Double_t Oyy, Double_t Rr, Short_t Charge, Double_t Start[3], Double_t ApotemaMin, Double_t ApotemaMax, Double_t GAP, Double_t Xcross[2], Double_t Ycross[2])
bool IsInMvdMiniDisk9_97to9_99(Double_t X, Double_t Y)
bool IsInMvdMiniDisk21_77to21_79withMargin(Double_t X, Double_t Y, Double_t xmargin, Double_t ymargin)
bool IsInMvdMiniDisk7_41to7_43withMargin(Double_t X, Double_t Y, Double_t xmargin, Double_t ymargin)
bool IsInMvdMiniDisk14_77to14_79(Double_t X, Double_t Y)
Double_t Dist_SZ_bis(Double_t Rr, Double_t KAPPA, Double_t FI0, Double_t ZED, Double_t S, Short_t n_allowed_rounds, Double_t signPz, Double_t &chosenS)
void ChooseEntranceExitbis(Double_t Oxx, Double_t Oyy, Short_t Charge, Double_t FiStart, Short_t nIntersections, Double_t *XintersectionList, Double_t *YintersectionList, Double_t Xcross[2], Double_t Ycross[2])
bool IntersectionCircle_Segment_forScitil(Double_t a, Double_t b, Double_t c, Double_t P1x, Double_t P2x, Double_t P1y, Double_t P2y, Double_t Oxx, Double_t Oyy, Double_t Rr, Double_t factor, Short_t *Nintersections, Double_t XintersectionList[2], Double_t YintersectionList[2], Double_t *distance)
bool IsInMvdMiniDisk15_21to15_23withMargin(Double_t X, Double_t Y, Double_t xmargin, Double_t ymargin)
const Double_t SEMILENGTH_STRAIGHT
bool CalculateCircleThru3Points(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Double_t x3, Double_t y3, Double_t *o_x, Double_t *o_y, Double_t *r_r)
bool IsInMvdMiniDisk1_97to1_99withMargin(Double_t X, Double_t Y, Double_t xmargin, Double_t ymargin)
bool IsInMvdMiniDisk22_21to22_23(Double_t X, Double_t Y)
const Double_t APOTEMAMINOUTERPARSTRAW
bool IsInMvdMiniDisk21_77to21_79(Double_t X, Double_t Y)
bool IsInMvdMiniDisk14_77to14_79withMargin(Double_t X, Double_t Y, Double_t xmargin, Double_t ymargin)
friend F32vec4 fabs(const F32vec4 &a)
bool IsInsideArc(Double_t Oxx, Double_t Oyy, Short_t Charge, Double_t Xcross[2], Double_t Ycross[2], Double_t Spoint)
Short_t IntersectionsWithOpenPolygon(Double_t Oxx, Double_t Oyy, Double_t Rr, Short_t nSides, Double_t *a, Double_t *b, Double_t *c, Double_t *side_x, Double_t *side_y, Double_t *XintersectionList, Double_t *YintersectionList)
void CalculateSandZ2(Double_t Oxx, Double_t Oyy, Double_t Rr, Short_t skewnum, Double_t info[][7], Double_t *WDX, Double_t *WDY, Double_t *WDZ, Double_t S[2], Double_t Sdrift[2], Double_t Z[2], Double_t Zdrift[2], Double_t Zerror[2])
const Double_t VERTICALGAP
bool IntersectionCircle_Segment(Double_t a, Double_t b, Double_t c, Double_t P1x, Double_t P2x, Double_t P1y, Double_t P2y, Double_t Oxx, Double_t Oyy, Double_t Rr, Short_t *Nintersections, Double_t XintersectionList[2], Double_t YintersectionList[2], Double_t *distance)
void Merge_Sort(Short_t n_ele, Double_t *array, Int_t *ind)
Short_t FindTrackEntranceExitbiHexagonRight2(Double_t vgap, Double_t Oxx, Double_t Oyy, Double_t Rr, Short_t Charge, Double_t Start[3], Double_t ApotemaMin, Double_t ApotemaMax, Double_t XintersectionList[16], Double_t YintersectionList[16], Double_t FiOrderedList[16])
friend F32vec4 atan2(const F32vec4 &y, const F32vec4 &x)
Double_t FindDistance(Double_t Oxx, Double_t Oyy, Double_t Rr, Double_t tanlow, Double_t tanmid, Double_t tanup, Double_t alfa, Double_t beta, Double_t gamma)
const Double_t APOTEMAMAXINNERPARSTRAW
Short_t FindTrackEntranceExitbiHexagonLeft2(Double_t vgap, Double_t Oxx, Double_t Oyy, Double_t Rr, Short_t Charge, Double_t Start[3], Double_t ApotemaMin, Double_t ApotemaMax, Double_t XintersectionList[16], Double_t YintersectionList[16], Double_t FiOrderedList[16])
bool IsInMvdMiniDisk4_41to4_43(Double_t X, Double_t Y)
Short_t FindTrackEntranceExitHexagonCircleRight2(Double_t Oxx, Double_t Oyy, Double_t Rr, Short_t Charge, Double_t Start[3], Double_t ApotemaMin, Double_t ApotemaMax, Double_t GAP, Double_t XintersectionList[12], Double_t YintersectionList[12], Double_t FiOrderedList[12])
Short_t FindTrackEntranceExitHexagonCircleRight(Double_t Oxx, Double_t Oyy, Double_t Rr, Short_t Charge, Double_t Start[3], Double_t ApotemaMin, Double_t ApotemaMax, Double_t GAP, Double_t Xcross[2], Double_t Ycross[2])
bool IsInMvdMiniDisk2_41to2_43(Double_t X, Double_t Y)
bool IntersectionSciTil_Circle(Double_t posizSciTilx, Double_t posizSciTily, Double_t Oxx, Double_t Oyy, Double_t Rr, Short_t *Nintersections, Double_t XintersectionList[2], Double_t YintersectionList[2])
bool IsInMvdMiniDisk7_41to7_43(Double_t X, Double_t Y)
bool IsInMvdMiniDisk15_21to15_23(Double_t X, Double_t Y)
bool IsInMvdMiniDisk3_97to3_99withMargin(Double_t X, Double_t Y, Double_t xmargin, Double_t ymargin)
Short_t FindIntersectionsOuterCircle(Double_t Oxx, Double_t Oyy, Double_t Rr, Double_t RMax, Double_t Xcross[2], Double_t Ycross[2])
Double_t CalculateArcLength(Double_t Oxx, Double_t Oyy, Double_t Rr, Short_t Charge, Double_t *Xcross, Double_t *Ycross)
Short_t IntersectionsWithGapSemicircle(Double_t Oxx, Double_t Oyy, Double_t Rr, Double_t gap, bool left, Double_t Rma, Double_t *XintersectionList, Double_t *YintersectionList)
Short_t FindTrackEntranceExitbiHexagonLeft(Double_t vgap, Double_t Oxx, Double_t Oyy, Double_t Rr, Short_t Charge, Double_t Start[3], Double_t ApotemaMin, Double_t ApotemaMax, Double_t Xcross[2], Double_t Ycross[2])
Short_t FindTrackEntranceExitbiHexagonRight(Double_t vgap, Double_t Oxx, Double_t Oyy, Double_t Rr, Short_t Charge, Double_t Start[3], Double_t ApotemaMin, Double_t ApotemaMax, Double_t Xcross[2], Double_t Ycross[2])
void calculateintersections(Double_t Oxx, Double_t Oyy, Double_t Rr, Double_t C0x, Double_t C0y, Double_t C0z, Double_t r, Double_t vx, Double_t vy, Double_t vz, Int_t *STATUS, Double_t *POINTS)
bool IsInMvdMiniDisk22_21to22_23withMargin(Double_t X, Double_t Y, Double_t xmargin, Double_t ymargin)
void FindingParallelTrackAngularRange2(Double_t oX, Double_t oY, Double_t Rma, Double_t Rmi, Double_t Rr, Double_t *Fi_low_limit, Double_t *Fi_up_limit, Short_t *status)
const Double_t APOTEMASTRAWDETECTORMIN
bool IsInMvdMiniDisk4_41to4_43withMargin(Double_t X, Double_t Y, Double_t xmargin, Double_t ymargin)
bool IsInMvdMiniDisk1_97to1_99(Double_t X, Double_t Y)
bool IsInMvdMiniDisk3_97to3_99(Double_t X, Double_t Y)
const Double_t ZCENTER_STRAIGHT
bool IsInMvdMiniDisk10_41to10_43withMargin(Double_t X, Double_t Y, Double_t xmargin, Double_t ymargin)
const Double_t DIMENSIONSCITIL