Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Types
G4Orb Class Reference

#include <G4Orb.hh>

Inheritance diagram for G4Orb:
G4CSGSolid G4VSolid

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
 
 G4Orb (__void__ &)
 
 G4Orb (const G4Orb &rhs)
 
G4Orboperator= (const G4Orb &rhs)
 
- Public Member Functions inherited from G4CSGSolid
 G4CSGSolid (const G4String &pName)
 
virtual ~G4CSGSolid ()
 
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
 
void DumpInfo () const
 
virtual G4VisExtent GetExtent () 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 60 of file G4Orb.hh.

Member Enumeration Documentation

enum G4Orb::ENorm
protected
Enumerator
kNRMax 

Definition at line 139 of file G4Orb.hh.

139 {kNRMax};
enum G4Orb::ESide
protected
Enumerator
kNull 
kRMax 

Definition at line 135 of file G4Orb.hh.

Constructor & Destructor Documentation

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

Definition at line 73 of file G4Orb.cc.

References FatalException, G4Exception(), G4GeometryTolerance::GetInstance(), G4GeometryTolerance::GetRadialTolerance(), G4VSolid::kCarTolerance, and G4INCL::Math::max().

Referenced by Clone().

74 : G4CSGSolid(pName), fRmax(pRmax)
75 {
76 
77  const G4double fEpsilon = 2.e-11; // relative tolerance of fRmax
78 
79  G4double kRadTolerance
81 
82  // Check radius
83  //
84  if ( pRmax < 10*kCarTolerance )
85  {
86  G4Exception("G4Orb::G4Orb()", "GeomSolids0002", FatalException,
87  "Invalid radius > 10*kCarTolerance.");
88  }
89  fRmaxTolerance = std::max( kRadTolerance, fEpsilon*fRmax);
90 
91 }
G4double GetRadialTolerance() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4CSGSolid(const G4String &pName)
Definition: G4CSGSolid.cc:42
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4double kCarTolerance
Definition: G4VSolid.hh:305
double G4double
Definition: G4Types.hh:76
static G4GeometryTolerance * GetInstance()
G4Orb::~G4Orb ( )
virtual

Definition at line 107 of file G4Orb.cc.

108 {
109 }
G4Orb::G4Orb ( __void__ &  a)

Definition at line 98 of file G4Orb.cc.

99  : G4CSGSolid(a), fRmax(0.), fRmaxTolerance(0.)
100 {
101 }
G4CSGSolid(const G4String &pName)
Definition: G4CSGSolid.cc:42
G4Orb::G4Orb ( const G4Orb rhs)

Definition at line 115 of file G4Orb.cc.

116  : G4CSGSolid(rhs), fRmax(rhs.fRmax), fRmaxTolerance(rhs.fRmaxTolerance)
117 {
118 }
G4CSGSolid(const G4String &pName)
Definition: G4CSGSolid.cc:42

Member Function Documentation

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

Implements G4VSolid.

Definition at line 158 of file G4Orb.cc.

