Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // G4VPhysicalVolume << 23 // >> 24 // $Id: G4VPhysicalVolume.hh,v 1.10 2003/11/02 14:01:22 gcosmo Exp $ >> 25 // GEANT4 tag $Name: geant4-06-00-patch-01 $ >> 26 // >> 27 // >> 28 // class G4VPhysicalVolume 27 // 29 // 28 // Class description: 30 // Class description: 29 // 31 // 30 // This is an Abstract Base class for the repr 32 // This is an Abstract Base class for the representation of positioned volume. 31 // The volume is placed within a mother volume 33 // The volume is placed within a mother volume, relative to its coordinate 32 // system. Either a single positioned volume 34 // system. Either a single positioned volume or many positioned volume can 33 // be represented by a particular G4VPhysicalV 35 // be represented by a particular G4VPhysicalVolume. 34 36 35 // 15.01.13, G.Cosmo, A.Dotti: Modified for th << 37 // History: 36 // 28.08.96, P.Kent: Replaced transform by rot << 38 // 09.11.99 J.Apostolakis Added GetObjectRotationValue() method & redid comments. 37 // 25.07.96, P.Kent: Modified interface for ne << 39 // 28.08.96 P.Kent Replaced transform by rotmat + vector 38 // 24.07.95, P.Kent: First non-stub version << 40 // 25.07.96 P.Kent Modified interface for new `Replica' capable geometry >> 41 // 24.07.95 P.Kent First non-stub version 39 // ------------------------------------------- 42 // -------------------------------------------------------------------- 40 #ifndef G4VPHYSICALVOLUME_HH 43 #ifndef G4VPHYSICALVOLUME_HH 41 #define G4VPHYSICALVOLUME_HH 1 << 44 #define G4VPHYSICALVOLUME_HH 42 45 43 #include "G4Types.hh" 46 #include "G4Types.hh" 44 #include "G4String.hh" 47 #include "G4String.hh" 45 48 46 #include "geomdefs.hh" 49 #include "geomdefs.hh" 47 50 48 #include "G4RotationMatrix.hh" 51 #include "G4RotationMatrix.hh" 49 #include "G4ThreeVector.hh" 52 #include "G4ThreeVector.hh" 50 #include "G4GeomSplitter.hh" << 51 53 52 class G4LogicalVolume; 54 class G4LogicalVolume; 53 class G4VPVParameterisation; 55 class G4VPVParameterisation; 54 56 55 class G4PVData << 56 { << 57 // Encapsulates the fields associated to G4V << 58 // that are not read-only - they will change << 59 // and must have a per-thread state. << 60 << 61 public: << 62 << 63 G4PVData() = default; << 64 << 65 void initialize() << 66 { << 67 frot = nullptr; << 68 tx = 0.; ty = 0.; tz = 0.; << 69 } << 70 << 71 G4RotationMatrix* frot = nullptr; << 72 G4double tx = 0., ty = 0., tz = 0.; << 73 }; << 74 << 75 using G4PVManager = G4GeomSplitter<G4PVData>; << 76 // Implementation detail for use of G4PVData o << 77 << 78 class G4VPhysicalVolume 57 class G4VPhysicalVolume 79 { 58 { 80 public: << 59 public: // with description 81 60 82 G4VPhysicalVolume(G4RotationMatrix* pRot, << 61 G4VPhysicalVolume(G4RotationMatrix *pRot, 83 const G4ThreeVector& tlate, << 62 const G4ThreeVector &tlate, 84 const G4String& pName, << 63 const G4String &pName, 85 G4LogicalVolume* pLogica << 64 G4LogicalVolume *pLogical, 86 G4VPhysicalVolume* pMoth << 65 G4VPhysicalVolume *pMother); 87 // Initialise volume, positioned in a fr 66 // Initialise volume, positioned in a frame which is rotated by *pRot, 88 // relative to the coordinate system of 67 // relative to the coordinate system of the mother volume pMother. 89 // The center of the object is then plac 68 // The center of the object is then placed at tlate in the new 90 // coordinates. If pRot=0 the volume is 69 // coordinates. If pRot=0 the volume is unrotated with respect to its 91 // mother. The physical volume is added 70 // mother. The physical volume is added to the mother's logical volume. 92 // 71 // 93 // Must be called by all subclasses. pMo 72 // Must be called by all subclasses. pMother must point to a valid parent 94 // volume, except in the case of the wor 73 // volume, except in the case of the world/top volume, when it =0. 95 // 74 // 96 // The constructor also registers volume 75 // The constructor also registers volume with physical volume Store. 97 // Note that the Store may be removed or 76 // Note that the Store may be removed or dynamically built in future 98 // because of memory constraints. 77 // because of memory constraints. 99 78 100 virtual ~G4VPhysicalVolume(); 79 virtual ~G4VPhysicalVolume(); 101 // Destructor, will be subclassed. Remov 80 // Destructor, will be subclassed. Removes volume from volume Store. 102 81 103 G4VPhysicalVolume(const G4VPhysicalVolume& << 104 G4VPhysicalVolume& operator=(const G4VPhys << 105 // No copy constructor and assignment op << 106 << 107 inline G4bool operator == (const G4VPhysic 82 inline G4bool operator == (const G4VPhysicalVolume& p) const; 108 // Equality defined by equal addresses o 83 // Equality defined by equal addresses only. 109 84 110 // Access functions 85 // Access functions 111 // << 86 112 // The following are accessor functions th << 87 // The following are accessor functions that make a distinction 113 // between whether the rotation/translatio << 88 // between whether the rotation/translation is being made for the 114 // frame or the object/volume that is bein << 89 // frame or the object/volume that is being placed. 115 // (They are the inverse of each other). << 90 // (They are the inverse of each other). 116 << 91 G4RotationMatrix* GetObjectRotation() const; // Obsolete 117 G4RotationMatrix* GetObjectRotation() cons << 92 inline G4RotationMatrix GetObjectRotationValue() const; // Replacement 118 G4RotationMatrix GetObjectRotationValue() << 93 inline G4ThreeVector GetObjectTranslation() const; 119 G4ThreeVector GetObjectTranslation() cons << 120 // Return the rotation/translation of th 94 // Return the rotation/translation of the Object relative to the mother. 121 const G4RotationMatrix* GetFrameRotation() << 95 inline const G4RotationMatrix* GetFrameRotation() const; 122 G4ThreeVector GetFrameTranslation() const; << 96 inline G4ThreeVector GetFrameTranslation() const; 123 // Return the rotation/translation of th 97 // Return the rotation/translation of the Frame used to position 124 // this volume in its mother volume (opp 98 // this volume in its mother volume (opposite of object rot/trans). 125 99 126 // Older access functions, that do not dis 100 // Older access functions, that do not distinguish between frame/object! 127 101 128 const G4ThreeVector GetTranslation() const << 102 inline const G4ThreeVector& GetTranslation() const; 129 const G4RotationMatrix* GetRotation() cons << 103 inline const G4RotationMatrix* GetRotation() const; 130 // Old access functions, that do not dis 104 // Old access functions, that do not distinguish between frame/object! 131 // They return the translation/rotation 105 // They return the translation/rotation of the volume. 132 106 133 // Set functions 107 // Set functions 134 108 135 void SetTranslation(const G4ThreeVector& v << 109 inline void SetTranslation(const G4ThreeVector &v); 136 G4RotationMatrix* GetRotation(); << 110 inline G4RotationMatrix* GetRotation(); 137 void SetRotation(G4RotationMatrix*); << 111 inline void SetRotation(G4RotationMatrix*); 138 // NOT INTENDED FOR GENERAL USE. 112 // NOT INTENDED FOR GENERAL USE. 139 // Non constant versions of above. Used 113 // Non constant versions of above. Used to change transformation 140 // for replication/parameterisation mech 114 // for replication/parameterisation mechanism. 141 115 142 inline G4LogicalVolume* GetLogicalVolume() 116 inline G4LogicalVolume* GetLogicalVolume() const; 143 // Return the associated logical volume. 117 // Return the associated logical volume. 144 inline void SetLogicalVolume(G4LogicalVolu << 118 inline void SetLogicalVolume(G4LogicalVolume *pLogical); 145 // Set the logical volume. Must not be c 119 // Set the logical volume. Must not be called when geometry closed. 146 120 147 inline G4LogicalVolume* GetMotherLogical() 121 inline G4LogicalVolume* GetMotherLogical() const; 148 // Return the current mother logical vol 122 // Return the current mother logical volume pointer. 149 inline void SetMotherLogical(G4LogicalVolu << 123 inline void SetMotherLogical(G4LogicalVolume *pMother); 150 // Set the mother logical volume. Must n 124 // Set the mother logical volume. Must not be called when geometry closed. 151 125 152 inline const G4String& GetName() const; << 126 inline G4String GetName() const; 153 // Return the volume's name. 127 // Return the volume's name. 154 void SetName(const G4String& pName); << 128 inline void SetName(const G4String& pName); 155 // Set the volume's name. 129 // Set the volume's name. 156 130 157 virtual G4int GetMultiplicity() const; 131 virtual G4int GetMultiplicity() const; 158 // Returns number of object entities (1 132 // Returns number of object entities (1 for normal placements, 159 // n for replicas or parameterised). 133 // n for replicas or parameterised). 160 134 161 // Functions required of subclasses 135 // Functions required of subclasses 162 136 163 virtual EVolume VolumeType() const = 0; << 164 // Characterise the type of volume - nor << 165 virtual G4bool IsMany() const = 0; 137 virtual G4bool IsMany() const = 0; 166 // Return true if the volume is MANY (no 138 // Return true if the volume is MANY (not implemented yet). 167 virtual G4int GetCopyNo() const = 0; 139 virtual G4int GetCopyNo() const = 0; 168 // Return the volumes copy number. 140 // Return the volumes copy number. 169 virtual void SetCopyNo(G4int CopyNo) = 0; 141 virtual void SetCopyNo(G4int CopyNo) = 0; 170 // Set the volumes copy number. 142 // Set the volumes copy number. 171 virtual G4bool IsReplicated() const = 0; 143 virtual G4bool IsReplicated() const = 0; 172 // Return true if replicated (single obj 144 // Return true if replicated (single object instance represents 173 // many real volumes), else false. 145 // many real volumes), else false. 174 virtual G4bool IsParameterised() const = 0 146 virtual G4bool IsParameterised() const = 0; 175 // Return true if parameterised (single 147 // Return true if parameterised (single object instance represents 176 // many real parameterised volumes), els 148 // many real parameterised volumes), else false. 177 virtual G4VPVParameterisation* GetParamete 149 virtual G4VPVParameterisation* GetParameterisation() const = 0; 178 // Return replicas parameterisation obje 150 // Return replicas parameterisation object (able to compute dimensions 179 // and transformations of replicas), or 151 // and transformations of replicas), or NULL if not applicable. 180 virtual void GetReplicationData(EAxis& axi 152 virtual void GetReplicationData(EAxis& axis, 181 G4int& nRe 153 G4int& nReplicas, 182 G4double& 154 G4double& width, 183 G4double& 155 G4double& offset, 184 G4bool& co 156 G4bool& consuming) const = 0; 185 // Return replication information. No-op 157 // Return replication information. No-op for no replicated volumes. 186 virtual G4bool IsRegularStructure() const << 187 // Returns true if the underlying volume << 188 virtual G4int GetRegularStructureId() cons << 189 // Returns non-zero code in case the und << 190 // is regular, voxel-like. Value is id << 191 // If non-zero the volume is a candidat << 192 // navigation such as 'nearest neighbou << 193 virtual G4bool CheckOverlaps(G4int res=100 << 194 G4bool verbos << 195 // Verifies if the placed volume is over << 196 // daughters or with the mother volume. << 197 // for the number of points to be genera << 198 // Concrete implementation is done and r << 199 // parameterised volumes. Returns true i << 200 << 201 public: << 202 << 203 G4VPhysicalVolume(__void__&); << 204 // Fake default constructor for usage re << 205 // persistency for clients requiring pre << 206 // persistifiable objects. << 207 << 208 inline G4int GetInstanceID() const; << 209 // Returns the instance ID. << 210 << 211 static const G4PVManager& GetSubInstanceMa << 212 // Returns the private data instance man << 213 << 214 static void Clean(); << 215 // Clear memory allocated by sub-instanc << 216 << 217 inline EVolume DeduceVolumeType() const; << 218 // Old VolumeType() method, replaced by << 219 // kept for checking << 220 << 221 protected: << 222 158 223 void InitialiseWorker(G4VPhysicalVolume* p << 159 private: 224 G4RotationMatrix* pR << 160 225 // This method is similar to the constru << 161 G4VPhysicalVolume(const G4VPhysicalVolume&); 226 // thread to achieve the partial effect << 162 G4VPhysicalVolume& operator=(const G4VPhysicalVolume&); 227 << 163 // Private copy constructor and assignment operator. 228 void TerminateWorker(G4VPhysicalVolume* pM << 229 // This method is similar to the destruc << 230 // thread to achieve the partial effect << 231 164 232 protected: 165 protected: 233 166 234 G4int instanceID; << 167 G4RotationMatrix *frot; 235 // For use in implementing the per-threa << 168 G4ThreeVector ftrans; 236 // It is equivalent to a pointer to a << 237 G4GEOM_DLL static G4PVManager subInstanceM << 238 // Needed to use G4PVManager for the G4 << 239 169 240 private: 170 private: 241 171 242 G4LogicalVolume* flogical = nullptr; // Th << 172 G4LogicalVolume *flogical; // The logical volume representing the 243 // ph << 173 // physical and tracking attributes of 244 // th << 174 // the volume 245 G4String fname; // Th << 175 G4String fname; // The name of the volume 246 G4LogicalVolume* flmother = nullptr; // Th << 176 G4LogicalVolume *flmother; // The current mother logical volume 247 << 248 G4PVData* pvdata = nullptr; // Shadow poin << 249 }; 177 }; 250 << 251 // NOTE: << 252 // The type G4PVManager is introduced to encap << 253 // both the master thread and worker threads t << 254 // the fields encapsulated by the class G4PVDa << 255 // initializes the value for these fields, it << 256 // definition defined below. For every G4VPhys << 257 // a corresponding G4PVData instance. All G4PV << 258 // by the class G4PVManager as an array. << 259 // The field "int instanceID" is added to the << 260 // The value of this field in each G4VPhysical << 261 // of the corresponding G4PVData instance. << 262 // In order to use the class G4PVManager, we a << 263 // G4VPhysicalVolume as follows: "static G4PVM << 264 // For the master thread, the array for G4PVDa << 265 // along with G4VPhysicalVolume instances are << 266 // it copies the array of G4PVData instances f << 267 // In addition, it invokes a method similiar t << 268 // to achieve the partial effect for each inst << 269 178 270 #include "G4VPhysicalVolume.icc" 179 #include "G4VPhysicalVolume.icc" 271 180 272 #endif 181 #endif 273 182