gfields
Loading...
Searching...
No Matches
gmagneto.h
Go to the documentation of this file.
1#pragma once
2
3// gemc
4#include "gfield.h"
5#include "gfield_options.h"
6#include "gfieldConventions.h"
7
14class GMagneto : public GBase<GMagneto> {
15public:
20 explicit GMagneto(const std::shared_ptr<GOptions>& gopts);
21
22private:
23 using gFieldMap = std::unordered_map<std::string, std::shared_ptr<GField>>;
24 using gFieldMgrMap = std::unordered_map<std::string, std::shared_ptr<G4FieldManager>>;
25
26 std::shared_ptr<gFieldMap> fields_map;
27 std::shared_ptr<gFieldMgrMap> fields_manager;
28
29public:
35 bool isField(const std::string& name) const { return fields_map->find(name) != fields_map->end(); }
36
43 std::shared_ptr<GField> getField(std::string name) {
44 bool not_found = (fields_map->find(name) == fields_map->end());
45
46 if (not_found) { log->error(ERR_WRONG_FIELD_NOT_FOUND, "GField ", name, " not found. Exiting."); }
47 return fields_map->at(name);
48 }
49
56 std::shared_ptr<G4FieldManager> getFieldMgr(std::string name) {
57 if (fields_manager->find(name) == fields_manager->end()) { log->error(ERR_WRONG_FIELD_NOT_FOUND, "GField ", name, " not found. Exiting."); }
58
59 return fields_manager->at(name);
60 }
61
62};
Represents a world containing collections of GFields and G4FieldManagers.
Definition gmagneto.h:14
std::shared_ptr< G4FieldManager > getFieldMgr(std::string name)
Retrieves a G4FieldManager object by its name.
Definition gmagneto.h:56
std::shared_ptr< GField > getField(std::string name)
Retrieves a GField object by its name.
Definition gmagneto.h:43
bool isField(const std::string &name) const
Checks if a field with the given name exists.
Definition gmagneto.h:35
GMagneto(const std::shared_ptr< GOptions > &gopts)
Constructs a GMagneto object and loads field definitions from options.
Definition gmagneto.cc:12
#define ERR_WRONG_FIELD_NOT_FOUND