Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 09:14:20

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 // G4UTrap
0027 //
0028 // Class description:
0029 //
0030 // Wrapper class for G4Trap to make use of VecGeom Trapezoid.
0031 
0032 // Author: G.Cosmo (CERN), 13.09.2013
0033 // --------------------------------------------------------------------
0034 #ifndef G4UTRAP_HH
0035 #define G4UTRAP_HH
0036 
0037 #include "G4UAdapter.hh"
0038 
0039 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
0040 
0041 #include <VecGeom/volumes/UnplacedTrapezoid.h>
0042 
0043 #include "G4Polyhedron.hh"
0044 
0045 /**
0046  * @brief G4UTrap is a wrapper class for G4Trap to make use of VecGeom Trapezoid.
0047  */
0048 
0049 class G4UTrap : public G4UAdapter<vecgeom::UnplacedTrapezoid>
0050 {
0051   using Shape_t = vecgeom::UnplacedTrapezoid;
0052   using Base_t = G4UAdapter<vecgeom::UnplacedTrapezoid>;
0053 
0054   public:
0055 
0056     /**
0057      * The most general constructor for G4Trap which prepares plane
0058      * equations and corner coordinates from parameters.
0059      *  @param[in] pName The name of the solid.
0060      *  @param[in] pDz Half-length along the Z-axis.
0061      *  @param[in] pTheta Polar angle of the line joining the centres
0062      *             of the faces at -/+pDz.
0063      *  @param[in] pPhi Azimuthal angle of the line joining the centre
0064      *             of the face at -pDz to the centre of the face at +pDz.
0065      *  @param[in] pDy1 Half-length along Y of the face at -pDz.
0066      *  @param[in] pDx1 Half-length along X of the side at y=-pDy1
0067      *             of the face at -pDz.
0068      *  @param[in] pDx2 Half-length along X of the side at y=+pDy1
0069      *             of the face at -pDz.
0070      *  @param[in] pAlp1 Angle with respect to the Y axis from the centre of the
0071      *             side at y=-pDy1 to the centre at y=+pDy1 of the face at -pDz.
0072      *  @param[in] pDy2 Half-length along Y of the face at +pDz.
0073      *  @param[in] pDx3 Half-length along X of the side at y=-pDy2
0074      *             of the face at +pDz.
0075      *  @param[in] pDx4 Half-length along X of the side at y=+pDy2
0076      *             of the face at +pDz.
0077      *  @param[in] pAlp2 Angle with respect to the Y axis from the centre of the
0078      *             side at y=-pDy2 to the centre at y=+pDy2 of the face at +pDz.
0079      */
0080     G4UTrap( const G4String& pName,
0081                    G4double pDz,
0082                    G4double pTheta, G4double pPhi,
0083                    G4double pDy1, G4double pDx1, G4double pDx2,
0084                    G4double pAlp1,
0085                    G4double pDy2, G4double pDx3, G4double pDx4,
0086                    G4double pAlp2 );
0087 
0088     /**
0089      * Prepares plane equations and parameters from corner coordinates.
0090      *  @param[in] pName The name of the solid.
0091      *  @param[in] pt Points of the 8 vertices.
0092      */
0093     G4UTrap( const G4String& pName,
0094              const G4ThreeVector pt[8] ) ;
0095 
0096     /**
0097      * Constructor for Right Angular Wedge from STEP (assumes pLTX<=pX).
0098      *  @param[in] pName The name of the solid.
0099      *  @param[in] pZ Length along Z.
0100      *  @param[in] pY Length along Y.
0101      *  @param[in] pX Length along X at the wider side.
0102      *  @param[in] pLTX Length along X at the narrower side (plTX<=pX).
0103      */
0104     G4UTrap( const G4String& pName,
0105                    G4double pZ,
0106                    G4double pY,
0107                    G4double pX, G4double pLTX );
0108 
0109     /**
0110      * Constructor for G4Trd.
0111      *  @param[in] pName The name of the solid.
0112      *  @param[in] pDx1 Half-length along X at the surface positioned at -dz.
0113      *  @param[in] pDx2 Half-length along X at the surface positioned at +dz.
0114      *  @param[in] pDy1 Half-length along Y at the surface positioned at -dz.
0115      *  @param[in] pDy2 Half-length along Y at the surface positioned at +dz.
0116      *  @param[in] pDz Half-length along Z axis.
0117      */
0118     G4UTrap( const G4String& pName,
0119                    G4double pDx1,  G4double pDx2,
0120                    G4double pDy1,  G4double pDy2,
0121                    G4double pDz );
0122 
0123     /**
0124      * Constructor for G4Para.
0125      *  @param[in] pName The name of the solid.
0126      *  @param[in] pDx Half-length in X.
0127      *  @param[in] pDy Half-length in Y.
0128      *  @param[in] pDz Half-length in Z.
0129      *  @param[in] pAlpha Angle formed by the Y axis and the plane joining the
0130      *             centre of the faces parallel to the Z-X plane at -dy and +dy.
0131      *  @param[in] pTheta Polar angle of the line joining the centres of the
0132      *             faces at -dz and +dz in Z.
0133      *  @param[in] pPhi Azimuthal angle of the line joining the centres of
0134      *             the faces at -dz and +dz in Z.
0135      */
0136     G4UTrap(const G4String& pName,
0137                   G4double pDx, G4double pDy, G4double pDz,
0138                   G4double pAlpha, G4double pTheta, G4double pPhi );
0139 
0140     /**
0141      * Constructor for "nominal" G4Trap whose parameters are to be set
0142      * by a G4VPVParamaterisation later on.
0143      *  @param[in] pName The name of the solid.
0144      */
0145     G4UTrap( const G4String& pName );
0146 
0147     /**
0148      * Default destructor.
0149      */
0150     ~G4UTrap() override = default;
0151 
0152     /**
0153      * Dispatch method for parameterisation replication mechanism and
0154      * dimension computation.
0155      */
0156     void ComputeDimensions(G4VPVParameterisation* p,
0157                            const G4int n,
0158                            const G4VPhysicalVolume* pRep) override;
0159 
0160     /**
0161      * Makes a clone of the object for use in multi-treading.
0162      *  @returns A pointer to the new cloned allocated solid.
0163      */
0164     G4VSolid* Clone() const override;
0165 
0166     using Base_t::GetTanAlpha1;
0167     using Base_t::GetTanAlpha2;
0168 
0169     /**
0170      * Accessors. Returning the coordinates of a unit vector along a straight
0171      * line joining centers of -/+fDz planes.
0172      */
0173     G4double GetZHalfLength()  const;
0174     G4double GetYHalfLength1() const;
0175     G4double GetXHalfLength1() const;
0176     G4double GetXHalfLength2() const;
0177     G4double GetTanAlpha1()    const;
0178     G4double GetYHalfLength2() const;
0179     G4double GetXHalfLength3() const;
0180     G4double GetXHalfLength4() const;
0181     G4double GetTanAlpha2()    const;
0182 
0183     /**
0184      * More accessors.
0185      */
0186     TrapSidePlane GetSidePlane(G4int n) const;
0187     G4ThreeVector GetSymAxis() const;
0188 
0189     /**
0190      * Accessors obtaining (re)computed values of the original parameters.
0191      */
0192     G4double GetPhi()    const;
0193     G4double GetTheta()  const;
0194     G4double GetAlpha1() const;
0195     G4double GetAlpha2() const;
0196 
0197     /**
0198      * Sets all parameters, as for constructor. Checks and sets half-widths
0199      * as well as angles. Makes a final check of co-planarity.
0200      */
0201     void SetAllParameters(G4double pDz, G4double pTheta, G4double pPhi,
0202                           G4double pDy1, G4double pDx1, G4double pDx2,
0203                           G4double pAlp1,
0204                           G4double pDy2, G4double pDx3, G4double pDx4,
0205                           G4double pAlp2);
0206 
0207     /**
0208      * Returns the type ID, "G4Trap" of the solid.
0209      */
0210     inline G4GeometryType GetEntityType() const override;
0211 
0212     /**
0213      * Returns true as the solid has only planar faces.
0214      */
0215     inline G4bool IsFaceted() const override;
0216 
0217     /**
0218      * Computes the bounding limits of the solid.
0219      *  @param[out] pMin The minimum bounding limit point.
0220      *  @param[out] pMax The maximum bounding limit point.
0221      */
0222     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0223 
0224     /**
0225      * Calculates the minimum and maximum extent of the solid, when under the
0226      * specified transform, and within the specified limits.
0227      *  @param[in] pAxis The axis along which compute the extent.
0228      *  @param[in] pVoxelLimit The limiting space dictated by voxels.
0229      *  @param[in] pTransform The internal transformation applied to the solid.
0230      *  @param[out] pMin The minimum extent value.
0231      *  @param[out] pMax The maximum extent value.
0232      *  @returns True if the solid is intersected by the extent region.
0233      */
0234     G4bool CalculateExtent(const EAxis pAxis,
0235                            const G4VoxelLimits& pVoxelLimit,
0236                            const G4AffineTransform& pTransform,
0237                            G4double& pMin, G4double& pMax) const override;
0238 
0239     /**
0240      * Returns a generated polyhedron as graphical representations.
0241      */
0242     G4Polyhedron* CreatePolyhedron() const override;
0243 
0244     /**
0245      * Copy constructor and assignment operator.
0246      */
0247     G4UTrap(const G4UTrap& rhs);
0248     G4UTrap& operator=(const G4UTrap& rhs);
0249 
0250   private:
0251 
0252     /**
0253      * Sets parameters using eight vertices.
0254      */
0255     void SetPlanes(const G4ThreeVector pt[8]);
0256 
0257     /**
0258      * Checks dimensions.
0259      */
0260     void CheckParameters() const;
0261 
0262     /**
0263      * Computes coordinates of vertices.
0264      */
0265     void GetVertices(G4ThreeVector pt[8]) const;
0266 
0267     /**
0268      * Checks planarity of lateral planes.
0269      */
0270     void CheckPlanarity(const G4ThreeVector pt[8]) const;
0271 };
0272 
0273 // --------------------------------------------------------------------
0274 // Inline methods
0275 // --------------------------------------------------------------------
0276 
0277 inline G4GeometryType G4UTrap::GetEntityType() const
0278 {
0279   return "G4Trap";
0280 }
0281 
0282 inline G4bool G4UTrap::IsFaceted() const
0283 {
0284   return true;
0285 }
0286 
0287 #endif  // G4GEOM_USE_USOLIDS
0288 
0289 #endif