BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
|
Efficient storage of magnet strengths. More...
#include <BDSMagnetStrength.hh>
Data Structures | |
struct | unitsFactors |
Structure for unit names and numerical factors from Geant4 to SI(ish). More... | |
Public Member Functions | |
BDSMagnetStrength () | |
Default constructor does nothing as class will return 0 for uninitialised keys. More... | |
BDSMagnetStrength (const std::map< G4String, G4double > &keyvalues) | |
This constructor allows instantiation with a map of keys and values. More... | |
std::ostream & | WriteValuesInSIUnitsForSuvey (std::ostream &out, const G4int precision=14) const |
G4double & | operator[] (const G4String &key) |
Accessors with array / map [] operator. More... | |
const G4double & | operator[] (const G4String &key) const |
const G4double & | at (const G4String &key) const |
std::vector< G4double > | NormalComponents () const |
Accessor for all normal components - k1 - k12. More... | |
std::vector< G4double > | SkewComponents () const |
Accessor for all skew components - k1 - k12. More... | |
G4bool | KeyHasBeenSet (const G4String &key) const |
Whether a key has been set. More... | |
Static Public Member Functions | |
static const std::vector< G4String > & | AllKeys () |
Accessor to all keys. More... | |
static G4bool | ValidKey (const G4String &key) |
Whether or not the supplied key is a valid magnet strength parameter. More... | |
static const std::map< G4String, unitsFactors > & | UnitsAndFactors () |
Accessor to all units. More... | |
static std::vector< G4String > | NormalComponentKeys () |
Accessor for normal component keys - k1 - k12. More... | |
static std::vector< G4String > | SkewComponentKeys () |
Accessor for skew component keys - k1 - k12. More... | |
static G4String | UnitName (const G4String &key) |
Access a unit name for a given key. More... | |
static G4double | Unit (const G4String &key) |
Access a unit factor for a given key. More... | |
Private Types | |
typedef std::map< G4String, G4double > | StrengthMap |
Typedefs up first so we can declare public iterators. More... | |
Private Member Functions | |
const G4double & | GetValue (const G4String &key) const |
Private Attributes | |
StrengthMap | strengths |
Static Private Attributes | |
static const std::vector< G4String > | keys |
Vector of the allowed strength parameters. More... | |
static const std::map< G4String, unitsFactors > | unitsFactorsMap |
Map of each unit name and numerical factor to each key. More... | |
static const std::vector< G4String > | normalComponentKeys |
Vector of the normal component strength parameters. More... | |
static const std::vector< G4String > | skewComponentKeys |
Vector of the normal component strength parameters. More... | |
static const G4double | zero = 0.0 |
Keep a single copy of 0.0 as it needs to be returned as a reference not a value. More... | |
static G4double | variable = 0.0 |
Dummy variable that can be overwritten. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &out, BDSMagnetStrength const &st) |
Output stream. More... | |
typedef StrengthMap::iterator | iterator |
Iterator mechanics. More... | |
typedef StrengthMap::const_iterator | const_iterator |
Iterator mechanics. More... | |
iterator | begin () |
Iterator mechanics. More... | |
iterator | end () |
Iterator mechanics. More... | |
const_iterator | begin () const |
Iterator mechanics. More... | |
const_iterator | end () const |
Iterator mechanics. More... | |
G4bool | empty () const |
Iterator mechanics. More... | |
Efficient storage of magnet strengths.
Based on std::map, this class stores magnet strengths.
As there will be one of these for every magnet and they may in future have to go up to high order normal plus skew (~40 doubles), it is more efficient to only store the required parameters. A pure quadrupole has no need of k20s, but a multipole may do. A static vector contains the possible magnet strength parameters that can be checked against. If a parameter is not specified in the map, its value is return as 0.
Angle in rad, Field in Geant4 units. k strengths as original (ie not converted to G4).
Definition at line 45 of file BDSMagnetStrength.hh.
typedef StrengthMap::const_iterator BDSMagnetStrength::const_iterator |
Iterator mechanics.
Definition at line 118 of file BDSMagnetStrength.hh.
typedef StrengthMap::iterator BDSMagnetStrength::iterator |
Iterator mechanics.
Definition at line 117 of file BDSMagnetStrength.hh.
|
private |
Typedefs up first so we can declare public iterators.
Definition at line 49 of file BDSMagnetStrength.hh.
|
inline |
Default constructor does nothing as class will return 0 for uninitialised keys.
Definition at line 58 of file BDSMagnetStrength.hh.
|
explicit |
This constructor allows instantiation with a map of keys and values.
Definition at line 173 of file BDSMagnetStrength.cc.
References ValidKey().
|
inline |
Definition at line 63 of file BDSMagnetStrength.hh.
|
inlinestatic |
Accessor to all keys.
Definition at line 87 of file BDSMagnetStrength.hh.
References keys.
Referenced by BDSFieldFactory::PrepareFieldStrengthFromParameters().
|
inline |
Definition at line 84 of file BDSMagnetStrength.hh.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
Accessor similar to [] but without linear search through keys to check validity. for fast internal use.
Definition at line 266 of file BDSMagnetStrength.cc.
References strengths, and zero.
Referenced by NormalComponents(), SkewComponents(), and WriteValuesInSIUnitsForSuvey().
G4bool BDSMagnetStrength::KeyHasBeenSet | ( | const G4String & | key | ) | const |
Whether a key has been set.
Definition at line 275 of file BDSMagnetStrength.cc.
References strengths.
Referenced by BDSFieldFactory::GetOuterScaling().
|
inlinestatic |
Accessor for normal component keys - k1 - k12.
Definition at line 96 of file BDSMagnetStrength.hh.
References normalComponentKeys.
Referenced by BDSComponentFactory::PrepareMagnetStrengthForMultipoles().
std::vector< G4double > BDSMagnetStrength::NormalComponents | ( | ) | const |
Accessor for all normal components - k1 - k12.
Definition at line 240 of file BDSMagnetStrength.cc.
References GetValue(), and normalComponentKeys.
Referenced by BDSOutputROOTEventModel::Fill().
G4double & BDSMagnetStrength::operator[] | ( | const G4String & | key | ) |
Accessors with array / map [] operator.
Definition at line 213 of file BDSMagnetStrength.cc.
References strengths, and ValidKey().
const G4double & BDSMagnetStrength::operator[] | ( | const G4String & | key | ) | const |
Definition at line 232 of file BDSMagnetStrength.cc.
|
inlinestatic |
Accessor for skew component keys - k1 - k12.
Definition at line 99 of file BDSMagnetStrength.hh.
References skewComponentKeys.
Referenced by BDSComponentFactory::PrepareMagnetStrengthForMultipoles().
std::vector< G4double > BDSMagnetStrength::SkewComponents | ( | ) | const |
Accessor for all skew components - k1 - k12.
Definition at line 249 of file BDSMagnetStrength.cc.
References GetValue(), and skewComponentKeys.
Referenced by BDSOutputROOTEventModel::Fill().
|
static |
Access a unit factor for a given key.
Definition at line 205 of file BDSMagnetStrength.cc.
References unitsFactorsMap, and ValidKey().
Referenced by BDSOutputROOTEventModel::Fill(), and BDSFieldFactory::PrepareFieldStrengthFromParameters().
|
static |
Access a unit name for a given key.
Definition at line 197 of file BDSMagnetStrength.cc.
References unitsFactorsMap, and ValidKey().
Referenced by BDSSurvey::WriteHeader().
|
inlinestatic |
Accessor to all units.
Definition at line 93 of file BDSMagnetStrength.hh.
References unitsFactorsMap.
|
static |
Whether or not the supplied key is a valid magnet strength parameter.
Definition at line 258 of file BDSMagnetStrength.cc.
References keys.
Referenced by BDSMagnetStrength(), operator[](), BDSFieldFactory::PrepareFieldStrengthFromParameters(), Unit(), and UnitName().
std::ostream & BDSMagnetStrength::WriteValuesInSIUnitsForSuvey | ( | std::ostream & | out, |
const G4int | precision = 14 |
||
) | const |
Print out each magnet strength value in order according to keys multiplied by the correct factors to return to the units on the input side of BDSIM rather than the Geant4 ones used internally.
Definition at line 189 of file BDSMagnetStrength.cc.
References GetValue(), keys, and unitsFactorsMap.
Referenced by BDSSurvey::Write().
|
friend |
Output stream.
Definition at line 182 of file BDSMagnetStrength.cc.
|
staticprivate |
Vector of the allowed strength parameters.
Definition at line 132 of file BDSMagnetStrength.hh.
Referenced by AllKeys(), ValidKey(), and WriteValuesInSIUnitsForSuvey().
|
staticprivate |
Vector of the normal component strength parameters.
Definition at line 138 of file BDSMagnetStrength.hh.
Referenced by NormalComponentKeys(), and NormalComponents().
|
staticprivate |
Vector of the normal component strength parameters.
Definition at line 141 of file BDSMagnetStrength.hh.
Referenced by SkewComponentKeys(), and SkewComponents().
|
private |
A map containing the values for various magnet strengths. It only contains the set magnet strengths. If a strength isn't specified, it's assumed to be zero without having to store the 0 value.
Definition at line 54 of file BDSMagnetStrength.hh.
Referenced by begin(), empty(), end(), GetValue(), KeyHasBeenSet(), and operator[]().
|
staticprivate |
Map of each unit name and numerical factor to each key.
Definition at line 135 of file BDSMagnetStrength.hh.
Referenced by Unit(), UnitName(), UnitsAndFactors(), and WriteValuesInSIUnitsForSuvey().
|
staticprivate |
Dummy variable that can be overwritten.
Definition at line 147 of file BDSMagnetStrength.hh.
|
staticprivate |
Keep a single copy of 0.0 as it needs to be returned as a reference not a value.
Definition at line 144 of file BDSMagnetStrength.hh.
Referenced by GetValue().