Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Hype.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// G4Hype
27//
28// Class description:
29//
30// This class implements a tube with hyperbolic profile.
31// It describes an hyperbolic volume with curved sides parallel to
32// the z-axis. The solid has a specified half-length along the z axis,
33// about which it is centered, and a given minimum and maximum radius.
34// A minimum radius of 0 signifies a filled Hype (with hyperbolical
35// inner surface). To have a filled Hype the user must specify
36// inner radius = 0 AND inner stereo angle = 0.
37// The inner and outer hyperbolical surfaces can have different
38// stereo angles. A stereo angle of 0 gives a cylindrical surface.
39
40// Authors: Ernesto Lamanna & Francesco Safai Tehrani - Created
41// Rome, INFN & University of Rome "La Sapienza", 09.06.1998.
42// --------------------------------------------------------------------
43#ifndef G4HYPE_HH
44#define G4HYPE_HH
45
46#include "G4GeomTypes.hh"
47
48#if defined(G4GEOM_USE_USOLIDS)
49#define G4GEOM_USE_UHYPE 1
50#endif
51
52#if (defined(G4GEOM_USE_UHYPE) && defined(G4GEOM_USE_SYS_USOLIDS))
53 #define G4UHype G4Hype
54 #include "G4UHype.hh"
55#else
56
57#include "G4VSolid.hh"
58#include "G4ThreeVector.hh"
59#include "G4Polyhedron.hh"
60
63
64/**
65 * @brief G4Hype is a tube with hyperbolic profile; it describes an hyperbolic
66 * volume with curved sides parallel to the Z axis. The solid has a specified
67 * half-length along the Z axis, about which it is centered, and a given
68 * minimum and maximum radii.
69 */
70
71class G4Hype : public G4VSolid
72{
73 public:
74
75 /**
76 * Constructs a hyperbolic tube, given its parameters.
77 * @param[in] pName The solid name.
78 * @param[in] newInnerRadius Inner radius.
79 * @param[in] newOuterRadius Outer radius.
80 * @param[in] newInnerStereo Inner stereo angle in radians.
81 * @param[in] newOuterStereo Outer stereo angle in radians.
82 * @param[in] newHalfLenZ Half length in Z.
83 */
84 G4Hype(const G4String& pName,
85 G4double newInnerRadius,
86 G4double newOuterRadius,
87 G4double newInnerStereo,
88 G4double newOuterStereo,
89 G4double newHalfLenZ);
90
91 /**
92 * Destructor.
93 */
94 ~G4Hype() override;
95
96 /**
97 * Accessors.
98 */
99 inline G4double GetInnerRadius () const;
100 inline G4double GetOuterRadius () const;
101 inline G4double GetZHalfLength () const;
102 inline G4double GetInnerStereo () const;
103 inline G4double GetOuterStereo () const;
104
105 /**
106 * Modifiers.
107 */
108 void SetInnerRadius (G4double newIRad);
109 void SetOuterRadius (G4double newORad);
110 void SetZHalfLength (G4double newHLZ);
111 void SetInnerStereo (G4double newISte);
112 void SetOuterStereo (G4double newOSte);
113
114 /**
115 * Dispatch method for parameterisation replication mechanism and
116 * dimension computation.
117 */
119 const G4int n,
120 const G4VPhysicalVolume* pRep) override;
121
122 /**
123 * Computes the bounding limits of the solid.
124 * @param[out] pMin The minimum bounding limit point.
125 * @param[out] pMax The maximum bounding limit point.
126 */
127 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
128
129 /**
130 * Calculates the minimum and maximum extent of the solid, when under the
131 * specified transform, and within the specified limits.
132 * @param[in] pAxis The axis along which compute the extent.
133 * @param[in] pVoxelLimit The limiting space dictated by voxels.
134 * @param[in] pTransform The internal transformation applied to the solid.
135 * @param[out] pMin The minimum extent value.
136 * @param[out] pMax The maximum extent value.
137 * @returns True if the solid is intersected by the extent region.
138 */
139 G4bool CalculateExtent(const EAxis pAxis,
140 const G4VoxelLimits& pVoxelLimit,
141 const G4AffineTransform& pTransform,
142 G4double& pMin, G4double& pMax) const override;
143
144 /**
145 * Concrete implementations of the expected query interfaces for
146 * solids, as defined in the base class G4VSolid.
147 */
148 EInside Inside(const G4ThreeVector& p) const override;
149 G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
151 const G4ThreeVector& v) const override;
152 G4double DistanceToIn(const G4ThreeVector& p) const override;
154 const G4bool calcNorm = false,
155 G4bool* validNorm = nullptr,
156 G4ThreeVector* n = nullptr) const override;
157 G4double DistanceToOut(const G4ThreeVector& p) const override;
158
159 /**
160 * Returns the type ID, "G4Hype" of the solid.
161 */
162 G4GeometryType GetEntityType() const override;
163
164 /**
165 * Makes a clone of the object for use in multi-treading.
166 * @returns A pointer to the new cloned allocated solid.
167 */
168 G4VSolid* Clone() const override;
169
170 /**
171 * Streams the object contents to an output stream.
172 */
173 std::ostream& StreamInfo(std::ostream& os) const override;
174
175 /**
176 * Returning an estimation of the solid volume (capacity) and
177 * surface area, in internal units.
178 */
179 G4double GetCubicVolume() override;
180 G4double GetSurfaceArea() override;
181
182 /**
183 * Returns a random point located and uniformly distributed on the
184 * surface of the solid.
185 */
186 G4ThreeVector GetPointOnSurface() const override;
187
188 /**
189 * Methods for creating graphical representations (i.e. for visualisation).
190 */
191 void DescribeYourselfTo(G4VGraphicsScene& scene) const override;
192 G4VisExtent GetExtent() const override;
193 G4Polyhedron* CreatePolyhedron() const override;
194 G4Polyhedron* GetPolyhedron() const override;
195
196 /**
197 * Fake default constructor for usage restricted to direct object
198 * persistency for clients requiring preallocation of memory for
199 * persistifiable objects.
200 */
201 G4Hype(__void__&);
202
203 /**
204 * Copy constructor and assignment operator.
205 */
206 G4Hype(const G4Hype& rhs);
207 G4Hype& operator=(const G4Hype& rhs);
208
209 private:
210
211 /**
212 * Tells whether we have an inner surface or not.
213 */
214 inline G4bool InnerSurfaceExists() const;
215
216 /**
217 * Returns the approximate isotropic distance to the hyperbolic surface.
218 */
219 G4double ApproxDistOutside( G4double pr, G4double pz,
220 G4double r0, G4double tanPhi ) const;
221 G4double ApproxDistInside( G4double pr, G4double pz,
222 G4double r0, G4double tan2Phi ) const;
223
224 /**
225 * Returns the values of the hype radii at a given Z.
226 */
227 inline G4double HypeInnerRadius2(G4double zVal) const;
228 inline G4double HypeOuterRadius2(G4double zVal) const;
229
230 /**
231 * Decides if and where a line intersects with a hyperbolic surface
232 * (of infinite extent).
233 * @returns The number of intersections. If 0, the trajectory misses.
234 */
235 G4int IntersectHype( const G4ThreeVector& p, const G4ThreeVector& v,
236 G4double r2, G4double tan2Phi, G4double s[2] ) const;
237
238 private:
239
240 G4double innerRadius;
241 G4double outerRadius;
242 G4double halfLenZ;
243 G4double innerStereo;
244 G4double outerStereo;
245
246 /** Precalculated parameters, squared quantities. */
247 G4double tanInnerStereo; // tan of Inner Stereo angle
248 G4double tanOuterStereo; // tan of Outer Stereo angle
249 G4double tanInnerStereo2; // squared tan of Inner Stereo angle
250 G4double tanOuterStereo2; // squared tan of Outer Stereo angle
251 G4double innerRadius2; // squared Inner Radius
252 G4double outerRadius2; // squared Outer Radius
253 G4double endInnerRadius2; // squared endcap Inner Radius
254 G4double endOuterRadius2; // squared endcap Outer Radius
255 G4double endInnerRadius; // endcap Inner Radius
256 G4double endOuterRadius; // endcap Outer Radius
257
258 /** Used by DistanceToOut(). */
259 enum ESide { outerFace, innerFace, leftCap, rightCap };
260
261 G4double fCubicVolume = 0.0;
262 G4double fSurfaceArea = 0.0;
263 G4double fInnerSurfaceArea = 0.0;
264 G4double fOuterSurfaceArea = 0.0;
265
266 G4double fHalfTol;
267
268 mutable G4bool fRebuildPolyhedron = false;
269 mutable G4Polyhedron* fpPolyhedron = nullptr;
270};
271
272#include "G4Hype.icc"
273
274#endif // defined(G4GEOM_USE_UHYPE) && defined(G4GEOM_USE_SYS_USOLIDS)
275
276#endif // G4HYPE_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...
G4ClippablePolygon in a utility class defining a polygon that can be clipped by a voxel.
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
Definition G4Hype.cc:266
G4Hype(const G4String &pName, G4double newInnerRadius, G4double newOuterRadius, G4double newInnerStereo, G4double newOuterStereo, G4double newHalfLenZ)
Definition G4Hype.cc:61
EInside Inside(const G4ThreeVector &p) const override
Definition G4Hype.cc:313
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
Definition G4Hype.cc:275
void DescribeYourselfTo(G4VGraphicsScene &scene) const override
Definition G4Hype.cc:1272
G4GeometryType GetEntityType() const override
Definition G4Hype.cc:1169
G4Hype & operator=(const G4Hype &rhs)
Definition G4Hype.cc:154
G4VisExtent GetExtent() const override
Definition G4Hype.cc:1279
G4VSolid * Clone() const override
Definition G4Hype.cc:1176
void SetOuterStereo(G4double newOSte)
Definition G4Hype.cc:249
G4Polyhedron * CreatePolyhedron() const override
Definition G4Hype.cc:1290
~G4Hype() override
Definition G4Hype.cc:130
G4ThreeVector GetPointOnSurface() const override
Definition G4Hype.cc:1204
G4Polyhedron * GetPolyhedron() const override
Definition G4Hype.cc:1298
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const override
Definition G4Hype.cc:296
void SetOuterRadius(G4double newORad)
Definition G4Hype.cc:200
G4double GetInnerStereo() const
G4double GetSurfaceArea() override
Definition G4Hype.cc:1259
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
Definition G4Hype.cc:785
std::ostream & StreamInfo(std::ostream &os) const override
Definition G4Hype.cc:1183
void SetZHalfLength(G4double newHLZ)
Definition G4Hype.cc:215
G4double GetZHalfLength() const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const override
Definition G4Hype.cc:354
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override
Definition G4Hype.cc:401
G4double GetOuterStereo() const
G4double GetOuterRadius() const
void SetInnerStereo(G4double newISte)
Definition G4Hype.cc:233
void SetInnerRadius(G4double newIRad)
Definition G4Hype.cc:185
G4double GetInnerRadius() const
G4double GetCubicVolume() override
Definition G4Hype.cc:1245
G4SolidExtentList is utility class designed for calculating the extent of a CSG-like solid for a voxe...
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