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

#include <G4Para.hh>

+ Inheritance diagram for G4Para:

Public Member Functions

 G4Para (const G4String &pName, G4double pDx, G4double pDy, G4double pDz, G4double pAlpha, G4double pTheta, G4double pPhi)
 
 G4Para (const G4String &pName, const G4ThreeVector pt[8])
 
virtual ~G4Para ()
 
G4double GetZHalfLength () const
 
G4ThreeVector GetSymAxis () const
 
G4double GetYHalfLength () const
 
G4double GetXHalfLength () const
 
G4double GetTanAlpha () const
 
void SetXHalfLength (G4double val)
 
void SetYHalfLength (G4double val)
 
void SetZHalfLength (G4double val)
 
void SetAlpha (G4double alpha)
 
void SetTanAlpha (G4double val)
 
void SetThetaAndPhi (double pTheta, double pPhi)
 
void SetAllParameters (G4double pDx, G4double pDy, G4double pDz, G4double pAlpha, G4double pTheta, G4double pPhi)
 
G4double GetCubicVolume ()
 
G4double GetSurfaceArea ()
 
void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
 
void BoundingLimits (G4ThreeVector &pMin, G4ThreeVector &pMax) const
 
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=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) 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
 
 G4Para (__void__ &)
 
 G4Para (const G4Para &rhs)
 
G4Paraoperator= (const G4Para &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 void BoundingLimits (G4ThreeVector &pMin, G4ThreeVector &pMax) 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=nullptr, G4ThreeVector *n=nullptr) 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 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)
 
G4double EstimateCubicVolume (G4int nStat, G4double epsilon) const
 
G4double EstimateSurfaceArea (G4int nStat, G4double ell) const
 

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
 
- Protected Attributes inherited from G4CSGSolid
G4double fCubicVolume = 0.0
 
G4double fSurfaceArea = 0.0
 
G4bool fRebuildPolyhedron = false
 
G4PolyhedronfpPolyhedron = nullptr
 
- Protected Attributes inherited from G4VSolid
G4double kCarTolerance
 

Detailed Description

Definition at line 78 of file G4Para.hh.

Constructor & Destructor Documentation

◆ G4Para() [1/4]

G4Para::G4Para ( const G4String pName,
G4double  pDx,
G4double  pDy,
G4double  pDz,
G4double  pAlpha,
G4double  pTheta,
G4double  pPhi 
)

Definition at line 53 of file G4Para.cc.

56 : G4CSGSolid(pName), halfCarTolerance(0.5*kCarTolerance)
57{
58 SetAllParameters(pDx, pDy, pDz, pAlpha, pTheta, pPhi);
59 fRebuildPolyhedron = false; // default value for G4CSGSolid
60}
G4bool fRebuildPolyhedron
Definition: G4CSGSolid.hh:72
void SetAllParameters(G4double pDx, G4double pDy, G4double pDz, G4double pAlpha, G4double pTheta, G4double pPhi)
Definition: G4Para.cc:185
G4double kCarTolerance
Definition: G4VSolid.hh:302

◆ G4Para() [2/4]

G4Para::G4Para ( const G4String pName,
const G4ThreeVector  pt[8] 
)

Definition at line 66 of file G4Para.cc.

