64 using namespace CLHEP;
73 :
G4VSolid(pName), fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0)
81 std::ostringstream message;
83 <<
" Invalid Z half-length: "
84 << newHalfLenZ/
mm <<
" mm";
92 if (newInnerRadius<0 || newOuterRadius<0)
94 std::ostringstream message;
96 <<
" Invalid radii ! Inner radius: "
97 << newInnerRadius/
mm <<
" mm" <<
G4endl
99 << newOuterRadius/
mm <<
" mm";
103 if (newInnerRadius >= newOuterRadius)
105 std::ostringstream message;
107 <<
" Invalid radii ! Inner radius: "
108 << newInnerRadius/
mm <<
" mm" <<
G4endl
110 << newOuterRadius/
mm <<
" mm";
131 :
G4VSolid(a), innerRadius(0.), outerRadius(0.), halfLenZ(0.), innerStereo(0.),
132 outerStereo(0.), tanInnerStereo(0.), tanOuterStereo(0.), tanInnerStereo2(0.),
133 tanOuterStereo2(0.), innerRadius2(0.), outerRadius2(0.), endInnerRadius2(0.),
134 endOuterRadius2(0.), endInnerRadius(0.), endOuterRadius(0.),
135 fCubicVolume(0.), fSurfaceArea(0.), fHalfTol(0.), fpPolyhedron(0)
153 :
G4VSolid(rhs), innerRadius(rhs.innerRadius),
154 outerRadius(rhs.outerRadius), halfLenZ(rhs.halfLenZ),
155 innerStereo(rhs.innerStereo), outerStereo(rhs.outerStereo),
156 tanInnerStereo(rhs.tanInnerStereo), tanOuterStereo(rhs.tanOuterStereo),
157 tanInnerStereo2(rhs.tanInnerStereo2), tanOuterStereo2(rhs.tanOuterStereo2),
158 innerRadius2(rhs.innerRadius2), outerRadius2(rhs.outerRadius2),
159 endInnerRadius2(rhs.endInnerRadius2), endOuterRadius2(rhs.endOuterRadius2),
160 endInnerRadius(rhs.endInnerRadius), endOuterRadius(rhs.endOuterRadius),
161 fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea),
162 fHalfTol(rhs.fHalfTol), fpPolyhedron(0)
175 if (
this == &rhs) {
return *
this; }
227 G4double rFudge = 1.0/std::cos(0.5*sigPhi);
280 cosPhi = std::cos(phi),
281 sinPhi = std::sin(phi);
289 w0, w1, w2, w3, w4, w5, w6;
347 if (numPhi == 1) phi = 0;
348 cosPhi = std::cos(phi),
349 sinPhi = std::sin(phi);
440 if (splitOuter) v4 = w4;
442 }
while( --numPhi > 0 );
495 phiPoly.
SetNormal( (v1-v0).cross(w0-v0).unit() );
509 const G4double absZ(std::fabs(p.z()));
516 const G4double xR2( p.x()*p.x()+p.y()*p.y() );
553 const G4double absZ(std::fabs(p.z()));
557 const G4double xR2( p.x()*p.x()+p.y()*p.y() );
566 if (dist2Inner < dist2Z && dist2Inner < dist2Outer)
573 if (dist2Z < dist2Outer)
626 G4bool couldMissOuter(
true),
627 couldMissInner(
true),
628 cantMissInnerCylinder(
false);
653 G4double pr2 = p.x()*p.x() + p.y()*p.y();
678 yi = p.y() + q*v.y();
705 && ((std::fabs(v.x()) >
DBL_MIN) || (std::fabs(v.y()) >
DBL_MIN)) )
706 cantMissInnerCylinder =
true;
716 G4double dotR( xi*v.x() + yi*v.y() );
784 if (zi < -halfLenZ)
continue;
785 if (zi > +halfLenZ && couldMissOuter)
continue;
791 yi = p.y() + q[i]*v.y();
809 if (cantMissInnerCylinder)
return (sigz <
fHalfTol) ? 0 : -sigz/vz;
837 if (q[i] > best)
break;
847 if (zi < -halfLenZ)
continue;
848 if (zi > +halfLenZ && couldMissInner)
continue;
854 yi = p.y() + q[i]*v.y();
896 G4double r2 = p.x()*p.x() + p.y()*p.y();
916 G4double answer = std::sqrt( dr*dr + sigz*sigz );
917 return answer <
fHalfTol ? 0 : answer;
937 G4double answer = std::sqrt( dr*dr + sigz*sigz );
938 return answer <
fHalfTol ? 0 : answer;
950 return answer <
fHalfTol ? 0 : answer;
958 return answer <
fHalfTol ? 0 : answer;
1005 if (calcNorm) { *norm = *nBest; *validNorm =
true; }
1018 G4double r2 = p.x()*p.x() + p.y()*p.y();
1037 if (normHere.dot(v) > 0)
1039 if (calcNorm) { *norm = normHere.unit(); *validNorm =
false; }
1048 for( i=0; i<
n; i++ )
1050 if (q[i] > sBest)
break;
1059 if (norm1.dot(v) > 0)
1085 if (normHere.dot(v) > 0)
1089 *norm = normHere.unit();
1100 for( i=0; i<
n; i++ )
1102 if (q[i] > sBest)
break;
1107 if (norm2.dot(v) > 0)
1126 if (nBest == &norm1 || nBest == &norm2)
1127 *norm = nBest->unit();
1152 if (tryOuter < sBest)
1158 if (tryInner < sBest) sBest = tryInner;
1208 G4double tx = v.x(), ty = v.y(), tz = v.z();
1210 G4double a = tx*tx + ty*ty - tz*tz*tan2Phi;
1211 G4double b = 2*( x0*tx + y0*ty -
z0*tz*tan2Phi );
1220 if (std::fabs(b) <
DBL_MIN)
return 0;
1229 if (radical < -
DBL_MIN)
return 0;
1240 radical = std::sqrt(radical);
1242 G4double q = -0.5*( b + (b < 0 ? -radical : +radical) );
1245 if (sa < sb) { ss[0] = sa; ss[1] = sb; }
else { ss[0] = sb; ss[1] = sa; }
1274 if (tanPhi <
DBL_MIN)
return pr-r0;
1282 G4double r1 = std::sqrt( r0*r0 + z1*z1*tan2Phi );
1287 G4double z2 = (pr*tanPhi + pz)/(1 + tan2Phi);
1288 G4double r2 = std::sqrt( r0*r0 + z2*z2*tan2Phi );
1296 G4double len = std::sqrt(dr*dr + dz*dz);
1305 return std::sqrt( dr*dr + dz*dz );
1311 return std::fabs((pr-r1)*dz - (pz-z1)*dr)/len;
1332 if (tan2Phi <
DBL_MIN)
return r0 - pr;
1337 G4double rh = std::sqrt( r0*r0 + pz*pz*tan2Phi );
1341 G4double len = std::sqrt(dr*dr + dz*dz);
1346 return std::fabs((pr-rh)*dr)/len;
1364 return new G4Hype(*
this);
1395 G4int oldprc = os.precision(16);
1396 os <<
"-----------------------------------------------------------\n"
1397 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
1398 <<
" ===================================================\n"
1399 <<
" Solid type: G4Hype\n"
1400 <<
" Parameters: \n"
1401 <<
" half length Z: " <<
halfLenZ/
mm <<
" mm \n"
1406 <<
"-----------------------------------------------------------\n";
1407 os.precision(oldprc);
1419 G4double xRand, yRand, zRand, r2 , aOne, aTwo, aThree, chose, sinhu;
1420 G4double phi, cosphi, sinphi, rBar2Out, rBar2In,
alpha, t, rOut, rIn2, rOut2;
1429 t = std::log(t+std::sqrt(
sqr(t)+1));
1430 aOne = std::fabs(2.*alpha*(std::sinh(2.*t)/4.+t/2.));
1436 t = std::log(t+std::sqrt(
sqr(t)+1));
1437 aTwo = std::fabs(2.*alpha*(std::sinh(2.*t)/4.+t/2.));
1446 cosphi = std::cos(phi);
1447 sinphi = std::sin(phi);
1452 if(chose>=0. && chose < aOne)
1467 else if(chose>=aOne && chose<aOne+aTwo)
1484 else if(chose>=aOne+aTwo && chose<aOne+aTwo+aThree)
1488 rOut = std::sqrt(rOut2) ;
1493 r2 = xRand*xRand + yRand*yRand ;
1494 }
while ( ! ( r2 >= rIn2 && r2 <= rOut2 ) ) ;
1503 rOut = std::sqrt(rOut2) ;
1508 r2 = xRand*xRand + yRand*yRand ;
1509 }
while ( ! ( r2 >= rIn2 && r2 <= rOut2 ) ) ;
1570 return std::log(arg+std::sqrt(
sqr(arg)+1));
G4double GetCubicVolume()
ThreeVector shoot(const G4int Ap, const G4int Af)
G4Hype(const G4String &pName, G4double newInnerRadius, G4double newOuterRadius, G4double newInnerStereo, G4double newOuterStereo, G4double newHalfLenZ)
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
static const G4double kInfinity
CLHEP::Hep3Vector G4ThreeVector
G4double GetSurfaceArea()
G4GeometryType GetEntityType() const
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
static G4double ApproxDistInside(G4double pr, G4double pz, G4double r0, G4double tan2Phi)
G4bool GetExtent(G4double &min, G4double &max) const
virtual G4double GetCubicVolume()
void SetNormal(const G4ThreeVector &newNormal)
virtual G4bool PartialClip(const G4VoxelLimits &voxelLimit, const EAxis IgnoreMe)
G4Polyhedron * CreatePolyhedron() const
virtual void AddVertexInOrder(const G4ThreeVector vertex)
void DescribeYourselfTo(G4VGraphicsScene &scene) const
virtual void AddSolid(const G4Box &)=0
G4bool InnerSurfaceExists() const
G4double HypeOuterRadius2(G4double zVal) const
static double normal(HepRandomEngine *eptr)
static G4double ApproxDistOutside(G4double pr, G4double pz, G4double r0, G4double tanPhi)
G4double HypeInnerRadius2(G4double zVal) const
void AddSurface(const G4ClippablePolygon &surface)
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=G4bool(false), G4bool *validNorm=0, G4ThreeVector *n=0) const
G4Hype & operator=(const G4Hype &rhs)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4ThreeVector GetPointOnSurface() const
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
static void AddPolyToExtent(const G4ThreeVector &v0, const G4ThreeVector &v1, const G4ThreeVector &w1, const G4ThreeVector &w0, const G4VoxelLimits &voxelLimit, const EAxis axis, G4SolidExtentList &extentList)
G4VisExtent GetExtent() const
static G4int IntersectHype(const G4ThreeVector &p, const G4ThreeVector &v, G4double r2, G4double tan2Phi, G4double s[2])
T max(const T t1, const T t2)
brief Return the largest of the two arguments
EInside Inside(const G4ThreeVector &p) const
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
static const double degree
G4Polyhedron * fpPolyhedron
G4double asinh(G4double arg)
G4VSolid & operator=(const G4VSolid &rhs)
G4int GetNumberOfRotationStepsAtTimeOfCreation() const
void SetOuterStereo(G4double newOSte)
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
static const G4double alpha
virtual G4double GetSurfaceArea()
std::ostream & StreamInfo(std::ostream &os) const
G4Polyhedron * GetPolyhedron() const
void SetInnerStereo(G4double newISte)
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
const G4int kMaxMeshSections