Geant4 10.7.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 ()
 
 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
 
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__ &)
 
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:35
#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 283 of file G4Region.cc.

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

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

◆ BelongsTo()

G4bool G4Region::BelongsTo ( G4VPhysicalVolume thePhys) const

Definition at line 404 of file G4Region.cc.

405{
406 G4LogicalVolume* currLog = thePhys->GetLogicalVolume();
407 if (currLog->GetRegion()==this) {return true;}
408
409 G4int nDaughters = currLog->GetNoDaughters();
410 while (nDaughters--) // Loop checking, 06.08.2015, G.Cosmo
411 {
412 if (BelongsTo(currLog->GetDaughter(nDaughters))) {return true;}
413 }
414
415 return false;
416}
int G4int
Definition: G4Types.hh:85
size_t GetNoDaughters() const
G4Region * GetRegion() const
G4VPhysicalVolume * GetDaughter(const G4int i) const
G4bool BelongsTo(G4VPhysicalVolume *thePhys) const
Definition: G4Region.cc:404
G4LogicalVolume * GetLogicalVolume() const

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

◆ Clean()

void G4Region::Clean ( )
static

Definition at line 346 of file G4Region.cc.

347{
348 subInstanceManager.FreeSlave();
349}

Referenced by G4RegionStore::~G4RegionStore().

◆ ClearFastSimulationManager()

void G4Region::ClearFastSimulationManager ( )

Definition at line 424 of file G4Region.cc.

425{
426 G4bool isUnique;
427 G4Region* parent = GetParentRegion(isUnique);
428 if(parent != nullptr)
429 {
430 if (isUnique)
431 {
433 }
434 else
435 {
436 std::ostringstream message;
437 message << "Region <" << fName << "> belongs to more than"
438 << " one parent region !" << G4endl
439 << "A region cannot belong to more than one direct parent region,"
440 << G4endl
441 << "to have fast-simulation assigned.";
442 G4Exception("G4Region::ClearFastSimulationManager()",
443 "GeomMgt1002", JustWarning, message);
444 G4MT_fsmanager = nullptr;
445 }
446 }
447 else
448 {
449 G4MT_fsmanager = nullptr;
450 }
451}
bool G4bool
Definition: G4Types.hh:86
G4Region * GetParentRegion(G4bool &unique) const
Definition: G4Region.cc:459
G4FastSimulationManager * GetFastSimulationManager() const
Definition: G4Region.cc:130

Referenced by G4FastSimulationManager::~G4FastSimulationManager().

◆ ClearMap()

void G4Region::ClearMap ( )
inline

◆ ClearMaterialList()

void G4Region::ClearMaterialList ( )

Definition at line 356 of file G4Region.cc.

357{
358 fMaterials.clear();
359}

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

size_t G4Region::GetNumberOfMaterials ( ) const
inline

◆ GetNumberOfRootVolumes()

size_t G4Region::GetNumberOfRootVolumes ( ) const
inline

◆ GetParentRegion()

G4Region * G4Region::GetParentRegion ( G4bool unique) const

Definition at line 459 of file G4Region.cc.

460{
461 G4Region* parent = nullptr; unique = true;
463
464 // Loop over all logical volumes in the store
465 //
466 for(auto lvItr=lvStore->cbegin(); lvItr!=lvStore->cend(); ++lvItr)
467 {
468 G4int nD = (*lvItr)->GetNoDaughters();
469 G4Region* aR = (*lvItr)->GetRegion();
470
471 // Loop over all daughters of each logical volume
472 //
473 for(auto iD=0; iD<nD; ++iD)
474 {
475 if((*lvItr)->GetDaughter(iD)->GetLogicalVolume()->GetRegion()==this)
476 {
477 if(parent)
478 {
479 if(parent!=aR) { unique = false; }
480 }
481 else // Cache LV parent region which includes a daughter volume
482 // with the same associated region as the current one
483 {
484 parent = aR;
485 }
486 }
487 }
488 }
489 return parent;
490}
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 318 of file G4Region.cc.

319{
320 // Find and remove logical volume from the list
321 //
322 auto pos = std::find(fRootVolumes.cbegin(),fRootVolumes.cend(),lv);
323 if (pos != fRootVolumes.cend())
324 {
325 if (fRootVolumes.size() != 1) // Avoid resetting flag for world since
326 { // volume may be already deleted !
327 lv->SetRegionRootFlag(false);
328 }
329 fRootVolumes.erase(pos);
330 }
331
332 if (scan) // Update the materials list
333 {
335 }
336
337 // Set region as modified
338 //
339 fRegionMod = true;
340}
void UpdateMaterialList()
Definition: G4Region.cc:367

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

◆ ScanVolumeTree()

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

Definition at line 162 of file G4Region.cc.

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

◆ SetProductionCuts()

◆ SetRegionalSteppingAction()

void G4Region::SetRegionalSteppingAction ( G4UserSteppingAction rusa)

Definition at line 139 of file G4Region.cc.

140{
141 G4MT_rsaction = rusa;
142}

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

389{
390 if(!wp)
391 { fWorldPhys = 0; }
392 else
393 { if(BelongsTo(wp)) fWorldPhys = wp; }
394
395 return;
396}

Referenced by G4RunManagerKernel::CheckRegions().

◆ UpdateMaterialList()

void G4Region::UpdateMaterialList ( )

Definition at line 367 of file G4Region.cc.

368{
369 // Reset the materials list
370 //
372
373 // Loop over the root logical volumes and rebuild the list
374 // of materials from scratch
375 //
376 for (auto pLV=fRootVolumes.cbegin(); pLV!=fRootVolumes.cend(); ++pLV)
377 {
378 ScanVolumeTree(*pLV, true);
379 }
380}
void ClearMaterialList()
Definition: G4Region.cc:356

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: