Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:12

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4Torus
0027 //
0028 // Class description:
0029 //
0030 //   A torus or torus segment with curved sides parallel to the z-axis.
0031 //   The torus has a specified swept radius about which it is centered,
0032 //   and a given minimum and maximum radius. A minimum radius of 0
0033 //   signifies a filled torus.
0034 //   The torus segment is specified by starting and delta angles for phi,
0035 //   with 0 being the +x axis, PI/2 the +y axis. A delta angle of 2PI
0036 //   signifies a complete, unsegmented torus/cylindr.
0037 //
0038 //   Member functions:
0039 //
0040 //   As inherited from G4CSGSolid+
0041 //
0042 //     G4Torus(const G4String      &pName
0043 //             G4double      pRmin
0044 //             G4double      pRmax
0045 //             G4double      pRtor
0046 //             G4double      pSPhi
0047 //             G4double      pDPhi )
0048 //
0049 //     - Construct a torus with the given name and dimensions.
0050 //       The angles are provided is radians. pRtor >= pRmax
0051 //
0052 //   Member Data:
0053 //
0054 //  fRmin  Inside radius
0055 //  fRmax  Outside radius
0056 //  fRtor  swept radius of torus
0057 //
0058 //  fSPhi  The starting phi angle in radians,
0059 //         adjusted such that fSPhi+fDPhi<=2PI, fSPhi>-2PI
0060 //
0061 //  fDPhi  Delta angle of the segment in radians
0062 //
0063 //   You could find very often in G4Torus functions values like 'pt' or
0064 //   'it'. These are the distances from p or i G4ThreeVector points in the
0065 //   plane (Z axis points p or i) to fRtor point in XY plane. This value is
0066 //   similar to rho for G4Tubs and is used for definiton of the point
0067 //   relative to fRmin and fRmax, i.e. for solution of inside/outside
0068 //   problems
0069 
0070 // 30.10.96 V.Grichine: first version
0071 // 31.08.00 E.Medernach: migrated to numeric solutions
0072 // --------------------------------------------------------------------
0073 #ifndef G4TORUS_HH
0074 #define G4TORUS_HH
0075 
0076 #include "G4GeomTypes.hh"
0077 
0078 #if defined(G4GEOM_USE_USOLIDS)
0079 #define G4GEOM_USE_UTORUS 1
0080 #endif
0081 
0082 #if (defined(G4GEOM_USE_UTORUS) && defined(G4GEOM_USE_SYS_USOLIDS))
0083   #define G4UTorus G4Torus
0084   #include "G4UTorus.hh"
0085 #else
0086 
0087 #include <CLHEP/Units/PhysicalConstants.h>
0088 
0089 #include "G4CSGSolid.hh"
0090 
0091 class G4Torus : public G4CSGSolid
0092 {
0093 
0094   public:
0095 
0096     G4Torus(const G4String &pName,
0097                   G4double pRmin,
0098                   G4double pRmax,
0099                   G4double pRtor,
0100                   G4double pSPhi,
0101                   G4double pDPhi);
0102 
0103    ~G4Torus() override;
0104 
0105     // Accessors
0106 
0107     inline G4double GetRmin() const;
0108     inline G4double GetRmax() const;
0109     inline G4double GetRtor() const;
0110     inline G4double GetSPhi() const;
0111     inline G4double GetDPhi() const;
0112     inline G4double GetSinStartPhi () const;
0113     inline G4double GetCosStartPhi () const;
0114     inline G4double GetSinEndPhi   () const;
0115     inline G4double GetCosEndPhi   () const;
0116 
0117     // Methods of solid
0118 
0119     inline G4double GetCubicVolume() override;
0120     inline G4double GetSurfaceArea() override;
0121 
0122     EInside Inside(const G4ThreeVector& p) const override;
0123     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0124     G4bool CalculateExtent(const EAxis pAxis,
0125                            const G4VoxelLimits& pVoxelLimit,
0126                            const G4AffineTransform& pTransform,
0127                                  G4double& pmin, G4double& pmax) const override;
0128     void ComputeDimensions(      G4VPVParameterisation* p,
0129                            const G4int n,
0130                            const G4VPhysicalVolume* pRep) override;
0131     G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const override;
0132     G4double DistanceToIn(const G4ThreeVector& p,
0133                           const G4ThreeVector& v) const override;
0134     G4double DistanceToIn(const G4ThreeVector& p) const override;
0135     G4double DistanceToOut(const G4ThreeVector& p,const G4ThreeVector& v,
0136                            const G4bool calcNorm = false,
0137                                  G4bool* validNorm = nullptr,
0138                                  G4ThreeVector* n = nullptr) const override;
0139     G4double DistanceToOut(const G4ThreeVector& p) const override;
0140 
0141     G4GeometryType GetEntityType() const override;
0142 
0143     G4ThreeVector GetPointOnSurface() const override;
0144 
0145     G4VSolid* Clone() const override;
0146 
0147     std::ostream& StreamInfo(std::ostream& os) const override;
0148 
0149     // Visualisation functions
0150 
0151     void          DescribeYourselfTo (G4VGraphicsScene& scene) const override;
0152     G4Polyhedron* CreatePolyhedron   () const override;
0153 
0154     void SetAllParameters(G4double pRmin, G4double pRmax, G4double pRtor,
0155                           G4double pSPhi, G4double pDPhi);
0156 
0157     G4Torus(__void__&);
0158       // Fake default constructor for usage restricted to direct object
0159       // persistency for clients requiring preallocation of memory for
0160       // persistifiable objects.
0161 
0162     G4Torus(const G4Torus& rhs);
0163     G4Torus& operator=(const G4Torus& rhs);
0164       // Copy constructor and assignment operator.
0165 
0166   private:
0167 
0168     void TorusRootsJT(const G4ThreeVector& p,
0169                       const G4ThreeVector& v,
0170                             G4double r,
0171                             std::vector<G4double>& roots) const ;
0172 
0173     G4double SolveNumericJT(const G4ThreeVector& p,
0174                             const G4ThreeVector& v,
0175                                   G4double r,
0176                                   G4bool IsDistanceToIn) const;
0177 
0178     G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p) const;
0179       // Algorithm for SurfaceNormal() following the original
0180       // specification for points not on the surface
0181 
0182   private:
0183 
0184     G4double fRmin,fRmax,fRtor,fSPhi,fDPhi;
0185 
0186     // Used by distanceToOut
0187     enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi};
0188 
0189     // used by normal
0190     enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi};
0191 
0192     G4double fRminTolerance, fRmaxTolerance, kRadTolerance, kAngTolerance;
0193       // Radial and angular tolerances
0194 
0195     G4double halfCarTolerance, halfAngTolerance;
0196       // Cached half tolerance values
0197 
0198 };
0199 
0200 #include "G4Torus.icc"
0201 
0202 #endif  // defined(G4GEOM_USE_UTORUS) && defined(G4GEOM_USE_SYS_USOLIDS)
0203 
0204 
0205 #endif // G4TORUS_HH