Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4CutTubs.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// G4CutTubs
27//
28// Class description:
29//
30// G4CutTubs is a tube with possible cuts in +-Z.
31//
32// G4CutTubs(pName,pRMin,pRMax,pDZ,pSPhi,pEPhi,pLowNorm,pHighNorm)
33// pName,pRMin,pRMax,pDZ,pSPhi,pEPhi are the same as for G4Tubs,
34// pLowNorm=Outside Normal at -Z
35// pHighNorm=Outside Normal at +Z.
36
37// Author: Tatiana Nikitina (CERN), 31.10.2011
38// Implementation adapted from G4Tubs and TGEo/Ctube implementations.
39// --------------------------------------------------------------------
40#ifndef G4CUTTUBS_HH
41#define G4CUTTUBS_HH
42
43#include "G4GeomTypes.hh"
44
45#if defined(G4GEOM_USE_USOLIDS)
46#define G4GEOM_USE_UCTUBS 1
47#endif
48
49#if defined(G4GEOM_USE_UCTUBS)
50 #define G4UCutTubs G4CutTubs
51 #include "G4UCutTubs.hh"
52#else
53
54#include "G4CSGSolid.hh"
55#include "G4Polyhedron.hh"
56
57/**
58 * @brief G4CutTubs is a tube with possible cuts in +-Z.
59 */
60
61class G4CutTubs : public G4CSGSolid
62{
63 public:
64
65 /**
66 * Constructs a tube with the given name and dimensions.
67 * @param[in] pName The name of the solid.
68 * @param[in] pRmin Inner radius.
69 * @param[in] pRmax Outer radius.
70 * @param[in] pDZ Half length in Z.
71 * @param[in] pSPhi Starting angle of the segment in radians.
72 * @param[in] pDPhi Delta angle of the segment in radians.
73 * @param[in] pLowNorm Outside normal vector at -Z.
74 * @param[in] pHighNorm Outside normal vector at +Z.
75 */
76 G4CutTubs( const G4String& pName,
77 G4double pRMin,
78 G4double pRMax,
79 G4double pDz,
80 G4double pSPhi,
81 G4double pDPhi,
82 G4ThreeVector pLowNorm,
83 G4ThreeVector pHighNorm );
84
85 /**
86 * Default destructor.
87 */
88 ~G4CutTubs() override = default;
89
90 /**
91 * Accessors.
92 */
93 inline G4double GetInnerRadius () const;
94 inline G4double GetOuterRadius () const;
95 inline G4double GetZHalfLength () const;
96 inline G4double GetStartPhiAngle () const;
97 inline G4double GetDeltaPhiAngle () const;
98 inline G4double GetSinStartPhi () const;
99 inline G4double GetCosStartPhi () const;
100 inline G4double GetSinEndPhi () const;
101 inline G4double GetCosEndPhi () const;
102 inline G4ThreeVector GetLowNorm () const;
103 inline G4ThreeVector GetHighNorm () const;
104
105 /**
106 * Modifiers.
107 */
108 inline void SetInnerRadius (G4double newRMin);
109 inline void SetOuterRadius (G4double newRMax);
110 inline void SetZHalfLength (G4double newDz);
111 inline void SetStartPhiAngle (G4double newSPhi, G4bool trig=true);
112 inline void SetDeltaPhiAngle (G4double newDPhi);
113
114 /**
115 * Returning an estimation of the solid volume (capacity) and
116 * surface area, in internal units.
117 */
118 G4double GetCubicVolume() override;
119 G4double GetSurfaceArea() override;
120
121 /**
122 * Computes the bounding limits of the solid.
123 * @param[out] pMin The minimum bounding limit point.
124 * @param[out] pMax The maximum bounding limit point.
125 */
126 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
127
128 /**
129 * Calculates the minimum and maximum extent of the solid, when under the
130 * specified transform, and within the specified limits.
131 * @param[in] pAxis The axis along which compute the extent.
132 * @param[in] pVoxelLimit The limiting space dictated by voxels.
133 * @param[in] pTransform The internal transformation applied to the solid.
134 * @param[out] pMin The minimum extent value.
135 * @param[out] pMax The maximum extent value.
136 * @returns True if the solid is intersected by the extent region.
137 */
138 G4bool CalculateExtent(const EAxis pAxis,
139 const G4VoxelLimits& pVoxelLimit,
140 const G4AffineTransform& pTransform,
141 G4double& pmin, G4double& pmax) const override;
142
143 /**
144 * Concrete implementations of the expected query interfaces for
145 * solids, as defined in the base class G4VSolid.
146 */
147 EInside Inside( const G4ThreeVector& p ) const override;
148 G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override;
150 const G4ThreeVector& v) const override;
151 G4double DistanceToIn(const G4ThreeVector& p) const override;
153 const G4bool calcNorm = false,
154 G4bool* validNorm = nullptr,
155 G4ThreeVector* n = nullptr) const override;
156 G4double DistanceToOut(const G4ThreeVector& p) const override;
157
158 /**
159 * Returns the type ID, "G4CutTubs" of the solid.
160 */
161 G4GeometryType GetEntityType() const override;
162
163 /**
164 * Returns a random point located and uniformly distributed on the
165 * surface of the solid.
166 */
167 G4ThreeVector GetPointOnSurface() const override;
168
169 /**
170 * Makes a clone of the object for use in multi-treading.
171 * @returns A pointer to the new cloned allocated solid.
172 */
173 G4VSolid* Clone() const override;
174
175 /**
176 * Streams the object contents to an output stream.
177 */
178 std::ostream& StreamInfo( std::ostream& os ) const override;
179
180 /**
181 * Methods for creating graphical representations (i.e. for visualisation).
182 */
183 void DescribeYourselfTo ( G4VGraphicsScene& scene ) const override;
184 G4Polyhedron* CreatePolyhedron () const override;
185
186 /**
187 * Fake default constructor for usage restricted to direct object
188 * persistency for clients requiring preallocation of memory for
189 * persistifiable objects.
190 */
191 G4CutTubs(__void__&);
192
193 /**
194 * Copy constructor and assignment operator.
195 */
196 G4CutTubs(const G4CutTubs& rhs) = default;
197 G4CutTubs& operator=(const G4CutTubs& rhs);
198
199 protected:
200
201 /**
202 * Resets relevant values to zero.
203 */
204 inline void Initialize();
205
206 /**
207 * Reset relevant flags and angle values.
208 */
209 inline void CheckSPhiAngle(G4double sPhi);
210 inline void CheckDPhiAngle(G4double dPhi);
211 inline void CheckPhiAngles(G4double sPhi, G4double dPhi);
212
213 /**
214 * Recomputes relevant trigonometric values and caches them.
215 */
217
218 /**
219 * Algorithm for SurfaceNormal() following the original specification
220 * for points not on the surface.
221 */
223
224 /**
225 * Checks if the cutted planes are crossing.
226 * @returns True if the solid is ill defined.
227 */
229
230 /**
231 * Gets the Z value of the point "p" on the cut plane.
232 */
233 G4double GetCutZ(const G4ThreeVector& p) const;
234
235 private:
236
237 /** Radial and angular tolerances. */
238 G4double kRadTolerance, kAngTolerance;
239
240 /** Radial and angular dimensions. */
241 G4double fRMin, fRMax, fDz, fSPhi, fDPhi;
242 mutable G4double fZMin, fZMax;
243
244 /** Cached trigonometric values. */
245 G4double sinCPhi, cosCPhi, cosHDPhi, cosHDPhiOT, cosHDPhiIT,
246 sinSPhi, cosSPhi, sinEPhi, cosEPhi;
247
248 /** Flag for identification of section or full tube. */
249 G4bool fPhiFullCutTube = false;
250
251 /** Cached half tolerance values. */
252 G4double halfCarTolerance, halfRadTolerance, halfAngTolerance;
253
254 /** Normals of Cut at -/+ Dz. */
255 G4ThreeVector fLowNorm, fHighNorm;
256};
257
258#include "G4CutTubs.icc"
259
260#endif
261
262#endif
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
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
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
Definition G4CutTubs.cc:210
G4ThreeVector GetPointOnSurface() const override
G4ThreeVector GetHighNorm() const
G4double GetStartPhiAngle() const
G4CutTubs(const G4CutTubs &rhs)=default
void Initialize()
G4double GetZHalfLength() const
G4double GetInnerRadius() const
void SetInnerRadius(G4double newRMin)
G4ThreeVector GetLowNorm() const
void CheckDPhiAngle(G4double dPhi)
G4VSolid * Clone() const override
void SetStartPhiAngle(G4double newSPhi, G4bool trig=true)
void SetDeltaPhiAngle(G4double newDPhi)
G4double GetSurfaceArea() override
G4GeometryType GetEntityType() const override
G4double GetCutZ(const G4ThreeVector &p) const
G4double GetDeltaPhiAngle() const
G4double GetOuterRadius() const
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
Definition G4CutTubs.cc:630
G4bool IsCrossingCutPlanes() const
G4double GetSinStartPhi() const
void CheckPhiAngles(G4double sPhi, G4double dPhi)
void SetZHalfLength(G4double newDz)
G4CutTubs & operator=(const G4CutTubs &rhs)
Definition G4CutTubs.cc:177
void DescribeYourselfTo(G4VGraphicsScene &scene) const override
EInside Inside(const G4ThreeVector &p) const override
Definition G4CutTubs.cc:441
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override
Definition G4CutTubs.cc:774
void InitializeTrigonometry()
G4double GetSinEndPhi() const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const override
Definition G4CutTubs.cc:527
void CheckSPhiAngle(G4double sPhi)
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const override
Definition G4CutTubs.cc:327
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
G4double GetCosStartPhi() const
G4double GetCosEndPhi() const
std::ostream & StreamInfo(std::ostream &os) const override
G4CutTubs(const G4String &pName, G4double pRMin, G4double pRMax, G4double pDz, G4double pSPhi, G4double pDPhi, G4ThreeVector pLowNorm, G4ThreeVector pHighNorm)
Definition G4CutTubs.cc:63
G4double GetCubicVolume() override
void SetOuterRadius(G4double newRMax)
~G4CutTubs() override=default
G4Polyhedron * CreatePolyhedron() const override
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