File indexing completed on 2026-05-05 08:34:03
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 using SPGeantGeo = GeantSetup::SPGeantGeo;
0081
0082
0083 public:
0084
0085 GeantImporter();
0086
0087
0088 explicit GeantImporter(GeantSetup&& setup);
0089
0090
0091 ImportData operator()(DataSelection const& selection);
0092
0093
0094 ImportData operator()() final { return (*this)(DataSelection{}); }
0095
0096
0097 SPGeantGeo const& geo_params() const { return setup_.geo_params(); }
0098
0099 private:
0100
0101 GeantSetup setup_;
0102 };
0103
0104
0105
0106 ImportParticle import_particle(G4ParticleDefinition const& p);
0107
0108
0109
0110
0111 inline constexpr bool operator==(GeantImporter::DataSelection const& lhs,
0112 GeantImporter::DataSelection const& rhs)
0113 {
0114
0115 return lhs.particles == rhs.particles
0116 && lhs.materials == rhs.materials
0117 && lhs.processes == rhs.processes
0118 && lhs.unique_volumes == rhs.unique_volumes
0119 && lhs.reader_data == rhs.reader_data;
0120
0121 }
0122
0123 inline bool operator!=(GeantImporter::DataSelection const& lhs,
0124 GeantImporter::DataSelection const& rhs)
0125 {
0126 return !(lhs == rhs);
0127 }
0128
0129 #if !CELERITAS_USE_GEANT4
0130 inline GeantImporter::GeantImporter()
0131 {
0132 CELER_NOT_CONFIGURED("Geant4");
0133 }
0134
0135 inline GeantImporter::GeantImporter(GeantSetup&&)
0136 {
0137 CELER_NOT_CONFIGURED("Geant4");
0138 }
0139
0140 inline ImportData GeantImporter::operator()(DataSelection const&)
0141 {
0142 CELER_ASSERT_UNREACHABLE();
0143 }
0144 #endif
0145
0146
0147 }