Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TwistedTubs.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// G4TwistedTubs
27//
28// Class description:
29//
30// G4TwistedTubs is a sector of a twisted hollow cylinder.
31// A twisted cylinder which is placed along with z-axis and is
32// separated into phi-segments should become a hyperboloid, and
33// its each segmented piece should be tilted with a stereo angle.
34// G4TwistedTubs is a G4VSolid.
35//
36// Details of the implementation: "Development of a Geant4 solid
37// for stereo mini-jet cells in a cylindrical drift chamber",
38// Computer Physics Communications 153 (2003) pp.373-391
39
40// Author: Kotoyo Hoshina (Chiba University), 01.08.2002 - created.
41// Oliver Link (CERN), 13.11.2003 - Integration in Geant4
42// from original version in Jupiter-2.5.02 application.
43// --------------------------------------------------------------------
44#ifndef G4TWISTEDTUBS_HH
45#define G4TWISTEDTUBS_HH
46
47#include "G4VSolid.hh"
49#include "G4TwistTubsSide.hh"
51
54
55/**
56 * @brief G4TwistedTubs is a sector of a twisted hollow cylinder.
57 * A twisted cylinder which is placed along with Z axis and is separated into
58 * phi-segments should become a hyperboloid, and its each segmented piece
59 * should be tilted with a stereo angle.
60 */
61
62class G4TwistedTubs : public G4VSolid
63{
64 public:
65
66 /**
67 * Constructs a twisted tube, given radii and twist angle.
68 * @param[in] pName The solid name.
69 * @param[in] twistedangle The twisted angle.
70 * @param[in] endinnerrad Inner radius at endcap.
71 * @param[in] endouterrad Outer radius at endcap.
72 * @param[in] halfzlen Half Z length.
73 * @param[in] dphi Phi angle of a segment.
74 */
75 G4TwistedTubs(const G4String& pname, // Name of instance
76 G4double twistedangle, // Twisted angle
77 G4double endinnerrad, // Inner radius at endcap
78 G4double endouterrad, // Outer radius at endcap
79 G4double halfzlen, // half z length
80 G4double dphi); // Phi angle of a segment
81
82 /**
83 * Constructs a twisted tube, given radii, twist angle and number of segments.
84 * @param[in] pName The solid name.
85 * @param[in] twistedangle The twisted angle.
86 * @param[in] endinnerrad Inner radius at endcap.
87 * @param[in] endouterrad Outer radius at endcap.
88 * @param[in] halfzlen Half Z length.
89 * @param[in] nseg Number of segments in Phi.
90 * @param[in] totphi Total angle of all segments.
91 */
92 G4TwistedTubs(const G4String& pname, // Name of instance
93 G4double twistedangle, // Stereo angle
94 G4double endinnerrad, // Inner radius at endcap
95 G4double endouterrad, // Outer radius at endcap
96 G4double halfzlen, // half z length
97 G4int nseg, // Number of segments in totalPhi
98 G4double totphi); // Total angle of all segments
99
100 /**
101 * Constructs a twisted tube, given radii, twist angle and EndZ values.
102 * @param[in] pName The solid name.
103 * @param[in] twistedangle The twisted angle.
104 * @param[in] innerrad Inner radius at z=0.
105 * @param[in] outerrad Outer radius at z=0.
106 * @param[in] negativeEndz -ve Z endplate.
107 * @param[in] positiveEndz +ve Z endplate.
108 * @param[in] dphi Phi angle of a segment.
109 */
110 G4TwistedTubs(const G4String& pname, // Name of instance
111 G4double twistedangle, // Twisted angle
112 G4double innerrad, // Inner radius at z=0
113 G4double outerrad, // Outer radius at z=0
114 G4double negativeEndz, // -ve z endplate
115 G4double positiveEndz, // +ve z endplate
116 G4double dphi); // Phi angle of a segment
117
118 /**
119 * Constructs a twisted tube, given radii, twist angle, EndZ values
120 * and number of segments.
121 * @param[in] pName The solid name.
122 * @param[in] twistedangle The twisted angle.
123 * @param[in] innerrad Inner radius at z=0.
124 * @param[in] outerrad Outer radius at z=0.
125 * @param[in] negativeEndz -ve Z endplate.
126 * @param[in] positiveEndz +ve Z endplate.
127 * @param[in] nseg Number of segments in Phi.
128 * @param[in] totphi Total angle of all segments.
129 */
130 G4TwistedTubs(const G4String& pname, // Name of instance
131 G4double twistedangle, // Stereo angle
132 G4double innerrad, // Inner radius at z=0
133 G4double outerrad, // Outer radius at z=0
134 G4double negativeEndz, // -ve z endplate
135 G4double positiveEndz, // +ve z endplate
136 G4int nseg, // Number of segments in totalPhi
137 G4double totphi); // Total angle of all segments
138
139 /**
140 * Destructor.
141 */
142 ~G4TwistedTubs() override;
143
144 /**
145 * Thows a fatal exception. Parameterisations are not allowed on this shape.
146 */
148 const G4int /* n */ ,
149 const G4VPhysicalVolume* /* prep */ ) override;
150
151 /**
152 * Computes the bounding limits of the solid.
153 * @param[out] pMin The minimum bounding limit point.
154 * @param[out] pMax The maximum bounding limit point.
155 */
156 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
157
158 /**
159 * Calculates the minimum and maximum extent of the solid, when under the
160 * specified transform, and within the specified limits.
161 * @param[in] pAxis The axis along which compute the extent.
162 * @param[in] pVoxelLimit The limiting space dictated by voxels.
163 * @param[in] pTransform The internal transformation applied to the solid.
164 * @param[out] pMin The minimum extent value.
165 * @param[out] pMax The maximum extent value.
166 * @returns True if the solid is intersected by the extent region.
167 */
168 G4bool CalculateExtent(const EAxis pAxis,
169 const G4VoxelLimits& pVoxelLimit,
170 const G4AffineTransform& pTransform,
171 G4double& pMin,
172 G4double& pMax ) const override;
173
174 /**
175 * Concrete implementations of the expected query interfaces for
176 * solids, as defined in the base class G4VSolid.
177 */
179 const G4ThreeVector& v ) const override;
180 G4double DistanceToIn (const G4ThreeVector& p ) const override;
182 const G4ThreeVector& v,
183 const G4bool calcnorm = false,
184 G4bool* validnorm = nullptr,
185 G4ThreeVector* n = nullptr ) const override;
186 G4double DistanceToOut(const G4ThreeVector& p) const override;
187 EInside Inside (const G4ThreeVector& p) const override;
188 G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
189
190 /**
191 * Methods for creating graphical representations (i.e. for visualisation).
192 */
193 void DescribeYourselfTo (G4VGraphicsScene& scene) const override;
194 G4Polyhedron* CreatePolyhedron () const override;
195 G4Polyhedron* GetPolyhedron () const override;
196 G4VisExtent GetExtent () const override;
197
198 /**
199 * Streams the object contents to an output stream.
200 */
201 std::ostream &StreamInfo(std::ostream& os) const override;
202
203 /**
204 * Accessors.
205 */
206 inline G4double GetDPhi () const { return fDPhi ; }
207 inline G4double GetPhiTwist () const { return fPhiTwist ; }
208 inline G4double GetInnerRadius () const { return fInnerRadius; }
209 inline G4double GetOuterRadius () const { return fOuterRadius; }
210 inline G4double GetInnerStereo () const { return fInnerStereo; }
211 inline G4double GetOuterStereo () const { return fOuterStereo; }
212 inline G4double GetZHalfLength () const { return fZHalfLength; }
213 inline G4double GetKappa () const { return fKappa ; }
214 //
215 inline G4double GetTanInnerStereo () const { return fTanInnerStereo ; }
216 inline G4double GetTanInnerStereo2() const { return fTanInnerStereo2 ; }
217 inline G4double GetTanOuterStereo () const { return fTanOuterStereo ; }
218 inline G4double GetTanOuterStereo2() const { return fTanOuterStereo2 ; }
219 //
220 inline G4double GetEndZ (G4int i) const { return fEndZ[i] ; }
221 inline G4double GetEndPhi (G4int i) const { return fEndPhi[i]; }
223 { return fEndInnerRadius[i]; }
225 { return fEndOuterRadius[i]; }
227 { return (fEndInnerRadius[0] > fEndInnerRadius[1] ?
228 fEndInnerRadius[0] : fEndInnerRadius[1]); }
230 { return (fEndOuterRadius[0] > fEndOuterRadius[1] ?
231 fEndOuterRadius[0] : fEndOuterRadius[1]); }
232
233 /**
234 * Returns the type ID, "G4TwistedTubs" of the solid.
235 */
236 G4GeometryType GetEntityType() const override;
237
238 /**
239 * Makes a clone of the object for use in multi-treading.
240 * @returns A pointer to the new cloned allocated solid.
241 */
242 G4VSolid* Clone() const override;
243
244 /**
245 * Returning an estimation of the solid volume (capacity) and surface area,
246 * in internal units. Caches the computed value once computed the first time.
247 */
248 G4double GetCubicVolume() override;
249 G4double GetSurfaceArea() override;
250
251 /**
252 * Returns a random point located and uniformly distributed on the
253 * surface of the solid.
254 */
255 G4ThreeVector GetPointOnSurface() const override ;
256
257 /**
258 * Fake default constructor for usage restricted to direct object
259 * persistency for clients requiring preallocation of memory for
260 * persistifiable objects.
261 */
262 G4TwistedTubs(__void__&);
263
264 /**
265 * Copy constructor and assignment operator.
266 */
267 G4TwistedTubs(const G4TwistedTubs& rhs);
269
270#ifdef G4TWISTDEBUG
271 inline G4VTwistSurface* GetOuterHype() const { return fOuterHype; }
272#endif
273
274 private:
275
276 /**
277 * Initialiser of data.
278 */
279 inline void SetFields(G4double phitwist, G4double innerrad,
280 G4double outerrad,
281 G4double negativeEndz, G4double positiveEndz);
282
283 /**
284 * Generates the surfaces. Used in constructors.
285 */
286 void CreateSurfaces();
287
288 /**
289 * Utilities for area computation.
290 */
291 G4double GetLateralArea(G4double a, G4double r, G4double z) const;
292 G4double GetPhiCutArea(G4double a, G4double r, G4double z) const;
293
294 private:
295
296 G4double fPhiTwist; // Twist angle from -fZHalfLength to fZHalfLength
297 G4double fInnerRadius; // Inner-hype radius at z=0
298 G4double fOuterRadius; // Outer-hype radius at z=0
299 G4double fEndZ[2]; // z at endcaps, [0] = -ve z, [1] = +ve z
300 G4double fDPhi; // Phi-width of a segment fDPhi > 0
301 G4double fZHalfLength; // Half length along z-axis
302
303 G4double fInnerStereo; // Inner-hype stereo angle
304 G4double fOuterStereo; // Outer-hype stereo angle
305 G4double fTanInnerStereo; // std::tan(innerStereoAngle)
306 G4double fTanOuterStereo; // std::tan(outerStereoAngle)
307 G4double fKappa; // std::tan(fPhiTwist/2)/fZHalfLen;
308 G4double fEndInnerRadius[2]; // Inner-hype radii endcaps [0] -ve z, [1] +ve z
309 G4double fEndOuterRadius[2]; // Outer-hype radii endcaps [0] -ve z, [1] +ve z
310 G4double fEndPhi[2]; // Phi endcaps, [0] = -ve z, [1] = +ve z
311
312 G4double fInnerRadius2; // fInnerRadius * fInnerRadius
313 G4double fOuterRadius2; // fOuterRadius * fOuterRadius
314 G4double fTanInnerStereo2; // fInnerRadius * fInnerRadius
315 G4double fTanOuterStereo2; // fInnerRadius * fInnerRadius
316 G4double fEndZ2[2]; // fEndZ * fEndZ
317
318 G4VTwistSurface* fLowerEndcap; // Surface of -ve z
319 G4VTwistSurface* fUpperEndcap; // Surface of +ve z
320 G4VTwistSurface* fLatterTwisted; // Surface of -ve phi
321 G4VTwistSurface* fFormerTwisted; // Surface of +ve phi
322 G4VTwistSurface* fInnerHype; // Surface of -ve r
323 G4VTwistSurface* fOuterHype; // Surface of +ve r
324
325 G4double fCubicVolume = 0.0; // Cached value for cubic volume
326 G4double fSurfaceArea = 0.0; // Cached value for surface area
327
328 mutable G4bool fRebuildPolyhedron = false;
329 mutable G4Polyhedron* fpPolyhedron = nullptr; // polyhedron for vis
330
331};
332
333//=====================================================================
334
335//---------------------
336// inline functions
337//---------------------
338
339inline
340void G4TwistedTubs::SetFields(G4double phitwist, G4double innerrad,
341 G4double outerrad, G4double negativeEndz,
342 G4double positiveEndz)
343{
344 fCubicVolume = 0.;
345 fPhiTwist = phitwist;
346 fEndZ[0] = negativeEndz;
347 fEndZ[1] = positiveEndz;
348 fEndZ2[0] = fEndZ[0] * fEndZ[0];
349 fEndZ2[1] = fEndZ[1] * fEndZ[1];
350 fInnerRadius = innerrad;
351 fOuterRadius = outerrad;
352 fInnerRadius2 = fInnerRadius * fInnerRadius;
353 fOuterRadius2 = fOuterRadius * fOuterRadius;
354
355 if (std::fabs(fEndZ[0]) >= std::fabs(fEndZ[1]))
356 {
357 fZHalfLength = std::fabs(fEndZ[0]);
358 }
359 else
360 {
361 fZHalfLength = std::fabs(fEndZ[1]);
362 }
363
364 G4double parity = (fPhiTwist > 0 ? 1 : -1);
365 G4double tanHalfTwist = std::tan(0.5 * fPhiTwist);
366 G4double innerNumerator = std::fabs(fInnerRadius * tanHalfTwist) * parity;
367 G4double outerNumerator = std::fabs(fOuterRadius * tanHalfTwist) * parity;
368
369 fTanInnerStereo = innerNumerator / fZHalfLength;
370 fTanOuterStereo = outerNumerator / fZHalfLength;
371 fTanInnerStereo2 = fTanInnerStereo * fTanInnerStereo;
372 fTanOuterStereo2 = fTanOuterStereo * fTanOuterStereo;
373 fInnerStereo = std::atan2(innerNumerator, fZHalfLength);
374 fOuterStereo = std::atan2(outerNumerator, fZHalfLength);
375 fEndInnerRadius[0] = std::sqrt(fInnerRadius2 + fEndZ2[0] * fTanInnerStereo2);
376 fEndInnerRadius[1] = std::sqrt(fInnerRadius2 + fEndZ2[1] * fTanInnerStereo2);
377 fEndOuterRadius[0] = std::sqrt(fOuterRadius2 + fEndZ2[0] * fTanOuterStereo2);
378 fEndOuterRadius[1] = std::sqrt(fOuterRadius2 + fEndZ2[1] * fTanOuterStereo2);
379
380 fKappa = tanHalfTwist / fZHalfLength;
381 fEndPhi[0] = std::atan2(fEndZ[0] * tanHalfTwist, fZHalfLength);
382 fEndPhi[1] = std::atan2(fEndZ[1] * tanHalfTwist, fZHalfLength);
383
384#ifdef G4TWISTDEBUG
385 G4cout << "/********* G4TwistedTubs::SetFields() Field Parameters ***************** " << G4endl;
386 G4cout << "/* fPhiTwist : " << fPhiTwist << G4endl;
387 G4cout << "/* fEndZ(0, 1) : " << fEndZ[0] << " , " << fEndZ[1] << G4endl;
388 G4cout << "/* fEndPhi(0, 1) : " << fEndPhi[0] << " , " << fEndPhi[1] << G4endl;
389 G4cout << "/* fInnerRadius, fOuterRadius : " << fInnerRadius << " , " << fOuterRadius << G4endl;
390 G4cout << "/* fEndInnerRadius(0, 1) : " << fEndInnerRadius[0] << " , "
391 << fEndInnerRadius[1] << G4endl;
392 G4cout << "/* fEndOuterRadius(0, 1) : " << fEndOuterRadius[0] << " , "
393 << fEndOuterRadius[1] << G4endl;
394 G4cout << "/* fInnerStereo, fOuterStereo : " << fInnerStereo << " , " << fOuterStereo << G4endl;
395 G4cout << "/* tanHalfTwist, fKappa : " << tanHalfTwist << " , " << fKappa << G4endl;
396 G4cout << "/*********************************************************************** " << G4endl;
397#endif
398}
399
400#endif
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
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
G4AffineTransform is a class for geometric affine transformations. It supports efficient arbitrary ro...
G4ClippablePolygon in a utility class defining a polygon that can be clipped by a voxel.
G4SolidExtentList is utility class designed for calculating the extent of a CSG-like solid for a voxe...
G4TwistedTubs is a sector of a twisted hollow cylinder. A twisted cylinder which is placed along with...
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcnorm=false, G4bool *validnorm=nullptr, G4ThreeVector *n=nullptr) const override
G4double GetOuterRadius() const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const override
G4double GetZHalfLength() const
G4double GetPhiTwist() const
G4Polyhedron * CreatePolyhedron() const override
G4double GetInnerStereo() const
G4double GetTanInnerStereo() const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override
G4TwistedTubs & operator=(const G4TwistedTubs &rhs)
G4double GetEndInnerRadius() const
G4double GetEndOuterRadius() const
G4double GetOuterStereo() const
G4VSolid * Clone() const override
G4Polyhedron * GetPolyhedron() const override
~G4TwistedTubs() override
G4GeometryType GetEntityType() const override
G4double GetEndPhi(G4int i) const
G4TwistedTubs(const G4String &pname, G4double twistedangle, G4double endinnerrad, G4double endouterrad, G4double halfzlen, G4double dphi)
G4double GetTanOuterStereo() const
std::ostream & StreamInfo(std::ostream &os) const override
G4double GetSurfaceArea() override
G4double GetCubicVolume() override
void ComputeDimensions(G4VPVParameterisation *, const G4int, const G4VPhysicalVolume *) override
G4double GetTanInnerStereo2() const
G4double GetTanOuterStereo2() const
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
G4VisExtent GetExtent() const override
G4ThreeVector GetPointOnSurface() const override
void DescribeYourselfTo(G4VGraphicsScene &scene) const override
G4double GetEndZ(G4int i) const
G4double GetKappa() const
G4double GetEndInnerRadius(G4int i) const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const override
G4double GetInnerRadius() const
EInside Inside(const G4ThreeVector &p) const override
G4double GetDPhi() const
G4double GetEndOuterRadius(G4int i) const
G4VPVParameterisation ia an abstract base class for Parameterisation, able to compute the transformat...
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
G4VSolid is an abstract base class for solids, physical shapes that can be tracked through....
Definition G4VSolid.hh:80
G4VSolid(const G4String &name)
Definition G4VSolid.cc:59
G4VTwistSurface is a base class for boundary surface of a G4VSolid.
G4VoxelLimits represents limitation/restrictions of space, where restrictions are only made perpendic...
EAxis
Definition geomdefs.hh:54
EInside
Definition geomdefs.hh:67