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::G4Region ( const G4String name  ) 

Definition at line 48 of file G4Region.cc.

References G4endl, G4Exception(), G4RegionStore::GetInstance(), G4RegionStore::GetRegion(), JustWarning, and G4RegionStore::Register().

00049   : fName(pName), fRegionMod(true), fCut(0), fUserInfo(0), fUserLimits(0),
00050     fFieldManager(0), fFastSimulationManager(0), fWorldPhys(0),
00051     fRegionalSteppingAction(0),
00052     fInMassGeometry(false), fInParallelGeometry(false)
00053 {
00054   G4RegionStore* rStore = G4RegionStore::GetInstance();
00055   if (rStore->GetRegion(pName,false))
00056   {
00057     std::ostringstream message;
00058     message << "The region has NOT been registered !" << G4endl
00059             << "          Region " << pName << " already existing in store !"
00060             << G4endl;
00061     G4Exception("G4Region::G4Region()", "GeomMgt1001",
00062                 JustWarning, message);
00063   }
00064   else
00065   {
00066     rStore->Register(this);
00067   }
00068 }

G4Region::~G4Region (  )  [virtual]

Definition at line 91 of file G4Region.cc.

References G4RegionStore::DeRegister(), and G4RegionStore::GetInstance().

00092 {
00093   G4RegionStore::GetInstance()->DeRegister(this);
00094   if(fUserInfo) delete fUserInfo;
00095 }

G4Region::G4Region ( __void__ &   ) 

Definition at line 75 of file G4Region.cc.

References G4RegionStore::GetInstance(), and G4RegionStore::Register().

00076   : fName(""), fRegionMod(true), fCut(0), fUserInfo(0), fUserLimits(0),
00077     fFieldManager(0), fFastSimulationManager(0), fWorldPhys(0),
00078     fRegionalSteppingAction(0),
00079     fInMassGeometry(false), fInParallelGeometry(false)
00080 {
00081   // Register to store
00082   //
00083   G4RegionStore::GetInstance()->Register(this);
00084 }


Member Function Documentation

void G4Region::AddRootLogicalVolume ( G4LogicalVolume lv  ) 

Definition at line 227 of file G4Region.cc.

References ScanVolumeTree(), and G4LogicalVolume::SetRegionRootFlag().

Referenced by G4RunManagerKernel::DefineWorldVolume().

00228 {
00229   // Check the logical volume is not already in the list
00230   //
00231   G4RootLVList::iterator pos;
00232   pos = std::find(fRootVolumes.begin(),fRootVolumes.end(),lv);
00233   if (pos == fRootVolumes.end())
00234   {
00235     // Insert the root volume in the list and set it as root region
00236     //
00237     fRootVolumes.push_back(lv);
00238     lv->SetRegionRootFlag(true);
00239   }
00240 
00241   // Scan recursively the tree of daugther volumes and set regions
00242   //
00243   ScanVolumeTree(lv, true);
00244 
00245   // Set region as modified
00246   //
00247   fRegionMod = true;
00248 }

G4bool G4Region::BelongsTo ( G4VPhysicalVolume thePhys  )  const

Definition at line 335 of file G4Region.cc.

References G4LogicalVolume::GetDaughter(), G4VPhysicalVolume::GetLogicalVolume(), G4LogicalVolume::GetNoDaughters(), and G4LogicalVolume::GetRegion().

Referenced by SetWorld().

00336 {
00337   G4LogicalVolume* currLog = thePhys->GetLogicalVolume();
00338   if (currLog->GetRegion()==this) {return true;}
00339 
00340   G4int nDaughters = currLog->GetNoDaughters();
00341   while (nDaughters--)
00342   {
00343     if (BelongsTo(currLog->GetDaughter(nDaughters))) {return true;}
00344   }
00345 
00346   return false;
00347 }

void G4Region::ClearFastSimulationManager (  ) 

Definition at line 355 of file G4Region.cc.

References G4endl, G4Exception(), GetFastSimulationManager(), GetParentRegion(), and JustWarning.

Referenced by G4FastSimulationManager::~G4FastSimulationManager().

