Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:05

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 // G4CutTubs
0027 //
0028 // Class description:
0029 //
0030 // G4CutTubs is a tube with possible cuts in +-Z.
0031 // Implementation adapted from G4Tubs (subclass of G4Tubs) and
0032 // from TGEo Ctube implementation (by A.Gheata, CERN)
0033 //
0034 // G4CutTubs(pName,pRMin,pRMax,pDZ,pSPhi,pEPhi,pLowNorm,pHighNorm)
0035 //           pName,pRMin,pRMax,pDZ,pSPhi,pEPhi are the same as for G4Tubs,
0036 //           pLowNorm=Outside Normal at -Z
0037 //           pHighNorm=Outsie Normal at +Z.
0038 
0039 // Author: Tatiana Nikitina, CERN
0040 // --------------------------------------------------------------------
0041 
0042 #ifndef G4CUTTUBS_HH
0043 #define G4CUTTUBS_HH
0044 
0045 #include "G4GeomTypes.hh"
0046 
0047 #if defined(G4GEOM_USE_USOLIDS)
0048 #define G4GEOM_USE_UCTUBS 1
0049 #endif
0050 
0051 #if defined(G4GEOM_USE_UCTUBS)
0052   #define G4UCutTubs G4CutTubs
0053   #include "G4UCutTubs.hh"
0054 #else
0055 
0056 #include "G4CSGSolid.hh"
0057 #include "G4Polyhedron.hh"
0058 
0059 class G4CutTubs : public G4CSGSolid
0060 {
0061   public:
0062 
0063     G4CutTubs( const G4String& pName,
0064                      G4double pRMin,
0065                      G4double pRMax,
0066                      G4double pDz,
0067                      G4double pSPhi,
0068                      G4double pDPhi,
0069                      G4ThreeVector pLowNorm,
0070                      G4ThreeVector pHighNorm );
0071       //
0072       // Constructs a tubs with the given name and dimensions
0073 
0074    ~G4CutTubs() override;
0075       //
0076       // Destructor
0077 
0078     // Accessors
0079 
0080     inline G4double GetInnerRadius   () const;
0081     inline G4double GetOuterRadius   () const;
0082     inline G4double GetZHalfLength   () const;
0083     inline G4double GetStartPhiAngle () const;
0084     inline G4double GetDeltaPhiAngle () const;
0085     inline G4double GetSinStartPhi   () const;
0086     inline G4double GetCosStartPhi   () const;
0087     inline G4double GetSinEndPhi     () const;
0088     inline G4double GetCosEndPhi     () const;
0089     inline G4ThreeVector GetLowNorm  () const;
0090     inline G4ThreeVector GetHighNorm () const;
0091 
0092     // Modifiers
0093 
0094     inline void SetInnerRadius   (G4double newRMin);
0095     inline void SetOuterRadius   (G4double newRMax);
0096     inline void SetZHalfLength   (G4double newDz);
0097     inline void SetStartPhiAngle (G4double newSPhi, G4bool trig=true);
0098     inline void SetDeltaPhiAngle (G4double newDPhi);
0099 
0100     // Methods for solid
0101 
0102     G4double GetCubicVolume() override;
0103     G4double GetSurfaceArea() override;
0104 
0105     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0106 
0107     G4bool CalculateExtent(const EAxis pAxis,
0108                            const G4VoxelLimits& pVoxelLimit,
0109                            const G4AffineTransform& pTransform,
0110                                  G4double& pmin, G4double& pmax) const override;
0111 
0112     EInside Inside( const G4ThreeVector& p ) const override;
0113 
0114     G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override;
0115 
0116     G4double DistanceToIn(const G4ThreeVector& p,
0117                           const G4ThreeVector& v) const override;
0118     G4double DistanceToIn(const G4ThreeVector& p) const override;
0119     G4double DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
0120                            const G4bool calcNorm = false,
0121                                  G4bool* validNorm = nullptr,
0122                                  G4ThreeVector* n = nullptr) const override;
0123     G4double DistanceToOut(const G4ThreeVector& p) const override;
0124 
0125     G4GeometryType GetEntityType() const override;
0126 
0127     G4ThreeVector GetPointOnSurface() const override;
0128 
0129     G4VSolid* Clone() const override;
0130 
0131     std::ostream& StreamInfo( std::ostream& os ) const override;
0132 
0133     // Visualisation functions
0134 
0135     void          DescribeYourselfTo ( G4VGraphicsScene& scene ) const override;
0136     G4Polyhedron* CreatePolyhedron () const override;
0137 
0138     G4CutTubs(__void__&);
0139       //
0140       // Fake default constructor for usage restricted to direct object
0141       // persistency for clients requiring preallocation of memory for
0142       // persistifiable objects.
0143 
0144     G4CutTubs(const G4CutTubs& rhs);
0145     G4CutTubs& operator=(const G4CutTubs& rhs);
0146       // Copy constructor and assignment operator.
0147 
0148   protected:
0149 
0150     inline void Initialize();
0151       //
0152       // Reset relevant values to zero
0153 
0154     inline void CheckSPhiAngle(G4double sPhi);
0155     inline void CheckDPhiAngle(G4double dPhi);
0156     inline void CheckPhiAngles(G4double sPhi, G4double dPhi);
0157       //
0158       // Reset relevant flags and angle values
0159 
0160     inline void InitializeTrigonometry();
0161       //
0162       // Recompute relevant trigonometric values and cache them
0163 
0164     G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const;
0165       //
0166       // Algorithm for SurfaceNormal() following the original
0167       // specification for points not on the surface
0168 
0169     G4bool IsCrossingCutPlanes() const;
0170       // Check if the cutted planes are crossing.
0171       // If 'true' , solid is ill defined
0172 
0173     G4double GetCutZ(const G4ThreeVector& p) const;
0174       // Get Z value of the point on Cutted Plane
0175 
0176   private:
0177 
0178     G4double kRadTolerance, kAngTolerance;
0179       //
0180       // Radial and angular tolerances
0181 
0182      G4double fRMin, fRMax, fDz, fSPhi, fDPhi;
0183      mutable G4double fZMin, fZMax;
0184       //
0185       // Radial and angular dimensions
0186 
0187     G4double sinCPhi, cosCPhi, cosHDPhi, cosHDPhiOT, cosHDPhiIT,
0188              sinSPhi, cosSPhi, sinEPhi, cosEPhi;
0189       //
0190       // Cached trigonometric values
0191 
0192     G4bool fPhiFullCutTube = false;
0193       //
0194       // Flag for identification of section or full tube
0195 
0196     G4double halfCarTolerance, halfRadTolerance, halfAngTolerance;
0197       //
0198       // Cached half tolerance values
0199 
0200     G4ThreeVector fLowNorm, fHighNorm;
0201       //
0202       // Normals of Cut at -/+ Dz
0203 };
0204 
0205 #include "G4CutTubs.icc"
0206 
0207 #endif
0208 
0209 #endif