Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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: G4Region.hh 99379 2016-09-20 09:45:19Z gcosmo $
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 
43 #include <vector>
44 #include <map>
45 #include <algorithm>
46 
47 #include "G4Types.hh"
48 #include "G4String.hh"
49 #include "G4GeomSplitter.hh"
50 
51 class G4ProductionCuts;
52 class G4LogicalVolume;
53 class G4Material;
56 class G4UserLimits;
57 class G4FieldManager;
59 class G4VPhysicalVolume;
61 
63 {
64  // Encapsulates the fields associated to the class
65  // G4Region that may not be read-only.
66 
67  public:
68 
69  void initialize()
70  {
73  }
74 
77 };
78 
79 // The type G4RegionManager is introduced to encapsulate the methods used by
80 // both the master thread and worker threads to allocate memory space for
81 // the fields encapsulated by the class G4RegionData. When each thread
82 // initializes the value for these fields, it refers to them using a macro
83 // definition defined below. For every G4Region instance, there is a
84 // corresponding G4RegionData instance. All G4RegionData instances are
85 // organized by the class G4RegionManager as an array.
86 // The field "int instanceID" is added to the class G4Region.
87 // The value of this field in each G4Region instance is the subscript
88 // of the corresponding G4RegionData instance.
89 // In order to use the class G4RegionManager, we add a static member in
90 // the class G4Region as follows: "static G4RegionManager subInstanceManager".
91 // For the master thread, the array for G4RegionData instances grows
92 // dynamically along with G4Region instances are created. For each worker
93 // thread, it copies the array of G4RegionData instances from the master thread.
94 // In addition, it invokes a method similiar to the constructor explicitly
95 // to achieve the partial effect for each instance in the array.
96 //
98 
99 class G4Region
100 {
101  typedef std::vector<G4LogicalVolume*> G4RootLVList;
102  typedef std::vector<G4Material*> G4MaterialList;
103  typedef std::pair<G4Material*,G4MaterialCutsCouple*> G4MaterialCouplePair;
104  typedef std::map<G4Material*,G4MaterialCutsCouple*> G4MaterialCoupleMap;
105 
106  public: // with description
107 
108  G4Region(const G4String& name);
109  virtual ~G4Region();
110 
111  inline G4bool operator==(const G4Region& rg) const;
112  // Equality defined by address only.
113 
115  void RemoveRootLogicalVolume(G4LogicalVolume* lv, G4bool scan=true);
116  // Add/remove root logical volumes and set/reset their
117  // daughters flags as regions. They also recompute the
118  // materials list for the region.
119 
120  inline void SetName(const G4String& name);
121  inline const G4String& GetName() const;
122  // Set/get region's name.
123 
124  inline void RegionModified(G4bool flag);
125  inline G4bool IsModified() const;
126  // Accessors to flag identifying if a region has been modified
127  // (and still cuts needs to be computed) or not.
128 
129  inline void SetProductionCuts(G4ProductionCuts* cut);
130  inline G4ProductionCuts* GetProductionCuts() const;
131 
132  inline std::vector<G4LogicalVolume*>::iterator
134  inline std::vector<G4Material*>::const_iterator
135  GetMaterialIterator() const;
136  // Return iterators to lists of root logical volumes and materials.
137 
138  inline size_t GetNumberOfMaterials() const;
139  inline size_t GetNumberOfRootVolumes() const;
140  // Return the number of elements in the lists of materials and
141  // root logical volumes.
142 
143  void UpdateMaterialList();
144  // Clears material list and recomputes it looping through
145  // each root logical volume in the region.
146 
147  void ClearMaterialList();
148  // Clears the material list.
149 
150  void ScanVolumeTree(G4LogicalVolume* lv, G4bool region);
151  // Scans recursively the 'lv' logical volume tree, retrieves
152  // and places all materials in the list if becoming a region.
153 
156  // Set and Get methods for user information.
157 
158  inline void SetUserLimits(G4UserLimits* ul);
159  inline G4UserLimits* GetUserLimits() const;
160  // Set and Get methods for userL-limits associated to a region.
161  // Once user-limits are set, it will propagate to daughter volumes.
162 
163  inline void ClearMap();
164  // Reset G4MaterialCoupleMap
165 
166  inline void RegisterMaterialCouplePair(G4Material* mat,
167  G4MaterialCutsCouple* couple);
168  // Method invoked by G4ProductionCutsTable to register the pair.
169 
171  // Find a G4MaterialCutsCouple which corresponds to the material
172  // in this region.
173 
176  // Set and Get methods for G4FastSimulationManager.
177  // The root logical volume that has the region with G4FastSimulationManager
178  // becomes an envelope of fast simulation.
179 
181  // Set G4FastSimulationManager pointer to the one for the parent region
182  // if it exists. Otherwise set to null.
183 
184  inline void SetFieldManager(G4FieldManager* fm);
185  inline G4FieldManager* GetFieldManager() const;
186  // Set and Get methods for G4FieldManager.
187  // The region with assigned field-manager sets the field to the
188  // geometrical area associated with it; priority is anyhow given
189  // to local fields eventually set to logical volumes.
190 
191  inline G4VPhysicalVolume* GetWorldPhysical() const;
192  // Get method for the world physical volume which this region
193  // belongs to. A valid pointer will be assigned by G4RunManagerKernel
194  // through G4RegionStore when the geometry is to be closed. Thus, this
195  // pointer may be incorrect at PreInit and Idle state. If the pointer
196  // is null at the proper state, this particular region does not belong
197  // to any world (maybe not assigned to any volume, etc.).
198 
200  // Set the world physical volume if this region belongs to this world.
201  // If wp is null, reset the pointer.
202 
203  G4bool BelongsTo(G4VPhysicalVolume* thePhys) const;
204  // Returns whether this region belongs to the given physical volume
205  // (recursively scanned to the bottom of the hierarchy).
206 
207  G4Region* GetParentRegion(G4bool& unique) const;
208  // Returns a region that contains this region. Otherwise null returned.
209  // Flag 'unique' is true if there is only one parent region containing
210  // the current region.
211 
214  // Set/Get method of the regional user stepping action
215 
216  public: // without description
217 
218  G4Region(__void__&);
219  // Fake default constructor for usage restricted to direct object
220  // persistency for clients requiring preallocation of memory for
221  // persistifiable objects.
222 
223  inline G4int GetInstanceID() const;
224  // Returns the instance ID.
225 
226  static const G4RegionManager& GetSubInstanceManager();
227  // Returns the private data instance manager.
228 
229  inline void UsedInMassGeometry(G4bool val=true);
230  inline void UsedInParallelGeometry(G4bool val=true);
231  inline G4bool IsInMassGeometry() const;
232  inline G4bool IsInParallelGeometry() const;
233  // Utility methods to identify if region is part of the main mass
234  // geometry for tracking or a parallel geometry.
235 
236  private:
237 
238  G4Region(const G4Region&);
239  G4Region& operator=(const G4Region&);
240  // Private copy constructor and assignment operator.
241 
242  inline void AddMaterial (G4Material* aMaterial);
243  // Searchs the specified material in the material table and
244  // if not present adds it.
245 
246  private:
247 
248  G4String fName;
249 
250  G4RootLVList fRootVolumes;
251  G4MaterialList fMaterials;
252  G4MaterialCoupleMap fMaterialCoupleMap;
253 
254  G4bool fRegionMod;
255  G4ProductionCuts* fCut;
256 
257  G4VUserRegionInformation* fUserInfo;
258  G4UserLimits* fUserLimits;
259  G4FieldManager* fFieldManager;
260 
261  G4VPhysicalVolume* fWorldPhys;
262 
263  G4bool fInMassGeometry;
264  G4bool fInParallelGeometry;
265 
266  G4int instanceID;
267  // This field is used as instance ID.
268  G4GEOM_DLL static G4RegionManager subInstanceManager;
269  // This field helps to use the class G4RegionManager introduced above.
270 };
271 
272 #include "G4Region.icc"
273 
274 #endif
void RegisterMaterialCouplePair(G4Material *mat, G4MaterialCutsCouple *couple)
const XML_Char * name
Definition: expat.h:151
void SetUserInformation(G4VUserRegionInformation *ui)
G4ProductionCuts * GetProductionCuts() const
std::vector< G4Material * >::const_iterator GetMaterialIterator() const
G4bool operator==(const G4Region &rg) const
const G4String & GetName() const
G4UserSteppingAction * GetRegionalSteppingAction() const
Definition: G4Region.cc:155
void AddRootLogicalVolume(G4LogicalVolume *lv)
Definition: G4Region.cc:290
void UsedInParallelGeometry(G4bool val=true)
G4int GetInstanceID() const
G4bool IsModified() const
G4VUserRegionInformation * GetUserInformation() const
void RegionModified(G4bool flag)
void ClearMap()
int G4int
Definition: G4Types.hh:78
static unsigned wp
Definition: csz_inflate.cc:294
void initialize()
Definition: G4Region.hh:69
void SetFastSimulationManager(G4FastSimulationManager *fsm)
Definition: G4Region.cc:128
G4UserSteppingAction * fRegionalSteppingAction
Definition: G4Region.hh:76
G4VPhysicalVolume * GetWorldPhysical() const
G4Region(const G4String &name)
Definition: G4Region.cc:68
void ScanVolumeTree(G4LogicalVolume *lv, G4bool region)
Definition: G4Region.cc:169
void SetName(const G4String &name)
bool G4bool
Definition: G4Types.hh:79
void UsedInMassGeometry(G4bool val=true)
void ClearFastSimulationManager()
Definition: G4Region.cc:418
G4MaterialCutsCouple * FindCouple(G4Material *mat)
G4FastSimulationManager * fFastSimulationManager
Definition: G4Region.hh:75
G4FieldManager * GetFieldManager() const
G4bool BelongsTo(G4VPhysicalVolume *thePhys) const
Definition: G4Region.cc:398
void SetWorld(G4VPhysicalVolume *wp)
Definition: G4Region.cc:382
G4Region * GetParentRegion(G4bool &unique) const
Definition: G4Region.cc:453
G4bool IsInMassGeometry() const
void SetProductionCuts(G4ProductionCuts *cut)
void SetUserLimits(G4UserLimits *ul)
virtual ~G4Region()
Definition: G4Region.cc:118
void UpdateMaterialList()
Definition: G4Region.cc:360
void SetRegionalSteppingAction(G4UserSteppingAction *rusa)
Definition: G4Region.cc:146
size_t GetNumberOfMaterials() const
size_t GetNumberOfRootVolumes() const
G4GeomSplitter< G4RegionData > G4RegionManager
Definition: G4Region.hh:97
void RemoveRootLogicalVolume(G4LogicalVolume *lv, G4bool scan=true)
Definition: G4Region.cc:319
static const G4RegionManager & GetSubInstanceManager()
Definition: G4Region.cc:58
G4bool IsInParallelGeometry() const
#define G4GEOM_DLL
Definition: geomwdefs.hh:48
void SetFieldManager(G4FieldManager *fm)
G4FastSimulationManager * GetFastSimulationManager() const
Definition: G4Region.cc:137
G4UserLimits * GetUserLimits() const
void ClearMaterialList()
Definition: G4Region.cc:349
std::vector< G4LogicalVolume * >::iterator GetRootLogicalVolumeIterator()