Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4LogicalVolume.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$
28//
29//
30// class G4LogicalVolume
31//
32// Class description:
33//
34// Represents a leaf node or unpositioned subtree in the geometry hierarchy.
35// Logical volumes are named, and may have daughters ascribed to them.
36// They are responsible for retrieval of the physical and tracking attributes
37// of the physical volume that it represents: solid, material, magnetic field,
38// and optionally, user limits, sensitive detectors, regions, biasing weights.
39//
40// Get and Set functionality is provided for all attributes, but note that
41// most set functions should not be used when the geometry is `closed'.
42// As a further development, `Guard' checks can be added to ensure
43// only legal operations at tracking time.
44//
45// On construction, solid, material and name must be specified.
46//
47// Daughters are ascribed and managed by means of a simple
48// GetNoDaughters,Get/SetDaughter(n),AddDaughter interface.
49//
50// Smart voxels as used for tracking optimisation. They're also an attribute.
51//
52// Logical volumes self register to the logical volume Store on construction,
53// and deregister on destruction.
54//
55// NOTE: This class is currently *NOT* subclassed, since not meant to
56// act as a base class. Therefore, the destructor is NOT virtual.
57//
58// Data members:
59//
60// std::vector<G4VPhysicalVolume*> fDaughters
61// - Vector of daughters. Given initial size of 0.
62// G4FieldManager* fFieldManager
63// - Pointer (possibly 0) to (magnetic or other) field manager object.
64// G4Material* fMaterial
65// - Pointer to material at this node.
66// G4String fName
67// - Name of logical volume.
68// G4VSensitiveDetector *fSensitiveDetector
69// - Pointer (possibly 0) to `Hit' object.
70// G4VSolid* fSolid
71// - Pointer to solid.
72// G4UserLimits* fUserLimits
73// - Pointer (possibly 0) to user Step limit object for this node.
74// G4SmartVoxelHeader* fVoxel
75// - Pointer (possibly 0) to optimisation info objects.
76// G4bool fOptimise
77// - Flag to identify if optimisation should be applied or not.
78// G4bool fRootRegion
79// - Flag to identify if the logical volume is a root region.
80// G4double fSmartless
81// - Quality for optimisation, average number of voxels to be spent
82// per content.
83// const G4VisAttributes* fVisAttributes
84// - Pointer (possibly 0) to visualization attributes.
85// G4Region* fRegion
86// - Pointer to the cuts region (if any)
87// G4MaterialCutsCouple* fCutsCouple
88// - Pointer (possibly 0) to associated production cuts.
89// G4double fBiasWeight
90// - Weight used in the event biasing technique.
91//
92// Following data members has been moved to G4Region - M.Asai (Aug/18/2005)
93// G4FastSimulationManager* fFastSimulationManager
94// - Pointer (possibly 0) to G4FastSimulationManager object.
95// G4bool fIsEnvelope
96// - Flags if the Logical Volume is an envelope for a FastSimulationManager.
97
98// History:
99// 12.11.04 G.Cosmo: Added GetMass() method for computing mass of the tree
100// 24.09.02 G.Cosmo: Added flags and accessors for region cuts handling
101// 17.05.02 G.Cosmo: Added IsToOptimise() method and related flag
102// 18.04.01 G.Cosmo: Migrated to STL vector
103// 12.02.99 S.Giani: Added user defined optimisation quality
104// 09.11.98 J.Apostolakis: Changed G4MagneticField to G4FieldManager
105// 09.11.98 M.Verderi, J.Apostolakis: Added BiasWeight member and accessors
106// 10.20.97 P.M.DeFreitas: Added pointer to a FastSimulation
107// J.Apostolakis: & flag to indicate if it is an Envelope for it
108// 19.11.96 J.Allison: Replaced G4Visible with explicit const G4VisAttributes*
109// 19.08.96 P.Kent: Split -> hh/icc/cc files; G4VSensitiveDetector change
110// 11.07.95 P.Kent: Initial version.
111// ------------------------------------------------------------------------
112#ifndef G4LOGICALVOLUME_HH
113#define G4LOGICALVOLUME_HH
114
115#include "G4Types.hh"
116#include "G4Region.hh" // Required by inline methods
117#include "G4VPhysicalVolume.hh" // Need operator == for vector fdaughters
118#include <vector>
119#include <assert.h>
120
121// Forward declarations
122//
123class G4FieldManager;
124class G4Material;
126class G4VSolid;
127class G4UserLimits;
129class G4VisAttributes;
132
134{
135 typedef std::vector<G4VPhysicalVolume*> G4PhysicalVolumeList;
136
137 public: // with description
138
140 G4Material* pMaterial,
141 const G4String& name,
142 G4FieldManager* pFieldMgr=0,
143 G4VSensitiveDetector* pSDetector=0,
144 G4UserLimits* pULimits=0,
145 G4bool optimise=true);
146 // Constructor. The solid and material pointer must be non null.
147 // The parameters for field, detector and user limits are optional.
148 // The volume also enters itself into the logical volume Store.
149 // Optimisation of the geometry (voxelisation) for the volume
150 // hierarchy is applied by default. For parameterised volumes in
151 // the hierarchy, optimisation is -always- applied.
152
154 // Destructor. Removes the logical volume from the logical volume Store.
155 // NOT virtual, since not meant to act as base class.
156
157 inline G4String GetName() const;
158 inline void SetName(const G4String& pName);
159 // Returns and sets the name of the logical volume.
160
161 inline G4int GetNoDaughters() const;
162 // Returns the number of daughters (0 to n).
163 inline G4VPhysicalVolume* GetDaughter(const G4int i) const;
164 // Returns the ith daughter. Note numbering starts from 0,
165 // and no bounds checking is performed.
167 // Adds the volume p as a daughter of the current logical volume.
168 inline G4bool IsDaughter(const G4VPhysicalVolume* p) const;
169 // Returns true if the volume p is a daughter of the current
170 // logical volume.
171 G4bool IsAncestor(const G4VPhysicalVolume* p) const;
172 // Returns true if the volume p is part of the hierarchy of
173 // volumes established by the current logical volume. Scans
174 // recursively the volume tree.
175 inline void RemoveDaughter(const G4VPhysicalVolume* p);
176 // Removes the volume p from the List of daughter of the current
177 // logical volume.
178 inline void ClearDaughters();
179 // Clears the list of daughters. Used by the phys-volume store when
180 // the geometry tree is cleared, since modified at run-time.
182 // Returns the total number of physical volumes (replicated or placed)
183 // in the tree represented by the current logical volume.
184
185
186 inline G4VSolid* GetSolid() const;
187 inline void SetSolid(G4VSolid *pSolid);
188 // Gets and sets the current solid.
189
190 inline G4Material* GetMaterial() const;
191 inline void SetMaterial(G4Material *pMaterial);
192 // Gets and sets the current material.
193 inline void UpdateMaterial(G4Material *pMaterial);
194 // Sets material and corresponding MaterialCutsCouple.
195 // This method is invoked by G4Navigator while it is navigating through
196 // material parameterization.
197 G4double GetMass(G4bool forced=false, G4bool propagate=true,
198 G4Material* parMaterial=0);
199 // Returns the mass of the logical volume tree computed from the
200 // estimated geometrical volume of each solid and material associated
201 // to the logical volume and (by default) to its daughters.
202 // NOTE: the computation may require a considerable amount of time,
203 // depending from the complexity of the geometry tree.
204 // The returned value is cached and can be used for successive
205 // calls (default), unless recomputation is forced by providing
206 // 'true' for the boolean argument in input. Computation should
207 // be forced if the geometry setup has changed after the previous
208 // call. By setting the 'propagate' boolean flag to 'false' the
209 // method returns the mass of the present logical volume only
210 // (subtracted for the volume occupied by the daughter volumes).
211 // An optional argument to specify a material is also provided.
212
214 // Gets current FieldManager.
215 void SetFieldManager(G4FieldManager *pFieldMgr, G4bool forceToAllDaughters);
216 // Sets FieldManager and propagates it:
217 // i) only to daughters with G4FieldManager = 0
218 // if forceToAllDaughters=false
219 // ii) to all daughters
220 // if forceToAllDaughters=true
221
223 // Gets current SensitiveDetector.
225 // Sets SensitiveDetector (can be 0).
226
228 inline void SetUserLimits(G4UserLimits *pULimits);
229 // Gets and sets current UserLimits.
230
232 inline void SetVoxelHeader(G4SmartVoxelHeader *pVoxel);
233 // Gets and sets current VoxelHeader.
234
235 inline G4double GetSmartless() const;
236 inline void SetSmartless(G4double s);
237 // Gets and sets user defined optimisation quality.
238
239 inline G4bool IsToOptimise() const;
240 // Replies if geometry optimisation (voxelisation) is to be
241 // applied for this volume hierarchy.
242 inline void SetOptimisation(G4bool optim);
243 // Specifies if to apply or not geometry optimisation to this
244 // volume hierarchy. Note that for parameterised volumes in the
245 // hierarchy, optimisation is always applied.
246
247 inline G4bool IsRootRegion() const;
248 // Replies if the logical volume represents a root region or not.
249 inline void SetRegionRootFlag(G4bool rreg);
250 // Sets/unsets the volume as a root region for cuts.
251 inline G4bool IsRegion() const;
252 // Replies if the logical volume is part of a cuts region or not.
253 inline void SetRegion(G4Region* reg);
254 // Sets/unsets the volume as cuts region.
255 inline G4Region* GetRegion() const;
256 // Return the region to which the volume belongs, if any.
257 inline void PropagateRegion();
258 // Propagates region pointer to daughters.
259
262 // Accessors for production cuts.
263
265 // Equality defined by address only.
266 // Returns true if objects are at same address, else false.
267
268 inline const G4VisAttributes* GetVisAttributes () const;
269 inline void SetVisAttributes (const G4VisAttributes* pVA);
270 void SetVisAttributes (const G4VisAttributes& VA);
271 // Gets and sets visualization attributes. A copy of 'VA' on the heap
272 // will be made in the case the call with a const reference is used.
273
275 // Gets current FastSimulationManager pointer if exists, otherwise null.
276
277 inline void SetBiasWeight (G4double w);
278 inline G4double GetBiasWeight() const;
279 // Sets and gets bias weight.
280
281 public: // without description
282
283 G4LogicalVolume(__void__&);
284 // Fake default constructor for usage restricted to direct object
285 // persistency for clients requiring preallocation of memory for
286 // persistifiable objects.
287
288 inline void Lock();
289 // Set lock identifier for final deletion of entity.
290
291 private:
292
294 G4LogicalVolume& operator=(const G4LogicalVolume&);
295 // Private copy-constructor and assignment operator.
296
297 private:
298
299 // Data members:
300
301 G4PhysicalVolumeList fDaughters;
302 // Vector of daughters. Given initial size of 0.
303 G4FieldManager* fFieldManager;
304 // Pointer (possibly 0) to (magnetic or other) field manager object.
305 G4Material* fMaterial;
306 // Pointer to material at this node.
307 G4String fName;
308 // Name of logical volume.
309 G4VSensitiveDetector* fSensitiveDetector;
310 // Pointer (possibly 0) to `Hit' object.
311 G4VSolid* fSolid;
312 // Pointer to solid.
313 G4UserLimits* fUserLimits;
314 // Pointer (possibly 0) to user Step limit object for this node.
315 G4SmartVoxelHeader* fVoxel;
316 // Pointer (possibly 0) to optimisation info objects.
317 G4bool fOptimise;
318 // Flag to identify if optimisation should be applied or not.
319 G4bool fRootRegion;
320 // Flag to identify if the logical volume is a root region.
321 G4bool fLock;
322 // Flag to identify if entity is locked for final deletion.
323 G4double fSmartless;
324 // Quality for optimisation, average number of voxels to be spent
325 // per content.
326 G4double fMass;
327 // Mass of the logical volume tree.
328 const G4VisAttributes* fVisAttributes;
329 // Pointer (possibly 0) to visualization attributes.
330 G4Region* fRegion;
331 // Pointer to the cuts region (if any)
332 G4MaterialCutsCouple* fCutsCouple;
333 // Pointer (possibly 0) to associated production cuts.
334 G4double fBiasWeight;
335 // Weight used in the event biasing technique.
336};
337
338#include "G4LogicalVolume.icc"
339
340#endif
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
G4bool operator==(const G4LogicalVolume &lv) const
void SetSmartless(G4double s)
G4VSolid * GetSolid() const
const G4VisAttributes * GetVisAttributes() const
void SetName(const G4String &pName)
G4int GetNoDaughters() const
G4String GetName() const
G4bool IsAncestor(const G4VPhysicalVolume *p) const
void SetFieldManager(G4FieldManager *pFieldMgr, G4bool forceToAllDaughters)
void AddDaughter(G4VPhysicalVolume *p)
void SetUserLimits(G4UserLimits *pULimits)
G4double GetMass(G4bool forced=false, G4bool propagate=true, G4Material *parMaterial=0)
void SetVoxelHeader(G4SmartVoxelHeader *pVoxel)
G4VSensitiveDetector * GetSensitiveDetector() const
void RemoveDaughter(const G4VPhysicalVolume *p)
void SetRegionRootFlag(G4bool rreg)
void SetRegion(G4Region *reg)
G4FastSimulationManager * GetFastSimulationManager() const
G4bool IsRootRegion() const
G4Region * GetRegion() const
G4double GetBiasWeight() const
G4bool IsRegion() const
G4double GetSmartless() const
G4bool IsDaughter(const G4VPhysicalVolume *p) const
G4Material * GetMaterial() const
void PropagateRegion()
G4VPhysicalVolume * GetDaughter(const G4int i) const
G4UserLimits * GetUserLimits() const
G4FieldManager * GetFieldManager() const
void SetVisAttributes(const G4VisAttributes *pVA)
G4int TotalVolumeEntities() const
void SetBiasWeight(G4double w)
G4bool IsToOptimise() const
void ClearDaughters()
const G4MaterialCutsCouple * GetMaterialCutsCouple() const
void SetMaterial(G4Material *pMaterial)
void SetSolid(G4VSolid *pSolid)
G4SmartVoxelHeader * GetVoxelHeader() const
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector)
void SetOptimisation(G4bool optim)
void SetMaterialCutsCouple(G4MaterialCutsCouple *cuts)
void UpdateMaterial(G4Material *pMaterial)