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
G4Region.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// class G4Region
30//
31// Class description:
32//
33// Defines a region or a group of regions in the detector geometry
34// setup, sharing properties associated to materials or production
35// cuts which may affect or bias specific physics processes.
36
37// History:
38// 18.09.02 G.Cosmo Initial version
39// --------------------------------------------------------------------
40#ifndef G4REGION_HH
41#define G4REGION_HH
42
44class G4LogicalVolume;
45class G4Material;
48class G4UserLimits;
49class G4FieldManager;
53
54#include <vector>
55#include <map>
56#include <algorithm>
57
58#include "G4Types.hh"
59#include "G4String.hh"
60
62{
63 typedef std::vector<G4LogicalVolume*> G4RootLVList;
64 typedef std::vector<G4Material*> G4MaterialList;
65 typedef std::pair<G4Material*,G4MaterialCutsCouple*> G4MaterialCouplePair;
66 typedef std::map<G4Material*,G4MaterialCutsCouple*> G4MaterialCoupleMap;
67
68 public: // with description
69
70 G4Region(const G4String& name);
71 virtual ~G4Region();
72
73 inline G4bool operator==(const G4Region& rg) const;
74 // Equality defined by address only.
75
78 // Add/remove root logical volumes and set/reset their
79 // daughters flags as regions. They also recompute the
80 // materials list for the region.
81
82 inline void SetName(const G4String& name);
83 inline const G4String& GetName() const;
84 // Set/get region's name.
85
86 inline void RegionModified(G4bool flag);
87 inline G4bool IsModified() const;
88 // Accessors to flag identifying if a region has been modified
89 // (and still cuts needs to be computed) or not.
90
93
94 inline std::vector<G4LogicalVolume*>::iterator
96 inline std::vector<G4Material*>::const_iterator
98 // Return iterators to lists of root logical volumes and materials.
99
100 inline size_t GetNumberOfMaterials() const;
101 inline size_t GetNumberOfRootVolumes() const;
102 // Return the number of elements in the lists of materials and
103 // root logical volumes.
104
105 void UpdateMaterialList();
106 // Clears material list and recomputes it looping through
107 // each root logical volume in the region.
108
109 void ClearMaterialList();
110 // Clears the material list.
111
112 void ScanVolumeTree(G4LogicalVolume* lv, G4bool region);
113 // Scans recursively the 'lv' logical volume tree, retrieves
114 // and places all materials in the list if becoming a region.
115
118 // Set and Get methods for user information.
119
120 inline void SetUserLimits(G4UserLimits* ul);
122 // Set and Get methods for userL-limits associated to a region.
123 // Once user-limits are set, it will propagate to daughter volumes.
124
125 inline void ClearMap();
126 // Reset G4MaterialCoupleMap
127
129 G4MaterialCutsCouple* couple);
130 // Method invoked by G4ProductionCutsTable to register the pair.
131
133 // Find a G4MaterialCutsCouple which corresponds to the material
134 // in this region.
135
138 // Set and Get methods for G4FastSimulationManager.
139 // The root logical volume that has the region with G4FastSimulationManager
140 // becomes an envelope of fast simulation.
141
143 // Set G4FastSimulationManager pointer to the one for the parent region
144 // if it exists. Otherwise set to null.
145
148 // Set and Get methods for G4FieldManager.
149 // The region with assigned field-manager sets the field to the
150 // geometrical area associated with it; priority is anyhow given
151 // to local fields eventually set to logical volumes.
152
154 // Get method for the world physical volume which this region
155 // belongs to. A valid pointer will be assigned by G4RunManagerKernel
156 // through G4RegionStore when the geometry is to be closed. Thus, this
157 // pointer may be incorrect at PreInit and Idle state. If the pointer
158 // is null at the proper state, this particular region does not belong
159 // to any world (maybe not assigned to any volume, etc.).
160
161 void SetWorld(G4VPhysicalVolume* wp);
162 // Set the world physical volume if this region belongs to this world.
163 // If wp is null, reset the pointer.
164
165 G4bool BelongsTo(G4VPhysicalVolume* thePhys) const;
166 // Returns whether this region belongs to the given physical volume
167 // (recursively scanned to the bottom of the hierarchy).
168
169 G4Region* GetParentRegion(G4bool& unique) const;
170 // Returns a region that contains this region. Otherwise null returned.
171 // Flag 'unique' is true if there is only one parent region containing
172 // the current region.
173
176 // Set/Get method of the regional user stepping action
177
178 public: // without description
179
180 G4Region(__void__&);
181 // Fake default constructor for usage restricted to direct object
182 // persistency for clients requiring preallocation of memory for
183 // persistifiable objects.
184
185 inline void UsedInMassGeometry(G4bool val=true);
186 inline void UsedInParallelGeometry(G4bool val=true);
187 inline G4bool IsInMassGeometry() const;
189 // Utility methods to identify if region is part of the main mass
190 // geometry for tracking or a parallel geometry.
191
192 private:
193
194 G4Region(const G4Region&);
195 G4Region& operator=(const G4Region&);
196 // Private copy constructor and assignment operator.
197
198 inline void AddMaterial (G4Material* aMaterial);
199 // Searchs the specified material in the material table and
200 // if not present adds it.
201
202 private:
203
204 G4String fName;
205
206 G4RootLVList fRootVolumes;
207 G4MaterialList fMaterials;
208 G4MaterialCoupleMap fMaterialCoupleMap;
209
210 G4bool fRegionMod;
211 G4ProductionCuts* fCut;
212
213 G4VUserRegionInformation* fUserInfo;
214 G4UserLimits* fUserLimits;
215 G4FieldManager* fFieldManager;
216
217 G4FastSimulationManager* fFastSimulationManager;
218
219 G4VPhysicalVolume* fWorldPhys;
220
221 G4UserSteppingAction* fRegionalSteppingAction;
222
223 G4bool fInMassGeometry;
224 G4bool fInParallelGeometry;
225
226};
227
228#include "G4Region.icc"
229
230#endif
bool G4bool
Definition: G4Types.hh:67
G4bool IsModified() const
G4bool BelongsTo(G4VPhysicalVolume *thePhys) const
Definition: G4Region.cc:335
void ScanVolumeTree(G4LogicalVolume *lv, G4bool region)
Definition: G4Region.cc:106
void ClearMaterialList()
Definition: G4Region.cc:286
G4Region * GetParentRegion(G4bool &unique) const
Definition: G4Region.cc:390
G4FastSimulationManager * GetFastSimulationManager() const
virtual ~G4Region()
Definition: G4Region.cc:91
G4VUserRegionInformation * GetUserInformation() const
void SetWorld(G4VPhysicalVolume *wp)
Definition: G4Region.cc:319
G4bool IsInParallelGeometry() const
G4FieldManager * GetFieldManager() const
G4ProductionCuts * GetProductionCuts() const
void RemoveRootLogicalVolume(G4LogicalVolume *lv, G4bool scan=true)
Definition: G4Region.cc:256
G4MaterialCutsCouple * FindCouple(G4Material *mat)
void SetFieldManager(G4FieldManager *fm)
G4bool operator==(const G4Region &rg) const
void RegionModified(G4bool flag)
G4VPhysicalVolume * GetWorldPhysical() const
void SetProductionCuts(G4ProductionCuts *cut)
G4UserLimits * GetUserLimits() const
const G4String & GetName() const
void UpdateMaterialList()
Definition: G4Region.cc:297
void SetFastSimulationManager(G4FastSimulationManager *fsm)
void ClearMap()
void SetUserInformation(G4VUserRegionInformation *ui)
void SetRegionalSteppingAction(G4UserSteppingAction *rusa)
void SetName(const G4String &name)
G4bool IsInMassGeometry() const
size_t GetNumberOfRootVolumes() const
G4UserSteppingAction * GetRegionalSteppingAction() const
size_t GetNumberOfMaterials() const
void ClearFastSimulationManager()
Definition: G4Region.cc:355
void UsedInParallelGeometry(G4bool val=true)
void RegisterMaterialCouplePair(G4Material *mat, G4MaterialCutsCouple *couple)
std::vector< G4Material * >::const_iterator GetMaterialIterator() const
void AddRootLogicalVolume(G4LogicalVolume *lv)
Definition: G4Region.cc:227
void SetUserLimits(G4UserLimits *ul)
std::vector< G4LogicalVolume * >::iterator GetRootLogicalVolumeIterator()
void UsedInMassGeometry(G4bool val=true)