Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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$
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 class G4ProductionCuts;
44 class G4LogicalVolume;
45 class G4Material;
48 class G4UserLimits;
49 class G4FieldManager;
51 class G4VPhysicalVolume;
53 
54 #include <vector>
55 #include <map>
56 #include <algorithm>
57 
58 #include "G4Types.hh"
59 #include "G4String.hh"
60 
61 class G4Region
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 
77  void RemoveRootLogicalVolume(G4LogicalVolume* lv, G4bool scan=true);
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 
91  inline void SetProductionCuts(G4ProductionCuts* cut);
92  inline G4ProductionCuts* GetProductionCuts() const;
93 
94  inline std::vector<G4LogicalVolume*>::iterator
96  inline std::vector<G4Material*>::const_iterator
97  GetMaterialIterator() const;
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);
121  inline G4UserLimits* GetUserLimits() const;
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 
146  inline void SetFieldManager(G4FieldManager* fm);
147  inline G4FieldManager* GetFieldManager() const;
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 
153  inline G4VPhysicalVolume* GetWorldPhysical() const;
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;
188  inline G4bool IsInParallelGeometry() 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