Low-level Celeritas integration

This subsection contains details of importing Geant4 data into Celeritas.

Geant4 geometry utilities

These utility classes are used to set up the Geant4 global geometry state.

class GeantGdmlLoader

Load a GDML file into memory.

The pointer treatment gives three options:

  • ignore leaves names as they are imported by Geant4’s GDML reader, which strips them from material/region names but leaves solid/logical/physical pointers in place.

  • truncate lets the Geant4 GDML remove the pointers, which cuts everything after 0x including suffixes like _refl added during volume construction.

  • remove uses a regular expression to remove pointers from volume names.

The detectors option reads auxiliary tags in the structure that have auxtype=SensDet and returns a multimap of strings to volume pointers.

inline G4VPhysicalVolume *celeritas::load_gdml(std::string const &filename)

Load a Geant4 geometry, excising pointers.

This provides a good default for using GDML in Celeritas.

Returns:

Geant4-owned world volume

inline void celeritas::save_gdml(G4VPhysicalVolume const *world, std::string const &out_filename)

Write a GDML file to the given filename.

inline std::unordered_set<G4LogicalVolume const*> celeritas::find_geant_volumes(std::unordered_set<std::string> names)

Find Geant4 logical volumes corresponding to a list of names.

If logical volumes with duplicate names are present, they will all show up in the output and a warning will be emitted. If one is missing, a RuntimeError will be raised.

static std::string_view const labels[] = {"Vol1", "Vol2"};
auto vols = find_geant_volumes(make_span(labels));

Geant4 physics interfaces

class GeantImporter : public celeritas::ImporterInterface

Load problem data directly from Geant4.

This can be used to circumvent ROOT as a serialization tool, whether to simplify the toolchain or to integrate better with user frameworks. As much data as possible is imported (subject to the data selection); downstream Celeritas classes will validate the imported data as needed.

GeantImporter import(GeantSetup("blah.gdml"));
ImportData data = import();
or to import from an existing, initialized Geant4 state:
GeantImport import(world_volume);
ImportData data = import();

class GeantSetup

Construct a Geant 4 run manager and populate internal Geant4 physics.

This is usually passed directly into GeantImporter . It hides Geant4 implementation details (including header files) from the rest of the code. It is safe to include even when Geant4 is unavailable!

The setup is targeted specifically for physics that Celeritas supports.

Todo:

This is a hot mess; it needs to be unified with inp/setup and not passed around by moving it.