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

#include <G4Trd.hh>

+ Inheritance diagram for G4Trd:

Public Member Functions

 G4Trd (const G4String &pName, G4double pdx1, G4double pdx2, G4double pdy1, G4double pdy2, G4double pdz)
 
 ~G4Trd ()
 
G4double GetXHalfLength1 () const
 
G4double GetXHalfLength2 () const
 
G4double GetYHalfLength1 () const
 
G4double GetYHalfLength2 () const
 
G4double GetZHalfLength () const
 
void SetXHalfLength1 (G4double val)
 
void SetXHalfLength2 (G4double val)
 
void SetYHalfLength1 (G4double val)
 
void SetYHalfLength2 (G4double val)
 
void SetZHalfLength (G4double val)
 
void SetAllParameters (G4double pdx1, G4double pdx2, G4double pdy1, G4double pdy2, G4double pdz)
 
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
 
 G4Trd (__void__ &)
 
 G4Trd (const G4Trd &rhs)
 
G4Trdoperator= (const G4Trd &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 62 of file G4Trd.hh.

Constructor & Destructor Documentation

◆ G4Trd() [1/3]

G4Trd::G4Trd ( const G4String pName,
G4double  pdx1,
G4double  pdx2,
G4double  pdy1,
G4double  pdy2,
G4double  pdz 
)

Definition at line 54 of file G4Trd.cc.

58 : G4CSGSolid(pName), halfCarTolerance(0.5*kCarTolerance),
59 fDx1(pdx1), fDx2(pdx2), fDy1(pdy1), fDy2(pdy2), fDz(pdz)
60{
61 CheckParameters();
62 MakePlanes();
63}
G4double kCarTolerance
Definition: G4VSolid.hh:299

◆ ~G4Trd()

G4Trd::~G4Trd ( )

Definition at line 81 of file G4Trd.cc.

82{
83}

◆ G4Trd() [2/3]

G4Trd::G4Trd ( __void__ &  a)

Definition at line 70 of file G4Trd.cc.

71 : G4CSGSolid(a), halfCarTolerance(0.5*kCarTolerance),
72 fDx1(1.), fDx2(1.), fDy1(1.), fDy2(1.), fDz(1.)
73{
74 MakePlanes();
75}
G4double a
Definition: G4Trd.hh:170

◆ G4Trd() [3/3]

G4Trd::G4Trd ( const G4Trd rhs)

Definition at line 89 of file G4Trd.cc.

90 : G4CSGSolid(rhs), halfCarTolerance(rhs.halfCarTolerance),
91 fDx1(rhs.fDx1), fDx2(rhs.fDx2),
92 fDy1(rhs.fDy1), fDy2(rhs.fDy2), fDz(rhs.fDz),
93 fHx(rhs.fHx), fHy(rhs.fHy)
94{
95 for (G4int i=0; i<4; ++i) { fPlanes[i] = rhs.fPlanes[i]; }
96}
int G4int
Definition: G4Types.hh:85

Member Function Documentation

◆ BoundingLimits()

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

Reimplemented from G4VSolid.

Definition at line 248 of file G4Trd.cc.

249{
255
256 G4double xmax = std::max(dx1,dx2);
257 G4double ymax = std::max(dy1,dy2);
258 pMin.set(-xmax,-ymax,-dz);
259 pMax.set( xmax, ymax, dz);
260
261 // Check correctness of the bounding box
262 //
263 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
264 {
265 std::ostringstream message;
266 message << "Bad bounding box (min >= max) for solid: "
267 << GetName() << " !"
268 << "\npMin = " << pMin
269 << "\npMax = " << pMax;
270 G4Exception("G4Trd::BoundingLimits()", "GeomMgt0001", JustWarning, message);
271 DumpInfo();
272 }
273}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
double G4double
Definition: G4Types.hh:83
double z() const
double x() const
double y() const
void set(double x, double y, double z)
G4double GetXHalfLength2() const
G4double GetYHalfLength2() const
G4double GetXHalfLength1() const
G4double GetYHalfLength1() const
G4double GetZHalfLength() const
G4String GetName() const
void DumpInfo() const

Referenced by CalculateExtent().

◆ CalculateExtent()

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

Implements G4VSolid.

Definition at line 279 of file G4Trd.cc.

283{
284 G4ThreeVector bmin, bmax;
285 G4bool exist;
286
287 // Check bounding box (bbox)
288 //
289 BoundingLimits(bmin,bmax);
290 G4BoundingEnvelope bbox(bmin,bmax);
291#ifdef G4BBOX_EXTENT
292 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
293#endif
294 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
295 {
296 return exist = (pMin < pMax) ? true : false;
297 }
298
299 // Set bounding envelope (benv) and calculate extent
300 //
306
307 G4ThreeVectorList baseA(4), baseB(4);
308 baseA[0].set(-dx1,-dy1,-dz);
309 baseA[1].set( dx1,-dy1,-dz);
310 baseA[2].set( dx1, dy1,-dz);
311 baseA[3].set(-dx1, dy1,-dz);
312 baseB[0].set(-dx2,-dy2, dz);
313 baseB[1].set( dx2,-dy2, dz);
314 baseB[2].set( dx2, dy2, dz);
315 baseB[3].set(-dx2, dy2, dz);
316
317 std::vector<const G4ThreeVectorList *> polygons(2);
318 polygons[0] = &baseA;
319 polygons[1] = &baseB;
320
321 G4BoundingEnvelope benv(bmin,bmax,polygons);
322 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
323 return exist;
324}
std::vector< G4ThreeVector > G4ThreeVectorList
bool G4bool
Definition: G4Types.hh:86
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
Definition: G4Trd.cc:248

◆ Clone()

G4VSolid * G4Trd::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 686 of file G4Trd.cc.

687{
688 return new G4Trd(*this);
689}
Definition: G4Trd.hh:63

◆ ComputeDimensions()

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

Reimplemented from G4VSolid.

Definition at line 237 of file G4Trd.cc.

240{
241 p->ComputeDimensions(*this,n,pRep);
242}
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const

◆ CreatePolyhedron()

G4Polyhedron * G4Trd::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 804 of file G4Trd.cc.

805{
806 return new G4PolyhedronTrd2 (fDx1, fDx2, fDy1, fDy2, fDz);
807}

◆ DescribeYourselfTo()

void G4Trd::DescribeYourselfTo ( G4VGraphicsScene scene) const
virtual

Implements G4VSolid.

Definition at line 799 of file G4Trd.cc.

800{
801 scene.AddSolid (*this);
802}
virtual void AddSolid(const G4Box &)=0

◆ DistanceToIn() [1/2]

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

Implements G4VSolid.

Definition at line 545 of file G4Trd.cc.

546{
547 G4double dx = fPlanes[3].a*std::abs(p.x())+fPlanes[3].c*p.z()+fPlanes[3].d;
548 G4double dy = fPlanes[1].b*std::abs(p.y())+fPlanes[1].c*p.z()+fPlanes[1].d;
549 G4double dxy = std::max(dx,dy);
550
551 G4double dz = std::abs(p.z())-fDz;
552 G4double dist = std::max(dz,dxy);
553
554 return (dist > 0) ? dist : 0.;
555}

◆ DistanceToIn() [2/2]

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

Implements G4VSolid.

Definition at line 452 of file G4Trd.cc.

454{
455 // Z intersections
456 //
457 if ((std::abs(p.z()) - fDz) >= -halfCarTolerance && p.z()*v.z() >= 0)
458 return kInfinity;
459 G4double invz = (-v.z() == 0) ? DBL_MAX : -1./v.z();
460 G4double dz = (invz < 0) ? fDz : -fDz;
461 G4double tzmin = (p.z() + dz)*invz;
462 G4double tzmax = (p.z() - dz)*invz;
463
464 // Y intersections
465 //
466 G4double tmin0 = tzmin, tmax0 = tzmax;
467 G4double ya = fPlanes[0].b*v.y(), yb = fPlanes[0].c*v.z();
468 G4double yc = fPlanes[0].b*p.y(), yd = fPlanes[0].c*p.z()+fPlanes[0].d;
469 G4double cos0 = yb + ya;
470 G4double dis0 = yd + yc;
471 if (dis0 >= -halfCarTolerance)
472 {
473 if (cos0 >= 0) return kInfinity;
474 G4double tmp = -dis0/cos0;
475 if (tmin0 < tmp) tmin0 = tmp;
476 }
477 else if (cos0 > 0)
478 {
479 G4double tmp = -dis0/cos0;
480 if (tmax0 > tmp) tmax0 = tmp;
481 }
482
483 G4double tmin1 = tmin0, tmax1 = tmax0;
484 G4double cos1 = yb - ya;
485 G4double dis1 = yd - yc;
486 if (dis1 >= -halfCarTolerance)
487 {
488 if (cos1 >= 0) return kInfinity;
489 G4double tmp = -dis1/cos1;
490 if (tmin1 < tmp) tmin1 = tmp;
491 }
492 else if (cos1 > 0)
493 {
494 G4double tmp = -dis1/cos1;
495 if (tmax1 > tmp) tmax1 = tmp;
496 }
497
498 // X intersections
499 //
500 G4double tmin2 = tmin1, tmax2 = tmax1;
501 G4double xa = fPlanes[2].a*v.x(), xb = fPlanes[2].c*v.z();
502 G4double xc = fPlanes[2].a*p.x(), xd = fPlanes[2].c*p.z()+fPlanes[2].d;
503 G4double cos2 = xb + xa;
504 G4double dis2 = xd + xc;
505 if (dis2 >= -halfCarTolerance)
506 {
507 if (cos2 >= 0) return kInfinity;
508 G4double tmp = -dis2/cos2;
509 if (tmin2 < tmp) tmin2 = tmp;
510 }
511 else if (cos2 > 0)
512 {
513 G4double tmp = -dis2/cos2;
514 if (tmax2 > tmp) tmax2 = tmp;
515 }
516
517 G4double tmin3 = tmin2, tmax3 = tmax2;
518 G4double cos3 = xb - xa;
519 G4double dis3 = xd - xc;
520 if (dis3 >= -halfCarTolerance)
521 {
522 if (cos3 >= 0) return kInfinity;
523 G4double tmp = -dis3/cos3;
524 if (tmin3 < tmp) tmin3 = tmp;
525 }
526 else if (cos3 > 0)
527 {
528 G4double tmp = -dis3/cos3;
529 if (tmax3 > tmp) tmax3 = tmp;
530 }
531
532 // Find distance
533 //
534 G4double tmin = tmin3, tmax = tmax3;
535 if (tmax <= tmin + halfCarTolerance) return kInfinity; // touch or no hit
536 return (tmin < halfCarTolerance ) ? 0. : tmin;
537}
#define DBL_MAX
Definition: templates.hh:62

◆ DistanceToOut() [1/2]

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

Implements G4VSolid.

Definition at line 645 of file G4Trd.cc.

646{
647#ifdef G4CSGDEBUG
648 if( Inside(p) == kOutside )
649 {
650 std::ostringstream message;
651 G4long oldprc = message.precision(16);
652 message << "Point p is outside (!?) of solid: " << GetName() << G4endl;
653 message << "Position:\n";
654 message << " p.x() = " << p.x()/mm << " mm\n";
655 message << " p.y() = " << p.y()/mm << " mm\n";
656 message << " p.z() = " << p.z()/mm << " mm";
657 G4cout.precision(oldprc);
658 G4Exception("G4Trd::DistanceToOut(p)", "GeomSolids1002",
659 JustWarning, message );
660 DumpInfo();
661 }
662#endif
663 G4double dx = fPlanes[3].a*std::abs(p.x())+fPlanes[3].c*p.z()+fPlanes[3].d;
664 G4double dy = fPlanes[1].b*std::abs(p.y())+fPlanes[1].c*p.z()+fPlanes[1].d;
665 G4double dxy = std::max(dx,dy);
666
667 G4double dz = std::abs(p.z())-fDz;
668 G4double dist = std::max(dz,dxy);
669
670 return (dist < 0) ? -dist : 0.;
671}
long G4long
Definition: G4Types.hh:87
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
EInside Inside(const G4ThreeVector &p) const
Definition: G4Trd.cc:330
@ kOutside
Definition: geomdefs.hh:68

◆ DistanceToOut() [2/2]

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

Implements G4VSolid.

Definition at line 563 of file G4Trd.cc.

566{
567 // Z intersections
568 //
569 if ((std::abs(p.z()) - fDz) >= -halfCarTolerance && p.z()*v.z() > 0)
570 {
571 if (calcNorm)
572 {
573 *validNorm = true;
574 n->set(0, 0, (p.z() < 0) ? -1 : 1);
575 }
576 return 0;
577 }
578 G4double vz = v.z();
579 G4double tmax = (vz == 0) ? DBL_MAX : (std::copysign(fDz,vz) - p.z())/vz;
580 G4int iside = (vz < 0) ? -4 : -2; // little trick: (-4+3)=-1, (-2+3)=+1
581
582 // Y intersections
583 //
584 G4int i = 0;
585 for ( ; i<2; ++i)
586 {
587 G4double cosa = fPlanes[i].b*v.y() + fPlanes[i].c*v.z();
588 if (cosa > 0)
589 {
590 G4double dist = fPlanes[i].b*p.y()+fPlanes[i].c*p.z()+fPlanes[i].d;
591 if (dist >= -halfCarTolerance)
592 {
593 if (calcNorm)
594 {
595 *validNorm = true;
596 n->set(0, fPlanes[i].b, fPlanes[i].c);
597 }
598 return 0;
599 }
600 G4double tmp = -dist/cosa;
601 if (tmax > tmp) { tmax = tmp; iside = i; }
602 }
603 }
604
605 // X intersections
606 //
607 for ( ; i<4; ++i)
608 {
609 G4double cosa = fPlanes[i].a*v.x()+fPlanes[i].c*v.z();
610 if (cosa > 0)
611 {
612 G4double dist = fPlanes[i].a*p.x()+fPlanes[i].c*p.z()+fPlanes[i].d;
613 if (dist >= -halfCarTolerance)
614 {
615 if (calcNorm)
616 {
617 *validNorm = true;
618 n->set(fPlanes[i].a, fPlanes[i].b, fPlanes[i].c);
619 }
620 return 0;
621 }
622 G4double tmp = -dist/cosa;
623 if (tmax > tmp) { tmax = tmp; iside = i; }
624 }
625 }
626
627 // Set normal, if required, and return distance
628 //
629 if (calcNorm)
630 {
631 *validNorm = true;
632 if (iside < 0)
633 n->set(0, 0, iside + 3); // (-4+3)=-1, (-2+3)=+1
634 else
635 n->set(fPlanes[iside].a, fPlanes[iside].b, fPlanes[iside].c);
636 }
637 return tmax;
638}
G4double b
Definition: G4Trd.hh:170
G4double c
Definition: G4Trd.hh:170

◆ GetCubicVolume()

G4double G4Trd::GetCubicVolume ( )
virtual

Reimplemented from G4VSolid.

Definition at line 208 of file G4Trd.cc.

209{
210 if (fCubicVolume == 0.)
211 {
212 fCubicVolume = 2*fDz*( (fDx1+fDx2)*(fDy1+fDy2) +
213 (fDx2-fDx1)*(fDy2-fDy1)/3 );
214 }
215 return fCubicVolume;
216}
G4double fCubicVolume
Definition: G4CSGSolid.hh:70

◆ GetEntityType()

G4GeometryType G4Trd::GetEntityType ( ) const
virtual

Implements G4VSolid.

Definition at line 677 of file G4Trd.cc.

678{
679 return G4String("G4Trd");
680}

◆ GetPointOnSurface()

G4ThreeVector G4Trd::GetPointOnSurface ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 718 of file G4Trd.cc.

719{
720 // Set areas
721 //
722 G4double sxz = (fDx1 + fDx2)*fHx;
723 G4double syz = (fDy1 + fDy2)*fHy;
724 G4double ssurf[6] = { 4.*fDx1*fDy1, sxz, sxz, syz, syz, 4.*fDx2*fDy2 };
725 ssurf[1] += ssurf[0];
726 ssurf[2] += ssurf[1];
727 ssurf[3] += ssurf[2];
728 ssurf[4] += ssurf[3];
729 ssurf[5] += ssurf[4];
730
731 // Select face
732 //
733 G4double select = ssurf[5]*G4QuickRand();
734 G4int k = 5;
735 k -= (select <= ssurf[4]);
736 k -= (select <= ssurf[3]);
737 k -= (select <= ssurf[2]);
738 k -= (select <= ssurf[1]);
739 k -= (select <= ssurf[0]);
740
741 // Generate point on selected surface
742 //
743 G4double u = G4QuickRand();
744 G4double v = G4QuickRand();
745 switch(k)
746 {
747 case 0: // base at -Z
748 {
749 return G4ThreeVector((2.*u - 1.)*fDx1, (2.*v - 1.)*fDy1, -fDz);
750 }
751 case 1: // X face at -Y
752 {
753 if (u + v > 1.) { u = 1. - u; v = 1. - v; }
754 G4ThreeVector p0(-fDx1,-fDy1,-fDz);
755 G4ThreeVector p1( fDx2,-fDy2, fDz);
756 return (select <= ssurf[0] + fDx1*fHx) ?
757 (1. - u - v)*p0 + u*p1 + v*G4ThreeVector( fDx1,-fDy1,-fDz) :
758 (1. - u - v)*p0 + u*p1 + v*G4ThreeVector(-fDx2,-fDy2, fDz);
759 }
760 case 2: // X face at +Y
761 {
762 if (u + v > 1.) { u = 1. - u; v = 1. - v; }
763 G4ThreeVector p0( fDx1, fDy1,-fDz);
764 G4ThreeVector p1(-fDx2, fDy2, fDz);
765 return (select <= ssurf[1] + fDx1*fHx) ?
766 (1. - u - v)*p0 + u*p1 + v*G4ThreeVector(-fDx1, fDy1,-fDz) :
767 (1. - u - v)*p0 + u*p1 + v*G4ThreeVector( fDx2, fDy2, fDz);
768 }
769 case 3: // Y face at -X
770 {
771 if (u + v > 1.) { u = 1. - u; v = 1. - v; }
772 G4ThreeVector p0(-fDx1, fDy1,-fDz);
773 G4ThreeVector p1(-fDx2,-fDy2, fDz);
774 return (select <= ssurf[2] + fDy1*fHy) ?
775 (1. - u - v)*p0 + u*p1 + v*G4ThreeVector(-fDx1,-fDy1,-fDz) :
776 (1. - u - v)*p0 + u*p1 + v*G4ThreeVector(-fDx2, fDy2, fDz);
777 }
778 case 4: // Y face at +X
779 {
780 if (u + v > 1.) { u = 1. - u; v = 1. - v; }
781 G4ThreeVector p0( fDx1,-fDy1,-fDz);
782 G4ThreeVector p1( fDx2, fDy2, fDz);
783 return (select <= ssurf[3] + fDy1*fHy) ?
784 (1. - u - v)*p0 + u*p1 + v*G4ThreeVector( fDx1, fDy1,-fDz) :
785 (1. - u - v)*p0 + u*p1 + v*G4ThreeVector( fDx2,-fDy2, fDz);
786 }
787 case 5: // base at +Z
788 {
789 return G4ThreeVector((2.*u - 1.)*fDx2, (2.*v - 1.)*fDy2, fDz);
790 }
791 }
792 return G4ThreeVector(0., 0., 0.);
793}
G4double G4QuickRand()
Definition: G4QuickRand.hh:34
CLHEP::Hep3Vector G4ThreeVector

◆ GetSurfaceArea()

G4double G4Trd::GetSurfaceArea ( )
virtual

Reimplemented from G4VSolid.

Definition at line 222 of file G4Trd.cc.

223{
224 if (fSurfaceArea == 0.)
225 {
227 4*(fDx1*fDy1 + fDx2*fDy2) + 2*(fDx1+fDx2)*fHx + 2*(fDy1+fDy2)*fHy;
228 }
229 return fSurfaceArea;
230}
G4double fSurfaceArea
Definition: G4CSGSolid.hh:71

◆ GetXHalfLength1()

◆ GetXHalfLength2()

◆ GetYHalfLength1()

◆ GetYHalfLength2()

◆ GetZHalfLength()

◆ Inside()

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

Implements G4VSolid.

Definition at line 330 of file G4Trd.cc.

331{
332 G4double dx = fPlanes[3].a*std::abs(p.x())+fPlanes[3].c*p.z()+fPlanes[3].d;
333 G4double dy = fPlanes[1].b*std::abs(p.y())+fPlanes[1].c*p.z()+fPlanes[1].d;
334 G4double dxy = std::max(dx,dy);
335
336 G4double dz = std::abs(p.z())-fDz;
337 G4double dist = std::max(dz,dxy);
338
339 return (dist > halfCarTolerance) ? kOutside :
340 ((dist > -halfCarTolerance) ? kSurface : kInside);
341}
@ kInside
Definition: geomdefs.hh:70
@ kSurface
Definition: geomdefs.hh:69

Referenced by DistanceToOut().

◆ operator=()

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

Definition at line 102 of file G4Trd.cc.

103{
104 // Check assignment to self
105 //
106 if (this == &rhs) { return *this; }
107
108 // Copy base class data
109 //
111
112 // Copy data
113 //
114 halfCarTolerance = rhs.halfCarTolerance;
115 fDx1 = rhs.fDx1; fDx2 = rhs.fDx2;
116 fDy1 = rhs.fDy1; fDy2 = rhs.fDy2;
117 fDz = rhs.fDz;
118 fHx = rhs.fHx; fHy = rhs.fHy;
119 for (G4int i=0; i<4; ++i) { fPlanes[i] = rhs.fPlanes[i]; }
120
121 return *this;
122}
G4CSGSolid & operator=(const G4CSGSolid &rhs)
Definition: G4CSGSolid.cc:89

◆ SetAllParameters()

void G4Trd::SetAllParameters ( G4double  pdx1,
G4double  pdx2,
G4double  pdy1,
G4double  pdy2,
G4double  pdz 
)

Definition at line 128 of file G4Trd.cc.

130{
131 // Reset data of the base class
132 fCubicVolume = 0.;
133 fSurfaceArea = 0.;
134 fRebuildPolyhedron = true;
135
136 // Set parameters
137 fDx1 = pdx1; fDx2 = pdx2;
138 fDy1 = pdy1; fDy2 = pdy2;
139 fDz = pdz;
140
141 CheckParameters();
142 MakePlanes();
143}
G4bool fRebuildPolyhedron
Definition: G4CSGSolid.hh:72

Referenced by G4ParameterisationTrdX::ComputeDimensions(), G4ParameterisationTrdY::ComputeDimensions(), and G4ParameterisationTrdZ::ComputeDimensions().

◆ SetXHalfLength1()

void G4Trd::SetXHalfLength1 ( G4double  val)
inline

◆ SetXHalfLength2()

void G4Trd::SetXHalfLength2 ( G4double  val)
inline

◆ SetYHalfLength1()

void G4Trd::SetYHalfLength1 ( G4double  val)
inline

◆ SetYHalfLength2()

void G4Trd::SetYHalfLength2 ( G4double  val)
inline

◆ SetZHalfLength()

void G4Trd::SetZHalfLength ( G4double  val)
inline

◆ StreamInfo()

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

Reimplemented from G4CSGSolid.

Definition at line 695 of file G4Trd.cc.

696{
697 G4long oldprc = os.precision(16);
698 os << "-----------------------------------------------------------\n"
699 << " *** Dump for solid - " << GetName() << " ***\n"
700 << " ===================================================\n"
701 << " Solid type: G4Trd\n"
702 << " Parameters: \n"
703 << " half length X, surface -dZ: " << fDx1/mm << " mm \n"
704 << " half length X, surface +dZ: " << fDx2/mm << " mm \n"
705 << " half length Y, surface -dZ: " << fDy1/mm << " mm \n"
706 << " half length Y, surface +dZ: " << fDy2/mm << " mm \n"
707 << " half length Z : " << fDz/mm << " mm \n"
708 << "-----------------------------------------------------------\n";
709 os.precision(oldprc);
710
711 return os;
712}

◆ SurfaceNormal()

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

Implements G4VSolid.

Definition at line 347 of file G4Trd.cc.

348{
349 G4int nsurf = 0; // number of surfaces where p is placed
350
351 // Check Z faces
352 //
353 G4double nz = 0;
354 G4double dz = std::abs(p.z()) - fDz;
355 if (std::abs(dz) <= halfCarTolerance)
356 {
357 nz = (p.z() < 0) ? -1 : 1;
358 ++nsurf;
359 }
360
361 // Check Y faces
362 //
363 G4double ny = 0;
364 G4double dy1 = fPlanes[0].b*p.y();
365 G4double dy2 = fPlanes[0].c*p.z() + fPlanes[0].d;
366 if (std::abs(dy2 + dy1) <= halfCarTolerance)
367 {
368 ny += fPlanes[0].b;
369 nz += fPlanes[0].c;
370 ++nsurf;
371 }
372 if (std::abs(dy2 - dy1) <= halfCarTolerance)
373 {
374 ny += fPlanes[1].b;
375 nz += fPlanes[1].c;
376 ++nsurf;
377 }
378
379 // Check X faces
380 //
381 G4double nx = 0;
382 G4double dx1 = fPlanes[2].a*p.x();
383 G4double dx2 = fPlanes[2].c*p.z() + fPlanes[2].d;
384 if (std::abs(dx2 + dx1) <= halfCarTolerance)
385 {
386 nx += fPlanes[2].a;
387 nz += fPlanes[2].c;
388 ++nsurf;
389 }
390 if (std::abs(dx2 - dx1) <= halfCarTolerance)
391 {
392 nx += fPlanes[3].a;
393 nz += fPlanes[3].c;
394 ++nsurf;
395 }
396
397 // Return normal
398 //
399 if (nsurf == 1) return G4ThreeVector(nx,ny,nz);
400 else if (nsurf != 0) return G4ThreeVector(nx,ny,nz).unit(); // edge or corner
401 else
402 {
403 // Point is not on the surface
404 //
405#ifdef G4CSGDEBUG
406 std::ostringstream message;
407 G4long oldprc = message.precision(16);
408 message << "Point p is not on surface (!?) of solid: "
409 << GetName() << G4endl;
410 message << "Position:\n";
411 message << " p.x() = " << p.x()/mm << " mm\n";
412 message << " p.y() = " << p.y()/mm << " mm\n";
413 message << " p.z() = " << p.z()/mm << " mm";
414 G4cout.precision(oldprc) ;
415 G4Exception("G4Trd::SurfaceNormal(p)", "GeomSolids1002",
416 JustWarning, message );
417 DumpInfo();
418#endif
419 return ApproxSurfaceNormal(p);
420 }
421}
Hep3Vector unit() const

Member Data Documentation

◆ a

G4double G4Trd::a

Definition at line 170 of file G4Trd.hh.

Referenced by DistanceToOut().

◆ b

G4double G4Trd::b

Definition at line 170 of file G4Trd.hh.

Referenced by DistanceToOut().

◆ c

G4double G4Trd::c

Definition at line 170 of file G4Trd.hh.

Referenced by DistanceToOut().

◆ d

G4double G4Trd::d

Definition at line 170 of file G4Trd.hh.


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