68 : G4CSGSolid(pName), halfCarTolerance(0.5*kCarTolerance)
69{
70 // Find dimensions and trigonometric values
71 //
72 fDx = (pt[3].x() - pt[2].x())*0.5;
73 fDy = (pt[2].y() - pt[1].y())*0.5;
74 fDz = pt[7].z();
75 CheckParameters(); // check dimensions
76
77 fTalpha = (pt[2].x() + pt[3].x() - pt[1].x() - pt[0].x())*0.25/fDy;
78 fTthetaCphi = (pt[4].x() + fDy*fTalpha + fDx)/fDz;
79 fTthetaSphi = (pt[4].y() + fDy)/fDz;
80 MakePlanes();
81
82 // Recompute vertices
83 //
84 G4ThreeVector v[8];
85 G4double DyTalpha = fDy*fTalpha;
86 G4double DzTthetaSphi = fDz*fTthetaSphi;
87 G4double DzTthetaCphi = fDz*fTthetaCphi;
88 v[0].set(-DzTthetaCphi-DyTalpha-fDx, -DzTthetaSphi-fDy, -fDz);
89 v[1].set(-DzTthetaCphi-DyTalpha+fDx, -DzTthetaSphi-fDy, -fDz);
90 v[2].set(-DzTthetaCphi+DyTalpha-fDx, -DzTthetaSphi+fDy, -fDz);
91 v[3].set(-DzTthetaCphi+DyTalpha+fDx, -DzTthetaSphi+fDy, -fDz);
92 v[4].set( DzTthetaCphi-DyTalpha-fDx, DzTthetaSphi-fDy, fDz);
93 v[5].set( DzTthetaCphi-DyTalpha+fDx, DzTthetaSphi-fDy, fDz);
94 v[6].set( DzTthetaCphi+DyTalpha-fDx, DzTthetaSphi+fDy, fDz);
95 v[7].set( DzTthetaCphi+DyTalpha+fDx, DzTthetaSphi+fDy, fDz);
96
97 // Compare with original vertices
98 //
99 for (G4int i=0; i<8; ++i)
100 {
101 G4double delx = std::abs(pt[i].x() - v[i].x());
102 G4double dely = std::abs(pt[i].y() - v[i].y());
103 G4double delz = std::abs(pt[i].z() - v[i].z());
104 G4double discrepancy = std::max(std::max(delx,dely),delz);
105 if (discrepancy > 0.1*kCarTolerance)
106 {
107 std::ostringstream message;
108 G4int oldprc = message.precision(16);
109 message << "Invalid vertice coordinates for Solid: " << GetName()
110 << "\nVertix #" << i << ", discrepancy = " << discrepancy
111 << "\n original : " << pt[i]
112 << "\n recomputed : " << v[i];
113 G4cout.precision(oldprc);
114 G4Exception("G4Para::G4Para()", "GeomSolids0002",
115 FatalException, message);
116
117 }
118 }
119}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cout
double z() const
double x() const
double y() const
void set(double x, double y, double z)
G4String GetName() const

◆ ~G4Para()

G4Para::~G4Para ( )
virtual

Definition at line 137 of file G4Para.cc.

138{
139}

◆ G4Para() [3/4]

G4Para::G4Para ( __void__ &  a)

Definition at line 126 of file G4Para.cc.

127 : G4CSGSolid(a), halfCarTolerance(0.5*kCarTolerance)
128{
129 SetAllParameters(1., 1., 1., 0., 0., 0.);
130 fRebuildPolyhedron = false; // default value for G4CSGSolid
131}
G4double a
Definition: G4Para.hh:182

◆ G4Para() [4/4]

G4Para::G4Para ( const G4Para rhs)

Definition at line 145 of file G4Para.cc.

146 : G4CSGSolid(rhs), halfCarTolerance(rhs.halfCarTolerance),
147 fDx(rhs.fDx), fDy(rhs.fDy), fDz(rhs.fDz), fTalpha(rhs.fTalpha),
148 fTthetaCphi(rhs.fTthetaCphi),fTthetaSphi(rhs.fTthetaSphi)
149{
150 for (G4int i=0; i<4; ++i) { fPlanes[i] = rhs.fPlanes[i]; }
151}

Member Function Documentation

◆ BoundingLimits()

void G4Para::BoundingLimits ( G4ThreeVector pMin,
G4ThreeVector pMax 
) const
virtual

Reimplemented from G4VSolid.

Definition at line 316 of file G4Para.cc.

317{
321
322 G4double x0 = dz*fTthetaCphi;
323 G4double x1 = dy*GetTanAlpha();
324 G4double xmin =
325 std::min(
326 std::min(
327 std::min(-x0-x1-dx,-x0+x1-dx),x0-x1-dx),x0+x1-dx);
328 G4double xmax =
329 std::max(
330 std::max(
331 std::max(-x0-x1+dx,-x0+x1+dx),x0-x1+dx),x0+x1+dx);
332
333 G4double y0 = dz*fTthetaSphi;
334 G4double ymin = std::min(-y0-dy,y0-dy);
335 G4double ymax = std::max(-y0+dy,y0+dy);
336
337 pMin.set(xmin,ymin,-dz);
338 pMax.set(xmax,ymax, dz);
339
340 // Check correctness of the bounding box
341 //
342 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
343 {
344 std::ostringstream message;
345 message << "Bad bounding box (min >= max) for solid: "
346 << GetName() << " !"
347 << "\npMin = " << pMin
348 << "\npMax = " << pMax;
349 G4Exception("G4Para::BoundingLimits()", "GeomMgt0001",
350 JustWarning, message);
351 DumpInfo();
352 }
353}
@ JustWarning
G4double GetTanAlpha() const
G4double GetYHalfLength() const
G4double GetZHalfLength() const
G4double GetXHalfLength() const
void DumpInfo() const

