ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Torus.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4Torus.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 // G4Torus
27 //
28 // Class description:
29 //
30 // A torus or torus segment with curved sides parallel to the z-axis.
31 // The torus has a specified swept radius about which it is centered,
32 // and a given minimum and maximum radius. A minimum radius of 0
33 // signifies a filled torus.
34 // The torus segment is specified by starting and delta angles for phi,
35 // with 0 being the +x axis, PI/2 the +y axis. A delta angle of 2PI
36 // signifies a complete, unsegmented torus/cylindr.
37 //
38 // Member functions:
39 //
40 // As inherited from G4CSGSolid+
41 //
42 // G4Torus(const G4String &pName
43 // G4double pRmin
44 // G4double pRmax
45 // G4double pRtor
46 // G4double pSPhi
47 // G4double pDPhi )
48 //
49 // - Construct a torus with the given name and dimensions.
50 // The angles are provided is radians. pRtor >= pRmax
51 //
52 // Member Data:
53 //
54 // fRmin Inside radius
55 // fRmax Outside radius
56 // fRtor swept radius of torus
57 //
58 // fSPhi The starting phi angle in radians,
59 // adjusted such that fSPhi+fDPhi<=2PI, fSPhi>-2PI
60 //
61 // fDPhi Delta angle of the segment in radians
62 //
63 // You could find very often in G4Torus functions values like 'pt' or
64 // 'it'. These are the distances from p or i G4ThreeVector points in the
65 // plane (Z axis points p or i) to fRtor point in XY plane. This value is
66 // similar to rho for G4Tubs and is used for definiton of the point
67 // relative to fRmin and fRmax, i.e. for solution of inside/outside
68 // problems
69 
70 // 30.10.96 V.Grichine: first version
71 // 31.08.00 E.Medernach: migrated to numeric solutions
72 // --------------------------------------------------------------------
73 #ifndef G4TORUS_HH
74 #define G4TORUS_HH
75 
76 #include "G4GeomTypes.hh"
77 
78 #if defined(G4GEOM_USE_USOLIDS)
79 #define G4GEOM_USE_UTORUS 1
80 #endif
81 
82 #if (defined(G4GEOM_USE_UTORUS) && defined(G4GEOM_USE_SYS_USOLIDS))
83  #define G4UTorus G4Torus
84  #include "G4UTorus.hh"
85 #else
86 
88 
89 #include "G4CSGSolid.hh"
90 
91 class G4Torus : public G4CSGSolid
92 {
93 
94  public: // with description
95 
96  G4Torus(const G4String &pName,
97  G4double pRmin,
98  G4double pRmax,
99  G4double pRtor,
100  G4double pSPhi,
101  G4double pDPhi);
102 
103  ~G4Torus();
104 
105  // Accessors
106 
107  inline G4double GetRmin() const;
108  inline G4double GetRmax() const;
109  inline G4double GetRtor() const;
110  inline G4double GetSPhi() const;
111  inline G4double GetDPhi() const;
112  inline G4double GetSinStartPhi () const;
113  inline G4double GetCosStartPhi () const;
114  inline G4double GetSinEndPhi () const;
115  inline G4double GetCosEndPhi () const;
116 
117  // Methods of solid
118 
119  inline G4double GetCubicVolume();
120  inline G4double GetSurfaceArea();
121 
122  EInside Inside(const G4ThreeVector& p) const;
124  G4bool CalculateExtent(const EAxis pAxis,
125  const G4VoxelLimits& pVoxelLimit,
126  const G4AffineTransform& pTransform,
127  G4double& pmin, G4double& pmax) const;
129  const G4int n,
130  const G4VPhysicalVolume* pRep);
131  G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
132  G4double DistanceToIn(const G4ThreeVector& p,const G4ThreeVector& v) const;
133  G4double DistanceToIn(const G4ThreeVector& p) const;
135  const G4bool calcNorm = false,
136  G4bool* validNorm = nullptr,
137  G4ThreeVector* n = nullptr) const;
138  G4double DistanceToOut(const G4ThreeVector& p) const;
139 
141 
143 
144  G4VSolid* Clone() const;
145 
146  std::ostream& StreamInfo(std::ostream& os) const;
147 
148  // Visualisation functions
149 
150  void DescribeYourselfTo (G4VGraphicsScene& scene) const;
151  G4Polyhedron* CreatePolyhedron () const;
152 
153  public: // without description
154 
155  void SetAllParameters(G4double pRmin, G4double pRmax, G4double pRtor,
156  G4double pSPhi, G4double pDPhi);
157 
158  G4Torus(__void__&);
159  // Fake default constructor for usage restricted to direct object
160  // persistency for clients requiring preallocation of memory for
161  // persistifiable objects.
162 
163  G4Torus(const G4Torus& rhs);
164  G4Torus& operator=(const G4Torus& rhs);
165  // Copy constructor and assignment operator.
166 
167  private:
168 
169  void TorusRootsJT(const G4ThreeVector& p,
170  const G4ThreeVector& v,
171  G4double r,
172  std::vector<G4double>& roots) const ;
173 
175  const G4ThreeVector& v,
176  G4double r,
177  G4bool IsDistanceToIn) const;
178 
180  // Algorithm for SurfaceNormal() following the original
181  // specification for points not on the surface
182 
183  private:
184 
186 
187  // Used by distanceToOut
189 
190  // used by normal
192 
194  // Radial and angular tolerances
195 
197  // Cached half tolerance values
198 
199 };
200 
201 #include "G4Torus.icc"
202 
203 #endif // defined(G4GEOM_USE_UTORUS) && defined(G4GEOM_USE_SYS_USOLIDS)
204 
205 
206 #endif // G4TORUS_HH