Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 09:13:18

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 // G4GenericPolycone
0027 //
0028 // Class description:
0029 //
0030 // Implementing a GenericPolycone constructed by points with (r,z)
0031 // coordinates and allowing Z 'go back'.
0032 //
0033 //   G4GenericPolycone( const G4String& name,
0034 //                      G4double phiStart,   // initial phi starting angle
0035 //                      G4double phiTotal,   // total phi angle
0036 //                      G4int    numRZ,      // number corners in r,z space
0037 //                      const G4double r[],  // r coordinate of these corners
0038 //                      const G4double z[])  // z coordinate of these corners
0039 
0040 // Authors: T.Nikitina, G.Cosmo (CERN), 29.10.2013 - Created
0041 // --------------------------------------------------------------------
0042 #ifndef G4GENERICPOLYCONE_HH
0043 #define G4GENERICPOLYCONE_HH
0044 
0045 #include "G4GeomTypes.hh"
0046 
0047 #if defined(G4GEOM_USE_USOLIDS)
0048 #define G4GEOM_USE_UGENERICPOLYCONE 1
0049 #endif
0050 
0051 #if defined(G4GEOM_USE_UGENERICPOLYCONE)
0052   #define G4UGenericPolycone G4GenericPolycone
0053   #include "G4UGenericPolycone.hh"
0054 #else
0055 
0056 #include "G4VCSGfaceted.hh"
0057 #include "G4PolyconeSide.hh"
0058 
0059 class G4EnclosingCylinder;
0060 class G4ReduciblePolygon;
0061 class G4VCSGface;
0062 
0063 /**
0064  * @brief G4GenericPolycone is a Polycone shape where the composing Z planes
0065  * positions, in their order of definition, may not be monotically increasing,
0066  * i.e. may also decrease.
0067  */
0068 
0069 class G4GenericPolycone : public G4VCSGfaceted
0070 {
0071   public:
0072 
0073     /**
0074      * Constructs a generic polycone shape, given its parameters.
0075      *  @param[in] name The solid name.
0076      *  @param[in] phiStart The initial Phi starting angle.
0077      *  @param[in] phiTotal The total Phi angle.
0078      *  @param[in] numRZ Number of corners in r,Z space.
0079      *  @param[in] r Vector of r coordinate of corners.
0080      *  @param[in] z Vector of Z coordinate of corners.
0081      */
0082     G4GenericPolycone( const G4String& name,
0083                              G4double phiStart,
0084                              G4double phiTotal,
0085                              G4int    numRZ,
0086                        const G4double r[],
0087                        const G4double z[] );
0088 
0089     /**
0090      * Destructor.
0091      */
0092     ~G4GenericPolycone() override;
0093 
0094     /**
0095      * Accessors.
0096      */
0097     inline G4double GetStartPhi()    const;
0098     inline G4double GetEndPhi()      const;
0099     inline G4double GetSinStartPhi() const;
0100     inline G4double GetCosStartPhi() const;
0101     inline G4double GetSinEndPhi()   const;
0102     inline G4double GetCosEndPhi()   const;
0103     inline G4bool IsOpen()           const;
0104     inline G4int  GetNumRZCorner()   const;
0105     inline G4PolyconeSideRZ GetCorner(G4int index) const;
0106 
0107     /**
0108      * Concrete implementations of the expected query interfaces for
0109      * solids, as defined in the base class G4VSolid.
0110      */
0111     EInside Inside( const G4ThreeVector &p ) const override;
0112     G4double DistanceToIn( const G4ThreeVector &p,
0113                            const G4ThreeVector &v ) const override;
0114     G4double DistanceToIn( const G4ThreeVector &p ) const override;
0115     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0116     G4bool CalculateExtent(const EAxis pAxis,
0117                            const G4VoxelLimits& pVoxelLimit,
0118                            const G4AffineTransform& pTransform,
0119                                  G4double& pmin, G4double& pmax) const override;
0120 
0121     /**
0122      * Returning an estimation of the solid volume (capacity) and
0123      * surface area, in internal units.
0124      */
0125     G4double GetCubicVolume() override;
0126     G4double GetSurfaceArea() override;
0127 
0128     /**
0129      * Returns a random point located and uniformly distributed on the
0130      * surface of the solid.
0131      */
0132     G4ThreeVector GetPointOnSurface() const override;
0133 
0134     /**
0135      * Returns the type ID, "G4GenericPolycone" of the solid.
0136      */
0137     G4GeometryType GetEntityType() const override;
0138 
0139     /**
0140      * Makes a clone of the object for use in multi-treading.
0141      *  @returns A pointer to the new cloned allocated solid.
0142      */
0143     G4VSolid* Clone() const override;
0144 
0145     /**
0146      * Streams the object contents to an output stream.
0147      */
0148     std::ostream& StreamInfo(std::ostream& os) const override;
0149 
0150     /**
0151      * Returns a pointer to a polyhedron for use in visualisation.
0152      */
0153     G4Polyhedron* CreatePolyhedron() const override;
0154 
0155     /**
0156      * Does nothing. Reset of parameters (for use in divisions) is not
0157      * allowed for a generic polycone. Issues a warning and just returns true.
0158      */
0159     G4bool Reset();
0160 
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     G4GenericPolycone(__void__&);
0167 
0168     /**
0169      * Copy constructor and assignment operator.
0170      */
0171     G4GenericPolycone( const G4GenericPolycone& source );
0172     G4GenericPolycone& operator=( const G4GenericPolycone& source );
0173 
0174   private:
0175 
0176     /**
0177      * Generic initializer, called by constructor.
0178      */
0179     void Create( G4double phiStart,        // initial phi starting angle
0180                  G4double phiTotal,        // total phi angle
0181                  G4ReduciblePolygon* rz ); // r/z coordinate of these corners
0182 
0183     /**
0184      * Utility for copying contents, used in copy constructor and assignment
0185      * operator.
0186      */
0187     void CopyStuff( const G4GenericPolycone& source );
0188 
0189      /**
0190       * Auxiliary method for sampling random points on surface.
0191       * Sets the vector of surface elements.
0192       */
0193     void SetSurfaceElements() const;
0194 
0195   private:
0196 
0197     /** Original parameters. */
0198     G4double startPhi;            // Starting phi value (0 < phiStart < 2pi)
0199     G4double endPhi;              // end phi value (0 < endPhi-phiStart < 2pi)
0200     G4bool   phiIsOpen = false;   // true if there is a phi segment
0201     G4int    numCorner;           // number RZ points
0202     G4PolyconeSideRZ* corners = nullptr;  // corner r,z points
0203 
0204     G4EnclosingCylinder* enclosingCylinder = nullptr; // Our quick test
0205 
0206     struct surface_element { G4double area = 0.; G4int i0 = 0, i1 = 0, i2 = 0; };
0207     mutable std::vector<surface_element>* fElements = nullptr;
0208 };
0209 
0210 #include "G4GenericPolycone.icc"
0211 
0212 #endif
0213 
0214 #endif