Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4Region.hh
이 파일의 문서화 페이지로 가기
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 103096 2017-03-15 15:21:33Z 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 
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  static void Clean();
230  // Clear memory allocated by sub-instance manager.
231 
232  inline void UsedInMassGeometry(G4bool val=true);
233  inline void UsedInParallelGeometry(G4bool val=true);
234  inline G4bool IsInMassGeometry() const;
235  inline G4bool IsInParallelGeometry() const;
236  // Utility methods to identify if region is part of the main mass
237  // geometry for tracking or a parallel geometry.
238 
239  private:
240 
241  G4Region(const G4Region&);
242  G4Region& operator=(const G4Region&);
243  // Private copy constructor and assignment operator.
244 
245  inline void AddMaterial (G4Material* aMaterial);
246  // Searchs the specified material in the material table and
247  // if not present adds it.
248 
249  private:
250 
252 
256 
259 
263 
265 
268 
270  // This field is used as instance ID.
272  // This field helps to use the class G4RegionManager introduced above.
273 };
274 
275 #include "G4Region.icc"
276 
277 #endif
void ClearMap()
void AddRootLogicalVolume(G4LogicalVolume *lv)
Definition: G4Region.cc:290
G4bool IsModified() const
const XML_Char * name
Definition: expat.h:151
G4FastSimulationManager * GetFastSimulationManager() const
Definition: G4Region.cc:137
G4int instanceID
Definition: G4Region.hh:269
G4Region(const G4String &name)
Definition: G4Region.cc:68
G4UserLimits * fUserLimits
Definition: G4Region.hh:261
G4VPhysicalVolume * fWorldPhys
Definition: G4Region.hh:264
G4bool operator==(const G4Region &rg) const
void SetFieldManager(G4FieldManager *fm)
G4bool IsInMassGeometry() const
void SetUserLimits(G4UserLimits *ul)
const G4String & GetName() const
std::vector< G4LogicalVolume * > G4RootLVList
Definition: G4Region.hh:101
G4bool IsInParallelGeometry() const
static const G4RegionManager & GetSubInstanceManager()
Definition: G4Region.cc:58
G4UserSteppingAction * GetRegionalSteppingAction() const
Definition: G4Region.cc:155
void SetWorld(G4VPhysicalVolume *wp)
Definition: G4Region.cc:391
G4int GetInstanceID() const
void SetProductionCuts(G4ProductionCuts *cut)
G4RootLVList fRootVolumes
Definition: G4Region.hh:253
G4bool fInParallelGeometry
Definition: G4Region.hh:267
void RegisterMaterialCouplePair(G4Material *mat, G4MaterialCutsCouple *couple)
G4UserLimits * GetUserLimits() const
void RemoveRootLogicalVolume(G4LogicalVolume *lv, G4bool scan=true)
Definition: G4Region.cc:319
G4FieldManager * GetFieldManager() const
size_t GetNumberOfMaterials() const
G4MaterialList fMaterials
Definition: G4Region.hh:254
static unsigned wp
Definition: csz_inflate.cc:294
G4ProductionCuts * fCut
Definition: G4Region.hh:258
G4String fName
Definition: G4Region.hh:251
G4FastSimulationManager * fFastSimulationManager
Definition: G4Region.hh:75
G4bool fInMassGeometry
Definition: G4Region.hh:266
bool G4bool
Definition: G4Types.hh:79
static void Clean()
Definition: G4Region.cc:348
G4GeomSplitter< G4RegionData > G4RegionManager
Definition: G4Region.hh:97
void SetUserInformation(G4VUserRegionInformation *ui)
std::vector< G4Material * >::const_iterator GetMaterialIterator() const
Float_t mat
G4bool BelongsTo(G4VPhysicalVolume *thePhys) const
Definition: G4Region.cc:407
G4ProductionCuts * GetProductionCuts() const
G4VUserRegionInformation * fUserInfo
Definition: G4Region.hh:260
void UsedInParallelGeometry(G4bool val=true)
G4VPhysicalVolume * GetWorldPhysical() const
void AddMaterial(G4Material *aMaterial)
void UpdateMaterialList()
Definition: G4Region.cc:369
std::vector< G4LogicalVolume * >::iterator GetRootLogicalVolumeIterator()
void ScanVolumeTree(G4LogicalVolume *lv, G4bool region)
Definition: G4Region.cc:169
int G4int
Definition: G4Types.hh:78
G4bool fRegionMod
Definition: G4Region.hh:257
std::map< G4Material *, G4MaterialCutsCouple * > G4MaterialCoupleMap
Definition: G4Region.hh:104
G4FieldManager * fFieldManager
Definition: G4Region.hh:262
void SetFastSimulationManager(G4FastSimulationManager *fsm)
Definition: G4Region.cc:128
G4Region * GetParentRegion(G4bool &unique) const
Definition: G4Region.cc:462
G4MaterialCoupleMap fMaterialCoupleMap
Definition: G4Region.hh:255
void SetRegionalSteppingAction(G4UserSteppingAction *rusa)
Definition: G4Region.cc:146
static G4GEOM_DLL G4RegionManager subInstanceManager
Definition: G4Region.hh:271
G4MaterialCutsCouple * FindCouple(G4Material *mat)
G4UserSteppingAction * fRegionalSteppingAction
Definition: G4Region.hh:76
void ClearFastSimulationManager()
Definition: G4Region.cc:427
void RegionModified(G4bool flag)
std::vector< G4Material * > G4MaterialList
Definition: G4Region.hh:102
void SetName(const G4String &name)
#define G4GEOM_DLL
Definition: geomwdefs.hh:48
virtual ~G4Region()
Definition: G4Region.cc:118
void initialize()
Definition: G4Region.hh:69
void UsedInMassGeometry(G4bool val=true)
G4Region & operator=(const G4Region &)
void ClearMaterialList()
Definition: G4Region.cc:358
std::pair< G4Material *, G4MaterialCutsCouple * > G4MaterialCouplePair
Definition: G4Region.hh:103
G4VUserRegionInformation * GetUserInformation() const
size_t GetNumberOfRootVolumes() const