4#include "G4MagneticField.hh"
5#include "G4FieldManager.hh"
73 stream <<
" > Field name: " << gfd.
name << std::endl;
75 stream <<
" - minimum step " << gfd.
minimum_step <<
" mm" << std::endl;
76 stream <<
" - type " << gfd.
type << std::endl;
80 stream <<
" - " << std::left << std::setw(21) << field_parameter.first << field_parameter.second << std::endl;
159 void set_loggers([[ maybe_unused ]]
const std::shared_ptr<GOptions>& g) {
169 std::vector<std::string> SUPPORTED_STEPPERS = {
170 "G4DormandPrince745",
173 "G4HelixExplicitEuler",
174 "G4HelixImplicitEuler",
198 if (!h)
return nullptr;
199 using fptr =
GField* (*)(
const std::shared_ptr<GOptions>&);
202 auto sym = dlsym(h,
"GFieldFactory");
203 if (!sym)
return nullptr;
205 auto func =
reinterpret_cast<fptr
>(sym);
Abstract base class representing a magnetic field.
virtual void GetFieldValue(const double x[3], double *bfield) const =0
Compute the magnetic field vector at a given position.
GFieldDefinition gfield_definitions
Stored field definition used for configuration and logging.
static GField * instantiate(const dlhandle h, const std::shared_ptr< GOptions > g)
Instantiate a field object from a plugin handle.
G4FieldManager * create_FieldManager()
Create a G4FieldManager configured for this field.
GField(const std::shared_ptr< GOptions > &gopt)
Construct the field base with the provided options (for logging and configuration access).
void set_loggers(const std::shared_ptr< GOptions > &g)
Hook for configuring module loggers from options.
virtual void load_field_definitions(GFieldDefinition gfd)
Store the field definition used to configure this field instance.
double get_field_parameter_double(const std::string &key)
Convenience accessor for floating-point parameters stored in field_parameters.
int get_field_parameter_int(const std::string &key)
Convenience accessor for integer-valued parameters stored in field_parameters.
constexpr const char * GFIELD_LOGGER
constexpr const char * GMAGNETO_LOGGER
Lightweight configuration carrier used to load and configure a GField plugin.
std::string gfieldPluginName() const
Derive the plugin name for the field definition.
double minimum_step
Minimum step size used when constructing the G4ChordFinder (Geant4 length units).
friend std::ostream & operator<<(std::ostream &stream, GFieldDefinition gfd)
Stream formatter used for logging/debug output.
std::string name
Field name key used by GMagneto maps.
std::map< std::string, std::string > field_parameters
Field parameters stored as string expressions (often including unit expressions).
GFieldDefinition()=default
Default constructor.
void add_map_parameter(const std::string &key, const std::string &value)
Add or overwrite a parameter in the field-parameter map.
std::string integration_stepper
Integration stepper name (string) used when creating the G4ChordFinder.
std::string type
Field type discriminator used to derive the plugin factory name (e.g. "multipoles").