References G4VoxelLimits::GetMaxXExtent(), G4VoxelLimits::GetMaxYExtent(), G4VoxelLimits::GetMaxZExtent(), G4VoxelLimits::GetMinXExtent(), G4VoxelLimits::GetMinYExtent(), G4VoxelLimits::GetMinZExtent(), G4VoxelLimits::IsXLimited(), G4VoxelLimits::IsYLimited(), G4VoxelLimits::IsZLimited(), G4VSolid::kCarTolerance, kXAxis, kYAxis, kZAxis, G4AffineTransform::NetTranslation(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

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

Reimplemented from G4VSolid.

Definition at line 665 of file G4Orb.cc.

References G4Orb().

666 {
667  return new G4Orb(*this);
668 }
G4Orb(const G4String &pName, G4double pRmax)
Definition: G4Orb.cc:73
void G4Orb::ComputeDimensions ( G4VPVParameterisation p,
const G4int  n,
const G4VPhysicalVolume pRep 
)
virtual

Reimplemented from G4VSolid.

Definition at line 147 of file G4Orb.cc.

References G4VPVParameterisation::ComputeDimensions().

150 {
151  p->ComputeDimensions(*this,n,pRep);
152 }
const G4int n
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
G4Polyhedron * G4Orb::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 719 of file G4Orb.cc.

References python.hepunit::pi.

720 {
721  return new G4PolyhedronSphere (0., fRmax, 0., 2*pi, 0., pi);
722 }
void G4Orb::DescribeYourselfTo ( G4VGraphicsScene scene) const
virtual

Implements G4VSolid.

Definition at line 714 of file G4Orb.cc.

References G4VGraphicsScene::AddSolid().

715 {
716  scene.AddSolid (*this);
717 }
virtual void AddSolid(const G4Box &)=0
G4double G4Orb::DistanceToIn ( const G4ThreeVector p,
const G4ThreeVector v 
) const
virtual

Implements G4VSolid.

Definition at line 383 of file G4Orb.cc.

References test::c, G4Exception(), JustWarning, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

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

Implements G4VSolid.

Definition at line 479 of file G4Orb.cc.

References CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

480 {
481  G4double safe = 0.0,
482  radius = std::sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
483  safe = radius - fRmax;
484  if( safe < 0 ) { safe = 0.; }
485  return safe;
486 }
double x() const
double z() const
double y() const
double G4double
Definition: G4Types.hh:76
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 493 of file G4Orb.cc.

References test::c, G4VSolid::DumpInfo(), G4cout, G4endl, G4Exception(), JustWarning, kNull, kRMax, python.hepunit::mm, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

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

Implements G4VSolid.

Definition at line 627 of file G4Orb.cc.

References G4VSolid::DumpInfo(), G4cout, G4endl, G4Exception(), Inside(), JustWarning, kOutside, python.hepunit::mm, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

628 {
629  G4double safe=0.0,radius = std::sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
630 
631 #ifdef G4CSGDEBUG
632  if( Inside(p) == kOutside )
633  {
634  G4int oldprc = G4cout.precision(16);
635  G4cout << G4endl;
636  DumpInfo();
637  G4cout << "Position:" << G4endl << G4endl;
638  G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl;
639  G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl;
640  G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl;
641  G4cout.precision(oldprc);
642  G4Exception("G4Orb::DistanceToOut(p)", "GeomSolids1002",
643  JustWarning, "Point p is outside !?" );
644  }
645 #endif
646 
647  safe = fRmax - radius;
648  if ( safe < 0. ) safe = 0.;
649  return safe;
650 }
double x() const
int G4int
Definition: G4Types.hh:78
EInside Inside(const G4ThreeVector &p) const
Definition: G4Orb.cc:321
double z() const
void DumpInfo() const
G4GLOB_DLL std::ostream G4cout
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double y() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4double G4Orb::GetCubicVolume ( )
inlinevirtual

Reimplemented from G4VSolid.

G4GeometryType G4Orb::GetEntityType ( ) const
virtual

Implements G4VSolid.

Definition at line 656 of file G4Orb.cc.

G4ThreeVector G4Orb::GetPointOnSurface ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 694 of file G4Orb.cc.

References python.hepunit::pi, G4INCL::DeJongSpin::shoot(), and sqr().

695 {
696  // generate a random number from zero to 2pi...
697  //
698  G4double phi = RandFlat::shoot(0.,2.*pi);
699  G4double cosphi = std::cos(phi);
700  G4double sinphi = std::sin(phi);
701 
702  // generate a random point uniform in area
703  G4double costheta = RandFlat::shoot(-1.,1.);
704  G4double sintheta = std::sqrt(1.-sqr(costheta));
705 
706  return G4ThreeVector (fRmax*sintheta*cosphi,
707  fRmax*sintheta*sinphi, fRmax*costheta);
708 }
ThreeVector shoot(const G4int Ap, const G4int Af)
CLHEP::Hep3Vector G4ThreeVector
T sqr(const T &x)
Definition: templates.hh:145
double G4double
Definition: G4Types.hh:76
G4double G4Orb::GetRadius ( ) const
inline
G4double G4Orb::GetSurfaceArea ( )
inlinevirtual

Reimplemented from G4VSolid.

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

Implements G4VSolid.

Definition at line 321 of file G4Orb.cc.

References kInside, kOutside, kSurface, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by DistanceToOut().

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

Definition at line 124 of file G4Orb.cc.

References G4CSGSolid::operator=().

125 {
126  // Check assignment to self
127  //
128  if (this == &rhs) { return *this; }
129 
130  // Copy base class data
131  //
133 
134  // Copy data
135  //
136  fRmax = rhs.fRmax;
137  fRmaxTolerance = rhs.fRmaxTolerance;
138 
139  return *this;
140 }
G4CSGSolid & operator=(const G4CSGSolid &rhs)
Definition: G4CSGSolid.cc:82
void G4Orb::SetRadius ( G4double  newRmax)
inline

Referenced by export_G4Orb().

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

Reimplemented from G4CSGSolid.

Definition at line 674 of file G4Orb.cc.

References G4VSolid::GetName(), and python.hepunit::mm.

675 {
676  G4int oldprc = os.precision(16);
677  os << "-----------------------------------------------------------\n"
678  << " *** Dump for solid - " << GetName() << " ***\n"
679  << " ===================================================\n"
680  << " Solid type: G4Orb\n"
681  << " Parameters: \n"
682 
683  << " outer radius: " << fRmax/mm << " mm \n"
684  << "-----------------------------------------------------------\n";
685  os.precision(oldprc);
686 
687  return os;
688 }
G4String GetName() const
int G4int
Definition: G4Types.hh:78
G4ThreeVector G4Orb::SurfaceNormal ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 353 of file G4Orb.cc.

References G4VSolid::DumpInfo(), G4Exception(), JustWarning, kNRMax, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

354 {
355  ENorm side = kNRMax;
356  G4ThreeVector norm;
357  G4double radius = std::sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
358 
359  switch (side)
360  {
361  case kNRMax:
362  norm = G4ThreeVector(p.x()/radius,p.y()/radius,p.z()/radius);
363  break;
364  default: // Should never reach this case ...
365  DumpInfo();
366  G4Exception("G4Orb::SurfaceNormal()", "GeomSolids1002", JustWarning,
367  "Undefined side for valid surface normal to solid.");
368  break;
369  }
370 
371  return norm;
372 }
CLHEP::Hep3Vector G4ThreeVector
double x() const
double z() const
void DumpInfo() const
ENorm
Definition: G4Cons.cc:72
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double y() const
double G4double
Definition: G4Types.hh:76

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