Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/G4VPhysicalVolume.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 // G4VPhysicalVolume
0027 //
0028 // Class description:
0029 //
0030 // This is an Abstract Base class for the representation of positioned volume.  
0031 // The volume is placed within a mother volume,  relative to its coordinate 
0032 // system.  Either a single positioned volume or many positioned volume can 
0033 // be represented by a particular G4VPhysicalVolume.
0034 
0035 // 15.01.13, G.Cosmo, A.Dotti: Modified for thread-safety for MT
0036 // 28.08.96, P.Kent: Replaced transform by rotmat + vector
0037 // 25.07.96, P.Kent: Modified interface for new `Replica' capable geometry 
0038 // 24.07.95, P.Kent: First non-stub version
0039 // --------------------------------------------------------------------
0040 #ifndef G4VPHYSICALVOLUME_HH
0041 #define G4VPHYSICALVOLUME_HH 1
0042 
0043 #include "G4Types.hh"
0044 #include "G4String.hh"
0045 
0046 #include "geomdefs.hh"
0047 
0048 #include "G4RotationMatrix.hh"
0049 #include "G4ThreeVector.hh"
0050 #include "G4GeomSplitter.hh"
0051 
0052 class G4LogicalVolume;
0053 class G4VPVParameterisation;
0054 
0055 class G4PVData
0056 {
0057   // Encapsulates the fields associated to G4VPhysicalVolume
0058   // that are not read-only - they will change during simulation
0059   // and must have a per-thread state.
0060 
0061   public:
0062 
0063     G4PVData() = default;
0064 
0065     void initialize()
0066     {
0067       frot = nullptr;
0068       tx = 0.; ty = 0.; tz = 0.;
0069     }
0070 
0071     G4RotationMatrix* frot = nullptr;
0072     G4double tx = 0., ty = 0., tz = 0.;
0073 };
0074 
0075 using G4PVManager = G4GeomSplitter<G4PVData>;
0076 // Implementation detail for use of G4PVData objects 
0077 
0078 class G4VPhysicalVolume
0079 {
0080   public:
0081 
0082     G4VPhysicalVolume(G4RotationMatrix* pRot,
0083                 const G4ThreeVector& tlate,
0084                 const G4String& pName,
0085                       G4LogicalVolume* pLogical,
0086                       G4VPhysicalVolume* pMother);
0087       // Initialise volume, positioned in a frame which is rotated by *pRot, 
0088       // relative to the coordinate system of the mother volume pMother.
0089       // The center of the object is then placed at tlate in the new
0090       // coordinates. If pRot=0 the volume is unrotated with respect to its
0091       // mother. The physical volume is added to the mother's logical volume.
0092       //
0093       // Must be called by all subclasses. pMother must point to a valid parent
0094       // volume, except in the case of the world/top volume, when it =0.
0095       // 
0096       // The constructor also registers volume with physical volume Store.
0097       // Note that the Store may be removed or dynamically built in future
0098       // because of memory constraints.
0099 
0100     virtual ~G4VPhysicalVolume();
0101       // Destructor, will be subclassed. Removes volume from volume Store.
0102 
0103     G4VPhysicalVolume(const G4VPhysicalVolume&) = delete;
0104     G4VPhysicalVolume& operator=(const G4VPhysicalVolume&) = delete;
0105       // No copy constructor and assignment operator.
0106 
0107     inline G4bool operator == (const G4VPhysicalVolume& p) const;
0108       // Equality defined by equal addresses only.
0109 
0110     // Access functions
0111     //
0112     // The following are accessor functions that make a distinction
0113     // between whether the rotation/translation is being made for the
0114     // frame or the object/volume that is being placed.
0115     // (They are the inverse of each other).
0116 
0117     G4RotationMatrix* GetObjectRotation() const;       //  Obsolete 
0118     G4RotationMatrix  GetObjectRotationValue() const;  //  Replacement
0119     G4ThreeVector  GetObjectTranslation() const;
0120       // Return the rotation/translation of the Object relative to the mother.
0121     const G4RotationMatrix* GetFrameRotation() const;
0122     G4ThreeVector GetFrameTranslation() const;
0123       // Return the rotation/translation of the Frame used to position 
0124       // this volume in its mother volume (opposite of object rot/trans).
0125 
0126     // Older access functions, that do not distinguish between frame/object!
0127 
0128     const G4ThreeVector GetTranslation() const;
0129     const G4RotationMatrix* GetRotation() const;
0130       // Old access functions, that do not distinguish between frame/object!
0131       // They return the translation/rotation of the volume.
0132 
0133     // Set functions
0134 
0135     void SetTranslation(const G4ThreeVector& v);
0136     G4RotationMatrix* GetRotation();
0137     void SetRotation(G4RotationMatrix*);
0138       // NOT INTENDED FOR GENERAL USE.
0139       // Non constant versions of above. Used to change transformation
0140       // for replication/parameterisation mechanism.
0141 
0142     inline G4LogicalVolume* GetLogicalVolume() const;
0143       // Return the associated logical volume.
0144     inline void SetLogicalVolume(G4LogicalVolume* pLogical);
0145       // Set the logical volume. Must not be called when geometry closed.
0146 
0147     inline G4LogicalVolume* GetMotherLogical() const;
0148       // Return the current mother logical volume pointer.
0149     inline void SetMotherLogical(G4LogicalVolume* pMother);
0150       // Set the mother logical volume. Must not be called when geometry closed.
0151 
0152     inline const G4String& GetName() const;
0153       // Return the volume's name.
0154     void SetName(const G4String& pName);
0155       // Set the volume's name.
0156 
0157     virtual G4int GetMultiplicity() const;
0158       // Returns number of object entities (1 for normal placements,
0159       // n for replicas or parameterised).
0160 
0161     // Functions required of subclasses
0162 
0163     virtual EVolume VolumeType() const = 0;
0164       // Characterise the type of volume - normal/replicated/parameterised.
0165     virtual G4bool IsMany() const = 0;
0166       // Return true if the volume is MANY (not implemented yet).
0167     virtual G4int GetCopyNo() const = 0;
0168       // Return the volumes copy number.
0169     virtual void  SetCopyNo(G4int CopyNo) = 0;
0170       // Set the volumes copy number.
0171     virtual G4bool IsReplicated() const = 0;
0172       // Return true if replicated (single object instance represents
0173       // many real volumes), else false.
0174     virtual G4bool IsParameterised() const = 0;
0175       // Return true if parameterised (single object instance represents
0176       // many real parameterised volumes), else false.
0177     virtual G4VPVParameterisation* GetParameterisation() const = 0;
0178       // Return replicas parameterisation object (able to compute dimensions
0179       // and transformations of replicas), or NULL if not applicable.
0180     virtual void GetReplicationData(EAxis& axis,
0181                                     G4int& nReplicas,
0182                                     G4double& width,
0183                                     G4double& offset,
0184                                     G4bool& consuming) const = 0;
0185       // Return replication information. No-op for no replicated volumes.
0186     virtual G4bool IsRegularStructure() const = 0;
0187       // Returns true if the underlying volume structure is regular.
0188     virtual G4int GetRegularStructureId() const = 0;
0189       // Returns non-zero code in case the underlying volume structure 
0190       //  is regular, voxel-like.  Value is id for structure type.
0191       //  If non-zero the volume is a candidate for specialised 
0192       //  navigation such as 'nearest neighbour' directly on volumes.
0193     virtual G4bool CheckOverlaps(G4int res=1000, G4double tol=0.,
0194                                  G4bool verbose=true, G4int errMax=1);
0195       // Verifies if the placed volume is overlapping with existing
0196       // daughters or with the mother volume. Provides default resolution
0197       // for the number of points to be generated and verified.
0198       // Concrete implementation is done and required only for placed and
0199       // parameterised volumes. Returns true if the volume is overlapping.
0200 
0201   public:
0202 
0203     G4VPhysicalVolume(__void__&);
0204       // Fake default constructor for usage restricted to direct object
0205       // persistency for clients requiring preallocation of memory for
0206       // persistifiable objects.
0207 
0208     inline G4int GetInstanceID() const;
0209       // Returns the instance ID.
0210 
0211     static const G4PVManager& GetSubInstanceManager();
0212       // Returns the private data instance manager.
0213 
0214     static void Clean();
0215       // Clear memory allocated by sub-instance manager.
0216 
0217     inline EVolume DeduceVolumeType() const;
0218       // Old VolumeType() method, replaced by virtual method,
0219       // kept for checking
0220       
0221   protected:
0222 
0223     void InitialiseWorker(G4VPhysicalVolume* pMasterObject,
0224                           G4RotationMatrix* pRot, const G4ThreeVector& tlate);
0225       // This method is similar to the constructor. It is used by each worker
0226       // thread to achieve the partial effect as that of the master thread.
0227 
0228     void TerminateWorker(G4VPhysicalVolume* pMasterObject);
0229       // This method is similar to the destructor. It is used by each worker
0230       // thread to achieve the partial effect as that of the master thread.
0231 
0232   protected:
0233 
0234     G4int instanceID;
0235       // For use in implementing the per-thread data,
0236       //   It is equivalent to a pointer to a G4PVData object.
0237     G4GEOM_DLL static G4PVManager subInstanceManager;
0238       //  Needed to use G4PVManager for the G4PVData per-thread objects.
0239 
0240   private:
0241 
0242     G4LogicalVolume* flogical = nullptr; // The logical volume representing the
0243                                          // physical and tracking attributes of
0244                                          // the volume
0245     G4String fname;                      // The name of the volume
0246     G4LogicalVolume* flmother = nullptr; // The current mother logical volume
0247 
0248     G4PVData* pvdata = nullptr; // Shadow pointer for use of object persistency
0249 };
0250 
0251 // NOTE: 
0252 // The type G4PVManager is introduced to encapsulate the methods used by
0253 // both the master thread and worker threads to allocate memory space for
0254 // the fields encapsulated by the class G4PVData. When each thread
0255 // initializes the value for these fields, it refers to them using a macro
0256 // definition defined below. For every G4VPhysicalVolume instance, there is
0257 // a corresponding G4PVData instance. All G4PVData instances are organized
0258 // by the class G4PVManager as an array.
0259 // The field "int instanceID" is added to the class G4VPhysicalVolume.
0260 // The value of this field in each G4VPhysicalVolume instance is the subscript
0261 // of the corresponding G4PVData instance.
0262 // In order to use the class G4PVManager, we add a static member in the class
0263 // G4VPhysicalVolume as follows: "static G4PVManager subInstanceManager;".
0264 // For the master thread, the array for G4PVData instances grows dynamically
0265 // along with G4VPhysicalVolume instances are created. For each worker thread,
0266 // it copies the array of G4PVData instances from the master thread.           
0267 // In addition, it invokes a method similiar to the constructor explicitly
0268 // to achieve the partial effect for each instance in the array.
0269 
0270 #include "G4VPhysicalVolume.icc"
0271 
0272 #endif