00356 {
00357   G4bool isUnique;
00358   G4Region* parent = GetParentRegion(isUnique);
00359   if(parent)
00360   {
00361     if (isUnique)
00362     {
00363       fFastSimulationManager = parent->GetFastSimulationManager();
00364     }
00365     else
00366     {
00367       std::ostringstream message;
00368       message << "Region <" << fName << "> belongs to more than"
00369               << " one parent region !" << G4endl
00370               << "A region cannot belong to more than one direct parent region,"
00371               << G4endl
00372               << "to have fast-simulation assigned.";
00373       G4Exception("G4Region::ClearFastSimulationManager()",
00374                   "GeomMgt1002", JustWarning, message);
00375       fFastSimulationManager = 0;
00376     }
00377   }
00378   else
00379   {
00380     fFastSimulationManager = 0;
00381   }
00382 }

void G4Region::ClearMap (  )  [inline]

Definition at line 196 of file G4Region.icc.

00197 {
00198   if(!(fMaterialCoupleMap.empty()))
00199   {
00200     G4MaterialCoupleMap::iterator b = fMaterialCoupleMap.begin();
00201     G4MaterialCoupleMap::iterator e = fMaterialCoupleMap.end();
00202     fMaterialCoupleMap.erase(b,e);
00203   }
00204 }

void G4Region::ClearMaterialList (  ) 

Definition at line 286 of file G4Region.cc.

Referenced by UpdateMaterialList().

00287 {
00288   fMaterials.clear();
00289 }

G4MaterialCutsCouple * G4Region::FindCouple ( G4Material mat  )  [inline]

Definition at line 222 of file G4Region.icc.

Referenced by G4LogicalVolume::UpdateMaterial().

00223 {
00224   G4MaterialCoupleMap::iterator c = fMaterialCoupleMap.find(mat);
00225   G4MaterialCutsCouple* couple = 0;
00226   if(c!=fMaterialCoupleMap.end()) couple = (*c).second;
00227   return couple;
00228 }

G4FastSimulationManager * G4Region::GetFastSimulationManager (  )  const [inline]

Definition at line 245 of file G4Region.icc.

Referenced by ClearFastSimulationManager(), G4RunManagerKernel::DumpRegion(), G4VFastSimulationModel::G4VFastSimulationModel(), G4LogicalVolume::GetFastSimulationManager(), and G4FastSimulationManager::~G4FastSimulationManager().

00246 {
00247   return fFastSimulationManager;
00248 }

G4FieldManager * G4Region::GetFieldManager (  )  const [inline]

Definition at line 255 of file G4Region.icc.

Referenced by G4PropagatorInField::FindAndSetFieldManager().

00256 {
00257   return fFieldManager;
00258 }

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

Definition at line 125 of file G4Region.icc.

Referenced by G4RunManagerKernel::DumpRegion().

00126 {
00127   G4MaterialList::const_iterator iterator = fMaterials.begin();
00128   return iterator;
00129 }

const G4String & G4Region::GetName (  )  const [inline]

Definition at line 50 of file G4Region.icc.

Referenced by G4PhysicalVolumeModel::CreateCurrentAttValues(), G4RunManagerKernel::DefineWorldVolume(), G4EmModelManager::DumpModelList(), G4RunManagerKernel::DumpRegion(), G4FastSimulationManager::ListTitle(), and G4GlobalFastSimulationManager::ShowSetup().

00051 {
00052   return fName;
00053 }

size_t G4Region::GetNumberOfMaterials (  )  const [inline]

Definition at line 136 of file G4Region.icc.

Referenced by G4RunManagerKernel::DumpRegion().

00137 {
00138   return fMaterials.size();
00139 }

size_t G4Region::GetNumberOfRootVolumes (  )  const [inline]

Definition at line 146 of file G4Region.icc.

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

00147 {
00148   return fRootVolumes.size();
00149 }

G4Region * G4Region::GetParentRegion ( G4bool unique  )  const

Definition at line 390 of file G4Region.cc.

References G4LogicalVolumeStore::GetInstance().

Referenced by ClearFastSimulationManager().

