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

Concrete GField reading a magnetic field from an ASCII map and a YAML definition. More...

#include <gfield_asciimap.h>

Public Member Functions

 GField_AsciiMapFactory (const std::shared_ptr< GOptions > &gopt)
 
void GetFieldValue (const double pos[3], G4double *bfield) const override
 Compute the field at the lab-frame point pos, writing {Bx,By,Bz} (Geant4 units) into bfield.
 
void load_field_definitions (GFieldDefinition gfd) override
 Parse the YAML definition, build the grid and read the map file.
 
- 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

Supported symmetries
  • dipole-x, dipole-y, dipole-z: 2D map of a single on-axis component, depending on a longitudinal and a transverse coordinate.
  • cylindrical-x, cylindrical-y, cylindrical-z: 2D phi-symmetric map of a transverse (radial) and a longitudinal component.
  • phi-segmented: 3D map in cylindrical coordinates (azimuthal, transverse, longitudinal) of three cartesian components, replicated over 60-degree segments.
  • cartesian_3D, cartesian_3D_quadrant: 3D cartesian map of three cartesian components. The _quadrant variant stores only the first quadrant (x>=0, y>=0) and mirrors it.
YAML parameters (all forwarded as scalar strings through the gfields node)
  • symmetry : one of the names above. Mandatory.
  • map : map file name. When it contains a / it is used as-is, otherwise it is looked up in dir. Mandatory.
  • dir : directory holding the map. Optional; when empty the map is read from the fields directory installed next to this plugin (<plugin_dir>/../fields).
  • coordinate1, coordinate2, coordinate3 : one grid axis each, as the compact string "name, npoints, min, max". min/max are Geant4-number expressions with units (e.g. 0*m, 3*m); the unit there also sets the unit of the matching coordinate column in the map file. coordinate3 is required only for the 3D symmetries. The column order in the map file follows coordinate1, coordinate2, coordinate3.
  • field_unit : unit of the field columns in the map file (default gauss).
  • scale : dimensionless multiplier applied to every field value (default 1).
  • interpolation : linear (default) or none (nearest neighbour).
  • vx,vy,vz : map origin subtracted from the query point before lookup (default 0).
  • rx,ry,rz : map rotation applied to the field vector (default 0*deg).
Coordinate names per symmetry
  • dipole : longitudinal, transverse
  • cylindrical : transverse, longitudinal
  • phi-segmented: azimuthal, transverse, longitudinal
  • cartesian : X, Y, Z
Implementation notes (improvements over the legacy asciiField)
  • Field values are stored in contiguous std::vector<float> buffers addressed with precomputed strides, instead of the legacy float**/float*** pointer pyramids; this keeps the hot GetFieldValue loop cache friendly and removes manual new/delete.
  • The symmetry is decoded once into an enum, so GetFieldValue dispatches on an integer rather than comparing strings at every step.
  • Rotation trigonometry is cached at load time.
  • The map rows may be listed in any order: the grid index of each row is computed from its coordinate columns and validated against the YAML grid.

Definition at line 77 of file gfield_asciimap.h.

Constructor & Destructor Documentation

◆ GField_AsciiMapFactory()

GField_AsciiMapFactory::GField_AsciiMapFactory ( const std::shared_ptr< GOptions > & gopt)
inlineexplicit

Definition at line 80 of file gfield_asciimap.h.

Member Function Documentation

◆ GetFieldValue()

void GField_AsciiMapFactory::GetFieldValue ( const double pos[3],
G4double * bfield ) const
override

Definition at line 301 of file gfield_asciimap.cc.

◆ load_field_definitions()

void GField_AsciiMapFactory::load_field_definitions ( GFieldDefinition gfd)
overridevirtual

Reimplemented from GField.

Definition at line 252 of file gfield_asciimap.cc.


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