222 Double_t rsq = point[0]*point[0]+point[1]*point[1];
229 norm[0] = norm[1] = 0.;
237 if (norm[0]*dir[0]+norm[1]*dir[1]<0) {
253 if (norm[0]*dir[0]+norm[1]*dir[1]<0) {
265 Double_t r2 = point[0]*point[0]+point[1]*point[1];
277 if (!
HasRmin()) numPoints = 2*(
n+1);
292 if (sz<=0)
return 0.0;
295 Double_t nsq=dir[0]*dir[0]+dir[1]*dir[1];
297 Double_t rsq=point[0]*point[0]+point[1]*point[1];
298 Double_t rdotn=point[0]*dir[0]+point[1]*dir[1];
305 if (rdotn<0)
return 0.0;
318 if (rdotn>=0)
return 0.0;
334 if (iact<3 && safe) {
360 xi = point[0]+
s*dir[0];
361 yi = point[1]+
s*dir[1];
363 if ((rminsq<=r2) && (r2<=rmaxsq))
return s;
366 Double_t rsq = point[0]*point[0]+point[1]*point[1];
368 Double_t nsq=dir[0]*dir[0]+dir[1]*dir[1];
369 Double_t rdotn=point[0]*dir[0]+point[1]*dir[1];
375 in = inz & inrmin & inrmax;
382 if (point[2]*dir[2]<0)
return 0.0;
386 if ((rmaxsq-rsq) < (rsq-rminsq)) checkout =
kTRUE;
392 if (rdotn>=0)
return 0.0;
399 zi=point[2]+
s*dir[2];
412 zi=point[2]+
s*dir[2];
423 zi=point[2]+
s*dir[2];
438 if (iact<3 && safe) {
498 for (
id=0;
id<ndiv;
id++) {
499 shape =
new TGeoTube(start+
id*step, start+(
id+1)*step,
fDz);
516 for (
id=0;
id<ndiv;
id++) {
522 finder =
new TGeoPatternZ(voldiv, ndiv, start, start+ndiv*step);
530 for (
id=0;
id<ndiv;
id++) {
536 Error(
"Divide",
"In shape %s wrong axis type for division",
GetName());
593 param[0] *= param[0];
595 param[1] *= param[1];
614 if (
xmax<0)
return 0;
619 if (
xmin<0)
return 0;
623 if (
xmax<=0)
return 0;
635 printf(
"*** Shape %s: TGeoTube ***\n",
GetName());
636 printf(
" Rmin = %11.5f\n",
fRmin);
637 printf(
" Rmax = %11.5f\n",
fRmax);
638 printf(
" dz = %11.5f\n",
fDz);
639 printf(
" Bounding box:\n");
659 nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols);
685 for (i = 0; i < 4; i++) {
686 for (j = 0; j <
n; j++) {
689 buffer.
fSegs[indx+1] = i*
n+j;
690 buffer.
fSegs[indx+2] = i*
n+(j+1)%
n;
696 for (i = 4; i < 6; i++) {
697 for (j = 0; j <
n; j++) {
699 buffer.
fSegs[indx ] =
c+1;
700 buffer.
fSegs[indx+1] = (i-4)*
n+j;
701 buffer.
fSegs[indx+2] = (i-2)*
n+j;
707 for (i = 6; i < 8; i++) {
708 for (j = 0; j <
n; j++) {
711 buffer.
fSegs[indx+1] = 2*(i-6)*
n+j;
712 buffer.
fSegs[indx+2] = (2*(i-6)+1)*
n+j;
718 for (j = 0; j <
n; j++) {
721 buffer.
fPols[indx+1] = 4;
722 buffer.
fPols[indx+2] = j;
723 buffer.
fPols[indx+3] = 4*
n+(j+1)%
n;
724 buffer.
fPols[indx+4] = 2*
n+j;
725 buffer.
fPols[indx+5] = 4*
n+j;
729 for (j = 0; j <
n; j++) {
731 buffer.
fPols[indx ] =
c+1;
732 buffer.
fPols[indx+1] = 4;
733 buffer.
fPols[indx+2] =
n+j;
734 buffer.
fPols[indx+3] = 5*
n+j;
735 buffer.
fPols[indx+4] = 3*
n+j;
736 buffer.
fPols[indx+5] = 5*
n+(j+1)%
n;
740 for (j = 0; j <
n; j++) {
743 buffer.
fPols[indx+1] = 4;
744 buffer.
fPols[indx+2] = j;
745 buffer.
fPols[indx+3] = 6*
n+j;
746 buffer.
fPols[indx+4] =
n+j;
747 buffer.
fPols[indx+5] = 6*
n+(j+1)%
n;
751 for (j = 0; j <
n; j++) {
754 buffer.
fPols[indx+1] = 4;
755 buffer.
fPols[indx+2] = 2*
n+j;
756 buffer.
fPols[indx+3] = 7*
n+(j+1)%
n;
757 buffer.
fPols[indx+4] = 3*
n+j;
758 buffer.
fPols[indx+5] = 7*
n+j;
766 for (i = 0; i < 2; i++) {
767 for (j = 0; j <
n; j++) {
770 buffer.
fSegs[indx+1] = 2+i*
n+j;
771 buffer.
fSegs[indx+2] = 2+i*
n+(j+1)%
n;
775 for (j = 0; j <
n; j++) {
777 buffer.
fSegs[indx ] =
c+1;
778 buffer.
fSegs[indx+1] = 2+j;
779 buffer.
fSegs[indx+2] = 2+
n+j;
784 for (i = 3; i < 5; i++) {
785 for (j = 0; j <
n; j++) {
788 buffer.
fSegs[indx+1] = i-3;
789 buffer.
fSegs[indx+2] = 2+(i-3)*
n+j;
794 for (j = 0; j <
n; j++) {
796 buffer.
fPols[indx ] =
c+1;
797 buffer.
fPols[indx+1] = 4;
798 buffer.
fPols[indx+2] = j;
799 buffer.
fPols[indx+3] = 2*
n+j;
800 buffer.
fPols[indx+4] =
n+j;
801 buffer.
fPols[indx+5] = 2*
n+(j+1)%
n;
804 for (j = 0; j <
n; j++) {
807 buffer.
fPols[indx+1] = 3;
808 buffer.
fPols[indx+2] = j;
809 buffer.
fPols[indx+3] = 3*
n+(j+1)%
n;
810 buffer.
fPols[indx+4] = 3*
n+j;
813 for (j = 0; j <
n; j++) {
814 indx = 6*
n + 5*
n + 5*j;
816 buffer.
fPols[indx+1] = 3;
817 buffer.
fPols[indx+2] =
n+j;
818 buffer.
fPols[indx+3] = 4*
n+j;
819 buffer.
fPols[indx+4] = 4*
n+(j+1)%
n;
836 if (safrmin < safe) safe = safrmin;
839 if (safrmax < safe) safe = safrmax;
844 if (safrmin > safe) safe = safrmin;
847 if (safrmax > safe) safe = safrmax;
852 Double_t rsq = point[0]*point[0]+point[1]*point[1];
858 for (
Int_t i=0; i<3; i++) saf[i]=-saf[i];
870 Double_t rsq = point[0]*point[0]+point[1]*point[1];
874 saf[0] = dz - point[2];
877 saf[0] = dz + point[2];
889 for (
Int_t i=0; i<3; i++) saf[i]=-saf[i];
900 out <<
" rmin = " <<
fRmin <<
";" << std::endl;
901 out <<
" rmax = " <<
fRmax <<
";" << std::endl;
902 out <<
" dz = " <<
fDz <<
";" << std::endl;
903 out <<
" TGeoShape *" <<
GetPointerName() <<
" = new TGeoTube(\"" <<
GetName() <<
"\",rmin,rmax,dz);" << std::endl;
916 Error(
"SetTubeDimensions",
"In shape %s wrong rmin=%g rmax=%g",
GetName(), rmin,rmax);
937 if (npoints > (npoints/2)*2) {
938 Error(
"GetPointsOnSegments",
"Npoints must be even number");
947 if (
HasRmin()) ntop = npoints/2 - nc*(nc-1);
948 else ntop = npoints - nc*(nc-1);
954 for (
Int_t i=0; i<nc; i++) {
955 if (i == (nc-1)) nphi = ntop;
958 for (
Int_t j=0; j<nphi; j++) {
990 for (j = 0; j <
n; j++) {
1002 for (j = 0; j <
n; j++) {
1022 for (j = 0; j <
n; j++) {
1053 for (j = 0; j <
n; j++) {
1065 for (j = 0; j <
n; j++) {
1085 for (j = 0; j <
n; j++) {
1106 if (!
HasRmin()) numPoints = 2*(
n+1);
1161 if (buffer.
SetRawSizes(nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols)) {
1230 fPhi1(0.), fPhi2(0.), fS1(0.), fC1(0.), fS2(0.), fC2(0.), fSm(0.), fCm(0.), fCdfi(0.)
1242 fPhi1(0.), fPhi2(0.), fS1(0.), fC1(0.), fS2(0.), fC2(0.), fSm(0.), fCm(0.), fCdfi(0.)
1352 if (ddp<0) ddp+= 360;
1353 if (ddp>360) ddp-=360;
1356 if (ddp<0) ddp+= 360;
1357 if (ddp>360) ddp-=360;
1360 if (ddp<0) ddp+= 360;
1361 if (ddp>360) ddp-=360;
1364 if (ddp<0) ddp+= 360;
1365 if (ddp>360) ddp-=360;
1381 Double_t rsq = point[0]*point[0]+point[1]*point[1];
1392 norm[0] = norm[1] = 0.;
1400 if (norm[0]*dir[0]+norm[1]*dir[1]<0) {
1414 Double_t rsq = point[0]*point[0]+point[1]*point[1];
1427 if (norm[0]*dir[0]+norm[1]*dir[1]<0) {
1449 const Int_t numPoints = 4*
n;
1462 if (stube<=0)
return 0.0;
1464 Double_t rsq = point[0]*point[0]+point[1]*point[1];
1475 ddotn =
s1*dir[0]-
c1*dir[1];
1476 if (ddotn>=0)
return 0.0;
1477 ddotn = -s2*dir[0]+
c2*dir[1];
1478 if (ddotn<=0)
return stube;
1479 sfmin = s2*point[0]-
c2*point[1];
1480 if (sfmin<=0)
return stube;
1482 if (sfmin >= stube)
return stube;
1483 xi = point[0]+sfmin*dir[0];
1484 yi = point[1]+sfmin*dir[1];
1485 if (yi*
cm-xi*sm<0)
return stube;
1488 ddotn = -s2*dir[0]+
c2*dir[1];
1489 if (ddotn>=0)
return 0.0;
1490 ddotn =
s1*dir[0]-
c1*dir[1];
1491 if (ddotn<=0)
return stube;
1492 sfmin = -
s1*point[0]+
c1*point[1];
1493 if (sfmin<=0)
return stube;
1495 if (sfmin >= stube)
return stube;
1496 xi = point[0]+sfmin*dir[0];
1497 yi = point[1]+sfmin*dir[1];
1498 if (yi*
cm-xi*sm>0)
return stube;
1508 if (iact<3 && safe) {
1516 return TGeoTubeSeg::DistFromInsideS(point,dir,
fRmin,
fRmax,
fDz,
fC1,
fS1,
fC2,
fS2,
fCm,
fSm,
fCdfi);
1540 xi = point[0]+
s*dir[0];
1541 yi = point[1]+
s*dir[1];
1543 if ((rminsq<=r2) && (r2<=rmaxsq)) {
1545 if (cpsi>=cdfi)
return s;
1550 Double_t rsq = point[0]*point[0]+point[1]*point[1];
1552 Double_t nsq=dir[0]*dir[0]+dir[1]*dir[1];
1553 Double_t rdotn=point[0]*dir[0]+point[1]*dir[1];
1560 cpsi=point[0]*
cm+point[1]*sm;
1562 in = inz & inrmin & inrmax & inphi;
1572 if (point[2]*dir[2]<0)
return 0.0;
1577 if ((rmaxsq-rsq) < (rsq-rminsq)) checkout =
kTRUE;
1579 if (checkout && (rmax-
r<safphi)) {
1589 if (point[0]*
c1 + point[1]*
s1 > point[0]*
c2 + point[1]*s2) {
1590 un = dir[0]*
s1-dir[1]*
c1;
1591 if (un < 0)
return 0.0;
1593 un = -dir[0]*s2+dir[1]*
c2;
1595 s = -point[0]*s2+point[1]*
c2;
1598 zi = point[2]+
s*dir[2];
1600 xi = point[0]+
s*dir[0];
1601 yi = point[1]+
s*dir[1];
1603 if ((rminsq<=r2) && (r2<=rmaxsq)) {
1604 if ((yi*
cm-xi*sm)>0)
return s;
1610 un = -dir[0]*s2+dir[1]*
c2;
1611 if (un < 0)
return 0.0;
1613 un = dir[0]*
s1-dir[1]*
c1;
1615 s = point[0]*
s1-point[1]*
c1;
1618 zi = point[2]+
s*dir[2];
1620 xi = point[0]+
s*dir[0];
1621 yi = point[1]+
s*dir[1];
1623 if ((rminsq<=r2) && (r2<=rmaxsq)) {
1624 if ((yi*
cm-xi*sm)<0)
return s;
1637 zi=point[2]+
s*dir[2];
1639 xi=point[0]+
s*dir[0];
1640 yi=point[1]+
s*dir[1];
1641 if ((xi*
cm+yi*sm) >= rmin*cdfi)
return s;
1648 if (rdotn>=0)
return 0.0;
1653 zi=point[2]+
s*dir[2];
1656 xi=point[0]+
s*dir[0];
1657 yi=point[1]+
s*dir[1];
1659 if ((xi*
cm+yi*sm) >= rmin*cdfi)
return s;
1663 s=point[0]*
s1-point[1]*
c1;
1666 zi=point[2]+
s*dir[2];
1668 xi=point[0]+
s*dir[0];
1669 yi=point[1]+
s*dir[1];
1671 if ((rminsq<=r2) && (r2<=rmaxsq)) {
1672 if ((yi*
cm-xi*sm)<=0) {
1679 un=dir[0]*s2-dir[1]*
c2;
1681 s=(point[1]*
c2-point[0]*s2)/un;
1682 if (
s>=0 &&
s<snxt) {
1683 zi=point[2]+
s*dir[2];
1685 xi=point[0]+
s*dir[0];
1686 yi=point[1]+
s*dir[1];
1688 if ((rminsq<=r2) && (r2<=rmaxsq)) {
1689 if ((yi*
cm-xi*sm)>=0) {
1704 if (rsq>=rmax*rmax) {
1710 zi=point[2]+
s*dir[2];
1712 xi=point[0]+
s*dir[0];
1713 yi=point[1]+
s*dir[1];
1715 if (cpsi>=rmax*cdfi)
return s;
1726 zi=point[2]+
s*dir[2];
1728 xi=point[0]+
s*dir[0];
1729 yi=point[1]+
s*dir[1];
1731 if (cpsi>=rmin*cdfi) snxt=
s;
1739 s=point[0]*
s1-point[1]*
c1;
1742 zi=point[2]+
s*dir[2];
1744 xi=point[0]+
s*dir[0];
1745 yi=point[1]+
s*dir[1];
1747 if ((rminsq<=r2) && (r2<=rmaxsq)) {
1748 if ((yi*
cm-xi*sm)<=0) {
1755 un=dir[0]*s2-dir[1]*
c2;
1757 s=point[1]*
c2-point[0]*s2;
1760 zi=point[2]+
s*dir[2];
1762 xi=point[0]+
s*dir[0];
1763 yi=point[1]+
s*dir[1];
1765 if ((rminsq<=r2) && (r2<=rmaxsq)) {
1766 if ((yi*
cm-xi*sm)>=0) {
1782 if (iact<3 && safe) {
1793 return TGeoTubeSeg::DistFromOutsideS(point, dir,
fRmin,
fRmax,
fDz,
fC1,
fS1,
fC2,
fS2,
fCm,
fSm,
fCdfi);
1821 for (
id=0;
id<ndiv;
id++) {
1832 if (dphi<0) dphi+=360.;
1833 if (step<=0) {step=dphi/ndiv; start=
fPhi1; end=
fPhi2;}
1842 for (
id=0;
id<ndiv;
id++) {
1856 for (
id=0;
id<ndiv;
id++) {
1862 Error(
"Divide",
"In shape %s wrong axis type for division",
GetName());
1902 param[0] *= param[0];
1904 param[1] *= param[1];
1917 Error(
"GetMakeRuntimeShape",
"Invalid mother for shape %s",
GetName());
1926 rmin = ((
TGeoTube*)mother)->GetRmin();
1928 rmax = ((
TGeoTube*)mother)->GetRmax();
1938 printf(
"*** Shape %s: TGeoTubeSeg ***\n",
GetName());
1939 printf(
" Rmin = %11.5f\n",
fRmin);
1940 printf(
" Rmax = %11.5f\n",
fRmax);
1941 printf(
" dz = %11.5f\n",
fDz);
1942 printf(
" phi1 = %11.5f\n",
fPhi1);
1943 printf(
" phi2 = %11.5f\n",
fPhi2);
1944 printf(
" Bounding box:\n");
1956 Int_t nbSegs = 2*nbPnts;
1957 Int_t nbPols = nbPnts-2;
1960 nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols);
1980 for (i = 0; i < 4; i++) {
1981 for (j = 1; j <
n; j++) {
1983 buff.
fSegs[(i*
n+j-1)*3+1] = i*
n+j-1;
1984 buff.
fSegs[(i*
n+j-1)*3+2] = i*
n+j;
1987 for (i = 4; i < 6; i++) {
1988 for (j = 0; j <
n; j++) {
1990 buff.
fSegs[(i*
n+j)*3+1] = (i-4)*
n+j;
1991 buff.
fSegs[(i*
n+j)*3+2] = (i-2)*
n+j;
1994 for (i = 6; i < 8; i++) {
1995 for (j = 0; j <
n; j++) {
1997 buff.
fSegs[(i*
n+j)*3+1] = 2*(i-6)*
n+j;
1998 buff.
fSegs[(i*
n+j)*3+2] = (2*(i-6)+1)*
n+j;
2005 for (j = 0; j <
n-1; j++) {
2007 buff.
fPols[indx++] = 4;
2008 buff.
fPols[indx++] = (4+i)*
n+j+1;
2009 buff.
fPols[indx++] = (2+i)*
n+j;
2010 buff.
fPols[indx++] = (4+i)*
n+j;
2011 buff.
fPols[indx++] = i*
n+j;
2014 for (j = 0; j <
n-1; j++) {
2016 buff.
fPols[indx++] = 4;
2017 buff.
fPols[indx++] = i*
n+j;
2018 buff.
fPols[indx++] = (4+i)*
n+j;
2019 buff.
fPols[indx++] = (2+i)*
n+j;
2020 buff.
fPols[indx++] = (4+i)*
n+j+1;
2023 for (j = 0; j <
n-1; j++) {
2024 buff.
fPols[indx++] =
c+i;
2025 buff.
fPols[indx++] = 4;
2026 buff.
fPols[indx++] = (i-2)*2*
n+j;
2027 buff.
fPols[indx++] = (4+i)*
n+j;
2028 buff.
fPols[indx++] = ((i-2)*2+1)*
n+j;
2029 buff.
fPols[indx++] = (4+i)*
n+j+1;
2032 for (j = 0; j <
n-1; j++) {
2033 buff.
fPols[indx++] =
c+i;
2034 buff.
fPols[indx++] = 4;
2035 buff.
fPols[indx++] = (4+i)*
n+j+1;
2036 buff.
fPols[indx++] = ((i-2)*2+1)*
n+j;
2037 buff.
fPols[indx++] = (4+i)*
n+j;
2038 buff.
fPols[indx++] = (i-2)*2*
n+j;
2040 buff.
fPols[indx++] =
c+2;
2041 buff.
fPols[indx++] = 4;
2042 buff.
fPols[indx++] = 6*
n;
2043 buff.
fPols[indx++] = 4*
n;
2044 buff.
fPols[indx++] = 7*
n;
2045 buff.
fPols[indx++] = 5*
n;
2046 buff.
fPols[indx++] =
c+2;
2047 buff.
fPols[indx++] = 4;
2048 buff.
fPols[indx++] = 6*
n-1;
2049 buff.
fPols[indx++] = 8*
n-1;
2050 buff.
fPols[indx++] = 5*
n-1;
2051 buff.
fPols[indx++] = 7*
n-1;
2062 Double_t rsq = point[0]*point[0]+point[1]*point[1];
2089 saf[1] =
fRmin-rproj;
2090 saf[2] = rproj-
fRmax;
2096 return (saf[0]<0) ? safe :
TMath::Sqrt(safe*safe+saf[0]*saf[0]);
2099 return (saf[0]<0) ? safphi :
TMath::Sqrt(saf[0]*saf[0]+safphi*safphi);
2110 Double_t rsq = point[0]*point[0]+point[1]*point[1];
2115 saf[0] = dz - point[2];
2118 saf[0] = dz + point[2];
2131 if ((phi2d-phi1d)>=360.)
return safe;
2164 saf[1] = rmin-rproj;
2165 saf[2] = rproj-rmax;
2167 if ((phi2d-phi1d)>=360.)
return TMath::Max(safe,saf[0]);
2171 return (saf[0]<0) ? safe :
TMath::Sqrt(safe*safe+saf[0]*saf[0]);
2174 return (saf[0]<0) ? safphi :
TMath::Sqrt(saf[0]*saf[0]+safphi*safphi);
2183 out <<
" // Shape: " <<
GetName() <<
" type: " <<
ClassName() << std::endl;
2184 out <<
" rmin = " <<
fRmin <<
";" << std::endl;
2185 out <<
" rmax = " <<
fRmax <<
";" << std::endl;
2186 out <<
" dz = " <<
fDz <<
";" << std::endl;
2187 out <<
" phi1 = " <<
fPhi1 <<
";" << std::endl;
2188 out <<
" phi2 = " <<
fPhi2 <<
";" << std::endl;
2189 out <<
" TGeoShape *" <<
GetPointerName() <<
" = new TGeoTubeSeg(\"" <<
GetName() <<
"\",rmin,rmax,dz,phi1,phi2);" << std::endl;
2231 if (npoints > (npoints/2)*2) {
2232 Error(
"GetPointsOnSegments",
"Npoints must be even number");
2239 Int_t ntop = npoints/2 - nc*(nc-1);
2245 for (
Int_t i=0; i<nc; i++) {
2252 for (
Int_t j=0; j<nphi; j++) {
2253 phi = phi1 + j*dphi;
2275 if (phi2<phi1) phi2+=360.;
2278 dphi = (phi2-phi1)/(
n-1);
2284 for (j = 0; j <
n; j++) {
2294 for (j = 0; j <
n; j++) {
2317 if (phi2<phi1) phi2+=360.;
2320 dphi = (phi2-phi1)/(
n-1);
2326 for (j = 0; j <
n; j++) {
2336 for (j = 0; j <
n; j++) {
2397 Int_t nbSegs = 2*nbPnts;
2398 Int_t nbPols = nbPnts-2;
2399 if (buffer.
SetRawSizes(nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols)) {
2511 SetCtubDimensions(params[0], params[1], params[2], params[3], params[4], params[5],
2512 params[6], params[7], params[8], params[9], params[10]);
2539 Error(
"ComputeBBox",
"In shape %s wrong definition of cut planes",
GetName());
2553 for (i=0; i<2; i++) {
2554 if (phi_low<0) phi_low+=360.;
2556 if (dphi < 0) dphi+=360.;
2558 if (ddp<0) ddp += 360.;
2570 in_range_low =
kTRUE;
2573 if (phi_low>360) phi_low-=360.;
2576 for (i=0; i<2; i++) {
2577 if (phi_hi<0) phi_hi+=360.;
2579 if (dphi < 0) dphi+=360.;
2581 if (ddp<0) ddp += 360.;
2593 in_range_hi =
kTRUE;
2596 if (phi_hi>360) phi_hi-=360.;
2632 fDZ = 0.5*(zmax-zmin);
2644 Double_t rsq = point[0]*point[0]+point[1]*point[1];
2660 if (norm[0]*dir[0]+norm[1]*dir[1]+norm[2]*dir[2]<0) {
2669 if (norm[0]*dir[0]+norm[1]*dir[1]+norm[2]*dir[2]<0) {
2681 if (norm[0]*dir[0]+norm[1]*dir[1]<0) {
2694 if (zin>0)
return kFALSE;
2697 if (zin>0)
return kFALSE;
2699 Double_t r2 = point[0]*point[0]+point[1]*point[1];
2703 if (phi < 0 ) phi+=360.;
2706 if (ddp<0) ddp += 360.;
2708 if (ddp > dphi)
return kFALSE;
2752 if (iact<3 && safe) {
2763 Double_t rsq = point[0]*point[0]+point[1]*point[1];
2778 xi = point[0]+
s*dir[0];
2779 yi = point[1]+
s*dir[1];
2784 if (cpsi>=
fCdfi)
return s;
2792 xi = point[0]+
s*dir[0];
2793 yi = point[1]+
s*dir[1];
2798 if (cpsi>=
fCdfi)
return s;
2804 Double_t nsq=dir[0]*dir[0]+dir[1]*dir[1];
2806 Double_t rdotn=point[0]*dir[0]+point[1]*dir[1];
2809 if (
r>
fRmax && rdotn<0) {
2814 xi=point[0]+
s*dir[0];
2815 yi=point[1]+
s*dir[1];
2816 zi=point[2]+
s*dir[2];
2821 if (cpsi>=
fCdfi)
return s;
2834 xi=point[0]+
s*dir[0];
2835 yi=point[1]+
s*dir[1];
2836 zi=point[2]+
s*dir[2];
2848 if (tub)
return snxt;
2851 s=(point[1]*
fC1-point[0]*
fS1)/un;
2853 xi=point[0]+
s*dir[0];
2854 yi=point[1]+
s*dir[1];
2855 zi=point[2]+
s*dir[2];
2860 if ((yi*
fCm-xi*
fSm)<=0) {
2868 un=dir[0]*
fS2-dir[1]*
fC2;
2870 s=(point[1]*
fC2-point[0]*
fS2)/un;
2872 xi=point[0]+
s*dir[0];
2873 yi=point[1]+
s*dir[1];
2874 zi=point[2]+
s*dir[2];
2879 if ((yi*
fCm-xi*
fSm)>=0) {
2898 Double_t rsq = point[0]*point[0]+point[1]*point[1];
2908 if (calf>0) sz = saf[0]/calf;
2914 if (sz1<sz) sz = sz1;
2918 Double_t nsq=dir[0]*dir[0]+dir[1]*dir[1];
2921 Double_t rdotn=point[0]*dir[0]+point[1]*dir[1];
2955 Warning(
"Divide",
"In shape %s division of a cut tube not implemented",
GetName());
2967 Error(
"GetMakeRuntimeShape",
"Invalid mother for shape %s",
GetName());
2976 rmin = ((
TGeoTube*)mother)->GetRmin();
2978 rmax = ((
TGeoTube*)mother)->GetRmax();
2989 printf(
"*** Shape %s: TGeoCtub ***\n",
GetName());
2990 printf(
" lx = %11.5f\n",
fNlow[0]);
2991 printf(
" ly = %11.5f\n",
fNlow[1]);
2992 printf(
" lz = %11.5f\n",
fNlow[2]);
2993 printf(
" tx = %11.5f\n",
fNhigh[0]);
2994 printf(
" ty = %11.5f\n",
fNhigh[1]);
2995 printf(
" tz = %11.5f\n",
fNhigh[2]);
3006 Double_t rsq = point[0]*point[0]+point[1]*point[1];
3023 for (
Int_t i=0; i<4; i++) saf[i]=-saf[i];
3051 out <<
" // Shape: " <<
GetName() <<
" type: " <<
ClassName() << std::endl;
3052 out <<
" rmin = " <<
fRmin <<
";" << std::endl;
3053 out <<
" rmax = " <<
fRmax <<
";" << std::endl;
3054 out <<
" dz = " <<
fDz <<
";" << std::endl;
3055 out <<
" phi1 = " <<
fPhi1 <<
";" << std::endl;
3056 out <<
" phi2 = " <<
fPhi2 <<
";" << std::endl;
3057 out <<
" lx = " <<
fNlow[0] <<
";" << std::endl;
3058 out <<
" ly = " <<
fNlow[1] <<
";" << std::endl;
3059 out <<
" lz = " <<
fNlow[2] <<
";" << std::endl;
3060 out <<
" tx = " <<
fNhigh[0] <<
";" << std::endl;
3061 out <<
" ty = " <<
fNhigh[1] <<
";" << std::endl;
3062 out <<
" tz = " <<
fNhigh[2] <<
";" << std::endl;
3063 out <<
" TGeoShape *" <<
GetPointerName() <<
" = new TGeoCtub(\"" <<
GetName() <<
"\",rmin,rmax,dz,phi1,phi2,lx,ly,lz,tx,ty,tz);" << std::endl;
TObject::SetBit(
TGeoShape::kGeoSavePrimitive);
3072 param[6], param[7], param[8], param[9], param[10]);
3096 if (phi2<phi1) phi2+=360.;
3099 dphi = (phi2-phi1)/(
n-1);
3105 for (j = 0; j <
n; j++) {
3115 for (j = 0; j <
n; j++) {
3138 if (phi2<phi1) phi2+=360.;
3141 dphi = (phi2-phi1)/(
n-1);
3147 for (j = 0; j <
n; j++) {
3157 for (j = 0; j <
n; j++) {
3205 for (
UInt_t i = 0; i < 3; i++ ) {
3214 Int_t nbSegs = 2*nbPnts;
3215 Int_t nbPols = nbPnts-2;
3216 if (buffer.
SetRawSizes(nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols)) {
R__EXTERN TGeoManager * gGeoManager
Cut tube segment description class - see TBuffer3DTypes for producer classes.
Double_t fLowPlaneNorm[3]
Double_t fHighPlaneNorm[3]
Tube segment description class - see TBuffer3DTypes for producer classes.
Complete tube description class - see TBuffer3DTypes for producer classes.
Generic 3D primitive description class.
Bool_t SectionsValid(UInt_t mask) const
void SetSectionsValid(UInt_t mask)
Bool_t SetRawSizes(UInt_t reqPnts, UInt_t reqPntsCapacity, UInt_t reqSegs, UInt_t reqSegsCapacity, UInt_t reqPols, UInt_t reqPolsCapacity)
Set kRaw tessellation section of buffer with supplied sizes.
virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0) const
Compute distance from outside point to surface of the box.
virtual void InspectShape() const
Prints shape parameters.
virtual void FillBuffer3D(TBuffer3D &buffer, Int_t reqSections, Bool_t localFrame) const
Fills the supplied buffer, with sections in desired frame See TBuffer3D.h for explanation of sections...
A tube segment cut with 2 planes.
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const
computes the closest distance from given point to this shape, according to option.
virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0) const
compute distance from inside point to surface of the cut tube
virtual Bool_t Contains(const Double_t *point) const
check if point is contained in the cut tube check the lower cut plane
virtual const TBuffer3D & GetBuffer3D(Int_t reqSections, Bool_t localFrame) const
Fills a static 3D buffer and returns a reference.
virtual void DistFromOutside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const
Compute distance from array of input points having directions specified by dirs. Store output in dist...
virtual void ComputeBBox()
compute minimum bounding box of the ctub
virtual ~TGeoCtub()
destructor
virtual void SetPoints(Double_t *points) const
Create mesh points for the cut tube.
virtual void ComputeNormal_v(const Double_t *points, const Double_t *dirs, Double_t *norms, Int_t vecsize)
Compute the normal for an array o points so that norm.dot.dir is positive Input: Arrays of point coor...
virtual TGeoShape * GetMakeRuntimeShape(TGeoShape *mother, TGeoMatrix *mat) const
in case shape has some negative parameters, these has to be computed in order to fit the mother
virtual void Safety_v(const Double_t *points, const Bool_t *inside, Double_t *safe, Int_t vecsize) const
Compute safe distance from each of the points in the input array.
virtual void SetDimensions(Double_t *param)
Set dimensions of the cut tube starting from a list.
virtual Double_t Capacity() const
Computes capacity of the shape in [length^3].
virtual Double_t GetAxisRange(Int_t iaxis, Double_t &xlo, Double_t &xhi) const
Get range of shape for a given axis.
virtual void InspectShape() const
print shape parameters
Double_t GetZcoord(Double_t xc, Double_t yc, Double_t zc) const
compute real Z coordinate of a point belonging to either lower or higher caps (z should be either +fD...
virtual void Contains_v(const Double_t *points, Bool_t *inside, Int_t vecsize) const
Check the inside status for each of the points in the array.
virtual void GetMeshNumbers(Int_t &nvert, Int_t &nsegs, Int_t &npols) const
Returns numbers of vertices, segments and polygons composing the shape mesh.
virtual Int_t GetNmeshVertices() const
Return number of vertices of the mesh representation.
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)
Compute normal to closest surface from POINT.
virtual void DistFromInside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const
Compute distance from array of input points having directions specified by dirs. Store output in dist...
virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0) const
compute distance from outside point to surface of the cut tube
virtual Bool_t GetPointsOnSegments(Int_t npoints, Double_t *array) const
Fills array with n random points located on the line segments of the shape mesh.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
void SetCtubDimensions(Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2, Double_t lx, Double_t ly, Double_t lz, Double_t tx, Double_t ty, Double_t tz)
set dimensions of a cut tube
virtual TGeoVolume * Divide(TGeoVolume *voldiv, const char *divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step)
Divide the tube along one axis.
TGeoVolumeMulti * MakeVolumeMulti(const char *name, TGeoMedium *medium)
Make a TGeoVolumeMulti handling a list of volumes.
Int_t GetNsegments() const
Get number of segments approximating circles.
Geometrical transformation package.
Node containing an offset.
Base finder class for patterns.
void SetDivIndex(Int_t index)
Base abstract class for all shapes.
virtual Double_t GetAxisRange(Int_t iaxis, Double_t &xlo, Double_t &xhi) const =0
Int_t GetBasicColor() const
Get the basic color (0-7).
void TransformPoints(Double_t *points, UInt_t NbPoints) const
Tranform a set of points (LocalToMaster)
void SetShapeBit(UInt_t f, Bool_t set)
Equivalent of TObject::SetBit.
static Double_t DistToPhiMin(const Double_t *point, const Double_t *dir, Double_t s1, Double_t c1, Double_t s2, Double_t c2, Double_t sm, Double_t cm, Bool_t in=kTRUE)
compute distance from point (inside phi) to both phi planes. Return minimum.
static Double_t SafetyPhi(const Double_t *point, Bool_t in, Double_t phi1, Double_t phi2)
Static method to compute safety w.r.t a phi corner defined by cosines/sines of the angles phi1,...
static Bool_t IsSameWithinTolerance(Double_t a, Double_t b)
Check if two numbers differ with less than a tolerance.
const char * GetPointerName() const
Provide a pointer name containing uid.
static Bool_t IsInPhiRange(const Double_t *point, Double_t phi1, Double_t phi2)
Static method to check if a point is in the phi range (phi1, phi2) [degrees].
Int_t ShapeDistancetoPrimitive(Int_t numpoints, Int_t px, Int_t py) const
Returns distance to shape primitive mesh.
virtual const char * GetName() const
Get the shape name.
static void NormalPhi(const Double_t *point, const Double_t *dir, Double_t *norm, Double_t c1, Double_t s1, Double_t c2, Double_t s2)
Static method to compute normal to phi planes.
static Double_t Tolerance()
static Bool_t IsCloseToPhi(Double_t epsil, const Double_t *point, Double_t c1, Double_t s1, Double_t c2, Double_t s2)
True if point is closer than epsil to one of the phi planes defined by c1,s1 or c2,...
Bool_t TestShapeBit(UInt_t f) const
virtual TGeoVolume * Divide(TGeoVolume *voldiv, const char *divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step)
Divide this tube segment shape belonging to volume "voldiv" into ndiv volumes called divname,...
virtual void Sizeof3D() const
fill size of this 3-D object
virtual void AfterStreamer()
Function called after streaming an object of this class.
virtual ~TGeoTubeSeg()
destructor
TGeoTubeSeg()
Default constructor.
virtual Bool_t Contains(const Double_t *point) const
test if point is inside this tube segment first check if point is inside the tube
virtual void ComputeNormal_v(const Double_t *points, const Double_t *dirs, Double_t *norms, Int_t vecsize)
Compute the normal for an array o points so that norm.dot.dir is positive Input: Arrays of point coor...
virtual void GetMeshNumbers(Int_t &nvert, Int_t &nsegs, Int_t &npols) const
Returns numbers of vertices, segments and polygons composing the shape mesh.
virtual const TBuffer3D & GetBuffer3D(Int_t reqSections, Bool_t localFrame) const
Fills a static 3D buffer and returns a reference.
virtual void DistFromInside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const
Compute distance from array of input points having directions specified by dirs. Store output in dist...
virtual void DistFromOutside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const
Compute distance from array of input points having directions specified by dirs. Store output in dist...
virtual Int_t GetNmeshVertices() const
Return number of vertices of the mesh representation.
virtual void ComputeBBox()
compute bounding box of the tube segment
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
static Double_t DistFromInsideS(const Double_t *point, const Double_t *dir, Double_t rmin, Double_t rmax, Double_t dz, Double_t c1, Double_t s1, Double_t c2, Double_t s2, Double_t cm, Double_t sm, Double_t cdfi)
Compute distance from inside point to surface of the tube segment (static) Boundary safe algorithm.
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)
Compute normal to closest surface from POINT.
virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0) const
compute distance from outside point to surface of the tube segment fist localize point w....
static Double_t DistFromOutsideS(const Double_t *point, const Double_t *dir, Double_t rmin, Double_t rmax, Double_t dz, Double_t c1, Double_t s1, Double_t c2, Double_t s2, Double_t cm, Double_t sm, Double_t cdfi)
Static method to compute distance to arbitrary tube segment from outside point Boundary safe algorith...
virtual Double_t Capacity() const
Computes capacity of the shape in [length^3].
virtual Double_t GetAxisRange(Int_t iaxis, Double_t &xlo, Double_t &xhi) const
Get range of shape for a given axis.
virtual void SetPoints(Double_t *points) const
Create tube segment mesh points.
static Double_t SafetyS(const Double_t *point, Bool_t in, Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2, Int_t skipz=0)
Static method to compute the closest distance from given point to this shape.
virtual Bool_t GetPointsOnSegments(Int_t npoints, Double_t *array) const
Fills array with n random points located on the line segments of the shape mesh.
void InitTrigonometry()
Init frequently used trigonometric values.
void SetTubsDimensions(Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2)
Set dimensions of the tube segment.
virtual TBuffer3D * MakeBuffer3D() const
Creates a TBuffer3D describing this shape.
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const
computes the closest distance from given point InitTrigonometry();to this shape, according to option.
virtual void Contains_v(const Double_t *points, Bool_t *inside, Int_t vecsize) const
Check the inside status for each of the points in the array.
virtual void Safety_v(const Double_t *points, const Bool_t *inside, Double_t *safe, Int_t vecsize) const
Compute safe distance from each of the points in the input array.
virtual void SetSegsAndPols(TBuffer3D &buff) const
Fill TBuffer3D structure for segments and polygons.
virtual void GetBoundingCylinder(Double_t *param) const
Fill vector param[4] with the bounding cylinder parameters.
virtual TGeoShape * GetMakeRuntimeShape(TGeoShape *mother, TGeoMatrix *mat) const
in case shape has some negative parameters, these has to be computed in order to fit the mother
virtual void InspectShape() const
print shape parameters
static void ComputeNormalS(const Double_t *point, const Double_t *dir, Double_t *norm, Double_t rmin, Double_t rmax, Double_t dz, Double_t c1, Double_t s1, Double_t c2, Double_t s2)
Compute normal to closest surface from POINT.
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
compute closest distance from point px,py to each corner
virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0) const
Compute distance from inside point to surface of the tube segment Boundary safe algorithm.
virtual void SetDimensions(Double_t *param)
Set dimensions of the tube segment starting from a list.
virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0) const
Compute distance from inside point to surface of the tube Boundary safe algorithm.
virtual void Contains_v(const Double_t *points, Bool_t *inside, Int_t vecsize) const
Check the inside status for each of the points in the array.
virtual void InspectShape() const
print shape parameters
virtual Double_t Capacity() const
Computes capacity of the shape in [length^3].
virtual const char * GetAxisName(Int_t iaxis) const
Returns name of axis IAXIS.
static void DistToTube(Double_t rsq, Double_t nsq, Double_t rdotn, Double_t radius, Double_t &b, Double_t &delta)
Static method computing the distance to a tube with given radius, starting from POINT along DIR direc...
void SetTubeDimensions(Double_t rmin, Double_t rmax, Double_t dz)
Set tube dimensions.
virtual void GetBoundingCylinder(Double_t *param) const
Fill vector param[4] with the bounding cylinder parameters.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
virtual void ComputeNormal_v(const Double_t *points, const Double_t *dirs, Double_t *norms, Int_t vecsize)
Compute the normal for an array o points so that norm.dot.dir is positive Input: Arrays of point coor...
virtual void SetSegsAndPols(TBuffer3D &buff) const
Fill TBuffer3D structure for segments and polygons.
virtual void SetDimensions(Double_t *param)
Set tube dimensions starting from a list.
virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0) const
Compute distance from outside point to surface of the tube and safe distance Boundary safe algorithm.
static Double_t DistFromOutsideS(const Double_t *point, const Double_t *dir, Double_t rmin, Double_t rmax, Double_t dz)
Static method to compute distance from outside point to a tube with given parameters Boundary safe al...
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const
computes the closest distance from given point to this shape, according to option.
virtual void ComputeBBox()
compute bounding box of the tube
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)
Compute normal to closest surface from POINT.
static Double_t SafetyS(const Double_t *point, Bool_t in, Double_t rmin, Double_t rmax, Double_t dz, Int_t skipz=0)
computes the closest distance from given point to this shape, according to option.
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
compute closest distance from point px,py to each corner
virtual Bool_t GetPointsOnSegments(Int_t npoints, Double_t *array) const
Fills array with n random points located on the line segments of the shape mesh.
virtual Int_t GetNmeshVertices() const
Return number of vertices of the mesh representation.
virtual Double_t GetAxisRange(Int_t iaxis, Double_t &xlo, Double_t &xhi) const
Get range of shape for a given axis.
virtual ~TGeoTube()
destructor
virtual void DistFromOutside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const
Compute distance from array of input points having directions specified by dirs. Store output in dist...
virtual const TBuffer3D & GetBuffer3D(Int_t reqSections, Bool_t localFrame) const
Fills a static 3D buffer and returns a reference.
virtual void Sizeof3D() const
fill size of this 3-D object
static void ComputeNormalS(const Double_t *point, const Double_t *dir, Double_t *norm, Double_t rmin, Double_t rmax, Double_t dz)
Compute normal to closest surface from POINT.
virtual void Safety_v(const Double_t *points, const Bool_t *inside, Double_t *safe, Int_t vecsize) const
Compute safe distance from each of the points in the input array.
virtual Bool_t Contains(const Double_t *point) const
test if point is inside this tube
virtual TGeoShape * GetMakeRuntimeShape(TGeoShape *mother, TGeoMatrix *mat) const
in case shape has some negative parameters, these has to be computed in order to fit the mother
virtual void SetPoints(Double_t *points) const
create tube mesh points
virtual void DistFromInside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const
Compute distance from array of input points having directions specified by dirs. Store output in dist...
virtual TGeoVolume * Divide(TGeoVolume *voldiv, const char *divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step)
Divide this tube shape belonging to volume "voldiv" into ndiv volumes called divname,...
virtual void GetMeshNumbers(Int_t &nvert, Int_t &nsegs, Int_t &npols) const
Returns numbers of vertices, segments and polygons composing the shape mesh.
virtual TBuffer3D * MakeBuffer3D() const
Creates a TBuffer3D describing this shape.
static Double_t DistFromInsideS(const Double_t *point, const Double_t *dir, Double_t rmin, Double_t rmax, Double_t dz)
Compute distance from inside point to surface of the tube (static) Boundary safe algorithm.
TGeoTube()
Default constructor.
void AddVolume(TGeoVolume *vol)
Add a volume with valid shape to the list of volumes.
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
void AddNodeOffset(TGeoVolume *vol, Int_t copy_no, Double_t offset=0, Option_t *option="")
Add a division node to the list of nodes.
TGeoMedium * GetMedium() const
void SetFinder(TGeoPatternFinder *finder)
Int_t GetNdaughters() const
TObject * At(Int_t idx) const
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
const char * Data() const
static constexpr double sr
static constexpr double s
static constexpr double cm
Long64_t LocMin(Long64_t n, const T *a)
Return index of array with the minimum element.
Short_t Max(Short_t a, Short_t b)
Long64_t LocMax(Long64_t n, const T *a)
Return index of array with the maximum element.
constexpr Double_t E()
Base of natural log:
Double_t ATan2(Double_t, Double_t)
constexpr Double_t DegToRad()
Conversion from degree to radian:
Double_t Sqrt(Double_t x)
Short_t Min(Short_t a, Short_t b)
constexpr Double_t RadToDeg()
Conversion from radian to degree:
constexpr Double_t TwoPi()