QwAnalysis
|
Magnetic field map object. More...
#include <QwMagneticField.h>
Public Member Functions | |
QwMagneticField (QwOptions &options, const bool suppress_read_field_map=false) | |
Default constructor. More... | |
virtual | ~QwMagneticField () |
Virtual destructor. More... | |
void | ProcessOptions (QwOptions &options) |
Process command line and config file options. More... | |
void | LoadBeamProperty (const TString &map) |
Load beam property. More... | |
void | SetFilename (const std::string &filename) |
Set the filename. More... | |
const std::string | GetFilename () const |
Get the filename. More... | |
void | SetActualCurrent (const double current) |
Set the actual current. More... | |
double | GetActualCurrent () const |
Get the actual current. More... | |
void | SetReferenceCurrent (const double current) |
Set the reference current. More... | |
double | GetReferenceCurrent () const |
Get the reference current. More... | |
void | SetRotation (const double rotation) |
Set the field rotation around z (with QwUnits) More... | |
double | GetRotation () const |
Get the field rotation around z (with QwUnits) More... | |
void | SetTranslation (const double translation) |
Set the field translation along z. More... | |
double | GetTranslation () const |
Get the field translation along z. More... | |
void | GetCartesianFieldValue (const double point_xyz[3], double field_xyz[3]) const |
Get the cartesian components of the field value. More... | |
void | GetCylindricalFieldValue (const double point_xyz[3], double field_rfz[3]) const |
Get the cylindrical components of the field value. More... | |
void | GetCartesianFieldValue (const TVector3 &point, TVector3 &field) const |
Get the cartesian components of the field value. More... | |
bool | ReadFieldMap () |
Read a field map. More... | |
bool | ReadFieldMapFile (const std::string &filename) |
Read a field map input file. More... | |
bool | ReadFieldMapZip (const std::string &filename) |
Read a field map input gzip file. More... | |
bool | ReadFieldMapStream (std::istream &input) |
Read the field map input stream. More... | |
bool | TestFieldMap () |
Test the field map. More... | |
Expose some functionality of underlying field map | |
bool | WriteBinaryFile (const std::string &fieldmap) const |
Write a binary field map. More... | |
bool | WriteTextFile (const std::string &fieldmap) const |
Write a text field map. More... | |
void | SetInterpolationMethod (const EQwInterpolationMethod method) |
Set interpolation method. More... | |
EQwInterpolationMethod | GetInterpolationMethod () const |
Get interpolation method. More... | |
Static Public Member Functions | |
static void | DefineOptions (QwOptions &options) |
Define command line and config file options. More... | |
Private Types | |
typedef float | field_t |
Private Member Functions | |
void | GetFieldValue (const double point[3], double field[value_n]) const |
Get the field value. More... | |
Private Attributes | |
std::string | fFilename |
File name. More... | |
QwInterpolator< field_t, value_n > * | fField |
Field map. More... | |
std::vector< double > | fMin |
Field map grid min, max, step, wrap. More... | |
std::vector< double > | fMax |
std::vector< double > | fStep |
std::vector< size_t > | fWrap |
double | fReferenceCurrent |
Field scale factor. More... | |
double | fActualCurrent |
double | fScaleFactor |
double | fRotation |
Field rotation and translation with respect to the z axis. More... | |
double | fRotationDeg |
double | fRotationRad |
double | fRotationCos |
double | fRotationSin |
double | fTranslation |
Static Private Attributes | |
static const unsigned int | value_n = 3 |
Magnetic field map object.
This class implements a magnetic field object using the QwInterpolator class.
Five magnetic field components are stored (larger memory usage, computationally more intensive on creation, but faster access by avoiding trigonometric operations).
Access to the field components is possible using two functions:
Currently no function exists that takes cylindrical coordinates.
Definition at line 50 of file QwMagneticField.h.
|
private |
Definition at line 58 of file QwMagneticField.h.
QwMagneticField::QwMagneticField | ( | QwOptions & | options, |
const bool | suppress_read_field_map = false |
||
) |
Default constructor.
Default constructor with optional field map
Definition at line 44 of file QwMagneticField.cc.
References QwLog::endl(), fField, ProcessOptions(), QwError, ReadFieldMap(), SetActualCurrent(), SetReferenceCurrent(), SetRotation(), SetTranslation(), and value_n.
|
virtual |
Virtual destructor.
Destructor
Definition at line 70 of file QwMagneticField.cc.
References fField.
|
static |
Define command line and config file options.
Define the options for this subsystem
options | Options object |
Definition at line 79 of file QwMagneticField.cc.
References QwOptions::AddOptions().
Referenced by DefineOptionsTracking(), and main().
|
inline |
Get the actual current.
Definition at line 90 of file QwMagneticField.h.
References fActualCurrent.
Referenced by QwRayTracer::GetMagneticFieldCurrent().
|
inline |
Get the cartesian components of the field value.
Definition at line 124 of file QwMagneticField.h.
References GetFieldValue(), and value_n.
Referenced by GetCartesianFieldValue(), QwRayTracer::IntegrateRK(), and main().
|
inline |
Get the cartesian components of the field value.
Definition at line 154 of file QwMagneticField.h.
References GetCartesianFieldValue().
|
inline |
Get the cylindrical components of the field value.
Definition at line 134 of file QwMagneticField.h.
References QwLog::endl(), GetFieldValue(), Qw::pi, QwWarning, and value_n.
|
private |
Get the field value.
Get a field value
coord_xyz[] | Cartesian coordinates (x,y,z) |
field[] | Field components (x,y,z,r,phi) (return) |
Definition at line 418 of file QwMagneticField.cc.
References QwLog::endl(), fField, fScaleFactor, QwInterpolator< value_t, value_n >::GetValue(), QwInterpolator< value_t, value_n >::InBounds(), Qw::pi, QwWarning, and value_n.
Referenced by GetCartesianFieldValue(), GetCylindricalFieldValue(), and TestFieldMap().
|
inline |
|
inline |
Get interpolation method.
Definition at line 192 of file QwMagneticField.h.
References fField, QwInterpolator< value_t, value_n >::GetInterpolationMethod(), and kInterpolationMethodUnknown.
Referenced by main().
|
inline |
Get the reference current.
Definition at line 100 of file QwMagneticField.h.
References fReferenceCurrent.
|
inline |
Get the field rotation around z (with QwUnits)
Definition at line 113 of file QwMagneticField.h.
References fRotationRad, and Qw::rad.
|
inline |
Get the field translation along z.
Definition at line 120 of file QwMagneticField.h.
References fTranslation.
void QwMagneticField::LoadBeamProperty | ( | const TString & | map | ) |
Load beam property.
Definition at line 457 of file QwMagneticField.cc.
References SetActualCurrent(), and QwParameterFile::TrimComment().
Referenced by ProcessOptions().
void QwMagneticField::ProcessOptions | ( | QwOptions & | options | ) |
Process command line and config file options.
Process the options for this subsystem
options | Options object |
Definition at line 135 of file QwMagneticField.cc.
References Qw::cm, Qw::deg, fMax, fMin, fStep, fWrap, QwOptions::GetValue(), LoadBeamProperty(), SetActualCurrent(), SetFilename(), SetReferenceCurrent(), SetRotation(), and SetTranslation().
Referenced by QwMagneticField().
bool QwMagneticField::ReadFieldMap | ( | ) |
Read a field map.
Read the magnetic field map
Definition at line 176 of file QwMagneticField.cc.
References QwLog::endl(), fField, fFilename, fMax, fMin, fStep, fWrap, getenv_safe_string(), QwError, QwWarning, QwInterpolator< value_t, value_n >::ReadBinaryFile(), ReadFieldMapFile(), ReadFieldMapZip(), and QwInterpolator< value_t, value_n >::SetWrapCoordinate().
Referenced by main(), and QwMagneticField().
bool QwMagneticField::ReadFieldMapFile | ( | const std::string & | filename | ) |
Read a field map input file.
Read the magnetic field from an ANSYS map file in text format
filename | ANSYS map file name |
Definition at line 276 of file QwMagneticField.cc.
References QwLog::endl(), Qw::in, QwError, and ReadFieldMapStream().
Referenced by ReadFieldMap().
bool QwMagneticField::ReadFieldMapStream | ( | std::istream & | input | ) |
Read the field map input stream.
Read the magnetic field from an ANSYS map text stream
input | Input stream |
Definition at line 318 of file QwMagneticField.cc.
References Qw::cm, Qw::deg, QwLog::endl(), fField, QwLog::flush(), fRotation, fRotationCos, fRotationSin, fTranslation, QwInterpolator< value_t, value_n >::GetCurrentEntries(), QwInterpolator< value_t, value_n >::GetMaximumEntries(), Qw::kG, Qw::pi, QwInterpolator< value_t, value_n >::PrintCoverage(), QwError, QwMessage, QwWarning, QwInterpolator< value_t, value_n >::Set(), and value_n.
Referenced by ReadFieldMapFile(), and ReadFieldMapZip().
bool QwMagneticField::ReadFieldMapZip | ( | const std::string & | filename | ) |
Read a field map input gzip file.
Read the magnetic field from an ANSYS map file in gzipped text format
filename | ANSYS map file name |
Definition at line 297 of file QwMagneticField.cc.
References QwLog::endl(), QwWarning, and ReadFieldMapStream().
Referenced by ReadFieldMap().
|
inline |
Set the actual current.
Definition at line 84 of file QwMagneticField.h.
References fActualCurrent, fReferenceCurrent, and fScaleFactor.
Referenced by LoadBeamProperty(), ProcessOptions(), QwMagneticField(), and QwRayTracer::SetMagneticFieldCurrent().
|
inline |
Set the filename.
Definition at line 77 of file QwMagneticField.h.
References fFilename.
Referenced by main(), and ProcessOptions().
|
inline |
Set interpolation method.
Definition at line 188 of file QwMagneticField.h.
References fField, and QwInterpolator< value_t, value_n >::SetInterpolationMethod().
Referenced by main().
|
inline |
Set the reference current.
Definition at line 94 of file QwMagneticField.h.
References fActualCurrent, fReferenceCurrent, and fScaleFactor.
Referenced by ProcessOptions(), and QwMagneticField().
|
inline |
Set the field rotation around z (with QwUnits)
Definition at line 104 of file QwMagneticField.h.
References Qw::deg, fRotation, fRotationCos, fRotationDeg, fRotationRad, fRotationSin, and Qw::rad.
Referenced by ProcessOptions(), and QwMagneticField().
|
inline |
Set the field translation along z.
Definition at line 117 of file QwMagneticField.h.
References fTranslation.
Referenced by ProcessOptions(), and QwMagneticField().
bool QwMagneticField::TestFieldMap | ( | ) |
Test the field map.
Test the field map value at a specific point to make sure nothing went wrong
Definition at line 218 of file QwMagneticField.cc.
References Qw::cm, QwLog::endl(), GetFieldValue(), Qw::kG, QwError, QwMessage, and QwWarning.
Referenced by QwRayTracer::LoadMagneticFieldMap().
|
inline |
Write a binary field map.
Definition at line 176 of file QwMagneticField.h.
References fField, getenv_safe_string(), and QwInterpolator< value_t, value_n >::WriteBinaryFile().
Referenced by main().
|
inline |
Write a text field map.
Definition at line 182 of file QwMagneticField.h.
References fField, getenv_safe_string(), and QwInterpolator< value_t, value_n >::WriteTextFile().
|
private |
Definition at line 212 of file QwMagneticField.h.
Referenced by GetActualCurrent(), SetActualCurrent(), and SetReferenceCurrent().
|
private |
Field map.
Definition at line 204 of file QwMagneticField.h.
Referenced by GetFieldValue(), GetInterpolationMethod(), QwMagneticField(), ReadFieldMap(), ReadFieldMapStream(), SetInterpolationMethod(), WriteBinaryFile(), WriteTextFile(), and ~QwMagneticField().
|
private |
File name.
Definition at line 201 of file QwMagneticField.h.
Referenced by GetFilename(), ReadFieldMap(), and SetFilename().
|
private |
Definition at line 207 of file QwMagneticField.h.
Referenced by ProcessOptions(), and ReadFieldMap().
|
private |
Field map grid min, max, step, wrap.
Definition at line 207 of file QwMagneticField.h.
Referenced by ProcessOptions(), and ReadFieldMap().
|
private |
Field scale factor.
Definition at line 211 of file QwMagneticField.h.
Referenced by GetReferenceCurrent(), SetActualCurrent(), and SetReferenceCurrent().
|
private |
Field rotation and translation with respect to the z axis.
Definition at line 225 of file QwMagneticField.h.
Referenced by ReadFieldMapStream(), and SetRotation().
|
private |
Definition at line 225 of file QwMagneticField.h.
Referenced by ReadFieldMapStream(), and SetRotation().
|
private |
Definition at line 225 of file QwMagneticField.h.
Referenced by SetRotation().
|
private |
Definition at line 225 of file QwMagneticField.h.
Referenced by GetRotation(), and SetRotation().
|
private |
Definition at line 225 of file QwMagneticField.h.
Referenced by ReadFieldMapStream(), and SetRotation().
|
private |
Definition at line 213 of file QwMagneticField.h.
Referenced by GetFieldValue(), SetActualCurrent(), and SetReferenceCurrent().
|
private |
Definition at line 207 of file QwMagneticField.h.
Referenced by ProcessOptions(), and ReadFieldMap().
|
private |
Definition at line 226 of file QwMagneticField.h.
Referenced by GetTranslation(), ReadFieldMapStream(), and SetTranslation().
|
private |
Definition at line 208 of file QwMagneticField.h.
Referenced by ProcessOptions(), and ReadFieldMap().
|
staticprivate |
Definition at line 55 of file QwMagneticField.h.
Referenced by GetCartesianFieldValue(), GetCylindricalFieldValue(), GetFieldValue(), QwMagneticField(), and ReadFieldMapStream().