Back to home page

EIC code displayed by LXR

 
 

    


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

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 // G4Trd
0027 //
0028 // Class description:
0029 //
0030 // A G4Trd is a trapezoid with the x and y dimensions varying along z
0031 // functions:
0032 //
0033 // Member Data:
0034 //
0035 //     fDx1    Half-length along x at the surface positioned at -dz
0036 //     fDx2    Half-length along x at the surface positioned at +dz
0037 //     fDy1    Half-length along y at the surface positioned at -dz
0038 //     fDy2    Half-length along y at the surface positioned at +dz
0039 //     fDz     Half-length along z axis
0040 
0041 // Author: Paul Kent (CERN), 12.01.1995 - Code converted to thick geometry
0042 // --------------------------------------------------------------------
0043 #ifndef G4TRD_HH
0044 #define G4TRD_HH
0045 
0046 #include "G4GeomTypes.hh"
0047 
0048 #if defined(G4GEOM_USE_USOLIDS)
0049 #define G4GEOM_USE_UTRD 1
0050 #endif
0051 
0052 #if defined(G4GEOM_USE_UTRD)
0053   #define G4UTrd G4Trd
0054   #include "G4UTrd.hh"
0055 #else
0056 
0057 #include "G4CSGSolid.hh"
0058 #include "G4Polyhedron.hh"
0059 
0060 /**
0061  * @brief G4Trd is a trapezoid with the X and Y dimensions varying along Z.
0062  */
0063 
0064 class G4Trd : public G4CSGSolid
0065 {
0066   public:
0067 
0068     /**
0069      * Constructs a trapezoid with name, and half lengths.
0070      *  @param[in] pName The name of the solid.
0071      *  @param[in] pdx1 Half-length along X at the surface positioned at -dz.
0072      *  @param[in] pdx2 Half-length along X at the surface positioned at +dz.
0073      *  @param[in] pdy1 Half-length along Y at the surface positioned at -dz.
0074      *  @param[in] pdy2 Half-length along Y at the surface positioned at +dz.
0075      *  @param[in] pdz Half-length along Z axis.
0076      */
0077     G4Trd( const G4String& pName,
0078                  G4double pdx1, G4double pdx2,
0079                  G4double pdy1, G4double pdy2,
0080                  G4double pdz );
0081 
0082     /**
0083      * Default destructor.
0084      */
0085    ~G4Trd() override = default;
0086 
0087     /**
0088      * Accessors.
0089      */
0090     inline G4double GetXHalfLength1() const;
0091     inline G4double GetXHalfLength2() const;
0092     inline G4double GetYHalfLength1() const;
0093     inline G4double GetYHalfLength2() const;
0094     inline G4double GetZHalfLength()  const;
0095 
0096     /**
0097      * Modifiers.
0098      */
0099     inline void SetXHalfLength1(G4double val);
0100     inline void SetXHalfLength2(G4double val);
0101     inline void SetYHalfLength1(G4double val);
0102     inline void SetYHalfLength2(G4double val);
0103     inline void SetZHalfLength(G4double val);
0104 
0105     /**
0106      * Sets all parameters, as for constructor. Checks and sets half-widths.
0107      */
0108     void SetAllParameters ( G4double pdx1, G4double pdx2,
0109                             G4double pdy1, G4double pdy2,
0110                             G4double pdz );
0111 
0112     /**
0113      * Returning an estimation of the solid volume (capacity) and
0114      * surface area, in internal units.
0115      */
0116     G4double GetCubicVolume() override;
0117     G4double GetSurfaceArea() override;
0118 
0119     /**
0120      * Dispatch method for parameterisation replication mechanism and
0121      * dimension computation.
0122      */
0123     void ComputeDimensions( G4VPVParameterisation* p,
0124                             const G4int n,
0125                             const G4VPhysicalVolume* pRep ) override;
0126 
0127     /**
0128      * Computes the bounding limits of the solid.
0129      *  @param[out] pMin The minimum bounding limit point.
0130      *  @param[out] pMax The maximum bounding limit point.
0131      */
0132     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0133 
0134     /**
0135      * Calculates the minimum and maximum extent of the solid, when under the
0136      * specified transform, and within the specified limits.
0137      *  @param[in] pAxis The axis along which compute the extent.
0138      *  @param[in] pVoxelLimit The limiting space dictated by voxels.
0139      *  @param[in] pTransform The internal transformation applied to the solid.
0140      *  @param[out] pMin The minimum extent value.
0141      *  @param[out] pMax The maximum extent value.
0142      *  @returns True if the solid is intersected by the extent region.
0143      */
0144     G4bool CalculateExtent(const EAxis pAxis,
0145                            const G4VoxelLimits& pVoxelLimit,
0146                            const G4AffineTransform& pTransform,
0147                                  G4double& pMin, G4double& pMax) const override;
0148 
0149     /**
0150      * Concrete implementations of the expected query interfaces for
0151      * solids, as defined in the base class G4VSolid.
0152      */
0153     EInside Inside( const G4ThreeVector& p ) const override;
0154     G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override;
0155     G4double DistanceToIn( const G4ThreeVector& p,
0156                            const G4ThreeVector& v ) const override;
0157     G4double DistanceToIn( const G4ThreeVector& p ) const override;
0158     G4double DistanceToOut( const G4ThreeVector& p,
0159                             const G4ThreeVector& v,
0160                             const G4bool calcNorm = false,
0161                                   G4bool* validNorm = nullptr,
0162                                   G4ThreeVector* n = nullptr ) const override;
0163     G4double DistanceToOut( const G4ThreeVector& p ) const override;
0164 
0165     /**
0166      * Returns the type ID, "G4Trd" of the solid.
0167      */
0168     G4GeometryType GetEntityType() const override;
0169 
0170     /**
0171      * Returns a random point located and uniformly distributed on the
0172      * surface of the solid.
0173      */
0174     G4ThreeVector GetPointOnSurface() const override;
0175 
0176     /**
0177      * Returns true as the solid has only planar faces.
0178      */
0179     G4bool IsFaceted() 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      * Streams the object contents to an output stream.
0189      */
0190     std::ostream& StreamInfo( std::ostream& os ) const override;
0191 
0192     /**
0193      * Methods for creating graphical representations (i.e. for visualisation).
0194      */
0195     void DescribeYourselfTo (G4VGraphicsScene& scene) const override;
0196     G4Polyhedron* CreatePolyhedron () const override;
0197 
0198     /**
0199      * Fake default constructor for usage restricted to direct object
0200      * persistency for clients requiring preallocation of memory for
0201      * persistifiable objects.
0202      */
0203     G4Trd(__void__&);
0204 
0205     /**
0206      * Copy constructor and assignment operator.
0207      */
0208     G4Trd(const G4Trd& rhs);
0209     G4Trd& operator=(const G4Trd& rhs);
0210 
0211   private:
0212 
0213     /**
0214      * Checks the input parameters.
0215      */
0216     void CheckParameters();
0217 
0218     /**
0219      * Sets the side planes.
0220      */
0221     void MakePlanes();
0222 
0223     /**
0224      * Algorithm for SurfaceNormal() following the original specification
0225      * for points not on the surface.
0226      */
0227     G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const;
0228 
0229   private:
0230 
0231     G4double halfCarTolerance;
0232     G4double fDx1,fDx2,fDy1,fDy2,fDz,fHx,fHy;
0233     struct { G4double a,b,c,d; } fPlanes[4];
0234 };
0235 
0236 #include "G4Trd.icc"
0237 
0238 #endif
0239 
0240 #endif