File indexing completed on 2025-02-22 10:31:20
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include <string>
0011 #include <G4Material.hh>
0012
0013 #include "celeritas/io/ImportPhysicsVector.hh"
0014 #include "celeritas/io/ImportUnits.hh"
0015
0016 #include "GeantProcessImporter.hh"
0017
0018 namespace celeritas
0019 {
0020 namespace detail
0021 {
0022
0023
0024
0025
0026 struct GeantMaterialPropertyGetter
0027 {
0028 using MPT = G4MaterialPropertiesTable;
0029
0030 MPT const& mpt;
0031
0032
0033 bool operator()(double* dst, char const* name, ImportUnits q)
0034 {
0035 if (!mpt.ConstPropertyExists(name))
0036 {
0037 return false;
0038 }
0039 *dst = mpt.GetConstProperty(name) * native_value_from_clhep(q);
0040 return true;
0041 }
0042
0043
0044 bool operator()(double* dst, std::string name, int comp, ImportUnits q)
0045 {
0046
0047 name += std::to_string(comp);
0048 return (*this)(dst, name.c_str(), q);
0049 }
0050
0051
0052 bool
0053 operator()(ImportPhysicsVector* dst, std::string const& name, ImportUnits q)
0054 {
0055
0056
0057 auto const* g4vector = const_cast<MPT&>(mpt).GetProperty(name.c_str());
0058 if (!g4vector)
0059 {
0060 return false;
0061 }
0062 *dst = import_physics_vector(*g4vector, {ImportUnits::mev, q});
0063 return true;
0064 }
0065 };
0066
0067
0068 }
0069 }