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

G4EnclosingCylinder is a utility class defining an envelope for quickly deciding if a point is clearly outside a polyhedra or polycone or deciding if a trajectory is clearly going to miss those shapes. More...

#include <G4EnclosingCylinder.hh>

Public Member Functions

 G4EnclosingCylinder (const G4ReduciblePolygon *rz, G4bool phiIsOpen, G4double startPhi, G4double totalPhi)
 ~G4EnclosingCylinder ()=default
G4bool MustBeOutside (const G4ThreeVector &p) const
G4bool ShouldMiss (const G4ThreeVector &p, const G4ThreeVector &v) const
 G4EnclosingCylinder (__void__ &)

Detailed Description

G4EnclosingCylinder is a utility class defining an envelope for quickly deciding if a point is clearly outside a polyhedra or polycone or deciding if a trajectory is clearly going to miss those shapes.

Definition at line 51 of file G4EnclosingCylinder.hh.

Constructor & Destructor Documentation

◆ G4EnclosingCylinder() [1/2]

G4EnclosingCylinder::G4EnclosingCylinder ( const G4ReduciblePolygon * rz,
G4bool phiIsOpen,
G4double startPhi,
G4double totalPhi )

Constructs the envelope, given its parameters.

Parameters
[in]rzPointer to the polygon structure.
[in]phiIsOpenBoolean flag to indicate if it is a section in Phi.
[in]startPhiStarting Phi angle.
[in]totalPhiTotal Phi angle of the section.

Definition at line 39 of file G4EnclosingCylinder.cc.

43 : startPhi(theStartPhi), totalPhi(theTotalPhi),
44 concave(theTotalPhi > pi)
45{
46 //
47 // Obtain largest r and smallest and largest z
48 //
49 radius = rz->Amax();
50 zHi = rz->Bmax();
51 zLo = rz->Bmin();
52
55 //
56 // Save phi info
57 //
58 phiIsOpen = thePhiIsOpen;
59 if ( phiIsOpen )
60 {
61 rx1 = std::cos(startPhi);
62 ry1 = std::sin(startPhi);
63 dx1 = +ry1*10*kCarTolerance;
64 dy1 = -rx1*10*kCarTolerance;
65
66 rx2 = std::cos(startPhi+totalPhi);
67 ry2 = std::sin(startPhi+totalPhi);
68 dx2 = -ry2*10*kCarTolerance;
69 dy2 = +rx2*10*kCarTolerance;
70 }
71
72 //
73 // Add safety
74 //
75 radius += 10*kCarTolerance;
76 zLo -= 10*kCarTolerance;
77 zHi += 10*kCarTolerance;
78}
const G4double kCarTolerance
double G4double
Definition G4Types.hh:83
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
G4double Bmin() const
G4double Amax() const

◆ ~G4EnclosingCylinder()

G4EnclosingCylinder::~G4EnclosingCylinder ( )
default

Default Destructor.

◆ G4EnclosingCylinder() [2/2]

G4EnclosingCylinder::G4EnclosingCylinder ( __void__ & )

Fake default constructor for usage restricted to direct object persistency for clients requiring preallocation of memory for persistifiable objects.

Definition at line 83 of file G4EnclosingCylinder.cc.

84: radius(0.), zLo(0.), zHi(0.), phiIsOpen(false), startPhi(0.), totalPhi(0.),
85 concave(false)
86{
87}

Member Function Documentation

◆ MustBeOutside()

G4bool G4EnclosingCylinder::MustBeOutside ( const G4ThreeVector & p) const

Decides very rapidly if the point 'p' is outside the cylinder.

Returns
If not certain to be outside, return false.

Definition at line 95 of file G4EnclosingCylinder.cc.

96{
97 if (p.perp() > radius) { return true; }
98 if (p.z() < zLo) { return true; }
99 if (p.z() > zHi) { return true; }
100
101 if (phiIsOpen)
102 {
103 if (concave)
104 {
105 if ( ((p.x()-dx1)*ry1 - (p.y()-dy1)*rx1) < 0) { return false; }
106 if ( ((p.x()-dx2)*ry2 - (p.y()-dy2)*rx2) > 0) { return false; }
107 }
108 else
109 {
110 if ( ((p.x()-dx1)*ry1 - (p.y()-dy1)*rx1) > 0) { return true; }
111 if ( ((p.x()-dx2)*ry2 - (p.y()-dy2)*rx2) < 0) { return true; }
112 }
113 }
114
115 return false;
116}
double z() const
double x() const
double y() const
double perp() const

Referenced by ShouldMiss().

◆ ShouldMiss()

G4bool G4EnclosingCylinder::ShouldMiss ( const G4ThreeVector & p,
const G4ThreeVector & v ) const

Decides very rapidly if the trajectory is going to miss the cylinder.

Returns
If not certain to miss, return false.

Definition at line 124 of file G4EnclosingCylinder.cc.

126{
127 if (!MustBeOutside(p)) { return false; }
128
129 G4double cross = p.x()*v.y() - p.y()*v.x();
130 if (cross > radius) { return true; }
131
132 if (p.perp() > radius)
133 {
134 G4double dot = p.x()*v.x() + p.y()*v.y();
135 if (dot > 0) { return true; }
136 }
137
138 return false;
139}
G4bool MustBeOutside(const G4ThreeVector &p) const

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