File indexing completed on 2025-09-17 08:59:57
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <string>
0010
0011 #include "corecel/Macros.hh"
0012 #include "corecel/Types.hh"
0013 #include "corecel/cont/LabelIdMultiMap.hh"
0014 #include "corecel/data/ParamsDataInterface.hh"
0015 #include "geocel/BoundingBox.hh"
0016 #include "geocel/GeoParamsInterface.hh"
0017 #include "geocel/Types.hh"
0018
0019 #include "GeantGeoData.hh"
0020
0021 class G4VPhysicalVolume;
0022
0023 namespace celeritas
0024 {
0025
0026 class ScopedGeantLogger;
0027 class ScopedGeantExceptionHandler;
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 class GeantGeoParams final : public GeoParamsInterface,
0039 public ParamsDataInterface<GeantGeoParamsData>
0040 {
0041 public:
0042
0043 explicit GeantGeoParams(std::string const& gdml_filename);
0044
0045
0046 explicit GeantGeoParams(G4VPhysicalVolume const* world);
0047
0048 CELER_DEFAULT_MOVE_DELETE_COPY(GeantGeoParams);
0049
0050
0051 ~GeantGeoParams() final;
0052
0053
0054 G4VPhysicalVolume const* world() const { return host_ref_.world; }
0055
0056
0057 bool supports_safety() const final { return true; }
0058
0059
0060 BBox const& bbox() const final { return bbox_; }
0061
0062
0063 LevelId::size_type max_depth() const final { return max_depth_; }
0064
0065
0066
0067
0068 inline VolumeMap const& volumes() const final;
0069
0070
0071 inline VolInstanceMap const& volume_instances() const final;
0072
0073
0074 VolumeId find_volume(G4LogicalVolume const* volume) const final;
0075
0076
0077 GeantPhysicalInstance id_to_geant(VolumeInstanceId vol_id) const final;
0078
0079
0080 G4LogicalVolume const* id_to_geant(VolumeId vol_id) const;
0081
0082
0083 using GeoParamsInterface::find_volume;
0084
0085
0086 VolumeId::size_type lv_offset() const { return lv_offset_; }
0087
0088
0089 VolumeId::size_type pv_offset() const { return pv_offset_; }
0090
0091
0092
0093
0094 HostRef const& host_ref() const final { return host_ref_; }
0095
0096
0097 DeviceRef const& device_ref() const final
0098 {
0099 CELER_NOT_IMPLEMENTED("Geant4 on GPU");
0100 }
0101
0102 private:
0103
0104
0105 bool loaded_gdml_{false};
0106 bool closed_geometry_{false};
0107 std::unique_ptr<ScopedGeantLogger> scoped_logger_;
0108 std::unique_ptr<ScopedGeantExceptionHandler> scoped_exceptions_;
0109
0110
0111 VolumeMap volumes_;
0112 VolInstanceMap vol_instances_;
0113 BBox bbox_;
0114 LevelId::size_type max_depth_{0};
0115 VolumeId::size_type lv_offset_{0};
0116 VolumeInstanceId::size_type pv_offset_{0};
0117
0118
0119 HostRef host_ref_;
0120
0121
0122
0123
0124 void build_tracking();
0125
0126
0127 void build_metadata();
0128 };
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138 auto GeantGeoParams::volumes() const -> VolumeMap const&
0139 {
0140 return volumes_;
0141 }
0142
0143
0144
0145
0146
0147
0148
0149 auto GeantGeoParams::volume_instances() const -> VolInstanceMap const&
0150 {
0151 return vol_instances_;
0152 }
0153
0154
0155 }