Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Orb Class Reference

#include <G4Orb.hh>

+ Inheritance diagram for G4Orb:

Public Member Functions

 G4Orb (const G4String &pName, G4double pRmax)
 
virtual ~G4Orb ()
 
G4double GetRadius () const
 
void SetRadius (G4double newRmax)
 
G4double GetCubicVolume ()
 
G4double GetSurfaceArea ()
 
void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
 
G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
 
EInside Inside (const G4ThreeVector &p) const
 
G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const
 
G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const
 
G4double DistanceToIn (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 DistanceToOut (const G4ThreeVector &p) const
 
G4GeometryType GetEntityType () const
 
G4ThreeVector GetPointOnSurface () const
 
G4VSolidClone () const
 
std::ostream & StreamInfo (std::ostream &os) const
 
void DescribeYourselfTo (G4VGraphicsScene &scene) const
 
G4PolyhedronCreatePolyhedron () const
 
G4NURBSCreateNURBS () const
 
 G4Orb (__void__ &)
 
 G4Orb (const G4Orb &rhs)
 
G4Orboperator= (const G4Orb &rhs)
 
- Public Member Functions inherited from G4CSGSolid
 G4CSGSolid (const G4String &pName)
 
virtual ~G4CSGSolid ()
 
virtual std::ostream & StreamInfo (std::ostream &os) const
 
virtual G4PolyhedronGetPolyhedron () const
 
 G4CSGSolid (__void__ &)
 
 G4CSGSolid (const G4CSGSolid &rhs)
 
G4CSGSolidoperator= (const G4CSGSolid &rhs)
 
- Public Member Functions inherited from G4VSolid
 G4VSolid (const G4String &name)
 
virtual ~G4VSolid ()
 
G4bool operator== (const G4VSolid &s) const
 
G4String GetName () const
 
void SetName (const G4String &name)
 
G4double GetTolerance () const
 
virtual G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const =0
 
virtual EInside Inside (const G4ThreeVector &p) const =0
 
virtual G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const =0
 
virtual G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const =0
 
virtual G4double DistanceToIn (const G4ThreeVector &p) const =0
 
virtual G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
 
virtual G4double DistanceToOut (const G4ThreeVector &p) const =0
 
virtual void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
 
virtual G4double GetCubicVolume ()
 
virtual G4double GetSurfaceArea ()
 
virtual G4GeometryType GetEntityType () const =0
 
virtual G4ThreeVector GetPointOnSurface () const
 
virtual G4VSolidClone () const
 
virtual std::ostream & StreamInfo (std::ostream &os) const =0
 
void DumpInfo () const
 
virtual void DescribeYourselfTo (G4VGraphicsScene &scene) const =0
 
virtual G4VisExtent GetExtent () const
 
virtual G4PolyhedronCreatePolyhedron () const
 
virtual G4NURBSCreateNURBS () const
 
virtual G4PolyhedronGetPolyhedron () const
 
virtual const G4VSolidGetConstituentSolid (G4int no) const
 
virtual G4VSolidGetConstituentSolid (G4int no)
 
virtual const G4DisplacedSolidGetDisplacedSolidPtr () const
 
virtual G4DisplacedSolidGetDisplacedSolidPtr ()
 
 G4VSolid (__void__ &)
 
 G4VSolid (const G4VSolid &rhs)
 
G4VSolidoperator= (const G4VSolid &rhs)
 

Protected Types

enum  ESide { kNull , kRMax }
 
enum  ENorm { kNRMax }
 

Additional Inherited Members

- Protected Member Functions inherited from G4CSGSolid
G4double GetRadiusInRing (G4double rmin, G4double rmax) const
 
- Protected Member Functions inherited from G4VSolid
void CalculateClippedPolygonExtent (G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void ClipCrossSection (G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void ClipBetweenSections (G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void ClipPolygon (G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis) const
 
G4double EstimateCubicVolume (G4int nStat, G4double epsilon) const
 
G4double EstimateSurfaceArea (G4int nStat, G4double ell) const
 
- Protected Attributes inherited from G4CSGSolid
G4double fCubicVolume
 
G4double fSurfaceArea
 
G4PolyhedronfpPolyhedron
 
- Protected Attributes inherited from G4VSolid
G4double kCarTolerance
 

Detailed Description

Definition at line 51 of file G4Orb.hh.

Member Enumeration Documentation

◆ ENorm

enum G4Orb::ENorm
protected
Enumerator
kNRMax 

Definition at line 131 of file G4Orb.hh.

131{kNRMax};
@ kNRMax
Definition: G4Orb.hh:131

◆ ESide

enum G4Orb::ESide
protected
Enumerator
kNull 
kRMax 

Definition at line 127 of file G4Orb.hh.

127{kNull,kRMax};
@ kNull
Definition: G4Orb.hh:127
@ kRMax
Definition: G4Orb.hh:127

Constructor & Destructor Documentation

◆ G4Orb() [1/3]

G4Orb::G4Orb ( const G4String pName,
G4double  pRmax 
)

Definition at line 75 of file G4Orb.cc.

76: G4CSGSolid(pName), fRmax(pRmax)
77{
78
79 const G4double fEpsilon = 2.e-11; // relative tolerance of fRmax
80
81 G4double kRadTolerance
83
84 // Check radius
85 //
86 if ( pRmax < 10*kCarTolerance )
87 {
88 G4Exception("G4Orb::G4Orb()", "GeomSolids0002", FatalException,
89 "Invalid radius > 10*kCarTolerance.");
90 }
91 fRmaxTolerance = std::max( kRadTolerance, fEpsilon*fRmax);
92
93}
@ FatalException
double G4double
Definition: G4Types.hh:64
G4double GetRadialTolerance() const
static G4GeometryTolerance * GetInstance()
G4double kCarTolerance
Definition: G4VSolid.hh:307
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

◆ ~G4Orb()

G4Orb::~G4Orb ( )
virtual

Definition at line 109 of file G4Orb.cc.

110{
111}

◆ G4Orb() [2/3]

G4Orb::G4Orb ( __void__ &  a)

Definition at line 100 of file G4Orb.cc.

101 : G4CSGSolid(a), fRmax(0.), fRmaxTolerance(0.)
102{
103}

◆ G4Orb() [3/3]

G4Orb::G4Orb ( const G4Orb rhs)

Definition at line 117 of file G4Orb.cc.

118 : G4CSGSolid(rhs), fRmax(rhs.fRmax), fRmaxTolerance(rhs.fRmaxTolerance)
119{
120}

Member Function Documentation

◆ CalculateExtent()

G4bool G4Orb::CalculateExtent ( const EAxis  pAxis,
const G4VoxelLimits pVoxelLimit,
const G4AffineTransform pTransform,
G4double pmin,
G4double pmax 
) const
virtual

Implements G4VSolid.

Definition at line 160 of file G4Orb.cc.

164{
165 // Compute x/y/z mins and maxs for bounding box respecting limits,
166 // with early returns if outside limits. Then switch() on pAxis,
167 // and compute exact x and y limit for x/y case
168
169 G4double xoffset,xMin,xMax;
170 G4double yoffset,yMin,yMax;
171 G4double zoffset,zMin,zMax;
172
173 G4double diff1,diff2,delta,maxDiff,newMin,newMax;
174 G4double xoff1,xoff2,yoff1,yoff2;
175
176 xoffset=pTransform.NetTranslation().x();
177 xMin=xoffset-fRmax;
178 xMax=xoffset+fRmax;
179
180 if (pVoxelLimit.IsXLimited())
181 {
182 if ( (xMin>pVoxelLimit.GetMaxXExtent()+kCarTolerance)
183 || (xMax<pVoxelLimit.GetMinXExtent()-kCarTolerance) )
184 {
185 return false;
186 }
187 else
188 {
189 if (xMin<pVoxelLimit.GetMinXExtent())
190 {
191 xMin=pVoxelLimit.GetMinXExtent();
192 }
193 if (xMax>pVoxelLimit.GetMaxXExtent())
194 {
195 xMax=pVoxelLimit.GetMaxXExtent();
196 }
197 }
198 }
199 yoffset=pTransform.NetTranslation().y();
200 yMin=yoffset-fRmax;
201 yMax=yoffset+fRmax;
202
203 if (pVoxelLimit.IsYLimited())
204 {
205 if ( (yMin>pVoxelLimit.GetMaxYExtent()+kCarTolerance)
206 || (yMax<pVoxelLimit.GetMinYExtent()-kCarTolerance) )
207 {
208 return false;
209 }
210 else
211 {
212 if (yMin<pVoxelLimit.GetMinYExtent())
213 {
214 yMin=pVoxelLimit.GetMinYExtent();
215 }
216 if (yMax>pVoxelLimit.GetMaxYExtent())
217 {
218 yMax=pVoxelLimit.GetMaxYExtent();
219 }
220 }
221 }
222 zoffset=pTransform.NetTranslation().z();
223 zMin=zoffset-fRmax;
224 zMax=zoffset+fRmax;
225
226 if (pVoxelLimit.IsZLimited())
227 {
228 if ( (zMin>pVoxelLimit.GetMaxZExtent()+kCarTolerance)
229 || (zMax<pVoxelLimit.GetMinZExtent()-kCarTolerance) )
230 {
231 return false;
232 }
233 else
234 {
235 if (zMin<pVoxelLimit.GetMinZExtent())
236 {
237 zMin=pVoxelLimit.GetMinZExtent();
238 }
239 if (zMax>pVoxelLimit.GetMaxZExtent())
240 {
241 zMax=pVoxelLimit.GetMaxZExtent();
242 }
243 }
244 }
245
246 // Known to cut sphere
247
248 switch (pAxis)
249 {
250 case kXAxis:
251 yoff1=yoffset-yMin;
252 yoff2=yMax-yoffset;
253
254 if ( yoff1 >= 0 && yoff2 >= 0 )
255 {
256 // Y limits cross max/min x => no change
257 //
258 pMin=xMin;
259 pMax=xMax;
260 }
261 else
262 {
263 // Y limits don't cross max/min x => compute max delta x,
264 // hence new mins/maxs
265 //
266 delta=fRmax*fRmax-yoff1*yoff1;
267 diff1=(delta>0.) ? std::sqrt(delta) : 0.;
268 delta=fRmax*fRmax-yoff2*yoff2;
269 diff2=(delta>0.) ? std::sqrt(delta) : 0.;
270 maxDiff=(diff1>diff2) ? diff1:diff2;
271 newMin=xoffset-maxDiff;
272 newMax=xoffset+maxDiff;
273 pMin=(newMin<xMin) ? xMin : newMin;
274 pMax=(newMax>xMax) ? xMax : newMax;
275 }
276 break;
277 case kYAxis:
278 xoff1=xoffset-xMin;
279 xoff2=xMax-xoffset;
280 if (xoff1>=0&&xoff2>=0)
281 {
282 // X limits cross max/min y => no change
283 //
284 pMin=yMin;
285 pMax=yMax;
286 }
287 else
288 {
289 // X limits don't cross max/min y => compute max delta y,
290 // hence new mins/maxs
291 //
292 delta=fRmax*fRmax-xoff1*xoff1;
293 diff1=(delta>0.) ? std::sqrt(delta) : 0.;
294 delta=fRmax*fRmax-xoff2*xoff2;
295 diff2=(delta>0.) ? std::sqrt(delta) : 0.;
296 maxDiff=(diff1>diff2) ? diff1:diff2;
297 newMin=yoffset-maxDiff;
298 newMax=yoffset+maxDiff;
299 pMin=(newMin<yMin) ? yMin : newMin;
300 pMax=(newMax>yMax) ? yMax : newMax;
301 }
302 break;
303 case kZAxis:
304 pMin=zMin;
305 pMax=zMax;
306 break;
307 default:
308 break;
309 }
310 pMin -= fRmaxTolerance;
311 pMax += fRmaxTolerance;
312
313 return true;
314
315}
double z() const
double x() const
double y() const
G4ThreeVector NetTranslation() const
G4bool IsYLimited() const
G4double GetMinZExtent() const
G4bool IsXLimited() const
G4double GetMaxYExtent() const
G4double GetMaxZExtent() const
G4double GetMinYExtent() const
G4double GetMinXExtent() const
G4bool IsZLimited() const
G4double GetMaxXExtent() const
@ kYAxis
Definition: geomdefs.hh:54
@ kXAxis
Definition: geomdefs.hh:54
@ kZAxis
Definition: geomdefs.hh:54

◆ Clone()

G4VSolid * G4Orb::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 667 of file G4Orb.cc.

668{
669 return new G4Orb(*this);
670}
Definition: G4Orb.hh:52

◆ ComputeDimensions()

void G4Orb::ComputeDimensions ( G4VPVParameterisation p,
const G4int  n,
const G4VPhysicalVolume pRep 
)
virtual

Reimplemented from G4VSolid.

Definition at line 149 of file G4Orb.cc.

152{
153 p->ComputeDimensions(*this,n,pRep);
154}
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const

◆ CreateNURBS()

G4NURBS * G4Orb::CreateNURBS ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 726 of file G4Orb.cc.

727{
728 return new G4NURBSbox (fRmax, fRmax, fRmax); // Box for now!!!
729}

◆ CreatePolyhedron()

G4Polyhedron * G4Orb::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 721 of file G4Orb.cc.

722{
723 return new G4PolyhedronSphere (0., fRmax, 0., 2*pi, 0., pi);
724}

◆ DescribeYourselfTo()

void G4Orb::DescribeYourselfTo ( G4VGraphicsScene scene) const
virtual

Implements G4VSolid.

Definition at line 716 of file G4Orb.cc.

717{
718 scene.AddSolid (*this);
719}
virtual void AddSolid(const G4Box &)=0

◆ DistanceToIn() [1/2]

G4double G4Orb::DistanceToIn ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 481 of file G4Orb.cc.

482{
483 G4double safe = 0.0,
484 radius = std::sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
485 safe = radius - fRmax;
486 if( safe < 0 ) { safe = 0.; }
487 return safe;
488}

◆ DistanceToIn() [2/2]

G4double G4Orb::DistanceToIn ( const G4ThreeVector p,
const G4ThreeVector v 
) const
virtual

Implements G4VSolid.

Definition at line 385 of file G4Orb.cc.

387{
388 G4double snxt = kInfinity; // snxt = default return value
389
390 G4double radius, pDotV3d; // , tolORMax2, tolIRMax2;
391 G4double c, d2, sd = kInfinity;
392
393 const G4double dRmax = 100.*fRmax;
394
395 // General Precalcs
396
397 radius = std::sqrt(p.x()*p.x() + p.y()*p.y() + p.z()*p.z());
398 pDotV3d = p.x()*v.x() + p.y()*v.y() + p.z()*v.z();
399
400 // Radial Precalcs
401
402 // tolORMax2 = (fRmax+fRmaxTolerance*0.5)*(fRmax+fRmaxTolerance*0.5);
403 // tolIRMax2 = (fRmax-fRmaxTolerance*0.5)*(fRmax-fRmaxTolerance*0.5);
404
405 // Outer spherical shell intersection
406 // - Only if outside tolerant fRmax
407 // - Check for if inside and outer G4Orb heading through solid (-> 0)
408 // - No intersect -> no intersection with G4Orb
409 //
410 // Shell eqn: x^2+y^2+z^2 = RSPH^2
411 //
412 // => (px+svx)^2+(py+svy)^2+(pz+svz)^2=R^2
413 //
414 // => (px^2+py^2+pz^2) +2sd(pxvx+pyvy+pzvz)+sd^2(vx^2+vy^2+vz^2)=R^2
415 // => rad2 +2sd(pDotV3d) +sd^2 =R^2
416 //
417 // => sd=-pDotV3d+-std::sqrt(pDotV3d^2-(rad2-R^2))
418
419 c = (radius - fRmax)*(radius + fRmax);
420
421 if( radius > fRmax-fRmaxTolerance*0.5 ) // not inside in terms of Inside(p)
422 {
423 if ( c > fRmaxTolerance*fRmax )
424 {
425 // If outside tolerant boundary of outer G4Orb in terms of c
426 // [ should be std::sqrt(rad2) - fRmax > fRmaxTolerance*0.5 ]
427
428 d2 = pDotV3d*pDotV3d - c;
429
430 if ( d2 >= 0 )
431 {
432 sd = -pDotV3d - std::sqrt(d2);
433 if ( sd >= 0 )
434 {
435 if ( sd > dRmax ) // Avoid rounding errors due to precision issues seen on
436 { // 64 bits systems. Split long distances and recompute
437 G4double fTerm = sd - std::fmod(sd,dRmax);
438 sd = fTerm + DistanceToIn(p+fTerm*v,v);
439 }
440 return snxt = sd;
441 }
442 }
443 else // No intersection with G4Orb
444 {
445 return snxt = kInfinity;
446 }
447 }
448 else // not outside in terms of c
449 {
450 if ( c > -fRmaxTolerance*fRmax ) // on surface
451 {
452 d2 = pDotV3d*pDotV3d - c;
453 if ( (d2 < fRmaxTolerance*fRmax) || (pDotV3d >= 0) )
454 {
455 return snxt = kInfinity;
456 }
457 else
458 {
459 return snxt = 0.;
460 }
461 }
462 }
463 }
464#ifdef G4CSGDEBUG
465 else // inside ???
466 {
467 G4Exception("G4Orb::DistanceToIn(p,v)", "GeomSolids1002",
468 JustWarning, "Point p is inside !?");
469 }
470#endif
471
472 return snxt;
473}
@ JustWarning
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
Definition: G4Orb.cc:385

Referenced by DistanceToIn().

◆ DistanceToOut() [1/2]

G4double G4Orb::DistanceToOut ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 629 of file G4Orb.cc.

630{
631 G4double safe=0.0,radius = std::sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
632
633#ifdef G4CSGDEBUG
634 if( Inside(p) == kOutside )
635 {
636 G4int oldprc = G4cout.precision(16);
637 G4cout << G4endl;
638 DumpInfo();
639 G4cout << "Position:" << G4endl << G4endl;
640 G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl;
641 G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl;
642 G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl;
643 G4cout.precision(oldprc);
644 G4Exception("G4Orb::DistanceToOut(p)", "GeomSolids1002",
645 JustWarning, "Point p is outside !?" );
646 }
647#endif
648
649 safe = fRmax - radius;
650 if ( safe < 0. ) safe = 0.;
651 return safe;
652}
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
EInside Inside(const G4ThreeVector &p) const
Definition: G4Orb.cc:323
void DumpInfo() const
@ kOutside
Definition: geomdefs.hh:58

◆ DistanceToOut() [2/2]

G4double G4Orb::DistanceToOut ( const G4ThreeVector p,
const G4ThreeVector v,
const G4bool  calcNorm = G4bool(false),
G4bool validNorm = 0,
G4ThreeVector n = 0 
) const
virtual

Implements G4VSolid.

Definition at line 495 of file G4Orb.cc.

500{
501 G4double snxt = kInfinity; // ??? snxt is default return value
502 ESide side = kNull;
503
504 G4double rad2,pDotV3d;
505 G4double xi,yi,zi; // Intersection point
506 G4double c,d2;
507
508 rad2 = p.x()*p.x() + p.y()*p.y() + p.z()*p.z();
509 pDotV3d = p.x()*v.x() + p.y()*v.y() + p.z()*v.z();
510
511 // Radial Intersection from G4Orb::DistanceToIn
512 //
513 // Outer spherical shell intersection
514 // - Only if outside tolerant fRmax
515 // - Check for if inside and outer G4Orb heading through solid (-> 0)
516 // - No intersect -> no intersection with G4Orb
517 //
518 // Shell eqn: x^2+y^2+z^2=RSPH^2
519 //
520 // => (px+svx)^2+(py+svy)^2+(pz+svz)^2=R^2
521 //
522 // => (px^2+py^2+pz^2) +2s(pxvx+pyvy+pzvz)+s^2(vx^2+vy^2+vz^2)=R^2
523 // => rad2 +2s(pDotV3d) +s^2 =R^2
524 //
525 // => s=-pDotV3d+-std::sqrt(pDotV3d^2-(rad2-R^2))
526
527 const G4double Rmax_plus = fRmax + fRmaxTolerance*0.5;
528 G4double radius = std::sqrt(rad2);
529
530 if ( radius <= Rmax_plus )
531 {
532 c = (radius - fRmax)*(radius + fRmax);
533
534 if ( c < fRmaxTolerance*fRmax )
535 {
536 // Within tolerant Outer radius
537 //
538 // The test is
539 // radius - fRmax < 0.5*fRmaxTolerance
540 // => radius < fRmax + 0.5*kRadTol
541 // => rad2 < (fRmax + 0.5*kRadTol)^2
542 // => rad2 < fRmax^2 + 2.*0.5*fRmax*kRadTol + 0.25*kRadTol*kRadTol
543 // => rad2 - fRmax^2 <~ fRmax*kRadTol
544
545 d2 = pDotV3d*pDotV3d - c;
546
547 if( ( c > -fRmaxTolerance*fRmax) && // on tolerant surface
548 ( ( pDotV3d >= 0 ) || ( d2 < 0 )) ) // leaving outside from Rmax
549 // not re-entering
550 {
551 if(calcNorm)
552 {
553 *validNorm = true;
554 *n = G4ThreeVector(p.x()/fRmax,p.y()/fRmax,p.z()/fRmax);
555 }
556 return snxt = 0;
557 }
558 else
559 {
560 snxt = -pDotV3d + std::sqrt(d2); // second root since inside Rmax
561 side = kRMax;
562 }
563 }
564 }
565 else // p is outside ???
566 {
567 G4cout << G4endl;
568 DumpInfo();
569 std::ostringstream message;
570 G4int oldprc = message.precision(16);
571 message << "Logic error: snxt = kInfinity ???" << G4endl
572 << "Position:" << G4endl << G4endl
573 << "p.x() = " << p.x()/mm << " mm" << G4endl
574 << "p.y() = " << p.y()/mm << " mm" << G4endl
575 << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl
576 << "Rp = "<< std::sqrt( p.x()*p.x()+p.y()*p.y()+p.z()*p.z() )/mm
577 << " mm" << G4endl << G4endl
578 << "Direction:" << G4endl << G4endl
579 << "v.x() = " << v.x() << G4endl
580 << "v.y() = " << v.y() << G4endl
581 << "v.z() = " << v.z() << G4endl << G4endl
582 << "Proposed distance :" << G4endl << G4endl
583 << "snxt = " << snxt/mm << " mm" << G4endl;
584 message.precision(oldprc);
585 G4Exception("G4Orb::DistanceToOut(p,v,..)", "GeomSolids1002",
586 JustWarning, message);
587 }
588 if (calcNorm) // Output switch operator
589 {
590 switch( side )
591 {
592 case kRMax:
593 xi=p.x()+snxt*v.x();
594 yi=p.y()+snxt*v.y();
595 zi=p.z()+snxt*v.z();
596 *n=G4ThreeVector(xi/fRmax,yi/fRmax,zi/fRmax);
597 *validNorm=true;
598 break;
599 default:
600 G4cout << G4endl;
601 DumpInfo();
602 std::ostringstream message;
603 G4int oldprc = message.precision(16);
604 message << "Undefined side for valid surface normal to solid."
605 << G4endl
606 << "Position:" << G4endl << G4endl
607 << "p.x() = " << p.x()/mm << " mm" << G4endl
608 << "p.y() = " << p.y()/mm << " mm" << G4endl
609 << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl
610 << "Direction:" << G4endl << G4endl
611 << "v.x() = " << v.x() << G4endl
612 << "v.y() = " << v.y() << G4endl
613 << "v.z() = " << v.z() << G4endl << G4endl
614 << "Proposed distance :" << G4endl << G4endl
615 << "snxt = " << snxt/mm << " mm" << G4endl;
616 message.precision(oldprc);
617 G4Exception("G4Orb::DistanceToOut(p,v,..)","GeomSolids1002",
618 JustWarning, message);
619 break;
620 }
621 }
622 return snxt;
623}
ESide
Definition: G4Cons.cc:68
CLHEP::Hep3Vector G4ThreeVector

◆ GetCubicVolume()

G4double G4Orb::GetCubicVolume ( )
inlinevirtual

Reimplemented from G4VSolid.

◆ GetEntityType()

G4GeometryType G4Orb::GetEntityType ( ) const
virtual

Implements G4VSolid.

Definition at line 658 of file G4Orb.cc.

659{
660 return G4String("G4Orb");
661}

◆ GetPointOnSurface()

G4ThreeVector G4Orb::GetPointOnSurface ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 696 of file G4Orb.cc.

697{
698 // generate a random number from zero to 2pi...
699 //
700 G4double phi = RandFlat::shoot(0.,2.*pi);
701 G4double cosphi = std::cos(phi);
702 G4double sinphi = std::sin(phi);
703
704 // generate a random point uniform in area
705 G4double costheta = RandFlat::shoot(-1.,1.);
706 G4double sintheta = std::sqrt(1.-sqr(costheta));
707
708 return G4ThreeVector (fRmax*sintheta*cosphi,
709 fRmax*sintheta*sinphi, fRmax*costheta);
710}
static double shoot()
Definition: RandFlat.cc:59
T sqr(const T &x)
Definition: templates.hh:145

◆ GetRadius()

◆ GetSurfaceArea()

G4double G4Orb::GetSurfaceArea ( )
inlinevirtual

Reimplemented from G4VSolid.

◆ Inside()

EInside G4Orb::Inside ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 323 of file G4Orb.cc.

324{
325 G4double rad2,tolRMax;
326 EInside in;
327
328
329 rad2 = p.x()*p.x()+p.y()*p.y()+p.z()*p.z();
330
331 G4double radius = std::sqrt(rad2);
332
333 // G4double radius = std::sqrt(rad2);
334 // Check radial surface
335 // sets `in'
336
337 tolRMax = fRmax - fRmaxTolerance*0.5;
338
339 if ( radius <= tolRMax ) { in = kInside; }
340 else
341 {
342 tolRMax = fRmax + fRmaxTolerance*0.5;
343 if ( radius <= tolRMax ) { in = kSurface; }
344 else { in = kOutside; }
345 }
346 return in;
347}
EInside
Definition: geomdefs.hh:58
@ kInside
Definition: geomdefs.hh:58
@ kSurface
Definition: geomdefs.hh:58

Referenced by DistanceToOut().

◆ operator=()

G4Orb & G4Orb::operator= ( const G4Orb rhs)

Definition at line 126 of file G4Orb.cc.

127{
128 // Check assignment to self
129 //
130 if (this == &rhs) { return *this; }
131
132 // Copy base class data
133 //
135
136 // Copy data
137 //
138 fRmax = rhs.fRmax;
139 fRmaxTolerance = rhs.fRmaxTolerance;
140
141 return *this;
142}
G4CSGSolid & operator=(const G4CSGSolid &rhs)
Definition: G4CSGSolid.cc:82

◆ SetRadius()

void G4Orb::SetRadius ( G4double  newRmax)
inline

◆ StreamInfo()

std::ostream & G4Orb::StreamInfo ( std::ostream &  os) const
virtual

Reimplemented from G4CSGSolid.

Definition at line 676 of file G4Orb.cc.

677{
678 G4int oldprc = os.precision(16);
679 os << "-----------------------------------------------------------\n"
680 << " *** Dump for solid - " << GetName() << " ***\n"
681 << " ===================================================\n"
682 << " Solid type: G4Orb\n"
683 << " Parameters: \n"
684
685 << " outer radius: " << fRmax/mm << " mm \n"
686 << "-----------------------------------------------------------\n";
687 os.precision(oldprc);
688
689 return os;
690}
G4String GetName() const

◆ SurfaceNormal()

G4ThreeVector G4Orb::SurfaceNormal ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 355 of file G4Orb.cc.

356{
357 ENorm side = kNRMax;
358 G4ThreeVector norm;
359 G4double radius = std::sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
360
361 switch (side)
362 {
363 case kNRMax:
364 norm = G4ThreeVector(p.x()/radius,p.y()/radius,p.z()/radius);
365 break;
366 default: // Should never reach this case ...
367 DumpInfo();
368 G4Exception("G4Orb::SurfaceNormal()", "GeomSolids1002", JustWarning,
369 "Undefined side for valid surface normal to solid.");
370 break;
371 }
372
373 return norm;
374}
ENorm
Definition: G4Cons.cc:72

The documentation for this class was generated from the following files: