Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-02 09:17:11

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 // G4PVPlacement
0027 //
0028 // Class description:
0029 //
0030 // Class representing a single volume positioned within and relative
0031 // to a mother volume.
0032 
0033 // Author: Paul Kent (CERN), 24.07.1995 - First non-stub version
0034 // ----------------------------------------------------------------------
0035 #ifndef G4PVPLACEMENT_HH
0036 #define G4PVPLACEMENT_HH
0037 
0038 #include "G4VPhysicalVolume.hh"
0039 #include "G4Transform3D.hh"
0040 
0041 /**
0042  * @brief G4PVPlacement represents a single volume positioned within and
0043  * relative to a mother volume.
0044  */
0045 
0046 class G4PVPlacement : public G4VPhysicalVolume
0047 {
0048   public:
0049 
0050     /**
0051      * Initialises a single volume, positioned in a frame which is rotated by
0052      * '*pRot' and traslated by 'tlate', relative to the coordinate system of
0053      * the mother volume 'pMotherLogical'.
0054      * If 'pRot=nullptr' the volume is unrotated with respect to its mother.
0055      * The physical volume is added to the mother's logical volume.
0056      * This is a very natural way of defining a physical volume, and is
0057      * especially useful when creating subdetectors: the mother volumes are
0058      * not placed until a later stage of the assembly program.
0059      *  @param[in] pRot The pointer to the rotation in the mother volume.
0060      *  @param[in] tlate Traslation vector in the mother volume.
0061      *  @param[in] pCurrentLogical Pointer to its logical volume.
0062      *  @param[in] pName The volume name.
0063      *  @param[in] pMotherLogical Pointer to the logical volume of the mother.
0064      *  @param[in] pMany Flag to identify if the volume is meant to be
0065      *             considered an overlapping structure, or not. - not used.
0066      *  @param[in] pCopyNo The optional custom copy number. Should be set to 0
0067      *             for the first volume of a given type.
0068      *  @param[in] pSurfChk Boolean flag, if true activates check for overlaps
0069      *             with existing volumes (false by default).
0070      */
0071     G4PVPlacement(G4RotationMatrix* pRot,
0072             const G4ThreeVector& tlate,
0073                   G4LogicalVolume* pCurrentLogical,
0074             const G4String& pName,
0075                   G4LogicalVolume* pMotherLogical,
0076                   G4bool pMany,
0077                   G4int  pCopyNo,
0078                   G4bool pSurfChk = false);
0079 
0080     /**
0081      * Additional constructor, which expects a G4Transform3D object that
0082      * represents the direct rotation and translation of the solid (NOT of the
0083      * frame). The G4Transform3D argument should be constructed by:
0084      *  i) First rotating it to align the solid to the system of 
0085      *     reference of its mother volume *pMotherLogical, and 
0086      * ii) Then placing the solid at the location Transform3D.getTranslation(),
0087      *     with respect to the origin of the system of coordinates of the
0088      *     mother volume.  
0089      * This construct is useful for the people who prefer to think in terms 
0090      * of moving objects in a given reference frame.
0091      * All other arguments are the same as for the previous constructor.
0092      *  @param[in] Transform3D The transformation in the 3D space.
0093      *  @param[in] pCurrentLogical Pointer to its logical volume.
0094      *  @param[in] pName The volume name.
0095      *  @param[in] pMotherLogical Pointer to the logical volume of the mother.
0096      *  @param[in] pMany Flag to identify if the volume is meant to be
0097      *             considered an overlapping structure, or not. - not used.
0098      *  @param[in] pCopyNo The optional custom copy number. Should be set to 0
0099      *             for the first volume of a given type.
0100      *  @param[in] pSurfChk Boolean flag, if true activates check for overlaps
0101      *             with existing volumes (false by default).
0102      */
0103     G4PVPlacement(const G4Transform3D& Transform3D,
0104                         G4LogicalVolume* pCurrentLogical,
0105                   const G4String& pName,
0106                         G4LogicalVolume* pMotherLogical,
0107                         G4bool pMany,
0108                         G4int pCopyNo,
0109                         G4bool pSurfChk = false);
0110 
0111     /**
0112      * A simple variation of the first constructor, only specifying the
0113      * mother volume as a pointer to its physical volume instead of its
0114      * logical volume. The effect is exactly the same.
0115      */
0116     G4PVPlacement(G4RotationMatrix* pRot,
0117             const G4ThreeVector& tlate,
0118             const G4String& pName,
0119                   G4LogicalVolume* pLogical,
0120                   G4VPhysicalVolume* pMother,
0121                   G4bool pMany,
0122                   G4int pCopyNo,
0123                   G4bool pSurfChk = false);
0124 
0125     /**
0126      * Utilises both variations above (from first and third constructors).
0127      * The effect is the same as for the second constructor.
0128      */
0129     G4PVPlacement(const G4Transform3D& Transform3D,
0130                   const G4String& pName,
0131                         G4LogicalVolume* pLogical,
0132                         G4VPhysicalVolume* pMother,
0133                         G4bool pMany,
0134                         G4int pCopyNo,
0135                         G4bool pSurfChk = false);
0136 
0137     /**
0138      * Fake default constructor for usage restricted to direct object
0139      * persistency for clients requiring preallocation of memory for
0140      * persistifiable objects.
0141      */
0142     G4PVPlacement(__void__&);
0143 
0144     /**
0145      * Default Destructor.
0146      */
0147     ~G4PVPlacement() override;
0148 
0149     /**
0150      * Copy constructor and assignment operator not allowed.
0151      */
0152     G4PVPlacement(const G4PVPlacement&) = delete;
0153     G4PVPlacement& operator=(const G4PVPlacement&) = delete;
0154 
0155     /**
0156      * Returns/sets the copy number associated to the volume.
0157      */
0158     inline G4int GetCopyNo() const override  { return fcopyNo; }
0159     void SetCopyNo(G4int CopyNo) override;
0160 
0161     /**
0162      * Verifies if the placed volume is overlapping with existing daughters
0163      * or with the mother volume. Provides default resolution for the number
0164      * of points to be generated and verified.
0165      * A tolerance for the precision of the overlap check can be specified,
0166      * by default it is set to maximum precision.
0167      * Reports a maximum of overlaps errors according to parameter in input.
0168      *  @param[in] res The number of points to generate on volume's surface.
0169      *  @param[in] tol The precision tolerance for the overlap check, below
0170      *             which to ignore overlaps (default is maximim precision).
0171      *  @param[in] verbose Verbosity mode (default is true).
0172      *  @param[in] maxErr Maximum of overlaps errors to report (default is 1).
0173      *  @returns True if an overlap occurs.
0174      */
0175     G4bool CheckOverlaps(G4int res = 1000, G4double tol = 0.,
0176                          G4bool verbose = true, G4int maxErr = 1) override;
0177 
0178     /**
0179      * Stub methods, unused for placed volumes.
0180      */
0181     G4bool IsMany() const override;
0182     G4bool IsReplicated() const override;
0183     G4bool IsParameterised() const override;
0184     G4VPVParameterisation* GetParameterisation() const override;
0185     void GetReplicationData(EAxis& axis,
0186                             G4int& nReplicas,
0187                             G4double& width,
0188                             G4double& offset,
0189                             G4bool& consuming) const override;
0190 
0191     /**
0192      * Used only for specialised repeated volumes. Always false with Id 0.
0193      */
0194     G4bool IsRegularStructure() const override; 
0195     G4int GetRegularStructureId() const override; 
0196 
0197     /**
0198      * Returns the volume type characterisation.
0199      */
0200     EVolume VolumeType() const override;
0201    
0202   private:
0203 
0204     /**
0205      * Auxiliary function for 2nd constructor (one with G4Transform3D).
0206      * Creates a new RotMatrix on the heap (using "new") and copies 
0207      * its argument into it.
0208      */
0209     static G4RotationMatrix* NewPtrRotMatrix(const G4RotationMatrix& RotMat);
0210 
0211   private:
0212 
0213     /** Flag for overlapping structure - not used. */
0214     G4bool fmany = false;
0215 
0216     /** Flag for allocation of the rotation matrix. */
0217     G4bool fallocatedRotM = false;
0218 
0219     /** Optional copy number, for identification. */
0220     G4int fcopyNo = 0;
0221 };
0222 
0223 #endif