Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Torus.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4Torus
27//
28// Class description:
29//
30// A torus or torus segment with curved sides parallel to the z-axis.
31// The torus has a specified swept radius about which it is centered,
32// and a given minimum and maximum radius. A minimum radius of 0
33// signifies a filled torus.
34// The torus segment is specified by starting and delta angles for phi,
35// with 0 being the +x axis, PI/2 the +y axis. A delta angle of 2PI
36// signifies a complete, unsegmented torus/cylindr.
37//
38// Member functions:
39//
40// As inherited from G4CSGSolid+
41//
42// G4Torus(const G4String &pName
43// G4double pRmin
44// G4double pRmax
45// G4double pRtor
46// G4double pSPhi
47// G4double pDPhi )
48//
49// - Construct a torus with the given name and dimensions.
50// The angles are provided is radians. pRtor >= pRmax
51//
52// Member Data:
53//
54// fRmin Inside radius
55// fRmax Outside radius
56// fRtor swept radius of torus
57//
58// fSPhi The starting phi angle in radians,
59// adjusted such that fSPhi+fDPhi<=2PI, fSPhi>-2PI
60//
61// fDPhi Delta angle of the segment in radians
62//
63// You could find very often in G4Torus functions values like 'pt' or
64// 'it'. These are the distances from p or i G4ThreeVector points in the
65// plane (Z axis points p or i) to fRtor point in XY plane. This value is
66// similar to rho for G4Tubs and is used for definiton of the point
67// relative to fRmin and fRmax, i.e. for solution of inside/outside
68// problems
69
70// 30.10.96 V.Grichine: first version
71// 31.08.00 E.Medernach: migrated to numeric solutions
72// --------------------------------------------------------------------
73#ifndef G4TORUS_HH
74#define G4TORUS_HH
75
76#include "G4GeomTypes.hh"
77
78#if defined(G4GEOM_USE_USOLIDS)
79#define G4GEOM_USE_UTORUS 1
80#endif
81
82#if (defined(G4GEOM_USE_UTORUS) && defined(G4GEOM_USE_SYS_USOLIDS))
83 #define G4UTorus G4Torus
84 #include "G4UTorus.hh"
85#else
86
88
89#include "G4CSGSolid.hh"
90
91class G4Torus : public G4CSGSolid
92{
93
94 public:
95
96 G4Torus(const G4String &pName,
97 G4double pRmin,
98 G4double pRmax,
99 G4double pRtor,
100 G4double pSPhi,
101 G4double pDPhi);
102
103 ~G4Torus() override;
104
105 // Accessors
106
107 inline G4double GetRmin() const;
108 inline G4double GetRmax() const;
109 inline G4double GetRtor() const;
110 inline G4double GetSPhi() const;
111 inline G4double GetDPhi() const;
112 inline G4double GetSinStartPhi () const;
113 inline G4double GetCosStartPhi () const;
114 inline G4double GetSinEndPhi () const;
115 inline G4double GetCosEndPhi () const;
116
117 // Methods of solid
118
119 inline G4double GetCubicVolume() override;
120 inline G4double GetSurfaceArea() override;
121
122 EInside Inside(const G4ThreeVector& p) const override;
123 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
124 G4bool CalculateExtent(const EAxis pAxis,
125 const G4VoxelLimits& pVoxelLimit,
126 const G4AffineTransform& pTransform,
127 G4double& pmin, G4double& pmax) const override;
129 const G4int n,
130 const G4VPhysicalVolume* pRep) override;
131 G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const override;
133 const G4ThreeVector& v) const override;
134 G4double DistanceToIn(const G4ThreeVector& p) const override;
136 const G4bool calcNorm = false,
137 G4bool* validNorm = nullptr,
138 G4ThreeVector* n = nullptr) const override;
139 G4double DistanceToOut(const G4ThreeVector& p) const override;
140
141 G4GeometryType GetEntityType() const override;
142
143 G4ThreeVector GetPointOnSurface() const override;
144
145 G4VSolid* Clone() const override;
146
147 std::ostream& StreamInfo(std::ostream& os) const override;
148
149 // Visualisation functions
150
151 void DescribeYourselfTo (G4VGraphicsScene& scene) const override;
152 G4Polyhedron* CreatePolyhedron () const override;
153
154 void SetAllParameters(G4double pRmin, G4double pRmax, G4double pRtor,
155 G4double pSPhi, G4double pDPhi);
156
157 G4Torus(__void__&);
158 // Fake default constructor for usage restricted to direct object
159 // persistency for clients requiring preallocation of memory for
160 // persistifiable objects.
161
162 G4Torus(const G4Torus& rhs);
163 G4Torus& operator=(const G4Torus& rhs);
164 // Copy constructor and assignment operator.
165
166 private:
167
168 void TorusRootsJT(const G4ThreeVector& p,
169 const G4ThreeVector& v,
170 G4double r,
171 std::vector<G4double>& roots) const ;
172
173 G4double SolveNumericJT(const G4ThreeVector& p,
174 const G4ThreeVector& v,
175 G4double r,
176 G4bool IsDistanceToIn) const;
177
178 G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p) const;
179 // Algorithm for SurfaceNormal() following the original
180 // specification for points not on the surface
181
182 private:
183
184 G4double fRmin,fRmax,fRtor,fSPhi,fDPhi;
185
186 // Used by distanceToOut
187 enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi};
188
189 // used by normal
190 enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi};
191
192 G4double fRminTolerance, fRmaxTolerance, kRadTolerance, kAngTolerance;
193 // Radial and angular tolerances
194
195 G4double halfCarTolerance, halfAngTolerance;
196 // Cached half tolerance values
197
198};
199
200#include "G4Torus.icc"
201
202#endif // defined(G4GEOM_USE_UTORUS) && defined(G4GEOM_USE_SYS_USOLIDS)
203
204
205#endif // G4TORUS_HH
ENorm
Definition G4Sphere.cc:65
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4Torus & operator=(const G4Torus &rhs)
Definition G4Torus.cc:187
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
Definition G4Torus.cc:214
G4double GetSinEndPhi() const
G4Torus(const G4Torus &rhs)
std::ostream & StreamInfo(std::ostream &os) const override
Definition G4Torus.cc:1562
G4ThreeVector GetPointOnSurface() const override
Definition G4Torus.cc:1585
G4VSolid * Clone() const override
Definition G4Torus.cc:1553
G4double GetDPhi() const
G4double GetRmin() const
void SetAllParameters(G4double pRmin, G4double pRmax, G4double pRtor, G4double pSPhi, G4double pDPhi)
Definition G4Torus.cc:81
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override
Definition G4Torus.cc:914
EInside Inside(const G4ThreeVector &p) const override
Definition G4Torus.cc:566
G4GeometryType GetEntityType() const override
Definition G4Torus.cc:1544
G4double GetSurfaceArea() override
G4double GetRtor() const
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
Definition G4Torus.cc:1137
G4double GetCubicVolume() override
G4Polyhedron * CreatePolyhedron() const override
Definition G4Torus.cc:1635
G4Torus(const G4String &pName, G4double pRmin, G4double pRmax, G4double pRtor, G4double pSPhi, G4double pDPhi)
Definition G4Torus.cc:65
G4double GetRmax() const
~G4Torus() override
void DescribeYourselfTo(G4VGraphicsScene &scene) const override
Definition G4Torus.cc:1630
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const override
Definition G4Torus.cc:677
G4double GetCosStartPhi() const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const override
Definition G4Torus.cc:428
G4double GetSPhi() const
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
Definition G4Torus.cc:383
G4double GetCosEndPhi() const
G4double GetSinStartPhi() const
EAxis
Definition geomdefs.hh:54
EInside
Definition geomdefs.hh:67