Referenced by CalculateExtent().

◆ CalculateExtent()

G4bool G4Para::CalculateExtent ( const EAxis  pAxis,
const G4VoxelLimits pVoxelLimit,
const G4AffineTransform pTransform,
G4double pMin,
G4double pMax 
) const
virtual

Implements G4VSolid.

Definition at line 359 of file G4Para.cc.

363{
364 G4ThreeVector bmin, bmax;
365 G4bool exist;
366
367 // Check bounding box (bbox)
368 //
369 BoundingLimits(bmin,bmax);
370 G4BoundingEnvelope bbox(bmin,bmax);
371#ifdef G4BBOX_EXTENT
372 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
373#endif
374 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
375 {
376 return exist = (pMin < pMax) ? true : false;
377 }
378
379 // Set bounding envelope (benv) and calculate extent
380 //
384
385 G4double x0 = dz*fTthetaCphi;
386 G4double x1 = dy*GetTanAlpha();
387 G4double y0 = dz*fTthetaSphi;
388
389 G4ThreeVectorList baseA(4), baseB(4);
390 baseA[0].set(-x0-x1-dx,-y0-dy,-dz);
391 baseA[1].set(-x0-x1+dx,-y0-dy,-dz);
392 baseA[2].set(-x0+x1+dx,-y0+dy,-dz);
393 baseA[3].set(-x0+x1-dx,-y0+dy,-dz);
394
395 baseB[0].set(+x0-x1-dx, y0-dy, dz);
396 baseB[1].set(+x0-x1+dx, y0-dy, dz);
397 baseB[2].set(+x0+x1+dx, y0+dy, dz);
398 baseB[3].set(+x0+x1-dx, y0+dy, dz);
399
400 std::vector<const G4ThreeVectorList *> polygons(2);
401 polygons[0] = &baseA;
402 polygons[1] = &baseB;
403
404 G4BoundingEnvelope benv(bmin,bmax,polygons);
405 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
406 return exist;
407}
std::vector< G4ThreeVector > G4ThreeVectorList
bool G4bool
Definition: G4Types.hh:86
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
Definition: G4Para.cc:316

◆ Clone()

G4VSolid * G4Para::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 803 of file G4Para.cc.

804{
805 return new G4Para(*this);
806}
Definition: G4Para.hh:79

◆ ComputeDimensions()

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

Reimplemented from G4VSolid.

Definition at line 305 of file G4Para.cc.

308{
309 p->ComputeDimensions(*this,n,pRep);
310}
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const

◆ CreatePolyhedron()

G4Polyhedron * G4Para::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 900 of file G4Para.cc.

901{
902 G4double phi = std::atan2(fTthetaSphi, fTthetaCphi);
903 G4double alpha = std::atan(fTalpha);
904 G4double theta = std::atan(std::sqrt(fTthetaCphi*fTthetaCphi +
905 fTthetaSphi*fTthetaSphi));
906
907 return new G4PolyhedronPara(fDx, fDy, fDz, alpha, theta, phi);
908}

◆ DescribeYourselfTo()

void G4Para::DescribeYourselfTo ( G4VGraphicsScene scene) const
virtual

Implements G4VSolid.

Definition at line 895 of file G4Para.cc.

896{
897 scene.AddSolid (*this);
898}
virtual void AddSolid(const G4Box &)=0

◆ DistanceToIn() [1/2]

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

Implements G4VSolid.

Definition at line 629 of file G4Para.cc.

630{
631 G4double xx = fPlanes[2].a*p.x()+fPlanes[2].b*p.y()+fPlanes[2].c*p.z();
632 G4double dx = std::abs(xx) + fPlanes[2].d;
633
634 G4double yy = fPlanes[0].b*p.y()+fPlanes[0].c*p.z();
635 G4double dy = std::abs(yy) + fPlanes[0].d;
636 G4double dxy = std::max(dx,dy);
637
638 G4double dz = std::abs(p.z())-fDz;
639 G4double dist = std::max(dxy,dz);
640
641 return (dist > 0) ? dist : 0.;
642}

◆ DistanceToIn() [2/2]

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

Implements G4VSolid.

Definition at line 539 of file G4Para.cc.

541{
542 // Z intersections
543 //
544 if ((std::abs(p.z()) - fDz) >= -halfCarTolerance && p.z()*v.z() >= 0)
545 return kInfinity;
546 G4double invz = (-v.z() == 0) ? DBL_MAX : -1./v.z();
547 G4double dz = (invz < 0) ? fDz : -fDz;
548 G4double tzmin = (p.z() + dz)*invz;
549 G4double tzmax = (p.z() - dz)*invz;
550
551 // Y intersections
552 //
553 G4double tmin0 = tzmin, tmax0 = tzmax;
554 G4double cos0 = fPlanes[0].b*v.y() + fPlanes[0].c*v.z();
555 G4double disy = fPlanes[0].b*p.y() + fPlanes[0].c*p.z();
556 G4double dis0 = fPlanes[0].d + disy;
557 if (dis0 >= -halfCarTolerance)
558 {
559 if (cos0 >= 0) return kInfinity;
560 G4double tmp = -dis0/cos0;
561 if (tmin0 < tmp) tmin0 = tmp;
562 }
563 else if (cos0 > 0)
564 {
565 G4double tmp = -dis0/cos0;
566 if (tmax0 > tmp) tmax0 = tmp;
567 }
568
569 G4double tmin1 = tmin0, tmax1 = tmax0;
570 G4double cos1 = -cos0;
571 G4double dis1 = fPlanes[1].d - disy;
572 if (dis1 >= -halfCarTolerance)
573 {
574 if (cos1 >= 0) return kInfinity;
575 G4double tmp = -dis1/cos1;
576 if (tmin1 < tmp) tmin1 = tmp;
577 }
578 else if (cos1 > 0)
579 {
580 G4double tmp = -dis1/cos1;
581 if (tmax1 > tmp) tmax1 = tmp;
582 }
583
584 // X intersections
585 //
586 G4double tmin2 = tmin1, tmax2 = tmax1;
587 G4double cos2 = fPlanes[2].a*v.x() + fPlanes[2].b*v.y() + fPlanes[2].c*v.z();
588 G4double disx = fPlanes[2].a*p.x() + fPlanes[2].b*p.y() + fPlanes[2].c*p.z();
589 G4double dis2 = fPlanes[2].d + disx;
590 if (dis2 >= -halfCarTolerance)
591 {
592 if (cos2 >= 0) return kInfinity;
593 G4double tmp = -dis2/cos2;
594 if (tmin2 < tmp) tmin2 = tmp;
595 }
596 else if (cos2 > 0)
597 {
598 G4double tmp = -dis2/cos2;
599 if (tmax2 > tmp) tmax2 = tmp;
600 }
601
602 G4double tmin3 = tmin2, tmax3 = tmax2;
603 G4double cos3 = -cos2;
604 G4double dis3 = fPlanes[3].d - disx;
605 if (dis3 >= -halfCarTolerance)
606 {
607 if (cos3 >= 0) return kInfinity;
608 G4double tmp = -dis3/cos3;
609 if (tmin3 < tmp) tmin3 = tmp;
610 }
611 else if (cos3 > 0)
612 {
613 G4double tmp = -dis3/cos3;
614 if (tmax3 > tmp) tmax3 = tmp;
615 }
616
617 // Find distance
618 //
619 G4double tmin = tmin3, tmax = tmax3;
620 if (tmax <= tmin + halfCarTolerance) return kInfinity; // touch or no hit
621 return (tmin < halfCarTolerance ) ? 0. : tmin;
622}
#define DBL_MAX
Definition: templates.hh:62

◆ DistanceToOut() [1/2]

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

Implements G4VSolid.

Definition at line 759 of file G4Para.cc.

760{
761#ifdef G4CSGDEBUG
762 if( Inside(p) == kOutside )
763 {
764 std::ostringstream message;
765 G4int oldprc = message.precision(16);
766 message << "Point p is outside (!?) of solid: " << GetName() << G4endl;
767 message << "Position:\n";
768 message << " p.x() = " << p.x()/mm << " mm\n";
769 message << " p.y() = " << p.y()/mm << " mm\n";
770 message << " p.z() = " << p.z()/mm << " mm";
771 G4cout.precision(oldprc) ;
772 G4Exception("G4Para::DistanceToOut(p)", "GeomSolids1002",
773 JustWarning, message );
774 DumpInfo();
775 }
776#endif
777 G4double xx = fPlanes[2].a*p.x()+fPlanes[2].b*p.y()+fPlanes[2].c*p.z();
778 G4double dx = std::abs(xx) + fPlanes[2].d;
779
780 G4double yy = fPlanes[0].b*p.y()+fPlanes[0].c*p.z();
781 G4double dy = std::abs(yy) + fPlanes[0].d;
782 G4double dxy = std::max(dx,dy);
783
784 G4double dz = std::abs(p.z())-fDz;
785 G4double dist = std::max(dxy,dz);
786
787 return (dist < 0) ? -dist : 0.;
788}
#define G4endl
Definition: G4ios.hh:57
EInside Inside(const G4ThreeVector &p) const
Definition: G4Para.cc:414
@ kOutside
Definition: geomdefs.hh:68

◆ DistanceToOut() [2/2]

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

Implements G4VSolid.

Definition at line 650 of file G4Para.cc.

653{
654 // Z intersections
655 //
656 if ((std::abs(p.z()) - fDz) >= -halfCarTolerance && p.z()*v.z() > 0)
657 {
658 if (calcNorm)
659 {
660 *validNorm = true;
661 n->set(0, 0, (p.z() < 0) ? -1 : 1);
662 }
663 return 0.;
664 }
665 G4double vz = v.z();
666 G4double tmax = (vz == 0) ? DBL_MAX : (std::copysign(fDz,vz) - p.z())/vz;
667 G4int iside = (vz < 0) ? -4 : -2; // little trick: (-4+3)=-1, (-2+3)=+1
668
669 // Y intersections
670 //
671 G4double cos0 = fPlanes[0].b*v.y() + fPlanes[0].c*v.z();
672 if (cos0 > 0)
673 {
674 G4double dis0 = fPlanes[0].b*p.y() + fPlanes[0].c*p.z() + fPlanes[0].d;
675 if (dis0 >= -halfCarTolerance)
676 {
677 if (calcNorm)
678 {
679 *validNorm = true;
680 n->set(0, fPlanes[0].b, fPlanes[0].c);
681 }
682 return 0.;
683 }
684 G4double tmp = -dis0/cos0;
685 if (tmax > tmp) { tmax = tmp; iside = 0; }
686 }
687
688 G4double cos1 = -cos0;
689 if (cos1 > 0)
690 {
691 G4double dis1 = fPlanes[1].b*p.y() + fPlanes[1].c*p.z() + fPlanes[1].d;
692 if (dis1 >= -halfCarTolerance)
693 {
694 if (calcNorm)
695 {
696 *validNorm = true;
697 n->set(0, fPlanes[1].b, fPlanes[1].c);
698 }
699 return 0.;
700 }
701 G4double tmp = -dis1/cos1;
702 if (tmax > tmp) { tmax = tmp; iside = 1; }
703 }
704
705 // X intersections
706 //
707 G4double cos2 = fPlanes[2].a*v.x() + fPlanes[2].b*v.y() + fPlanes[2].c*v.z();
708 if (cos2 > 0)
709 {
710 G4double dis2 = fPlanes[2].a*p.x()+fPlanes[2].b*p.y()+fPlanes[2].c*p.z()+fPlanes[2].d;
711 if (dis2 >= -halfCarTolerance)
712 {
713 if (calcNorm)
714 {
715 *validNorm = true;
716 n->set(fPlanes[2].a, fPlanes[2].b, fPlanes[2].c);
717 }
718 return 0.;
719 }
720 G4double tmp = -dis2/cos2;
721 if (tmax > tmp) { tmax = tmp; iside = 2; }
722 }
723
724 G4double cos3 = -cos2;
725 if (cos3 > 0)
726 {
727 G4double dis3 = fPlanes[3].a*p.x()+fPlanes[3].b*p.y()+fPlanes[3].c*p.z()+fPlanes[3].d;
728 if (dis3 >= -halfCarTolerance)
729 {
730 if (calcNorm)
731 {
732 *validNorm = true;
733 n->set(fPlanes[3].a, fPlanes[3].b, fPlanes[3].c);
734 }
735 return 0.;
736 }
737 G4double tmp = -dis3/cos3;
738 if (tmax > tmp) { tmax = tmp; iside = 3; }
739 }
740
741 // Set normal, if required, and return distance
742 //
743 if (calcNorm)
744 {
745 *validNorm = true;
746 if (iside < 0)
747 n->set(0, 0, iside + 3); // (-4+3)=-1, (-2+3)=+1
748 else
749 n->set(fPlanes[iside].a, fPlanes[iside].b, fPlanes[iside].c);
750 }
751 return tmax;
752}
G4double b
Definition: G4Para.hh:182
G4double c
Definition: G4Para.hh:182

