49 explicit GMagneto(
const std::shared_ptr<GOptions>& gopts);
52 using gFieldMap = std::unordered_map<std::string, std::shared_ptr<GField>>;
53 using gFieldMgrMap = std::unordered_map<std::string, std::shared_ptr<G4FieldManager>>;
56 std::shared_ptr<gFieldMap> fields_map;
59 std::shared_ptr<gFieldMgrMap> fields_manager;
67 bool isField(
const std::string& name)
const {
return fields_map->find(name) != fields_map->end(); }
82 std::shared_ptr<GField>
getField(std::string name) {
83 bool not_found = (fields_map->find(name) == fields_map->end());
86 return fields_map->at(name);
96 std::shared_ptr<G4FieldManager>
getFieldMgr(std::string name) {
99 for (
const auto& [key, value] : *fields_manager) {
100 log->
info(2,
"GFieldManager >", key,
"< >", value);
103 if (fields_manager->find(name) == fields_manager->end()) {
107 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.
std::vector< std::string > getFieldNames() const
Return the configured field names.
GMagneto(const std::shared_ptr< GOptions > &gopts)
Construct and initialize the magnetic field registry.
#define ERR_WRONG_FIELD_NOT_FOUND