Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-21 09:11:30

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 // G4VNestedParameterisation
0027 //
0028 // Class description:
0029 //
0030 // Base class for parameterisations that use information from the parent
0031 // volume to compute the material of a copy/instance of this volume. 
0032 // This is in addition to using the current replication number.
0033 // 
0034 // Notes:
0035 //  - Such a volume can be nested inside a placement volume or a parameterised  
0036 //    volume.
0037 //  - The user can modify the solid type, size or transformation using only
0038 //    the replication number of this parameterised volume.
0039 //    He/she is NOT allowed to change these attributes using information of
0040 //    parent volumes - otherwise incorrect results will occur.
0041 //  Also note that the usual restrictions apply: 
0042 //   - the mother volume, in which these copies are placed, must always be
0043 //     of the same dimensions
0044 
0045 // Author: John Apostolakis (CERN), 24.02.2005 - First created version
0046 // --------------------------------------------------------------------
0047 #ifndef G4VNESTEDPARAMETERISATION_HH
0048 #define G4VNESTEDPARAMETERISATION_HH
0049 
0050 #include "G4Types.hh"
0051 #include "G4VPVParameterisation.hh" 
0052 #include "G4VVolumeMaterialScanner.hh"
0053 #include "G4VTouchable.hh"
0054 
0055 class G4VPhysicalVolume;
0056 class G4VSolid;
0057 class G4Material;
0058 
0059 // CSG Entities which may be parameterised/replicated
0060 //
0061 class G4Box;
0062 class G4Tubs;
0063 class G4Trd;
0064 class G4Trap;
0065 class G4Cons;
0066 class G4Sphere;
0067 class G4Orb;
0068 class G4Ellipsoid;
0069 class G4Torus;
0070 class G4Para;
0071 class G4Polycone;
0072 class G4Polyhedra;
0073 class G4Hype;
0074 
0075 /**
0076  * @brief G4VNestedParameterisation is a base class for parameterisations that
0077  * use information from the parent volume to compute the material of a
0078  * copy/instance of this volume. This is in addition to using the current
0079  * replication number. Such a volume can be nested inside a placement volume
0080  * or a parameterised volume. The user can modify the solid type, size or
0081  * transformation using only the replication number of this parameterised
0082  * volume; it is NOT allowed to change these attributes using information of
0083  * the parent volumes, otherwise incorrect results will occur.
0084  */
0085 
0086 class G4VNestedParameterisation : public G4VPVParameterisation, 
0087                                   public G4VVolumeMaterialScanner
0088 {
0089   public:
0090 
0091     /**
0092      * Default Constructor & Destructor.
0093      */
0094     G4VNestedParameterisation() = default; 
0095     ~G4VNestedParameterisation() override = default; 
0096 
0097     // Methods required in derived classes
0098     // -----------------------------------
0099 
0100     /**
0101      * Computes the material for the 'currentVol' and replica number 'repNo'.
0102      * It is a required method, as it is the reason for this class.
0103      * Must cope with parentTouch=nullptr for navigator's SetupHierarchy().
0104      *  @param[in] currentVol Pointer to the current physical volume.
0105      *  @param[in] repNo The copy number index.
0106      *  @param[in] parentTouch Pointer to the touchable of the parent volume.
0107      *  @returns A pointer to the associated material.
0108      */
0109     virtual G4Material* ComputeMaterial(G4VPhysicalVolume* currentVol,
0110                                  const G4int repNo, 
0111                                  const G4VTouchable* parentTouch = nullptr)=0;
0112 
0113     /**
0114      * Accessors needed to define materials for instances of a Nested
0115      * Parameterisation. Eeach call should return the materials of all
0116      * instances with the same mother/ancestor volume.
0117      */
0118     G4int GetNumberOfMaterials() const override =0;
0119     G4Material* GetMaterial(G4int idx) const override =0;
0120 
0121     /**
0122      * Computes the transformation for the 'currentPV' and replica number 'no'.
0123      * It is a required method, as it is the reason for this class.
0124      * Must cope with parentTouch=nullptr for navigator's SetupHierarchy().
0125      *  @param[in] currentPV Pointer to the current physical volume.
0126      *  @param[in] no The copy number index.
0127      */
0128      void ComputeTransformation(const G4int no,
0129                                 G4VPhysicalVolume* currentPV) const override=0;
0130 
0131     // Methods optional in derived classes
0132     // -----------------------------------
0133 
0134     /**
0135      * Computes the solid for the 'thisVol' volume and replica number 'no'.
0136      * To be optionally defined in derived classes, for parameterisation of
0137      * the solid type.
0138      *  @param[in] no The copy number index.
0139      *  @param[in] thisVol Pointer to the current physical volume.
0140      */
0141     G4VSolid* ComputeSolid(const G4int no, G4VPhysicalVolume* thisVol) override;
0142 
0143     /**
0144      * Method implemented in this class in terms of the above ComputeMaterial().
0145      */
0146     G4Material* ComputeMaterial(const G4int repNo, 
0147                            G4VPhysicalVolume* currentVol,
0148                            const G4VTouchable* parentTouch = nullptr) override;
0149 
0150     /**
0151      * Methods to identify nested parameterisations. Required in order
0152      * to enable material scan for nested parameterisations.
0153      */
0154     G4bool IsNested() const override;
0155     G4VVolumeMaterialScanner* GetMaterialScanner() override; 
0156 
0157   // Dispatch methods for the specific solids where parameterisation is allowed
0158   // --------------------------------------------------------------------------
0159 
0160     void ComputeDimensions(G4Box &,
0161                            const G4int,
0162                            const G4VPhysicalVolume *) const override {}
0163 
0164     void ComputeDimensions(G4Tubs &,
0165                            const G4int,
0166                            const G4VPhysicalVolume *) const override {}
0167 
0168     void ComputeDimensions(G4Trd &,
0169                            const G4int,
0170                            const G4VPhysicalVolume *) const override {}
0171 
0172     void ComputeDimensions(G4Trap &,
0173                            const G4int,
0174                            const G4VPhysicalVolume *) const override {}
0175 
0176     void ComputeDimensions(G4Cons &,
0177                            const G4int,
0178                            const G4VPhysicalVolume *) const override {}
0179 
0180     void ComputeDimensions(G4Sphere &,
0181                            const G4int,
0182                            const G4VPhysicalVolume *) const override {}
0183 
0184     void ComputeDimensions(G4Orb &,
0185                            const G4int,
0186                            const G4VPhysicalVolume *) const override {}
0187 
0188     void ComputeDimensions(G4Ellipsoid &,
0189                            const G4int,
0190                            const G4VPhysicalVolume *) const override {}
0191 
0192     void ComputeDimensions(G4Torus &,
0193                            const G4int,
0194                            const G4VPhysicalVolume *) const override {}
0195 
0196     void ComputeDimensions(G4Para &,
0197                            const G4int,
0198                            const G4VPhysicalVolume *) const override {}
0199 
0200     void ComputeDimensions(G4Polycone &,
0201                            const G4int,
0202                            const G4VPhysicalVolume *) const override {}
0203 
0204     void ComputeDimensions(G4Polyhedra &,
0205                            const G4int,
0206                            const G4VPhysicalVolume *) const override {}
0207 
0208     void ComputeDimensions(G4Hype &,
0209                            const G4int,
0210                            const G4VPhysicalVolume *) const override {}
0211 };
0212 
0213 #endif