gfields
gmagneto.cc
Go to the documentation of this file.
1 // glibrary
2 #include "gfactory.h"
3 
4 // gsystem
5 #include "gmagneto.h"
6 
7 using namespace std;
8 
9 GMagneto::GMagneto(GOptions *gopts) : GStateMessage(gopts, "GMagneto", "gfield") {
10 
11  gFieldMap = new map<string, GField *>;
12  gFieldMgrMap = new map<string, G4FieldManager *>;
13 
14  GManager gFieldManager("GMagneto", verbosity);
15 
16  // TODO: this should be done in gemc instead and passed to gmagneto, same as gopts.
17  vector <GFieldDefinition> field_definition_array = gfields::get_GFieldDefinition(gopts);
18 
19  for (auto &field_definition: field_definition_array) {
20  string name = field_definition.name;
21 
22  if (verbosity >= GVERBOSITY_SUMMARY) { G4cout << field_definition << G4endl; }
23 
24  if (gFieldMap->find(name) == gFieldMap->end()) {
25  (*gFieldMap)[name] = gFieldManager.LoadAndRegisterObjectFromLibrary<GField>( field_definition.gfieldPluginName());
26  (*gFieldMap)[name]->load_field_definitions(field_definition);
27  (*gFieldMgrMap)[name] = (*gFieldMap)[name]->create_FieldManager();
28  }
29  }
30 
31 }
Abstract base class representing a magnetic field.
Definition: gfield.h:67
virtual void load_field_definitions(GFieldDefinition gfd)
Sets the field definition for the field.
Definition: gfield.h:97
GMagneto(GOptions *gopts)
Constructs a GMagneto object and loads field definitions from options.
Definition: gmagneto.cc:9
vector< GFieldDefinition > get_GFieldDefinition(GOptions *gopts)