4#include "G4MagneticField.hh"
5#include "G4FieldManager.hh"
46 stream <<
" > Field name: " << gfd.
name << std::endl;
48 stream <<
" - minimum step " << gfd.
minimum_step <<
" mm" << std::endl;
49 stream <<
" - type " << gfd.
type << std::endl;
53 for (
auto& field_parameter : gfd.
field_parameters) { stream <<
" - " << std::left << std::setw(21) << field_parameter.first << field_parameter.second << std::endl; }
62class GField :
public GBase<GField>,
public G4MagneticField {
76 virtual void GetFieldValue(
const double x[3],
double* bfield)
const = 0;
93 void set_loggers([[ maybe_unused ]]
const std::shared_ptr<GOptions>& g) {
98 std::vector<std::string> SUPPORTED_STEPPERS = {
102 "G4HelixExplicitEuler",
103 "G4HelixImplicitEuler",
117 if (!h)
return nullptr;
118 using fptr =
GField* (*)(std::shared_ptr<GOptions>);
121 auto sym = dlsym(h,
"GFieldFactory");
122 if (!sym)
return nullptr;
124 auto func =
reinterpret_cast<fptr
>(sym);
Abstract base class representing a magnetic field.
virtual void GetFieldValue(const double x[3], double *bfield) const =0
Pure virtual function to get the magnetic field value.
GFieldDefinition gfield_definitions
G4FieldManager * create_FieldManager()
Creates the G4FieldManager for the field.
GField(const std::shared_ptr< GOptions > &gopt)
Default constructor.
void set_loggers(const std::shared_ptr< GOptions > &g)
virtual void load_field_definitions(GFieldDefinition gfd)
Sets the field definition for the field.
double get_field_parameter_double(const std::string &key)
int get_field_parameter_int(const std::string &key)
static GField * instantiate(const dlhandle h, std::shared_ptr< GOptions > g)
constexpr const char * GFIELD_LOGGER
constexpr const char * GMAGNETO_LOGGER
Utility struct to load GFields from options.
std::string gfieldPluginName() const
Gets the plugin name for the field.
double minimum_step
Minimum step size for integration.
friend std::ostream & operator<<(std::ostream &stream, GFieldDefinition gfd)
std::string name
Key in the gmagneto maps.
std::map< std::string, std::string > field_parameters
Field parameters as key-value pairs.
GFieldDefinition()=default
Default constructor.
void add_map_parameter(const std::string &key, const std::string &value)
Adds a parameter to the field parameters map.
std::string integration_stepper
Type of integration stepper.
std::string type
Type of the field.