00391 {
00392   G4Region* parent = 0; unique = true;
00393   G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
00394   G4LogicalVolumeStore::iterator lvItr;
00395 
00396   // Loop over all logical volumes in the store
00397   //
00398   for(lvItr=lvStore->begin(); lvItr!=lvStore->end(); lvItr++)
00399   {
00400     G4int nD = (*lvItr)->GetNoDaughters();
00401     G4Region* aR = (*lvItr)->GetRegion();
00402 
00403     // Loop over all daughters of each logical volume
00404     //
00405     for(G4int iD=0; iD<nD; iD++)
00406     {
00407       if((*lvItr)->GetDaughter(iD)->GetLogicalVolume()->GetRegion()==this)
00408       { 
00409         if(parent)
00410         {
00411           if(parent!=aR) { unique = false; }
00412         }
00413         else  // Cache LV parent region which includes a daughter volume
00414               // with the same associated region as the current one
00415         {
00416           parent = aR;
00417         }
00418       }
00419     }
00420   }
00421   return parent;
00422 }

G4ProductionCuts * G4Region::GetProductionCuts (  )  const [inline]

Definition at line 101 of file G4Region.icc.

Referenced by G4RunManagerKernel::DumpRegion(), G4EmCalculator::FindCouple(), G4VUserPhysicsList::GetCutValue(), G4VAtomDeexcitation::InitialiseAtomicDeexcitation(), and G4VUserPhysicsList::SetParticleCuts().

00102 {
00103   return fCut;
00104 }

G4UserSteppingAction * G4Region::GetRegionalSteppingAction (  )  const [inline]

Definition at line 311 of file G4Region.icc.

Referenced by G4RunManagerKernel::DumpRegion(), and G4SteppingManager::Stepping().

00312 {
00313   return fRegionalSteppingAction;
00314 }

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

Definition at line 112 of file G4Region.icc.

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

00113 {
00114   G4RootLVList::iterator iterator =
00115     G4RootLVList::iterator(fRootVolumes.begin());
00116   return iterator;
00117 }

G4VUserRegionInformation * G4Region::GetUserInformation (  )  const [inline]

Definition at line 166 of file G4Region.icc.

Referenced by G4RunManagerKernel::DumpRegion().

00167 {
00168   return fUserInfo;
00169 }

G4UserLimits * G4Region::GetUserLimits (  )  const [inline]

Definition at line 186 of file G4Region.icc.

Referenced by G4RunManagerKernel::DumpRegion(), and G4LogicalVolume::GetUserLimits().

00187 {
00188   return fUserLimits;
00189 }

G4VPhysicalVolume * G4Region::GetWorldPhysical (  )  const [inline]

Definition at line 275 of file G4Region.icc.

Referenced by G4RunManagerKernel::DumpRegion(), and G4FastSimulationManager::ListTitle().

00276 {
00277   return fWorldPhys;
00278 }

G4bool G4Region::IsInMassGeometry (  )  const [inline]

Definition at line 341 of file G4Region.icc.

Referenced by G4RunManagerKernel::DumpRegion().

00342 {
00343   return fInMassGeometry;
00344 }

G4bool G4Region::IsInParallelGeometry (  )  const [inline]

Definition at line 351 of file G4Region.icc.

Referenced by G4RunManagerKernel::DumpRegion().

00352 {
00353   return fInParallelGeometry;
00354 }

G4bool G4Region::IsModified (  )  const [inline]

Definition at line 80 of file G4Region.icc.

00081 {
00082   return fRegionMod;
00083 }

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

Definition at line 40 of file G4Region.icc.

00041 {
00042   return (this==&rg) ? true : false;
00043 }

void G4Region::RegionModified ( G4bool  flag  )  [inline]

Definition at line 70 of file G4Region.icc.

Referenced by G4LogicalVolume::AddDaughter(), G4LogicalVolume::ClearDaughters(), and G4LogicalVolume::RemoveDaughter().

00071 {
00072   fRegionMod = flag;
00073 }

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

Definition at line 211 of file G4Region.icc.

00213 {
00214   fMaterialCoupleMap.insert(G4MaterialCouplePair(mat,couple));
00215 }

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

Definition at line 256 of file G4Region.cc.

References G4LogicalVolume::SetRegionRootFlag(), and UpdateMaterialList().

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

00257 {
00258   // Find and remove logical volume from the list
00259   //
00260   G4RootLVList::iterator pos;
00261   pos = std::find(fRootVolumes.begin(),fRootVolumes.end(),lv);
00262   if (pos != fRootVolumes.end())
00263   {
00264     if (fRootVolumes.size() != 1)  // Avoid resetting flag for world since
00265     {                              // volume may be already deleted !
00266       lv->SetRegionRootFlag(false);
00267     }
00268     fRootVolumes.erase(pos);
00269   }
00270 
00271   if (scan)  // Update the materials list
00272   {
00273     UpdateMaterialList();
00274   }
00275 
00276   // Set region as modified
00277   //
00278   fRegionMod = true;
00279 }

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

