BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
|
A loader for various field map formats. More...
#include <BDSFieldLoader.hh>
Public Member Functions | |
void | DeleteArrays () |
BDSFieldMagInterpolated * | LoadMagField (const BDSFieldInfo &info, const BDSMagnetStrength *scalingStrength=nullptr, const G4String &scalingKey="none") |
Main interface to load a magnetic field. | |
BDSFieldEInterpolated * | LoadEField (const BDSFieldInfo &info) |
Main interface to load an electric field. | |
BDSFieldEMInterpolated * | LoadEMField (const BDSFieldInfo &info) |
Main interface to load an electro-magnetic field. | |
Static Public Member Functions | |
static BDSFieldLoader * | Instance () |
Singleton accessor. | |
Private Member Functions | |
BDSFieldLoader () | |
Private default constructor as singleton. | |
void | CreateOperators (const BDSArrayReflectionTypeSet *reflectionTypes, const BDSArray4DCoords *existingArray, BDSArrayOperatorIndex *&indexOperator, BDSArrayOperatorValue *&valueOperator) const |
void | ReportIfProblemWithReflection (const BDSArrayInfo &info, const std::array< G4bool, 4 > &operatesOnXYZT, G4double tolerance=0.05) const |
G4bool | NeedToProvideTransform (const BDSArrayReflectionTypeSet *reflectionTypes) const |
BDSArray1DCoords * | CreateArrayReflected (BDSArray1DCoords *existingArray, const BDSArrayReflectionTypeSet *reflectionType) const |
BDSArray2DCoords * | CreateArrayReflected (BDSArray2DCoords *existingArray, const BDSArrayReflectionTypeSet *reflectionType) const |
BDSArray3DCoords * | CreateArrayReflected (BDSArray3DCoords *existingArray, const BDSArrayReflectionTypeSet *reflectionType) const |
BDSArray4DCoords * | CreateArrayReflected (BDSArray4DCoords *existingArray, const BDSArrayReflectionTypeSet *reflectionType) const |
BDSInterpolator1D * | CreateInterpolator1D (BDSArray1DCoords *array, BDSInterpolatorType interpolatorType) const |
Create the appropriate 1D interpolator for an array. | |
BDSInterpolator2D * | CreateInterpolator2D (BDSArray2DCoords *array, BDSInterpolatorType interpolatorType) const |
Create the appropriate 2D interpolator for an array. | |
BDSInterpolator3D * | CreateInterpolator3D (BDSArray3DCoords *array, BDSInterpolatorType interpolatorType) const |
Create the appropriate 3D interpolator for an array. | |
BDSInterpolator4D * | CreateInterpolator4D (BDSArray4DCoords *array, BDSInterpolatorType interpolatorType) const |
Create the appropriate 4D interpolator for an array. | |
BDSFieldMagInterpolated * | LoadBDSIM1DB (const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double bScaling, const BDSArrayReflectionTypeSet *reflection=nullptr) |
Load a 1D BDSIM format magnetic field. | |
BDSFieldMagInterpolated * | LoadBDSIM2DB (const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double bScaling, const BDSArrayReflectionTypeSet *reflection=nullptr) |
Load a 2D BDSIM format magnetic field. | |
BDSFieldMagInterpolated * | LoadBDSIM3DB (const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double bScaling, const BDSArrayReflectionTypeSet *reflection=nullptr) |
Load a 3D BDSIM format magnetic field. | |
BDSFieldMagInterpolated * | LoadBDSIM4DB (const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double bScaling, const BDSArrayReflectionTypeSet *reflection=nullptr) |
Load a 4D BDSIM format magnetic field. | |
BDSFieldMagInterpolated * | LoadPoissonSuperFishB (const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double bScaling, const BDSArrayReflectionTypeSet *reflection=nullptr) |
Load a 2D poisson superfish B field map. | |
BDSFieldMagInterpolated * | LoadPoissonSuperFishBQuad (const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double bScaling, const BDSArrayReflectionTypeSet *reflection=nullptr) |
BDSFieldMagInterpolated * | LoadPoissonSuperFishBDipole (const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double bScaling, const BDSArrayReflectionTypeSet *reflection=nullptr) |
BDSFieldEInterpolated * | LoadBDSIM1DE (const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double eScaling, const BDSArrayReflectionTypeSet *reflection=nullptr) |
Load a 1D BDSIM format electric field. | |
BDSFieldEInterpolated * | LoadBDSIM2DE (const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double eScaling, const BDSArrayReflectionTypeSet *reflection=nullptr) |
Load a 2D BDSIM format electric field. | |
BDSFieldEInterpolated * | LoadBDSIM3DE (const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double eScaling, const BDSArrayReflectionTypeSet *reflection=nullptr) |
Load a 3D BDSIM format electric field. | |
BDSFieldEInterpolated * | LoadBDSIM4DE (const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double eScaling, const BDSArrayReflectionTypeSet *reflection=nullptr) |
Load a 4D BDSIM format electric field. | |
BDSFieldEMInterpolated * | LoadBDSIM1DEM (const G4String &eFilePath, const G4String &bFilePath, BDSInterpolatorType eInterpolatorType, BDSInterpolatorType bInterpolatorType, const G4Transform3D &transform, G4double eScaling, G4double bScaling, const BDSArrayReflectionTypeSet *eReflection=nullptr, const BDSArrayReflectionTypeSet *bReflection=nullptr) |
Load a 1D BDSIM format electro-magnetic field. | |
BDSFieldEMInterpolated * | LoadBDSIM2DEM (const G4String &eFilePath, const G4String &bFilePath, BDSInterpolatorType eInterpolatorType, BDSInterpolatorType bInterpolatorType, const G4Transform3D &transform, G4double eScaling, G4double bScaling, const BDSArrayReflectionTypeSet *eReflection=nullptr, const BDSArrayReflectionTypeSet *bReflection=nullptr) |
Load a 2D BDSIM format electro-magnetic field. | |
BDSFieldEMInterpolated * | LoadBDSIM3DEM (const G4String &eFilePath, const G4String &bFilePath, BDSInterpolatorType eInterpolatorType, BDSInterpolatorType bInterpolatorType, const G4Transform3D &transform, G4double eScaling, G4double bScaling, const BDSArrayReflectionTypeSet *eReflection=nullptr, const BDSArrayReflectionTypeSet *bReflection=nullptr) |
Load a 3D BDSIM format electro-magnetic field. | |
BDSFieldEMInterpolated * | LoadBDSIM4DEM (const G4String &eFilePath, const G4String &bFilePath, BDSInterpolatorType eInterpolatorType, BDSInterpolatorType bInterpolatorType, const G4Transform3D &transform, G4double eScaling, G4double bScaling, const BDSArrayReflectionTypeSet *eReflection=nullptr, const BDSArrayReflectionTypeSet *bReflection=nullptr) |
Load a 4D BDSIM format electro-magnetic field. | |
BDSArray1DCoords * | Get1DCached (const G4String &filePath) |
Return the cached array if there is one - may return nullptr. | |
BDSArray2DCoords * | Get2DCached (const G4String &filePath) |
Return the cached array if there is one - may return nullptr. | |
BDSArray3DCoords * | Get3DCached (const G4String &filePath) |
Return the cached array if there is one - may return nullptr. | |
BDSArray4DCoords * | Get4DCached (const G4String &filePath) |
Return the cached array if there is one - may return nullptr. | |
BDSArray2DCoords * | LoadPoissonMag2D (const G4String &filePath) |
Utility function to use the right templated loader class (gz or normal). | |
BDSArray1DCoords * | LoadBDSIM1D (const G4String &filePath) |
Utility function to use the right templated loader class (gz or normal). | |
BDSArray2DCoords * | LoadBDSIM2D (const G4String &filePath) |
Utility function to use the right templated loader class (gz or normal). | |
BDSArray3DCoords * | LoadBDSIM3D (const G4String &filePath) |
Utility function to use the right templated loader class (gz or normal). | |
BDSArray4DCoords * | LoadBDSIM4D (const G4String &filePath) |
Utility function to use the right templated loader class (gz or normal). | |
Static Private Member Functions | |
static void | BFilePathOK (const BDSFieldInfo &info) |
Check file path isn't empty and throw exception if it is. | |
static void | EFilePathOK (const BDSFieldInfo &info) |
Check file path isn't empty and throw exception if it is. | |
Private Attributes | |
std::map< G4String, BDSArray1DCoords * > | arrays1d |
Map of cached field map array. | |
std::map< G4String, BDSArray2DCoords * > | arrays2d |
Map of cached field map array. | |
std::map< G4String, BDSArray3DCoords * > | arrays3d |
Map of cached field map array. | |
std::map< G4String, BDSArray4DCoords * > | arrays4d |
Map of cached field map array. | |
Static Private Attributes | |
static BDSFieldLoader * | instance = nullptr |
Singleton instance. | |
A loader for various field map formats.
A factory to use the appropriate file loader for different field map formats and construct into required field including the correct interpolator and possible reflections.
This is a singleton as the field loader owns the loaded data arrays and reuses them wrapping them in interpolators multiple times if needed. For this reason there should be only one field loader.
Definition at line 62 of file BDSFieldLoader.hh.
BDSFieldLoader::~BDSFieldLoader | ( | ) |
Definition at line 116 of file BDSFieldLoader.cc.
|
private |
Private default constructor as singleton.
Definition at line 113 of file BDSFieldLoader.cc.
Referenced by Instance().
|
staticprivate |
Check file path isn't empty and throw exception if it is.
Definition at line 320 of file BDSFieldLoader.cc.
References BDSFieldInfo::MagneticFile(), and BDSFieldInfo::NameOfParserDefinition().
Referenced by LoadEMField(), and LoadMagField().
|
private |
Definition at line 752 of file BDSFieldLoader.cc.
|
private |
Definition at line 765 of file BDSFieldLoader.cc.
|
private |
Definition at line 778 of file BDSFieldLoader.cc.
|
private |
Definition at line 791 of file BDSFieldLoader.cc.
|
private |
Create the appropriate 1D interpolator for an array.
Definition at line 503 of file BDSFieldLoader.cc.
References BDSTypeSafeEnum< def, inner >::underlying().
Referenced by LoadBDSIM1DB(), LoadBDSIM1DE(), and LoadBDSIM1DEM().
|
private |
Create the appropriate 2D interpolator for an array.
Definition at line 523 of file BDSFieldLoader.cc.
References BDSTypeSafeEnum< def, inner >::underlying().
Referenced by LoadBDSIM2DB(), LoadBDSIM2DE(), LoadBDSIM2DEM(), LoadPoissonSuperFishB(), LoadPoissonSuperFishBDipole(), and LoadPoissonSuperFishBQuad().
|
private |
Create the appropriate 3D interpolator for an array.
Definition at line 543 of file BDSFieldLoader.cc.
References BDSTypeSafeEnum< def, inner >::underlying().
Referenced by LoadBDSIM3DB(), LoadBDSIM3DE(), and LoadBDSIM3DEM().
|
private |
Create the appropriate 4D interpolator for an array.
Definition at line 563 of file BDSFieldLoader.cc.
References BDSTypeSafeEnum< def, inner >::underlying().
Referenced by LoadBDSIM4DB(), LoadBDSIM4DE(), and LoadBDSIM4DEM().
|
private |
Create the appropriate array operators (index and value) and assign to the pointers given by reference. Assumes valid pointer for reflectionTypes argument.
Definition at line 583 of file BDSFieldLoader.cc.
References BDSArray4DCoords::DimensionIndex(), BDSArrayOperatorIndex::Name(), BDSArrayOperatorValue::Name(), BDSArrayOperatorIndex::OperatesOnXYZT(), BDS::ProblemWithArrayReflectionCombination(), and ReportIfProblemWithReflection().
void BDSFieldLoader::DeleteArrays | ( | ) |
Definition at line 122 of file BDSFieldLoader.cc.
|
staticprivate |
Check file path isn't empty and throw exception if it is.
Definition at line 330 of file BDSFieldLoader.cc.
References BDSFieldInfo::ElectricFile(), and BDSFieldInfo::NameOfParserDefinition().
Referenced by LoadEField(), and LoadEMField().
|
private |
Return the cached array if there is one - may return nullptr.
Definition at line 340 of file BDSFieldLoader.cc.
References arrays1d.
Referenced by LoadBDSIM1D().
|
private |
Return the cached array if there is one - may return nullptr.
Definition at line 349 of file BDSFieldLoader.cc.
References arrays2d.
Referenced by LoadBDSIM2D(), and LoadPoissonMag2D().
|
private |
Return the cached array if there is one - may return nullptr.
Definition at line 358 of file BDSFieldLoader.cc.
References arrays3d.
Referenced by LoadBDSIM3D().
|
private |
Return the cached array if there is one - may return nullptr.
Definition at line 367 of file BDSFieldLoader.cc.
References arrays4d.
Referenced by LoadBDSIM4D().
|
static |
Singleton accessor.
Definition at line 106 of file BDSFieldLoader.cc.
References BDSFieldLoader(), and instance.
Referenced by BDSFieldFactory::CreateFieldEM(), BDSFieldFactory::CreateFieldERaw(), BDSFieldFactory::CreateFieldMagRaw(), BDSIM::~BDSIM(), and BDSIMLink::~BDSIMLink().
|
private |
Utility function to use the right templated loader class (gz or normal).
Definition at line 401 of file BDSFieldLoader.cc.
References arrays1d, Get1DCached(), and BDSFieldLoaderBDSIM< T >::Load1D().
Referenced by LoadBDSIM1DB(), LoadBDSIM1DE(), and LoadBDSIM1DEM().
|
private |
Load a 1D BDSIM format magnetic field.
Definition at line 804 of file BDSFieldLoader.cc.
References CreateInterpolator1D(), and LoadBDSIM1D().
Referenced by LoadMagField().
|
private |
Load a 1D BDSIM format electric field.
Definition at line 907 of file BDSFieldLoader.cc.
References CreateInterpolator1D(), and LoadBDSIM1D().
Referenced by LoadEField().
|
private |
Load a 1D BDSIM format electro-magnetic field.
Definition at line 963 of file BDSFieldLoader.cc.
References CreateInterpolator1D(), and LoadBDSIM1D().
Referenced by LoadEMField().
|
private |
Utility function to use the right templated loader class (gz or normal).
Definition at line 428 of file BDSFieldLoader.cc.
References arrays2d, Get2DCached(), and BDSFieldLoaderBDSIM< T >::Load2D().
Referenced by LoadBDSIM2DB(), LoadBDSIM2DE(), and LoadBDSIM2DEM().
|
private |
Load a 2D BDSIM format magnetic field.
Definition at line 819 of file BDSFieldLoader.cc.
References CreateInterpolator2D(), and LoadBDSIM2D().
Referenced by LoadMagField().
|
private |
Load a 2D BDSIM format electric field.
Definition at line 921 of file BDSFieldLoader.cc.
References CreateInterpolator2D(), and LoadBDSIM2D().
Referenced by LoadEField().
|
private |
Load a 2D BDSIM format electro-magnetic field.
Definition at line 986 of file BDSFieldLoader.cc.
References CreateInterpolator2D(), and LoadBDSIM2D().
Referenced by LoadEMField().
|
private |
Utility function to use the right templated loader class (gz or normal).
Definition at line 453 of file BDSFieldLoader.cc.
References arrays3d, Get3DCached(), and BDSFieldLoaderBDSIM< T >::Load3D().
Referenced by LoadBDSIM3DB(), LoadBDSIM3DE(), and LoadBDSIM3DEM().
|
private |
Load a 3D BDSIM format magnetic field.
Definition at line 833 of file BDSFieldLoader.cc.
References CreateInterpolator3D(), and LoadBDSIM3D().
Referenced by LoadMagField().
|
private |
Load a 3D BDSIM format electric field.
Definition at line 935 of file BDSFieldLoader.cc.
References CreateInterpolator3D(), and LoadBDSIM3D().
Referenced by LoadEField().
|
private |
Load a 3D BDSIM format electro-magnetic field.
Definition at line 1009 of file BDSFieldLoader.cc.
References CreateInterpolator3D(), and LoadBDSIM3D().
Referenced by LoadEMField().
|
private |
Utility function to use the right templated loader class (gz or normal).
Definition at line 478 of file BDSFieldLoader.cc.
References arrays4d, Get4DCached(), and BDSFieldLoaderBDSIM< T >::Load4D().
Referenced by LoadBDSIM4DB(), LoadBDSIM4DE(), and LoadBDSIM4DEM().
|
private |
Load a 4D BDSIM format magnetic field.
Definition at line 847 of file BDSFieldLoader.cc.
References CreateInterpolator4D(), and LoadBDSIM4D().
Referenced by LoadMagField().
|
private |
Load a 4D BDSIM format electric field.
Definition at line 949 of file BDSFieldLoader.cc.
References CreateInterpolator4D(), and LoadBDSIM4D().
Referenced by LoadEField().
|
private |
Load a 4D BDSIM format electro-magnetic field.
Definition at line 1032 of file BDSFieldLoader.cc.
References CreateInterpolator4D(), and LoadBDSIM4D().
Referenced by LoadEMField().
BDSFieldEInterpolated * BDSFieldLoader::LoadEField | ( | const BDSFieldInfo & | info | ) |
Main interface to load an electric field.
Definition at line 218 of file BDSFieldLoader.cc.
References EFilePathOK(), BDSFieldInfo::ElectricArrayReflectionType(), BDSFieldInfo::ElectricFile(), BDSFieldInfo::ElectricFormat(), BDSFieldInfo::ElectricInterpolatorType(), BDSFieldInfo::EScaling(), LoadBDSIM1DE(), LoadBDSIM2DE(), LoadBDSIM3DE(), LoadBDSIM4DE(), BDSFieldInfo::NameOfParserDefinition(), BDSFieldInfo::Transform(), and BDSTypeSafeEnum< def, inner >::underlying().
Referenced by BDSFieldFactory::CreateFieldERaw().
BDSFieldEMInterpolated * BDSFieldLoader::LoadEMField | ( | const BDSFieldInfo & | info | ) |
Main interface to load an electro-magnetic field.
Definition at line 254 of file BDSFieldLoader.cc.
References BFilePathOK(), BDSFieldInfo::BScaling(), EFilePathOK(), BDSFieldInfo::ElectricArrayReflectionType(), BDSFieldInfo::ElectricFile(), BDSFieldInfo::ElectricFormat(), BDSFieldInfo::ElectricInterpolatorType(), BDSFieldInfo::EScaling(), LoadBDSIM1DEM(), LoadBDSIM2DEM(), LoadBDSIM3DEM(), LoadBDSIM4DEM(), BDSFieldInfo::MagneticArrayReflectionType(), BDSFieldInfo::MagneticFile(), BDSFieldInfo::MagneticFormat(), BDSFieldInfo::MagneticInterpolatorType(), BDSFieldInfo::NameOfParserDefinition(), BDSFieldInfo::Transform(), and BDSTypeSafeEnum< def, inner >::underlying().
Referenced by BDSFieldFactory::CreateFieldEM().
BDSFieldMagInterpolated * BDSFieldLoader::LoadMagField | ( | const BDSFieldInfo & | info, |
const BDSMagnetStrength * | scalingStrength = nullptr , |
||
const G4String & | scalingKey = "none" |
||
) |
Main interface to load a magnetic field.
Definition at line 134 of file BDSFieldLoader.cc.
References BDSFieldInfo::AutoScale(), BFilePathOK(), BDSFieldInfo::BRho(), BDSFieldInfo::BScaling(), BDSFieldMagGradient::CalculateMultipoles(), BDS::InterpolatorTypeSpecificFromAuto(), LoadBDSIM1DB(), LoadBDSIM2DB(), LoadBDSIM3DB(), LoadBDSIM4DB(), LoadMagField(), LoadPoissonSuperFishB(), LoadPoissonSuperFishBDipole(), LoadPoissonSuperFishBQuad(), BDSFieldInfo::MagneticArrayReflectionType(), BDSFieldInfo::MagneticFile(), BDSFieldInfo::MagneticFormat(), BDSFieldInfo::MagneticInterpolatorType(), BDSFieldInfo::NameOfParserDefinition(), BDS::NDimensionsOfFieldFormat(), BDSFieldInfo::Transform(), and BDSTypeSafeEnum< def, inner >::underlying().
Referenced by BDSFieldFactory::CreateFieldMagRaw(), and LoadMagField().
|
private |
Utility function to use the right templated loader class (gz or normal).
Definition at line 376 of file BDSFieldLoader.cc.
References arrays2d, Get2DCached(), and BDSFieldLoaderPoisson< T >::LoadMag2D().
Referenced by LoadPoissonSuperFishB(), LoadPoissonSuperFishBDipole(), and LoadPoissonSuperFishBQuad().
|
private |
Load a 2D poisson superfish B field map.
Definition at line 861 of file BDSFieldLoader.cc.
References CreateInterpolator2D(), and LoadPoissonMag2D().
Referenced by LoadMagField().
|
private |
Similar to LoadPoissonSuperFishB() but with appropriate reflections for a map for the positive quadrant reflected to all quadrants.
Definition at line 892 of file BDSFieldLoader.cc.
References CreateInterpolator2D(), and LoadPoissonMag2D().
Referenced by LoadMagField().
|
private |
Similar to LoadPoissonSuperFishB() but the data below y = x is reflected and the data relfected from one quadrant to all four at the array level.
Definition at line 875 of file BDSFieldLoader.cc.
References CreateInterpolator2D(), LoadPoissonMag2D(), BDSArray4DCoords::XStep(), and BDSArray4DCoords::YStep().
Referenced by LoadMagField().
|
private |
Small utility to check the pointer is valid and if it is that it's also not empty. Returns true only if it's value and not empty.
Definition at line 739 of file BDSFieldLoader.cc.
|
private |
Print a warning if the array info says the zero-point in array coordinates is not within the tolerance value. Only do this for dimensions where index operating is applied as given by operatesOnXYZT.
Definition at line 721 of file BDSFieldLoader.cc.
Referenced by CreateOperators().
|
private |
Map of cached field map array.
Definition at line 277 of file BDSFieldLoader.hh.
Referenced by Get1DCached(), and LoadBDSIM1D().
|
private |
Map of cached field map array.
Definition at line 278 of file BDSFieldLoader.hh.
Referenced by Get2DCached(), LoadBDSIM2D(), and LoadPoissonMag2D().
|
private |
Map of cached field map array.
Definition at line 279 of file BDSFieldLoader.hh.
Referenced by Get3DCached(), and LoadBDSIM3D().
|
private |
Map of cached field map array.
Definition at line 280 of file BDSFieldLoader.hh.
Referenced by Get4DCached(), and LoadBDSIM4D().
|
staticprivate |