243 Double_t rsq = point[0]*point[0]+point[1]*point[1];
250 norm[0] = norm[1] = 0.;
258 if (norm[0]*dir[0]+norm[1]*dir[1]<0) {
274 if (norm[0]*dir[0]+norm[1]*dir[1]<0) {
286 Double_t r2 = point[0]*point[0]+point[1]*point[1];
298 if (!
HasRmin()) numPoints = 2*(
n+1);
313 if (sz<=0)
return 0.0;
316 Double_t nsq=dir[0]*dir[0]+dir[1]*dir[1];
318 Double_t rsq=point[0]*point[0]+point[1]*point[1];
319 Double_t rdotn=point[0]*dir[0]+point[1]*dir[1];
325 if (rdotn<0)
return 0.0;
338 if (rdotn>=0)
return 0.0;
354 if (iact<3 && safe) {
379 xi = point[0]+s*dir[0];
380 yi = point[1]+s*dir[1];
382 if ((rminsq<=r2) && (r2<=rmaxsq))
return s;
385 Double_t rsq = point[0]*point[0]+point[1]*point[1];
387 Double_t nsq=dir[0]*dir[0]+dir[1]*dir[1];
388 Double_t rdotn=point[0]*dir[0]+point[1]*dir[1];
394 in = inz & inrmin & inrmax;
401 if (point[2]*dir[2]<0)
return 0.0;
405 if ((rmaxsq-rsq) < (rsq-rminsq)) checkout =
kTRUE;
411 if (rdotn>=0)
return 0.0;
418 zi=point[2]+s*dir[2];
431 zi=point[2]+s*dir[2];
442 zi=point[2]+s*dir[2];
457 if (iact<3 && safe) {
517 for (
id=0;
id<ndiv;
id++) {
518 shape =
new TGeoTube(start+
id*step, start+(
id+1)*step,
fDz);
535 for (
id=0;
id<ndiv;
id++) {
541 finder =
new TGeoPatternZ(voldiv, ndiv, start, start+ndiv*step);
549 for (
id=0;
id<ndiv;
id++) {
555 Error(
"Divide",
"In shape %s wrong axis type for division",
GetName());
612 param[0] *= param[0];
614 param[1] *= param[1];
633 if (
xmax<0)
return 0;
638 if (
xmin<0)
return 0;
642 if (
xmax<=0)
return 0;
654 printf(
"*** Shape %s: TGeoTube ***\n",
GetName());
655 printf(
" Rmin = %11.5f\n",
fRmin);
656 printf(
" Rmax = %11.5f\n",
fRmax);
657 printf(
" dz = %11.5f\n",
fDz);
658 printf(
" Bounding box:\n");
678 nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols);
704 for (i = 0; i < 4; i++) {
705 for (j = 0; j <
n; j++) {
708 buffer.
fSegs[indx+1] = i*
n+j;
709 buffer.
fSegs[indx+2] = i*
n+(j+1)%
n;
715 for (i = 4; i < 6; i++) {
716 for (j = 0; j <
n; j++) {
718 buffer.
fSegs[indx ] =
c+1;
719 buffer.
fSegs[indx+1] = (i-4)*
n+j;
720 buffer.
fSegs[indx+2] = (i-2)*
n+j;
726 for (i = 6; i < 8; i++) {
727 for (j = 0; j <
n; j++) {
730 buffer.
fSegs[indx+1] = 2*(i-6)*
n+j;
731 buffer.
fSegs[indx+2] = (2*(i-6)+1)*
n+j;
737 for (j = 0; j <
n; j++) {
740 buffer.
fPols[indx+1] = 4;
741 buffer.
fPols[indx+2] = j;
742 buffer.
fPols[indx+3] = 4*
n+(j+1)%
n;
743 buffer.
fPols[indx+4] = 2*
n+j;
744 buffer.
fPols[indx+5] = 4*
n+j;
748 for (j = 0; j <
n; j++) {
750 buffer.
fPols[indx ] =
c+1;
751 buffer.
fPols[indx+1] = 4;
752 buffer.
fPols[indx+2] =
n+j;
753 buffer.
fPols[indx+3] = 5*
n+j;
754 buffer.
fPols[indx+4] = 3*
n+j;
755 buffer.
fPols[indx+5] = 5*
n+(j+1)%
n;
759 for (j = 0; j <
n; j++) {
762 buffer.
fPols[indx+1] = 4;
763 buffer.
fPols[indx+2] = j;
764 buffer.
fPols[indx+3] = 6*
n+j;
765 buffer.
fPols[indx+4] =
n+j;
766 buffer.
fPols[indx+5] = 6*
n+(j+1)%
n;
770 for (j = 0; j <
n; j++) {
773 buffer.
fPols[indx+1] = 4;
774 buffer.
fPols[indx+2] = 2*
n+j;
775 buffer.
fPols[indx+3] = 7*
n+(j+1)%
n;
776 buffer.
fPols[indx+4] = 3*
n+j;
777 buffer.
fPols[indx+5] = 7*
n+j;
785 for (i = 0; i < 2; i++) {
786 for (j = 0; j <
n; j++) {
789 buffer.
fSegs[indx+1] = 2+i*
n+j;
790 buffer.
fSegs[indx+2] = 2+i*
n+(j+1)%
n;
794 for (j = 0; j <
n; j++) {
796 buffer.
fSegs[indx ] =
c+1;
797 buffer.
fSegs[indx+1] = 2+j;
798 buffer.
fSegs[indx+2] = 2+
n+j;
803 for (i = 3; i < 5; i++) {
804 for (j = 0; j <
n; j++) {
807 buffer.
fSegs[indx+1] = i-3;
808 buffer.
fSegs[indx+2] = 2+(i-3)*
n+j;
813 for (j = 0; j <
n; j++) {
815 buffer.
fPols[indx ] =
c+1;
816 buffer.
fPols[indx+1] = 4;
817 buffer.
fPols[indx+2] = j;
818 buffer.
fPols[indx+3] = 2*
n+j;
819 buffer.
fPols[indx+4] =
n+j;
820 buffer.
fPols[indx+5] = 2*
n+(j+1)%
n;
823 for (j = 0; j <
n; j++) {
826 buffer.
fPols[indx+1] = 3;
827 buffer.
fPols[indx+2] = j;
828 buffer.
fPols[indx+3] = 3*
n+(j+1)%
n;
829 buffer.
fPols[indx+4] = 3*
n+j;
832 for (j = 0; j <
n; j++) {
833 indx = 6*
n + 5*
n + 5*j;
835 buffer.
fPols[indx+1] = 3;
836 buffer.
fPols[indx+2] =
n+j;
837 buffer.
fPols[indx+3] = 4*
n+j;
838 buffer.
fPols[indx+4] = 4*
n+(j+1)%
n;
855 if (safrmin < safe) safe = safrmin;
858 if (safrmax < safe) safe = safrmax;
863 if (safrmin > safe) safe = safrmin;
866 if (safrmax > safe) safe = safrmax;
871 Double_t rsq = point[0]*point[0]+point[1]*point[1];
877 for (
Int_t i=0; i<3; i++) saf[i]=-saf[i];
889 Double_t rsq = point[0]*point[0]+point[1]*point[1];
893 saf[0] = dz - point[2];
896 saf[0] = dz + point[2];
908 for (
Int_t i=0; i<3; i++) saf[i]=-saf[i];
919 out <<
" rmin = " <<
fRmin <<
";" << std::endl;
920 out <<
" rmax = " <<
fRmax <<
";" << std::endl;
921 out <<
" dz = " <<
fDz <<
";" << std::endl;
922 out <<
" TGeoShape *" <<
GetPointerName() <<
" = new TGeoTube(\"" <<
GetName() <<
"\",rmin,rmax,dz);" << std::endl;
935 Error(
"SetTubeDimensions",
"In shape %s wrong rmin=%g rmax=%g",
GetName(), rmin,rmax);
956 if (npoints > (npoints/2)*2) {
957 Error(
"GetPointsOnSegments",
"Npoints must be even number");
966 if (
HasRmin()) ntop = npoints/2 - nc*(nc-1);
967 else ntop = npoints - nc*(nc-1);
973 for (
Int_t i=0; i<nc; i++) {
974 if (i == (nc-1)) nphi = ntop;
977 for (
Int_t j=0; j<nphi; j++) {
1009 for (j = 0; j <
n; j++) {
1021 for (j = 0; j <
n; j++) {
1041 for (j = 0; j <
n; j++) {
1072 for (j = 0; j <
n; j++) {
1084 for (j = 0; j <
n; j++) {
1104 for (j = 0; j <
n; j++) {
1125 if (!
HasRmin()) numPoints = 2*(
n+1);
1180 if (buffer.
SetRawSizes(nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols)) {
1249 fPhi1(0.), fPhi2(0.), fS1(0.), fC1(0.), fS2(0.), fC2(0.), fSm(0.), fCm(0.), fCdfi(0.)
1261 fPhi1(0.), fPhi2(0.), fS1(0.), fC1(0.), fS2(0.), fC2(0.), fSm(0.), fCm(0.), fCdfi(0.)
1371 if (ddp<0) ddp+= 360;
1372 if (ddp>360) ddp-=360;
1375 if (ddp<0) ddp+= 360;
1376 if (ddp>360) ddp-=360;
1379 if (ddp<0) ddp+= 360;
1380 if (ddp>360) ddp-=360;
1383 if (ddp<0) ddp+= 360;
1384 if (ddp>360) ddp-=360;
1400 Double_t rsq = point[0]*point[0]+point[1]*point[1];
1411 norm[0] = norm[1] = 0.;
1419 if (norm[0]*dir[0]+norm[1]*dir[1]<0) {
1433 Double_t rsq = point[0]*point[0]+point[1]*point[1];
1446 if (norm[0]*dir[0]+norm[1]*dir[1]<0) {
1468 const Int_t numPoints = 4*
n;
1481 if (stube<=0)
return 0.0;
1482 Double_t rsq = point[0]*point[0]+point[1]*point[1];
1484 Double_t cpsi=point[0]*cm+point[1]*sm;
1493 ddotn =
s1*dir[0]-
c1*dir[1];
1494 if (ddotn>=0)
return 0.0;
1495 ddotn = -s2*dir[0]+
c2*dir[1];
1496 if (ddotn<=0)
return stube;
1498 if (sfmin<=0)
return stube;
1500 if (sfmin >= stube)
return stube;
1501 xi = point[0]+sfmin*dir[0];
1502 yi = point[1]+sfmin*dir[1];
1503 if (yi*cm-xi*sm<0)
return stube;
1506 ddotn = -s2*dir[0]+
c2*dir[1];
1507 if (ddotn>=0)
return 0.0;
1508 ddotn =
s1*dir[0]-
c1*dir[1];
1509 if (ddotn<=0)
return stube;
1511 if (sfmin<=0)
return stube;
1513 if (sfmin >= stube)
return stube;
1514 xi = point[0]+sfmin*dir[0];
1515 yi = point[1]+sfmin*dir[1];
1516 if (yi*cm-xi*sm>0)
return stube;
1526 if (iact<3 && safe) {
1534 return TGeoTubeSeg::DistFromInsideS(point,dir,
fRmin,
fRmax,
fDz,
fC1,
fS1,
fC2,
fS2,
fCm,
fSm,
fCdfi);
1557 xi = point[0]+s*dir[0];
1558 yi = point[1]+s*dir[1];
1560 if ((rminsq<=r2) && (r2<=rmaxsq)) {
1562 if (cpsi>=cdfi)
return s;
1567 Double_t rsq = point[0]*point[0]+point[1]*point[1];
1569 Double_t nsq=dir[0]*dir[0]+dir[1]*dir[1];
1570 Double_t rdotn=point[0]*dir[0]+point[1]*dir[1];
1577 cpsi=point[0]*cm+point[1]*sm;
1579 in = inz & inrmin & inrmax & inphi;
1589 if (point[2]*dir[2]<0)
return 0.0;
1594 if ((rmaxsq-rsq) < (rsq-rminsq)) checkout =
kTRUE;
1596 if (checkout && (rmax-
r<safphi)) {
1606 if (point[0]*
c1 + point[1]*
s1 > point[0]*
c2 + point[1]*s2) {
1607 un = dir[0]*
s1-dir[1]*
c1;
1608 if (un < 0)
return 0.0;
1610 un = -dir[0]*s2+dir[1]*
c2;
1612 s = -point[0]*s2+point[1]*
c2;
1615 zi = point[2]+s*dir[2];
1617 xi = point[0]+s*dir[0];
1618 yi = point[1]+s*dir[1];
1620 if ((rminsq<=r2) && (r2<=rmaxsq)) {
1621 if ((yi*cm-xi*sm)>0)
return s;
1627 un = -dir[0]*s2+dir[1]*
c2;
1628 if (un < 0)
return 0.0;
1630 un = dir[0]*
s1-dir[1]*
c1;
1632 s = point[0]*
s1-point[1]*
c1;
1635 zi = point[2]+s*dir[2];
1637 xi = point[0]+s*dir[0];
1638 yi = point[1]+s*dir[1];
1640 if ((rminsq<=r2) && (r2<=rmaxsq)) {
1641 if ((yi*cm-xi*sm)<0)
return s;
1654 zi=point[2]+s*dir[2];
1656 xi=point[0]+s*dir[0];
1657 yi=point[1]+s*dir[1];
1658 if ((xi*cm+yi*sm) >= rmin*cdfi)
return s;
1665 if (rdotn>=0)
return 0.0;
1670 zi=point[2]+s*dir[2];
1673 xi=point[0]+s*dir[0];
1674 yi=point[1]+s*dir[1];
1675 if ((xi*cm+yi*sm) >= rmin*cdfi)
return s;
1679 s=point[0]*
s1-point[1]*
c1;
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) {
1695 un=dir[0]*s2-dir[1]*
c2;
1697 s=(point[1]*
c2-point[0]*s2)/un;
1698 if (s>=0 && s<snxt) {
1699 zi=point[2]+s*dir[2];
1701 xi=point[0]+s*dir[0];
1702 yi=point[1]+s*dir[1];
1704 if ((rminsq<=r2) && (r2<=rmaxsq)) {
1705 if ((yi*cm-xi*sm)>=0) {
1720 if (rsq>=rmax*rmax) {
1726 zi=point[2]+s*dir[2];
1728 xi=point[0]+s*dir[0];
1729 yi=point[1]+s*dir[1];
1731 if (cpsi>=rmax*cdfi)
return s;
1742 zi=point[2]+s*dir[2];
1744 xi=point[0]+s*dir[0];
1745 yi=point[1]+s*dir[1];
1747 if (cpsi>=rmin*cdfi) snxt=s;
1755 s=point[0]*
s1-point[1]*
c1;
1758 zi=point[2]+s*dir[2];
1760 xi=point[0]+s*dir[0];
1761 yi=point[1]+s*dir[1];
1763 if ((rminsq<=r2) && (r2<=rmaxsq)) {
1764 if ((yi*cm-xi*sm)<=0) {
1771 un=dir[0]*s2-dir[1]*
c2;
1773 s=point[1]*
c2-point[0]*s2;
1776 zi=point[2]+s*dir[2];
1778 xi=point[0]+s*dir[0];
1779 yi=point[1]+s*dir[1];
1781 if ((rminsq<=r2) && (r2<=rmaxsq)) {
1782 if ((yi*cm-xi*sm)>=0) {
1798 if (iact<3 && safe) {
1809 return TGeoTubeSeg::DistFromOutsideS(point, dir,
fRmin,
fRmax,
fDz,
fC1,
fS1,
fC2,
fS2,
fCm,
fSm,
fCdfi);
1837 for (
id=0;
id<ndiv;
id++) {
1848 if (dphi<0) dphi+=360.;
1849 if (step<=0) {step=dphi/ndiv; start=
fPhi1; end=
fPhi2;}
1858 for (
id=0;
id<ndiv;
id++) {
1872 for (
id=0;
id<ndiv;
id++) {
1878 Error(
"Divide",
"In shape %s wrong axis type for division",
GetName());
1918 param[0] *= param[0];
1920 param[1] *= param[1];
1933 Error(
"GetMakeRuntimeShape",
"Invalid mother for shape %s",
GetName());
1942 rmin = ((
TGeoTube*)mother)->GetRmin();
1944 rmax = ((
TGeoTube*)mother)->GetRmax();
1954 printf(
"*** Shape %s: TGeoTubeSeg ***\n",
GetName());
1955 printf(
" Rmin = %11.5f\n",
fRmin);
1956 printf(
" Rmax = %11.5f\n",
fRmax);
1957 printf(
" dz = %11.5f\n",
fDz);
1958 printf(
" phi1 = %11.5f\n",
fPhi1);
1959 printf(
" phi2 = %11.5f\n",
fPhi2);
1960 printf(
" Bounding box:\n");
1972 Int_t nbSegs = 2*nbPnts;
1973 Int_t nbPols = nbPnts-2;
1976 nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols);
1996 for (i = 0; i < 4; i++) {
1997 for (j = 1; j <
n; j++) {
1999 buff.
fSegs[(i*
n+j-1)*3+1] = i*
n+j-1;
2000 buff.
fSegs[(i*
n+j-1)*3+2] = i*
n+j;
2003 for (i = 4; i < 6; i++) {
2004 for (j = 0; j <
n; j++) {
2006 buff.
fSegs[(i*
n+j)*3+1] = (i-4)*
n+j;
2007 buff.
fSegs[(i*
n+j)*3+2] = (i-2)*
n+j;
2010 for (i = 6; i < 8; i++) {
2011 for (j = 0; j <
n; j++) {
2013 buff.
fSegs[(i*
n+j)*3+1] = 2*(i-6)*
n+j;
2014 buff.
fSegs[(i*
n+j)*3+2] = (2*(i-6)+1)*
n+j;
2021 for (j = 0; j <
n-1; j++) {
2023 buff.
fPols[indx++] = 4;
2024 buff.
fPols[indx++] = (4+i)*
n+j+1;
2025 buff.
fPols[indx++] = (2+i)*
n+j;
2026 buff.
fPols[indx++] = (4+i)*
n+j;
2027 buff.
fPols[indx++] = i*
n+j;
2030 for (j = 0; j <
n-1; j++) {
2032 buff.
fPols[indx++] = 4;
2033 buff.
fPols[indx++] = i*
n+j;
2034 buff.
fPols[indx++] = (4+i)*
n+j;
2035 buff.
fPols[indx++] = (2+i)*
n+j;
2036 buff.
fPols[indx++] = (4+i)*
n+j+1;
2039 for (j = 0; j <
n-1; j++) {
2040 buff.
fPols[indx++] =
c+i;
2041 buff.
fPols[indx++] = 4;
2042 buff.
fPols[indx++] = (i-2)*2*
n+j;
2043 buff.
fPols[indx++] = (4+i)*
n+j;
2044 buff.
fPols[indx++] = ((i-2)*2+1)*
n+j;
2045 buff.
fPols[indx++] = (4+i)*
n+j+1;
2048 for (j = 0; j <
n-1; j++) {
2049 buff.
fPols[indx++] =
c+i;
2050 buff.
fPols[indx++] = 4;
2051 buff.
fPols[indx++] = (4+i)*
n+j+1;
2052 buff.
fPols[indx++] = ((i-2)*2+1)*
n+j;
2053 buff.
fPols[indx++] = (4+i)*
n+j;
2054 buff.
fPols[indx++] = (i-2)*2*
n+j;
2056 buff.
fPols[indx++] =
c+2;
2057 buff.
fPols[indx++] = 4;
2058 buff.
fPols[indx++] = 6*
n;
2059 buff.
fPols[indx++] = 4*
n;
2060 buff.
fPols[indx++] = 7*
n;
2061 buff.
fPols[indx++] = 5*
n;
2062 buff.
fPols[indx++] =
c+2;
2063 buff.
fPols[indx++] = 4;
2064 buff.
fPols[indx++] = 6*
n-1;
2065 buff.
fPols[indx++] = 8*
n-1;
2066 buff.
fPols[indx++] = 5*
n-1;
2067 buff.
fPols[indx++] = 7*
n-1;
2077 Double_t rsq = point[0]*point[0]+point[1]*point[1];
2104 saf[1] =
fRmin-rproj;
2105 saf[2] = rproj-
fRmax;
2111 return (saf[0]<0) ? safe :
TMath::Sqrt(safe*safe+saf[0]*saf[0]);
2114 return (saf[0]<0) ? safphi :
TMath::Sqrt(saf[0]*saf[0]+safphi*safphi);
2124 Double_t rsq = point[0]*point[0]+point[1]*point[1];
2129 saf[0] = dz - point[2];
2132 saf[0] = dz + point[2];
2145 if ((phi2d-phi1d)>=360.)
return safe;
2158 Double_t cpsi=point[0]*cm+point[1]*sm;
2178 saf[1] = rmin-rproj;
2179 saf[2] = rproj-rmax;
2181 if ((phi2d-phi1d)>=360.)
return TMath::Max(safe,saf[0]);
2185 return (saf[0]<0) ? safe :
TMath::Sqrt(safe*safe+saf[0]*saf[0]);
2188 return (saf[0]<0) ? safphi :
TMath::Sqrt(saf[0]*saf[0]+safphi*safphi);
2197 out <<
" // Shape: " <<
GetName() <<
" type: " <<
ClassName() << std::endl;
2198 out <<
" rmin = " <<
fRmin <<
";" << std::endl;
2199 out <<
" rmax = " <<
fRmax <<
";" << std::endl;
2200 out <<
" dz = " <<
fDz <<
";" << std::endl;
2201 out <<
" phi1 = " <<
fPhi1 <<
";" << std::endl;
2202 out <<
" phi2 = " <<
fPhi2 <<
";" << std::endl;
2203 out <<
" TGeoShape *" <<
GetPointerName() <<
" = new TGeoTubeSeg(\"" <<
GetName() <<
"\",rmin,rmax,dz,phi1,phi2);" << std::endl;
2245 if (npoints > (npoints/2)*2) {
2246 Error(
"GetPointsOnSegments",
"Npoints must be even number");
2253 Int_t ntop = npoints/2 - nc*(nc-1);
2259 for (
Int_t i=0; i<nc; i++) {
2266 for (
Int_t j=0; j<nphi; j++) {
2267 phi = phi1 + j*dphi;
2289 if (phi2<phi1) phi2+=360.;
2292 dphi = (phi2-phi1)/(
n-1);
2298 for (j = 0; j <
n; j++) {
2308 for (j = 0; j <
n; j++) {
2331 if (phi2<phi1) phi2+=360.;
2334 dphi = (phi2-phi1)/(
n-1);
2340 for (j = 0; j <
n; j++) {
2350 for (j = 0; j <
n; j++) {
2411 Int_t nbSegs = 2*nbPnts;
2412 Int_t nbPols = nbPnts-2;
2413 if (buffer.
SetRawSizes(nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols)) {
2525 SetCtubDimensions(params[0], params[1], params[2], params[3], params[4], params[5],
2526 params[6], params[7], params[8], params[9], params[10]);
2553 Error(
"ComputeBBox",
"In shape %s wrong definition of cut planes",
GetName());
2567 for (i=0; i<2; i++) {
2568 if (phi_low<0) phi_low+=360.;
2570 if (dphi < 0) dphi+=360.;
2572 if (ddp<0) ddp += 360.;
2584 in_range_low =
kTRUE;
2587 if (phi_low>360) phi_low-=360.;
2590 for (i=0; i<2; i++) {
2591 if (phi_hi<0) phi_hi+=360.;
2593 if (dphi < 0) dphi+=360.;
2595 if (ddp<0) ddp += 360.;
2607 in_range_hi =
kTRUE;
2610 if (phi_hi>360) phi_hi-=360.;
2646 fDZ = 0.5*(zmax-zmin);
2658 Double_t rsq = point[0]*point[0]+point[1]*point[1];
2674 if (norm[0]*dir[0]+norm[1]*dir[1]+norm[2]*dir[2]<0) {
2683 if (norm[0]*dir[0]+norm[1]*dir[1]+norm[2]*dir[2]<0) {
2695 if (norm[0]*dir[0]+norm[1]*dir[1]<0) {
2708 if (zin>0)
return kFALSE;
2711 if (zin>0)
return kFALSE;
2713 Double_t r2 = point[0]*point[0]+point[1]*point[1];
2717 if (phi < 0 ) phi+=360.;
2720 if (ddp<0) ddp += 360.;
2722 if (ddp > dphi)
return kFALSE;
2766 if (iact<3 && safe) {
2777 Double_t rsq = point[0]*point[0]+point[1]*point[1];
2791 xi = point[0]+s*dir[0];
2792 yi = point[1]+s*dir[1];
2797 if (cpsi>=
fCdfi)
return s;
2805 xi = point[0]+s*dir[0];
2806 yi = point[1]+s*dir[1];
2811 if (cpsi>=
fCdfi)
return s;
2817 Double_t nsq=dir[0]*dir[0]+dir[1]*dir[1];
2819 Double_t rdotn=point[0]*dir[0]+point[1]*dir[1];
2822 if (
r>
fRmax && rdotn<0) {
2827 xi=point[0]+s*dir[0];
2828 yi=point[1]+s*dir[1];
2829 zi=point[2]+s*dir[2];
2834 if (cpsi>=
fCdfi)
return s;
2847 xi=point[0]+s*dir[0];
2848 yi=point[1]+s*dir[1];
2849 zi=point[2]+s*dir[2];
2854 if (cpsi>=
fCdfi) snxt=s;
2861 if (tub)
return snxt;
2864 s=(point[1]*
fC1-point[0]*
fS1)/un;
2866 xi=point[0]+s*dir[0];
2867 yi=point[1]+s*dir[1];
2868 zi=point[2]+s*dir[2];
2873 if ((yi*
fCm-xi*
fSm)<=0) {
2881 un=dir[0]*
fS2-dir[1]*
fC2;
2883 s=(point[1]*
fC2-point[0]*
fS2)/un;
2885 xi=point[0]+s*dir[0];
2886 yi=point[1]+s*dir[1];
2887 zi=point[2]+s*dir[2];
2892 if ((yi*
fCm-xi*
fSm)>=0) {
2911 Double_t rsq = point[0]*point[0]+point[1]*point[1];
2921 if (calf>0) sz = saf[0]/calf;
2926 if (sz1<sz) sz = sz1;
2930 Double_t nsq=dir[0]*dir[0]+dir[1]*dir[1];
2933 Double_t rdotn=point[0]*dir[0]+point[1]*dir[1];
2942 if (sr>0) skip_outer =
kTRUE;
2967 Warning(
"Divide",
"In shape %s division of a cut tube not implemented",
GetName());
2979 Error(
"GetMakeRuntimeShape",
"Invalid mother for shape %s",
GetName());
2988 rmin = ((
TGeoTube*)mother)->GetRmin();
2990 rmax = ((
TGeoTube*)mother)->GetRmax();
3001 printf(
"*** Shape %s: TGeoCtub ***\n",
GetName());
3002 printf(
" lx = %11.5f\n",
fNlow[0]);
3003 printf(
" ly = %11.5f\n",
fNlow[1]);
3004 printf(
" lz = %11.5f\n",
fNlow[2]);
3005 printf(
" tx = %11.5f\n",
fNhigh[0]);
3006 printf(
" ty = %11.5f\n",
fNhigh[1]);
3007 printf(
" tz = %11.5f\n",
fNhigh[2]);
3018 Double_t rsq = point[0]*point[0]+point[1]*point[1];
3034 for (
Int_t i=0; i<4; i++) saf[i]=-saf[i];
3062 out <<
" // Shape: " <<
GetName() <<
" type: " <<
ClassName() << std::endl;
3063 out <<
" rmin = " <<
fRmin <<
";" << std::endl;
3064 out <<
" rmax = " <<
fRmax <<
";" << std::endl;
3065 out <<
" dz = " <<
fDz <<
";" << std::endl;
3066 out <<
" phi1 = " <<
fPhi1 <<
";" << std::endl;
3067 out <<
" phi2 = " <<
fPhi2 <<
";" << std::endl;
3068 out <<
" lx = " <<
fNlow[0] <<
";" << std::endl;
3069 out <<
" ly = " <<
fNlow[1] <<
";" << std::endl;
3070 out <<
" lz = " <<
fNlow[2] <<
";" << std::endl;
3071 out <<
" tx = " <<
fNhigh[0] <<
";" << std::endl;
3072 out <<
" ty = " <<
fNhigh[1] <<
";" << std::endl;
3073 out <<
" tz = " <<
fNhigh[2] <<
";" << std::endl;
3074 out <<
" TGeoShape *" <<
GetPointerName() <<
" = new TGeoCtub(\"" <<
GetName() <<
"\",rmin,rmax,dz,phi1,phi2,lx,ly,lz,tx,ty,tz);" << std::endl;
TObject::SetBit(
TGeoShape::kGeoSavePrimitive);
3083 param[6], param[7], param[8], param[9], param[10]);
3107 if (phi2<phi1) phi2+=360.;
3110 dphi = (phi2-phi1)/(
n-1);
3116 for (j = 0; j <
n; j++) {
3126 for (j = 0; j <
n; j++) {
3149 if (phi2<phi1) phi2+=360.;
3152 dphi = (phi2-phi1)/(
n-1);
3158 for (j = 0; j <
n; j++) {
3168 for (j = 0; j <
n; j++) {
3216 for (
UInt_t i = 0; i < 3; i++ ) {
3225 Int_t nbSegs = 2*nbPnts;
3226 Int_t nbPols = nbPnts-2;
3227 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...
The cut tubes constructor has the form:
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
A tube segment is a tube having a range in phi.
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()