Celeritas 0.7.0-dev.79+develop.b3dc2e108
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
celeritas::GeantGeoParams Class Referencefinal

Manage and provide access to a Geant4 geometry model. More...

#include <GeantGeoParams.hh>

Inheritance diagram for celeritas::GeantGeoParams:
Inheritance graph
[legend]

Public Member Functions

 GeantGeoParams (G4VPhysicalVolume const *world, Ownership owns)
 Use an existing loaded Geant4 geometry.
 
 CELER_DEFAULT_MOVE_DELETE_COPY (GeantGeoParams)
 
 ~GeantGeoParams () final
 Clean up on destruction.
 
bool supports_safety () const final
 Whether safety distance calculations are accurate and precise.
 
BBox constbbox () const final
 Outer bounding box of geometry.
 
inp::Model make_model_input () const final
 Create model params from a Geant4 world volume.
 
ImplVolumeMap constimpl_volumes () const final
 Get volume metadata.
 
G4VPhysicalVolume constid_to_geant (VolumeInstanceId vol_id) const
 Get the Geant4 physical volume corresponding to a volume instance ID.
 
G4LogicalVolume constid_to_geant (VolumeId vol_id) const
 Get the Geant4 logical volume corresponding to a volume ID.
 
VolumeId volume_id (ImplVolumeId) const final
 Get the canonical volume IDs corresponding to an implementation volume.
 
SurfaceId::size_type num_surfaces () const
 Get the number of surfaces (TODO: maybe live in surface params?)
 
G4LogicalSurface constid_to_geant (SurfaceId surf_id) const
 Get the Geant4 logical surface corresponding to a surface ID.
 
ImplVolumeId::size_type lv_offset () const
 Offset of logical volume ID after reloading geometry.
 
GeoMatId::size_type mat_offset () const
 Offset of material index after reloading geometry.
 
GeoMatId geant_to_id (G4Material const &mat) const
 Get the geometry material ID for a logical volume.
 
VolumeId geant_to_id (G4LogicalVolume const &volume) const
 Locate the volume ID corresponding to a Geant4 logical volume.
 
VolumeInstanceId geant_to_id (G4VPhysicalVolume const &volume) const
 Get the volume instance ID corresponding to a Geant4 physical volume.
 
BoundingBox< doubleget_clhep_bbox () const
 Get the world bbox.
 
HostRef consthost_ref () const final
 Access geometry data on host.
 
DeviceRef constdevice_ref () const final
 No GPU support code.
 
G4VPhysicalVolume constworld () const
 
G4VPhysicalVolumeworld ()
 
- Public Member Functions inherited from celeritas::GeoParamsInterface
virtual ~GeoParamsInterface ()=0
 Default virtual destructor.
 
- Public Member Functions inherited from celeritas::ParamsDataInterface< GeantGeoParamsData >
GeantGeoParamsData< Ownership::const_reference, M > const & ref () const
 
GeantGeoParamsData< Ownership::const_reference, M > const & ref () const
 Dispatch a "ref" call to host or device data.
 

Static Public Member Functions

static std::shared_ptr< GeantGeoParamsfrom_tracking_manager ()
 Create from a running Geant4 application.
 
static std::shared_ptr< GeantGeoParamsfrom_gdml (std::string const &filename)
 Construct from a GDML input.
 
static std::shared_ptr< GeantGeoParamsfrom_geant (std::shared_ptr< GeantGeoParams const > const &geo)
 Return the input geometry for a consistent interface.
 

Additional Inherited Members

- Public Types inherited from celeritas::GeoParamsInterface
using SpanConstVolumeId = Span< ImplVolumeId const >
 
using ImplVolumeMap = LabelIdMultiMap< ImplVolumeId >
 
- Public Types inherited from celeritas::ParamsDataInterface< GeantGeoParamsData >
using HostRef = HostCRef< GeantGeoParamsData >
 
using DeviceRef = DeviceCRef< GeantGeoParamsData >
 
- Protected Member Functions inherited from celeritas::GeoParamsInterface
 CELER_DEFAULT_COPY_MOVE (GeoParamsInterface)
 
- Protected Member Functions inherited from celeritas::ParamsDataInterface< GeantGeoParamsData >
 CELER_DEFAULT_COPY_MOVE (ParamsDataInterface)
 

Detailed Description

Manage and provide access to a Geant4 geometry model.

This can be constructed directly by loading a GDML file, or in-memory using an existing physical volume. The make_model_input function returns the geometry hierarchy including surface definitions for optical physics. The geant_to_id and id_to_geant functions provide mappings between Geant4 pointers and Celeritas IDs.

The ImplVolumeId used by Celeritas is equal to the index of a G4LogicalVolume in the G4LogicalVolumeStore. Due to potential resetting of the geometry, the internal Geant4 ID for the volume may be offset from this index. Currently the ImplVolumeId maps exactly to the VolumeId value: some volumes may be unreachable by the world hierarchy.

