Geant4 11.1.1
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 ()
 
 G4Region (const G4Region &)=delete
 
G4Regionoperator= (const G4Region &)=delete
 
G4bool operator== (const G4Region &rg) const
 
void AddRootLogicalVolume (G4LogicalVolume *lv, G4bool search=true)
 
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
 
std::size_t GetNumberOfMaterials () const
 
std::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__ &)
 
G4int GetInstanceID () const
 
void UsedInMassGeometry (G4bool val=true)
 
void UsedInParallelGeometry (G4bool val=true)
 
G4bool IsInMassGeometry () const
 
G4bool IsInParallelGeometry () const
 

Static Public Member Functions

static const G4RegionManagerGetSubInstanceManager ()
 
static void Clean ()
 

Detailed Description

Definition at line 95 of file G4Region.hh.

Constructor & Destructor Documentation

◆ G4Region() [1/3]

G4Region::G4Region ( const G4String name)

Definition at line 65 of file G4Region.cc.

66 : fName(pName)
67{
68
69 instanceID = subInstanceManager.CreateSubInstance();
70 G4MT_fsmanager = nullptr;
71 G4MT_rsaction = nullptr;
72
74 if (rStore->GetRegion(pName, false))
75 {
76 std::ostringstream message;
77 message << "The region has NOT been registered !" << G4endl
78 << " Region " << pName << " already existing in store !"
79 << G4endl;
80 G4Exception("G4Region::G4Region()", "GeomMgt1001",
81 JustWarning, message);
82 }
83 else
84 {
85 rStore->Register(this);
86 }
87}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
#define G4MT_rsaction
Definition: G4Region.cc:44
#define G4MT_fsmanager
Definition: G4Region.cc:43
#define G4endl
Definition: G4ios.hh:57
G4int CreateSubInstance()
static void Register(G4Region *pRegion)
static G4RegionStore * GetInstance()
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const

◆ ~G4Region()

G4Region::~G4Region ( )
virtual

Definition at line 111 of file G4Region.cc.

112{
114 if(fUserInfo != nullptr) { delete fUserInfo; }
115}
static void DeRegister(G4Region *pRegion)

◆ G4Region() [2/3]

G4Region::G4Region ( const G4Region )
delete

◆ G4Region() [3/3]

G4Region::G4Region ( __void__ &  )

Definition at line 94 of file G4Region.cc.

95 : fName("")
96{
97 instanceID = subInstanceManager.CreateSubInstance();
98 G4MT_fsmanager = nullptr;
99 G4MT_rsaction = nullptr;
100
101 // Register to store
102 //
104}

Member Function Documentation

◆ AddRootLogicalVolume()

void G4Region::AddRootLogicalVolume ( G4LogicalVolume lv,
G4bool  search = true 
)

Definition at line 293 of file G4Region.cc.

294{
295 // Check the logical volume is not already in the list
296 //
297 if (search)
298 {
299 auto pos = std::find(fRootVolumes.cbegin(),fRootVolumes.cend(),lv);
300 if (pos == fRootVolumes.cend())
301 {
302 // Insert the root volume in the list and set it as root region
303 //
304 fRootVolumes.push_back(lv);
305 lv->SetRegionRootFlag(true);
306 }
307 }
308 else // WARNING: user *MUST* guarantee lv is not already inserted.
309 { // Providing speedup for very complex flat geometries
310 fRootVolumes.push_back(lv);
311 lv->SetRegionRootFlag(true);
312 }
313 // Scan recursively the tree of daugther volumes and set regions
314 //
315 ScanVolumeTree(lv, true);
316
317 // Set region as modified
318 //
319 fRegionMod = true;
320}
void SetRegionRootFlag(G4bool rreg)
void ScanVolumeTree(G4LogicalVolume *lv, G4bool region)
Definition: G4Region.cc:172

Referenced by G4RunManagerKernel::CheckRegions(), and G4RunManagerKernel::DefineWorldVolume().

◆ BelongsTo()

G4bool G4Region::BelongsTo ( G4VPhysicalVolume thePhys) const

Definition at line 414 of file G4Region.cc.

