Geant4 11.2.2
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 () override
 
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 () override
 
G4double GetSurfaceArea () override
 
void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
 
void BoundingLimits (G4ThreeVector &pMin, G4ThreeVector &pMax) const override
 
G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const override
 
EInside Inside (const G4ThreeVector &p) const override
 
G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const override
 
G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const override
 
G4double DistanceToIn (const G4ThreeVector &p) const override
 
G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
 
G4double DistanceToOut (const G4ThreeVector &p) const override
 
G4GeometryType GetEntityType () const override
 
G4ThreeVector GetPointOnSurface () const override
 
G4VSolidClone () const override
 
std::ostream & StreamInfo (std::ostream &os) const override
 
void DescribeYourselfTo (G4VGraphicsScene &scene) const override
 
G4PolyhedronCreatePolyhedron () const override
 
 G4Trd (__void__ &)
 
 G4Trd (const G4Trd &rhs)
 
G4Trdoperator= (const G4Trd &rhs)
 
- Public Member Functions inherited from G4CSGSolid
 G4CSGSolid (const G4String &pName)
 
virtual ~G4CSGSolid ()
 
G4PolyhedronGetPolyhedron () const override
 
 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)
 
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}
G4CSGSolid(const G4String &pName)
Definition G4CSGSolid.cc:49
G4double kCarTolerance
Definition G4VSolid.hh:299

Referenced by Clone().

◆ ~G4Trd()

G4Trd::~G4Trd ( )
overridedefault

◆ 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:168

◆ G4Trd() [3/3]

G4Trd::G4Trd ( const G4Trd & rhs)

Definition at line 87 of file G4Trd.cc.

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

Member Function Documentation

◆ BoundingLimits()

void G4Trd::BoundingLimits ( G4ThreeVector & pMin,
G4ThreeVector & pMax ) const
overridevirtual

Reimplemented from G4VSolid.

Definition at line 246 of file G4Trd.cc.

247{
253
254 G4double xmax = std::max(dx1,dx2);
255 G4double ymax = std::max(dy1,dy2);
256 pMin.set(-xmax,-ymax,-dz);
257 pMax.set( xmax, ymax, dz);
258
259 // Check correctness of the bounding box
260 //
261 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
262 {
263 std::ostringstream message;
264 message << "Bad bounding box (min >= max) for solid: "
265 << GetName() << " !"
266 << "\npMin = " << pMin
267 << "\npMax = " << pMax;
268 G4Exception("G4Trd::BoundingLimits()", "GeomMgt0001", JustWarning, message);
269 DumpInfo();
270 }
271}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
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
overridevirtual

Implements G4VSolid.

Definition at line 277 of file G4Trd.cc.

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

◆ Clone()

G4VSolid * G4Trd::Clone ( ) const
overridevirtual

Reimplemented from G4VSolid.

Definition at line 684 of file G4Trd.cc.

685{
686 return new G4Trd(*this);
687}
G4Trd(const G4String &pName, G4double pdx1, G4double pdx2, G4double pdy1, G4double pdy2, G4double pdz)
Definition G4Trd.cc:54

◆ ComputeDimensions()

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

Reimplemented from G4VSolid.

Definition at line 235 of file G4Trd.cc.

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

◆ CreatePolyhedron()

G4Polyhedron * G4Trd::CreatePolyhedron ( ) const
overridevirtual

Reimplemented from G4VSolid.

Definition at line 802 of file G4Trd.cc.

803{
804 return new G4PolyhedronTrd2 (fDx1, fDx2, fDy1, fDy2, fDz);
805}

◆ DescribeYourselfTo()

void G4Trd::DescribeYourselfTo ( G4VGraphicsScene & scene) const
overridevirtual

Implements G4VSolid.

Definition at line 797 of file G4Trd.cc.

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

◆ DistanceToIn() [1/2]

G4double G4Trd::DistanceToIn ( const G4ThreeVector & p) const
overridevirtual

Implements G4VSolid.

Definition at line 543 of file G4Trd.cc.

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

◆ DistanceToIn() [2/2]

G4double G4Trd::DistanceToIn ( const G4ThreeVector & p,
const G4ThreeVector & v ) const
overridevirtual

Implements G4VSolid.

Definition at line 450 of file G4Trd.cc.

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

◆ DistanceToOut() [1/2]

G4double G4Trd::DistanceToOut ( const G4ThreeVector & p) const
overridevirtual

Implements G4VSolid.

Definition at line 643 of file G4Trd.cc.

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

Implements G4VSolid.

Definition at line 561 of file G4Trd.cc.

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

◆ GetCubicVolume()

G4double G4Trd::GetCubicVolume ( )
overridevirtual

Reimplemented from G4VSolid.

Definition at line 206 of file G4Trd.cc.

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

◆ GetEntityType()

G4GeometryType G4Trd::GetEntityType ( ) const
overridevirtual

Implements G4VSolid.

Definition at line 675 of file G4Trd.cc.

676{
677 return {"G4Trd"};
678}

◆ GetPointOnSurface()

G4ThreeVector G4Trd::GetPointOnSurface ( ) const
overridevirtual

Reimplemented from G4VSolid.

Definition at line 716 of file G4Trd.cc.

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

◆ GetSurfaceArea()

G4double G4Trd::GetSurfaceArea ( )
overridevirtual

Reimplemented from G4VSolid.

Definition at line 220 of file G4Trd.cc.

221{
222 if (fSurfaceArea == 0.)
223 {
225 4*(fDx1*fDy1 + fDx2*fDy2) + 2*(fDx1+fDx2)*fHx + 2*(fDy1+fDy2)*fHy;
226 }
227 return fSurfaceArea;
228}
G4double fSurfaceArea
Definition G4CSGSolid.hh:69

◆ GetXHalfLength1()

◆ GetXHalfLength2()

◆ GetYHalfLength1()

◆ GetYHalfLength2()

◆ GetZHalfLength()

◆ Inside()

EInside G4Trd::Inside ( const G4ThreeVector & p) const
overridevirtual

Implements G4VSolid.

Definition at line 328 of file G4Trd.cc.

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

Referenced by DistanceToOut().

◆ operator=()

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

Definition at line 100 of file G4Trd.cc.

101{
102 // Check assignment to self
103 //
104 if (this == &rhs) { return *this; }
105
106 // Copy base class data
107 //
109
110 // Copy data
111 //
112 halfCarTolerance = rhs.halfCarTolerance;
113 fDx1 = rhs.fDx1; fDx2 = rhs.fDx2;
114 fDy1 = rhs.fDy1; fDy2 = rhs.fDy2;
115 fDz = rhs.fDz;
116 fHx = rhs.fHx; fHy = rhs.fHy;
117 for (G4int i=0; i<4; ++i) { fPlanes[i] = rhs.fPlanes[i]; }
118
119 return *this;
120}
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 126 of file G4Trd.cc.

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

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
overridevirtual

Reimplemented from G4CSGSolid.

Definition at line 693 of file G4Trd.cc.

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

◆ SurfaceNormal()

G4ThreeVector G4Trd::SurfaceNormal ( const G4ThreeVector & p) const
overridevirtual

Implements G4VSolid.

Definition at line 345 of file G4Trd.cc.

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

Member Data Documentation

◆ a

G4double G4Trd::a

Definition at line 168 of file G4Trd.hh.

Referenced by DistanceToOut().

◆ b

G4double G4Trd::b

Definition at line 168 of file G4Trd.hh.

Referenced by DistanceToOut().

◆ c

G4double G4Trd::c

Definition at line 168 of file G4Trd.hh.

Referenced by DistanceToOut().

◆ d

G4double G4Trd::d

Definition at line 168 of file G4Trd.hh.


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