Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Region Class Reference

#include <G4Region.hh>

Public Member Functions

 G4Region (const G4String &name)
 
virtual ~G4Region ()
 
G4bool operator== (const G4Region &rg) const
 
void AddRootLogicalVolume (G4LogicalVolume *lv)
 
void RemoveRootLogicalVolume (G4LogicalVolume *lv, G4bool scan=true)
 
void SetName (const G4String &name)
 
const G4StringGetName () const
 
void RegionModified (G4bool flag)
 
G4bool IsModified () const
 
void SetProductionCuts (G4ProductionCuts *cut)
 
G4ProductionCutsGetProductionCuts () const
 
std::vector< G4LogicalVolume * >::iterator GetRootLogicalVolumeIterator ()
 
std::vector< G4Material * >::const_iterator GetMaterialIterator () const
 
size_t GetNumberOfMaterials () const
 
size_t GetNumberOfRootVolumes () const
 
void UpdateMaterialList ()
 
void ClearMaterialList ()
 
void ScanVolumeTree (G4LogicalVolume *lv, G4bool region)
 
void SetUserInformation (G4VUserRegionInformation *ui)
 
G4VUserRegionInformationGetUserInformation () const
 
void SetUserLimits (G4UserLimits *ul)
 
G4UserLimitsGetUserLimits () const
 
void ClearMap ()
 
void RegisterMaterialCouplePair (G4Material *mat, G4MaterialCutsCouple *couple)
 
G4MaterialCutsCoupleFindCouple (G4Material *mat)
 
void SetFastSimulationManager (G4FastSimulationManager *fsm)
 
G4FastSimulationManagerGetFastSimulationManager () const
 
void ClearFastSimulationManager ()
 
void SetFieldManager (G4FieldManager *fm)
 
G4FieldManagerGetFieldManager () const
 
G4VPhysicalVolumeGetWorldPhysical () const
 
void SetWorld (G4VPhysicalVolume *wp)
 
G4bool BelongsTo (G4VPhysicalVolume *thePhys) const
 
G4RegionGetParentRegion (G4bool &unique) const
 
void SetRegionalSteppingAction (G4UserSteppingAction *rusa)
 
G4UserSteppingActionGetRegionalSteppingAction () const
 
 G4Region (__void__ &)
 
void UsedInMassGeometry (G4bool val=true)
 
void UsedInParallelGeometry (G4bool val=true)
 
G4bool IsInMassGeometry () const
 
G4bool IsInParallelGeometry () const
 

Detailed Description

Definition at line 61 of file G4Region.hh.

Constructor & Destructor Documentation

◆ G4Region() [1/2]

G4Region::G4Region ( const G4String name)

Definition at line 48 of file G4Region.cc.

49 : fName(pName), fRegionMod(true), fCut(0), fUserInfo(0), fUserLimits(0),
50 fFieldManager(0), fFastSimulationManager(0), fWorldPhys(0),
51 fRegionalSteppingAction(0),
52 fInMassGeometry(false), fInParallelGeometry(false)
53{
55 if (rStore->GetRegion(pName,false))
56 {
57 std::ostringstream message;
58 message << "The region has NOT been registered !" << G4endl
59 << " Region " << pName << " already existing in store !"
60 << G4endl;
61 G4Exception("G4Region::G4Region()", "GeomMgt1001",
62 JustWarning, message);
63 }
64 else
65 {
66 rStore->Register(this);
67 }
68}
@ JustWarning
#define G4endl
Definition: G4ios.hh:52
static G4RegionStore * GetInstance()
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
static void Register(G4Region *pSolid)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

◆ ~G4Region()

G4Region::~G4Region ( )
virtual

Definition at line 91 of file G4Region.cc.

92{
94 if(fUserInfo) delete fUserInfo;
95}
static void DeRegister(G4Region *pSolid)

◆ G4Region() [2/2]

G4Region::G4Region ( __void__ &  )

Definition at line 75 of file G4Region.cc.

76 : fName(""), fRegionMod(true), fCut(0), fUserInfo(0), fUserLimits(0),
77 fFieldManager(0), fFastSimulationManager(0), fWorldPhys(0),
78 fRegionalSteppingAction(0),
79 fInMassGeometry(false), fInParallelGeometry(false)
80{
81 // Register to store
82 //
84}

Member Function Documentation

◆ AddRootLogicalVolume()

void G4Region::AddRootLogicalVolume ( G4LogicalVolume lv)

Definition at line 227 of file G4Region.cc.

