Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TwistTubsSide.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// G4TwistTubsSide
27//
28// Class description:
29//
30// Class describing a twisted 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 G4TWISTTUBSSIDE_HH
37#define G4TWISTTUBSSIDE_HH
38
39#include "G4VTwistSurface.hh"
40
41/**
42 * @brief G4TwistTubsFlatSide describes a twisted boundary surface for
43 * a cylinder.
44 */
45
47{
48 public:
49
50 /**
51 * Constructs a cylinder twisted boundary surface, given its parameters.
52 * @param[in] name The surface name.
53 * @param[in] rot Rotation: 0.5*(phi-width segment).
54 * @param[in] tlate Translation.
55 * @param[in] handedness Orientation: R-hand = 1, L-hand = -1.
56 * @param[in] kappa Kappa=tan(TwistAngle/2)/fZHalfLen.
57 * @param[in] axis0 X axis.
58 * @param[in] axis1 Z axis.
59 * @param[in] axis0min Minimum in X.
60 * @param[in] axis1min Minimum in Z.
61 * @param[in] axis0max Maximum in X.
62 * @param[in] axis1max Maximum in Z.
63 */
64 G4TwistTubsSide(const G4String& name,
65 const G4RotationMatrix& rot, // 0.5*(phi-width segment)
66 const G4ThreeVector& tlate,
67 G4int handedness, // R-hand = 1, L-hand = -1
68 const G4double kappa, // tan(TwistAngle/2)/fZHalfLen
69 const EAxis axis0 = kXAxis,
70 const EAxis axis1 = kZAxis,
71 G4double axis0min = -kInfinity,
72 G4double axis1min = -kInfinity,
73 G4double axis0max = kInfinity,
74 G4double axis1max = kInfinity );
75
76 /**
77 * Alternative Construct for a cylinder twisted boundary surface.
78 * @param[in] name The surface name.
79 * @param[in] EndInnerRadius Inner-hype radius at z=0.
80 * @param[in] EndOuterRadius Outer-hype radius at z=0.
81 * @param[in] DPhi Phi angle.
82 * @param[in] EndPhi Total Phi.
83 * @param[in] EndZ Z length.
84 * @param[in] InnerRadius Inner radius.
85 * @param[in] OuterRadius Outer radius.
86 * @param[in] Kappa Kappa=tan(TwistAngle/2)/fZHalfLen.
87 * @param[in] handedness Orientation: R-hand = 1, L-hand = -1.
88 */
89 G4TwistTubsSide(const G4String& name,
90 G4double EndInnerRadius[2],
91 G4double EndOuterRadius[2],
92 G4double DPhi,
93 G4double EndPhi[2],
94 G4double EndZ[2],
95 G4double InnerRadius,
96 G4double OuterRadius,
97 G4double Kappa,
98 G4int handedness);
99
100 /**
101 * Default destructor.
102 */
103 ~G4TwistTubsSide() override = default;
104
105 /**
106 * Returns a normal vector at a surface (or very close to the surface)
107 * point at 'p'.
108 * @param[in] p The point where computing the normal.
109 * @param[in] isGlobal If true, it returns the normal in global coordinates.
110 * @returns The normal vector.
111 */
113 G4bool isGlobal = false) override ;
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 * Get projection at p.z() on the surface.
149 */
151 G4bool isglobal = false) const ;
152
153 G4TwistTubsSide(__void__&);
154 // Fake default constructor for usage restricted to direct object
155 // persistency for clients requiring preallocation of memory for
156 // persistifiable objects.
157
158 private:
159
160 /**
161 * Returns point on surface given 'x' and 'z'.
162 */
163 inline G4ThreeVector SurfacePoint(G4double x, G4double z,
164 G4bool isGlobal = false) override ;
165
166 /**
167 * Internal accessors.
168 */
169 inline G4double GetBoundaryMin(G4double phi) override ;
170 inline G4double GetBoundaryMax(G4double phi) override ;
171 inline G4double GetSurfaceArea() override ;
172 void GetFacets( G4int m, G4int n, G4double xyz[][3],
173 G4int faces[][4], G4int iside ) override ;
174
175 /**
176 * Internal method to compute the distance to a plane.
177 */
178 G4double DistanceToPlane(const G4ThreeVector& p,
179 const G4ThreeVector& A,
180 const G4ThreeVector& B,
181 const G4ThreeVector& C,
182 const G4ThreeVector& D,
183 const G4int parity,
184 G4ThreeVector& xx,
185 G4ThreeVector& n);
186
187 /**
188 * Returns the area code for point 'xx' using or not surface tolerance.
189 */
190 G4int GetAreaCode(const G4ThreeVector& xx,
191 G4bool withTol = true) override;
192
193 /**
194 * Setters.
195 */
196 void SetCorners() override;
197 void SetCorners( G4double endInnerRad[2],
198 G4double endOuterRad[2],
199 G4double endPhi[2],
200 G4double endZ[2] ) ;
201 void SetBoundaries() override;
202
203 private:
204
205 G4double fKappa; // std::tan(TwistedAngle/2)/HalfLenZ;
206};
207
208
209//========================================================
210// inline functions
211//========================================================
212
213inline
215 G4bool isglobal) const
216{
217 // Get Rho at p.z() on Hyperbolic Surface.
218 G4ThreeVector tmpp;
219 if (isglobal) { tmpp = fRot.inverse()*p - fTrans; }
220 else { tmpp = p; }
221 G4ThreeVector xx(p.x(), p.x() * fKappa * p.z(), p.z());
222 if (isglobal) { return (fRot * xx + fTrans); }
223 return xx;
224}
225
226inline
228G4TwistTubsSide::SurfacePoint(G4double x, G4double z, G4bool isGlobal)
229{
230 G4ThreeVector SurfPoint( x , x * fKappa * z , z ) ;
231
232 if (isGlobal) { return (fRot * SurfPoint + fTrans); }
233 return SurfPoint;
234}
235
236inline
237G4double G4TwistTubsSide::GetBoundaryMin(G4double)
238{
239 return fAxisMin[0] ; // inner radius at z = 0
240}
241
242inline
243G4double G4TwistTubsSide::GetBoundaryMax(G4double)
244{
245 return fAxisMax[0] ; // outer radius at z = 0
246}
247
248inline
250{
251 // approximation only
252 return ( fAxisMax[0] - fAxisMin[0] ) * ( fAxisMax[1] - fAxisMin[1] ) ;
253}
254
255#endif
G4double C(G4double temp)
G4double B(G4double temperature)
G4double D(G4double temp)
CLHEP::HepRotation G4RotationMatrix
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
const G4double A[17]
double z() const
double x() const
G4ThreeVector ProjectAtPXPZ(const G4ThreeVector &p, G4bool isglobal=false) const
G4ThreeVector GetNormal(const G4ThreeVector &p, G4bool isGlobal=false) override
G4TwistTubsSide(const G4String &name, const G4RotationMatrix &rot, const G4ThreeVector &tlate, G4int handedness, const G4double kappa, const EAxis axis0=kXAxis, const EAxis axis1=kZAxis, G4double axis0min=-kInfinity, G4double axis1min=-kInfinity, G4double axis0max=kInfinity, G4double axis1max=kInfinity)
G4int DistanceToSurface(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector gxx[], G4double distance[], G4int areacode[], G4bool isvalid[], EValidate validate=kValidateWithTol) override
~G4TwistTubsSide() override=default
G4VTwistSurface(const G4String &name)
G4RotationMatrix fRot
G4ThreeVector fTrans
virtual G4double GetSurfaceArea()=0
EAxis
Definition geomdefs.hh:54
@ kXAxis
Definition geomdefs.hh:55
@ kZAxis
Definition geomdefs.hh:57