Back to home page

EIC code displayed by LXR

 
 

    


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

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 // G4Hype
0027 //
0028 // Class description:
0029 //
0030 //   This class implements a tube with hyperbolic profile.
0031 //
0032 //   It describes an hyperbolic volume with curved sides parallel to
0033 //   the z-axis. The solid has a specified half-length along the z axis,
0034 //   about which it is centered, and a given minimum and maximum radius.
0035 //   A minimum radius of 0 signifies a filled Hype (with hyperbolical
0036 //   inner surface). To have a filled Hype the user must specify
0037 //   inner radius = 0 AND inner stereo angle = 0.
0038 //
0039 //   The inner and outer hyperbolical surfaces can have different
0040 //   stereo angles. A stereo angle of 0 gives a cylindrical surface.
0041 
0042 // Authors:
0043 //      Ernesto Lamanna (Ernesto.Lamanna@roma1.infn.it) &
0044 //      Francesco Safai Tehrani (Francesco.SafaiTehrani@roma1.infn.it)
0045 //      Rome, INFN & University of Rome "La Sapienza",  9 June 1998.
0046 // --------------------------------------------------------------------
0047 #ifndef G4HYPE_HH
0048 #define G4HYPE_HH
0049 
0050 #include "G4GeomTypes.hh"
0051 
0052 #if defined(G4GEOM_USE_USOLIDS)
0053 #define G4GEOM_USE_UHYPE 1
0054 #endif
0055 
0056 #if (defined(G4GEOM_USE_UHYPE) && defined(G4GEOM_USE_SYS_USOLIDS))
0057   #define G4UHype G4Hype
0058   #include "G4UHype.hh"
0059 #else
0060 
0061 #include "G4VSolid.hh"
0062 #include "G4ThreeVector.hh"
0063 #include "G4Polyhedron.hh"
0064 
0065 class G4SolidExtentList;
0066 class G4ClippablePolygon;
0067 
0068 class G4Hype : public G4VSolid
0069 {
0070   public:
0071 
0072     G4Hype(const G4String& pName,
0073                  G4double  newInnerRadius,
0074                  G4double  newOuterRadius,
0075                  G4double  newInnerStereo,
0076                  G4double  newOuterStereo,
0077                  G4double  newHalfLenZ);
0078 
0079     ~G4Hype() override;
0080 
0081     void ComputeDimensions(      G4VPVParameterisation* p,
0082                            const G4int n,
0083                            const G4VPhysicalVolume* pRep) override;
0084 
0085     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0086 
0087     G4bool CalculateExtent(const EAxis pAxis,
0088                            const G4VoxelLimits& pVoxelLimit,
0089                            const G4AffineTransform& pTransform,
0090                                  G4double& pMin, G4double& pMax) const override;
0091 
0092     inline G4double GetInnerRadius () const;
0093     inline G4double GetOuterRadius () const;
0094     inline G4double GetZHalfLength () const;
0095     inline G4double GetInnerStereo () const;
0096     inline G4double GetOuterStereo () const;
0097 
0098     inline void SetInnerRadius (G4double newIRad);
0099     inline void SetOuterRadius (G4double newORad);
0100     inline void SetZHalfLength (G4double newHLZ);
0101     inline void SetInnerStereo (G4double newISte);
0102     inline void SetOuterStereo (G4double newOSte);
0103 
0104     EInside Inside(const G4ThreeVector& p) const override;
0105 
0106     G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
0107 
0108     G4double DistanceToIn(const G4ThreeVector& p,
0109                           const G4ThreeVector& v) const override;
0110     G4double DistanceToIn(const G4ThreeVector& p) const override;
0111     G4double DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
0112                            const G4bool calcNorm = false,
0113                                  G4bool* validNorm = nullptr,
0114                                  G4ThreeVector* n = nullptr) const override;
0115     G4double DistanceToOut(const G4ThreeVector& p) const override;
0116 
0117     G4GeometryType  GetEntityType() const override;
0118 
0119     G4VSolid* Clone() const override;
0120 
0121     std::ostream& StreamInfo(std::ostream& os) const override;
0122 
0123     G4double GetCubicVolume() override;
0124     G4double GetSurfaceArea() override;
0125 
0126     G4ThreeVector GetPointOnSurface() const override;
0127 
0128     void          DescribeYourselfTo (G4VGraphicsScene& scene) const override;
0129     G4VisExtent   GetExtent          () const override;
0130     G4Polyhedron* CreatePolyhedron   () const override;
0131     G4Polyhedron* GetPolyhedron      () const override;
0132 
0133     G4Hype(__void__&);
0134       // Fake default constructor for usage restricted to direct object
0135       // persistency for clients requiring preallocation of memory for
0136       // persistifiable objects.
0137 
0138     G4Hype(const G4Hype& rhs);
0139     G4Hype& operator=(const G4Hype& rhs);
0140       // Copy constructor and assignment operator.
0141 
0142   protected:
0143 
0144     inline G4bool InnerSurfaceExists() const;
0145       // whether we have an inner surface or not
0146 
0147     static G4double ApproxDistOutside( G4double pr, G4double pz,
0148                                        G4double r0, G4double tanPhi );
0149     static G4double ApproxDistInside( G4double pr, G4double pz,
0150                                       G4double r0, G4double tan2Phi );
0151       // approximate isotropic distance to hyperbolic surface
0152 
0153     inline G4double HypeInnerRadius2(G4double zVal) const;
0154     inline G4double HypeOuterRadius2(G4double zVal) const;
0155       // values of hype radius at a given Z
0156 
0157     static G4int IntersectHype( const G4ThreeVector &p, const G4ThreeVector &v,
0158                                 G4double r2, G4double tan2Phi, G4double s[2] );
0159       // intersection with hyperbolic surface
0160 
0161    private:
0162 
0163     G4double asinh(G4double arg);
0164 
0165   protected:
0166 
0167     G4double innerRadius;
0168     G4double outerRadius;
0169     G4double halfLenZ;
0170     G4double innerStereo;
0171     G4double outerStereo;
0172 
0173     // precalculated parameters, squared quantities
0174 
0175     G4double tanInnerStereo;
0176     G4double tanOuterStereo;
0177     G4double tanInnerStereo2; // squared tan of Inner Stereo angle
0178     G4double tanOuterStereo2; // squared tan of Outer Stereo angle
0179     G4double innerRadius2;    // squared Inner Radius
0180     G4double outerRadius2;    // squared Outer Radius
0181     G4double endInnerRadius2; // squared endcap Inner Radius
0182     G4double endOuterRadius2; // squared endcap Outer Radius
0183     G4double endInnerRadius; // endcap Inner Radius
0184     G4double endOuterRadius; // endcap Outer Radius
0185 
0186     // Used by distanceToOut
0187 
0188     enum ESide {outerFace,innerFace,leftCap, rightCap};
0189 
0190   private:
0191 
0192     G4double fCubicVolume = 0.0;
0193     G4double fSurfaceArea = 0.0;
0194 
0195     G4double fHalfTol;
0196 
0197     mutable G4bool fRebuildPolyhedron = false;
0198     mutable G4Polyhedron* fpPolyhedron = nullptr;
0199 };
0200 
0201 #include "G4Hype.icc"
0202 
0203 #endif  // defined(G4GEOM_USE_UHYPE) && defined(G4GEOM_USE_SYS_USOLIDS)
0204 
0205 #endif // G4HYPE_HH