Back to home page

EIC code displayed by LXR

 
 

    


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

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 // G4Cons
0027 //
0028 // Class description:
0029 //
0030 //   A G4Cons is, in the general case, a Phi segment of a cone, with
0031 //   half-length fDz, inner and outer radii specified at -fDz and +fDz.
0032 //   The Phi segment is described by a starting fSPhi angle, and the
0033 //   +fDPhi delta angle for the shape.
0034 //   If the delta angle is >=2*pi, the shape is treated as continuous
0035 //   in Phi
0036 //
0037 //   Member Data:
0038 //
0039 //  fRmin1  inside radius at  -fDz
0040 //  fRmin2  inside radius at  +fDz
0041 //  fRmax1  outside radius at -fDz
0042 //  fRmax2  outside radius at +fDz
0043 //  fDz  half length in z
0044 //
0045 //  fSPhi  starting angle of the segment in radians
0046 //  fDPhi  delta angle of the segment in radians
0047 //
0048 //  fPhiFullCone   Boolean variable used for indicate the Phi Section
0049 //
0050 //   Note:
0051 //      Internally fSPhi & fDPhi are adjusted so that fDPhi<=2PI,
0052 //      and fDPhi+fSPhi<=2PI. This enables simpler comparisons to be
0053 //      made with (say) Phi of a point.
0054 
0055 // 19.3.94 P.Kent: Old C++ code converted to tolerant geometry
0056 // 13.9.96 V.Grichine: Final modifications to commit
0057 // --------------------------------------------------------------------
0058 #ifndef G4CONS_HH
0059 #define G4CONS_HH
0060 
0061 #include "G4GeomTypes.hh"
0062 
0063 #if defined(G4GEOM_USE_USOLIDS)
0064 #define G4GEOM_USE_UCONS 1
0065 #endif
0066 
0067 #if defined(G4GEOM_USE_UCONS)
0068   #define G4UCons G4Cons
0069   #include "G4UCons.hh"
0070 #else
0071 
0072 #include <CLHEP/Units/PhysicalConstants.h>
0073 
0074 #include "G4CSGSolid.hh"
0075 #include "G4Polyhedron.hh"
0076 
0077 class G4Cons : public G4CSGSolid
0078 {
0079   public:
0080 
0081     G4Cons(const G4String& pName,
0082                  G4double pRmin1, G4double pRmax1,
0083                  G4double pRmin2, G4double pRmax2,
0084                  G4double pDz,
0085                  G4double pSPhi, G4double pDPhi);
0086       //
0087       // Constructs a cone with the given name and dimensions
0088 
0089    ~G4Cons() override ;
0090       //
0091       // Destructor
0092 
0093     // Accessors
0094 
0095     inline G4double GetInnerRadiusMinusZ() const;
0096     inline G4double GetOuterRadiusMinusZ() const;
0097     inline G4double GetInnerRadiusPlusZ()  const;
0098     inline G4double GetOuterRadiusPlusZ()  const;
0099     inline G4double GetZHalfLength()       const;
0100     inline G4double GetStartPhiAngle()     const;
0101     inline G4double GetDeltaPhiAngle()     const;
0102     inline G4double GetSinStartPhi()       const;
0103     inline G4double GetCosStartPhi()       const;
0104     inline G4double GetSinEndPhi()         const;
0105     inline G4double GetCosEndPhi()         const;
0106 
0107     // Modifiers
0108 
0109     inline void SetInnerRadiusMinusZ (G4double Rmin1 );
0110     inline void SetOuterRadiusMinusZ (G4double Rmax1 );
0111     inline void SetInnerRadiusPlusZ  (G4double Rmin2 );
0112     inline void SetOuterRadiusPlusZ  (G4double Rmax2 );
0113     inline void SetZHalfLength       (G4double newDz );
0114     inline void SetStartPhiAngle     (G4double newSPhi, G4bool trig=true);
0115     inline void SetDeltaPhiAngle     (G4double newDPhi);
0116 
0117     // Other methods for solid
0118 
0119     inline G4double GetCubicVolume() override;
0120     inline G4double GetSurfaceArea() override;
0121 
0122     void ComputeDimensions(      G4VPVParameterisation* p,
0123                            const G4int n,
0124                            const G4VPhysicalVolume* pRep) override;
0125 
0126     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0127 
0128     G4bool CalculateExtent(const EAxis pAxis,
0129                            const G4VoxelLimits& pVoxelLimit,
0130                            const G4AffineTransform& pTransform,
0131                                  G4double& pMin, G4double& pMax) const override;
0132 
0133     EInside Inside( const G4ThreeVector& p ) const override;
0134 
0135     G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override;
0136 
0137     G4double DistanceToIn (const G4ThreeVector& p,
0138                            const G4ThreeVector& v) const override;
0139     G4double DistanceToIn (const G4ThreeVector& p) const override;
0140     G4double DistanceToOut(const G4ThreeVector& p,
0141                            const G4ThreeVector& v,
0142                            const G4bool calcNorm = false,
0143                                  G4bool* validNorm = nullptr,
0144                                  G4ThreeVector* n = nullptr) const override;
0145     G4double DistanceToOut(const G4ThreeVector& p) const override;
0146 
0147     G4GeometryType GetEntityType() const override;
0148 
0149     G4ThreeVector GetPointOnSurface() const override;
0150 
0151     G4VSolid* Clone() const override;
0152 
0153     std::ostream& StreamInfo(std::ostream& os) const override;
0154 
0155     // Visualisation functions
0156 
0157     void          DescribeYourselfTo( G4VGraphicsScene& scene ) const override;
0158     G4Polyhedron* CreatePolyhedron() const override;
0159 
0160     G4Cons(__void__&);
0161       //
0162       // Fake default constructor for usage restricted to direct object
0163       // persistency for clients requiring preallocation of memory for
0164       // persistifiable objects.
0165 
0166     G4Cons(const G4Cons& rhs);
0167     G4Cons& operator=(const G4Cons& rhs);
0168       // Copy constructor and assignment operator.
0169 
0170   private:
0171 
0172     inline void Initialize();
0173       //
0174       // Reset relevant values to zero
0175 
0176     inline void CheckSPhiAngle(G4double sPhi);
0177     inline void CheckDPhiAngle(G4double dPhi);
0178     inline void CheckPhiAngles(G4double sPhi, G4double dPhi);
0179       //
0180       // Reset relevant flags and angle values
0181 
0182     inline void InitializeTrigonometry();
0183       //
0184       // Recompute relevant trigonometric values and cache them
0185 
0186     G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
0187       //
0188       // Algorithm for SurfaceNormal() following the original
0189       // specification for points not on the surface
0190 
0191   private:
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     G4double fRmin1, fRmin2, fRmax1, fRmax2, fDz, fSPhi, fDPhi;
0206       //
0207       // Radial and angular dimensions
0208 
0209     G4double sinCPhi, cosCPhi, cosHDPhi, cosHDPhiOT, cosHDPhiIT,
0210              sinSPhi, cosSPhi, sinEPhi, cosEPhi;
0211       //
0212       // Cached trigonometric values
0213 
0214     G4bool fPhiFullCone = false;
0215       //
0216       // Flag for identification of section or full cone
0217 
0218     G4double halfCarTolerance, halfRadTolerance, halfAngTolerance;
0219       //
0220       // Cached half tolerance values
0221 };
0222 
0223 #include "G4Cons.icc"
0224 
0225 #endif
0226 
0227 #endif