File indexing completed on 2025-02-22 10:31:20
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include <memory>
0011
0012 #include "corecel/Config.hh"
0013
0014 #include "celeritas/io/ImportData.hh"
0015 #include "celeritas/io/ImporterInterface.hh"
0016
0017 #include "GeantSetup.hh"
0018
0019
0020 class G4VPhysicalVolume;
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
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071 class GeantImporter final : public ImporterInterface
0072 {
0073 public:
0074
0075
0076 using DataSelection = GeantImportDataSelection;
0077
0078
0079 public:
0080
0081 static G4VPhysicalVolume const* get_world_volume();
0082
0083
0084 explicit GeantImporter(G4VPhysicalVolume const* world);
0085
0086
0087 explicit GeantImporter(GeantSetup&& setup);
0088
0089
0090 ImportData operator()(DataSelection const& selection);
0091
0092
0093 ImportData operator()() { return (*this)(DataSelection{}); }
0094
0095 private:
0096
0097 GeantSetup setup_;
0098
0099 G4VPhysicalVolume const* world_{nullptr};
0100
0101
0102
0103 std::vector<ImportVolume> import_volumes(bool unique_volumes) const;
0104 };
0105
0106
0107
0108
0109 inline bool operator==(GeantImporter::DataSelection const& lhs,
0110 GeantImporter::DataSelection const& rhs)
0111 {
0112 return lhs.particles == rhs.particles && lhs.processes == rhs.processes
0113 && lhs.reader_data == rhs.reader_data;
0114 }
0115
0116 inline bool operator!=(GeantImporter::DataSelection const& lhs,
0117 GeantImporter::DataSelection const& rhs)
0118 {
0119 return !(lhs == rhs);
0120 }
0121
0122 #if !CELERITAS_USE_GEANT4
0123 inline G4VPhysicalVolume const* GeantImporter::get_world_volume()
0124 {
0125 CELER_NOT_CONFIGURED("Geant4");
0126 }
0127
0128 inline GeantImporter::GeantImporter(G4VPhysicalVolume const*)
0129 {
0130 CELER_DISCARD(world_);
0131 CELER_NOT_CONFIGURED("Geant4");
0132 }
0133
0134 inline GeantImporter::GeantImporter(GeantSetup&&)
0135 {
0136 CELER_NOT_CONFIGURED("Geant4");
0137 }
0138
0139 inline ImportData GeantImporter::operator()(DataSelection const&)
0140 {
0141 CELER_ASSERT_UNREACHABLE();
0142 }
0143 #endif
0144
0145
0146 }