◆ GetCubicVolume()

G4double G4Para::GetCubicVolume ( )
virtual

Reimplemented from G4VSolid.

Definition at line 269 of file G4Para.cc.

270{
271 // It is like G4Box, since para transformations keep the volume to be const
272 if (fCubicVolume == 0)
273 {
274 fCubicVolume = 8*fDx*fDy*fDz;
275 }
276 return fCubicVolume;
277}
G4double fCubicVolume
Definition: G4CSGSolid.hh:70

◆ GetEntityType()

G4GeometryType G4Para::GetEntityType ( ) const
virtual

Implements G4VSolid.

Definition at line 794 of file G4Para.cc.

795{
796 return G4String("G4Para");
797}

◆ GetPointOnSurface()

G4ThreeVector G4Para::GetPointOnSurface ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 842 of file G4Para.cc.

843{
844 G4double DyTalpha = fDy*fTalpha;
845 G4double DzTthetaSphi = fDz*fTthetaSphi;
846 G4double DzTthetaCphi = fDz*fTthetaCphi;
847
848 // Set vertices
849 //
850 G4ThreeVector pt[8];
851 pt[0].set(-DzTthetaCphi-DyTalpha-fDx, -DzTthetaSphi-fDy, -fDz);
852 pt[1].set(-DzTthetaCphi-DyTalpha+fDx, -DzTthetaSphi-fDy, -fDz);
853 pt[2].set(-DzTthetaCphi+DyTalpha-fDx, -DzTthetaSphi+fDy, -fDz);
854 pt[3].set(-DzTthetaCphi+DyTalpha+fDx, -DzTthetaSphi+fDy, -fDz);
855 pt[4].set( DzTthetaCphi-DyTalpha-fDx, DzTthetaSphi-fDy, fDz);
856 pt[5].set( DzTthetaCphi-DyTalpha+fDx, DzTthetaSphi-fDy, fDz);
857 pt[6].set( DzTthetaCphi+DyTalpha-fDx, DzTthetaSphi+fDy, fDz);
858 pt[7].set( DzTthetaCphi+DyTalpha+fDx, DzTthetaSphi+fDy, fDz);
859
860 // Set areas (-Z, -Y, +Y, -X, +X, +Z)
861 //
862 G4ThreeVector vx(fDx, 0, 0);
863 G4ThreeVector vy(DyTalpha, fDy, 0);
864 G4ThreeVector vz(DzTthetaCphi, DzTthetaSphi, fDz);
865
866 G4double sxy = fDx*fDy; // (vx.cross(vy)).mag();
867 G4double sxz = (vx.cross(vz)).mag();
868 G4double syz = (vy.cross(vz)).mag();
869
870 G4double sface[6] = { sxy, syz, syz, sxz, sxz, sxy };
871 for (G4int i=1; i<6; ++i) { sface[i] += sface[i-1]; }
872
873 // Select face
874 //
875 G4double select = sface[5]*G4UniformRand();
876 G4int k = 5;
877 if (select <= sface[4]) k = 4;
878 if (select <= sface[3]) k = 3;
879 if (select <= sface[2]) k = 2;
880 if (select <= sface[1]) k = 1;
881 if (select <= sface[0]) k = 0;
882
883 // Generate point
884 //
885 G4int ip[6][3] = {{0,1,2}, {0,4,1}, {2,3,6}, {0,2,4}, {1,5,3}, {4,6,5}};
888 return (1.-u-v)*pt[ip[k][0]] + u*pt[ip[k][1]] + v*pt[ip[k][2]];
889}
#define G4UniformRand()
Definition: Randomize.hh:52

◆ GetSurfaceArea()

G4double G4Para::GetSurfaceArea ( )
virtual

Reimplemented from G4VSolid.

Definition at line 283 of file G4Para.cc.

284{
285 if(fSurfaceArea == 0)
286 {
287 G4ThreeVector vx(fDx, 0, 0);
288 G4ThreeVector vy(fDy*fTalpha, fDy, 0);
289 G4ThreeVector vz(fDz*fTthetaCphi, fDz*fTthetaSphi, fDz);
290
291 G4double sxy = fDx*fDy; // (vx.cross(vy)).mag();
292 G4double sxz = (vx.cross(vz)).mag();
293 G4double syz = (vy.cross(vz)).mag();
294
295 fSurfaceArea = 8*(sxy+sxz+syz);
296 }
297 return fSurfaceArea;
298}
G4double fSurfaceArea
Definition: G4CSGSolid.hh:71

◆ GetSymAxis()

◆ GetTanAlpha()

◆ GetXHalfLength()

◆ GetYHalfLength()

◆ GetZHalfLength()

◆ Inside()

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

Implements G4VSolid.

Definition at line 414 of file G4Para.cc.

415{
416 G4double xx = fPlanes[2].a*p.x()+fPlanes[2].b*p.y()+fPlanes[2].c*p.z();
417 G4double dx = std::abs(xx) + fPlanes[2].d;
418
419 G4double yy = fPlanes[0].b*p.y()+fPlanes[0].c*p.z();
420 G4double dy = std::abs(yy) + fPlanes[0].d;
421 G4double dxy = std::max(dx,dy);
422
423 G4double dz = std::abs(p.z())-fDz;
424 G4double dist = std::max(dxy,dz);
425
426 if (dist > halfCarTolerance) return kOutside;
427 return (dist > -halfCarTolerance) ? kSurface : kInside;
428}
@ kInside
Definition: geomdefs.hh:70
@ kSurface
Definition: geomdefs.hh:69

Referenced by DistanceToOut().

◆ operator=()

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

Definition at line 157 of file G4Para.cc.

158{
159 // Check assignment to self
160 //
161 if (this == &rhs) { return *this; }
162
163 // Copy base class data
164 //
166
167 // Copy data
168 //
169 halfCarTolerance = rhs.halfCarTolerance;
170 fDx = rhs.fDx;
171 fDy = rhs.fDy;
172 fDz = rhs.fDz;
173 fTalpha = rhs.fTalpha;
174 fTthetaCphi = rhs.fTthetaCphi;
175 fTthetaSphi = rhs.fTthetaSphi;
176 for (G4int i=0; i<4; ++i) { fPlanes[i] = rhs.fPlanes[i]; }
177
178 return *this;
179}
G4CSGSolid & operator=(const G4CSGSolid &rhs)
Definition: G4CSGSolid.cc:89

◆ SetAllParameters()

void G4Para::SetAllParameters ( G4double  pDx,
G4double  pDy,
G4double  pDz,
G4double  pAlpha,
G4double  pTheta,
G4double  pPhi 
)

Definition at line 185 of file G4Para.cc.

187{
188 // Reset data of the base class
189 fCubicVolume = 0;
190 fSurfaceArea = 0;
191 fRebuildPolyhedron = true;
192
193 // Set parameters
194 fDx = pDx;
195 fDy = pDy;
196 fDz = pDz;
197 fTalpha = std::tan(pAlpha);
198 fTthetaCphi = std::tan(pTheta)*std::cos(pPhi);
199 fTthetaSphi = std::tan(pTheta)*std::sin(pPhi);
200
201 CheckParameters();
202 MakePlanes();
203}

Referenced by G4ParameterisationParaX::ComputeDimensions(), G4ParameterisationParaY::ComputeDimensions(), G4ParameterisationParaZ::ComputeDimensions(), and G4Para().

◆ SetAlpha()

void G4Para::SetAlpha ( G4double  alpha)
inline

◆ SetTanAlpha()

void G4Para::SetTanAlpha ( G4double  val)
inline

◆ SetThetaAndPhi()

void G4Para::SetThetaAndPhi ( double  pTheta,
double  pPhi 
)
inline

◆ SetXHalfLength()

void G4Para::SetXHalfLength ( G4double  val)
inline

◆ SetYHalfLength()

void G4Para::SetYHalfLength ( G4double  val)
inline

◆ SetZHalfLength()

void G4Para::SetZHalfLength ( G4double  val)
inline

◆ StreamInfo()

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

Reimplemented from G4CSGSolid.

Definition at line 812 of file G4Para.cc.

