36 #if !(defined(G4GEOM_USE_UPARABOLOID) && defined(G4GEOM_USE_SYS_USOLIDS))
56 using namespace CLHEP;
68 if( (pDz <= 0.) || (pR2 <= pR1) || (pR1 < 0.) )
71 message <<
"Invalid dimensions. Negative Input Values or R1>=R2 - "
73 G4Exception(
"G4Paraboloid::G4Paraboloid()",
"GeomSolids0002",
75 "Z half-length must be larger than zero or R1>=R2.");
116 fSurfaceArea(rhs.fSurfaceArea), fCubicVolume(rhs.fCubicVolume),
129 if (
this == &rhs) {
return *
this; }
157 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
160 message <<
"Bad bounding box (min >= max) for solid: "
162 <<
"\npMin = " << pMin
163 <<
"\npMax = " <<
pMax;
164 G4Exception(
"G4Paraboloid::BoundingLimits()",
"GeomMgt0001",
204 if(
A < 0 &&
sqr(
A) > rhoSurfTimesTol2)
209 if(std::fabs(p.
z()) >
dz - 0.5 * kCarTolerance)
221 else if(
A <= 0 ||
sqr(
A) < rhoSurfTimesTol2)
295 if(A < 0 &&
sqr(A) > rhoSurfTimesTol2)
302 else if(A <= 0 ||
sqr(A) < rhoSurfTimesTol2)
317 message <<
"No normal defined for this point p." <<
G4endl
318 <<
" p = " << 1 /
mm * p <<
" mm";
319 G4Exception(
"G4Paraboloid::SurfaceNormal(p)",
"GeomSolids1002",
338 if(
r2 && p.
z() > - tolh +
dz)
345 if(
sqr(p.
x() + v.
x()*intersection)
346 +
sqr(p.
y() + v.
y()*intersection) <
sqr(
r2 + 0.5 * kCarTolerance))
348 if(p.
z() < tolh +
dz)
351 {
return intersection; }
359 else if(
r1 && p.
z() < tolh -
dz)
366 if(
sqr(p.
x() + v.
x()*intersection)
367 +
sqr(p.
y() + v.
y()*intersection) <
sqr(
r1 + 0.5 * kCarTolerance))
369 if(p.
z() > -tolh -
dz)
386 vRho2 = v.
perp2(), intersection,
387 B = (
k1 * p.
z() +
k2 - rho2) * vRho2;
389 if ( ( (rho2 > paraRho2) && (
sqr(rho2-paraRho2-0.25*tol2) > tol2*paraRho2) )
397 intersection = ((rho2 -
k2)/
k1 - p.
z())/v.
z();
398 if(intersection < 0) {
return kInfinity; }
399 else if(std::fabs(p.
z() + v.
z() * intersection) <=
dz)
414 intersection = (A - std::sqrt(B +
sqr(A))) / vRho2;
419 else if(std::fabs(p.
z() + intersection * v.
z()) <
dz + tolh)
429 else if(
sqr(rho2 - paraRho2 - .25 * tol2) <= tol2 * paraRho2)
448 message <<
"Likely a problem in this function, for solid: " <<
GetName()
451 message <<
" p = " << p * (1/
mm) <<
" mm" <<
G4endl
452 <<
" v = " << v * (1/
mm) <<
" mm";
453 G4Exception(
"G4Paraboloid::DistanceToIn(p,v)",
"GeomSolids1002",
467 if(safz<0.) { safz=0.; }
477 if(safr>safz) { safz=safr; }
481 G4double sqprho = std::sqrt(paraRho);
483 if(dRho<0.) {
return safz; }
487 if(tmp<0.) {
return safz; }
489 G4double salf = talf/std::sqrt(tmp);
490 safr = std::fabs(dRho*salf);
491 if(safr>safz) { safz=safr; }
511 if(calcNorm) { *validNorm =
false; }
527 if ( rho2 < paraRho2 &&
sqr(rho2 - paraRho2 - 0.25 * tol2) > tol2 * paraRho2
528 && std::fabs(p.
z()) <
dz - kCarTolerance)
539 intersection = (
dz - p.
z()) / v.
z();
564 intersection = (-
dz - p.
z()) / v.
z();
587 intersection = ((rho2 -
k2)/
k1 - p.
z())/v.
z();
598 else if( ((A <= 0) && (B >=
sqr(A) * (
sqr(vRho2) - 1))) || (A >= 0))
605 B = (
k1 * p.
z() +
k2 - rho2)/vRho2;
606 intersection = B/(-A + std::sqrt(B +
sqr(A)));
617 message <<
"There is no intersection between given line and solid!"
621 G4Exception(
"G4Paraboloid::DistanceToOut(p,v,...)",
"GeomSolids1002",
626 else if ( (rho2 < paraRho2 + kCarTolerance
627 ||
sqr(rho2 - paraRho2 - 0.25 * tol2) < tol2 * paraRho2 )
628 && std::fabs(p.
z()) <
dz + tolh)
634 if(std::fabs(p.
z()) >
dz - tolh)
638 if( ((v.
z() > 0) && (p.
z() > 0)) || ((v.
z() < 0) && (p.
z() < 0)) )
660 intersection = (-pDotV + std::sqrt(A +
sqr(pDotV))) / vRho2;
668 * intersection, -
k1/2).unit()).unit();
698 intersection = (
dz - p.
z()) / v.
z();
726 intersection = (-
dz - p.
z()) / v.
z();
753 if(std::fabs(vRho2) > tol2)
756 B = (
k1 * p.
z() +
k2 - rho2);
760 intersection = B/(-A + std::sqrt(B +
sqr(A)));
764 if(normal.
dot(v) >= 0)
778 intersection = ((rho2 -
k2) /
k1 - p.
z()) / v.
z();
785 + intersection * v.
y(), -
k1 / 2);
795 G4Exception(
"G4Paraboloid::DistanceToOut(p,v,...)",
"GeomSolids1002",
799 G4Exception(
"G4Paraboloid::DistanceToOut(p,v,...)",
"GeomSolids1002",
800 JustWarning,
"There's an error in this functions code.");
822 G4int oldprc = message.precision(16);
823 message <<
"Point p is outside !?" << G4endl
824 <<
"Position:" << G4endl
825 <<
" p.x() = " << p.
x()/
mm <<
" mm" << G4endl
826 <<
" p.y() = " << p.
y()/
mm <<
" mm" << G4endl
827 <<
" p.z() = " << p.
z()/
mm <<
" mm";
828 message.precision(oldprc) ;
829 G4Exception(
"G4Paraboloid::DistanceToOut(p)",
"GeomSolids1002",
835 safeZ =
dz - std::fabs(p.
z()) ;
837 tanRMax = (
r2 -
r1)*0.5/
dz ;
838 secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
839 pRMax = tanRMax*p.
z() + (
r1+
r2)*0.5 ;
840 safeR = (pRMax - rho)/secRMax ;
842 if (safeZ < safeR) { safe = safeZ; }
843 else { safe = safeR; }
872 G4int oldprc = os.precision(16);
873 os <<
"-----------------------------------------------------------\n"
874 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
875 <<
" ===================================================\n"
876 <<
" Solid type: G4Paraboloid\n"
878 <<
" z half-axis: " <<
dz/
mm <<
" mm \n"
879 <<
" radius at -dz: " <<
r1/
mm <<
" mm \n"
880 <<
" radius at dz: " <<
r2/
mm <<
" mm \n"
881 <<
"-----------------------------------------------------------\n";
882 os.precision(oldprc);
914 std::sqrt(z*
k1 +
k2)*std::sin(phi), z);
948 #endif // !defined(G4GEOM_USE_UPARABOLOID) || !defined(G4GEOM_USE_SYS_USOLIDS)