Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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__ &)
 
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 ()
 

Detailed Description

Definition at line 99 of file G4Region.hh.

Constructor & Destructor Documentation

G4Region::G4Region ( const G4String name)

Definition at line 68 of file G4Region.cc.

69  : fName(pName), fRegionMod(true), fCut(0), fUserInfo(0), fUserLimits(0),
70  fFieldManager(0), fWorldPhys(0),
71  fInMassGeometry(false), fInParallelGeometry(false)
72 {
73 
74  instanceID = subInstanceManager.CreateSubInstance();
75  G4MT_fsmanager = 0;
76  G4MT_rsaction = 0;
77 
79  if (rStore->GetRegion(pName,false))
80  {
81  std::ostringstream message;
82  message << "The region has NOT been registered !" << G4endl
83  << " Region " << pName << " already existing in store !"
84  << G4endl;
85  G4Exception("G4Region::G4Region()", "GeomMgt1001",
86  JustWarning, message);
87  }
88  else
89  {
90  rStore->Register(this);
91  }
92 }
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
#define G4MT_rsaction
Definition: G4Region.cc:47
G4int CreateSubInstance()
#define G4MT_fsmanager
Definition: G4Region.cc:46
static G4RegionStore * GetInstance()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
static void Register(G4Region *pRegion)

Here is the call graph for this function:

G4Region::~G4Region ( )
virtual

Definition at line 118 of file G4Region.cc.

119 {
121  if(fUserInfo) delete fUserInfo;
122 }
static void DeRegister(G4Region *pRegion)
static G4RegionStore * GetInstance()

Here is the call graph for this function:

G4Region::G4Region ( __void__ &  )

Definition at line 99 of file G4Region.cc.

100  : fName(""), fRegionMod(true), fCut(0), fUserInfo(0), fUserLimits(0),
101  fFieldManager(0), fWorldPhys(0),
102  fInMassGeometry(false), fInParallelGeometry(false)
103 {
104  instanceID = subInstanceManager.CreateSubInstance();
105  G4MT_fsmanager = 0;
106  G4MT_rsaction = 0;
107 
108  // Register to store
109  //
111 }
#define G4MT_rsaction
Definition: G4Region.cc:47
G4int CreateSubInstance()
#define G4MT_fsmanager
Definition: G4Region.cc:46
static G4RegionStore * GetInstance()
static void Register(G4Region *pRegion)

Here is the call graph for this function:

Member Function Documentation

void G4Region::AddRootLogicalVolume ( G4LogicalVolume lv)

Definition at line 290 of file G4Region.cc.

291 {
292  // Check the logical volume is not already in the list
293  //
294  G4RootLVList::iterator pos;
295  pos = std::find(fRootVolumes.begin(),fRootVolumes.end(),lv);
296  if (pos == fRootVolumes.end())
297  {
298  // Insert the root volume in the list and set it as root region
299  //
300  fRootVolumes.push_back(lv);
301  lv->SetRegionRootFlag(true);
302  }
303 
304  // Scan recursively the tree of daugther volumes and set regions
305  //
306  ScanVolumeTree(lv, true);
307 
308  // Set region as modified
309  //
310  fRegionMod = true;
311 }
void SetRegionRootFlag(G4bool rreg)
void ScanVolumeTree(G4LogicalVolume *lv, G4bool region)
Definition: G4Region.cc:169
static const G4double pos

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G4Region::BelongsTo ( G4VPhysicalVolume thePhys) const

Definition at line 398 of file G4Region.cc.

399 {
400  G4LogicalVolume* currLog = thePhys->GetLogicalVolume();
401  if (currLog->GetRegion()==this) {return true;}
402 
403  G4int nDaughters = currLog->GetNoDaughters();
404  while (nDaughters--) // Loop checking, 06.08.2015, G.Cosmo
405  {
406  if (BelongsTo(currLog->GetDaughter(nDaughters))) {return true;}
407  }
408 
409  return false;
410 }
G4VPhysicalVolume * GetDaughter(const G4int i) const
G4Region * GetRegion() const
int G4int
Definition: G4Types.hh:78
G4int GetNoDaughters() const
G4bool BelongsTo(G4VPhysicalVolume *thePhys) const
Definition: G4Region.cc:398
G4LogicalVolume * GetLogicalVolume() const

