BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
|
Factory that produces fields and their associated objects. More...
#include <BDSFieldFactory.hh>
Public Member Functions | |
BDSFieldObjects * | CreateField (const BDSFieldInfo &info, const BDSMagnetStrength *scalingStrength=nullptr, const G4String &scalingKey="none") |
Main interface to field factory. | |
BDSFieldInfo * | GetDefinition (const G4String &name) const |
BDSModulatorInfo * | GetModulatorDefinition (const G4String &modulatorName) const |
Static Public Member Functions | |
static BDSFieldFactory * | Instance () |
Public accessor method for singleton pattern. | |
static void | SetDesignParticle (const BDSParticleDefinition *designParticleIn) |
Update the internal cache of the rigidity. | |
static void | SetPrimaryGeneratorAction (BDSPrimaryGeneratorAction *pgaIn) |
Update the internal cache of the primary generator action. | |
static BDSInterpolatorType | DefaultInterpolatorType (G4int numberOfDimensions) |
Suggest a default interpolator. | |
static G4double | CalculateGlobalPhase (G4double oscillatorFrequency, G4double tOffsetIn) |
static G4double | CalculateGlobalPhase (const BDSModulatorInfo &modulatorInfo, const BDSFieldInfo &fieldInfo) |
Private Member Functions | |
BDSFieldObjects * | CreateFieldMag (const BDSFieldInfo &info, const BDSMagnetStrength *scalingStrength=nullptr, const G4String &scalingKey="none") |
Create a purely magnetic field. | |
BDSFieldObjects * | CreateFieldEM (const BDSFieldInfo &info) |
Create a general EM field. | |
BDSFieldObjects * | CreateFieldE (const BDSFieldInfo &info) |
Create an electric field. | |
BDSFieldObjects * | CreateFieldIrregular (const BDSFieldInfo &info) |
Create an irregular (special) field. | |
BDSFieldMag * | CreateFieldMagRaw (const BDSFieldInfo &info, const BDSMagnetStrength *scalingStrength=nullptr, const G4String &scalingKey="none") |
Creat just the magnetic field object. | |
BDSFieldE * | CreateFieldERaw (const BDSFieldInfo &info) |
Creat just the electric field object. | |
G4MagIntegratorStepper * | CreateIntegratorMag (const BDSFieldInfo &info, G4Mag_EqRhs *eqOfM, const BDSMagnetStrength *strength) |
G4MagIntegratorStepper * | CreateIntegratorEM (const BDSFieldInfo &info, G4EquationOfMotion *eqOfM) |
G4MagIntegratorStepper * | CreateIntegratorE (const BDSFieldInfo &info, G4EquationOfMotion *eqOfM) |
BDSFieldObjects * | CreateTeleporter (const BDSFieldInfo &info) |
BDSFieldObjects * | CreateRMatrix (const BDSFieldInfo &info) |
Create special rmatrix 'field' that applies an rmatrix. | |
BDSFieldObjects * | CreateCavityFringe (const BDSFieldInfo &info) |
Create special rf cavity fringe 'field' that applies an rmatrix. | |
BDSFieldObjects * | CreateParallelTransport (const BDSFieldInfo &info) |
G4double | GetOuterScaling (const BDSMagnetStrength *st) const |
Return the parameter "outerScaling" from strength st, but default to 1. | |
BDSModulator * | CreateModulator (const BDSModulatorInfo *modulatorRecipe, const BDSFieldInfo &info) const |
Create the necessary modulator. | |
BDSFieldFactory () | |
Private default constructor as singleton class. | |
void | PrepareFieldDefinitions (const std::vector< GMAD::Field > &definitions, G4double defaultBRho) |
Prepare all required definitions that can be used dynamically. | |
void | PrepareModulatorDefinitions (const std::vector< GMAD::Modulator > &definitions) |
Prepare all required modulator definitions that can be used dynamically. | |
G4double | ConvertToDoubleWithException (const G4String &value, const G4String ¶meterNameForError) const |
Convert the string 'value' to a double. Throw an exception including the parameterNameForError if it doesn't work. | |
void | PrepareFieldStrengthFromParameters (BDSMagnetStrength *st, const G4String &fieldParameters, G4double &poleTipRadius) const |
Private Attributes | |
std::map< G4String, BDSFieldInfo * > | parserDefinitions |
BDSFieldInfo definitions prepare from parser vector of definitions. | |
std::map< G4String, BDSModulatorInfo * > | parserModulatorDefinitions |
G4bool | useOldMultipoleOuterFields |
Static Private Attributes | |
static BDSFieldFactory * | instance = nullptr |
Instance - singleton pattern. | |
static const BDSParticleDefinition * | designParticle = nullptr |
Cache of design particle for fields. | |
static BDSPrimaryGeneratorAction * | primaryGeneratorAction = nullptr |
Cache of primary generator action. | |
Factory that produces fields and their associated objects.
Field objects are created according to a BDSFieldType and the associated and required Geant4 objects to properly implement a field. These are packaged together in one object. This factory does not own any of its products. Construction follows in this order:
1 field 2 equation of motion (based on field object) 3 integrator 4 chord finder 5 field manager 6 package it up
This also makes use of BDSParser singleton class to create a series of BDSFieldInfo field specifications as defined by the parser.
This owns the converted modulator definitions (BDSModulatorInfo*) despite the design of a factory that should give up ownership. This is so we don't duplicate the instance for the sake of ownership.
Definition at line 76 of file BDSFieldFactory.hh.
BDSFieldFactory::~BDSFieldFactory | ( | ) |
Definition at line 180 of file BDSFieldFactory.cc.
|
private |
Private default constructor as singleton class.
Definition at line 165 of file BDSFieldFactory.cc.
References BDSParticleDefinition::BRho(), designParticle, BDSGlobalConstants::Instance(), BDSParser::Instance(), BDSParser::IsInitialised(), PrepareFieldDefinitions(), and PrepareModulatorDefinitions().
Referenced by Instance().
|
static |
Definition at line 414 of file BDSFieldFactory.cc.
|
static |
Definition at line 400 of file BDSFieldFactory.cc.
|
private |
Convert the string 'value' to a double. Throw an exception including the parameterNameForError if it doesn't work.
Definition at line 434 of file BDSFieldFactory.cc.
Referenced by PrepareFieldStrengthFromParameters().
|
private |
Create special rf cavity fringe 'field' that applies an rmatrix.
Definition at line 1267 of file BDSFieldFactory.cc.
References BDSFieldInfo::BeamPipeRadius(), and BDSFieldInfo::MagnetStrength().
Referenced by CreateFieldIrregular().
BDSFieldObjects * BDSFieldFactory::CreateField | ( | const BDSFieldInfo & | info, |
const BDSMagnetStrength * | scalingStrength = nullptr , |
||
const G4String & | scalingKey = "none" |
||
) |
Main interface to field factory.
Definition at line 520 of file BDSFieldFactory.cc.
References CreateFieldE(), CreateFieldEM(), CreateFieldIrregular(), CreateFieldMag(), BDS::DetermineFieldClassType(), BDSFieldInfo::FieldType(), BDSFieldInfo::NameOfParserDefinition(), and BDSTypeSafeEnum< def, inner >::underlying().
|
private |
Create an electric field.
Definition at line 935 of file BDSFieldFactory.cc.
References CreateFieldERaw(), CreateIntegratorE(), BDSFieldInfo::ProvideGlobal(), and BDSFieldInfo::UsePlacementWorldTransform().
Referenced by CreateField().
|
private |
Create a general EM field.
Definition at line 875 of file BDSFieldFactory.cc.
References BDSFieldInfo::BRho(), CreateIntegratorEM(), CreateModulator(), BDSFieldInfo::FieldType(), BDSFieldLoader::Instance(), BDSFieldLoader::LoadEMField(), BDSFieldInfo::MagnetStrength(), BDSFieldInfo::ModulatorInfo(), BDSFieldInfo::NameOfParserDefinition(), BDSFieldInfo::ProvideGlobal(), BDSModulator::RecommendedMaxStepLength(), BDSFieldEM::SetModulator(), BDSFieldEM::SetTransform(), BDSFieldEM::TimeVarying(), BDSFieldInfo::TransformComplete(), BDSTypeSafeEnum< def, inner >::underlying(), BDSFieldInfo::UpdateUserLimitsLengthMaximumStepSize(), BDSFieldInfo::UsePlacementWorldTransform(), and BDSModulator::VariesWithTime().
Referenced by CreateField().
|
private |
Creat just the electric field object.
Definition at line 958 of file BDSFieldFactory.cc.
References BDSFieldInfo::BRho(), CreateFieldERaw(), CreateModulator(), BDSFieldInfo::ElectricSubFieldName(), BDSFieldInfo::FieldType(), GetDefinition(), BDSFieldLoader::Instance(), BDSFieldLoader::LoadEField(), BDSFieldInfo::MagnetStrength(), BDSFieldInfo::ModulatorInfo(), BDSFieldInfo::NameOfParserDefinition(), BDSModulator::RecommendedMaxStepLength(), BDSFieldE::SetModulator(), BDSFieldE::SetTransform(), BDSFieldE::TimeVarying(), BDSFieldInfo::Transform(), BDSFieldInfo::TransformBeamline(), BDSFieldInfo::TransformComplete(), BDSTypeSafeEnum< def, inner >::underlying(), BDSFieldInfo::UpdateUserLimitsLengthMaximumStepSize(), and BDSModulator::VariesWithTime().
Referenced by CreateFieldE(), and CreateFieldERaw().
|
private |
Create an irregular (special) field.
Definition at line 1023 of file BDSFieldFactory.cc.
References CreateCavityFringe(), CreateParallelTransport(), CreateRMatrix(), CreateTeleporter(), BDSFieldInfo::FieldType(), and BDSTypeSafeEnum< def, inner >::underlying().
Referenced by CreateField().
|
private |
Create a purely magnetic field.
Definition at line 575 of file BDSFieldFactory.cc.
References CreateFieldMagRaw(), CreateIntegratorMag(), BDSFieldInfo::MagnetStrength(), BDSFieldInfo::ProvideGlobal(), and BDSFieldInfo::UsePlacementWorldTransform().
Referenced by CreateField().
|
private |
Creat just the magnetic field object.
Definition at line 601 of file BDSFieldFactory.cc.
References BDSFieldInfo::BeamPipeRadius(), BDSMagnetOuterFactoryLHC::beamSeparation, BDSFieldInfo::BRho(), CreateFieldMagRaw(), CreateModulator(), BDSFieldInfo::FieldType(), GetDefinition(), GetOuterScaling(), BDSFieldLoader::Instance(), BDSFieldLoader::LoadMagField(), BDSFieldInfo::MagneticSubFieldName(), BDSFieldInfo::MagnetStrength(), BDSFieldInfo::ModulatorInfo(), BDSFieldInfo::NameOfParserDefinition(), BDSFieldInfo::PoleTipRadius(), BDSModulator::RecommendedMaxStepLength(), BDSFieldInfo::SecondFieldOnLeft(), BDSFieldMag::SetModulator(), BDSFieldMag::SetTransform(), BDSFieldMag::TimeVarying(), BDSFieldInfo::Transform(), BDSFieldInfo::TransformBeamline(), BDSFieldInfo::TransformComplete(), BDSTypeSafeEnum< def, inner >::underlying(), BDSFieldInfo::UpdateUserLimitsLengthMaximumStepSize(), and BDSModulator::VariesWithTime().
Referenced by CreateFieldMag(), and CreateFieldMagRaw().
|
private |
Create an integrator for a general E field. Same ones as EM but keep this method for clarity as Geant4 unclear - only based on their examples. examples/extended/field/field02/src/F02ElectricFieldSetup.cc
Definition at line 1227 of file BDSFieldFactory.cc.
References CreateIntegratorEM().
Referenced by CreateFieldE().
|
private |
Create an integrator for a general EM field. As it's a general field, this takes a G4EquationOfMotion* equation of motion instance.
Definition at line 1131 of file BDSFieldFactory.cc.
References BDSFieldInfo::IntegratorType(), and BDSTypeSafeEnum< def, inner >::underlying().
Referenced by CreateFieldEM(), CreateIntegratorE(), and CreateIntegratorMag().
|
private |
Create a purely magnetic integrator. As it's purely magnetic, this requires a G4Mag_EqRhs* equation of motion instance.
Definition at line 1043 of file BDSFieldFactory.cc.
References BDSFieldInfo::BeamPipeRadius(), BDSFieldInfo::BRho(), CreateIntegratorEM(), designParticle, BDSGlobalConstants::Instance(), BDSFieldInfo::IntegratorType(), BDSFieldInfo::Tilt(), and BDSTypeSafeEnum< def, inner >::underlying().
Referenced by CreateFieldMag().
|
private |
Create the necessary modulator.
Definition at line 1295 of file BDSFieldFactory.cc.
References BDSModulatorInfo::amplitudeOffset, BDSModulatorInfo::frequency, BDS::IsFinite(), BDSModulatorInfo::modulatorType, BDSFieldInfo::NameOfParserDefinition(), BDSModulatorInfo::phase, BDSModulatorInfo::scale, BDSModulatorInfo::T0, BDSModulatorInfo::T1, BDSModulatorInfo::tOffset, and BDSTypeSafeEnum< def, inner >::underlying().
Referenced by CreateFieldEM(), CreateFieldERaw(), and CreateFieldMagRaw().
|
private |
Create special parallel transport 'field' that applies a parallel transport along beam line.
Definition at line 1277 of file BDSFieldFactory.cc.
Referenced by CreateFieldIrregular().
|
private |
Create special rmatrix 'field' that applies an rmatrix.
Definition at line 1257 of file BDSFieldFactory.cc.
References BDSFieldInfo::BeamPipeRadius(), and BDSFieldInfo::MagnetStrength().
Referenced by CreateFieldIrregular().
|
private |
Create a special teleporter 'field' that shifts particles at the end of rings to match up correctly.
Definition at line 1233 of file BDSFieldFactory.cc.
References designParticle, BDSGlobalConstants::Instance(), BDSFieldInfo::MagnetStrength(), primaryGeneratorAction, BDSPrimaryGeneratorAction::RegisterPTCOneTurnMap(), and BDSFieldInfo::TransformComplete().
Referenced by CreateFieldIrregular().
|
static |
Suggest a default interpolator.
Definition at line 556 of file BDSFieldFactory.cc.
Referenced by PrepareFieldDefinitions().
BDSFieldInfo * BDSFieldFactory::GetDefinition | ( | const G4String & | name | ) | const |
Return a BDSFieldInfo instance from the parser definitions. Will exit if no matching field definition is found but will return nullptr if empty string supplied.
Definition at line 483 of file BDSFieldFactory.cc.
References parserDefinitions.
Referenced by CreateFieldERaw(), and CreateFieldMagRaw().
BDSModulatorInfo * BDSFieldFactory::GetModulatorDefinition | ( | const G4String & | modulatorName | ) | const |
Return a BDSModulatorInfo instance from the parser definitions. Will exit if no matching modulator definition is found but will return nullptr if empty string supplied.
Definition at line 502 of file BDSFieldFactory.cc.
Referenced by BDSComponentFactory::ModulatorDefinition(), and PrepareFieldDefinitions().
|
private |
Return the parameter "outerScaling" from strength st, but default to 1.
Definition at line 1287 of file BDSFieldFactory.cc.
References BDSMagnetStrength::KeyHasBeenSet().
Referenced by CreateFieldMagRaw().
|
static |
Public accessor method for singleton pattern.
Definition at line 158 of file BDSFieldFactory.cc.
References BDSFieldFactory(), and instance.
Referenced by BDS::BuildPlacementGeometry(), BDSComponentFactory::ModulatorDefinition(), BDSComponentFactory::SetFieldDefinitions(), BDSIM::~BDSIM(), and BDSIMLink::~BDSIMLink().
|
private |
Prepare all required definitions that can be used dynamically.
Definition at line 188 of file BDSFieldFactory.cc.
References BDSBeamPipeInfo::aper1, BDS::CreateUserLimits(), DefaultInterpolatorType(), BDS::DetermineArrayReflectionTypeSet(), BDS::DetermineFieldFormat(), BDS::DetermineFieldType(), BDS::DetermineIntegratorType(), BDS::DetermineInterpolatorType(), BDS::GetFullPath(), GetModulatorDefinition(), BDSGlobalConstants::Instance(), BDS::InterpolatorTypeIsAuto(), BDS::InterpolatorTypeSpecificFromAuto(), BDS::IsFinite(), BDS::NDimensionsOfFieldFormat(), BDS::NDimensionsOfInterpolatorType(), parserDefinitions, PrepareFieldStrengthFromParameters(), and BDS::SplitOnColon().
Referenced by BDSFieldFactory().
|
private |
Fill an instance of BDSMagnetStrength with parameters as defined in a string "fieldParameters" that is assumed to be a space-delimited set of parameter=value strings.
Definition at line 450 of file BDSFieldFactory.cc.
References BDSMagnetStrength::AllKeys(), ConvertToDoubleWithException(), BDS::GetUserParametersMap(), BDSMagnetStrength::Unit(), and BDSMagnetStrength::ValidKey().
Referenced by PrepareFieldDefinitions().
|
private |
Prepare all required modulator definitions that can be used dynamically.
Definition at line 373 of file BDSFieldFactory.cc.
References BDS::DetermineModulatorType().
Referenced by BDSFieldFactory().
|
inlinestatic |
Update the internal cache of the rigidity.
Definition at line 83 of file BDSFieldFactory.hh.
References designParticle.
Referenced by BDSIM::Initialise().
|
inlinestatic |
Update the internal cache of the primary generator action.
Definition at line 86 of file BDSFieldFactory.hh.
References primaryGeneratorAction.
Referenced by BDSIM::Initialise().
|
staticprivate |
Cache of design particle for fields.
Definition at line 203 of file BDSFieldFactory.hh.
Referenced by BDSFieldFactory(), CreateIntegratorMag(), CreateTeleporter(), and SetDesignParticle().
|
staticprivate |
Instance - singleton pattern.
Definition at line 179 of file BDSFieldFactory.hh.
Referenced by Instance().
|
private |
BDSFieldInfo definitions prepare from parser vector of definitions.
Definition at line 199 of file BDSFieldFactory.hh.
Referenced by GetDefinition(), and PrepareFieldDefinitions().
|
private |
Definition at line 200 of file BDSFieldFactory.hh.
|
staticprivate |
Cache of primary generator action.
Definition at line 206 of file BDSFieldFactory.hh.
Referenced by CreateTeleporter(), and SetPrimaryGeneratorAction().
|
private |
Definition at line 208 of file BDSFieldFactory.hh.