Back to home page

EIC code displayed by LXR

 
 

    


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

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 // G4Tubs
0027 //
0028 // Class description:
0029 //
0030 //   A tube or tube segment with curved sides parallel to
0031 //   the z-axis. The tube has a specified half-length along
0032 //   the z-axis, about which it is centered, and a given
0033 //   minimum and maximum radius. A minimum radius of 0
0034 //   corresponds to filled tube /cylinder. The tube segment is
0035 //   specified by starting and delta angles for phi, with 0
0036 //   being the +x axis, PI/2 the +y axis.
0037 //   A delta angle of 2PI signifies a complete, unsegmented
0038 //   tube/cylinder.
0039 //
0040 //   Member Data:
0041 //
0042 //   fRMin  Inner radius
0043 //   fRMax  Outer radius
0044 //   fDz  half length in z
0045 //
0046 //   fSPhi  The starting phi angle in radians,
0047 //          adjusted such that fSPhi+fDPhi<=2PI, fSPhi>-2PI
0048 //
0049 //   fDPhi  Delta angle of the segment.
0050 //
0051 //   fPhiFullTube   Boolean variable used for indicate the Phi Section
0052 
0053 // 23.01.94 P.Kent: First version. Converted to `tolerant' geometry
0054 // --------------------------------------------------------------------
0055 #ifndef G4TUBS_HH
0056 #define G4TUBS_HH
0057 
0058 #include "G4GeomTypes.hh"
0059 
0060 #if defined(G4GEOM_USE_USOLIDS)
0061 #define G4GEOM_USE_UTUBS 1
0062 #endif
0063 
0064 #if defined(G4GEOM_USE_UTUBS)
0065   #define G4UTubs G4Tubs
0066   #include "G4UTubs.hh"
0067 #else
0068 
0069 #include <CLHEP/Units/PhysicalConstants.h>
0070 
0071 #include "G4CSGSolid.hh"
0072 #include "G4Polyhedron.hh"
0073 
0074 class G4Tubs : public G4CSGSolid
0075 {
0076   public:
0077 
0078     G4Tubs( const G4String& pName,
0079                   G4double pRMin,
0080                   G4double pRMax,
0081                   G4double pDz,
0082                   G4double pSPhi,
0083                   G4double pDPhi );
0084       //
0085       // Constructs a tubs with the given name and dimensions
0086 
0087     ~G4Tubs() override;
0088       //
0089       // Destructor
0090 
0091     // Accessors
0092 
0093     inline G4double GetInnerRadius   () const;
0094     inline G4double GetOuterRadius   () const;
0095     inline G4double GetZHalfLength   () const;
0096     inline G4double GetStartPhiAngle () const;
0097     inline G4double GetDeltaPhiAngle () const;
0098     inline G4double GetSinStartPhi   () const;
0099     inline G4double GetCosStartPhi   () const;
0100     inline G4double GetSinEndPhi     () const;
0101     inline G4double GetCosEndPhi     () const;
0102 
0103     // Modifiers
0104 
0105     inline void SetInnerRadius   (G4double newRMin);
0106     inline void SetOuterRadius   (G4double newRMax);
0107     inline void SetZHalfLength   (G4double newDz);
0108     inline void SetStartPhiAngle (G4double newSPhi, G4bool trig=true);
0109     inline void SetDeltaPhiAngle (G4double newDPhi);
0110 
0111     // Methods for solid
0112 
0113     inline G4double GetCubicVolume() override;
0114     inline G4double GetSurfaceArea() override;
0115 
0116     void ComputeDimensions(       G4VPVParameterisation* p,
0117                             const G4int n,
0118                             const G4VPhysicalVolume* pRep ) override;
0119 
0120     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0121 
0122     G4bool CalculateExtent(const EAxis pAxis,
0123                            const G4VoxelLimits& pVoxelLimit,
0124                            const G4AffineTransform& pTransform,
0125                                  G4double& pmin, G4double& pmax) const override;
0126 
0127     EInside Inside( const G4ThreeVector& p ) const override;
0128 
0129     G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override;
0130 
0131     G4double DistanceToIn(const G4ThreeVector& p,
0132                           const G4ThreeVector& v) const override;
0133     G4double DistanceToIn(const G4ThreeVector& p) const override;
0134     G4double DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
0135                            const G4bool calcNorm = false,
0136                                  G4bool* validNorm = nullptr,
0137                                  G4ThreeVector* n = nullptr) const override;
0138     G4double DistanceToOut(const G4ThreeVector& p) const override;
0139 
0140     G4GeometryType GetEntityType() const override;
0141 
0142     G4ThreeVector GetPointOnSurface() const override;
0143 
0144     G4VSolid* Clone() const override;
0145 
0146     std::ostream& StreamInfo( std::ostream& os ) const override;
0147 
0148     // Visualisation functions
0149 
0150     void          DescribeYourselfTo (G4VGraphicsScene& scene) const override;
0151     G4Polyhedron* CreatePolyhedron   () const override;
0152 
0153     G4Tubs(__void__&);
0154       //
0155       // Fake default constructor for usage restricted to direct object
0156       // persistency for clients requiring preallocation of memory for
0157       // persistifiable objects.
0158 
0159     G4Tubs(const G4Tubs& rhs);
0160     G4Tubs& operator=(const G4Tubs& rhs);
0161       // Copy constructor and assignment operator.
0162 
0163   protected:
0164 
0165     inline void Initialize();
0166       //
0167       // Reset relevant values to zero
0168 
0169     inline void CheckSPhiAngle(G4double sPhi);
0170     inline void CheckDPhiAngle(G4double dPhi);
0171     inline void CheckPhiAngles(G4double sPhi, G4double dPhi);
0172       //
0173       // Reset relevant flags and angle values
0174 
0175     inline void InitializeTrigonometry();
0176       //
0177       // Recompute relevant trigonometric values and cache them
0178 
0179     inline G4double FastInverseRxy( const G4ThreeVector& pos, G4double invRad,
0180                                     G4double normalTolerance ) const;
0181       //
0182       // Compute fast inverse cylindrical (Rxy) radius for points expected to
0183       // be on a cylindrical surface. Ensures that surface normal vector
0184       // produced has magnitude with 'normalTolerance' of unit
0185 
0186     virtual G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const;
0187       //
0188       // Algorithm for SurfaceNormal() following the original
0189       // specification for points not on the surface
0190 
0191   protected:
0192 
0193     // Used by distanceToOut
0194     //
0195     enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kPZ,kMZ};
0196 
0197     // Used by normal
0198     //
0199     enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNZ};
0200 
0201     G4double kRadTolerance, kAngTolerance;
0202       //
0203       // Radial and angular tolerances
0204 
0205     static constexpr G4double kNormTolerance = 1.0e-6;
0206       //
0207       // Tolerance of unity for surface normal
0208       // (for speedup - use fInvRmax if possible )
0209 
0210     G4double fRMin, fRMax, fDz, fSPhi, fDPhi;
0211       //
0212       // Radial and angular dimensions
0213 
0214     G4double sinCPhi, cosCPhi, cosHDPhi, cosHDPhiOT, cosHDPhiIT,
0215              sinSPhi, cosSPhi, sinEPhi, cosEPhi;
0216       //
0217       // Cached trigonometric values
0218 
0219     G4bool fPhiFullTube;
0220       //
0221       // Flag for identification of section or full tube
0222 
0223     G4double fInvRmax, fInvRmin;
0224       //
0225       // More cached values - inverse of Rmax, Rmin.
0226 
0227     G4double halfCarTolerance, halfRadTolerance, halfAngTolerance;
0228       //
0229       // Cached half tolerance values
0230 };
0231 
0232 #include "G4Tubs.icc"
0233 
0234 #endif
0235 
0236 #endif