In general, the G4VPhysicalVolume is equivalent to the index in its store. However, due to the way Geant4 represents "parameterised" and "replicated" placements, a single G4PV may correspond to multiple spatial placements. Celeritas disambiguates and maps each replicated instance to a distinct VolumeInstanceId (see detail::GeantVolumeInstanceMapper). When querying this ID from an in-memory physical volume, the returned value uses the G4PV's current state (i.e., the copy number). Similarly, calling id_to_geant on a volume instance ID for a replica volume will change the thread-local state of the G4VPhysicalVolume.

Each SurfaceId maps to a G4LogicalSurface instance, which is ether a G4LogicalBorderSurface (an "interface" surface between two volume instances) or a G4LogicalSkinSurface (a "boundary" surrounding a single logical volume). To ensure reproducible surface IDs across runs, we put boundaries before interfaces, and sort within each set by volume IDs (not by Geant4 object pointers, which is what the Geant4 implementation stores in a table). Surface labels are accessed via the SurfaceParams object, which can be created by the model input returned by this class.

Todo:
Much of the conversion should be factored out into a separate Model class which provides adapters to materials, detectors, and geometry structure.

Member Function Documentation

◆ bbox()

BBox const & celeritas::GeantGeoParams::bbox ( ) const
inlinefinalvirtual

Outer bounding box of geometry.

Implements celeritas::GeoParamsInterface.

◆ device_ref()

DeviceRef const & celeritas::GeantGeoParams::device_ref ( ) const
inlinefinalvirtual

No GPU support code.

Implements celeritas::ParamsDataInterface< GeantGeoParamsData >.

◆ from_gdml()

std::shared_ptr< GeantGeoParams > celeritas::GeantGeoParams::from_gdml ( std::string const filename)
static

Construct from a GDML input.

This assumes that Celeritas is driving and will manage Geant4 logging and exceptions. It saves the result to the global Celeritas Geant4 geometry weak pointer global_geant_geo.

Due to limitations in the Geant4 GDML code, this task must be performed from the main thread.

It also loads sensitive detectors and assigns dummy sensitive detectors to volumes annotated with auxiliary auxtype="SensDet" tags. It creates one detector per unique auxvalue name and shares that one among the volumes that use the same detector name. The resulting GeantGeoParams class retains ownership of the created detectors. Since this function is only called on the main thread, and the SensitiveDetector getter/setter on G4LogicalVolume uses a thread-local "split" class, worker threads will not see the sensitive detectors this loader creates. Use celeritas::DetectorConstruction if thread-local detectors are needed.

◆ from_tracking_manager()

std::shared_ptr< GeantGeoParams > celeritas::GeantGeoParams::from_tracking_manager ( )
static

Create from a running Geant4 application.

It saves the result to the global Celeritas Geant4 geometry weak pointer global_geant_geo.

◆ geant_to_id()

CELER_FORCEINLINE VolumeInstanceId celeritas::GeantGeoParams::geant_to_id ( G4VPhysicalVolume const volume) const
inline

Get the volume instance ID corresponding to a Geant4 physical volume.

Warning
For Geant4 parameterised/replicated volumes, external state (e.g. the local navigation) must be used in concert with this method: i.e., navigation on the current thread needs to have just "visited" the instance.

◆ get_clhep_bbox()

BoundingBox< double > celeritas::GeantGeoParams::get_clhep_bbox ( ) const

Get the world bbox.

This assumes no transformation on the global PV.

◆ host_ref()

HostRef const & celeritas::GeantGeoParams::host_ref ( ) const
inlinefinalvirtual

Access geometry data on host.

Implements celeritas::ParamsDataInterface< GeantGeoParamsData >.

◆ id_to_geant()

G4LogicalVolume const * celeritas::GeantGeoParams::id_to_geant ( VolumeId  id) const

Get the Geant4 logical volume corresponding to a volume ID.

If the input volume ID is unassigned, a null pointer will be returned.

◆ impl_volumes()

auto celeritas::GeantGeoParams::impl_volumes ( ) const
inlinefinalvirtual

Get volume metadata.

Volumes correspond directly to Geant4 logical volumes.

Implements celeritas::GeoParamsInterface.

◆ make_model_input()

inp::Model celeritas::GeantGeoParams::make_model_input ( ) const
finalvirtual

Create model params from a Geant4 world volume.

Implements celeritas::GeoParamsInterface.

◆ supports_safety()

bool celeritas::GeantGeoParams::supports_safety ( ) const
inlinefinalvirtual

Whether safety distance calculations are accurate and precise.

Implements celeritas::GeoParamsInterface.

◆ volume_id()

VolumeId celeritas::GeantGeoParams::volume_id ( ImplVolumeId  iv_id) const
inlinefinalvirtual

Get the canonical volume IDs corresponding to an implementation volume.

Note
See make_inp_volumes : for now, volume IDs and impl IDs are identical

Implements celeritas::GeoParamsInterface.

◆ world() [1/2]

G4VPhysicalVolume * celeritas::GeantGeoParams::world ( )
inline

Access the world volume

◆ world() [2/2]

G4VPhysicalVolume const * celeritas::GeantGeoParams::world ( ) const
inline

Access the world volume


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