g4system
Loading...
Searching...
No Matches

Builds a full Geant4 geometry "world" from a GEMC GWorld description. More...

#include <g4world.h>

Public Member Functions

 G4World (const GWorld *gworld, const std::shared_ptr< GOptions > &gopts)
 Construct and build the Geant4 world from a GEMC world.
 
const G4VolumegetG4Volume (const std::string &volumeName) const
 Return the G4Volume wrapper for a volume name.
 
void setFieldManagerForVolume (const std::string &volumeName, G4FieldManager *fm, bool forceToAllDaughters)
 Attach a G4FieldManager to the logical volume of a named volume.
 
bool is_empty () const noexcept
 Check whether the world currently has no cached volumes.
 
std::size_t number_of_volumes () const noexcept
 Number of volumes stored so far.
 
G4ObjectsFactoryget_factory (const std::string &factoryName)
 Retrieve a registered factory by name.
 
std::unordered_map< std::string, G4Volume * > get_g4volumes_map () const
 Return a copy of the current volume map (name → wrapper pointer).
 
- Public Member Functions inherited from GBase< G4World >
 GBase (const std::shared_ptr< GOptions > &gopt, std::string logger_name="")
 
 GBase (const std::shared_ptr< GLogger > &logger)
 
 GBase (const GBase &)=default
 
 GBase (GBase &&) noexcept=default
 
virtual ~GBase ()
 
GBaseoperator= (const GBase &)=default
 
GBaseoperator= (GBase &&) noexcept=default
 

Additional Inherited Members

- Protected Attributes inherited from GBase< G4World >
std::shared_ptr< GLoggerlog
 

Detailed Description

Public helpers let clients:

  • query a G4Volume by name
  • attach a G4FieldManager to a volume subtree (logical volume + daughters)
  • query whether any volumes were produced

Definition at line 49 of file g4world.h.

Constructor & Destructor Documentation

◆ G4World()

G4World::G4World ( const GWorld * gworld,
const std::shared_ptr< GOptions > & gopts )
Parameters
gworldPointer to the GEMC world object (volume/material definitions).
goptsGlobal options used by builders and factories (verbosity, overlap checks, backup material).

The constructor performs the full build:

  • initializes factories based on each system factory label
  • builds materials and default elements/isotopes
  • iteratively builds volumes until all resolvable dependencies are satisfied

Definition at line 32 of file g4world.cc.

Member Function Documentation

◆ get_factory()

G4ObjectsFactory * G4World::get_factory ( const std::string & factoryName)
inline
Parameters
factoryNameFactory label used as key in the internal factory map.
Returns
Pointer to the factory instance.

If the factory is missing, an error is emitted through the logger.

Definition at line 112 of file g4world.h.

◆ get_g4volumes_map()

std::unordered_map< std::string, G4Volume * > G4World::get_g4volumes_map ( ) const
inline
Returns
Copy of the internal map.
Note
This returns a copy intentionally; callers cannot mutate internal state through it.

Definition at line 127 of file g4world.h.

◆ getG4Volume()

const G4Volume * G4World::getG4Volume ( const std::string & volumeName) const
Parameters
volumeNameKey used in the internal volume map.
Returns
Pointer to the cached G4Volume wrapper, or nullptr if not found.

Definition at line 126 of file g4world.cc.

◆ is_empty()

bool G4World::is_empty ( ) const
inlinenoexcept
Returns
true if no volumes were built or cached, otherwise false.

Definition at line 95 of file g4world.h.

◆ number_of_volumes()

std::size_t G4World::number_of_volumes ( ) const
inlinenoexcept
Returns
Size of the internal volume map.

Definition at line 101 of file g4world.h.

◆ setFieldManagerForVolume()

void G4World::setFieldManagerForVolume ( const std::string & volumeName,
G4FieldManager * fm,
bool forceToAllDaughters )
Parameters
volumeNameName of the volume in the internal map.
fmField manager pointer to attach.
forceToAllDaughtersIf true, propagate to daughter logical volumes.

If the volume is not found, the method does nothing. If found but the logical volume is not yet available, the underlying wrapper ignores the request.

Definition at line 131 of file g4world.cc.


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