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] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /geometry/management/include/G4VPhysicalVolume.hh (Version 11.3.0) and /geometry/management/include/G4VPhysicalVolume.hh (Version 11.2)


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