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

#include <G4RegionStore.hh>

+ Inheritance diagram for G4RegionStore:

Public Member Functions

G4bool IsModified () const
 
void ResetRegionModified ()
 
void UpdateMaterialList (G4VPhysicalVolume *currentWorld=nullptr)
 
G4RegionGetRegion (const G4String &name, G4bool verbose=true) const
 
G4bool IsMapValid () const
 
void SetMapValid (G4bool val)
 
const std::map< G4String, std::vector< G4Region * > > & GetMap () const
 
void UpdateMap ()
 
G4RegionFindOrCreateRegion (const G4String &name)
 
void SetWorldVolume ()
 
virtual ~G4RegionStore ()
 
 G4RegionStore (const G4RegionStore &)=delete
 
G4RegionStoreoperator= (const G4RegionStore &)=delete
 

Static Public Member Functions

static void Register (G4Region *pRegion)
 
static void DeRegister (G4Region *pRegion)
 
static G4RegionStoreGetInstance ()
 
static void SetNotifier (G4VStoreNotifier *pNotifier)
 
static void Clean ()
 

Protected Member Functions

 G4RegionStore ()
 

Detailed Description

Definition at line 58 of file G4RegionStore.hh.

Constructor & Destructor Documentation

◆ ~G4RegionStore()

G4RegionStore::~G4RegionStore ( )
virtual

Definition at line 68 of file G4RegionStore.cc.

69{
70 Clean(); // Delete all regions in the store
71 G4Region::Clean(); // Delete allocated sub-instance data
72}
static void Clean()
static void Clean()
Definition G4Region.cc:370

◆ G4RegionStore() [1/2]

G4RegionStore::G4RegionStore ( const G4RegionStore & )
delete

◆ G4RegionStore() [2/2]

G4RegionStore::G4RegionStore ( )
protected

Definition at line 58 of file G4RegionStore.cc.

60{
61 reserve(20);
62}

Member Function Documentation

◆ Clean()

void G4RegionStore::Clean ( )
static

Definition at line 78 of file G4RegionStore.cc.

79{
80 // Do nothing if geometry is closed
81 //
83 {
84 G4cout << "WARNING - Attempt to delete the region store"
85 << " while geometry closed !" << G4endl;
86 return;
87 }
88
89 // Locks store for deletion of regions. De-registration will be
90 // performed at this stage. G4Regions will not de-register themselves.
91 //
92 locked = true;
93
94 G4RegionStore* store = GetInstance();
95
96 for(auto pos=store->cbegin(); pos!=store->cend(); ++pos)
97 {
98 if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
99 delete *pos;
100 }
101
102 store->bmap.clear(); store->mvalid = false;
103 locked = false;
104 store->clear();
105}
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
static G4bool IsGeometryClosed()
static G4RegionStore * GetInstance()
virtual void NotifyDeRegistration()=0

Referenced by ~G4RegionStore().

◆ DeRegister()

void G4RegionStore::DeRegister ( G4Region * pRegion)
static

Definition at line 171 of file G4RegionStore.cc.

172{
173 G4RegionStore* store = GetInstance();
174 if (!locked) // Do not de-register if locked !
175 {
176 if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
177 for (auto i=store->cbegin(); i!=store->cend(); ++i)
178 {
179 if (**i==*pRegion)
180 {
181 store->erase(i);
182 break;
183 }
184 }
185 const G4String& reg_name = pRegion->GetName();
186 auto it = store->bmap.find(reg_name);
187 if (it != store->bmap.cend())
188 {
189 if (it->second.size() > 1)
190 {
191 for (auto i=it->second.cbegin(); i!=it->second.cend(); ++i)
192 {
193 if (**i==*pRegion)
194 {
195 it->second.erase(i);
196 break;
197 }
198 }
199 }
200 else
201 {
202 store->bmap.erase(it);
203 }
204 }
205 }
206}
const G4String & GetName() const

Referenced by G4Region::~G4Region().

◆ FindOrCreateRegion()

G4Region * G4RegionStore::FindOrCreateRegion ( const G4String & name)

Definition at line 303 of file G4RegionStore.cc.

304{
305 G4Region* target = GetRegion(name,false);
306 if (target == nullptr)
307 {
308 target = new G4Region(name);
309 }
310 return target;
311}
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const

◆ GetInstance()

G4RegionStore * G4RegionStore::GetInstance ( )
static

