Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UTrap.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// G4UTrap
27//
28// Class description:
29//
30// Wrapper class for G4Trap to make use of VecGeom Trapezoid.
31
32// Author: G.Cosmo (CERN), 13.09.2013
33// --------------------------------------------------------------------
34#ifndef G4UTRAP_HH
35#define G4UTRAP_HH
36
37#include "G4UAdapter.hh"
38
39#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
40
41#include <VecGeom/volumes/UnplacedTrapezoid.h>
42
43#include "G4Polyhedron.hh"
44
45/**
46 * @brief G4UTrap is a wrapper class for G4Trap to make use of VecGeom Trapezoid.
47 */
48
49class G4UTrap : public G4UAdapter<vecgeom::UnplacedTrapezoid>
50{
51 using Shape_t = vecgeom::UnplacedTrapezoid;
52 using Base_t = G4UAdapter<vecgeom::UnplacedTrapezoid>;
53
54 public:
55
56 /**
57 * The most general constructor for G4Trap which prepares plane
58 * equations and corner coordinates from parameters.
59 * @param[in] pName The name of the solid.
60 * @param[in] pDz Half-length along the Z-axis.
61 * @param[in] pTheta Polar angle of the line joining the centres
62 * of the faces at -/+pDz.
63 * @param[in] pPhi Azimuthal angle of the line joining the centre
64 * of the face at -pDz to the centre of the face at +pDz.
65 * @param[in] pDy1 Half-length along Y of the face at -pDz.
66 * @param[in] pDx1 Half-length along X of the side at y=-pDy1
67 * of the face at -pDz.
68 * @param[in] pDx2 Half-length along X of the side at y=+pDy1
69 * of the face at -pDz.
70 * @param[in] pAlp1 Angle with respect to the Y axis from the centre of the
71 * side at y=-pDy1 to the centre at y=+pDy1 of the face at -pDz.
72 * @param[in] pDy2 Half-length along Y of the face at +pDz.
73 * @param[in] pDx3 Half-length along X of the side at y=-pDy2
74 * of the face at +pDz.
75 * @param[in] pDx4 Half-length along X of the side at y=+pDy2
76 * of the face at +pDz.
77 * @param[in] pAlp2 Angle with respect to the Y axis from the centre of the
78 * side at y=-pDy2 to the centre at y=+pDy2 of the face at +pDz.
79 */
80 G4UTrap( const G4String& pName,
81 G4double pDz,
82 G4double pTheta, G4double pPhi,
83 G4double pDy1, G4double pDx1, G4double pDx2,
84 G4double pAlp1,
85 G4double pDy2, G4double pDx3, G4double pDx4,
86 G4double pAlp2 );
87
88 /**
89 * Prepares plane equations and parameters from corner coordinates.
90 * @param[in] pName The name of the solid.
91 * @param[in] pt Points of the 8 vertices.
92 */
93 G4UTrap( const G4String& pName,
94 const G4ThreeVector pt[8] ) ;
95
96 /**
97 * Constructor for Right Angular Wedge from STEP (assumes pLTX<=pX).
98 * @param[in] pName The name of the solid.
99 * @param[in] pZ Length along Z.
100 * @param[in] pY Length along Y.
101 * @param[in] pX Length along X at the wider side.
102 * @param[in] pLTX Length along X at the narrower side (plTX<=pX).
103 */
104 G4UTrap( const G4String& pName,
105 G4double pZ,
106 G4double pY,
107 G4double pX, G4double pLTX );
108
109 /**
110 * Constructor for G4Trd.
111 * @param[in] pName The name of the solid.
112 * @param[in] pDx1 Half-length along X at the surface positioned at -dz.
113 * @param[in] pDx2 Half-length along X at the surface positioned at +dz.
114 * @param[in] pDy1 Half-length along Y at the surface positioned at -dz.
115 * @param[in] pDy2 Half-length along Y at the surface positioned at +dz.
116 * @param[in] pDz Half-length along Z axis.
117 */
118 G4UTrap( const G4String& pName,
119 G4double pDx1, G4double pDx2,
120 G4double pDy1, G4double pDy2,
121 G4double pDz );
122
123 /**
124 * Constructor for G4Para.
125 * @param[in] pName The name of the solid.
126 * @param[in] pDx Half-length in X.
127 * @param[in] pDy Half-length in Y.
128 * @param[in] pDz Half-length in Z.
129 * @param[in] pAlpha Angle formed by the Y axis and the plane joining the
130 * centre of the faces parallel to the Z-X plane at -dy and +dy.
131 * @param[in] pTheta Polar angle of the line joining the centres of the
132 * faces at -dz and +dz in Z.
133 * @param[in] pPhi Azimuthal angle of the line joining the centres of
134 * the faces at -dz and +dz in Z.
135 */
136 G4UTrap(const G4String& pName,
137 G4double pDx, G4double pDy, G4double pDz,
138 G4double pAlpha, G4double pTheta, G4double pPhi );
139
140 /**
141 * Constructor for "nominal" G4Trap whose parameters are to be set
142 * by a G4VPVParamaterisation later on.
143 * @param[in] pName The name of the solid.
144 */
145 G4UTrap( const G4String& pName );
146
147 /**
148 * Default destructor.
149 */
150 ~G4UTrap() override = default;
151
152 /**
153 * Dispatch method for parameterisation replication mechanism and
154 * dimension computation.
155 */
156 void ComputeDimensions(G4VPVParameterisation* p,
157 const G4int n,
158 const G4VPhysicalVolume* pRep) override;
159
160 /**
161 * Makes a clone of the object for use in multi-treading.
162 * @returns A pointer to the new cloned allocated solid.
163 */
164 G4VSolid* Clone() const override;
165
166 using Base_t::GetTanAlpha1;
167 using Base_t::GetTanAlpha2;
168
169 /**
170 * Accessors. Returning the coordinates of a unit vector along a straight
171 * line joining centers of -/+fDz planes.
172 */
173 G4double GetZHalfLength() const;
174 G4double GetYHalfLength1() const;
175 G4double GetXHalfLength1() const;
176 G4double GetXHalfLength2() const;
177 G4double GetTanAlpha1() const;
178 G4double GetYHalfLength2() const;
179 G4double GetXHalfLength3() const;
180 G4double GetXHalfLength4() const;
181 G4double GetTanAlpha2() const;
182
183 /**
184 * More accessors.
185 */
186 TrapSidePlane GetSidePlane(G4int n) const;
187 G4ThreeVector GetSymAxis() const;
188
189 /**
190 * Accessors obtaining (re)computed values of the original parameters.
191 */
192 G4double GetPhi() const;
193 G4double GetTheta() const;
194 G4double GetAlpha1() const;
195 G4double GetAlpha2() const;
196
197 /**
198 * Sets all parameters, as for constructor. Checks and sets half-widths
199 * as well as angles. Makes a final check of co-planarity.
200 */
201 void SetAllParameters(G4double pDz, G4double pTheta, G4double pPhi,
202 G4double pDy1, G4double pDx1, G4double pDx2,
203 G4double pAlp1,
204 G4double pDy2, G4double pDx3, G4double pDx4,
205 G4double pAlp2);
206
207 /**
208 * Returns the type ID, "G4Trap" of the solid.
209 */
210 inline G4GeometryType GetEntityType() const override;
211
212 /**
213 * Returns true as the solid has only planar faces.
214 */
215 inline G4bool IsFaceted() const override;
216
217 /**
218 * Computes the bounding limits of the solid.
219 * @param[out] pMin The minimum bounding limit point.
220 * @param[out] pMax The maximum bounding limit point.
221 */
222 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
223
224 /**
225 * Calculates the minimum and maximum extent of the solid, when under the
226 * specified transform, and within the specified limits.
227 * @param[in] pAxis The axis along which compute the extent.
228 * @param[in] pVoxelLimit The limiting space dictated by voxels.
229 * @param[in] pTransform The internal transformation applied to the solid.
230 * @param[out] pMin The minimum extent value.
231 * @param[out] pMax The maximum extent value.
232 * @returns True if the solid is intersected by the extent region.
233 */
234 G4bool CalculateExtent(const EAxis pAxis,
235 const G4VoxelLimits& pVoxelLimit,
236 const G4AffineTransform& pTransform,
237 G4double& pMin, G4double& pMax) const override;
238
239 /**
240 * Returns a generated polyhedron as graphical representations.
241 */
242 G4Polyhedron* CreatePolyhedron() const override;
243
244 /**
245 * Copy constructor and assignment operator.
246 */
247 G4UTrap(const G4UTrap& rhs);
248 G4UTrap& operator=(const G4UTrap& rhs);
249
250 private:
251
252 /**
253 * Sets parameters using eight vertices.
254 */
255 void SetPlanes(const G4ThreeVector pt[8]);
256
257 /**
258 * Checks dimensions.
259 */
260 void CheckParameters() const;
261
262 /**
263 * Computes coordinates of vertices.
264 */
265 void GetVertices(G4ThreeVector pt[8]) const;
266
267 /**
268 * Checks planarity of lateral planes.
269 */
270 void CheckPlanarity(const G4ThreeVector pt[8]) const;
271};
272
273// --------------------------------------------------------------------
274// Inline methods
275// --------------------------------------------------------------------
276
277inline G4GeometryType G4UTrap::GetEntityType() const
278{
279 return "G4Trap";
280}
281
282inline G4bool G4UTrap::IsFaceted() const
283{
284 return true;
285}
286
287#endif // G4GEOM_USE_USOLIDS
288
289#endif
G4PVDivision & operator=(const G4PVDivision &)=delete
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
EAxis
Definition geomdefs.hh:54