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. | |
BDSMagnetStrength (const std::map< G4String, G4double > &keyvalues) | |
This constructor allows instantiation with a map of keys and values. | |
std::ostream & | WriteValuesInSIUnitsForSuvey (std::ostream &out, const G4int precision=14) const |
G4double & | operator[] (const G4String &key) |
Accessors with array / map [] operator. | |
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. | |
std::vector< G4double > | SkewComponents () const |
Accessor for all skew components - k1 - k12. | |
G4bool | KeyHasBeenSet (const G4String &key) const |
Whether a key has been set. | |
Static Public Member Functions | |
static const std::vector< G4String > & | AllKeys () |
Accessor to all keys. | |
static G4bool | ValidKey (const G4String &key) |
Whether or not the supplied key is a valid magnet strength parameter. | |
static const std::map< G4String, unitsFactors > & | UnitsAndFactors () |
Accessor to all units. | |
static std::vector< G4String > | NormalComponentKeys () |
Accessor for normal component keys - k1 - k12. | |
static std::vector< G4String > | SkewComponentKeys () |
Accessor for skew component keys - k1 - k12. | |
static G4String | UnitName (const G4String &key) |
Access a unit name for a given key. | |
static G4double | Unit (const G4String &key) |
Access a unit factor for a given key. | |
Private Types | |
typedef std::map< G4String, G4double > | StrengthMap |
Typedefs up first so we can declare public iterators. | |
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. | |
static const std::map< G4String, unitsFactors > | unitsFactorsMap |
Map of each unit name and numerical factor to each key. | |
static const std::vector< G4String > | normalComponentKeys |
Vector of the normal component strength parameters. | |
static const std::vector< G4String > | skewComponentKeys |
Vector of the normal component strength parameters. | |
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. | |
static G4double | variable = 0.0 |
Dummy variable that can be overwritten. | |
Friends | |
std::ostream & | operator<< (std::ostream &out, BDSMagnetStrength const &st) |
Output stream. | |
typedef StrengthMap::iterator | iterator |
Iterator mechanics. | |
typedef StrengthMap::const_iterator | const_iterator |
Iterator mechanics. | |
iterator | begin () |
Iterator mechanics. | |
iterator | end () |
Iterator mechanics. | |
const_iterator | begin () const |
Iterator mechanics. | |
const_iterator | end () const |
Iterator mechanics. | |
G4bool | empty () const |
Iterator mechanics. | |
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 there are many parameters (e.g. up to ~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 allowed keys that can be checked against before setting the value. If a (valid) key is not specified in the map, its value is returned as 0.
Angle in rad, Field in Geant4 units. k strengths as original (ie not converted to G4).
Definition at line 44 of file BDSMagnetStrength.hh.
typedef StrengthMap::const_iterator BDSMagnetStrength::const_iterator |
Iterator mechanics.
Definition at line 117 of file BDSMagnetStrength.hh.
typedef StrengthMap::iterator BDSMagnetStrength::iterator |
Iterator mechanics.
Definition at line 116 of file BDSMagnetStrength.hh.
|
private |
Typedefs up first so we can declare public iterators.
Definition at line 48 of file BDSMagnetStrength.hh.
|
inline |
Default constructor does nothing as class will return 0 for uninitialised keys.
Definition at line 57 of file BDSMagnetStrength.hh.
|
explicit |
This constructor allows instantiation with a map of keys and values.
Definition at line 181 of file BDSMagnetStrength.cc.
References ValidKey().
|
inline |
Definition at line 62 of file BDSMagnetStrength.hh.
|
inlinestatic |
Accessor to all keys.
Definition at line 86 of file BDSMagnetStrength.hh.
References keys.
Referenced by BDSFieldFactory::PrepareFieldStrengthFromParameters().
|
inline |
Definition at line 83 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 274 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 283 of file BDSMagnetStrength.cc.
References strengths.
Referenced by BDSFieldFactory::GetOuterScaling().
|
inlinestatic |
Accessor for normal component keys - k1 - k12.
Definition at line 95 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 248 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 221 of file BDSMagnetStrength.cc.
References strengths, and ValidKey().
const G4double & BDSMagnetStrength::operator[] | ( | const G4String & | key | ) | const |
Definition at line 240 of file BDSMagnetStrength.cc.
|
inlinestatic |
Accessor for skew component keys - k1 - k12.
Definition at line 98 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 257 of file BDSMagnetStrength.cc.
References GetValue(), and skewComponentKeys.
Referenced by BDSOutputROOTEventModel::Fill().
|
static |
Access a unit factor for a given key.
Definition at line 213 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 205 of file BDSMagnetStrength.cc.
References unitsFactorsMap, and ValidKey().
Referenced by BDSSurvey::WriteHeader().
|
inlinestatic |
Accessor to all units.
Definition at line 92 of file BDSMagnetStrength.hh.
References unitsFactorsMap.
|
static |
Whether or not the supplied key is a valid magnet strength parameter.
Definition at line 266 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 197 of file BDSMagnetStrength.cc.
References GetValue(), keys, and unitsFactorsMap.
Referenced by BDSSurvey::Write().
|
friend |
Output stream.
Definition at line 190 of file BDSMagnetStrength.cc.
|
staticprivate |
Vector of the allowed strength parameters.
Definition at line 131 of file BDSMagnetStrength.hh.
Referenced by AllKeys(), ValidKey(), and WriteValuesInSIUnitsForSuvey().
|
staticprivate |
Vector of the normal component strength parameters.
Definition at line 137 of file BDSMagnetStrength.hh.
Referenced by NormalComponentKeys(), and NormalComponents().
|
staticprivate |
Vector of the normal component strength parameters.
Definition at line 140 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 53 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 134 of file BDSMagnetStrength.hh.
Referenced by Unit(), UnitName(), UnitsAndFactors(), and WriteValuesInSIUnitsForSuvey().
|
staticprivate |
Dummy variable that can be overwritten.
Definition at line 146 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 143 of file BDSMagnetStrength.hh.
Referenced by GetValue().