Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-26 08:57:07

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 // G4PVDivision
0027 //
0028 // Class description:
0029 //
0030 // Represents many touchable detector elements differing only in their
0031 // positioning. The elements' positions are calculated by means of a simple
0032 // linear formula.
0033 
0034 // Author: Pedro Arce (CIEMAT), 09.05.2001 - Initial version
0035 // ----------------------------------------------------------------------
0036 #ifndef G4PVDIVISION_HH
0037 #define G4PVDIVISION_HH 1
0038 
0039 #include "geomdefs.hh"
0040 #include "G4PVReplica.hh"
0041 #include "G4VDivisionParameterisation.hh"
0042 
0043 class G4LogicalVolume;
0044 class G4VSolid;
0045 
0046 /**
0047  * @brief G4PVDivision represents many touchable detector elements differing
0048  * only in their positioning. The elements' positions are calculated by means
0049  * of a simple linear formula.
0050  * 
0051  * Division may occur along:
0052  *
0053  * o Cartesian axes (kXAxis,kYAxis,kZAxis)
0054  *
0055  *   The divisions, of specified width have coordinates of
0056  *   form (-width*(nReplicas-1)*0.5+n*width,0,0) where n=0.. nReplicas-1
0057  *   for the case of kXAxis, and are unrotated.
0058  *
0059  * o Radial axis (cylindrical polar) (kRho)
0060  *
0061  *   The divisions are cons/tubs sections, centred on the origin
0062  *   and are unrotated.
0063  *   They have radii of width*n+offset to width*(n+1)+offset
0064  *                      where n=0..nReplicas-1
0065  *
0066  * o Phi axis (cylindrical polar) (kPhi)
0067  *   The divisions are `phi sections' or wedges, and of cons/tubs form
0068  *   They have phi of offset+n*width to offset+(n+1)*width where
0069  *   n=0..nReplicas-1
0070  */
0071 
0072 class G4PVDivision : public G4PVReplica
0073 {
0074   public:
0075     
0076     /**
0077      * Constructor with number of divisions and width.
0078      *  @param[in] pName The volume name.
0079      *  @param[in] pLogical Pointer to the logical volume of the division.
0080      *  @param[in] pMother Pointer to the logical volume of the mother.
0081      *  @param[in] pAxis The axis along which do the division.
0082      *  @param[in] nReplicas The number of copies to replicate.
0083      *  @param[in] width The witdh of the divided slice along the axis.
0084      *  @param[in] offset The optional offset distance from mother's border.
0085      */
0086     G4PVDivision(const G4String& pName,
0087                        G4LogicalVolume* pLogical,
0088                        G4LogicalVolume* pMother,
0089                  const EAxis pAxis,
0090                  const G4int nReplicas,
0091                  const G4double width,
0092                  const G4double offset );
0093 
0094     /**
0095      * Constructor with number of divisions.
0096      *  @param[in] pName The volume name.
0097      *  @param[in] pLogical Pointer to the logical volume of the division.
0098      *  @param[in] pMother Pointer to the logical volume of the mother.
0099      *  @param[in] pAxis The axis along which do the division.
0100      *  @param[in] nReplicas The number of copies to replicate.
0101      *  @param[in] offset The optional offset distance from mother's border.
0102      */
0103     G4PVDivision(const G4String& pName,
0104                        G4LogicalVolume* pLogical,
0105                        G4LogicalVolume* pMother,
0106                  const EAxis pAxis,
0107                  const G4int nReplicas,
0108                  const G4double offset );
0109 
0110     /**
0111      * Constructor with width.
0112      *  @param[in] pName The volume name.
0113      *  @param[in] pLogical Pointer to the logical volume of the division.
0114      *  @param[in] pMother Pointer to the logical volume of the mother.
0115      *  @param[in] pAxis The axis along which do the division.
0116      *  @param[in] width The witdh of the divided slice along the axis.
0117      *  @param[in] offset The optional offset distance from mother's border.
0118      */
0119     G4PVDivision(const G4String& pName,
0120                        G4LogicalVolume* pLogical,
0121                        G4LogicalVolume* pMother,
0122                  const EAxis pAxis,
0123                  const G4double width,
0124                  const G4double offset );
0125 
0126     /**
0127      * Constructor in mother physical volume (same as first constructor).
0128      *  @param[in] pName The volume name.
0129      *  @param[in] pLogical Pointer to the logical volume of the division.
0130      *  @param[in] pMother Pointer to the physical volume of the mother.
0131      *  @param[in] pAxis The axis along which do the division.
0132      *  @param[in] nReplicas The number of copies to replicate.
0133      *  @param[in] width The witdh of the divided slice along the axis.
0134      *  @param[in] offset The optional offset distance from mother's border.
0135      */
0136     G4PVDivision(const G4String& pName,
0137                        G4LogicalVolume* pLogical,
0138                        G4VPhysicalVolume* pMother,
0139                  const EAxis pAxis,
0140                  const G4int nReplicas,
0141                  const G4double width,
0142                  const G4double offset);
0143 
0144     /**
0145      * Destructor.
0146      */
0147     ~G4PVDivision() override;
0148 
0149     /**
0150      * Copy constructor and assignment operator not allowed.
0151      */
0152     G4PVDivision(const G4PVDivision&) = delete;
0153     G4PVDivision& operator=(const G4PVDivision&) = delete;
0154 
0155     /**
0156      * Not used.
0157      */
0158     G4bool IsMany() const override;
0159 
0160     /**
0161      * Returns true.
0162      */
0163     G4bool IsReplicated() const override;
0164 
0165     /**
0166      * Returns the number of divisions.
0167      */
0168     G4int GetMultiplicity() const override;
0169 
0170     /**
0171      * Returns true to identify if it is a parameterised physical volume.
0172      */
0173     G4bool IsParameterised() const override;
0174 
0175     /**
0176      * Returns the pointer to the parameterisation algorithm.
0177      */
0178     G4VPVParameterisation* GetParameterisation() const override;
0179 
0180     /**
0181      * Fills arguments with the attributes from the base replica.
0182      * @param[in,out] axis Axis of parameterisation returned.
0183      * @param[in,out] nReplicas The number of division copies.
0184      * @param[in,out] width Width of the division slice.
0185      * @param[in,out] offset Potential offset in replication.
0186      * @param[in,out] consuming Flag of replica characterisation (always false
0187      *                for parameterisations).
0188      */
0189     void GetReplicationData( EAxis& axis,
0190                              G4int& nReplicas,
0191                              G4double& width,
0192                              G4double& offset,
0193                              G4bool& consuming ) const override;
0194 
0195     /**
0196      * Returns the axis along which the division is made.
0197      *  @returns The string Id of the axis.
0198      */
0199     EAxis GetDivisionAxis() const;
0200    
0201     /**
0202      * Returns the volume type characterisation.
0203      *  @returns The string Id of the volume type, i.e. 'kParameterised'.
0204      */
0205     EVolume VolumeType() const override;
0206 
0207     /**
0208      * Methods to identify volumes that can have revised 'regular' navigation.
0209      * Currently divisions do not qualify for this.
0210      */
0211     G4bool IsRegularStructure() const override;    // Returns false
0212     G4int GetRegularStructureId() const override;  // Returns 0
0213 
0214   private:
0215 
0216     /**
0217      * Invoked in constructors to check and set the parameters for the
0218      * parameterisation.
0219      */
0220     void CheckAndSetParameters( const EAxis pAxis,
0221                                 const G4int nDivs,
0222                                 const G4double width,
0223                                 const G4double offset, 
0224                                       DivisionType divType,
0225                                 const G4LogicalVolume* pMotherLogical );
0226 
0227     /**
0228      * Sets the parameterisation according to the allowed type of solid
0229      * to be divided.
0230      */
0231     void SetParameterisation( G4LogicalVolume* motherLogical,
0232                         const EAxis pAxis,
0233                         const G4int nReplicas,
0234                         const G4double width,
0235                         const G4double offset, 
0236                               DivisionType divType );
0237 
0238     /**
0239      * Logging the axis when an error in division occurs.
0240      */
0241     void ErrorInAxis( EAxis axis, G4VSolid* solid );
0242 
0243   protected:
0244 
0245     /** Axis of optimisation. */
0246     EAxis faxis;
0247 
0248     /** Axis of division. */
0249     EAxis fdivAxis;
0250 
0251     /** Number of divisions. */
0252     G4int fnReplicas = 0;
0253 
0254     /** Width of the division slice and potential offset. */
0255     G4double fwidth = 0.0, foffset = 0.0;
0256 
0257     /** Pointer to the parameterisation algorithm. */
0258     G4VDivisionParameterisation* fparam = nullptr; 
0259 };
0260 
0261 #endif