40 #if !(defined(G4GEOM_USE_UPARABOLOID) && defined(G4GEOM_USE_SYS_USOLIDS))
60 using namespace CLHEP;
70 :
G4VSolid(pName), fRebuildPolyhedron(false), fpPolyhedron(0),
71 fSurfaceArea(0.), fCubicVolume(0.)
74 if( (pDz <= 0.) || (pR2 <= pR1) || (pR1 < 0.) )
76 std::ostringstream message;
77 message <<
"Invalid dimensions. Negative Input Values or R1>=R2 - "
79 G4Exception(
"G4Paraboloid::G4Paraboloid()",
"GeomSolids0002",
81 "Z half-length must be larger than zero or R1>=R2.");
93 k1 = (r2 * r2 - r1 * r1) / 2 / dz;
94 k2 = (r2 * r2 + r1 * r1) / 2;
103 :
G4VSolid(a), fRebuildPolyhedron(false), fpPolyhedron(0),
104 fSurfaceArea(0.), fCubicVolume(0.),
105 dz(0.), r1(0.), r2(0.), k1(0.), k2(0.)
123 :
G4VSolid(rhs), fRebuildPolyhedron(false), fpPolyhedron(0),
124 fSurfaceArea(rhs.fSurfaceArea), fCubicVolume(rhs.fCubicVolume),
125 dz(rhs.dz), r1(rhs.r1), r2(rhs.r2), k1(rhs.k1), k2(rhs.k2)
138 if (
this == &rhs) {
return *
this; }
146 fSurfaceArea = rhs.fSurfaceArea; fCubicVolume = rhs.fCubicVolume;
147 dz = rhs.dz; r1 = rhs.r1; r2 = rhs.r2; k1 = rhs.k1; k2 = rhs.k2;
172 pMin.
set(-r2,-r2,-dz);
173 pMax.
set( r2, r2, dz);
177 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
179 std::ostringstream message;
180 message <<
"Bad bounding box (min >= max) for solid: "
182 <<
"\npMin = " << pMin
183 <<
"\npMax = " << pMax;
223 if(
A < 0 &&
sqr(
A) > rhoSurfTimesTol2)
228 if(std::fabs(p.
z()) > dz - 0.5 * kCarTolerance)
240 else if(
A <= 0 ||
sqr(
A) < rhoSurfTimesTol2)
313 if(A < 0 &&
sqr(A) > rhoSurfTimesTol2)
320 else if(A <= 0 ||
sqr(A) < rhoSurfTimesTol2)
334 std::ostringstream message;
335 message <<
"No normal defined for this point p." <<
G4endl
336 <<
" p = " << 1 /
mm * p <<
" mm";
337 G4Exception(
"G4Paraboloid::SurfaceNormal(p)",
"GeomSolids1002",
356 if(r2 && p.
z() > - tolh + dz)
363 if(
sqr(p.
x() + v.
x()*intersection)
364 +
sqr(p.
y() + v.
y()*intersection) <
sqr(r2 + 0.5 * kCarTolerance))
366 if(p.
z() < tolh + dz)
369 {
return intersection; }
377 else if(r1 && p.
z() < tolh - dz)
383 G4double intersection = (-dz - p.
z()) / v.
z();
384 if(
sqr(p.
x() + v.
x()*intersection)
385 +
sqr(p.
y() + v.
y()*intersection) <
sqr(r1 + 0.5 * kCarTolerance))
387 if(p.
z() > -tolh - dz)
404 vRho2 = v.
perp2(), intersection,
405 B = (k1 * p.
z() + k2 - rho2) * vRho2;
407 if ( ( (rho2 > paraRho2) && (
sqr(rho2-paraRho2-0.25*tol2) > tol2*paraRho2) )
415 intersection = ((rho2 - k2)/k1 - p.
z())/v.
z();
416 if(intersection < 0) {
return kInfinity; }
417 else if(std::fabs(p.
z() + v.
z() * intersection) <= dz)
432 intersection = (A - std::sqrt(B +
sqr(A))) / vRho2;
437 else if(std::fabs(p.
z() + intersection * v.
z()) < dz + tolh)
447 else if(
sqr(rho2 - paraRho2 - .25 * tol2) <= tol2 * paraRho2)
459 std::ostringstream message;
466 message <<
"Likely a problem in this function, for solid: " <<
GetName()
469 message <<
" p = " << p * (1/
mm) <<
" mm" <<
G4endl
470 <<
" v = " << v * (1/
mm) <<
" mm";
471 G4Exception(
"G4Paraboloid::DistanceToIn(p,v)",
"GeomSolids1002",
485 if(safz<0) { safz=0; }
495 if(safr>safz) { safz=safr; }
499 G4double sqprho = std::sqrt(paraRho);
501 if(dRho<0) {
return safz; }
505 if(tmp<0.) {
return safz; }
507 G4double salf = talf/std::sqrt(tmp);
508 safr = std::fabs(dRho*salf);
509 if(safr>safz) { safz=safr; }
529 if(calcNorm) { *validNorm =
false; }
545 if ( rho2 < paraRho2 &&
sqr(rho2 - paraRho2 - 0.25 * tol2) > tol2 * paraRho2
546 && std::fabs(p.
z()) < dz - kCarTolerance)
557 intersection = (dz - p.
z()) / v.
z();
560 if(ip.
perp2() <
sqr(r2 + kCarTolerance))
565 if(r2 < tolh || ip.
perp2() >
sqr(r2 - tolh))
582 intersection = (-dz - p.
z()) / v.
z();
590 if(r1 < tolh || ip.
perp2() >
sqr(r1 - tolh))
605 intersection = ((rho2 - k2)/k1 - p.
z())/v.
z();
616 else if( ((A <= 0) && (B >=
sqr(A) * (
sqr(vRho2) - 1))) || (A >= 0))
623 B = (k1 * p.
z() + k2 - rho2)/vRho2;
624 intersection = B/(-A + std::sqrt(B +
sqr(A)));
634 std::ostringstream message;
635 message <<
"There is no intersection between given line and solid!"
639 G4Exception(
"G4Paraboloid::DistanceToOut(p,v,...)",
"GeomSolids1002",
644 else if ( (rho2 < paraRho2 + kCarTolerance
645 ||
sqr(rho2 - paraRho2 - 0.25 * tol2) < tol2 * paraRho2 )
646 && std::fabs(p.
z()) < dz + tolh)
652 if(std::fabs(p.
z()) > dz - tolh)
656 if( ((v.
z() > 0) && (p.
z() > 0)) || ((v.
z() < 0) && (p.
z() < 0)) )
678 intersection = (-pDotV + std::sqrt(A +
sqr(pDotV))) / vRho2;
686 * intersection, -k1/2).unit()).unit();
716 intersection = (dz - p.
z()) / v.
z();
728 else if(ip.
perp2() <
sqr(r2 + tolh))
744 intersection = (-dz - p.
z()) / v.
z();
756 else if(ip.
perp2() <
sqr(r1 + tolh))
771 if(std::fabs(vRho2) > tol2)
774 B = (k1 * p.
z() + k2 - rho2);
778 intersection = B/(-A + std::sqrt(B +
sqr(A)));
782 if(normal.
dot(v) >= 0)
796 intersection = ((rho2 - k2) / k1 - p.
z()) / v.
z();
803 + intersection * v.
y(), - k1 / 2);
813 G4Exception(
"G4Paraboloid::DistanceToOut(p,v,...)",
"GeomSolids1002",
817 G4Exception(
"G4Paraboloid::DistanceToOut(p,v,...)",
"GeomSolids1002",
818 JustWarning,
"There's an error in this functions code.");
839 std::ostringstream message;
840 G4int oldprc = message.precision(16);
841 message <<
"Point p is outside !?" << G4endl
842 <<
"Position:" << G4endl
843 <<
" p.x() = " << p.
x()/
mm <<
" mm" << G4endl
844 <<
" p.y() = " << p.
y()/
mm <<
" mm" << G4endl
845 <<
" p.z() = " << p.
z()/
mm <<
" mm";
846 message.precision(oldprc) ;
847 G4Exception(
"G4Paraboloid::DistanceToOut(p)",
"GeomSolids1002",
853 safeZ = dz - std::fabs(p.
z()) ;
855 tanRMax = (r2 - r1)*0.5/dz ;
856 secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
857 pRMax = tanRMax*p.
z() + (r1+r2)*0.5 ;
858 safeR = (pRMax - rho)/secRMax ;
860 if (safeZ < safeR) { safe = safeZ; }
861 else { safe = safeR; }
890 G4int oldprc = os.precision(16);
891 os <<
"-----------------------------------------------------------\n"
892 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
893 <<
" ===================================================\n"
894 <<
" Solid type: G4Paraboloid\n"
896 <<
" z half-axis: " << dz/
mm <<
" mm \n"
897 <<
" radius at -dz: " << r1/
mm <<
" mm \n"
898 <<
" radius at dz: " << r2/
mm <<
" mm \n"
899 <<
"-----------------------------------------------------------\n";
900 os.precision(oldprc);
917 if(
pi *
sqr(r1) / A > z)
920 return G4ThreeVector(rho * std::cos(phi), rho * std::sin(phi), -dz);
925 return G4ThreeVector(rho * std::cos(phi), rho * std::sin(phi), dz);
932 std::sqrt(z*k1 + k2)*std::sin(phi), z);
967 #endif // !defined(G4GEOM_USE_UPARABOLOID) || !defined(G4GEOM_USE_SYS_USOLIDS)
void set(double x, double y, double z)
ThreeVector shoot(const G4int Ap, const G4int Af)
static constexpr double mm
static const G4double kInfinity
CLHEP::Hep3Vector G4ThreeVector
G4Polyhedron * fpPolyhedron
double dot(const Hep3Vector &) const
std::vector< ExP01TrackerHit * > a
G4Paraboloid & operator=(const G4Paraboloid &rhs)
G4GeometryType GetEntityType() const
double B(double temperature)
virtual void AddSolid(const G4Box &)=0
#define G4MUTEX_INITIALIZER
G4double CalculateSurfaceArea() const
static constexpr double twopi
static double normal(HepRandomEngine *eptr)
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
void DescribeYourselfTo(G4VGraphicsScene &scene) const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=G4bool(false), G4bool *validNorm=0, G4ThreeVector *n=0) const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
EInside Inside(const G4ThreeVector &p) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
std::ostream & StreamInfo(std::ostream &os) const
static G4int GetNumberOfRotationSteps()
G4ThreeVector GetPointOnSurface() const
G4VSolid & operator=(const G4VSolid &rhs)
G4int GetNumberOfRotationStepsAtTimeOfCreation() const
static constexpr double pi
G4Polyhedron * GetPolyhedron() const
G4Paraboloid(const G4String &pName, G4double pDz, G4double pR1, G4double pR2)
G4Polyhedron * CreatePolyhedron() const
void Extent(G4ThreeVector &pMin, G4ThreeVector &pMax) const
G4bool fRebuildPolyhedron