5 #include "G4MagneticField.hh"
6 #include "G4FieldManager.hh"
7 #include "G4MagIntegratorStepper.hh"
45 return "gfield" +
type +
"Factory";
50 stream <<
" > Field name: " << gfd.
name << std::endl;
52 stream <<
" - minimum step " << gfd.
minimum_step <<
" mm" << std::endl;
53 stream <<
" - type " << gfd.
type << std::endl;
54 stream <<
" - verbosity " << gfd.
verbosity << std::endl;
59 stream <<
" - " << std::left << std::setw(21) << field_parameter.first << field_parameter.second << std::endl;
69 class GField :
public G4MagneticField {
87 virtual void GetFieldValue(
const double x[3],
double *bfield)
const = 0;
121 std::vector <std::string> SUPPORTED_STEPPERS = {
122 "G4DormandPrince745",
"G4ClassicalRK4",
"G4SimpleRunge",
"G4HelixExplicitEuler",
123 "G4HelixImplicitEuler",
"G4CashKarpRKF45",
"G4RKG3_Stepper",
"G4SimpleHeum",
124 "G4NystromRK4",
"G4ImplicitEuler",
"G4ExplicitEuler"
135 if (handle ==
nullptr)
return nullptr;
138 void *maker = dlsym(handle,
"GFieldFactory");
140 if (maker ==
nullptr)
return nullptr;
142 typedef GField *(*fptr)();
147 fptr func =
reinterpret_cast<fptr
>(
reinterpret_cast<void *
>(maker));
Abstract base class representing a magnetic field.
void gFLogMessage(std::string message)
Logs a message with the field context.
virtual void GetFieldValue(const double x[3], double *bfield) const =0
Pure virtual function to get the magnetic field value.
GFieldDefinition gfield_definitions
int get_field_parameter_int(std::string key)
G4FieldManager * create_FieldManager()
Creates the G4FieldManager for the field.
GField()=default
Default constructor.
static GField * instantiate(const dlhandle handle)
virtual void load_field_definitions(GFieldDefinition gfd)
Sets the field definition for the field.
virtual ~GField()=default
Virtual destructor.
double get_field_parameter_double(std::string key)
Utility struct to load GFields from options.
GFieldDefinition()
Default constructor.
double minimum_step
Minimum step size for integration.
std::string name
Key in the gmagneto maps.
map< std::string, string > field_parameters
Field parameters as key-value pairs.
friend std::ostream & operator<<(std::ostream &stream, GFieldDefinition gfd)
void add_map_parameter(std::string key, std::string value)
Adds a parameter to the field parameters map.
std::string integration_stepper
Type of integration stepper.
string gfieldPluginName()
Gets the plugin name for the field.
int verbosity
Verbosity level.
std::string type
Type of the field.