48 explicit GMagneto(
const std::shared_ptr<GOptions>& gopts);
51 using gFieldMap = std::unordered_map<std::string, std::shared_ptr<GField>>;
52 using gFieldMgrMap = std::unordered_map<std::string, std::shared_ptr<G4FieldManager>>;
55 std::shared_ptr<gFieldMap> fields_map;
58 std::shared_ptr<gFieldMgrMap> fields_manager;
66 bool isField(
const std::string& name)
const {
return fields_map->find(name) != fields_map->end(); }
75 std::shared_ptr<GField>
getField(std::string name) {
76 bool not_found = (fields_map->find(name) == fields_map->end());
79 return fields_map->at(name);
89 std::shared_ptr<G4FieldManager>
getFieldMgr(std::string name) {
92 for (
const auto& [key, value] : *fields_manager) {
93 log->
info(2,
"GFieldManager >", key,
"< >", value);
98 return fields_manager->at(name);
std::shared_ptr< GLogger > log
void info(int level, Args &&... args) const
void error(int exit_code, Args &&... args) const
Manager for magnetic fields and their associated G4FieldManager objects.
std::shared_ptr< G4FieldManager > getFieldMgr(std::string name)
Retrieve the G4FieldManager associated with a given field name.
std::shared_ptr< GField > getField(std::string name)
Retrieve a field object by name.
bool isField(const std::string &name) const
Check whether a field with the given name exists.
GMagneto(const std::shared_ptr< GOptions > &gopts)
Construct and initialize the magnetic field registry.
#define ERR_WRONG_FIELD_NOT_FOUND