Celeritas 0.6.0-67+develop.47f47c88
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
celeritas::GeantGeoParams Class Referencefinal

Shared Geant4 geometry model wrapper. More...

#include <GeantGeoParams.hh>

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

Public Types

Type aliases
using ReplicaId = GeantPhysicalInstance::ReplicaId
 
- Public Types inherited from celeritas::GeoParamsInterface
using SpanConstVolumeId = Span< VolumeId const >
 
using VolumeMap = LabelIdMultiMap< VolumeId >
 
using VolInstanceMap = LabelIdMultiMap< VolumeInstanceId >
 
- Public Types inherited from celeritas::ParamsDataInterface< GeantGeoParamsData >
using HostRef = HostCRef< GeantGeoParamsData >
 
using DeviceRef = DeviceCRef< GeantGeoParamsData >
 

Public Member Functions

 GeantGeoParams (std::string const &gdml_filename)
 Construct from a GDML input.
 
 GeantGeoParams (G4VPhysicalVolume const *world)
 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.
 
LevelId::size_type max_depth () const final
 Maximum nested volume instance depth.
 
inp::Model make_model_input () const final
 Create model params from a Geant4 world volume.
 
VolumeMap constvolumes () const final
 Get volume metadata.
 
VolInstanceMap constvolume_instances () const final
 Get volume instance metadata.
 
VolumeId find_volume (G4LogicalVolume const *volume) const final
 Locate the volume ID corresponding to a Geant4 logical volume.
 
GeantPhysicalInstance id_to_geant (VolumeInstanceId vol_id) const final
 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.
 
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.
 
VolumeId::size_type lv_offset () const
 Offset of logical volume ID after reloading geometry.
 
VolumeInstanceId::size_type pv_offset () const
 Offset of physical volume ID after reloading geometry.
 
GeoMatId::size_type mat_offset () const
 Offset of material index after reloading geometry.
 
VolumeId geant_to_id (G4LogicalVolume const &volume) const
 Get the volume ID corresponding to a Geant4 logical volume.
 
VolumeInstanceId geant_to_id (G4VPhysicalVolume const &volume) const
 Get the volume ID corresponding to a Geant4 physical volume.
 
ReplicaId replica_id (G4VPhysicalVolume const &volume) const
 Get the replica ID corresponding to a Geant4 physical volume.
 
BoundingBox< doubleget_clhep_bbox () const
 Get the world bbox.
 
void reset_replica_data () const
 Initialize thread-local mutable copy numbers for "replica" volumes.
 
HostRef consthost_ref () const final
 Access geometry data on host.
 
DeviceRef constdevice_ref () const final
 No GPU support code.
 
virtual VolumeId find_volume (G4LogicalVolume const *volume) const=0
 Get the volume ID corresponding to a Geant4 logical volume.
 
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.
 

Additional Inherited Members

- 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

Shared Geant4 geometry model wrapper.

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 VolumeId used by Celeritas is equal to the index of a G4LogicalVolume in the G4LogicalVolumeStore. Due to potential resetting of the geometry, the "volume instance ID" for the logical volume may be offset from this index.

Analogously, the G4VPhysicalVolume is equivalent to the index in its store. Due to the way Geant4 represents "parameterised" and "replicated" placements, a single PV may correspond to multiple spatial placements and is disambiguated with ReplicaId , which corresponds to the PV's "copy number".

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.

Constructor & Destructor Documentation

◆ GeantGeoParams()

celeritas::GeantGeoParams::GeantGeoParams ( std::string const filename)
explicit

Construct from a GDML input.

This assumes that Celeritas is driving and will manage Geant4 logging and exceptions.

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 >.

◆ find_volume() [1/2]

VolumeId celeritas::GeantGeoParams::find_volume ( G4LogicalVolume const volume) const
finalvirtual

Locate the volume ID corresponding to a Geant4 logical volume.

Implements celeritas::GeoParamsInterface.

◆ find_volume() [2/2]

virtual VolumeId celeritas::GeoParamsInterface::find_volume ( G4LogicalVolume const volume) const
virtual

Get the volume ID corresponding to a Geant4 logical volume.

Implements celeritas::GeoParamsInterface.

◆ geant_to_id()

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

Get the volume ID corresponding to a Geant4 physical volume.

Note
See id_to_geant: the volume instance ID may be non-unique.

◆ 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() [1/2]

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.

◆ id_to_geant() [2/2]

GeantPhysicalInstance celeritas::GeantGeoParams::id_to_geant ( VolumeInstanceId  id) const
finalvirtual

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

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.
Todo:
Create our own volume instance mapping for Geant4, where VolumeInstanceId corresponds to a (G4PV*, int) pair rather than just G4PV* (which in Geant4 is not sufficiently unique). See https://jira-geant4.kek.jp/browse/UR-100 and https://github.com/celeritas-project/celeritas/issues/1748 . When this is done, update g4org::PhysicalVolume .

Implements celeritas::GeoParamsInterface.

◆ make_model_input()

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

Create model params from a Geant4 world volume.

Todo:
Eventually (see #1815) the label map will be stored as part of the volumes and referenced by the geometry, rather than vice versa.

Implements celeritas::GeoParamsInterface.

◆ max_depth()

LevelId::size_type celeritas::GeantGeoParams::max_depth ( ) const
inlinefinalvirtual

Maximum nested volume instance depth.

Todo:
move to VolumeParams

Implements celeritas::GeoParamsInterface.

◆ replica_id()

auto celeritas::GeantGeoParams::replica_id ( G4VPhysicalVolume const volume) const

Get the replica ID corresponding to a Geant4 physical volume.

If the volume is not parameterized or replicated, the result is false.

◆ reset_replica_data()

void celeritas::GeantGeoParams::reset_replica_data ( ) const

Initialize thread-local mutable copy numbers for "replica" volumes.

Copy numbers for "replica" volumes (where one instance pretends to be many different volumes) are uninitialized (older Geant4) or initialized to -1. To avoid reading invalid or returning an invalid instance, set all the replica copy numbers to zero.

◆ supports_safety()

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

Whether safety distance calculations are accurate and precise.

Implements celeritas::GeoParamsInterface.

◆ volume_instances()

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

Get volume instance metadata.

Volume instances correspond directly to Geant4 physical volumes.

Implements celeritas::GeoParamsInterface.

◆ volumes()

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

Get volume metadata.

Volumes correspond directly to Geant4 logical volumes.

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: