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