Here is the call graph for this function:

Here is the caller graph for this function:

void G4Region::ClearFastSimulationManager ( )

Definition at line 418 of file G4Region.cc.

419 {
420  G4bool isUnique;
421  G4Region* parent = GetParentRegion(isUnique);
422  if(parent)
423  {
424  if (isUnique)
425  {
427  }
428  else
429  {
430  std::ostringstream message;
431  message << "Region <" << fName << "> belongs to more than"
432  << " one parent region !" << G4endl
433  << "A region cannot belong to more than one direct parent region,"
434  << G4endl
435  << "to have fast-simulation assigned.";
436  G4Exception("G4Region::ClearFastSimulationManager()",
437  "GeomMgt1002", JustWarning, message);
438  G4MT_fsmanager = 0;
439  }
440  }
441  else
442  {
443  G4MT_fsmanager = 0;
444  }
445 }
#define G4MT_fsmanager
Definition: G4Region.cc:46
bool G4bool
Definition: G4Types.hh:79
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4Region * GetParentRegion(G4bool &unique) const
Definition: G4Region.cc:453
#define G4endl
Definition: G4ios.hh:61
G4FastSimulationManager * GetFastSimulationManager() const
Definition: G4Region.cc:137

Here is the call graph for this function:

Here is the caller graph for this function:

void G4Region::ClearMap ( )
inline
void G4Region::ClearMaterialList ( )

Definition at line 349 of file G4Region.cc.

350 {
351  fMaterials.clear();
352 }

Here is the caller graph for this function:

G4MaterialCutsCouple* G4Region::FindCouple ( G4Material mat)
inline

Here is the caller graph for this function:

G4FastSimulationManager * G4Region::GetFastSimulationManager ( ) const

Definition at line 137 of file G4Region.cc.

138 {
139  return G4MT_fsmanager;
140 }
#define G4MT_fsmanager
Definition: G4Region.cc:46

Here is the caller graph for this function:

G4FieldManager* G4Region::GetFieldManager ( ) const
inline

Here is the caller graph for this function:

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

Here is the caller graph for this function:

const G4String& G4Region::GetName ( ) const
inline

Here is the caller graph for this function:

size_t G4Region::GetNumberOfMaterials ( ) const
inline

Here is the caller graph for this function:

size_t G4Region::GetNumberOfRootVolumes ( ) const
inline

Here is the caller graph for this function:

G4Region * G4Region::GetParentRegion ( G4bool unique) const

Definition at line 453 of file G4Region.cc.

454 {
455  G4Region* parent = 0; unique = true;
457  G4LogicalVolumeStore::iterator lvItr;
458 
459  // Loop over all logical volumes in the store
460  //
461  for(lvItr=lvStore->begin(); lvItr!=lvStore->end(); lvItr++)
462  {
463  G4int nD = (*lvItr)->GetNoDaughters();
464  G4Region* aR = (*lvItr)->GetRegion();
465 
466  // Loop over all daughters of each logical volume
467  //
468  for(G4int iD=0; iD<nD; iD++)
469  {
470  if((*lvItr)->GetDaughter(iD)->GetLogicalVolume()->GetRegion()==this)
471  {
472  if(parent)
473  {
474  if(parent!=aR) { unique = false; }
475  }
476  else // Cache LV parent region which includes a daughter volume
477  // with the same associated region as the current one
478  {
479  parent = aR;
480  }
481  }
482  }
483  }
484  return parent;
485 }
int G4int
Definition: G4Types.hh:78
static G4LogicalVolumeStore * GetInstance()

Here is the call graph for this function:

Here is the caller graph for this function:

G4ProductionCuts* G4Region::GetProductionCuts ( ) const
inline

Here is the caller graph for this function:

G4UserSteppingAction * G4Region::GetRegionalSteppingAction ( ) const

Definition at line 155 of file G4Region.cc.

156 {
157  return G4MT_rsaction;
158 }
#define G4MT_rsaction
Definition: G4Region.cc:47

Here is the caller graph for this function:

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

Here is the caller graph for this function:

const G4RegionManager & G4Region::GetSubInstanceManager ( )
static

