48 #if !(defined(G4GEOM_USE_UHYPE) && defined(G4GEOM_USE_SYS_USOLIDS))
73 using namespace CLHEP;
82 :
G4VSolid(pName), fCubicVolume(0.), fSurfaceArea(0.),
83 fRebuildPolyhedron(false), fpPolyhedron(0)
93 <<
" Invalid Z half-length: "
94 << newHalfLenZ/
mm <<
" mm";
102 if (newInnerRadius<0 || newOuterRadius<0)
106 <<
" Invalid radii ! Inner radius: "
107 << newInnerRadius/
mm <<
" mm" <<
G4endl
109 << newOuterRadius/
mm <<
" mm";
113 if (newInnerRadius >= newOuterRadius)
117 <<
" Invalid radii ! Inner radius: "
118 << newInnerRadius/
mm <<
" mm" <<
G4endl
120 << newOuterRadius/
mm <<
" mm";
141 :
G4VSolid(a), innerRadius(0.), outerRadius(0.), halfLenZ(0.), innerStereo(0.),
142 outerStereo(0.), tanInnerStereo(0.), tanOuterStereo(0.), tanInnerStereo2(0.),
143 tanOuterStereo2(0.), innerRadius2(0.), outerRadius2(0.), endInnerRadius2(0.),
144 endOuterRadius2(0.), endInnerRadius(0.), endOuterRadius(0.),
145 fCubicVolume(0.), fSurfaceArea(0.), fHalfTol(0.),
146 fRebuildPolyhedron(false), fpPolyhedron(0)
164 :
G4VSolid(rhs), innerRadius(rhs.innerRadius),
165 outerRadius(rhs.outerRadius), halfLenZ(rhs.halfLenZ),
166 innerStereo(rhs.innerStereo), outerStereo(rhs.outerStereo),
167 tanInnerStereo(rhs.tanInnerStereo), tanOuterStereo(rhs.tanOuterStereo),
168 tanInnerStereo2(rhs.tanInnerStereo2), tanOuterStereo2(rhs.tanOuterStereo2),
169 innerRadius2(rhs.innerRadius2), outerRadius2(rhs.outerRadius2),
170 endInnerRadius2(rhs.endInnerRadius2), endOuterRadius2(rhs.endOuterRadius2),
171 endInnerRadius(rhs.endInnerRadius), endOuterRadius(rhs.endOuterRadius),
172 fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea),
173 fHalfTol(rhs.fHalfTol), fRebuildPolyhedron(false), fpPolyhedron(0)
185 if (
this == &rhs) {
return *
this; }
232 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
235 message <<
"Bad bounding box (min >= max) for solid: "
237 <<
"\npMin = " << pMin
238 <<
"\npMax = " << pMax;
239 G4Exception(
"G4Hype::BoundingLimits()",
"GeomMgt0001",
330 if (dist2Inner < dist2Z && dist2Inner < dist2Outer)
337 if (dist2Z < dist2Outer)
390 G4bool couldMissOuter(
true),
391 couldMissInner(
true),
392 cantMissInnerCylinder(
false);
442 yi = p.
y() + q*v.
y();
470 cantMissInnerCylinder =
true;
548 if (zi < -halfLenZ)
continue;
549 if (zi > +halfLenZ && couldMissOuter)
continue;
555 yi = p.
y() + q[i]*v.
y();
573 if (cantMissInnerCylinder)
return (sigz <
fHalfTol) ? 0 : -sigz/vz;
601 if (q[i] > best)
break;
611 if (zi < -halfLenZ)
continue;
612 if (zi > +halfLenZ && couldMissInner)
continue;
618 yi = p.
y() + q[i]*v.
y();
680 G4double answer = std::sqrt( dr*dr + sigz*sigz );
681 return answer <
fHalfTol ? 0 : answer;
701 G4double answer = std::sqrt( dr*dr + sigz*sigz );
702 return answer <
fHalfTol ? 0 : answer;
714 return answer <
fHalfTol ? 0 : answer;
722 return answer <
fHalfTol ? 0 : answer;
769 if (calcNorm) { *norm = *nBest; *validNorm =
true; }
801 if (normHere.dot(v) > 0)
803 if (calcNorm) { *norm = normHere.
unit(); *validNorm =
false; }
814 if (q[i] > sBest)
break;
823 if (norm1.
dot(v) > 0)
849 if (normHere.dot(v) > 0)
853 *norm = normHere.
unit();
866 if (q[i] > sBest)
break;
871 if (norm2.
dot(v) > 0)
890 if (nBest == &norm1 || nBest == &norm2)
891 *norm = nBest->
unit();
916 if (tryOuter < sBest)
922 if (tryInner < sBest) sBest = tryInner;
974 G4double a = tx*tx + ty*ty - tz*tz*tan2Phi;
975 G4double b = 2*( x0*tx + y0*ty -
z0*tz*tan2Phi );
984 if (std::fabs(b) <
DBL_MIN)
return 0;
994 if (radical < -
DBL_MIN)
return 0;
1005 radical = std::sqrt(radical);
1007 G4double q = -0.5*( b + (b < 0 ? -radical : +radical) );
1010 if (sa < sb) { ss[0] = sa; ss[1] = sb; }
else { ss[0] = sb; ss[1] = sa; }
1039 if (tanPhi <
DBL_MIN)
return pr-r0;
1047 G4double r1 = std::sqrt( r0*r0 + z1*z1*tan2Phi );
1052 G4double z2 = (pr*tanPhi + pz)/(1 + tan2Phi);
1053 G4double r2 = std::sqrt( r0*r0 + z2*z2*tan2Phi );
1070 return std::sqrt( dr*dr + dz*dz );
1076 return std::fabs((pr-r1)*dz - (pz-z1)*dr)/
len;
1097 if (tan2Phi <
DBL_MIN)
return r0 - pr;
1102 G4double rh = std::sqrt( r0*r0 + pz*pz*tan2Phi );
1111 return std::fabs((pr-rh)*dr)/
len;
1129 return new G4Hype(*
this);
1160 G4int oldprc = os.precision(16);
1161 os <<
"-----------------------------------------------------------\n"
1162 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
1163 <<
" ===================================================\n"
1164 <<
" Solid type: G4Hype\n"
1165 <<
" Parameters: \n"
1166 <<
" half length Z: " <<
halfLenZ/
mm <<
" mm \n"
1171 <<
"-----------------------------------------------------------\n";
1172 os.precision(oldprc);
1184 G4double xRand, yRand, zRand, r2 , aOne, aTwo, aThree, chose, sinhu;
1185 G4double phi, cosphi, sinphi, rBar2Out, rBar2In,
alpha, t, rOut, rIn2, rOut2;
1194 t = std::log(t+std::sqrt(
sqr(t)+1));
1195 aOne = std::fabs(2.*alpha*(std::sinh(2.*t)/4.+t/2.));
1201 t = std::log(t+std::sqrt(
sqr(t)+1));
1202 aTwo = std::fabs(2.*alpha*(std::sinh(2.*t)/4.+t/2.));
1211 cosphi = std::cos(phi);
1212 sinphi = std::sin(phi);
1217 if(chose>=0. && chose < aOne)
1232 else if(chose>=aOne && chose<aOne+aTwo)
1249 else if(chose>=aOne+aTwo && chose<aOne+aTwo+aThree)
1253 rOut = std::sqrt(rOut2) ;
1259 r2 = xRand*xRand + yRand*yRand ;
1260 }
while ( ! ( r2 >= rIn2 && r2 <= rOut2 ) ) ;
1269 rOut = std::sqrt(rOut2) ;
1275 r2 = xRand*xRand + yRand*yRand ;
1276 }
while ( ! ( r2 >= rIn2 && r2 <= rOut2 ) ) ;
1341 return std::log(arg+std::sqrt(
sqr(arg)+1));
1344 #endif // !defined(G4GEOM_USE_UHYPE) || !defined(G4GEOM_USE_SYS_USOLIDS)
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
void set(double x, double y, double z)
G4double HypeInnerRadius2(G4double zVal) const
CLHEP::Hep3Vector G4ThreeVector
G4Polyhedron * CreatePolyhedron() const
std::vector< ExP01TrackerHit * > a
virtual void AddSolid(const G4Box &)=0
static const G4double kInfinity
static G4double ApproxDistOutside(G4double pr, G4double pz, G4double r0, G4double tanPhi)
static constexpr double mm
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
void message(RunManager *runmanager)
void SetOuterStereo(G4double newOSte)
G4VisExtent GetExtent() const
virtual G4double GetSurfaceArea()
G4double HypeOuterRadius2(G4double zVal) const
G4double GetSurfaceArea()
G4double asinh(G4double arg)
double dot(const Hep3Vector &) const
G4Hype(const G4String &pName, G4double newInnerRadius, G4double newOuterRadius, G4double newInnerStereo, G4double newOuterStereo, G4double newHalfLenZ)
G4double GetCubicVolume()
static G4double ApproxDistInside(G4double pr, G4double pz, G4double r0, G4double tan2Phi)
void DescribeYourselfTo(G4VGraphicsScene &scene) const
G4VSolid & operator=(const G4VSolid &rhs)
G4Hype & operator=(const G4Hype &rhs)
#define G4MUTEX_INITIALIZER
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
G4GeometryType GetEntityType() const
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
static const G4double alpha
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
ThreeVector shoot(const G4int Ap, const G4int Af)
EInside Inside(const G4ThreeVector &p) const
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=G4bool(false), G4bool *validNorm=0, G4ThreeVector *n=0) const
static G4int IntersectHype(const G4ThreeVector &p, const G4ThreeVector &v, G4double r2, G4double tan2Phi, G4double s[2])
static G4int GetNumberOfRotationSteps()
G4Polyhedron * GetPolyhedron() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4int GetNumberOfRotationStepsAtTimeOfCreation() const
G4bool fRebuildPolyhedron
G4bool InnerSurfaceExists() const
virtual G4double GetCubicVolume()
static constexpr double degree
static constexpr double pi
G4ThreeVector GetPointOnSurface() const
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
std::ostream & StreamInfo(std::ostream &os) const
void SetInnerStereo(G4double newISte)
G4Polyhedron * fpPolyhedron