Definition at line 106 of file G4Region.cc.

References FatalException, G4endl, G4Exception(), G4LogicalVolume::GetDaughter(), G4VPhysicalVolume::GetLogicalVolume(), G4Material::GetMaterial(), G4LogicalVolume::GetMaterial(), G4VPVParameterisation::GetMaterialScanner(), G4VPhysicalVolume::GetMultiplicity(), G4VPhysicalVolume::GetName(), G4LogicalVolume::GetName(), G4LogicalVolume::GetNoDaughters(), G4VVolumeMaterialScanner::GetNumberOfMaterials(), G4VPhysicalVolume::GetParameterisation(), G4VPhysicalVolume::IsParameterised(), and G4LogicalVolume::SetRegion().

Referenced by AddRootLogicalVolume(), G4LogicalVolume::PropagateRegion(), and UpdateMaterialList().

00107 {
00108   // If logical volume is going to become a region, add 
00109   // its material to the list if not already present
00110   //
00111   G4Region* currentRegion = 0;
00112   size_t noDaughters = lv->GetNoDaughters();
00113   G4Material* volMat = lv->GetMaterial();
00114   if(!volMat && fInMassGeometry)
00115   {
00116     std::ostringstream message;
00117     message << "Logical volume <" << lv->GetName() << ">" << G4endl
00118             << "does not have a valid material pointer." << G4endl
00119             << "A logical volume belonging to the (tracking) world volume "
00120             << "must have a valid material.";
00121     G4Exception("G4Region::ScanVolumeTree()", "GeomMgt0002",
00122                 FatalException, message, "Check your geometry construction.");
00123   }
00124   if (region)
00125   {
00126     currentRegion = this;
00127     if (volMat)
00128     { 
00129       AddMaterial(volMat); 
00130       G4Material* baseMat = const_cast<G4Material*>(volMat->GetBaseMaterial());
00131       if (baseMat) { AddMaterial(baseMat); }
00132     }
00133   }
00134 
00135   // Set the LV region to be either the current region or NULL,
00136   // according to the boolean selector
00137   //
00138   lv->SetRegion(currentRegion);
00139 
00140   // Stop recursion here if no further daughters are involved
00141   //
00142   if(noDaughters==0) return;
00143 
00144   G4VPhysicalVolume* daughterPVol = lv->GetDaughter(0);
00145   if (daughterPVol->IsParameterised())
00146   {
00147     // Adopt special treatment in case of parameterised volumes,
00148     // where parameterisation involves a new material scan
00149     //
00150     G4VPVParameterisation* pParam = daughterPVol->GetParameterisation();
00151 
00152     if (pParam->GetMaterialScanner())
00153     {
00154       size_t matNo = pParam->GetMaterialScanner()->GetNumberOfMaterials();
00155       for (register size_t mat=0; mat<matNo; mat++)
00156       {
00157         volMat = pParam->GetMaterialScanner()->GetMaterial(mat);
00158         if(!volMat && fInMassGeometry)
00159         {
00160           std::ostringstream message;
00161           message << "The parameterisation for the physical volume <"
00162                   << daughterPVol->GetName() << ">" << G4endl
00163                   << "does not return a valid material pointer." << G4endl
00164                   << "A volume belonging to the (tracking) world volume must "
00165                   << "have a valid material.";
00166           G4Exception("G4Region::ScanVolumeTree()", "GeomMgt0002",
00167                       FatalException, message, "Check your parameterisation.");
00168         }
00169         if (volMat)
00170         { 
00171           AddMaterial(volMat); 
00172           G4Material* baseMat = const_cast<G4Material*>(volMat->GetBaseMaterial());
00173           if (baseMat) { AddMaterial(baseMat); }
00174         }
00175       }
00176     }
00177     else
00178     {
00179       size_t repNo = daughterPVol->GetMultiplicity();
00180       for (register size_t rep=0; rep<repNo; rep++)
00181       {
00182         volMat = pParam->ComputeMaterial(rep, daughterPVol);
00183         if(!volMat && fInMassGeometry)
00184         {
00185           std::ostringstream message;
00186           message << "The parameterisation for the physical volume <"
00187                   << daughterPVol->GetName() << ">" << G4endl
00188                   << "does not return a valid material pointer." << G4endl
00189                   << "A volume belonging to the (tracking) world volume must "
00190                   << "have a valid material.";
00191           G4Exception("G4Region::ScanVolumeTree()", "GeomMgt0002",
00192                       FatalException, message, "Check your parameterisation.");
00193         }
00194         if(volMat)
00195         { 
00196           AddMaterial(volMat);
00197           G4Material* baseMat = const_cast<G4Material*>(volMat->GetBaseMaterial());
00198           if (baseMat) { AddMaterial(baseMat); }
00199         }
00200       }
00201     }
00202     G4LogicalVolume* daughterLVol = daughterPVol->GetLogicalVolume();
00203     ScanVolumeTree(daughterLVol, region);
00204   }
00205   else
00206   {
00207     for (register size_t i=0; i<noDaughters; i++)
00208     {
00209       G4LogicalVolume* daughterLVol = lv->GetDaughter(i)->GetLogicalVolume();
00210       if (!daughterLVol->IsRootRegion())
00211       {
00212         // Set daughter's LV to be a region and store materials in
00213         // the materials list, if the LV is not already a root region
00214         //
00215         ScanVolumeTree(daughterLVol, region);
00216       }
00217     }
00218   }
00219 }

