gfields
Loading...
Searching...
No Matches
GField_MultipolesFactory Class Reference

Factory class implementing an ideal multipole magnetic field. More...

#include <gfield_multipoles.h>

Public Member Functions

 GField_MultipolesFactory (const std::shared_ptr< GOptions > &gopt)
 Construct the multipole field factory using the module options.
 
void GetFieldValue (const double pos[3], G4double *bfield) const override
 Evaluate the magnetic field B at a given position.
 
void load_field_definitions (GFieldDefinition gfd) override
 Load and cache field-definition parameters for fast field evaluation.
 
- Public Member Functions inherited from GField
 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.
 
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
 

Additional Inherited Members

- Static Public Member Functions inherited from GField
static GFieldinstantiate (const dlhandle h, const std::shared_ptr< GOptions > g)
 Instantiate a field object from a plugin handle.
 
- Protected Attributes inherited from GField
GFieldDefinition gfield_definitions
 Stored field definition used for configuration and logging.
 
- Protected Attributes inherited from GBase< GField >
std::shared_ptr< GLoggerlog
 

Detailed Description

This class is a concrete GField implementation that evaluates an idealized multipole field using common accelerator-style conventions:

  • The transverse field scales like r^(n-1) where n = pole_number/2.
  • The angular dependence is expressed via cos((n-1)*phi) and sin((n-1)*phi).

The field is evaluated in a local magnet frame centered at origin and then rotated back into the lab frame by rotation_angle around rotaxis.

Two operating modes exist:

  • Transverse multipole mode (longitudinal == false): produces a 2D multipole field in the plane perpendicular to rotaxis.
  • Longitudinal mode (longitudinal == true): produces a uniform axial field aligned with rotaxis (solenoid-like); this mode is not a multipole expansion, but is provided for convenience/configuration symmetry.

Units:

  • origin and the evaluation point pos are expected in Geant4 length units (e.g. mm).
  • strength is expected in Tesla.
  • rotation_angle is expected in Geant4 angle units (e.g. deg).

Definition at line 39 of file gfield_multipoles.h.

Constructor & Destructor Documentation

◆ GField_MultipolesFactory()

GField_MultipolesFactory::GField_MultipolesFactory ( const std::shared_ptr< GOptions > & gopt)
inlineexplicit
Parameters
goptShared options object used by the base class (logging, configuration).

The options are owned externally and are expected to outlive this object.

Definition at line 48 of file gfield_multipoles.h.

Member Function Documentation

◆ GetFieldValue()

void GField_MultipolesFactory::GetFieldValue ( const double pos[3],
G4double * bfield ) const
override
Parameters
posPosition in the lab frame as {x,y,z}.
bfieldOutput array filled with {Bx,By,Bz} in Tesla.

This method is the Geant4 entry point used by the field propagator. The implementation:

  1. Translates the query point into magnet-centered coordinates using origin.
  2. Applies an “unroll” rotation by -rotation_angle around rotaxis.
  3. Computes the field in the transverse plane (or axial mode if enabled).
  4. Rotates the field back to the lab frame and writes it to bfield.

Definition at line 26 of file gfield_multipoles.cc.

◆ load_field_definitions()

void GField_MultipolesFactory::load_field_definitions ( GFieldDefinition gfd)
overridevirtual
Parameters
gfdField definition populated from options.

The input definition is copied into the base class storage and the frequently used parameters are parsed and cached into member variables (e.g. pole number, origin, rotation).

Reimplemented from GField.

Definition at line 157 of file gfield_multipoles.cc.


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