221 Double_t rsq = point[0]*point[0]+point[1]*point[1];
228 norm[0] = norm[1] = 0.;
236 if (norm[0]*dir[0]+norm[1]*dir[1]<0) {
252 if (norm[0]*dir[0]+norm[1]*dir[1]<0) {
264 Double_t r2 = point[0]*point[0]+point[1]*point[1];
276 if (!
HasRmin()) numPoints = 2*(
n+1);
291 if (sz<=0)
return 0.0;
294 Double_t nsq=dir[0]*dir[0]+dir[1]*dir[1];
296 Double_t rsq=point[0]*point[0]+point[1]*point[1];
297 Double_t rdotn=point[0]*dir[0]+point[1]*dir[1];
304 if (rdotn<0)
return 0.0;
317 if (rdotn>=0)
return 0.0;
333 if (iact<3 && safe) {
359 xi = point[0]+s*dir[0];
360 yi = point[1]+s*dir[1];
362 if ((rminsq<=r2) && (r2<=rmaxsq))
return s;
365 Double_t rsq = point[0]*point[0]+point[1]*point[1];
367 Double_t nsq=dir[0]*dir[0]+dir[1]*dir[1];
368 Double_t rdotn=point[0]*dir[0]+point[1]*dir[1];
374 in = inz & inrmin & inrmax;
381 if (point[2]*dir[2]<0)
return 0.0;
385 if ((rmaxsq-rsq) < (rsq-rminsq)) checkout =
kTRUE;
391 if (rdotn>=0)
return 0.0;
398 zi=point[2]+s*dir[2];
411 zi=point[2]+s*dir[2];
422 zi=point[2]+s*dir[2];
437 if (iact<3 && safe) {
497 for (
id=0;
id<ndiv;
id++) {
498 shape =
new TGeoTube(start+
id*step, start+(
id+1)*step,
fDz);
515 for (
id=0;
id<ndiv;
id++) {
521 finder =
new TGeoPatternZ(voldiv, ndiv, start, start+ndiv*step);
529 for (
id=0;
id<ndiv;
id++) {
535 Error(
"Divide",
"In shape %s wrong axis type for division",
GetName());
592 param[0] *= param[0];
594 param[1] *= param[1];
613 if (
xmax<0)
return 0;
618 if (
xmin<0)
return 0;
622 if (
xmax<=0)
return 0;
634 printf(
"*** Shape %s: TGeoTube ***\n",
GetName());
635 printf(
" Rmin = %11.5f\n",
fRmin);
636 printf(
" Rmax = %11.5f\n",
fRmax);
637 printf(
" dz = %11.5f\n",
fDz);
638 printf(
" Bounding box:\n");
658 nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols);
684 for (i = 0; i < 4; i++) {
685 for (j = 0; j <
n; j++) {
688 buffer.
fSegs[indx+1] = i*
n+j;
689 buffer.
fSegs[indx+2] = i*
n+(j+1)%
n;
695 for (i = 4; i < 6; i++) {
696 for (j = 0; j <
n; j++) {
698 buffer.
fSegs[indx ] =
c+1;
699 buffer.
fSegs[indx+1] = (i-4)*
n+j;
700 buffer.
fSegs[indx+2] = (i-2)*
n+j;
706 for (i = 6; i < 8; i++) {
707 for (j = 0; j <
n; j++) {
710 buffer.
fSegs[indx+1] = 2*(i-6)*
n+j;
711 buffer.
fSegs[indx+2] = (2*(i-6)+1)*
n+j;
717 for (j = 0; j <
n; j++) {
720 buffer.
fPols[indx+1] = 4;
721 buffer.
fPols[indx+2] = j;
722 buffer.
fPols[indx+3] = 4*
n+(j+1)%
n;
723 buffer.
fPols[indx+4] = 2*
n+j;
724 buffer.
fPols[indx+5] = 4*
n+j;
728 for (j = 0; j <
n; j++) {
730 buffer.
fPols[indx ] =
c+1;
731 buffer.
fPols[indx+1] = 4;
732 buffer.
fPols[indx+2] =
n+j;
733 buffer.
fPols[indx+3] = 5*
n+j;
734 buffer.
fPols[indx+4] = 3*
n+j;
735 buffer.
fPols[indx+5] = 5*
n+(j+1)%
n;
739 for (j = 0; j <
n; j++) {
742 buffer.
fPols[indx+1] = 4;
743 buffer.
fPols[indx+2] = j;
744 buffer.
fPols[indx+3] = 6*
n+j;
745 buffer.
fPols[indx+4] =
n+j;
746 buffer.
fPols[indx+5] = 6*
n+(j+1)%
n;
750 for (j = 0; j <
n; j++) {
753 buffer.
fPols[indx+1] = 4;
754 buffer.
fPols[indx+2] = 2*
n+j;
755 buffer.
fPols[indx+3] = 7*
n+(j+1)%
n;
756 buffer.
fPols[indx+4] = 3*
n+j;
757 buffer.
fPols[indx+5] = 7*
n+j;
765 for (i = 0; i < 2; i++) {
766 for (j = 0; j <
n; j++) {
769 buffer.
fSegs[indx+1] = 2+i*
n+j;
770 buffer.
fSegs[indx+2] = 2+i*
n+(j+1)%
n;
774 for (j = 0; j <
n; j++) {
776 buffer.
fSegs[indx ] =
c+1;
777 buffer.
fSegs[indx+1] = 2+j;
778 buffer.
fSegs[indx+2] = 2+
n+j;
783 for (i = 3; i < 5; i++) {
784 for (j = 0; j <
n; j++) {
787 buffer.
fSegs[indx+1] = i-3;
788 buffer.
fSegs[indx+2] = 2+(i-3)*
n+j;
793 for (j = 0; j <
n; j++) {
795 buffer.
fPols[indx ] =
c+1;
796 buffer.
fPols[indx+1] = 4;
797 buffer.
fPols[indx+2] = j;
798 buffer.
fPols[indx+3] = 2*
n+j;
799 buffer.
fPols[indx+4] =
n+j;
800 buffer.
fPols[indx+5] = 2*
n+(j+1)%
n;
803 for (j = 0; j <
n; j++) {
806 buffer.
fPols[indx+1] = 3;
807 buffer.
fPols[indx+2] = j;
808 buffer.
fPols[indx+3] = 3*
n+(j+1)%
n;
809 buffer.
fPols[indx+4] = 3*
n+j;
812 for (j = 0; j <
n; j++) {
813 indx = 6*
n + 5*
n + 5*j;
815 buffer.
fPols[indx+1] = 3;
816 buffer.
fPols[indx+2] =
n+j;
817 buffer.
fPols[indx+3] = 4*
n+j;
818 buffer.
fPols[indx+4] = 4*
n+(j+1)%
n;
835 if (safrmin < safe) safe = safrmin;
838 if (safrmax < safe) safe = safrmax;
843 if (safrmin > safe) safe = safrmin;
846 if (safrmax > safe) safe = safrmax;
851 Double_t rsq = point[0]*point[0]+point[1]*point[1];
857 for (
Int_t i=0; i<3; i++) saf[i]=-saf[i];
869 Double_t rsq = point[0]*point[0]+point[1]*point[1];
873 saf[0] = dz - point[2];
876 saf[0] = dz + point[2];
888 for (
Int_t i=0; i<3; i++) saf[i]=-saf[i];
899 out <<
" rmin = " <<
fRmin <<
";" << std::endl;
900 out <<
" rmax = " <<
fRmax <<
";" << std::endl;
901 out <<
" dz = " <<
fDz <<
";" << std::endl;
902 out <<
" TGeoShape *" <<
GetPointerName() <<
" = new TGeoTube(\"" <<
GetName() <<
"\",rmin,rmax,dz);" << std::endl;
915 Error(
"SetTubeDimensions",
"In shape %s wrong rmin=%g rmax=%g",
GetName(), rmin,rmax);
936 if (npoints > (npoints/2)*2) {
937 Error(
"GetPointsOnSegments",
"Npoints must be even number");
946 if (
HasRmin()) ntop = npoints/2 - nc*(nc-1);
947 else ntop = npoints - nc*(nc-1);
953 for (
Int_t i=0; i<nc; i++) {
954 if (i == (nc-1)) nphi = ntop;
957 for (
Int_t j=0; j<nphi; j++) {
989 for (j = 0; j <
n; j++) {
1001 for (j = 0; j <
n; j++) {
1021 for (j = 0; j <
n; j++) {
1052 for (j = 0; j <
n; j++) {
1064 for (j = 0; j <
n; j++) {
1084 for (j = 0; j <
n; j++) {
1105 if (!
HasRmin()) numPoints = 2*(
n+1);
1160 if (buffer.
SetRawSizes(nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols)) {
1229 fPhi1(0.), fPhi2(0.), fS1(0.), fC1(0.), fS2(0.), fC2(0.), fSm(0.), fCm(0.), fCdfi(0.)
1241 fPhi1(0.), fPhi2(0.), fS1(0.), fC1(0.), fS2(0.), fC2(0.), fSm(0.), fCm(0.), fCdfi(0.)
1351 if (ddp<0) ddp+= 360;
1352 if (ddp>360) ddp-=360;
1355 if (ddp<0) ddp+= 360;
1356 if (ddp>360) ddp-=360;
1359 if (ddp<0) ddp+= 360;
1360 if (ddp>360) ddp-=360;
1363 if (ddp<0) ddp+= 360;
1364 if (ddp>360) ddp-=360;
1380 Double_t rsq = point[0]*point[0]+point[1]*point[1];
1391 norm[0] = norm[1] = 0.;
1399 if (norm[0]*dir[0]+norm[1]*dir[1]<0) {
1413 Double_t rsq = point[0]*point[0]+point[1]*point[1];
1426 if (norm[0]*dir[0]+norm[1]*dir[1]<0) {
1448 const Int_t numPoints = 4*
n;
1461 if (stube<=0)
return 0.0;
1463 Double_t rsq = point[0]*point[0]+point[1]*point[1];
1465 Double_t cpsi=point[0]*cm+point[1]*sm;
1474 ddotn =
s1*dir[0]-
c1*dir[1];
1475 if (ddotn>=0)
return 0.0;
1476 ddotn = -s2*dir[0]+
c2*dir[1];
1477 if (ddotn<=0)
return stube;
1478 sfmin = s2*point[0]-
c2*point[1];
1479 if (sfmin<=0)
return stube;
1481 if (sfmin >= stube)
return stube;
1482 xi = point[0]+sfmin*dir[0];
1483 yi = point[1]+sfmin*dir[1];
1484 if (yi*cm-xi*sm<0)
return stube;
1487 ddotn = -s2*dir[0]+
c2*dir[1];
1488 if (ddotn>=0)
return 0.0;
1489 ddotn =
s1*dir[0]-
c1*dir[1];
1490 if (ddotn<=0)
return stube;
1491 sfmin = -
s1*point[0]+
c1*point[1];
1492 if (sfmin<=0)
return stube;
1494 if (sfmin >= stube)
return stube;
1495 xi = point[0]+sfmin*dir[0];
1496 yi = point[1]+sfmin*dir[1];
1497 if (yi*cm-xi*sm>0)
return stube;
1507 if (iact<3 && safe) {
1515 return TGeoTubeSeg::DistFromInsideS(point,dir,
fRmin,
fRmax,
fDz,
fC1,
fS1,
fC2,
fS2,
fCm,
fSm,
fCdfi);
1539 xi = point[0]+s*dir[0];
1540 yi = point[1]+s*dir[1];
1542 if ((rminsq<=r2) && (r2<=rmaxsq)) {
1544 if (cpsi>=cdfi)
return s;
1549 Double_t rsq = point[0]*point[0]+point[1]*point[1];
1551 Double_t nsq=dir[0]*dir[0]+dir[1]*dir[1];
1552 Double_t rdotn=point[0]*dir[0]+point[1]*dir[1];
1559 cpsi=point[0]*cm+point[1]*sm;
1561 in = inz & inrmin & inrmax & inphi;
1571 if (point[2]*dir[2]<0)
return 0.0;
1576 if ((rmaxsq-rsq) < (rsq-rminsq)) checkout =
kTRUE;
1578 if (checkout && (rmax-
r<safphi)) {
1588 if (point[0]*
c1 + point[1]*
s1 > point[0]*
c2 + point[1]*s2) {
1589 un = dir[0]*
s1-dir[1]*
c1;
1590 if (un < 0)
return 0.0;
1592 un = -dir[0]*s2+dir[1]*
c2;
1594 s = -point[0]*s2+point[1]*
c2;
1597 zi = point[2]+s*dir[2];
1599 xi = point[0]+s*dir[0];
1600 yi = point[1]+s*dir[1];
1602 if ((rminsq<=r2) && (r2<=rmaxsq)) {
1603 if ((yi*cm-xi*sm)>0)
return s;
1609 un = -dir[0]*s2+dir[1]*
c2;
1610 if (un < 0)
return 0.0;
1612 un = dir[0]*
s1-dir[1]*
c1;
1614 s = point[0]*
s1-point[1]*
c1;
1617 zi = point[2]+s*dir[2];
1619 xi = point[0]+s*dir[0];
1620 yi = point[1]+s*dir[1];
1622 if ((rminsq<=r2) && (r2<=rmaxsq)) {
1623 if ((yi*cm-xi*sm)<0)
return s;
1636 zi=point[2]+s*dir[2];
1638 xi=point[0]+s*dir[0];
1639 yi=point[1]+s*dir[1];
1640 if ((xi*cm+yi*sm) >= rmin*cdfi)
return s;
1647 if (rdotn>=0)
return 0.0;
1652 zi=point[2]+s*dir[2];
1655 xi=point[0]+s*dir[0];
1656 yi=point[1]+s*dir[1];
1658 if ((xi*cm+yi*sm) >= rmin*cdfi)
return s;
1662 s=point[0]*
s1-point[1]*
c1;
1665 zi=point[2]+s*dir[2];
1667 xi=point[0]+s*dir[0];
1668 yi=point[1]+s*dir[1];
1670 if ((rminsq<=r2) && (r2<=rmaxsq)) {
1671 if ((yi*cm-xi*sm)<=0) {
1678 un=dir[0]*s2-dir[1]*
c2;
1680 s=(point[1]*
c2-point[0]*s2)/un;
1681 if (s>=0 && s<snxt) {
1682 zi=point[2]+s*dir[2];
1684 xi=point[0]+s*dir[0];
1685 yi=point[1]+s*dir[1];
1687 if ((rminsq<=r2) && (r2<=rmaxsq)) {
1688 if ((yi*cm-xi*sm)>=0) {
1703 if (rsq>=rmax*rmax) {
1709 zi=point[2]+s*dir[2];
1711 xi=point[0]+s*dir[0];
1712 yi=point[1]+s*dir[1];
1714 if (cpsi>=rmax*cdfi)
return s;
1725 zi=point[2]+s*dir[2];
1727 xi=point[0]+s*dir[0];
1728 yi=point[1]+s*dir[1];
1730 if (cpsi>=rmin*cdfi) snxt=s;
1738 s=point[0]*
s1-point[1]*
c1;
1741 zi=point[2]+s*dir[2];
1743 xi=point[0]+s*dir[0];
1744 yi=point[1]+s*dir[1];
1746 if ((rminsq<=r2) && (r2<=rmaxsq)) {
1747 if ((yi*cm-xi*sm)<=0) {
1754 un=dir[0]*s2-dir[1]*
c2;
1756 s=point[1]*
c2-point[0]*s2;
1759 zi=point[2]+s*dir[2];
1761 xi=point[0]+s*dir[0];
1762 yi=point[1]+s*dir[1];
1764 if ((rminsq<=r2) && (r2<=rmaxsq)) {
1765 if ((yi*cm-xi*sm)>=0) {
1781 if (iact<3 && safe) {
1792 return TGeoTubeSeg::DistFromOutsideS(point, dir,
fRmin,
fRmax,
fDz,
fC1,
fS1,
fC2,
fS2,
fCm,
fSm,
fCdfi);
1820 for (
id=0;
id<ndiv;
id++) {
1831 if (dphi<0) dphi+=360.;
1832 if (step<=0) {step=dphi/ndiv; start=
fPhi1; end=
fPhi2;}
1841 for (
id=0;
id<ndiv;
id++) {
1855 for (
id=0;
id<ndiv;
id++) {
1861 Error(
"Divide",
"In shape %s wrong axis type for division",
GetName());
1901 param[0] *= param[0];
1903 param[1] *= param[1];
1916 Error(
"GetMakeRuntimeShape",
"Invalid mother for shape %s",
GetName());
1925 rmin = ((
TGeoTube*)mother)->GetRmin();
1927 rmax = ((
TGeoTube*)mother)->GetRmax();
1937 printf(
"*** Shape %s: TGeoTubeSeg ***\n",
GetName());
1938 printf(
" Rmin = %11.5f\n",
fRmin);
1939 printf(
" Rmax = %11.5f\n",
fRmax);
1940 printf(
" dz = %11.5f\n",
fDz);
1941 printf(
" phi1 = %11.5f\n",
fPhi1);
1942 printf(
" phi2 = %11.5f\n",
fPhi2);
1943 printf(
" Bounding box:\n");
1955 Int_t nbSegs = 2*nbPnts;
1956 Int_t nbPols = nbPnts-2;
1959 nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols);
1979 for (i = 0; i < 4; i++) {
1980 for (j = 1; j <
n; j++) {
1982 buff.
fSegs[(i*
n+j-1)*3+1] = i*
n+j-1;
1983 buff.
fSegs[(i*
n+j-1)*3+2] = i*
n+j;
1986 for (i = 4; i < 6; i++) {
1987 for (j = 0; j <
n; j++) {
1989 buff.
fSegs[(i*
n+j)*3+1] = (i-4)*
n+j;
1990 buff.
fSegs[(i*
n+j)*3+2] = (i-2)*
n+j;
1993 for (i = 6; i < 8; i++) {
1994 for (j = 0; j <
n; j++) {
1996 buff.
fSegs[(i*
n+j)*3+1] = 2*(i-6)*
n+j;
1997 buff.
fSegs[(i*
n+j)*3+2] = (2*(i-6)+1)*
n+j;
2004 for (j = 0; j <
n-1; j++) {
2006 buff.
fPols[indx++] = 4;
2007 buff.
fPols[indx++] = (4+i)*
n+j+1;
2008 buff.
fPols[indx++] = (2+i)*
n+j;
2009 buff.
fPols[indx++] = (4+i)*
n+j;
2010 buff.
fPols[indx++] = i*
n+j;
2013 for (j = 0; j <
n-1; j++) {
2015 buff.
fPols[indx++] = 4;
2016 buff.
fPols[indx++] = i*
n+j;
2017 buff.
fPols[indx++] = (4+i)*
n+j;
2018 buff.
fPols[indx++] = (2+i)*
n+j;
2019 buff.
fPols[indx++] = (4+i)*
n+j+1;
2022 for (j = 0; j <
n-1; j++) {
2023 buff.
fPols[indx++] =
c+i;
2024 buff.
fPols[indx++] = 4;
2025 buff.
fPols[indx++] = (i-2)*2*
n+j;
2026 buff.
fPols[indx++] = (4+i)*
n+j;
2027 buff.
fPols[indx++] = ((i-2)*2+1)*
n+j;
2028 buff.
fPols[indx++] = (4+i)*
n+j+1;
2031 for (j = 0; j <
n-1; j++) {
2032 buff.
fPols[indx++] =
c+i;
2033 buff.
fPols[indx++] = 4;
2034 buff.
fPols[indx++] = (4+i)*
n+j+1;
2035 buff.
fPols[indx++] = ((i-2)*2+1)*
n+j;
2036 buff.
fPols[indx++] = (4+i)*
n+j;
2037 buff.
fPols[indx++] = (i-2)*2*
n+j;
2039 buff.
fPols[indx++] =
c+2;
2040 buff.
fPols[indx++] = 4;
2041 buff.
fPols[indx++] = 6*
n;
2042 buff.
fPols[indx++] = 4*
n;
2043 buff.
fPols[indx++] = 7*
n;
2044 buff.
fPols[indx++] = 5*
n;
2045 buff.
fPols[indx++] =
c+2;
2046 buff.
fPols[indx++] = 4;
2047 buff.
fPols[indx++] = 6*
n-1;
2048 buff.
fPols[indx++] = 8*
n-1;
2049 buff.
fPols[indx++] = 5*
n-1;
2050 buff.
fPols[indx++] = 7*
n-1;
2061 Double_t rsq = point[0]*point[0]+point[1]*point[1];
2088 saf[1] =
fRmin-rproj;
2089 saf[2] = rproj-
fRmax;
2095 return (saf[0]<0) ? safe :
TMath::Sqrt(safe*safe+saf[0]*saf[0]);
2098 return (saf[0]<0) ? safphi :
TMath::Sqrt(saf[0]*saf[0]+safphi*safphi);
2109 Double_t rsq = point[0]*point[0]+point[1]*point[1];
2114 saf[0] = dz - point[2];
2117 saf[0] = dz + point[2];
2130 if ((phi2d-phi1d)>=360.)
return safe;
2143 Double_t cpsi=point[0]*cm+point[1]*sm;
2163 saf[1] = rmin-rproj;
2164 saf[2] = rproj-rmax;
2166 if ((phi2d-phi1d)>=360.)
return TMath::Max(safe,saf[0]);
2170 return (saf[0]<0) ? safe :
TMath::Sqrt(safe*safe+saf[0]*saf[0]);
2173 return (saf[0]<0) ? safphi :
TMath::Sqrt(saf[0]*saf[0]+safphi*safphi);
2182 out <<
" // Shape: " <<
GetName() <<
" type: " <<
ClassName() << std::endl;
2183 out <<
" rmin = " <<
fRmin <<
";" << std::endl;
2184 out <<
" rmax = " <<
fRmax <<
";" << std::endl;
2185 out <<
" dz = " <<
fDz <<
";" << std::endl;
2186 out <<
" phi1 = " <<
fPhi1 <<
";" << std::endl;
2187 out <<
" phi2 = " <<
fPhi2 <<
";" << std::endl;
2188 out <<
" TGeoShape *" <<
GetPointerName() <<
" = new TGeoTubeSeg(\"" <<
GetName() <<
"\",rmin,rmax,dz,phi1,phi2);" << std::endl;
2230 if (npoints > (npoints/2)*2) {
2231 Error(
"GetPointsOnSegments",
"Npoints must be even number");
2238 Int_t ntop = npoints/2 - nc*(nc-1);
2244 for (
Int_t i=0; i<nc; i++) {
2251 for (
Int_t j=0; j<nphi; j++) {
2252 phi = phi1 + j*dphi;
2274 if (phi2<phi1) phi2+=360.;
2277 dphi = (phi2-phi1)/(
n-1);
2283 for (j = 0; j <
n; j++) {
2293 for (j = 0; j <
n; j++) {
2316 if (phi2<phi1) phi2+=360.;
2319 dphi = (phi2-phi1)/(
n-1);
2325 for (j = 0; j <
n; j++) {
2335 for (j = 0; j <
n; j++) {
2396 Int_t nbSegs = 2*nbPnts;
2397 Int_t nbPols = nbPnts-2;
2398 if (buffer.
SetRawSizes(nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols)) {
2510 SetCtubDimensions(params[0], params[1], params[2], params[3], params[4], params[5],
2511 params[6], params[7], params[8], params[9], params[10]);
2538 Error(
"ComputeBBox",
"In shape %s wrong definition of cut planes",
GetName());
2552 for (i=0; i<2; i++) {
2553 if (phi_low<0) phi_low+=360.;
2555 if (dphi < 0) dphi+=360.;
2557 if (ddp<0) ddp += 360.;
2569 in_range_low =
kTRUE;
2572 if (phi_low>360) phi_low-=360.;
2575 for (i=0; i<2; i++) {
2576 if (phi_hi<0) phi_hi+=360.;
2578 if (dphi < 0) dphi+=360.;
2580 if (ddp<0) ddp += 360.;
2592 in_range_hi =
kTRUE;
2595 if (phi_hi>360) phi_hi-=360.;
2631 fDZ = 0.5*(zmax-zmin);
2643 Double_t rsq = point[0]*point[0]+point[1]*point[1];
2659 if (norm[0]*dir[0]+norm[1]*dir[1]+norm[2]*dir[2]<0) {
2668 if (norm[0]*dir[0]+norm[1]*dir[1]+norm[2]*dir[2]<0) {
2680 if (norm[0]*dir[0]+norm[1]*dir[1]<0) {
2693 if (zin>0)
return kFALSE;
2696 if (zin>0)
return kFALSE;
2698 Double_t r2 = point[0]*point[0]+point[1]*point[1];
2702 if (phi < 0 ) phi+=360.;
2705 if (ddp<0) ddp += 360.;
2707 if (ddp > dphi)
return kFALSE;
2751 if (iact<3 && safe) {
2762 Double_t rsq = point[0]*point[0]+point[1]*point[1];
2777 xi = point[0]+s*dir[0];
2778 yi = point[1]+s*dir[1];
2783 if (cpsi>=
fCdfi)
return s;
2791 xi = point[0]+s*dir[0];
2792 yi = point[1]+s*dir[1];
2797 if (cpsi>=
fCdfi)
return s;
2803 Double_t nsq=dir[0]*dir[0]+dir[1]*dir[1];
2805 Double_t rdotn=point[0]*dir[0]+point[1]*dir[1];
2808 if (
r>
fRmax && rdotn<0) {
2813 xi=point[0]+s*dir[0];
2814 yi=point[1]+s*dir[1];
2815 zi=point[2]+s*dir[2];
2820 if (cpsi>=
fCdfi)
return s;
2833 xi=point[0]+s*dir[0];
2834 yi=point[1]+s*dir[1];
2835 zi=point[2]+s*dir[2];
2840 if (cpsi>=
fCdfi) snxt=s;
2847 if (tub)
return snxt;
2850 s=(point[1]*
fC1-point[0]*
fS1)/un;
2852 xi=point[0]+s*dir[0];
2853 yi=point[1]+s*dir[1];
2854 zi=point[2]+s*dir[2];
2859 if ((yi*
fCm-xi*
fSm)<=0) {
2867 un=dir[0]*
fS2-dir[1]*
fC2;
2869 s=(point[1]*
fC2-point[0]*
fS2)/un;
2871 xi=point[0]+s*dir[0];
2872 yi=point[1]+s*dir[1];
2873 zi=point[2]+s*dir[2];
2878 if ((yi*
fCm-xi*
fSm)>=0) {
2897 Double_t rsq = point[0]*point[0]+point[1]*point[1];
2907 if (calf>0) sz = saf[0]/calf;
2913 if (sz1<sz) sz = sz1;
2917 Double_t nsq=dir[0]*dir[0]+dir[1]*dir[1];
2920 Double_t rdotn=point[0]*dir[0]+point[1]*dir[1];
2929 if (sr>0) skip_outer =
kTRUE;
2954 Warning(
"Divide",
"In shape %s division of a cut tube not implemented",
GetName());
2966 Error(
"GetMakeRuntimeShape",
"Invalid mother for shape %s",
GetName());
2975 rmin = ((
TGeoTube*)mother)->GetRmin();
2977 rmax = ((
TGeoTube*)mother)->GetRmax();
2988 printf(
"*** Shape %s: TGeoCtub ***\n",
GetName());
2989 printf(
" lx = %11.5f\n",
fNlow[0]);
2990 printf(
" ly = %11.5f\n",
fNlow[1]);
2991 printf(
" lz = %11.5f\n",
fNlow[2]);
2992 printf(
" tx = %11.5f\n",
fNhigh[0]);
2993 printf(
" ty = %11.5f\n",
fNhigh[1]);
2994 printf(
" tz = %11.5f\n",
fNhigh[2]);
3005 Double_t rsq = point[0]*point[0]+point[1]*point[1];
3022 for (
Int_t i=0; i<4; i++) saf[i]=-saf[i];
3050 out <<
" // Shape: " <<
GetName() <<
" type: " <<
ClassName() << std::endl;
3051 out <<
" rmin = " <<
fRmin <<
";" << std::endl;
3052 out <<
" rmax = " <<
fRmax <<
";" << std::endl;
3053 out <<
" dz = " <<
fDz <<
";" << std::endl;
3054 out <<
" phi1 = " <<
fPhi1 <<
";" << std::endl;
3055 out <<
" phi2 = " <<
fPhi2 <<
";" << std::endl;
3056 out <<
" lx = " <<
fNlow[0] <<
";" << std::endl;
3057 out <<
" ly = " <<
fNlow[1] <<
";" << std::endl;
3058 out <<
" lz = " <<
fNlow[2] <<
";" << std::endl;
3059 out <<
" tx = " <<
fNhigh[0] <<
";" << std::endl;
3060 out <<
" ty = " <<
fNhigh[1] <<
";" << std::endl;
3061 out <<
" tz = " <<
fNhigh[2] <<
";" << std::endl;
3062 out <<
" TGeoShape *" <<
GetPointerName() <<
" = new TGeoCtub(\"" <<
GetName() <<
"\",rmin,rmax,dz,phi1,phi2,lx,ly,lz,tx,ty,tz);" << std::endl;
TObject::SetBit(
TGeoShape::kGeoSavePrimitive);
3071 param[6], param[7], param[8], param[9], param[10]);
3095 if (phi2<phi1) phi2+=360.;
3098 dphi = (phi2-phi1)/(
n-1);
3104 for (j = 0; j <
n; j++) {
3114 for (j = 0; j <
n; j++) {
3137 if (phi2<phi1) phi2+=360.;
3140 dphi = (phi2-phi1)/(
n-1);
3146 for (j = 0; j <
n; j++) {
3156 for (j = 0; j <
n; j++) {
3204 for (
UInt_t i = 0; i < 3; i++ ) {
3213 Int_t nbSegs = 2*nbPnts;
3214 Int_t nbPols = nbPnts-2;
3215 if (buffer.
SetRawSizes(nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols)) {
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
void Fatal(const char *location, const char *msgfmt,...)
Use this function in case of a fatal error. It will abort the program.
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.
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.
const char * Data() const
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)
Double_t ATan2(Double_t y, Double_t x)
Long64_t LocMax(Long64_t n, const T *a)
Return index of array with the maximum element.
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()