Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TwistTrapFlatSide.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// G4TwistTrapFlatSide
27//
28// Class description:
29//
30// Class describing a flat boundary surface for a trapezoid.
31
32// Author: Oliver Link (CERN), 27.10.2004 - Created
33// --------------------------------------------------------------------
34#ifndef G4TWISTTRAPFLATSIDE_HH
35#define G4TWISTTRAPFLATSIDE_HH
36
37#include "G4VTwistSurface.hh"
38
39/**
40 * @brief G4TwistTrapFlatSide describes a flat boundary surface for a trapezoid.
41 */
42
44{
45 public:
46
47 /**
48 * Constructs a trapezoid flat boundary surface, given its parameters.
49 * @param[in] name The surface name.
50 * @param[in] PhiTwist The twist angle.
51 * @param[in] pDx1 Half x length at -pDz,-pDy.
52 * @param[in] pDx2 Half x length at -pDz,+pDy.
53 * @param[in] pDy Half y length.
54 * @param[in] pDz Half z length.
55 * @param[in] pAlpha Tilt angle at +pDz.
56 * @param[in] pPhi Direction between end planes - azimuthal angle.
57 * @param[in] pTheta Direction between end planes - polar angle.
58 * @param[in] handedness Orientation: +z = +ve, -z = -ve.
59 */
60 G4TwistTrapFlatSide( const G4String& name,
61 G4double PhiTwist,
62 G4double pDx1,
63 G4double pDx2,
64 G4double pDy,
65 G4double pDz,
66 G4double pAlpha,
67 G4double pPhi,
68 G4double pTheta,
69 G4int handedness );
70
71 /**
72 * Default destructor.
73 */
74 ~G4TwistTrapFlatSide() override = default;
75
76 /**
77 * Returns a normal vector at a surface (or very close to the surface)
78 * point at 'p'.
79 * @param[in] p Not used. Using current normal.
80 * @param[in] isGlobal If true, it returns the normal in global coordinates.
81 * @returns The current normal vector.
82 */
84 G4bool isGlobal = false) override;
85
86 /**
87 * Returns the distance to surface, given point 'gp' and direction 'gv'.
88 * @param[in] gp The point from where computing the distance.
89 * @param[in] gv The direction along which computing the distance.
90 * @param[out] gxx Vector of global points based on number of solutions.
91 * @param[out] distance The distance vector based on number of solutions.
92 * @param[out] areacode The location vector based on number of solutions.
93 * @param[out] isvalid Validity vector based on number of solutions.
94 * @param[in] validate Adopted validation criteria.
95 * @returns The number of solutions.
96 */
98 const G4ThreeVector& gv,
99 G4ThreeVector gxx[],
100 G4double distance[],
101 G4int areacode[],
102 G4bool isvalid[],
103 EValidate validate = kValidateWithTol) override;
104
105 /**
106 * Returns the safety distance to surface, given point 'gp'.
107 * @param[in] gp The point from where computing the safety distance.
108 * @param[out] gxx Vector of global points based on number of solutions.
109 * @param[out] distance The distance vector based on number of solutions.
110 * @param[out] areacode The location vector based on number of solutions.
111 * @returns The number of solutions.
112 */
114 G4ThreeVector gxx[],
115 G4double distance[],
116 G4int areacode[]) override;
117
118 /**
119 * Fake default constructor for usage restricted to direct object
120 * persistency for clients requiring preallocation of memory for
121 * persistifiable objects.
122 */
123 G4TwistTrapFlatSide(__void__&);
124
125 private:
126
127 /**
128 * Returns point on surface given 'phi' and 'u'.
129 */
130 inline G4ThreeVector SurfacePoint(G4double x, G4double y,
131 G4bool isGlobal = false) override;
132
133 /**
134 * Internal accessors.
135 */
136 inline G4double GetBoundaryMin(G4double u) override;
137 inline G4double GetBoundaryMax(G4double u) override;
138 inline G4double GetSurfaceArea() override;
139 void GetFacets( G4int m, G4int n, G4double xyz[][3],
140 G4int faces[][4], G4int iside ) override;
141 inline G4double xAxisMax(G4double u, G4double fTanAlpha) const;
142
143 /**
144 * Setters.
145 */
146 void SetCorners() override;
147 void SetBoundaries() override;
148
149 /**
150 * Returns the area code for point 'xx' using or not surface tolerance.
151 */
152 G4int GetAreaCode(const G4ThreeVector& xx,
153 G4bool withTol = true) override;
154
155 private:
156
157 G4double fDx1;
158 G4double fDx2;
159 G4double fDy;
160 G4double fDz;
161 G4double fPhiTwist;
162 G4double fAlpha;
163 G4double fTAlph;
164 G4double fPhi;
165 G4double fTheta;
166 G4double fdeltaX;
167 G4double fdeltaY;
168};
169
170//========================================================
171// inline functions
172//========================================================
173
174inline
175G4double G4TwistTrapFlatSide::xAxisMax(G4double u, G4double fTanAlpha) const
176{
177 return ( ( fDx2 + fDx1 )/2. + u*(fDx2 - fDx1)/(2.*fDy) + u *fTanAlpha ) ;
178}
179
180inline G4ThreeVector
181G4TwistTrapFlatSide::SurfacePoint(G4double x, G4double y, G4bool isGlobal)
182{
183 G4ThreeVector SurfPoint ( x,y,0);
184
185 if (isGlobal) { return (fRot*SurfPoint + fTrans); }
186 return SurfPoint;
187}
188
189inline
190G4double G4TwistTrapFlatSide::GetBoundaryMin(G4double y)
191{
192 return -xAxisMax(y, -fTAlph) ;
193}
194
195inline
196G4double G4TwistTrapFlatSide::GetBoundaryMax(G4double y)
197{
198 return xAxisMax(y, fTAlph) ;
199}
200
201inline
203{
204 return 2*(fDx1 + fDx2)*fDy ;
205}
206
207#endif
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4ThreeVector GetNormal(const G4ThreeVector &, G4bool isGlobal=false) override
~G4TwistTrapFlatSide() override=default
G4TwistTrapFlatSide(const G4String &name, G4double PhiTwist, G4double pDx1, G4double pDx2, G4double pDy, G4double pDz, G4double pAlpha, G4double pPhi, G4double pTheta, G4int handedness)
G4int DistanceToSurface(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector gxx[], G4double distance[], G4int areacode[], G4bool isvalid[], EValidate validate=kValidateWithTol) override
G4VTwistSurface(const G4String &name)
G4RotationMatrix fRot
G4ThreeVector fTrans
virtual G4double GetSurfaceArea()=0