813{
814 G4double alpha = std::atan(fTalpha);
815 G4double theta = std::atan(std::sqrt(fTthetaCphi*fTthetaCphi +
816 fTthetaSphi*fTthetaSphi));
817 G4double phi = std::atan2(fTthetaSphi,fTthetaCphi);
818 G4String signDegree = "\u00B0";
819
820 G4int oldprc = os.precision(16);
821 os << "-----------------------------------------------------------\n"
822 << " *** Dump for solid - " << GetName() << " ***\n"
823 << " ===================================================\n"
824 << " Solid type: G4Para\n"
825 << " Parameters:\n"
826 << " half length X: " << fDx/mm << " mm\n"
827 << " half length Y: " << fDy/mm << " mm\n"
828 << " half length Z: " << fDz/mm << " mm\n"
829 << " alpha: " << alpha/degree << signDegree << "\n"
830 << " theta: " << theta/degree << signDegree << "\n"
831 << " phi: " << phi/degree << signDegree << "\n"
832 << "-----------------------------------------------------------\n";
833 os.precision(oldprc);
834
835 return os;
836}

◆ SurfaceNormal()

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

Implements G4VSolid.

Definition at line 434 of file G4Para.cc.

435{
436 G4int nsurf = 0; // number of surfaces where p is placed
437
438 // Check Z faces
439 //
440 G4double nz = 0;
441 G4double dz = std::abs(p.z()) - fDz;
442 if (std::abs(dz) <= halfCarTolerance)
443 {
444 nz = (p.z() < 0) ? -1 : 1;
445 ++nsurf;
446 }
447
448 // Check Y faces
449 //
450 G4double ny = 0;
451 G4double yy = fPlanes[0].b*p.y()+fPlanes[0].c*p.z();
452 if (std::abs(fPlanes[0].d + yy) <= halfCarTolerance)
453 {
454 ny = fPlanes[0].b;
455 nz += fPlanes[0].c;
456 ++nsurf;
457 }
458 else if (std::abs(fPlanes[1].d - yy) <= halfCarTolerance)
459 {
460 ny = fPlanes[1].b;
461 nz += fPlanes[1].c;
462 ++nsurf;
463 }
464
465 // Check X faces
466 //
467 G4double nx = 0;
468 G4double xx = fPlanes[2].a*p.x()+fPlanes[2].b*p.y()+fPlanes[2].c*p.z();
469 if (std::abs(fPlanes[2].d + xx) <= halfCarTolerance)
470 {
471 nx = fPlanes[2].a;
472 ny += fPlanes[2].b;
473 nz += fPlanes[2].c;
474 ++nsurf;
475 }
476 else if (std::abs(fPlanes[3].d - xx) <= halfCarTolerance)
477 {
478 nx = fPlanes[3].a;
479 ny += fPlanes[3].b;
480 nz += fPlanes[3].c;
481 ++nsurf;
482 }
483
484 // Return normal
485 //
486 if (nsurf == 1) return G4ThreeVector(nx,ny,nz);
487 else if (nsurf != 0) return G4ThreeVector(nx,ny,nz).unit(); // edge or corner
488 else
489 {
490 // Point is not on the surface
491 //
492#ifdef G4CSGDEBUG
493 std::ostringstream message;
494 G4int oldprc = message.precision(16);
495 message << "Point p is not on surface (!?) of solid: "
496 << GetName() << G4endl;
497 message << "Position:\n";
498 message << " p.x() = " << p.x()/mm << " mm\n";
499 message << " p.y() = " << p.y()/mm << " mm\n";
500 message << " p.z() = " << p.z()/mm << " mm";
501 G4cout.precision(oldprc) ;
502 G4Exception("G4Para::SurfaceNormal(p)", "GeomSolids1002",
503 JustWarning, message );
504 DumpInfo();
505#endif
506 return ApproxSurfaceNormal(p);
507 }
508}
CLHEP::Hep3Vector G4ThreeVector
Hep3Vector unit() const
G4double d
Definition: G4Para.hh:182

Member Data Documentation

◆ a

G4double G4Para::a

Definition at line 182 of file G4Para.hh.

Referenced by DistanceToOut().

◆ b

G4double G4Para::b

Definition at line 182 of file G4Para.hh.

Referenced by DistanceToOut().

◆ c

G4double G4Para::c

Definition at line 182 of file G4Para.hh.

Referenced by DistanceToOut().

◆ d

G4double G4Para::d

Definition at line 182 of file G4Para.hh.

Referenced by SurfaceNormal().


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