Definition at line 212 of file G4RegionStore.cc.

213{
214 static G4RegionStore worldStore;
215 if (fgInstance == nullptr)
216 {
217 fgInstance = &worldStore;
218 }
219 return fgInstance;
220}

Referenced by G4EmBiasingManager::ActivateForcedInteraction(), G4EmBiasingManager::ActivateSecondaryBiasing(), G4LowECapture::BuildPhysicsTable(), G4MicroElecCapture::BuildPhysicsTable(), G4RunManagerKernel::CheckRegions(), Clean(), G4TheRayTracer::CreateBitMap(), G4EmExtraParameters::DefineRegParamForLoss(), DeRegister(), G4RunManagerKernel::DumpRegion(), G4RunManagerKernel::DumpRegion(), G4EmCalculator::FindCouple(), G4EmUtility::FindRegion(), G4ProductionCutsTable::G4ProductionCutsTable(), G4Region::G4Region(), G4Region::G4Region(), G4RunManagerKernel::G4RunManagerKernel(), G4VUserPhysicsList::GetCutValue(), GetRegion(), G4EmModelManager::Initialise(), G4PAIModel::Initialise(), G4PAIPhotModel::Initialise(), G4VAtomDeexcitation::InitialiseAtomicDeexcitation(), IsModified(), Register(), G4RunManager::ReinitializeGeometry(), ResetRegionModified(), G4VUserPhysicsList::SetCutValue(), G4VAtomDeexcitation::SetDeexcitationActiveRegion(), G4ScoringProbe::SetMaterial(), G4Region::SetName(), SetNotifier(), G4VUserPhysicsList::SetParticleCuts(), G4MaterialScanner::SetRegionName(), G4ScoringProbe::SetupGeometry(), SetWorldVolume(), G4GlobalFastSimulationManager::ShowSetup(), G4WorkerThread::UpdateGeometryAndPhysicsVectorFromMaster(), UpdateMap(), UpdateMaterialList(), G4RunManagerKernel::UpdateRegion(), and G4Region::~G4Region().

◆ GetMap()

const std::map< G4String, std::vector< G4Region * > > & G4RegionStore::GetMap ( ) const
inline

Definition at line 94 of file G4RegionStore.hh.

94{ return bmap; }

◆ GetRegion()

G4Region * G4RegionStore::GetRegion ( const G4String & name,
G4bool verbose = true ) const

Definition at line 267 of file G4RegionStore.cc.

268{
269 G4RegionStore* store = GetInstance();
270 if (!store->mvalid) { store->UpdateMap(); }
271 auto pos = store->bmap.find(name);
272 if(pos != store->bmap.cend())
273 {
274 if ((verbose) && (pos->second.size()>1))
275 {
276 std::ostringstream message;
277 message << "There exists more than ONE region in store named: "
278 << name << "!" << G4endl
279 << "Returning the first found.";
280 G4Exception("G4RegionStore::GetSolid()",
281 "GeomMgt1001", JustWarning, message);
282 }
283 return pos->second[0];
284 }
285 if (verbose)
286 {
287 std::ostringstream message;
288 message << "Region NOT found in store !" << G4endl
289 << " Region " << name << " NOT found in store !" << G4endl
290 << " Returning NULL pointer.";
291 G4Exception("G4RegionStore::GetRegion()",
292 "GeomMgt1001", JustWarning, message);
293 }
294 return nullptr;
295}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
const char * name(G4int ptype)

Referenced by G4EmBiasingManager::ActivateForcedInteraction(), G4EmBiasingManager::ActivateSecondaryBiasing(), G4LowECapture::BuildPhysicsTable(), G4ProductionCutsTable::CheckMaterialCutsCoupleInfo(), G4EmExtraParameters::DefineRegParamForLoss(), G4RunManagerKernel::DumpRegion(), FindOrCreateRegion(), G4EmUtility::FindRegion(), G4Region::G4Region(), G4RunManagerKernel::G4RunManagerKernel(), G4VUserPhysicsList::GetCutValue(), G4EmModelManager::Initialise(), G4VAtomDeexcitation::InitialiseAtomicDeexcitation(), G4VUserPhysicsList::SetCutValue(), G4ScoringProbe::SetMaterial(), G4VUserPhysicsList::SetParticleCuts(), G4MaterialScanner::SetRegionName(), and G4ScoringProbe::SetupGeometry().

◆ IsMapValid()

