Geant4 11.4.0
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/cylinder.
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// Author: V.Grichine (CERN), 30.10.1996 - First version
71// E.Medernach (CERN), 31.08.2000 - 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
91/**
92 * @brief G4Torus represents a torus or torus segment with curved sides
93 * parallel to the z-axis. The torus has a specified swept radius about which
94 * it is centered, and a given minimum and maximum radius. A minimum radius
95 * of 0 signifies a filled torus.
96 * The torus segment is specified by starting and delta angles for phi,
97 * with 0 being the +x axis, PI/2 the +y axis. A delta angle of 2PI
98 * signifies a complete, unsegmented torus/cylinder.
99 */
100
101class G4Torus : public G4CSGSolid
102{
103
104 public:
105
106 /**
107 * Constructs a torus or torus segment with the given name and dimensions.
108 * @param[in] pName The name of the solid.
109 * @param[in] pRmin Inner radius.
110 * @param[in] pRmax Outer radius.
111 * @param[in] pRtor Swept radius of torus.
112 * @param[in] pSPhi Starting Phi angle in radians
113 * adjusted such that fSPhi+fDPhi<=2PI, fSPhi>-2PI.
114 * @param[in] pDPhi Delta angle of the segment in radians.
115 */
116 G4Torus(const G4String& pName,
117 G4double pRmin,
118 G4double pRmax,
119 G4double pRtor,
120 G4double pSPhi,
121 G4double pDPhi);
122
123 /**
124 * Default destructor.
125 */
126 ~G4Torus() override = default;
127
128 /**
129 * Accessors.
130 */
131 inline G4double GetRmin() const;
132 inline G4double GetRmax() const;
133 inline G4double GetRtor() const;
134 inline G4double GetSPhi() const;
135 inline G4double GetDPhi() const;
136 inline G4double GetSinStartPhi () const;
137 inline G4double GetCosStartPhi () const;
138 inline G4double GetSinEndPhi () const;
139 inline G4double GetCosEndPhi () const;
140
141 /**
142 * Returning an estimation of the solid volume (capacity) and
143 * surface area, in internal units.
144 */
145 G4double GetCubicVolume() override;
146 G4double GetSurfaceArea() override;
147
148 /**
149 * Dispatch method for parameterisation replication mechanism and
150 * dimension computation.
151 */
153 const G4int n,
154 const G4VPhysicalVolume* pRep) override;
155
156 /**
157 * Computes the bounding limits of the solid.
158 * @param[out] pMin The minimum bounding limit point.
159 * @param[out] pMax The maximum bounding limit point.
160 */
161 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
162
163 /**
164 * Calculates the minimum and maximum extent of the solid, when under the
165 * specified transform, and within the specified limits.
166 * @param[in] pAxis The axis along which compute the extent.
167 * @param[in] pVoxelLimit The limiting space dictated by voxels.
168 * @param[in] pTransform The internal transformation applied to the solid.
169 * @param[out] pMin The minimum extent value.
170 * @param[out] pMax The maximum extent value.
171 * @returns True if the solid is intersected by the extent region.
172 */
173 G4bool CalculateExtent(const EAxis pAxis,
174 const G4VoxelLimits& pVoxelLimit,
175 const G4AffineTransform& pTransform,
176 G4double& pmin, G4double& pmax) const override;
177
178 /**
179 * Concrete implementations of the expected query interfaces for
180 * solids, as defined in the base class G4VSolid.
181 */
182 EInside Inside(const G4ThreeVector& p) const override;
183 G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const override;
185 const G4ThreeVector& v) const override;
186 G4double DistanceToIn(const G4ThreeVector& p) const override;
188 const G4bool calcNorm = false,
189 G4bool* validNorm = nullptr,
190 G4ThreeVector* n = nullptr) const override;
191 G4double DistanceToOut(const G4ThreeVector& p) const override;
192
193 /**
194 * Returns the type ID, "G4Torus" of the solid.
195 */
196 G4GeometryType GetEntityType() const override;
197
198 /**
199 * Returns a random point located and uniformly distributed on the
200 * surface of the solid.
201 */
202 G4ThreeVector GetPointOnSurface() const override;
203
204 /**
205 * Makes a clone of the object for use in multi-treading.
206 * @returns A pointer to the new cloned allocated solid.
207 */
208 G4VSolid* Clone() const override;
209
210 /**
211 * Streams the object contents to an output stream.
212 */
213 std::ostream& StreamInfo(std::ostream& os) const override;
214
215 /**
216 * Methods for creating graphical representations (i.e. for visualisation).
217 */
218 void DescribeYourselfTo (G4VGraphicsScene& scene) const override;
219 G4Polyhedron* CreatePolyhedron () const override;
220
221 /**
222 * Checks and sets all the parameters given in input. Used in constructor.
223 */
224 void SetAllParameters(G4double pRmin, G4double pRmax, G4double pRtor,
225 G4double pSPhi, G4double pDPhi);
226
227 /**
228 * Fake default constructor for usage restricted to direct object
229 * persistency for clients requiring preallocation of memory for
230 * persistifiable objects.
231 */
232 G4Torus(__void__&);
233
234 /**
235 * Copy constructor and assignment operator.
236 */
237 G4Torus(const G4Torus& rhs) = default;
238 G4Torus& operator=(const G4Torus& rhs);
239
240 private:
241
242 /**
243 * Calculates the real roots to the torus surface, using the
244 * G4JTPolynomialSolver class. Returns negative solutions as well.
245 */
246 void TorusRootsJT(const G4ThreeVector& p,
247 const G4ThreeVector& v,
248 G4double r,
249 std::vector<G4double>& roots) const ;
250
251 /**
252 * Interface method for DistanceToIn() and DistanceToOut().
253 * Calls TorusRootsJT() using the Jenkins-Traub algorithm for real
254 * polynomial root finding.
255 * @returns The smalles possible distance to the surface.
256 */
257 G4double SolveNumericJT(const G4ThreeVector& p,
258 const G4ThreeVector& v,
259 G4double r,
260 G4bool IsDistanceToIn) const;
261
262 /**
263 * Algorithm for SurfaceNormal() following the original specification
264 * for points not on the surface.
265 */
266 G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p) const;
267
268 private:
269
270 /** The cached parameters, ensured within range. */
271 G4double fRmin, fRmax, fRtor, fSPhi, fDPhi;
272
273 /** Radial and angular tolerances. */
274 G4double fRminTolerance, fRmaxTolerance, kRadTolerance, kAngTolerance;
275
276 /** Cached half tolerance values. */
277 G4double halfCarTolerance, halfAngTolerance;
278};
279
280#include "G4Torus.icc"
281
282#endif // defined(G4GEOM_USE_UTORUS) && defined(G4GEOM_USE_SYS_USOLIDS)
283
284
285#endif // G4TORUS_HH
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4String G4GeometryType
Definition G4VSolid.hh:70
G4AffineTransform is a class for geometric affine transformations. It supports efficient arbitrary ro...
G4CSGSolid(const G4String &pName)
Definition G4CSGSolid.cc:49
G4Torus & operator=(const G4Torus &rhs)
Definition G4Torus.cc:188
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
Definition G4Torus.cc:215
G4double GetSinEndPhi() const
std::ostream & StreamInfo(std::ostream &os) const override
Definition G4Torus.cc:1565
G4ThreeVector GetPointOnSurface() const override
Definition G4Torus.cc:1588
G4VSolid * Clone() const override
Definition G4Torus.cc:1556
G4double GetDPhi() const
G4double GetRmin() const
void SetAllParameters(G4double pRmin, G4double pRmax, G4double pRtor, G4double pSPhi, G4double pDPhi)
Definition G4Torus.cc:94
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override
Definition G4Torus.cc:917
~G4Torus() override=default
EInside Inside(const G4ThreeVector &p) const override
Definition G4Torus.cc:570
G4GeometryType GetEntityType() const override
Definition G4Torus.cc:1547
G4double GetSurfaceArea() override
Definition G4Torus.cc:1642
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:1140
G4double GetCubicVolume() override
Definition G4Torus.cc:1627
G4Polyhedron * CreatePolyhedron() const override
Definition G4Torus.cc:1666
G4Torus(const G4String &pName, G4double pRmin, G4double pRmax, G4double pRtor, G4double pSPhi, G4double pDPhi)
Definition G4Torus.cc:78
G4double GetRmax() const
void DescribeYourselfTo(G4VGraphicsScene &scene) const override
Definition G4Torus.cc:1661
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const override
Definition G4Torus.cc:680
G4double GetCosStartPhi() const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const override
Definition G4Torus.cc:429
G4double GetSPhi() const
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
Definition G4Torus.cc:384
G4double GetCosEndPhi() const
G4double GetSinStartPhi() const
G4Torus(const G4Torus &rhs)=default
G4VPVParameterisation ia an abstract base class for Parameterisation, able to compute the transformat...
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
G4VSolid(const G4String &name)
Definition G4VSolid.cc:59
G4VoxelLimits represents limitation/restrictions of space, where restrictions are only made perpendic...
EAxis
Definition geomdefs.hh:54
EInside
Definition geomdefs.hh:67