Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 09:13:09

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 // G4EllipticalCone
0027 //
0028 // Class description:
0029 //
0030 // G4EllipticalCone is a full cone with elliptical base which can be cut in Z.
0031 //
0032 // Member Data:
0033 //
0034 //      xSemiAxis       semi-axis, x, without dimentions
0035 //      ySemiAxis       semi-axis, y, without dimentions
0036 //      zheight         height, z
0037 //      zTopCut         upper cut plane level, z
0038 //
0039 // The height in Z corresponds to where the elliptical cone hits the
0040 // Z-axis if it had no Z cut. Also the cone is centered at zero having a
0041 // base at zTopCut and another at -zTopCut. The semi-major axes at the Z=0
0042 // plane are given by xSemiAxis*zheight and ySemiAxis*zheight so that the
0043 // curved surface of our cone satisfies the equation:
0044 //
0045 // ***************************************************************************
0046 // *                                                                         *
0047 // *           (x/xSemiAxis)^2 + (y/ySemiAxis)^2 = (zheight - z)^2           *
0048 // *                                                                         *
0049 // ***************************************************************************
0050 //
0051 // In case you want to construct G4EllipticalCone from:
0052 //   1. halflength in Z = zTopCut
0053 //   2. Dx and Dy =  halflength of ellipse axis  at  z = -zTopCut
0054 //   3. dx and dy =  halflength of ellipse axis  at  z =  zTopCut
0055 //      ! Attention :  dx/dy=Dx/Dy
0056 //
0057 // You need to find xSemiAxis,ySemiAxis and zheight:
0058 //
0059 //  xSemiAxis = (Dx-dx)/(2*zTopCut)
0060 //  ySemiAxis = (Dy-dy)/(2*zTopCut)
0061 //    zheight = (Dx+dx)/(2*xSemiAxis)
0062 
0063 // Author: Dionysios Anninos (CERN), 08.09.2005 - Created
0064 //         Lukas Lindroos, Tatiana Nikitina (CERN), 20.08.2007 - Revised
0065 //         Evgueni Tcherniaev (CERN), 20.07.2017 - New revision
0066 // --------------------------------------------------------------------
0067 #ifndef G4ELLIPTICALCONE_HH
0068 #define G4ELLIPTICALCONE_HH
0069 
0070 #include "G4GeomTypes.hh"
0071 
0072 #if defined(G4GEOM_USE_USOLIDS)
0073 #define G4GEOM_USE_UELLIPTICALCONE 1
0074 #endif
0075 
0076 #if (defined(G4GEOM_USE_UELLIPTICALCONE) && defined(G4GEOM_USE_SYS_USOLIDS))
0077   #define G4UEllipticalCone G4EllipticalCone
0078   #include "G4UEllipticalCone.hh"
0079 #else
0080 
0081 #include <CLHEP/Units/PhysicalConstants.h>
0082 
0083 #include "G4VSolid.hh"
0084 #include "G4Polyhedron.hh"
0085 
0086 /**
0087  * @brief G4EllipticalCone is a full cone with elliptical base which
0088  * can be cut in Z. The height in Z corresponds to where the elliptical
0089  * cone hits the Z-axis if it had no Z cut.
0090  */
0091 
0092 class G4EllipticalCone : public G4VSolid
0093 {
0094   public:
0095 
0096     /**
0097      * Constructs an elliptical cone, with cut in Z.
0098      *  @param[in] name The solid name.
0099      *  @param[in] pxSemiAxis Scalar value, defining the scaling along X-axis.
0100      *  @param[in] pySemiAxis Scalar value, defining the scaling along Y-axis.
0101      *  @param[in] zMax The Z-coordinate at the apex.
0102      *  @param[in] pzTopCut Upper cut plane level.
0103      */
0104     G4EllipticalCone(const G4String& pName,
0105                            G4double  pxSemiAxis,
0106                            G4double  pySemiAxis,
0107                            G4double  zMax,
0108                            G4double  pzTopCut);
0109 
0110     /**
0111      * Destructor.
0112      */
0113     ~G4EllipticalCone() override;
0114 
0115     /**
0116      * Accessors.
0117      */
0118     inline G4double GetSemiAxisMin () const;
0119     inline G4double GetSemiAxisMax () const;
0120     inline G4double GetSemiAxisX () const;
0121     inline G4double GetSemiAxisY () const;
0122     inline G4double GetZMax() const;
0123     inline G4double GetZTopCut() const;
0124 
0125     /**
0126      * Modifiers.
0127      */
0128     void SetSemiAxis (G4double x, G4double y, G4double z);
0129     void SetZCut (G4double newzTopCut);
0130 
0131     /**
0132      * Returning an estimation of the solid volume (capacity) and
0133      * surface area, in internal units.
0134      */
0135     G4double GetCubicVolume() override;
0136     G4double GetSurfaceArea() override;
0137 
0138     /**
0139      * Computes the bounding limits of the solid.
0140      *  @param[out] pMin The minimum bounding limit point.
0141      *  @param[out] pMax The maximum bounding limit point.
0142      */
0143     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0144 
0145     /**
0146      * Calculates the minimum and maximum extent of the solid, when under the
0147      * specified transform, and within the specified limits.
0148      *  @param[in] pAxis The axis along which compute the extent.
0149      *  @param[in] pVoxelLimit The limiting space dictated by voxels.
0150      *  @param[in] pTransform The internal transformation applied to the solid.
0151      *  @param[out] pMin The minimum extent value.
0152      *  @param[out] pMax The maximum extent value.
0153      *  @returns True if the solid is intersected by the extent region.
0154      */
0155     G4bool CalculateExtent(const EAxis pAxis,
0156                            const G4VoxelLimits& pVoxelLimit,
0157                            const G4AffineTransform& pTransform,
0158                                  G4double& pMin, G4double& pMax) const override;
0159 
0160     /**
0161      * Concrete implementations of the expected query interfaces for
0162      * solids, as defined in the base class G4VSolid.
0163      */
0164     EInside Inside(const G4ThreeVector& p) const override;
0165     G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
0166     G4double DistanceToIn(const G4ThreeVector& p,
0167                           const G4ThreeVector& v) const override;
0168     G4double DistanceToIn(const G4ThreeVector& p) const override;
0169     G4double DistanceToOut(const G4ThreeVector& p,
0170                            const G4ThreeVector& v,
0171                            const G4bool calcNorm = false,
0172                                  G4bool* validNorm = nullptr,
0173                                  G4ThreeVector* n = nullptr) const override;
0174     G4double DistanceToOut(const G4ThreeVector& p) const override;
0175 
0176     /**
0177      * Returns the type ID, "G4EllipticalCone" of the solid.
0178      */
0179     G4GeometryType GetEntityType() const override;
0180 
0181     /**
0182      * Makes a clone of the object for use in multi-treading.
0183      *  @returns A pointer to the new cloned allocated solid.
0184      */
0185     G4VSolid* Clone() const override;
0186 
0187     /**
0188      * Returns a random point located and uniformly distributed on the
0189      * surface of the solid.
0190      */
0191     G4ThreeVector GetPointOnSurface() const override;
0192 
0193     /**
0194      * Streams the object contents to an output stream.
0195      */
0196     std::ostream& StreamInfo(std::ostream& os) const override;
0197 
0198     /**
0199      * Methods for creating graphical representations (i.e. for visualisation).
0200      */
0201     G4Polyhedron* GetPolyhedron() const override;
0202     void DescribeYourselfTo(G4VGraphicsScene& scene) const override;
0203     G4VisExtent GetExtent() const override;
0204     G4Polyhedron* CreatePolyhedron() const override;
0205 
0206     /**
0207      * Fake default constructor for usage restricted to direct object
0208      * persistency for clients requiring preallocation of memory for
0209      * persistifiable objects.
0210      */
0211     G4EllipticalCone(__void__&);
0212 
0213     /**
0214      * Copy constructor and assignment operator.
0215      */
0216     G4EllipticalCone(const G4EllipticalCone& rhs);
0217     G4EllipticalCone& operator=(const G4EllipticalCone& rhs);
0218 
0219   protected:
0220 
0221     mutable G4bool fRebuildPolyhedron = false;
0222     mutable G4Polyhedron* fpPolyhedron = nullptr;
0223 
0224   private:
0225 
0226     /**
0227      * Algorithm for SurfaceNormal() following the original
0228      * specification for points not on the surface.
0229      */
0230     G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
0231 
0232   private:
0233 
0234     G4double halfCarTol;
0235     G4double fCubicVolume = 0.0;
0236     G4double fSurfaceArea = 0.0;
0237     G4double fMinZBaseArea = 0.0;
0238     G4double fMaxZBaseArea = 0.0;
0239     G4double xSemiAxis, ySemiAxis, zheight, zTopCut;
0240     G4double cosAxisMin, invXX, invYY;
0241 };
0242 
0243 #include "G4EllipticalCone.icc"
0244 
0245 #endif  // defined(G4GEOM_USE_UELLIPTICALCONE) && defined(G4GEOM_USE_SYS_USOLIDS)
0246 
0247 #endif // G4ELLIPTICALCONE_HH