Base class orchestrating the conversion of a GVolume into a Geant4 representation.
More...
#include <g4objectsFactory.h>
|
| virtual G4VSolid * | buildSolid (const GVolume *s, std::unordered_map< std::string, G4Volume * > *g4s)=0 |
| | Build the G4VSolid for a volume.
|
| |
| virtual G4LogicalVolume * | buildLogical (const GVolume *s, std::unordered_map< std::string, G4Volume * > *g4s) |
| | Build or retrieve the G4LogicalVolume for a volume.
|
| |
| virtual G4VPhysicalVolume * | buildPhysical (const GVolume *s, std::unordered_map< std::string, G4Volume * > *g4s) |
| | Build or retrieve the G4VPhysicalVolume for a volume.
|
| |
| G4Volume * | getOrCreateG4Volume (const std::string &volume_name, std::unordered_map< std::string, G4Volume * > *g4s) |
| | Get or create a G4Volume wrapper entry in the map.
|
| |
| G4VisAttributes | createVisualAttributes (const GVolume *s) |
| | Build visualization attributes from the volume definition.
|
| |
| bool | checkSolidDependencies (const GVolume *s, std::unordered_map< std::string, G4Volume * > *g4s) |
| | Check whether all prerequisites to build a solid are satisfied.
|
| |
| bool | checkPhysicalDependencies (const GVolume *s, std::unordered_map< std::string, G4Volume * > *g4s) |
| | Verify prerequisites to build a physical placement.
|
| |
|
| static G4VSolid * | getSolidFromMap (const std::string &volume_name, std::unordered_map< std::string, G4Volume * > *g4s) |
| | Lookup solid in the g4s map.
|
| |
| static G4LogicalVolume * | getLogicalFromMap (const std::string &volume_name, std::unordered_map< std::string, G4Volume * > *g4s) |
| | Lookup logical volume in the g4s map.
|
| |
| static G4VPhysicalVolume * | getPhysicalFromMap (const std::string &volume_name, std::unordered_map< std::string, G4Volume * > *g4s) |
| | Lookup physical volume in the g4s map.
|
| |
| static bool | checkLogicalDependencies (const GVolume *s, std::unordered_map< std::string, G4Volume * > *g4s) |
| | Logical dependency check placeholder.
|
| |
| static G4RotationMatrix * | getRotation (const GVolume *s) |
| | Parse rotation string and build a Geant4 rotation matrix.
|
| |
| static G4ThreeVector | getPosition (const GVolume *s) |
| | Parse position and optional shift strings to compute placement translation.
|
| |
The public entry point build_g4volume() ensures that a volume has:
- a
G4VSolid
- a
G4LogicalVolume
- a
G4VPhysicalVolume
The factory may short-circuit and return false when dependencies are not available yet (for example, a mother volume is not built). The world builder can then retry on a later pass.
Definition at line 52 of file g4objectsFactory.h.
◆ ~G4ObjectsFactory()
| G4ObjectsFactory::~G4ObjectsFactory |
( |
| ) |
|
|
overridedefault |
Virtual destructor (subclasses may own additional resources).
◆ G4ObjectsFactory()
| G4ObjectsFactory::G4ObjectsFactory |
( |
const std::shared_ptr< GOptions > & | g | ) |
|
|
inlineexplicit |
- Parameters
-
| g | Shared option set used to initialize the logging base and other behaviors. |
Definition at line 62 of file g4objectsFactory.h.
◆ build_g4volume()
| bool G4ObjectsFactory::build_g4volume |
( |
const GVolume * | s, |
|
|
std::unordered_map< std::string, G4Volume * > * | g4s ) |
- Parameters
-
| s | Pointer to the GEMC volume definition. |
| g4s | Map that stores and caches the resulting G4Volume wrappers. |
- Returns
true if solid, logical, and physical objects were successfully created; otherwise false.
This method calls:
Implementations are expected to return nullptr when dependencies are not satisfied.
Definition at line 186 of file g4objectsFactory.cc.
◆ buildLogical()
| G4LogicalVolume * G4ObjectsFactory::buildLogical |
( |
const GVolume * | s, |
|
|
std::unordered_map< std::string, G4Volume * > * | g4s ) |
|
protectedvirtual |
- Parameters
-
| s | Volume definition to convert. |
| g4s | Map of cached G4Volume wrappers. |
- Returns
- Pointer to the created/retrieved logical volume, or
nullptr if dependencies are missing.
The default implementation:
- ensures the solid exists (or it was copied from another volume)
- looks up the requested material in the Geant4 material tables
- optionally falls back to the configured backup material
- sets visualization attributes derived from the volume definition
Definition at line 102 of file g4objectsFactory.cc.
◆ buildPhysical()
| G4VPhysicalVolume * G4ObjectsFactory::buildPhysical |
( |
const GVolume * | s, |
|
|
std::unordered_map< std::string, G4Volume * > * | g4s ) |
|
protectedvirtual |
- Parameters
-
| s | Volume definition to convert. |
| g4s | Map of cached G4Volume wrappers. |
- Returns
- Pointer to the created/retrieved physical volume, or
nullptr if dependencies are missing.
The default implementation:
- checks existence and mother/logical dependencies
- computes rotation and translation from the volume definition
- places the logical volume into its mother via
G4PVPlacement
Definition at line 146 of file g4objectsFactory.cc.
◆ buildSolid()
| virtual G4VSolid * G4ObjectsFactory::buildSolid |
( |
const GVolume * | s, |
|
|
std::unordered_map< std::string, G4Volume * > * | g4s ) |
|
protectedpure virtual |
- Parameters
-
| s | Volume definition to convert. |
| g4s | Map of cached G4Volume wrappers. |
- Returns
- Pointer to the created/retrieved solid, or
nullptr on failure or missing dependencies.
Subclasses implement the actual conversion from the GEMC type/parameters to a Geant4 solid.
Implemented in G4CadSystemFactory, and G4NativeSystemFactory.
◆ checkLogicalDependencies()
| bool G4ObjectsFactory::checkLogicalDependencies |
( |
const GVolume * | s, |
|
|
std::unordered_map< std::string, G4Volume * > * | g4s ) |
|
staticprotected |
- Parameters
-
| s | Candidate volume. |
| g4s | Map containing all created wrappers so far. |
- Returns
- Always
true for now.
The hook exists for future extensions (material prerequisites, sensitive detector constraints, etc.).
Definition at line 72 of file geant4Dependencies.cc.
◆ checkPhysicalDependencies()
| bool G4ObjectsFactory::checkPhysicalDependencies |
( |
const GVolume * | s, |
|
|
std::unordered_map< std::string, G4Volume * > * | g4s ) |
|
protected |
- Parameters
-
| s | Candidate volume. |
| g4s | Map containing all created wrappers so far. |
- Returns
true if the candidate logical volume and mother logical volume exist; otherwise false.
This check ensures:
- the candidate wrapper exists in the map
- the candidate logical volume exists (or its copy source logical exists)
- the mother logical exists unless the candidate is the world volume
Definition at line 81 of file geant4Dependencies.cc.
◆ checkSolidDependencies()
| bool G4ObjectsFactory::checkSolidDependencies |
( |
const GVolume * | s, |
|
|
std::unordered_map< std::string, G4Volume * > * | g4s ) |
|
protected |
- Parameters
-
| s | Candidate volume. |
| g4s | Map containing all created wrappers so far. |
- Returns
true if dependencies are satisfied, otherwise false.
The function handles mutually exclusive scenarios:
- "copy of" another volume (solid already exists)
- boolean solid operations (operand solids must exist)
- ordinary primitive solids (no extra prerequisites)
Definition at line 20 of file geant4Dependencies.cc.
◆ className()
| virtual std::string_view G4ObjectsFactory::className |
( |
| ) |
const |
|
pure virtual |
◆ createVisualAttributes()
| G4VisAttributes G4ObjectsFactory::createVisualAttributes |
( |
const GVolume * | s | ) |
|
|
protected |
- Parameters
-
| s | Volume definition containing color/opacity/style/visibility. |
- Returns
- A
G4VisAttributes instance configured accordingly.
Definition at line 54 of file g4objectsFactory.cc.
◆ getLogicalFromMap()
| G4LogicalVolume * G4ObjectsFactory::getLogicalFromMap |
( |
const std::string & | volume_name, |
|
|
std::unordered_map< std::string, G4Volume * > * | g4s ) |
|
staticprotected |
◆ getOrCreateG4Volume()
| G4Volume * G4ObjectsFactory::getOrCreateG4Volume |
( |
const std::string & | volume_name, |
|
|
std::unordered_map< std::string, G4Volume * > * | g4s ) |
|
inlineprotected |
- Parameters
-
| volume_name | Key used for the volume. |
| g4s | Map holding cached wrappers. |
- Returns
- Pointer to an existing wrapper if found, otherwise a newly allocated wrapper.
The wrapper is created once and reused for solid/logical/physical caching across build passes.
Definition at line 173 of file g4objectsFactory.h.
◆ getPhysicalFromMap()
| G4VPhysicalVolume * G4ObjectsFactory::getPhysicalFromMap |
( |
const std::string & | volume_name, |
|
|
std::unordered_map< std::string, G4Volume * > * | g4s ) |
|
staticprotected |
◆ getPosition()
| G4ThreeVector G4ObjectsFactory::getPosition |
( |
const GVolume * | s | ) |
|
|
staticprotected |
- Parameters
-
| s | Volume definition containing position and optional shift. |
- Returns
- Translation vector to use for placement.
Definition at line 88 of file g4objectsFactory.cc.
◆ getRotation()
| G4RotationMatrix * G4ObjectsFactory::getRotation |
( |
const GVolume * | s | ) |
|
|
staticprotected |
- Parameters
-
| s | Volume definition containing rotation specification. |
- Returns
- Newly allocated
G4RotationMatrix pointer.
Definition at line 73 of file g4objectsFactory.cc.
◆ getSolidFromMap()
| G4VSolid * G4ObjectsFactory::getSolidFromMap |
( |
const std::string & | volume_name, |
|
|
std::unordered_map< std::string, G4Volume * > * | g4s ) |
|
staticprotected |
◆ initialize_context()
| void G4ObjectsFactory::initialize_context |
( |
int | checkOverlaps, |
|
|
const std::string & | backupMaterial ) |
- Parameters
-
| checkOverlaps | Forwarded to placement calls to enable overlap checking. |
| backupMaterial | Material name used if a requested material is missing. |
- If
backupMaterial is empty, a missing material is treated as an error.
- If overlap checking is enabled, placements may perform overlap checks at construction time.
Definition at line 27 of file g4objectsFactory.cc.
◆ backupMaterial
| std::string G4ObjectsFactory::backupMaterial |
|
protected |
Empty string means: no fallback; missing material lookup becomes fatal.
Definition at line 257 of file g4objectsFactory.h.
◆ checkOverlaps
| int G4ObjectsFactory::checkOverlaps {0} |
|
protected |
The documentation for this class was generated from the following files: