Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/G4PhantomParameterisation.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 // class G4PhantomParameterisation
0027 //
0028 // Class description:
0029 // 
0030 // Describes regular parameterisations: a set of boxes of equal dimension
0031 // in the x, y and z dimensions. The G4PVParameterised volume using this
0032 // class must be placed inside a volume that is completely filled by these
0033 // boxes.
0034 
0035 // History:
0036 // - Created: P.Arce, May 2007
0037 //---------------------------------------------------------------------
0038 #ifndef G4PhantomParameterisation_HH
0039 #define G4PhantomParameterisation_HH
0040 
0041 #include <vector>
0042 
0043 #include "G4Types.hh"
0044 #include "G4VPVParameterisation.hh"
0045 #include "G4AffineTransform.hh"
0046 #include "G4VTouchable.hh" 
0047 
0048 class G4VPhysicalVolume;
0049 class G4VSolid;
0050 class G4Material;
0051 
0052 // Dummy forward declarations ...
0053 
0054 class G4Box;
0055 class G4Tubs;
0056 class G4Trd;
0057 class G4Trap;
0058 class G4Cons;
0059 class G4Orb;
0060 class G4Sphere;
0061 class G4Ellipsoid;
0062 class G4Torus;
0063 class G4Para;
0064 class G4Hype;
0065 class G4Polycone;
0066 class G4Polyhedra;
0067 
0068 class G4PhantomParameterisation : public G4VPVParameterisation
0069 {
0070   public:
0071 
0072     G4PhantomParameterisation();
0073    ~G4PhantomParameterisation() override;
0074 
0075     void ComputeTransformation(const G4int, G4VPhysicalVolume *) const override;
0076   
0077     G4VSolid* ComputeSolid(const G4int, G4VPhysicalVolume *) override;
0078   
0079     G4Material* ComputeMaterial(const G4int repNo, 
0080                                              G4VPhysicalVolume* currentVol,
0081                                        const G4VTouchable* parentTouch=nullptr) override;
0082   // Dummy declarations ...
0083 
0084     void ComputeDimensions (G4Box &, const G4int,
0085                             const G4VPhysicalVolume*) const override {}
0086     void ComputeDimensions (G4Tubs&, const G4int,
0087                             const G4VPhysicalVolume*) const override {}
0088     void ComputeDimensions (G4Trd&, const G4int,
0089                             const G4VPhysicalVolume*) const override {}
0090     void ComputeDimensions (G4Trap&, const G4int,
0091                             const G4VPhysicalVolume*) const override {}
0092     void ComputeDimensions (G4Cons&, const G4int,
0093                             const G4VPhysicalVolume*) const override {}
0094     void ComputeDimensions (G4Orb&, const G4int,
0095                             const G4VPhysicalVolume*) const override {}
0096     void ComputeDimensions (G4Sphere&, const G4int,
0097                             const G4VPhysicalVolume*) const override {}
0098     void ComputeDimensions (G4Ellipsoid&,const G4int,
0099                             const G4VPhysicalVolume*) const override {}
0100     void ComputeDimensions (G4Torus&, const G4int,
0101                             const G4VPhysicalVolume*) const override {}
0102     void ComputeDimensions (G4Para&, const G4int,
0103                             const G4VPhysicalVolume*) const override {}
0104     void ComputeDimensions (G4Hype&, const G4int,
0105                             const G4VPhysicalVolume*) const override {}
0106     void ComputeDimensions (G4Polycone&, const G4int,
0107                             const G4VPhysicalVolume*) const override {}
0108     void ComputeDimensions (G4Polyhedra&, const G4int,
0109                             const G4VPhysicalVolume*) const override {}
0110   
0111     void BuildContainerSolid( G4VPhysicalVolume* pPhysicalVol );
0112     void BuildContainerSolid( G4VSolid* pMotherSolid );
0113       // Save as container solid the parent of the voxels. Check that the
0114       // voxels fill it completely.
0115 
0116     virtual G4int GetReplicaNo( const G4ThreeVector& localPoint,
0117                                 const G4ThreeVector& localDir );
0118       // Get the voxel number corresponding to the point in the container
0119       // frame. Use 'localDir' to avoid precision problems at the surfaces.
0120 
0121     // Set and Get methods
0122 
0123     inline void SetMaterials(std::vector<G4Material*>& mates );
0124 
0125     inline void SetMaterialIndices( std::size_t* matInd );
0126 
0127     void SetVoxelDimensions( G4double halfx, G4double halfy, G4double halfz );
0128     void SetNoVoxels( std::size_t nx, std::size_t ny, std::size_t nz );
0129     
0130     inline G4double GetVoxelHalfX() const;
0131     inline G4double GetVoxelHalfY() const;
0132     inline G4double GetVoxelHalfZ() const;
0133     inline std::size_t GetNoVoxelsX() const;
0134     inline std::size_t GetNoVoxelsY() const;
0135     inline std::size_t GetNoVoxelsZ() const;
0136     inline std::size_t GetNoVoxels() const;
0137 
0138     inline std::vector<G4Material*> GetMaterials() const;
0139     inline std::size_t* GetMaterialIndices() const;
0140     inline G4VSolid* GetContainerSolid() const;
0141 
0142     G4ThreeVector GetTranslation(const G4int copyNo ) const;
0143 
0144     G4bool SkipEqualMaterials() const;
0145     void SetSkipEqualMaterials( G4bool skip );
0146 
0147     std::size_t GetMaterialIndex( std::size_t nx, std::size_t ny, std::size_t nz) const;
0148     std::size_t GetMaterialIndex( std::size_t copyNo) const;
0149 
0150     G4Material* GetMaterial( std::size_t nx, std::size_t ny, std::size_t nz) const;
0151     G4Material* GetMaterial( std::size_t copyNo ) const;
0152 
0153     void CheckVoxelsFillContainer( G4double contX, G4double contY,
0154                                    G4double contZ ) const;
0155       // Check that the voxels fill it completely.
0156 
0157   private:
0158 
0159     void ComputeVoxelIndices(const G4int copyNo, std::size_t& nx,
0160                                    std::size_t& ny, std::size_t& nz ) const;
0161       // Convert the copyNo to voxel numbers in x, y and z.
0162 
0163     void CheckCopyNo( const G4long copyNo ) const;
0164       // Check that the copy number is within limits.
0165 
0166   protected:
0167 
0168     G4double fVoxelHalfX = 0.0, fVoxelHalfY = 0.0, fVoxelHalfZ = 0.0;
0169       // Half dimension of voxels (assume they are boxes).
0170     std::size_t fNoVoxelsX = 0, fNoVoxelsY = 0, fNoVoxelsZ = 0;
0171       // Number of voxel in x, y and z dimensions.
0172     std::size_t fNoVoxelsXY = 0;
0173       // Number of voxels in x times number of voxels in y (for speed-up).
0174     std::size_t fNoVoxels = 0;
0175       // Total number of voxels (for speed-up).
0176 
0177     std::vector<G4Material*> fMaterials;
0178       // List of materials of the voxels.
0179     std::size_t* fMaterialIndices = nullptr;
0180       // Index in fMaterials that correspond to each voxel.
0181 
0182     G4VSolid* fContainerSolid = nullptr;
0183       // Save as container solid the parent of the voxels.
0184       // Check that the voxels fill it completely.
0185 
0186     G4double fContainerWallX=0.0, fContainerWallY=0.0, fContainerWallZ=0.0;
0187       // Save position of container wall for speed-up.
0188 
0189     G4double kCarTolerance;
0190       // Relative surface tolerance.
0191 
0192     G4bool bSkipEqualMaterials = true;
0193       // Flag to skip surface when two voxel have same material or not
0194 };
0195 
0196 #include "G4PhantomParameterisation.icc"
0197 
0198 #endif