Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-04 09:11:34

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 // G4UPara
0027 //
0028 // Class description:
0029 //
0030 // Wrapper class for G4Para to make use of VecGeom Parallelepiped.
0031 
0032 // Author: G.Cosmo (CERN), 13.09.2013
0033 // --------------------------------------------------------------------
0034 #ifndef G4UPARA_HH
0035 #define G4UPARA_HH
0036 
0037 #include "G4UAdapter.hh"
0038 
0039 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
0040 
0041 #include <VecGeom/volumes/UnplacedParallelepiped.h>
0042 
0043 #include "G4Polyhedron.hh"
0044 
0045 /**
0046  * @brief G4UPara is a wrapper class for G4Para to make use of
0047  * VecGeom Parallelepiped.
0048  */
0049 
0050 class G4UPara : public G4UAdapter<vecgeom::UnplacedParallelepiped> 
0051 {
0052   using Shape_t = vecgeom::UnplacedParallelepiped;
0053   using Base_t  = G4UAdapter<vecgeom::UnplacedParallelepiped>;
0054 
0055   public:
0056 
0057     /**
0058      * Constructs a parallelepiped, given a name and its parameters.
0059      *  @param[in] pName The name of the solid.
0060      *  @param[in] pDx Half-length in x.
0061      *  @param[in] pDy Half-length in y.
0062      *  @param[in] pDz Half-length in z.
0063      *  @param[in] pAlpha Angle formed by the Y axis and by the plane joining
0064      *             the centre of the faces parallel to the Z-X plane at -dy
0065      *             and +dy.
0066      *  @param[in] pTheta Polar angle of the line joining the centres of the
0067      *             faces at -dz and +dz in Z.
0068      *  @param[in] pPhi Azimuthal angle of the line joining the centres of
0069      *             the faces at -dz and +dz in Z.
0070      */
0071     G4UPara(const G4String& pName,
0072                   G4double pDx, G4double pDy, G4double pDz,
0073                   G4double pAlpha, G4double pTheta, G4double pPhi);
0074 
0075     /**
0076      * Constructs a parallelepiped, given a name and its 8 vertices.
0077      *  @param[in] pName The name of the solid.
0078      *  @param[in] pt Points of the 8 vertices.
0079      */
0080     G4UPara(const G4String& pName,
0081             const G4ThreeVector pt[8]);
0082 
0083     /**
0084      * Default destructor.
0085      */
0086     ~G4UPara() override = default;
0087 
0088     /**
0089      * Accessors.
0090      */
0091     G4double GetZHalfLength()  const;
0092     G4double GetYHalfLength()  const;
0093     G4double GetXHalfLength()  const;
0094     G4ThreeVector GetSymAxis() const;
0095     G4double GetTanAlpha()     const;
0096 
0097     /**
0098      * Accessors. Obtain (re)computed values of the original parameters.
0099      */
0100     G4double GetAlpha()  const;
0101     G4double GetTheta()  const;    
0102     G4double GetPhi()    const;
0103     // Obtain (re)computed values of original parameters
0104    
0105     /**
0106      * Modifiers.
0107      */
0108     void SetXHalfLength(G4double val);
0109     void SetYHalfLength(G4double val);
0110     void SetZHalfLength(G4double val);
0111     void SetAlpha(G4double alpha);
0112     void SetTanAlpha(G4double val);
0113     void SetThetaAndPhi(double pTheta, double pPhi);
0114 
0115     /**
0116      * Sets all parameters, as for constructor.
0117      */
0118     void SetAllParameters(G4double pDx, G4double pDy, G4double pDz,
0119                           G4double pAlpha, G4double pTheta, G4double pPhi);
0120 
0121     /**
0122      * Dispatch method for parameterisation replication mechanism and
0123      * dimension computation.
0124      */
0125     void ComputeDimensions(G4VPVParameterisation* p,
0126                            const G4int n,
0127                            const G4VPhysicalVolume* pRep) override;
0128 
0129     /**
0130      * Returns the type ID, "G4Para" of the solid.
0131      */
0132     inline G4GeometryType GetEntityType() const override;
0133 
0134     /**
0135      * Returns true as the solid has only planar faces.
0136      */
0137     inline G4bool IsFaceted() const override;
0138 
0139     /**
0140      * Computes the bounding limits of the solid.
0141      *  @param[out] pMin The minimum bounding limit point.
0142      *  @param[out] pMax The maximum bounding limit point.
0143      */
0144     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0145 
0146     /**
0147      * Calculates the minimum and maximum extent of the solid, when under the
0148      * specified transform, and within the specified limits.
0149      *  @param[in] pAxis The axis along which compute the extent.
0150      *  @param[in] pVoxelLimit The limiting space dictated by voxels.
0151      *  @param[in] pTransform The internal transformation applied to the solid.
0152      *  @param[out] pMin The minimum extent value.
0153      *  @param[out] pMax The maximum extent value.
0154      *  @returns True if the solid is intersected by the extent region.
0155      */
0156     G4bool CalculateExtent(const EAxis pAxis,
0157                            const G4VoxelLimits& pVoxelLimit,
0158                            const G4AffineTransform& pTransform,
0159                                  G4double& pMin, G4double& pMax) const override;
0160 
0161     /**
0162      * Makes a clone of the object for use in multi-treading.
0163      *  @returns A pointer to the new cloned allocated solid.
0164      */
0165     G4VSolid* Clone() const override;
0166 
0167     /**
0168      * Returns a generated polyhedron as graphical representations.
0169      */
0170     G4Polyhedron* CreatePolyhedron() const override;
0171 
0172     /**
0173      * Copy constructor and assignment operator.
0174      */
0175     G4UPara(const G4UPara& rhs);
0176     G4UPara& operator=(const G4UPara& rhs);
0177 
0178   private:
0179 
0180     /**
0181      * Checks input parameters.
0182      */
0183     void CheckParameters();
0184 
0185     /**
0186      * Sets the side planes.
0187      */
0188     void MakePlanes();
0189 
0190   private:
0191 
0192     G4double fTalpha,fTthetaCphi,fTthetaSphi;
0193     struct { G4double a,b,c,d; } fPlanes[4];
0194 };
0195 
0196 // --------------------------------------------------------------------
0197 // Inline methods
0198 // --------------------------------------------------------------------
0199 
0200 inline G4GeometryType G4UPara::GetEntityType() const
0201 {
0202   return "G4Para";
0203 }
0204 
0205 inline G4bool G4UPara::IsFaceted() const
0206 {
0207   return true;
0208 }
0209 
0210 #endif  // G4GEOM_USE_USOLIDS
0211 
0212 #endif