ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Tubs.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4Tubs.hh
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 // G4Tubs
27 //
28 // Class description:
29 //
30 // A tube or tube segment with curved sides parallel to
31 // the z-axis. The tube has a specified half-length along
32 // the z-axis, about which it is centered, and a given
33 // minimum and maximum radius. A minimum radius of 0
34 // corresponds to filled tube /cylinder. The tube segment is
35 // specified by starting and delta angles for phi, with 0
36 // being the +x axis, PI/2 the +y axis.
37 // A delta angle of 2PI signifies a complete, unsegmented
38 // tube/cylinder.
39 //
40 // Member Data:
41 //
42 // fRMin Inner radius
43 // fRMax Outer radius
44 // fDz half length in z
45 //
46 // fSPhi The starting phi angle in radians,
47 // adjusted such that fSPhi+fDPhi<=2PI, fSPhi>-2PI
48 //
49 // fDPhi Delta angle of the segment.
50 //
51 // fPhiFullTube Boolean variable used for indicate the Phi Section
52 
53 // 23.01.94 P.Kent: First version. Converted to `tolerant' geometry
54 // --------------------------------------------------------------------
55 #ifndef G4TUBS_HH
56 #define G4TUBS_HH
57 
58 #include "G4GeomTypes.hh"
59 
60 #if defined(G4GEOM_USE_USOLIDS)
61 #define G4GEOM_USE_UTUBS 1
62 #endif
63 
64 #if defined(G4GEOM_USE_UTUBS)
65  #define G4UTubs G4Tubs
66  #include "G4UTubs.hh"
67 #else
68 
70 
71 #include "G4CSGSolid.hh"
72 #include "G4Polyhedron.hh"
73 
74 class G4Tubs : public G4CSGSolid
75 {
76  public: // with description
77 
78  G4Tubs( const G4String& pName,
79  G4double pRMin,
80  G4double pRMax,
81  G4double pDz,
82  G4double pSPhi,
83  G4double pDPhi );
84  //
85  // Constructs a tubs with the given name and dimensions
86 
87  virtual ~G4Tubs();
88  //
89  // Destructor
90 
91  // Accessors
92 
93  inline G4double GetInnerRadius () const;
94  inline G4double GetOuterRadius () const;
95  inline G4double GetZHalfLength () const;
96  inline G4double GetStartPhiAngle () const;
97  inline G4double GetDeltaPhiAngle () const;
98  inline G4double GetSinStartPhi () const;
99  inline G4double GetCosStartPhi () const;
100  inline G4double GetSinEndPhi () const;
101  inline G4double GetCosEndPhi () const;
102 
103  // Modifiers
104 
105  inline void SetInnerRadius (G4double newRMin);
106  inline void SetOuterRadius (G4double newRMax);
107  inline void SetZHalfLength (G4double newDz);
108  inline void SetStartPhiAngle (G4double newSPhi, G4bool trig=true);
109  inline void SetDeltaPhiAngle (G4double newDPhi);
110 
111  // Methods for solid
112 
113  inline G4double GetCubicVolume();
114  inline G4double GetSurfaceArea();
115 
117  const G4int n,
118  const G4VPhysicalVolume* pRep );
119 
121 
122  G4bool CalculateExtent( const EAxis pAxis,
123  const G4VoxelLimits& pVoxelLimit,
124  const G4AffineTransform& pTransform,
125  G4double& pmin, G4double& pmax ) const;
126 
127  EInside Inside( const G4ThreeVector& p ) const;
128 
129  G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const;
130 
131  G4double DistanceToIn(const G4ThreeVector& p, const G4ThreeVector& v) const;
132  G4double DistanceToIn(const G4ThreeVector& p) const;
134  const G4bool calcNorm = false,
135  G4bool* validNorm = nullptr,
136  G4ThreeVector* n = nullptr) const;
137  G4double DistanceToOut(const G4ThreeVector& p) const;
138 
140 
142 
143  G4VSolid* Clone() const;
144 
145  std::ostream& StreamInfo( std::ostream& os ) const;
146 
147  // Visualisation functions
148 
149  void DescribeYourselfTo ( G4VGraphicsScene& scene ) const;
150  G4Polyhedron* CreatePolyhedron () const;
151 
152  public: // without description
153 
154  G4Tubs(__void__&);
155  //
156  // Fake default constructor for usage restricted to direct object
157  // persistency for clients requiring preallocation of memory for
158  // persistifiable objects.
159 
160  G4Tubs(const G4Tubs& rhs);
161  G4Tubs& operator=(const G4Tubs& rhs);
162  // Copy constructor and assignment operator.
163 
164  // Older names for access functions
165 
166  inline G4double GetRMin() const;
167  inline G4double GetRMax() const;
168  inline G4double GetDz () const;
169  inline G4double GetSPhi() const;
170  inline G4double GetDPhi() const;
171 
172  protected:
173 
174  inline void Initialize();
175  //
176  // Reset relevant values to zero
177 
178  inline void CheckSPhiAngle(G4double sPhi);
179  inline void CheckDPhiAngle(G4double dPhi);
180  inline void CheckPhiAngles(G4double sPhi, G4double dPhi);
181  //
182  // Reset relevant flags and angle values
183 
184  inline void InitializeTrigonometry();
185  //
186  // Recompute relevant trigonometric values and cache them
187 
188  inline G4double FastInverseRxy( const G4ThreeVector& pos, G4double invRad,
189  G4double normalTolerance ) const;
190  //
191  // Compute fast inverse cylindrical (Rxy) radius for points expected to
192  // be on a cylindrical surface. Ensures that surface normal vector
193  // produced has magnitude with 'normalTolerance' of unit
194 
195  virtual G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const;
196  //
197  // Algorithm for SurfaceNormal() following the original
198  // specification for points not on the surface
199 
200  protected:
201 
202  // Used by distanceToOut
203  //
205 
206  // Used by normal
207  //
209 
211  //
212  // Radial and angular tolerances
213 
214  static constexpr G4double kNormTolerance = 1.0e-6;
215  //
216  // Tolerance of unity for surface normal
217  // (for speedup - use fInvRmax if possible )
218 
220  //
221  // Radial and angular dimensions
222 
225  //
226  // Cached trigonometric values
227 
229  //
230  // Flag for identification of section or full tube
231 
233  //
234  // More cached values - inverse of Rmax, Rmin.
235 
237  //
238  // Cached half tolerance values
239 };
240 
241 #include "G4Tubs.icc"
242 
243 #endif
244 
245 #endif