void G4Region::SetFastSimulationManager ( G4FastSimulationManager fsm  )  [inline]

Definition at line 235 of file G4Region.icc.

Referenced by G4FastSimulationManager::G4FastSimulationManager().

00236 {
00237   fFastSimulationManager = fsm;
00238 }

void G4Region::SetFieldManager ( G4FieldManager fm  )  [inline]

Definition at line 265 of file G4Region.icc.

00266 {
00267   fFieldManager = fm;
00268 }

void G4Region::SetName ( const G4String name  )  [inline]

Definition at line 60 of file G4Region.icc.

00061 {
00062   fName = pName;
00063 }

void G4Region::SetProductionCuts ( G4ProductionCuts cut  )  [inline]

Definition at line 90 of file G4Region.icc.

Referenced by G4RunManagerKernel::DumpRegion(), and G4RunManagerKernel::G4RunManagerKernel().

00091 {
00092   fCut = cut;
00093   fRegionMod = true;
00094 }

void G4Region::SetRegionalSteppingAction ( G4UserSteppingAction rusa  )  [inline]

Definition at line 301 of file G4Region.icc.

00302 {
00303   fRegionalSteppingAction = rusa;
00304 }

void G4Region::SetUserInformation ( G4VUserRegionInformation ui  )  [inline]

Definition at line 156 of file G4Region.icc.

00157 {
00158   fUserInfo = ui;
00159 }

void G4Region::SetUserLimits ( G4UserLimits ul  )  [inline]

Definition at line 176 of file G4Region.icc.

00177 {
00178   fUserLimits = ul;
00179 }

void G4Region::SetWorld ( G4VPhysicalVolume wp  ) 

Definition at line 319 of file G4Region.cc.

References BelongsTo().

00320 {
00321   if(!wp)
00322   { fWorldPhys = 0; }
00323   else
00324   { if(BelongsTo(wp)) fWorldPhys = wp; }
00325 
00326   return;
00327 }

void G4Region::UpdateMaterialList (  ) 

Definition at line 297 of file G4Region.cc.

References ClearMaterialList(), and ScanVolumeTree().

Referenced by RemoveRootLogicalVolume().

00298 {
00299   // Reset the materials list
00300   //
00301   ClearMaterialList();
00302 
00303   // Loop over the root logical volumes and rebuild the list
00304   // of materials from scratch
00305   //
00306   G4RootLVList::iterator pLV;
00307   for (pLV=fRootVolumes.begin(); pLV!=fRootVolumes.end(); pLV++)
00308   {
00309     ScanVolumeTree(*pLV, true);
00310   }
00311 }

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

Definition at line 321 of file G4Region.icc.

00322 {
00323   fInMassGeometry = val;
00324 }

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

Definition at line 331 of file G4Region.icc.

00332 {
00333   fInParallelGeometry = val;
00334 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:16 2013 for Geant4 by  doxygen 1.4.7