Definition at line 58 of file G4Region.cc.

59 {
60  return subInstanceManager;
61 }

Here is the caller graph for this function:

G4VUserRegionInformation* G4Region::GetUserInformation ( ) const
inline

Here is the caller graph for this function:

G4UserLimits* G4Region::GetUserLimits ( ) const
inline

Here is the caller graph for this function:

G4VPhysicalVolume* G4Region::GetWorldPhysical ( ) const
inline

Here is the caller graph for this function:

G4bool G4Region::IsInMassGeometry ( ) const
inline

Here is the caller graph for this function:

G4bool G4Region::IsInParallelGeometry ( ) const
inline

Here is the caller graph for this function:

G4bool G4Region::IsModified ( ) const
inline
G4bool G4Region::operator== ( const G4Region rg) const
inline
void G4Region::RegionModified ( G4bool  flag)
inline

Here is the caller graph for this function:

void G4Region::RegisterMaterialCouplePair ( G4Material mat,
G4MaterialCutsCouple couple 
)
inline
void G4Region::RemoveRootLogicalVolume ( G4LogicalVolume lv,
G4bool  scan = true 
)

Definition at line 319 of file G4Region.cc.

320 {
321  // Find and remove logical volume from the list
322  //
323  G4RootLVList::iterator pos;
324  pos = std::find(fRootVolumes.begin(),fRootVolumes.end(),lv);
325  if (pos != fRootVolumes.end())
326  {
327  if (fRootVolumes.size() != 1) // Avoid resetting flag for world since
328  { // volume may be already deleted !
329  lv->SetRegionRootFlag(false);
330  }
331  fRootVolumes.erase(pos);
332  }
333 
334  if (scan) // Update the materials list
335  {
337  }
338 
339  // Set region as modified
340  //
341  fRegionMod = true;
342 }
void SetRegionRootFlag(G4bool rreg)
void UpdateMaterialList()
Definition: G4Region.cc:360
static const G4double pos

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 169 of file G4Region.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

void G4Region::SetFastSimulationManager ( G4FastSimulationManager fsm)

Definition at line 128 of file G4Region.cc.

129 {
130  G4MT_fsmanager = fsm;
131 }
#define G4MT_fsmanager
Definition: G4Region.cc:46

Here is the caller graph for this function:

void G4Region::SetFieldManager ( G4FieldManager fm)
inline
void G4Region::SetName ( const G4String name)
inline
void G4Region::SetProductionCuts ( G4ProductionCuts cut)
inline

Here is the caller graph for this function:

void G4Region::SetRegionalSteppingAction ( G4UserSteppingAction rusa)

Definition at line 146 of file G4Region.cc.

147 {
148  G4MT_rsaction = rusa;
149 }
#define G4MT_rsaction
Definition: G4Region.cc:47

Here is the caller graph for this function:

void G4Region::SetUserInformation ( G4VUserRegionInformation ui)
inline
void G4Region::SetUserLimits ( G4UserLimits ul)
inline
void G4Region::SetWorld ( G4VPhysicalVolume wp)

Definition at line 382 of file G4Region.cc.

383 {
384  if(!wp)
385  { fWorldPhys = 0; }
386  else
387  { if(BelongsTo(wp)) fWorldPhys = wp; }
388 
389  return;
390 }
static unsigned wp
Definition: csz_inflate.cc:294
G4bool BelongsTo(G4VPhysicalVolume *thePhys) const
Definition: G4Region.cc:398

Here is the call graph for this function:

Here is the caller graph for this function:

void G4Region::UpdateMaterialList ( )

Definition at line 360 of file G4Region.cc.

361 {
362  // Reset the materials list
363  //
365 
366  // Loop over the root logical volumes and rebuild the list
367  // of materials from scratch
368  //
369  G4RootLVList::iterator pLV;
370  for (pLV=fRootVolumes.begin(); pLV!=fRootVolumes.end(); pLV++)
371  {
372  ScanVolumeTree(*pLV, true);
373  }
374 }
void ScanVolumeTree(G4LogicalVolume *lv, G4bool region)
Definition: G4Region.cc:169
void ClearMaterialList()
Definition: G4Region.cc:349

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the caller graph for this function:

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

Here is the caller graph for this function:


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