415{
416 G4LogicalVolume* currLog = thePhys->GetLogicalVolume();
417 if (currLog->GetRegion()==this) {return true;}
418
419 std::size_t nDaughters = currLog->GetNoDaughters();
420 while (nDaughters--) // Loop checking, 06.08.2015, G.Cosmo
421 {
422 if (BelongsTo(currLog->GetDaughter(nDaughters))) {return true;}
423 }
424
425 return false;
426}
std::size_t GetNoDaughters() const
G4Region * GetRegion() const
G4VPhysicalVolume * GetDaughter(const std::size_t i) const
G4bool BelongsTo(G4VPhysicalVolume *thePhys) const
Definition: G4Region.cc:414
G4LogicalVolume * GetLogicalVolume() const

Referenced by BelongsTo(), G4RunManagerKernel::CheckRegions(), and SetWorld().

◆ Clean()

void G4Region::Clean ( )
static

Definition at line 356 of file G4Region.cc.

357{
358 subInstanceManager.FreeSlave();
359}

Referenced by G4RegionStore::~G4RegionStore().

◆ ClearFastSimulationManager()

void G4Region::ClearFastSimulationManager ( )

Definition at line 434 of file G4Region.cc.

435{
436 G4bool isUnique;
437 G4Region* parent = GetParentRegion(isUnique);
438 if(parent != nullptr)
439 {
440 if (isUnique)
441 {
443 }
444 else
445 {
446 std::ostringstream message;
447 message << "Region <" << fName << "> belongs to more than"
448 << " one parent region !" << G4endl
449 << "A region cannot belong to more than one direct parent region,"
450 << G4endl
451 << "to have fast-simulation assigned.";
452 G4Exception("G4Region::ClearFastSimulationManager()",
453 "GeomMgt1002", JustWarning, message);
454 G4MT_fsmanager = nullptr;
455 }
456 }
457 else
458 {
459 G4MT_fsmanager = nullptr;
460 }
461}
bool G4bool
Definition: G4Types.hh:86
G4Region * GetParentRegion(G4bool &unique) const
Definition: G4Region.cc:469
G4FastSimulationManager * GetFastSimulationManager() const
Definition: G4Region.cc:140

Referenced by G4FastSimulationManager::~G4FastSimulationManager().

◆ ClearMap()

void G4Region::ClearMap ( )
inline

◆ ClearMaterialList()

void G4Region::ClearMaterialList ( )

Definition at line 366 of file G4Region.cc.

367{
368 fMaterials.clear();
369}

Referenced by UpdateMaterialList().

◆ FindCouple()

◆ GetFastSimulationManager()

◆ GetFieldManager()

G4FieldManager * G4Region::GetFieldManager ( ) const
inline

◆ GetInstanceID()

G4int G4Region::GetInstanceID ( ) const
inline

◆ GetMaterialIterator()

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

◆ GetName()

◆ GetNumberOfMaterials()

std::size_t G4Region::GetNumberOfMaterials ( ) const
inline

◆ GetNumberOfRootVolumes()

std::size_t G4Region::GetNumberOfRootVolumes ( ) const
inline

◆ GetParentRegion()

G4Region * G4Region::GetParentRegion ( G4bool unique) const

Definition at line 469 of file G4Region.cc.

470{
471 G4Region* parent = nullptr; unique = true;
473
474 // Loop over all logical volumes in the store
475 //
476 for(auto lvItr=lvStore->cbegin(); lvItr!=lvStore->cend(); ++lvItr)
477 {
478 std::size_t nD = (*lvItr)->GetNoDaughters();
479 G4Region* aR = (*lvItr)->GetRegion();
480
481 // Loop over all daughters of each logical volume
482 //
483 for(std::size_t iD=0; iD<nD; ++iD)
484 {
485 if((*lvItr)->GetDaughter(iD)->GetLogicalVolume()->GetRegion()==this)
486 {
487 if(parent)
488 {
489 if(parent!=aR) { unique = false; }
490 }
491 else // Cache LV parent region which includes a daughter volume
492 // with the same associated region as the current one
493 {
494 parent = aR;
495 }
496 }
497 }
498 }
499 return parent;
500}
static G4LogicalVolumeStore * GetInstance()

Referenced by ClearFastSimulationManager().

◆ GetProductionCuts()

◆ GetRegionalSteppingAction()

G4UserSteppingAction * G4Region::GetRegionalSteppingAction ( ) const

◆ GetRootLogicalVolumeIterator()

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

◆ GetSubInstanceManager()

const G4RegionManager & G4Region::GetSubInstanceManager ( )
static

Definition at line 55 of file G4Region.cc.

56{
57 return subInstanceManager;
58}

Referenced by G4GeometryWorkspace::G4GeometryWorkspace().

◆ 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=()

G4Region & G4Region::operator= ( const G4Region )
delete

◆ 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 328 of file G4Region.cc.

329{
330 // Find and remove logical volume from the list
331 //
332 auto pos = std::find(fRootVolumes.cbegin(),fRootVolumes.cend(),lv);
333 if (pos != fRootVolumes.cend())
334 {
335 if (fRootVolumes.size() != 1) // Avoid resetting flag for world since
336 { // volume may be already deleted !
337 lv->SetRegionRootFlag(false);
338 }
339 fRootVolumes.erase(pos);
340 }
341
342 if (scan) // Update the materials list
343 {
345 }
346
347 // Set region as modified
348 //
349 fRegionMod = true;
350}
void UpdateMaterialList()
Definition: G4Region.cc:377

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

◆ ScanVolumeTree()

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

Definition at line 172 of file G4Region.cc.

173{
174 // If logical volume is going to become a region, add
175 // its material to the list if not already present
176 //
177 G4Region* currentRegion = nullptr;
178 std::size_t noDaughters = lv->GetNoDaughters();
179 G4Material* volMat = lv->GetMaterial();
180 if((volMat == nullptr) && fInMassGeometry)
181 {
182 std::ostringstream message;
183 message << "Logical volume <" << lv->GetName() << ">" << G4endl
184 << "does not have a valid material pointer." << G4endl
185 << "A logical volume belonging to the (tracking) world volume "
186 << "must have a valid material.";
187 G4Exception("G4Region::ScanVolumeTree()", "GeomMgt0002",
188 FatalException, message, "Check your geometry construction.");
189 }
190 if (region)
191 {
192 currentRegion = this;
193 if (volMat != nullptr)
194 {
195 AddMaterial(volMat);
196 G4Material* baseMat = const_cast<G4Material*>(volMat->GetBaseMaterial());
197 if (baseMat != nullptr) { AddMaterial(baseMat); }
198 }
199 }
200
201 // Set the LV region to be either the current region or NULL,
202 // according to the boolean selector
203 //
204 lv->SetRegion(currentRegion);
205
206 // Stop recursion here if no further daughters are involved
207 //
208 if(noDaughters==0) return;
209
210 G4VPhysicalVolume* daughterPVol = lv->GetDaughter(0);
211 if (daughterPVol->IsParameterised())
212 {
213 // Adopt special treatment in case of parameterised volumes,
214 // where parameterisation involves a new material scan
215 //
216 G4VPVParameterisation* pParam = daughterPVol->GetParameterisation();
217
218 if (pParam->GetMaterialScanner() != nullptr)
219 {
220 std::size_t matNo = pParam->GetMaterialScanner()->GetNumberOfMaterials();
221 for (std::size_t mat=0; mat<matNo; ++mat)
222 {
223 volMat = pParam->GetMaterialScanner()->GetMaterial((G4int)mat);
224 if(!volMat && fInMassGeometry)
225 {
226 std::ostringstream message;
227 message << "The parameterisation for the physical volume <"
228 << daughterPVol->GetName() << ">" << G4endl
229 << "does not return a valid material pointer." << G4endl
230 << "A volume belonging to the (tracking) world volume must "
231 << "have a valid material.";
232 G4Exception("G4Region::ScanVolumeTree()", "GeomMgt0002",
233 FatalException, message, "Check your parameterisation.");
234 }
235 if (volMat != nullptr)
236 {
237 AddMaterial(volMat);
238 G4Material* baseMat = const_cast<G4Material*>(volMat->GetBaseMaterial());
239 if (baseMat != nullptr) { AddMaterial(baseMat); }
240 }
241 }
242 }
243 else
244 {
245 std::size_t repNo = daughterPVol->GetMultiplicity();
246 for (std::size_t rep=0; rep<repNo; ++rep)
247 {
248 volMat = pParam->ComputeMaterial((G4int)rep, daughterPVol);
249 if((volMat == nullptr) && fInMassGeometry)
250 {
251 std::ostringstream message;
252 message << "The parameterisation for the physical volume <"
253 << daughterPVol->GetName() << ">" << G4endl
254 << "does not return a valid material pointer." << G4endl
255 << "A volume belonging to the (tracking) world volume must "
256 << "have a valid material.";
257 G4Exception("G4Region::ScanVolumeTree()", "GeomMgt0002",
258 FatalException, message, "Check your parameterisation.");
259 }
260 if(volMat != nullptr)
261 {
262 AddMaterial(volMat);
263 G4Material* baseMat = const_cast<G4Material*>(volMat->GetBaseMaterial());
264 if (baseMat != nullptr) { AddMaterial(baseMat); }
265 }
266 }
267 }
268 G4LogicalVolume* daughterLVol = daughterPVol->GetLogicalVolume();
269 ScanVolumeTree(daughterLVol, region);
270 }
271 else
272 {
273 for (std::size_t i=0; i<noDaughters; ++i)
274 {
275 G4LogicalVolume* daughterLVol = lv->GetDaughter(i)->GetLogicalVolume();
276 if (!daughterLVol->IsRootRegion())
277 {
278 // Set daughter's LV to be a region and store materials in
279 // the materials list, if the LV is not already a root region
280 //
281 ScanVolumeTree(daughterLVol, region);
282 }
283 }
284 }
285}
@ FatalException
int G4int
Definition: G4Types.hh:85
void SetRegion(G4Region *reg)
G4bool IsRootRegion() const
G4Material * GetMaterial() const
const G4String & GetName() const
const G4Material * GetBaseMaterial() const
Definition: G4Material.hh:228
virtual G4VVolumeMaterialScanner * GetMaterialScanner()
virtual G4Material * ComputeMaterial(const G4int repNo, G4VPhysicalVolume *currentVol, const G4VTouchable *parentTouch=nullptr)
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)

◆ SetFieldManager()

void G4Region::SetFieldManager ( G4FieldManager fm)
inline

◆ SetName()

void G4Region::SetName ( const G4String name)

Definition at line 121 of file G4Region.cc.

122{
123 fName = pName;
125}
void SetMapValid(G4bool val)

◆ SetProductionCuts()

◆ SetRegionalSteppingAction()

void G4Region::SetRegionalSteppingAction ( G4UserSteppingAction rusa)

Definition at line 149 of file G4Region.cc.

150{
151 G4MT_rsaction = rusa;
152}

Referenced by G4WorkerThread::UpdateGeometryAndPhysicsVectorFromMaster().

◆ SetUserInformation()

void G4Region::SetUserInformation ( G4VUserRegionInformation ui)
inline

◆ SetUserLimits()

void G4Region::SetUserLimits ( G4UserLimits ul)
inline

◆ SetWorld()

void G4Region::SetWorld ( G4VPhysicalVolume wp)

Definition at line 398 of file G4Region.cc.

399{
400 if(!wp)
401 { fWorldPhys = nullptr; }
402 else
403 { if(BelongsTo(wp)) fWorldPhys = wp; }
404
405 return;
406}

Referenced by G4RunManagerKernel::CheckRegions().

◆ UpdateMaterialList()

void G4Region::UpdateMaterialList ( )

Definition at line 377 of file G4Region.cc.

378{
379 // Reset the materials list
380 //
382
383 // Loop over the root logical volumes and rebuild the list
384 // of materials from scratch
385 //
386 for (auto pLV=fRootVolumes.cbegin(); pLV!=fRootVolumes.cend(); ++pLV)
387 {
388 ScanVolumeTree(*pLV, true);
389 }
390}
void ClearMaterialList()
Definition: G4Region.cc:366

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: