Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:14

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 // G4Trap
0027 //
0028 // Class description:
0029 //
0030 //   A G4Trap is a general trapezoid: The faces perpendicular to the
0031 //   z planes are trapezia, and their centres are not necessarily on
0032 //   a line parallel to the z axis.
0033 //
0034 //   Note that of the 11 parameters described below, only 9 are really
0035 //   independent - a check for planarity is made in the calculation of the
0036 //   equation for each plane. If the planes are not parallel, a call to
0037 //   G4Exception is made.
0038 //
0039 //      pDz     Half-length along the z-axis
0040 //      pTheta  Polar angle of the line joining the centres of the faces
0041 //              at -/+pDz
0042 //      pPhi    Azimuthal angle of the line joing the centre of the face at
0043 //              -pDz to the centre of the face at +pDz
0044 //      pDy1    Half-length along y of the face at -pDz
0045 //      pDx1    Half-length along x of the side at y=-pDy1 of the face at -pDz
0046 //      pDx2    Half-length along x of the side at y=+pDy1 of the face at -pDz
0047 //      pAlp1   Angle with respect to the y axis from the centre of the side
0048 //              at y=-pDy1 to the centre at y=+pDy1 of the face at -pDz
0049 //
0050 //      pDy2    Half-length along y of the face at +pDz
0051 //      pDx3    Half-length along x of the side at y=-pDy2 of the face at +pDz
0052 //      pDx4    Half-length along x of the side at y=+pDy2 of the face at +pDz
0053 //      pAlp2   Angle with respect to the y axis from the centre of the side
0054 //              at y=-pDy2 to the centre at y=+pDy2 of the face at +pDz
0055 //
0056 //
0057 //   Member Data:
0058 //
0059 //      fDz     Half-length along the z axis
0060 //      fTthetaCphi = std::tan(pTheta)*std::cos(pPhi)
0061 //      fTthetaSphi = std::tan(pTheta)*std::sin(pPhi)
0062 //      These combinations are suitable for creation of the trapezoid corners
0063 //
0064 //      fDy1    Half-length along y of the face at -fDz
0065 //      fDx1    Half-length along x of the side at y=-fDy1 of the face at -fDz
0066 //      fDx2    Half-length along x of the side at y=+fDy1 of the face at -fDz
0067 //      fTalpha1   Tan of Angle with respect to the y axis from the centre of
0068 //                 the side at y=-fDy1 to the centre at y=+fDy1 of the face
0069 //                 at -fDz
0070 //
0071 //      fDy2    Half-length along y of the face at +fDz
0072 //      fDx3    Half-length along x of the side at y=-fDy2 of the face at +fDz
0073 //      fDx4    Half-length along x of the side at y=+fDy2 of the face at +fDz
0074 //      fTalpha2   Tan of Angle with respect to the y axis from the centre of
0075 //                 the side at y=-fDy2 to the centre at y=+fDy2 of the face
0076 //                 at +fDz
0077 //
0078 //      TrapSidePlane fPlanes[4]   Plane equations of the faces not at +/-fDz
0079 //                                 NOTE: order is important !!!
0080 
0081 // 23.3.94 P.Kent: Old C++ code converted to tolerant geometry
0082 // 9.9.96  V.Grichine: Final modifications before to commit
0083 // 8.12.97 J.Allison: Added "nominal" contructor and method SetAllParameters
0084 // --------------------------------------------------------------------
0085 #ifndef G4TRAP_HH
0086 #define G4TRAP_HH
0087 
0088 #include "G4Types.hh"
0089 
0090 struct TrapSidePlane
0091 {
0092     G4double a,b,c,d;    // Normal unit vector (a,b,c)  and offset (d)
0093         // => Ax+By+Cz+D=0
0094 };
0095 
0096 #include "G4GeomTypes.hh"
0097 
0098 #if defined(G4GEOM_USE_USOLIDS)
0099 #define G4GEOM_USE_UTRAP 1
0100 #endif
0101 
0102 #if defined(G4GEOM_USE_UTRAP)
0103   #define G4UTrap G4Trap
0104   #include "G4UTrap.hh"
0105 #else
0106 
0107 #include "G4CSGSolid.hh"
0108 
0109 class G4Trap : public G4CSGSolid
0110 {
0111 
0112   public:
0113 
0114     G4Trap( const G4String& pName,
0115                   G4double pDz,
0116                   G4double pTheta, G4double pPhi,
0117                   G4double pDy1, G4double pDx1, G4double pDx2,
0118                   G4double pAlp1,
0119                   G4double pDy2, G4double pDx3, G4double pDx4,
0120                   G4double pAlp2 );
0121       //
0122       // The most general constructor for G4Trap which prepares plane
0123       // equations and corner coordinates from parameters
0124 
0125     G4Trap( const G4String& pName,
0126             const G4ThreeVector pt[8] ) ;
0127       //
0128       // Prepares plane equations and parameters from corner coordinates
0129 
0130     G4Trap( const G4String& pName,
0131                   G4double pZ,
0132                   G4double pY,
0133                   G4double pX, G4double pLTX );
0134       //
0135       // Constructor for Right Angular Wedge from STEP (assumes pLTX<=pX)
0136 
0137     G4Trap( const G4String& pName,
0138                   G4double pDx1,  G4double pDx2,
0139                   G4double pDy1,  G4double pDy2,
0140                   G4double pDz );
0141       //
0142       // Constructor for G4Trd
0143 
0144      G4Trap(const G4String& pName,
0145                   G4double pDx, G4double pDy, G4double pDz,
0146                   G4double pAlpha, G4double pTheta, G4double pPhi );
0147       //
0148       // Constructor for G4Para
0149 
0150      G4Trap( const G4String& pName );
0151        //
0152        // Constructor for "nominal" G4Trap whose parameters are to be set
0153        // by a G4VPVParamaterisation later
0154 
0155      ~G4Trap() override ;
0156        //
0157        // Destructor
0158 
0159   // Accessors
0160 
0161     inline G4double GetZHalfLength()  const;
0162     inline G4double GetYHalfLength1() const;
0163     inline G4double GetXHalfLength1() const;
0164     inline G4double GetXHalfLength2() const;
0165     inline G4double GetTanAlpha1()    const;
0166     inline G4double GetYHalfLength2() const;
0167     inline G4double GetXHalfLength3() const;
0168     inline G4double GetXHalfLength4() const;
0169     inline G4double GetTanAlpha2()    const;
0170       //
0171       // Returns coordinates of unit vector along straight
0172       // line joining centers of -/+fDz planes
0173 
0174     inline TrapSidePlane GetSidePlane( G4int n ) const;
0175     inline G4ThreeVector GetSymAxis() const;
0176 
0177     inline G4double GetPhi() const;
0178     inline G4double GetTheta() const;
0179     inline G4double GetAlpha1() const;
0180     inline G4double GetAlpha2() const;   
0181       // Obtain (re)computed values of original parameters
0182    
0183   // Modifiers
0184 
0185     void SetAllParameters ( G4double pDz,
0186                             G4double pTheta,
0187                             G4double pPhi,
0188                             G4double pDy1,
0189                             G4double pDx1,
0190                             G4double pDx2,
0191                             G4double pAlp1,
0192                             G4double pDy2,
0193                             G4double pDx3,
0194                             G4double pDx4,
0195                             G4double pAlp2 );
0196 
0197   // Methods for solid
0198 
0199     G4double GetCubicVolume() override;
0200     G4double GetSurfaceArea() override;
0201 
0202     void ComputeDimensions(       G4VPVParameterisation* p,
0203                             const G4int n,
0204                             const G4VPhysicalVolume* pRep ) override;
0205 
0206     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0207 
0208     G4bool CalculateExtent(const EAxis pAxis,
0209                            const G4VoxelLimits& pVoxelLimit,
0210                            const G4AffineTransform& pTransform,
0211                                  G4double& pMin, G4double& pMax) const override;
0212 
0213     EInside Inside( const G4ThreeVector& p ) const override;
0214 
0215     G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override;
0216 
0217     G4double DistanceToIn(const G4ThreeVector& p,
0218                           const G4ThreeVector& v) const override;
0219 
0220     G4double DistanceToIn( const G4ThreeVector& p ) const override;
0221 
0222     G4double DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
0223                            const G4bool calcNorm = false,
0224                                  G4bool* validNorm = nullptr,
0225                                  G4ThreeVector* n = nullptr) const override;
0226 
0227     G4double DistanceToOut( const G4ThreeVector& p ) const override;
0228 
0229     G4GeometryType GetEntityType() const override;
0230 
0231     G4ThreeVector GetPointOnSurface() const override;
0232 
0233     G4VSolid* Clone() const override;
0234 
0235     std::ostream& StreamInfo( std::ostream& os ) const override;
0236 
0237   // Visualisation functions
0238 
0239     void          DescribeYourselfTo (G4VGraphicsScene& scene) const override;
0240     G4Polyhedron* CreatePolyhedron   () const override;
0241 
0242     G4Trap(__void__&);
0243       // Fake default constructor for usage restricted to direct object
0244       // persistency for clients requiring preallocation of memory for
0245       // persistifiable objects.
0246 
0247     G4Trap(const G4Trap& rhs);
0248     G4Trap& operator=(const G4Trap& rhs);
0249       // Copy constructor and assignment operator.
0250 
0251   protected:
0252 
0253     void MakePlanes();
0254     void MakePlanes( const G4ThreeVector pt[8] );
0255     G4bool MakePlane( const G4ThreeVector& p1,
0256                       const G4ThreeVector& p2,
0257                       const G4ThreeVector& p3,
0258                       const G4ThreeVector& p4,
0259                             TrapSidePlane& plane ) ;
0260     void SetCachedValues();
0261 
0262   private:
0263 
0264     void CheckParameters();
0265       // Check parameters
0266 
0267     void GetVertices(G4ThreeVector pt[8]) const;
0268       // Compute coordinates of the trap vertices from planes
0269 
0270     G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const;
0271       // Algorithm for SurfaceNormal() following the original
0272       // specification for points not on the surface
0273 
0274   private:
0275 
0276     G4double halfCarTolerance;
0277     G4double fDz,fTthetaCphi,fTthetaSphi;
0278     G4double fDy1,fDx1,fDx2,fTalpha1;
0279     G4double fDy2,fDx3,fDx4,fTalpha2;
0280     TrapSidePlane fPlanes[4];
0281     G4double fAreas[6];
0282     G4int fTrapType;
0283 };
0284 
0285 #include "G4Trap.icc"
0286 
0287 #endif
0288 
0289 #endif