Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TwistTubsHypeSide.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// G4TwistTubsHypeSide
27//
28// Class description:
29//
30// Class describing a hyperbolic boundary surface for a cylinder.
31
32// Author: Kotoyo Hoshina (Chiba University), 01.08.2002 - Created.
33// Oliver Link (CERN), 13.11.2003 - Integration in Geant4
34// from original version in Jupiter-2.5.02 application.
35// --------------------------------------------------------------------
36#ifndef G4TWISTTUBSHYPESIDE_HH
37#define G4TWISTTUBSHYPESIDE_HH
38
39#include "G4VTwistSurface.hh"
40#include "G4Integrator.hh"
42
43/**
44 * @brief G4TwistTubsHypeSide describes hyperbolic boundary surface
45 * for a cylinder.
46 */
47
49{
50 public:
51
52 /**
53 * Constructs a cylinder hyperbolic boundary surface, given its parameters.
54 * @param[in] name The surface name.
55 * @param[in] rot Rotation: 0.5*(phi-width segment).
56 * @param[in] tlate Translation.
57 * @param[in] handedness Orientation: R-hand = 1, L-hand = -1.
58 * @param[in] kappa Kappa=tan(TwistAngle/2)/fZHalfLen.
59 * @param[in] tanstereo Tangent of the stereo angle.
60 * @param[in] r0 Radius at z = 0.
61 * @param[in] axis0 Phi axis.
62 * @param[in] axis1 Z axis.
63 * @param[in] axis0min Minimum in Phi.
64 * @param[in] axis1min Minimum in Z.
65 * @param[in] axis0max Maximum in Phi.
66 * @param[in] axis1max Maximum in Z.
67 */
68 G4TwistTubsHypeSide(const G4String& name,
69 const G4RotationMatrix& rot, // 0.5*(phi-width segment)
70 const G4ThreeVector& tlate,
71 const G4int handedness, // R-hand = 1, L-hand = -1
72 const G4double kappa, // tan(TwistAngle/2)/fZHalfLen
73 const G4double tanstereo, // tan(stereo angle)
74 const G4double r0, // radius at z = 0
75 const EAxis axis0 = kPhi,
76 const EAxis axis1 = kZAxis,
77 G4double axis0min = -kInfinity,
78 G4double axis1min = -kInfinity,
79 G4double axis0max = kInfinity,
80 G4double axis1max = kInfinity);
81
82 /**
83 * Alternative Construct for a cylinder hyperbolic boundary surface.
84 * @param[in] name The surface name.
85 * @param[in] EndInnerRadius Inner-hype radius at z=0.
86 * @param[in] EndOuterRadius Outer-hype radius at z=0.
87 * @param[in] DPhi Phi angle.
88 * @param[in] EndPhi Total Phi.
89 * @param[in] EndZ Z length.
90 * @param[in] InnerRadius Inner radius.
91 * @param[in] OuterRadius Outer radius.
92 * @param[in] Kappa Kappa=tan(TwistAngle/2)/fZHalfLen.
93 * @param[in] TanInnerStereo Tangent inner stereo angle.
94 * @param[in] TanOuterStereo Tangent outer stereo angle.
95 * @param[in] handedness Orientation: R-hand = 1, L-hand = -1.
96 */
97 G4TwistTubsHypeSide(const G4String& name,
98 G4double EndInnerRadius[2],
99 G4double EndOuterRadius[2],
100 G4double DPhi,
101 G4double EndPhi[2],
102 G4double EndZ[2],
103 G4double InnerRadius,
104 G4double OuterRadius,
105 G4double Kappa,
106 G4double TanInnerStereo,
107 G4double TanOuterStereo,
108 G4int handedness) ;
109
110 /**
111 * Default destructor.
112 */
113 ~G4TwistTubsHypeSide() override = default;
114
115 /**
116 * Returns the distance to surface, given point 'gp' and direction 'gv'.
117 * @param[in] gp The point from where computing the distance.
118 * @param[in] gv The direction along which computing the distance.
119 * @param[out] gxx Vector of global points based on number of solutions.
120 * @param[out] distance The distance vector based on number of solutions.
121 * @param[out] areacode The location vector based on number of solutions.
122 * @param[out] isvalid Validity vector based on number of solutions.
123 * @param[in] validate Adopted validation criteria.
124 * @returns The number of solutions.
125 */
127 const G4ThreeVector& gv,
128 G4ThreeVector gxx[],
129 G4double distance[],
130 G4int areacode[],
131 G4bool isvalid[],
132 EValidate validate = kValidateWithTol) override;
133
134 /**
135 * Returns the safety distance to surface, given point 'gp'.
136 * @param[in] gp The point from where computing the safety distance.
137 * @param[out] gxx Vector of global points based on number of solutions.
138 * @param[out] distance The distance vector based on number of solutions.
139 * @param[out] areacode The location vector based on number of solutions.
140 * @returns The number of solutions.
141 */
143 G4ThreeVector gxx[],
144 G4double distance[],
145 G4int areacode[]) override;
146
147 /**
148 * Returns a normal vector at a surface (or very close to the surface)
149 * point at 'p'.
150 * @param[in] p The point where computing the normal.
151 * @param[in] isGlobal If true, it returns the normal in global coordinates.
152 * @returns The normal vector.
153 */
155 G4bool isGlobal = false) override ;
156
157 /**
158 * Returns if point at 'gp' is inside surface.
159 */
160 EInside Inside(const G4ThreeVector& gp) ;
161
162 /**
163 * Gets Rho at p.z() on Hyperbolic Surface.
164 */
165 inline G4double GetRhoAtPZ(const G4ThreeVector& p,
166 G4bool isglobal = false) const ;
167
168 /**
169 * Fake default constructor for usage restricted to direct object
170 * persistency for clients requiring preallocation of memory for
171 * persistifiable objects.
172 */
173 G4TwistTubsHypeSide(__void__&);
174
175 private:
176
177 /**
178 * Returns point on surface given 'phi' and 'z'.
179 */
180 inline G4ThreeVector SurfacePoint(G4double phi, G4double z,
181 G4bool isGlobal = false) override ;
182
183 /**
184 * Internal accessors.
185 */
186 inline G4double GetBoundaryMin(G4double phi) override ;
187 inline G4double GetBoundaryMax(G4double phi) override ;
188 inline G4double GetSurfaceArea() override ;
189 void GetFacets( G4int m, G4int n, G4double xyz[][3],
190 G4int faces[][4], G4int iside ) override ;
191
192 /**
193 * Returns the area code for point 'xx' using or not surface tolerance.
194 */
195 G4int GetAreaCode(const G4ThreeVector& xx,
196 G4bool withTol = true) override;
197 G4int GetAreaCodeInPhi(const G4ThreeVector& xx,
198 G4bool withTol = true);
199
200 /**
201 * Setters.
202 */
203 void SetCorners() override;
204 void SetCorners(G4double EndInnerRadius[2],
205 G4double EndOuterRadius[2],
206 G4double DPhi,
207 G4double EndPhi[2],
208 G4double EndZ[2]);
209 void SetBoundaries() override;
210
211 private:
212
213 G4double fKappa; // std::tan(TwistedAngle/2)/HalfLenZ;
214 G4double fTanStereo; // std::tan(StereoAngle)
215 G4double fTan2Stereo; // std::tan(StereoAngle)**2
216 G4double fR0; // radius at z = 0
217 G4double fR02; // radius**2 at z = 0
218 G4double fDPhi ; // segment
219
220 class Insidetype
221 {
222 public:
223
224 G4ThreeVector gp;
225 EInside inside;
226 };
227 Insidetype fInside;
228};
229
230//========================================================
231// inline functions
232//========================================================
233
234inline
236 G4bool isglobal) const
237{
238 // Get Rho at p.z() on Hyperbolic Surface.
239 G4ThreeVector tmpp;
240 if (isglobal) { tmpp = fRot.inverse()*p - fTrans; }
241 else { tmpp = p; }
242
243 return std::sqrt(fR02 + tmpp.z() * tmpp.z() * fTan2Stereo);
244}
245
246inline
247G4ThreeVector G4TwistTubsHypeSide::
248SurfacePoint(G4double phi , G4double z , G4bool isGlobal)
249{
250 G4double rho = std::sqrt(fR02 + z * z * fTan2Stereo) ;
251
252 G4ThreeVector SurfPoint (rho*std::cos(phi), rho*std::sin(phi), z) ;
253
254 if (isGlobal) { return (fRot * SurfPoint + fTrans); }
255 return SurfPoint;
256}
257
258inline
259G4double G4TwistTubsHypeSide::GetBoundaryMin(G4double z)
260{
261 G4ThreeVector ptmp(0,0,z) ; // temporary point with z Komponent only
262 G4ThreeVector lowerlimit; // lower phi-boundary limit at z = ptmp.z()
263 lowerlimit = GetBoundaryAtPZ(sAxis0 & sAxisMin, ptmp);
264 return std::atan2( lowerlimit.y(), lowerlimit.x() ) ;
265}
266
267inline
268G4double G4TwistTubsHypeSide::GetBoundaryMax(G4double z )
269{
270 G4ThreeVector ptmp(0,0,z) ; // temporary point with z Komponent only
271 G4ThreeVector upperlimit; // upper phi-boundary limit at z = ptmp.z()
272 upperlimit = GetBoundaryAtPZ(sAxis0 & sAxisMax, ptmp);
273 return std::atan2( upperlimit.y(), upperlimit.x() ) ;
274}
275
276inline
278{
279 // approximation with tube surface
280
281 return ( fAxisMax[1] - fAxisMin[1] ) * fR0 * fDPhi ;
282}
283
284#endif
CLHEP::HepRotation G4RotationMatrix
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
double z() const
double x() const
double y() const
~G4TwistTubsHypeSide() override=default
G4ThreeVector GetNormal(const G4ThreeVector &p, G4bool isGlobal=false) override
G4int DistanceToSurface(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector gxx[], G4double distance[], G4int areacode[], G4bool isvalid[], EValidate validate=kValidateWithTol) override
EInside Inside(const G4ThreeVector &gp)
G4TwistTubsHypeSide(const G4String &name, const G4RotationMatrix &rot, const G4ThreeVector &tlate, const G4int handedness, const G4double kappa, const G4double tanstereo, const G4double r0, const EAxis axis0=kPhi, const EAxis axis1=kZAxis, G4double axis0min=-kInfinity, G4double axis1min=-kInfinity, G4double axis0max=kInfinity, G4double axis1max=kInfinity)
G4double GetRhoAtPZ(const G4ThreeVector &p, G4bool isglobal=false) const
G4VTwistSurface(const G4String &name)
static const G4int sAxisMax
static const G4int sAxis0
G4RotationMatrix fRot
static const G4int sAxisMin
virtual G4ThreeVector GetBoundaryAtPZ(G4int areacode, const G4ThreeVector &p) const
G4ThreeVector fTrans
virtual G4double GetSurfaceArea()=0
EAxis
Definition geomdefs.hh:54
@ kPhi
Definition geomdefs.hh:60
@ kZAxis
Definition geomdefs.hh:57
EInside
Definition geomdefs.hh:67