File indexing completed on 2025-09-17 08:53:37
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <memory>
0010
0011 #include "corecel/Config.hh"
0012
0013 #include "celeritas/io/ImportData.hh"
0014 #include "celeritas/io/ImporterInterface.hh"
0015
0016 #include "GeantSetup.hh"
0017
0018
0019 class G4VPhysicalVolume;
0020 class G4ParticleDefinition;
0021
0022 namespace celeritas
0023 {
0024
0025
0026 struct GeantImportDataSelection
0027 {
0028
0029 using Flags = unsigned int;
0030 enum : unsigned int
0031 {
0032 none = 0x0,
0033 dummy = 0x1,
0034 em_basic = 0x2,
0035 em_ex = 0x4,
0036 optical = 0x8,
0037 em = em_basic | em_ex,
0038 hadron = 0x10,
0039 };
0040
0041 Flags particles = em | optical;
0042 bool materials = true;
0043 Flags processes = em | optical;
0044
0045
0046 bool unique_volumes = false;
0047
0048
0049 bool reader_data = true;
0050
0051
0052 inp::Interpolation interpolation{};
0053 };
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074 class GeantImporter final : public ImporterInterface
0075 {
0076 public:
0077
0078
0079 using DataSelection = GeantImportDataSelection;
0080
0081
0082 public:
0083
0084 static G4VPhysicalVolume const* get_world_volume();
0085
0086
0087 explicit GeantImporter(G4VPhysicalVolume const* world);
0088
0089
0090 explicit GeantImporter(GeantSetup&& setup);
0091
0092
0093 ImportData operator()(DataSelection const& selection);
0094
0095
0096 ImportData operator()() final { return (*this)(DataSelection{}); }
0097
0098 private:
0099
0100 GeantSetup setup_;
0101
0102 G4VPhysicalVolume const* world_{nullptr};
0103 };
0104
0105
0106
0107 std::vector<ImportVolume> import_volumes(G4VPhysicalVolume const& world);
0108
0109 ImportParticle import_particle(G4ParticleDefinition const& p);
0110
0111
0112
0113
0114 inline constexpr bool operator==(GeantImporter::DataSelection const& lhs,
0115 GeantImporter::DataSelection const& rhs)
0116 {
0117
0118 return lhs.particles == rhs.particles
0119 && lhs.materials == rhs.materials
0120 && lhs.processes == rhs.processes
0121 && lhs.unique_volumes == rhs.unique_volumes
0122 && lhs.reader_data == rhs.reader_data;
0123
0124 }
0125
0126 inline bool operator!=(GeantImporter::DataSelection const& lhs,
0127 GeantImporter::DataSelection const& rhs)
0128 {
0129 return !(lhs == rhs);
0130 }
0131
0132 #if !CELERITAS_USE_GEANT4
0133 inline G4VPhysicalVolume const* GeantImporter::get_world_volume()
0134 {
0135 CELER_NOT_CONFIGURED("Geant4");
0136 }
0137
0138 inline GeantImporter::GeantImporter(G4VPhysicalVolume const*)
0139 {
0140 CELER_DISCARD(world_);
0141 CELER_NOT_CONFIGURED("Geant4");
0142 }
0143
0144 inline GeantImporter::GeantImporter(GeantSetup&&)
0145 {
0146 CELER_NOT_CONFIGURED("Geant4");
0147 }
0148
0149 inline ImportData GeantImporter::operator()(DataSelection const&)
0150 {
0151 CELER_ASSERT_UNREACHABLE();
0152 }
0153 #endif
0154
0155
0156 }