G4bool G4RegionStore::IsMapValid ( ) const
inline

Definition at line 90 of file G4RegionStore.hh.

90{ return mvalid; }

◆ IsModified()

G4bool G4RegionStore::IsModified ( ) const

Definition at line 227 of file G4RegionStore.cc.

228{
229 for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
230 {
231 if ((*i)->IsModified()) { return true; }
232 }
233 return false;
234}

◆ operator=()

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

◆ Register()

void G4RegionStore::Register ( G4Region * pRegion)
static

Definition at line 148 of file G4RegionStore.cc.

149{
150 G4RegionStore* store = GetInstance();
151 store->push_back(pRegion);
152 const G4String& reg_name = pRegion->GetName();
153 auto it = store->bmap.find(reg_name);
154 if (it != store->bmap.cend())
155 {
156 it->second.push_back(pRegion);
157 }
158 else
159 {
160 std::vector<G4Region*> reg_vec { pRegion };
161 store->bmap.insert(std::make_pair(reg_name, reg_vec));
162 }
163 if (fgNotifier != nullptr) { fgNotifier->NotifyRegistration(); }
164 store->mvalid = true;
165}
virtual void NotifyRegistration()=0

Referenced by G4Region::G4Region(), and G4Region::G4Region().

◆ ResetRegionModified()

void G4RegionStore::ResetRegionModified ( )

Definition at line 241 of file G4RegionStore.cc.

242{
243 for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
244 {
245 (*i)->RegionModified(false);
246 }
247}

◆ SetMapValid()

void G4RegionStore::SetMapValid ( G4bool val)
inline

Definition at line 91 of file G4RegionStore.hh.

91{ mvalid = val; }

Referenced by G4Region::SetName().

◆ SetNotifier()

void G4RegionStore::SetNotifier ( G4VStoreNotifier * pNotifier)
static

Definition at line 111 of file G4RegionStore.cc.

112{
113 GetInstance();
114 fgNotifier = pNotifier;
115}

◆ SetWorldVolume()

void G4RegionStore::SetWorldVolume ( )

Definition at line 318 of file G4RegionStore.cc.

319{
320 // Reset all pointers first
321 //
322 for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
323 { (*i)->SetWorld(nullptr); }
324
325 // Find world volumes
326 //
327 G4PhysicalVolumeStore* fPhysicalVolumeStore
329 std::size_t nPhys = fPhysicalVolumeStore->size();
330 for(std::size_t iPhys=0; iPhys<nPhys; ++iPhys)
331 {
332 G4VPhysicalVolume* fPhys = (*fPhysicalVolumeStore)[iPhys];
333 if(fPhys->GetMotherLogical() != nullptr) { continue; } // not a world volume
334
335 // Now 'fPhys' is a world volume, set it to regions that belong to it.
336 //
337 for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
338 { (*i)->SetWorld(fPhys); }
339 }
340}
static G4PhysicalVolumeStore * GetInstance()
G4LogicalVolume * GetMotherLogical() const

◆ UpdateMap()

void G4RegionStore::UpdateMap ( )

Definition at line 121 of file G4RegionStore.cc.

122{
123 G4AutoLock l(&mapMutex); // to avoid thread contention at initialisation
124 if (mvalid) return;
125 bmap.clear();
126 for(auto pos=GetInstance()->cbegin(); pos!=GetInstance()->cend(); ++pos)
127 {
128 const G4String& reg_name = (*pos)->GetName();
129 auto it = bmap.find(reg_name);
130 if (it != bmap.cend())
131 {
132 it->second.push_back(*pos);
133 }
134 else
135 {
136 std::vector<G4Region*> reg_vec { *pos };
137 bmap.insert(std::make_pair(reg_name, reg_vec));
138 }
139 }
140 mvalid = true;
141 l.unlock();
142}

Referenced by GetRegion().

◆ UpdateMaterialList()

void G4RegionStore::UpdateMaterialList ( G4VPhysicalVolume * currentWorld = nullptr)

Definition at line 253 of file G4RegionStore.cc.

254{
255 for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
256 {
257 if((*i)->IsInMassGeometry() || (*i)->IsInParallelGeometry()
258 || (currentWorld != nullptr))
259 { (*i)->UpdateMaterialList(); }
260 }
261}

Referenced by G4TheRayTracer::CreateBitMap(), and G4RunManagerKernel::UpdateRegion().


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