source: trunk/source/geometry/management/include/G4LogicalVolume.hh@ 1051

Last change on this file since 1051 was 850, checked in by garnier, 17 years ago

geant4.8.2 beta

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