62 #if !defined(G4GEOM_USE_USPHERE)
79 using namespace CLHEP;
99 fFullPhiSphere(true), fFullThetaSphere(true)
109 if ( (pRmin >= pRmax) || (pRmax < 1.1*
kRadTolerance) || (pRmin < 0) )
112 message <<
"Invalid radii for Solid: " <<
GetName() <<
G4endl
113 <<
" pRmin = " << pRmin <<
", pRmax = " << pRmax;
114 G4Exception(
"G4Sphere::G4Sphere()",
"GeomSolids0002",
133 :
G4CSGSolid(a), fRminTolerance(0.), fRmaxTolerance(0.),
134 kAngTolerance(0.), kRadTolerance(0.), fEpsilon(0.),
135 fRmin(0.), fRmax(0.), fSPhi(0.), fDPhi(0.), fSTheta(0.),
136 fDTheta(0.), sinCPhi(0.), cosCPhi(0.), cosHDPhiOT(0.), cosHDPhiIT(0.),
137 sinSPhi(0.), cosSPhi(0.), sinEPhi(0.), cosEPhi(0.), hDPhi(0.), cPhi(0.),
138 ePhi(0.), sinSTheta(0.), cosSTheta(0.), sinETheta(0.), cosETheta(0.),
139 tanSTheta(0.), tanSTheta2(0.), tanETheta(0.), tanETheta2(0.), eTheta(0.),
140 fFullPhiSphere(false), fFullThetaSphere(false), fFullSphere(true),
141 halfCarTolerance(0.), halfAngTolerance(0.)
158 :
G4CSGSolid(rhs), fRminTolerance(rhs.fRminTolerance),
159 fRmaxTolerance(rhs.fRmaxTolerance), kAngTolerance(rhs.kAngTolerance),
160 kRadTolerance(rhs.kRadTolerance), fEpsilon(rhs.fEpsilon),
161 fRmin(rhs.fRmin), fRmax(rhs.fRmax), fSPhi(rhs.fSPhi), fDPhi(rhs.fDPhi),
162 fSTheta(rhs.fSTheta), fDTheta(rhs.fDTheta),
163 sinCPhi(rhs.sinCPhi), cosCPhi(rhs.cosCPhi),
164 cosHDPhiOT(rhs.cosHDPhiOT), cosHDPhiIT(rhs.cosHDPhiIT),
165 sinSPhi(rhs.sinSPhi), cosSPhi(rhs.cosSPhi),
166 sinEPhi(rhs.sinEPhi), cosEPhi(rhs.cosEPhi),
167 hDPhi(rhs.hDPhi), cPhi(rhs.cPhi), ePhi(rhs.ePhi),
168 sinSTheta(rhs.sinSTheta), cosSTheta(rhs.cosSTheta),
169 sinETheta(rhs.sinETheta), cosETheta(rhs.cosETheta),
170 tanSTheta(rhs.tanSTheta), tanSTheta2(rhs.tanSTheta2),
171 tanETheta(rhs.tanETheta), tanETheta2(rhs.tanETheta2), eTheta(rhs.eTheta),
172 fFullPhiSphere(rhs.fFullPhiSphere), fFullThetaSphere(rhs.fFullThetaSphere),
173 fFullSphere(rhs.fFullSphere),
174 halfCarTolerance(rhs.halfCarTolerance),
175 halfAngTolerance(rhs.halfAngTolerance)
187 if (
this == &rhs) {
return *
this; }
241 pMin.
set(-rmax,-rmax,-rmax);
242 pMax.
set( rmax, rmax, rmax);
255 if (stheta >
halfpi) rhomax = rmax*sinStart;
256 if (etheta <
halfpi) rhomax = rmax*sinEnd;
266 pMin.
set(xymin.
x(),xymin.
y(),zmin);
267 pMax.
set(xymax.
x(),xymax.
y(),zmax);
272 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
275 message <<
"Bad bounding box (min >= max) for solid: "
277 <<
"\npMin = " << pMin
278 <<
"\npMax = " << pMax;
279 G4Exception(
"G4Sphere::BoundingLimits()",
"GeomMgt0001",
312 G4double rho,rho2,rad2,tolRMin,tolRMax;
321 rho2 = p.
x()*p.
x() + p.
y()*p.
y() ;
322 rad2 = rho2 + p.
z()*p.
z() ;
327 tolRMax = Rmax_minus;
345 if ( (rad2 <= Rmax_minus*Rmax_minus) && (rad2 >= Rmin_plus*Rmin_plus) )
351 tolRMax =
fRmax + halfRmaxTolerance;
353 if ( (rad2 <= tolRMax*tolRMax) && (rad2 >= tolRMin*tolRMin) )
367 pPhi = std::atan2(p.
y(),p.
x()) ;
386 rho = std::sqrt(rho2);
387 pTheta = std::atan2(rho,p.
z());
426 G4int noSurfaces = 0;
434 rho2 = p.
x()*p.
x()+p.
y()*p.
y();
435 radius = std::sqrt(rho2+p.
z()*p.
z());
436 rho = std::sqrt(rho2);
439 if (
fRmin) distRMin = std::fabs(radius-
fRmin);
443 pPhi = std::atan2(p.
y(),p.
x());
452 distSPhi = std::fabs( pPhi-
fSPhi );
453 distEPhi = std::fabs( pPhi-
ePhi );
467 pTheta = std::atan2(rho,p.
z());
468 distSTheta = std::fabs(pTheta-
fSTheta);
469 distETheta = std::fabs(pTheta-
eTheta);
524 else { sumnorm += nTs; }
530 else { sumnorm += nTe; }
531 if(sumnorm.
z() == 0.) { sumnorm += nZ; }
534 if ( noSurfaces == 0 )
537 G4Exception(
"G4Sphere::SurfaceNormal(p)",
"GeomSolids1002",
542 else if ( noSurfaces == 1 ) { norm = sumnorm; }
543 else { norm = sumnorm.
unit(); }
558 G4double distRMin,distRMax,distSPhi,distEPhi,
559 distSTheta,distETheta,distMin;
561 rho2=p.
x()*p.
x()+p.
y()*p.
y();
562 radius=std::sqrt(rho2+p.
z()*p.
z());
569 distRMax=std::fabs(radius-
fRmax);
572 distRMin=std::fabs(radius-
fRmin);
574 if (distRMin<distRMax)
596 pPhi = std::atan2(p.
y(),p.
x());
597 if (pPhi<0) { pPhi +=
twopi; }
607 distSPhi=std::fabs(pPhi-
fSPhi)*rho;
614 if (distSPhi<distEPhi)
616 if (distSPhi<distMin)
624 if (distEPhi<distMin)
638 pTheta=std::atan2(rho,p.
z());
644 if (distSTheta<distETheta)
646 if (distSTheta<distMin)
648 distMin = distSTheta ;
654 if (distETheta<distMin)
656 distMin = distETheta ;
690 "Undefined side for valid surface normal to solid.");
730 G4double rho2, rad2, pDotV2d, pDotV3d, pTheta ;
731 G4double tolSTheta=0., tolETheta=0. ;
737 ? (
fRmin-halfRminTolerance)*(
fRmin-halfRminTolerance) : 0;
739 (
fRmin+halfRminTolerance)*(
fRmin+halfRminTolerance);
741 (
fRmax+halfRmaxTolerance)*(
fRmax+halfRmaxTolerance);
743 (
fRmax-halfRmaxTolerance)*(
fRmax-halfRmaxTolerance);
747 G4double xi, yi, zi, rhoi, rhoi2, radi2, iTheta ;
764 rho2 = p.
x()*p.
x() + p.
y()*p.
y() ;
765 rad2 = rho2 + p.
z()*p.
z() ;
766 pTheta = std::atan2(std::sqrt(rho2),p.
z()) ;
768 pDotV2d = p.
x()*v.
x() + p.
y()*v.
y() ;
769 pDotV3d = pDotV2d + p.
z()*v.
z() ;
780 if ((rad2!=0.0) || (
fRmin!=0.0))
786 G4double vTheta = std::atan2(std::sqrt(v.
x()*v.
x()+v.
y()*v.
y()),v.
z()) ;
787 if ( (vTheta < tolSTheta) || (vTheta > tolETheta) )
816 d2 = pDotV3d*pDotV3d - c ;
820 sd = -pDotV3d - std::sqrt(d2) ;
826 G4double fTerm = sd-std::fmod(sd,dRmax);
829 xi = p.
x() + sd*v.
x() ;
830 yi = p.
y() + sd*v.
y() ;
831 rhoi = std::sqrt(xi*xi + yi*yi) ;
841 zi = p.
z() + sd*v.
z() ;
846 iTheta = std::atan2(rhoi,zi) ;
847 if ( (iTheta >= tolSTheta) && (iTheta <= tolETheta) )
862 zi = p.
z() + sd*v.
z() ;
867 iTheta = std::atan2(rhoi,zi) ;
868 if ( (iTheta >= tolSTheta) && (iTheta <= tolETheta) )
890 d2 = pDotV3d*pDotV3d - c ;
892 if ( (rad2 > tolIRMax2)
946 d2 = pDotV3d*pDotV3d - c ;
951 if ( (c > -halfRminTolerance) && (rad2 < tolIRMin2)
998 sd = -pDotV3d + std::sqrt(d2) ;
999 if ( sd >= halfRminTolerance )
1001 xi = p.
x() + sd*v.
x() ;
1002 yi = p.
y() + sd*v.
y() ;
1003 rhoi = std::sqrt(xi*xi+yi*yi) ;
1013 zi = p.
z() + sd*v.
z() ;
1018 iTheta = std::atan2(rhoi,zi) ;
1019 if ( (iTheta >= tolSTheta) && (iTheta<=tolETheta) )
1034 zi = p.
z() + sd*v.
z() ;
1039 iTheta = std::atan2(rhoi,zi) ;
1040 if ( (iTheta >= tolSTheta) && (iTheta <= tolETheta) )
1083 xi = p.
x() + sd*v.
x() ;
1084 yi = p.
y() + sd*v.
y() ;
1085 zi = p.
z() + sd*v.
z() ;
1086 rhoi2 = xi*xi + yi*yi ;
1087 radi2 = rhoi2 + zi*zi ;
1098 if ( (radi2 <= tolORMax2)
1099 && (radi2 >= tolORMin2)
1108 iTheta = std::atan2(std::sqrt(rhoi2),zi) ;
1109 if ( (iTheta >= tolSTheta) && (iTheta <= tolETheta) )
1114 if ((yi*
cosCPhi-xi*sinCPhi) <= 0)
1145 xi = p.
x() + sd*v.
x() ;
1146 yi = p.
y() + sd*v.
y() ;
1147 zi = p.
z() + sd*v.
z() ;
1148 rhoi2 = xi*xi + yi*yi ;
1149 radi2 = rhoi2 + zi*zi ;
1160 if ( (radi2 <= tolORMax2)
1161 && (radi2 >= tolORMin2)
1170 iTheta = std::atan2(std::sqrt(rhoi2),zi) ;
1171 if ( (iTheta >= tolSTheta) && (iTheta <= tolETheta) )
1176 if ((yi*
cosCPhi-xi*sinCPhi) >= 0)
1233 if ( pTheta < tolSTheta )
1243 c = dist2STheta/
t1 ;
1250 zi = p.
z() + sd*v.
z();
1256 if ((sd >= 0) && (sd < snxt))
1258 xi = p.
x() + sd*v.
x();
1259 yi = p.
y() + sd*v.
y();
1260 zi = p.
z() + sd*v.
z();
1261 rhoi2 = xi*xi + yi*yi;
1262 radi2 = rhoi2 + zi*zi;
1263 if ( (radi2 <= tolORMax2)
1264 && (radi2 >= tolORMin2)
1294 c = dist2ETheta/
t1 ;
1302 if ( (sd >= 0) && (sd < snxt) )
1304 xi = p.
x() + sd*v.
x() ;
1305 yi = p.
y() + sd*v.
y() ;
1306 zi = p.
z() + sd*v.
z() ;
1307 rhoi2 = xi*xi + yi*yi ;
1308 radi2 = rhoi2 + zi*zi ;
1310 if ( (radi2 <= tolORMax2)
1311 && (radi2 >= tolORMin2)
1332 else if ( pTheta > tolETheta )
1343 c = dist2ETheta/
t1 ;
1350 zi = p.
z() + sd*v.
z();
1356 if ( (sd >= 0) && (sd < snxt) )
1358 xi = p.
x() + sd*v.
x() ;
1359 yi = p.
y() + sd*v.
y() ;
1360 zi = p.
z() + sd*v.
z() ;
1361 rhoi2 = xi*xi + yi*yi ;
1362 radi2 = rhoi2 + zi*zi ;
1364 if ( (radi2 <= tolORMax2)
1365 && (radi2 >= tolORMin2)
1395 c = dist2STheta/
t1 ;
1403 if ( (sd >= 0) && (sd < snxt) )
1405 xi = p.
x() + sd*v.
x() ;
1406 yi = p.
y() + sd*v.
y() ;
1407 zi = p.
z() + sd*v.
z() ;
1408 rhoi2 = xi*xi + yi*yi ;
1409 radi2 = rhoi2 + zi*zi ;
1411 if ( (radi2 <= tolORMax2)
1412 && (radi2 >= tolORMin2)
1441 if ( (t2>=0 && tolIRMin2<rad2 && rad2<tolIRMax2 &&
fSTheta<
halfpi)
1442 || (t2<0 && tolIRMin2<rad2 && rad2<tolIRMax2 && fSTheta>
halfpi)
1443 || (v.
z()<0 && tolIRMin2<rad2 && rad2<tolIRMax2 &&
fSTheta==
halfpi) )
1465 c = dist2STheta/
t1 ;
1474 xi = p.
x() + sd*v.
x() ;
1475 yi = p.
y() + sd*v.
y() ;
1476 zi = p.
z() + sd*v.
z() ;
1477 rhoi2 = xi*xi + yi*yi ;
1478 radi2 = rhoi2 + zi*zi ;
1480 if ( (radi2 <= tolORMax2)
1481 && (radi2 >= tolORMin2)
1482 && (zi*(fSTheta - halfpi) <= 0) )
1511 && (tolIRMin2 < rad2) && (rad2 < tolIRMax2))
1513 && (tolIRMin2 < rad2) && (rad2 < tolIRMax2))
1515 && (tolIRMin2 < rad2) && (rad2 < tolIRMax2)) )
1537 c = dist2ETheta/
t1 ;
1548 xi = p.
x() + sd*v.
x() ;
1549 yi = p.
y() + sd*v.
y() ;
1550 zi = p.
z() + sd*v.
z() ;
1551 rhoi2 = xi*xi + yi*yi ;
1552 radi2 = rhoi2 + zi*zi ;
1554 if ( (radi2 <= tolORMax2)
1555 && (radi2 >= tolORMin2)
1585 c = dist2STheta/
t1 ;
1593 if ((sd >= 0) && (sd < snxt))
1595 xi = p.
x() + sd*v.
x() ;
1596 yi = p.
y() + sd*v.
y() ;
1597 zi = p.
z() + sd*v.
z() ;
1598 rhoi2 = xi*xi + yi*yi ;
1599 radi2 = rhoi2 + zi*zi ;
1601 if ( (radi2 <= tolORMax2)
1602 && (radi2 >= tolORMin2)
1626 c = dist2ETheta/
t1 ;
1634 if ((sd >= 0) && (sd < snxt))
1636 xi = p.
x() + sd*v.
x() ;
1637 yi = p.
y() + sd*v.
y() ;
1638 zi = p.
z() + sd*v.
z() ;
1639 rhoi2 = xi*xi + yi*yi ;
1640 radi2 = rhoi2 + zi*zi ;
1642 if ( (radi2 <= tolORMax2)
1643 && (radi2 >= tolORMin2)
1677 G4double safe=0.0,safeRMin,safeRMax,safePhi,safeTheta;
1681 rho2=p.
x()*p.
x()+p.
y()*p.
y();
1682 rds=std::sqrt(rho2+p.
z()*p.
z());
1683 rho=std::sqrt(rho2);
1692 if (safeRMin>safeRMax)
1714 if (cosPsi<std::cos(
hDPhi))
1726 if (safePhi>safe) { safe=safePhi; }
1734 pTheta=std::acos(p.
z()/rds);
1735 if (pTheta<0) { pTheta+=
pi; }
1738 if (dTheta1>dTheta2)
1742 safeTheta=rds*std::sin(dTheta1);
1743 if (safe<=safeTheta)
1753 safeTheta=rds*std::sin(dTheta2);
1754 if (safe<=safeTheta)
1762 if (safe<0) { safe=0; }
1790 G4double pDistS,compS,pDistE,compE,sphi2,vphi;
1792 G4double rho2,rad2,pDotV2d,pDotV3d;
1799 G4double dist2STheta, dist2ETheta, distTheta;
1804 rho2 = p.
x()*p.
x()+p.
y()*p.
y();
1805 rad2 = rho2+p.
z()*p.
z();
1807 pDotV2d = p.
x()*v.
x()+p.
y()*v.
y();
1808 pDotV3d = pDotV2d+p.
z()*v.
z();
1826 if( (rad2 <= Rmax_plus*Rmax_plus) && (rad2 >= Rmin_minus*Rmin_minus) )
1841 d2 = pDotV3d*pDotV3d - c;
1844 && ((pDotV3d >=0) || (d2 < 0)) )
1856 snxt = -pDotV3d+std::sqrt(d2);
1868 d2 = pDotV3d*pDotV3d - c;
1875 if(calcNorm) { *validNorm =
false; }
1882 sd = -pDotV3d-std::sqrt(d2);
1928 if ( std::fabs( p.
z() ) <= halfRmaxTolerance )
1937 stheta = -p.
z()/v.
z();
1953 if(std::fabs(distTheta) < halfRmaxTolerance)
1957 if( calcNorm ) { *validNorm =
false; }
1967 rhoSecTheta = std::sqrt(rho2*(1+
tanSTheta2));
1978 stheta = -0.5*dist2STheta/
t2;
1984 if( std::fabs(distTheta) < halfRmaxTolerance )
1993 rhoSecTheta = std::sqrt(rho2*(1+
tanSTheta2));
2005 if( calcNorm ) { *validNorm =
false; }
2021 if ( ((std::fabs(
s) < halfRmaxTolerance) && (t2 < 0.))
2022 || (sd < 0.) || ( (sd > 0.) && (p.
z() + sd*v.
z() > 0.) ) )
2026 if( (sd > halfRmaxTolerance) && (p.
z() + sd*v.
z() <= 0.) )
2036 if ( ( (std::fabs(sd) < halfRmaxTolerance) && (t2 >= 0.) )
2037 || (sd < 0.) || ( (sd > 0.) && (p.
z() + sd*v.
z() < 0.) ) )
2041 if( (sd > halfRmaxTolerance) && (p.
z() + sd*v.
z() >= 0.) )
2057 if ( std::fabs( p.
z() ) <= halfRmaxTolerance )
2087 if(std::fabs(distTheta) < halfRmaxTolerance)
2091 if( calcNorm ) { *validNorm =
false; }
2101 rhoSecTheta = std::sqrt(rho2*(1+
tanETheta2));
2111 sd = -0.5*dist2ETheta/
t2;
2122 if ( std::fabs(distTheta) < halfRmaxTolerance )
2131 rhoSecTheta = std::sqrt(rho2*(1+
tanETheta2));
2141 && (t2 < 0.) && (p.
z() <=0.) )
2143 if( calcNorm ) { *validNorm =
false; }
2150 if ( (d2 <halfRmaxTolerance) && (d2 > -halfRmaxTolerance) )
2162 if( ((std::fabs(sd) < halfRmaxTolerance) && (t2 < 0.))
2167 if( sd > halfRmaxTolerance )
2180 if ( ((std::fabs(sd) < halfRmaxTolerance) && (t2 >= 0.))
2182 || ( (sd > 0.) && (p.
z() + sd*v.
z() > halfRmaxTolerance) ) )
2186 if ( ( sd>halfRmaxTolerance )
2187 && ( p.
z()+sd*v.
z() <= halfRmaxTolerance ) )
2207 if ( p.
x() || p.
y() )
2220 if ( (pDistS <= 0) && (pDistE <= 0) )
2226 sphi = pDistS/compS ;
2227 xi = p.
x()+sphi*v.
x() ;
2228 yi = p.
y()+sphi*v.
y() ;
2234 vphi = std::atan2(v.
y(),v.
x());
2256 sphi2=pDistE/compE ;
2259 xi = p.
x()+sphi2*v.
x() ;
2260 yi = p.
y()+sphi2*v.
y() ;
2269 vphi = std::atan2(v.
y(),v.
x()) ;
2276 else { sphi = 0.0; }
2294 else if ((pDistS >= 0) && (pDistE >= 0))
2296 if ( pDistS <= pDistE )
2306 if ( (compS < 0) && (compE < 0) ) { sphi = 0; }
2314 if ( (compS >= 0) && (compE >= 0) ) { sphi =
kInfinity; }
2318 else if ( (pDistS > 0) && (pDistE < 0) )
2326 sphi = pDistE/compE ;
2327 xi = p.
x() + sphi*v.
x() ;
2328 yi = p.
y() + sphi*v.
y() ;
2335 vphi = std::atan2(v.
y(),v.
x());
2364 sphi = pDistE/compE ;
2365 xi = p.
x() + sphi*v.
x() ;
2366 yi = p.
y() + sphi*v.
y() ;
2374 vphi = std::atan2(v.
y(),v.
x());
2410 xi=p.
x()+sphi*v.
x();
2411 yi=p.
y()+sphi*v.
y();
2418 vphi = std::atan2(v.
y(),v.
x()) ;
2447 sphi = pDistS/compS ;
2448 xi = p.
x()+sphi*v.
x() ;
2449 yi = p.
y()+sphi*v.
y() ;
2457 vphi = std::atan2(v.
y(),v.
x()) ;
2492 if ( v.
x() || v.
y() )
2494 vphi = std::atan2(v.
y(),v.
x()) ;
2527 xi=p.
x()+snxt*v.
x();
2528 yi=p.
y()+snxt*v.
y();
2529 zi=p.
z()+snxt*v.
z();
2544 else { *validNorm=
false; }
2553 else { *validNorm=
false; }
2564 xi = p.
x() + snxt*v.
x();
2565 yi = p.
y() + snxt*v.
y();
2569 rhoSecTheta = std::sqrt(rho2*(1+
tanSTheta2));
2579 else { *validNorm=
false; }
2590 xi=p.
x()+snxt*v.
x();
2591 yi=p.
y()+snxt*v.
y();
2595 rhoSecTheta = std::sqrt(rho2*(1+
tanETheta2));
2605 else { *validNorm=
false; }
2612 G4int oldprc = message.precision(16);
2613 message <<
"Undefined side for valid surface normal to solid."
2615 <<
"Position:" << G4endl << G4endl
2616 <<
"p.x() = " << p.
x()/
mm <<
" mm" << G4endl
2617 <<
"p.y() = " << p.
y()/
mm <<
" mm" << G4endl
2618 <<
"p.z() = " << p.
z()/
mm <<
" mm" << G4endl << G4endl
2619 <<
"Direction:" << G4endl << G4endl
2620 <<
"v.x() = " << v.
x() << G4endl
2621 <<
"v.y() = " << v.
y() << G4endl
2622 <<
"v.z() = " << v.
z() << G4endl << G4endl
2623 <<
"Proposed distance :" << G4endl << G4endl
2624 <<
"snxt = " << snxt/
mm <<
" mm" <<
G4endl;
2625 message.precision(oldprc);
2636 G4int oldprc = message.precision(16);
2637 message <<
"Logic error: snxt = kInfinity ???" << G4endl
2638 <<
"Position:" << G4endl << G4endl
2639 <<
"p.x() = " << p.
x()/
mm <<
" mm" << G4endl
2640 <<
"p.y() = " << p.
y()/
mm <<
" mm" << G4endl
2641 <<
"p.z() = " << p.
z()/
mm <<
" mm" << G4endl << G4endl
2642 <<
"Rp = "<< std::sqrt( p.
x()*p.
x()+p.
y()*p.
y()+p.
z()*p.
z() )/
mm
2643 <<
" mm" << G4endl << G4endl
2644 <<
"Direction:" << G4endl << G4endl
2645 <<
"v.x() = " << v.
x() << G4endl
2646 <<
"v.y() = " << v.
y() << G4endl
2647 <<
"v.z() = " << v.
z() << G4endl << G4endl
2648 <<
"Proposed distance :" << G4endl << G4endl
2649 <<
"snxt = " << snxt/
mm <<
" mm" <<
G4endl;
2650 message.precision(oldprc);
2664 G4double safe=0.0,safeRMin,safeRMax,safePhi,safeTheta;
2667 rho2=p.
x()*p.
x()+p.
y()*p.
y();
2668 rds=std::sqrt(rho2+p.
z()*p.
z());
2669 rho=std::sqrt(rho2);
2681 G4cout.precision(old_prc) ;
2683 "GeomSolids1002",
JustWarning,
"Point p is outside !?" );
2689 safeRMax =
fRmax-rds;
2693 safeRMin = rds-
fRmin;
2694 safe =
std::min( safeRMin, safeRMax );
2728 pTheta=std::acos(p.
z()/rds);
2729 if (pTheta<0) { pTheta+=
pi; }
2733 { dTheta2=
eTheta-pTheta;}
2735 safeTheta=rds*std::sin(
std::min(dTheta1, dTheta2) );
2742 safe =
std::min( safe, safeTheta );
2745 if (safe<0.0) { safe=0; }
2775 G4int oldprc = os.precision(16);
2776 os <<
"-----------------------------------------------------------\n"
2777 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
2778 <<
" ===================================================\n"
2779 <<
" Solid type: G4Sphere\n"
2780 <<
" Parameters: \n"
2781 <<
" inner radius: " <<
fRmin/
mm <<
" mm \n"
2782 <<
" outer radius: " <<
fRmax/
mm <<
" mm \n"
2783 <<
" starting phi of segment : " <<
fSPhi/
degree <<
" degrees \n"
2784 <<
" delta phi of segment : " <<
fDPhi/
degree <<
" degrees \n"
2785 <<
" starting theta of segment: " <<
fSTheta/
degree <<
" degrees \n"
2786 <<
" delta theta of segment : " <<
fDTheta/
degree <<
" degrees \n"
2787 <<
"-----------------------------------------------------------\n";
2788 os.precision(oldprc);
2799 G4double zRand, aOne, aTwo, aThr, aFou, aFiv, chose, phi, sinphi, cosphi;
2800 G4double height1, height2, slant1, slant2, costheta, sintheta, rRand;
2815 cosphi = std::cos(phi);
2816 sinphi = std::sin(phi);
2818 sintheta = std::sqrt(1.-
sqr(costheta));
2827 if( (chose>=0.) && (chose<aOne) )
2832 else if( (chose>=aOne) && (chose<aOne+aTwo) )
2837 else if( (chose>=aOne+aTwo) && (chose<aOne+aTwo+aThr) )
2850 else if( (chose>=aOne+aTwo+aThr) && (chose<aOne+aTwo+aThr+aFou) )
2863 else if( (chose>=aOne+aTwo+aThr+aFou) && (chose<aOne+aTwo+aThr+aFou+aFiv) )
2866 rRand*sintheta*
sinSPhi,rRand*costheta);
2871 rRand*sintheta*
sinEPhi,rRand*costheta);
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
void set(double x, double y, double z)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
CLHEP::Hep3Vector G4ThreeVector
G4Sphere(const G4String &pName, G4double pRmin, G4double pRmax, G4double pSPhi, G4double pDPhi, G4double pSTheta, G4double pDTheta)
void CheckThetaAngles(G4double sTheta, G4double dTheta)
G4double GetCosEndTheta() const
std::vector< ExP01TrackerHit * > a
virtual void AddSolid(const G4Box &)=0
static const G4double kInfinity
std::ostream & StreamInfo(std::ostream &os) const
G4Polyhedron * CreatePolyhedron() const
EInside Inside(const G4ThreeVector &p) const
static constexpr double mm
G4CSGSolid & operator=(const G4CSGSolid &rhs)
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
G4double GetSinStartPhi() const
G4double GetCosStartPhi() const
void message(RunManager *runmanager)
G4double GetRadiusInRing(G4double rmin, G4double rmax) const
G4double GetAngularTolerance() const
G4GeometryType GetEntityType() const
G4double GetRadialTolerance() const
G4double halfCarTolerance
G4VisExtent GetExtent() const
void DescribeYourselfTo(G4VGraphicsScene &scene) const
G4double GetCosStartTheta() const
G4double GetSurfaceArea()
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
static constexpr double twopi
static constexpr double halfpi
G4double GetSinEndTheta() const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
void CheckPhiAngles(G4double sPhi, G4double dPhi)
G4double GetCosEndPhi() const
G4ThreeVector GetPointOnSurface() const
G4double GetStartThetaAngle() const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
ThreeVector shoot(const G4int Ap, const G4int Af)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4double halfAngTolerance
G4double GetSinStartTheta() const
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=G4bool(false), G4bool *validNorm=0, G4ThreeVector *n=0) const
G4double GetDeltaThetaAngle() const
static constexpr double degree
G4GLOB_DLL std::ostream G4cout
G4Sphere & operator=(const G4Sphere &rhs)
G4double GetDeltaPhiAngle() const
static G4GeometryTolerance * GetInstance()
G4double GetSinEndPhi() const
static constexpr double pi
G4double GetOuterRadius() const
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4double GetInnerRadius() const