228{
229 // Check the logical volume is not already in the list
230 //
231 G4RootLVList::iterator pos;
232 pos = std::find(fRootVolumes.begin(),fRootVolumes.end(),lv);
233 if (pos == fRootVolumes.end())
234 {
235 // Insert the root volume in the list and set it as root region
236 //
237 fRootVolumes.push_back(lv);
238 lv->SetRegionRootFlag(true);
239 }
240
241 // Scan recursively the tree of daugther volumes and set regions
242 //
243 ScanVolumeTree(lv, true);
244
245 // Set region as modified
246 //
247 fRegionMod = true;
248}
void SetRegionRootFlag(G4bool rreg)
void ScanVolumeTree(G4LogicalVolume *lv, G4bool region)
Definition: G4Region.cc:106

Referenced by G4RunManagerKernel::DefineWorldVolume().

◆ BelongsTo()

G4bool G4Region::BelongsTo ( G4VPhysicalVolume thePhys) const

Definition at line 335 of file G4Region.cc.

336{
337 G4LogicalVolume* currLog = thePhys->GetLogicalVolume();
338 if (currLog->GetRegion()==this) {return true;}
339
340 G4int nDaughters = currLog->GetNoDaughters();
341 while (nDaughters--)
342 {
343 if (BelongsTo(currLog->GetDaughter(nDaughters))) {return true;}
344 }
345
346 return false;
347}
int G4int
Definition: G4Types.hh:66
G4int GetNoDaughters() const
G4Region * GetRegion() const
G4VPhysicalVolume * GetDaughter(const G4int i) const
G4bool BelongsTo(G4VPhysicalVolume *thePhys) const
Definition: G4Region.cc:335
G4LogicalVolume * GetLogicalVolume() const

Referenced by BelongsTo(), and SetWorld().

◆ ClearFastSimulationManager()

void G4Region::ClearFastSimulationManager ( )

Definition at line 355 of file G4Region.cc.

356{
357 G4bool isUnique;
358 G4Region* parent = GetParentRegion(isUnique);
359 if(parent)
360 {
361 if (isUnique)
362 {
363 fFastSimulationManager = parent->GetFastSimulationManager();
364 }
365 else
366 {
367 std::ostringstream message;
368 message << "Region <" << fName << "> belongs to more than"
369 << " one parent region !" << G4endl
370 << "A region cannot belong to more than one direct parent region,"
371 << G4endl
372 << "to have fast-simulation assigned.";
373 G4Exception("G4Region::ClearFastSimulationManager()",
374 "GeomMgt1002", JustWarning, message);
375 fFastSimulationManager = 0;
376 }
377 }
378 else
379 {
380 fFastSimulationManager = 0;
381 }
382}
bool G4bool
Definition: G4Types.hh:67
G4Region * GetParentRegion(G4bool &unique) const
Definition: G4Region.cc:390
G4FastSimulationManager * GetFastSimulationManager() const

Referenced by G4FastSimulationManager::~G4FastSimulationManager().

◆ ClearMap()

void G4Region::ClearMap ( )
inline

◆ ClearMaterialList()

void G4Region::ClearMaterialList ( )

Definition at line 286 of file G4Region.cc.

287{
288 fMaterials.clear();
289}

Referenced by UpdateMaterialList().

◆ FindCouple()

G4MaterialCutsCouple * G4Region::FindCouple ( G4Material mat)
inline

◆ GetFastSimulationManager()

◆ GetFieldManager()

G4FieldManager * G4Region::GetFieldManager ( ) const
inline

◆ GetMaterialIterator()

std::vector< G4Material * >::const_iterator G4Region::GetMaterialIterator ( ) const
inline

◆ GetName()

◆ GetNumberOfMaterials()

size_t G4Region::GetNumberOfMaterials ( ) const
inline

◆ GetNumberOfRootVolumes()

size_t G4Region::GetNumberOfRootVolumes ( ) const
inline

◆ GetParentRegion()

G4Region * G4Region::GetParentRegion ( G4bool unique) const

Definition at line 390 of file G4Region.cc.

391{
392 G4Region* parent = 0; unique = true;
394 G4LogicalVolumeStore::iterator lvItr;
395
396 // Loop over all logical volumes in the store
397 //
398 for(lvItr=lvStore->begin(); lvItr!=lvStore->end(); lvItr++)
399 {
400 G4int nD = (*lvItr)->GetNoDaughters();
401 G4Region* aR = (*lvItr)->GetRegion();
402
403 // Loop over all daughters of each logical volume
404 //
405 for(G4int iD=0; iD<nD; iD++)
406 {
407 if((*lvItr)->GetDaughter(iD)->GetLogicalVolume()->GetRegion()==this)
408 {
409 if(parent)
410 {
411 if(parent!=aR) { unique = false; }
412 }
413 else // Cache LV parent region which includes a daughter volume
414 // with the same associated region as the current one
415 {
416 parent = aR;
417 }
418 }
419 }
420 }
421 return parent;
422}
static G4LogicalVolumeStore * GetInstance()

Referenced by ClearFastSimulationManager().

◆ GetProductionCuts()

◆ GetRegionalSteppingAction()

G4UserSteppingAction * G4Region::GetRegionalSteppingAction ( ) const
inline

◆ GetRootLogicalVolumeIterator()

std::vector< G4LogicalVolume * >::iterator G4Region::GetRootLogicalVolumeIterator ( )
inline

◆ GetUserInformation()

G4VUserRegionInformation * G4Region::GetUserInformation ( ) const
inline

◆ GetUserLimits()

G4UserLimits * G4Region::GetUserLimits ( ) const
inline

◆ GetWorldPhysical()

G4VPhysicalVolume * G4Region::GetWorldPhysical ( ) const
inline

◆ IsInMassGeometry()

G4bool G4Region::IsInMassGeometry ( ) const
inline

◆ IsInParallelGeometry()

G4bool G4Region::IsInParallelGeometry ( ) const
inline

◆ IsModified()

G4bool G4Region::IsModified ( ) const
inline

◆ operator==()

G4bool G4Region::operator== ( const G4Region rg) const
inline

◆ RegionModified()

void G4Region::RegionModified ( G4bool  flag)
inline

◆ RegisterMaterialCouplePair()

void G4Region::RegisterMaterialCouplePair ( G4Material mat,
G4MaterialCutsCouple couple 
)
inline

◆ RemoveRootLogicalVolume()

void G4Region::RemoveRootLogicalVolume ( G4LogicalVolume lv,
G4bool  scan = true 
)

Definition at line 256 of file G4Region.cc.

257{
258 // Find and remove logical volume from the list
259 //
260 G4RootLVList::iterator pos;
261 pos = std::find(fRootVolumes.begin(),fRootVolumes.end(),lv);
262 if (pos != fRootVolumes.end())
263 {
264 if (fRootVolumes.size() != 1) // Avoid resetting flag for world since
265 { // volume may be already deleted !
266 lv->SetRegionRootFlag(false);
267 }
268 fRootVolumes.erase(pos);
269 }
270
271 if (scan) // Update the materials list
272 {
274 }
275
276 // Set region as modified
277 //
278 fRegionMod = true;
279}
void UpdateMaterialList()
Definition: G4Region.cc:297

Referenced by G4RunManagerKernel::DefineWorldVolume(), and G4LogicalVolume::~G4LogicalVolume().

◆ ScanVolumeTree()

void G4Region::ScanVolumeTree ( G4LogicalVolume lv,
G4bool  region 
)

Definition at line 106 of file G4Region.cc.

107{
108 // If logical volume is going to become a region, add
109 // its material to the list if not already present
110 //
111 G4Region* currentRegion = 0;
112 size_t noDaughters = lv->GetNoDaughters();
113 G4Material* volMat = lv->GetMaterial();
114 if(!volMat && fInMassGeometry)
115 {
116 std::ostringstream message;
117 message << "Logical volume <" << lv->GetName() << ">" << G4endl
118 << "does not have a valid material pointer." << G4endl
119 << "A logical volume belonging to the (tracking) world volume "
120 << "must have a valid material.";
121 G4Exception("G4Region::ScanVolumeTree()", "GeomMgt0002",
122 FatalException, message, "Check your geometry construction.");
123 }
124 if (region)
125 {
126 currentRegion = this;
127 if (volMat)
128 {
129 AddMaterial(volMat);
130 G4Material* baseMat = const_cast<G4Material*>(volMat->GetBaseMaterial());
131 if (baseMat) { AddMaterial(baseMat); }
132 }
133 }
134
135 // Set the LV region to be either the current region or NULL,
136 // according to the boolean selector
137 //
138 lv->SetRegion(currentRegion);
139
140 // Stop recursion here if no further daughters are involved
141 //
142 if(noDaughters==0) return;
143
144 G4VPhysicalVolume* daughterPVol = lv->GetDaughter(0);
145 if (daughterPVol->IsParameterised())
146 {
147 // Adopt special treatment in case of parameterised volumes,
148 // where parameterisation involves a new material scan
149 //
150 G4VPVParameterisation* pParam = daughterPVol->GetParameterisation();
151
152 if (pParam->GetMaterialScanner())
153 {
154 size_t matNo = pParam->GetMaterialScanner()->GetNumberOfMaterials();
155 for (register size_t mat=0; mat<matNo; mat++)
156 {
157 volMat = pParam->GetMaterialScanner()->GetMaterial(mat);
158 if(!volMat && fInMassGeometry)
159 {
160 std::ostringstream message;
161 message << "The parameterisation for the physical volume <"
162 << daughterPVol->GetName() << ">" << G4endl
163 << "does not return a valid material pointer." << G4endl
164 << "A volume belonging to the (tracking) world volume must "
165 << "have a valid material.";
166 G4Exception("G4Region::ScanVolumeTree()", "GeomMgt0002",
167 FatalException, message, "Check your parameterisation.");
168 }
169 if (volMat)
170 {
171 AddMaterial(volMat);
172 G4Material* baseMat = const_cast<G4Material*>(volMat->GetBaseMaterial());
173 if (baseMat) { AddMaterial(baseMat); }
174 }
175 }
176 }
177 else
178 {
179 size_t repNo = daughterPVol->GetMultiplicity();
180 for (register size_t rep=0; rep<repNo; rep++)
181 {
182 volMat = pParam->ComputeMaterial(rep, daughterPVol);
183 if(!volMat && fInMassGeometry)
184 {
185 std::ostringstream message;
186 message << "The parameterisation for the physical volume <"
187 << daughterPVol->GetName() << ">" << G4endl
188 << "does not return a valid material pointer." << G4endl
189 << "A volume belonging to the (tracking) world volume must "
190 << "have a valid material.";
191 G4Exception("G4Region::ScanVolumeTree()", "GeomMgt0002",
192 FatalException, message, "Check your parameterisation.");
193 }
194 if(volMat)
195 {
196 AddMaterial(volMat);
197 G4Material* baseMat = const_cast<G4Material*>(volMat->GetBaseMaterial());
198 if (baseMat) { AddMaterial(baseMat); }
199 }
200 }
201 }
202 G4LogicalVolume* daughterLVol = daughterPVol->GetLogicalVolume();
203 ScanVolumeTree(daughterLVol, region);
204 }
205 else
206 {
207 for (register size_t i=0; i<noDaughters; i++)
208 {
209 G4LogicalVolume* daughterLVol = lv->GetDaughter(i)->GetLogicalVolume();
210 if (!daughterLVol->IsRootRegion())
211 {
212 // Set daughter's LV to be a region and store materials in
213 // the materials list, if the LV is not already a root region
214 //
215 ScanVolumeTree(daughterLVol, region);
216 }
217 }
218 }
219}
@ FatalException
G4String GetName() const
void SetRegion(G4Region *reg)
G4bool IsRootRegion() const
G4Material * GetMaterial() const
const G4Material * GetBaseMaterial() const
Definition: G4Material.hh:232
virtual G4Material * ComputeMaterial(const G4int repNo, G4VPhysicalVolume *currentVol, const G4VTouchable *parentTouch=0)
virtual G4VVolumeMaterialScanner * GetMaterialScanner()
virtual G4int GetMultiplicity() const
const G4String & GetName() const
virtual G4VPVParameterisation * GetParameterisation() const =0
virtual G4bool IsParameterised() const =0
virtual G4Material * GetMaterial(G4int idx) const =0
virtual G4int GetNumberOfMaterials() const =0

Referenced by AddRootLogicalVolume(), ScanVolumeTree(), and UpdateMaterialList().

◆ SetFastSimulationManager()

void G4Region::SetFastSimulationManager ( G4FastSimulationManager fsm)
inline

◆ SetFieldManager()

void G4Region::SetFieldManager ( G4FieldManager fm)
inline

◆ SetName()

void G4Region::SetName ( const G4String name)
inline

◆ SetProductionCuts()

void G4Region::SetProductionCuts ( G4ProductionCuts cut)
inline

◆ SetRegionalSteppingAction()

void G4Region::SetRegionalSteppingAction ( G4UserSteppingAction rusa)
inline

◆ SetUserInformation()

void G4Region::SetUserInformation ( G4VUserRegionInformation ui)
inline

◆ SetUserLimits()

void G4Region::SetUserLimits ( G4UserLimits ul)
inline

◆ SetWorld()

void G4Region::SetWorld ( G4VPhysicalVolume wp)

Definition at line 319 of file G4Region.cc.

320{
321 if(!wp)
322 { fWorldPhys = 0; }
323 else
324 { if(BelongsTo(wp)) fWorldPhys = wp; }
325
326 return;
327}

◆ UpdateMaterialList()

void G4Region::UpdateMaterialList ( )

Definition at line 297 of file G4Region.cc.

298{
299 // Reset the materials list
300 //
302
303 // Loop over the root logical volumes and rebuild the list
304 // of materials from scratch
305 //
306 G4RootLVList::iterator pLV;
307 for (pLV=fRootVolumes.begin(); pLV!=fRootVolumes.end(); pLV++)
308 {
309 ScanVolumeTree(*pLV, true);
310 }
311}
void ClearMaterialList()
Definition: G4Region.cc:286

Referenced by RemoveRootLogicalVolume().

◆ UsedInMassGeometry()

void G4Region::UsedInMassGeometry ( G4bool  val = true)
inline

◆ UsedInParallelGeometry()

void G4Region::UsedInParallelGeometry ( G4bool  val = true)
inline

The documentation for this class was generated from the following files: