ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Sphere.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4Sphere.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 // G4Sphere
27 //
28 // Class description:
29 //
30 // A G4Sphere is, in the general case, a section of a spherical shell,
31 // between specified phi and theta angles
32 //
33 // The phi and theta segments are described by a starting angle,
34 // and the +ve delta angle for the shape.
35 // If the delta angle is >=2*pi, or >=pi the shape is treated as
36 // continuous in phi or theta respectively.
37 //
38 // Theta must lie between 0-pi (incl).
39 //
40 // Member Data:
41 //
42 // fRmin inner radius
43 // fRmax outer radius
44 //
45 // fSPhi starting angle of the segment in radians
46 // fDPhi delta angle of the segment in radians
47 //
48 // fSTheta starting angle of the segment in radians
49 // fDTheta delta angle of the segment in radians
50 //
51 //
52 // Note:
53 // Internally fSPhi & fDPhi are adjusted so that fDPhi<=2PI,
54 // and fDPhi+fSPhi<=2PI. This enables simpler comparisons to be
55 // made with (say) Phi of a point.
56 
57 // 28.3.94 P.Kent: old C++ code converted to tolerant geometry
58 // 17.9.96 V.Grichine: final modifications to commit
59 // --------------------------------------------------------------------
60 #ifndef G4SPHERE_HH
61 #define G4SPHERE_HH
62 
63 #include "G4GeomTypes.hh"
64 
65 #if defined(G4GEOM_USE_USOLIDS)
66 #define G4GEOM_USE_USPHERE 1
67 #endif
68 
69 #if defined(G4GEOM_USE_USPHERE)
70  #define G4USphere G4Sphere
71  #include "G4USphere.hh"
72 #else
73 
75 #include "G4CSGSolid.hh"
76 #include "G4Polyhedron.hh"
77 
78 class G4VisExtent;
79 
80 class G4Sphere : public G4CSGSolid
81 {
82  public: // with description
83 
84  G4Sphere(const G4String& pName,
85  G4double pRmin, G4double pRmax,
86  G4double pSPhi, G4double pDPhi,
87  G4double pSTheta, G4double pDTheta);
88  //
89  // Constructs a sphere or sphere shell section
90  // with the given name and dimensions
91 
92  ~G4Sphere();
93  //
94  // Destructor
95 
96  // Accessors
97 
98  inline G4double GetInnerRadius () const;
99  inline G4double GetOuterRadius () const;
100  inline G4double GetStartPhiAngle () const;
101  inline G4double GetDeltaPhiAngle () const;
102  inline G4double GetStartThetaAngle() const;
103  inline G4double GetDeltaThetaAngle() const;
104  inline G4double GetSinStartPhi () const;
105  inline G4double GetCosStartPhi () const;
106  inline G4double GetSinEndPhi () const;
107  inline G4double GetCosEndPhi () const;
108  inline G4double GetSinStartTheta () const;
109  inline G4double GetCosStartTheta () const;
110  inline G4double GetSinEndTheta () const;
111  inline G4double GetCosEndTheta () const;
112 
113  // Modifiers
114 
115  inline void SetInnerRadius (G4double newRMin);
116  inline void SetOuterRadius (G4double newRmax);
117  inline void SetStartPhiAngle (G4double newSphi, G4bool trig = true);
118  inline void SetDeltaPhiAngle (G4double newDphi);
119  inline void SetStartThetaAngle(G4double newSTheta);
120  inline void SetDeltaThetaAngle(G4double newDTheta);
121 
122  // Methods for solid
123 
124  inline G4double GetCubicVolume();
126 
128  const G4int n,
129  const G4VPhysicalVolume* pRep);
130 
132 
133  G4bool CalculateExtent(const EAxis pAxis,
134  const G4VoxelLimits& pVoxelLimit,
135  const G4AffineTransform& pTransform,
136  G4double& pmin, G4double& pmax) const;
137 
138  EInside Inside(const G4ThreeVector& p) const;
139 
140  G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
141 
143  const G4ThreeVector& v) const;
144 
145  G4double DistanceToIn(const G4ThreeVector& p) const;
146 
148  const G4ThreeVector& v,
149  const G4bool calcNorm = false,
150  G4bool* validNorm = nullptr,
151  G4ThreeVector* n = nullptr) const;
152 
153  G4double DistanceToOut(const G4ThreeVector& p) const;
154 
156 
158 
159  G4VSolid* Clone() const;
160 
161  std::ostream& StreamInfo(std::ostream& os) const;
162 
163  // Visualisation functions
164 
165  G4VisExtent GetExtent () const;
166  void DescribeYourselfTo(G4VGraphicsScene& scene) const;
168 
169  public: // without description
170 
171  G4Sphere(__void__&);
172  //
173  // Fake default constructor for usage restricted to direct object
174  // persistency for clients requiring preallocation of memory for
175  // persistifiable objects.
176 
177  G4Sphere(const G4Sphere& rhs);
178  G4Sphere& operator=(const G4Sphere& rhs);
179  // Copy constructor and assignment operator.
180 
181  // Old access functions
182 
183  inline G4double GetRmin() const;
184  inline G4double GetRmax() const;
185  inline G4double GetSPhi() const;
186  inline G4double GetDPhi() const;
187  inline G4double GetSTheta() const;
188  inline G4double GetDTheta() const;
189  inline G4double GetInsideRadius() const;
190  inline void SetInsideRadius(G4double newRmin);
191 
192  private:
193 
194  inline void Initialize();
195  //
196  // Reset relevant values to zero
197 
198  inline void CheckThetaAngles(G4double sTheta, G4double dTheta);
199  inline void CheckSPhiAngle(G4double sPhi);
200  inline void CheckDPhiAngle(G4double dPhi);
201  inline void CheckPhiAngles(G4double sPhi, G4double dPhi);
202  //
203  // Reset relevant flags and angle values
204 
205  inline void InitializePhiTrigonometry();
206  inline void InitializeThetaTrigonometry();
207  //
208  // Recompute relevant trigonometric values and cache them
209 
211  //
212  // Algorithm for SurfaceNormal() following the original
213  // specification for points not on the surface
214 
215  private:
216 
217  // Used by distanceToOut
218  //
220 
221  // used by normal
222  //
224 
227  //
228  // Radial and angular tolerances
229 
231  //
232  // Radial and angular dimensions
233 
236  //
237  // Cached trigonometric values for Phi angle
238 
241  //
242  // Cached trigonometric values for Theta angle
243 
245  //
246  // Flags for identification of section, shell or full sphere
247 
249  //
250  // Cached half tolerance values
251 };
252 
253 #include "G4Sphere.icc"
254 
255 #endif
256 
257 #endif