gfields
Loading...
Searching...
No Matches
GField Class Referenceabstract

Abstract base class representing a magnetic field. More...

#include <gfield.h>

Public Member Functions

 GField (const std::shared_ptr< GOptions > &gopt)
 Construct the field base with the provided options (for logging and configuration access).
 
virtual void GetFieldValue (const double x[3], double *bfield) const =0
 Compute the magnetic field vector at a given position.
 
G4FieldManager * create_FieldManager ()
 Create a G4FieldManager configured for this field.
 
virtual void load_field_definitions (GFieldDefinition gfd)
 Store the field definition used to configure this field instance.
 
int get_field_parameter_int (const std::string &key)
 Convenience accessor for integer-valued parameters stored in field_parameters.
 
double get_field_parameter_double (const std::string &key)
 Convenience accessor for floating-point parameters stored in field_parameters.
 
void set_loggers (const std::shared_ptr< GOptions > &g)
 Hook for configuring module loggers from options.
 
- Public Member Functions inherited from GBase< GField >
 GBase (const std::shared_ptr< GOptions > &gopt, std::string logger_name="")
 
 GBase (const std::shared_ptr< GLogger > &logger)
 
 GBase (const GBase &)=default
 
 GBase (GBase &&) noexcept=default
 
virtual ~GBase ()
 
GBaseoperator= (const GBase &)=default
 
GBaseoperator= (GBase &&) noexcept=default
 

Static Public Member Functions

static GFieldinstantiate (const dlhandle h, const std::shared_ptr< GOptions > g)
 Instantiate a field object from a plugin handle.
 

Protected Attributes

GFieldDefinition gfield_definitions
 Stored field definition used for configuration and logging.
 
- Protected Attributes inherited from GBase< GField >
std::shared_ptr< GLoggerlog
 

Detailed Description

A concrete field implementation must provide GetFieldValue() and may override load_field_definitions() to parse/cache configuration from a GFieldDefinition.

Integration:

  • The field is also a G4MagneticField and is used by Geant4 stepping infrastructure.
  • The helper create_FieldManager() constructs a G4FieldManager and its chord finder using a supported stepper name.

Definition at line 99 of file gfield.h.

Constructor & Destructor Documentation

◆ GField()

GField::GField ( const std::shared_ptr< GOptions > & gopt)
inlineexplicit
Parameters
goptShared options object.

Definition at line 106 of file gfield.h.

Member Function Documentation

◆ create_FieldManager()

G4FieldManager * GField::create_FieldManager ( )
Returns
Newly allocated G4FieldManager pointer.

The manager is created using:

  • G4Mag_UsualEqRhs as the equation of motion,
  • one of the supported integration steppers (selected by name),
  • a G4ChordFinder constructed with the configured minimum step.

Ownership:

  • The returned object is heap-allocated. In this module it is owned by GMagneto.

Definition at line 24 of file gfield.cc.

◆ get_field_parameter_double()

double GField::get_field_parameter_double ( const std::string & key)
inline
Parameters
keyMap key to retrieve.
Returns
Parsed floating-point value.

Definition at line 151 of file gfield.h.

◆ get_field_parameter_int()

int GField::get_field_parameter_int ( const std::string & key)
inline
Parameters
keyMap key to retrieve.
Returns
Parsed integer value.

Definition at line 144 of file gfield.h.

◆ GetFieldValue()

virtual void GField::GetFieldValue ( const double x[3],
double * bfield ) const
pure virtual
Parameters
xPosition in the lab frame as {x,y,z}.
bfieldOutput array filled with {Bx,By,Bz}.

This method is the key interface used by Geant4 when transporting tracks in a field.

◆ instantiate()

static GField * GField::instantiate ( const dlhandle h,
const std::shared_ptr< GOptions > g )
inlinestatic
Parameters
hDynamic library handle.
gShared options passed to the plugin factory.
Returns
Newly allocated field pointer, or nullptr on failure.

The plugin must export a C symbol named "GFieldFactory" with a compatible signature. This method looks up that symbol and calls it to construct the concrete GField instance.

Definition at line 197 of file gfield.h.

◆ load_field_definitions()

virtual void GField::load_field_definitions ( GFieldDefinition gfd)
inlinevirtual
Parameters
gfdField definition to copy into internal storage.

Concrete implementations typically override this method to parse and cache frequently used parameters.

Reimplemented in GField_MultipolesFactory.

Definition at line 137 of file gfield.h.

◆ set_loggers()

void GField::set_loggers ( const std::shared_ptr< GOptions > & g)
inline
Parameters
gShared options object.

This module currently does not add additional logger wiring here.

Definition at line 159 of file gfield.h.

Field Documentation

◆ gfield_definitions

GFieldDefinition GField::gfield_definitions
protected

Definition at line 185 of file gfield.h.


The documentation for this class was generated from the following files: