Back to home page

EIC code displayed by LXR

 
 

    


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

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 // G4Ellipsoid
0027 //
0028 // Class description:
0029 //
0030 //   A G4Ellipsoid is an ellipsoidal solid, optionally cut at a given z
0031 //
0032 //   Member Data:
0033 //
0034 //     xSemiAxis   semi-axis, X
0035 //     ySemiAxis   semi-axis, Y
0036 //     zSemiAxis   semi-axis, Z
0037 //     zBottomCut  lower cut in Z (solid lies above this plane)
0038 //     zTopCut     upper cut in Z (solid lies below this plane)
0039 
0040 // 10.11.1999  G.Horton-Smith (Caltech, USA) - First implementation
0041 // 10.02.2005  G.Guerrieri (INFN Genova, Italy) - Revision
0042 // 15.12.2019  E.Tcherniaev - Complete revision
0043 // --------------------------------------------------------------------
0044 #ifndef G4ELLIPSOID_HH
0045 #define G4ELLIPSOID_HH
0046 
0047 #include "G4GeomTypes.hh"
0048 
0049 #if defined(G4GEOM_USE_USOLIDS)
0050 #define G4GEOM_USE_UELLIPSOID 1
0051 #endif
0052 
0053 #if (defined(G4GEOM_USE_UELLIPSOID) && defined(G4GEOM_USE_SYS_USOLIDS))
0054   #define G4UEllipsoid G4Ellipsoid
0055   #include "G4UEllipsoid.hh"
0056 #else
0057 
0058 #include <CLHEP/Units/PhysicalConstants.h>
0059 
0060 #include "G4VSolid.hh"
0061 #include "G4Polyhedron.hh"
0062 
0063 class G4Ellipsoid : public G4VSolid
0064 {
0065   public:
0066 
0067     G4Ellipsoid(const G4String& name,
0068                       G4double  xSemiAxis,
0069                       G4double  ySemiAxis,
0070                       G4double  zSemiAxis,
0071                       G4double  zBottomCut = 0.,
0072                       G4double  zTopCut = 0.);
0073 
0074     ~G4Ellipsoid() override;
0075 
0076     // Accessors
0077     inline G4double GetDx() const;
0078     inline G4double GetDy() const;
0079     inline G4double GetDz() const;
0080     inline G4double GetSemiAxisMax (G4int i) const;
0081     inline G4double GetZBottomCut() const;
0082     inline G4double GetZTopCut() const;
0083 
0084     // Modifiers
0085     inline void SetSemiAxis (G4double x, G4double y, G4double z);
0086     inline void SetZCuts (G4double newzBottomCut, G4double newzTopCut);
0087 
0088     // Standard methods
0089     void ComputeDimensions(G4VPVParameterisation* p,
0090                            const G4int n,
0091                            const G4VPhysicalVolume* pRep) override;
0092 
0093     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0094     G4bool CalculateExtent(const EAxis pAxis,
0095                            const G4VoxelLimits& pVoxelLimit,
0096                            const G4AffineTransform& pTransform,
0097                                  G4double& pmin, G4double& pmax) const override;
0098 
0099     EInside Inside(const G4ThreeVector& p) const override;
0100     G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
0101     G4double DistanceToIn(const G4ThreeVector& p,
0102                           const G4ThreeVector& v) const override;
0103     G4double DistanceToIn(const G4ThreeVector& p) const override;
0104     G4double DistanceToOut(const G4ThreeVector& p,
0105                            const G4ThreeVector& v,
0106                            const G4bool calcNorm = false,
0107                                  G4bool* validNorm = nullptr,
0108                                  G4ThreeVector* n = nullptr) const override;
0109     G4double DistanceToOut(const G4ThreeVector& p) const override;
0110 
0111     G4GeometryType GetEntityType() const override;
0112 
0113     G4VSolid* Clone() const override;
0114 
0115     std::ostream& StreamInfo(std::ostream& os) const override;
0116 
0117     G4double GetCubicVolume() override;
0118     G4double GetSurfaceArea() override;
0119 
0120     G4ThreeVector GetPointOnSurface() const override;
0121 
0122     // Visualisation methods
0123     void DescribeYourselfTo(G4VGraphicsScene& scene) const override;
0124     G4VisExtent GetExtent() const override;
0125     G4Polyhedron* CreatePolyhedron() const override;
0126     G4Polyhedron* GetPolyhedron () const override;
0127 
0128     // Fake default constructor for usage restricted to direct object
0129     // persistency for clients requiring preallocation of memory for
0130     // persistifiable objects
0131     G4Ellipsoid(__void__&);
0132 
0133     // Copy constructorassignment operator
0134     G4Ellipsoid(const G4Ellipsoid& rhs);
0135 
0136     // Assignment
0137     G4Ellipsoid& operator=(const G4Ellipsoid& rhs);
0138 
0139   private:
0140 
0141     // Check parameters and set cached values
0142     void CheckParameters();
0143 
0144     // Return normal to surface closest to p
0145     G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
0146 
0147     // Calculate area of lateral surface
0148     G4double LateralSurfaceArea() const;
0149 
0150   private:
0151 
0152     // Ellipsoid parameters
0153     G4double fDx;         // X semi-axis
0154     G4double fDy;         // Y semi-axis
0155     G4double fDz;         // Z semi-axis
0156     G4double fZBottomCut; // Bottom cut in Z
0157     G4double fZTopCut;    // Top cut in Z
0158 
0159     // Precalculated cached values
0160     G4double halfTolerance; // Surface tolerance
0161     G4double fXmax;         // X extent
0162     G4double fYmax;         // Y extent
0163     G4double fRsph;         // Radius of bounding sphere
0164     G4double fR;            // Radius of sphere after scaling
0165     G4double fSx;           // X scale factor
0166     G4double fSy;           // Y scale factor
0167     G4double fSz;           // Z scale factor
0168     G4double fZMidCut;      // Middle position between cuts after scaling
0169     G4double fZDimCut;      // Half distance between cut after scaling
0170     G4double fQ1; // 1st coefficient in approximation of dist = Q1*(x^2+y^2+z^2) - Q2
0171     G4double fQ2; // 2nd coefficient in approximation of dist = Q1*(x^2+y^2+z^2) - Q2
0172 
0173     G4double fCubicVolume = 0.0; // Volume
0174     G4double fSurfaceArea = 0.0; // Surface area
0175     mutable G4double fLateralArea = 0.0; // Lateral surface area
0176     mutable G4bool fRebuildPolyhedron = false;
0177     mutable G4Polyhedron* fpPolyhedron = nullptr;
0178 };
0179 
0180 #include "G4Ellipsoid.icc"
0181 
0182 #endif  // defined(G4GEOM_USE_UELLIPSOID) && defined(G4GEOM_USE_SYS_USOLIDS)
0183 
0184 #endif // G4ELLIPSOID_HH