8 #ifndef _QwMagneticField_h_
9 #define _QwMagneticField_h_
20 #include <TRotation.h>
29 template <
class value_t,
unsigned int value_n>
class QwInterpolator;
128 field_xyz[0] = field[0];
129 field_xyz[1] = field[1];
130 field_xyz[2] = field[2];
138 double r = sqrt(field[0] * field[0] + field[1] * field[1]) ;
139 double phi = atan2(field[1],field[0]);
140 if (phi < 0) phi += 2.0 *
Qw::pi;
143 field_rfz[2] = field[2];
145 field_rfz[0] = field[3];
146 field_rfz[1] = field[4];
147 field_rfz[2] = field[2];
155 double point_xyz[3], field_xyz[3];
156 point.GetXYZ(point_xyz);
158 field = TVector3(field_xyz);
230 #endif // _QwMagneticField_h_
static const double pi
Angles: base unit is radian.
std::string fFilename
File name.
void GetCartesianFieldValue(const TVector3 &point, TVector3 &field) const
Get the cartesian components of the field value.
Magnetic field map object.
void GetCylindricalFieldValue(const double point_xyz[3], double field_rfz[3]) const
Get the cylindrical components of the field value.
EQwInterpolationMethod
Allowed interpolation methods.
void SetFilename(const std::string &filename)
Set the filename.
double GetRotation() const
Get the field rotation around z (with QwUnits)
QwMagneticField(QwOptions &options, const bool suppress_read_field_map=false)
Default constructor.
std::vector< double > fStep
double GetTranslation() const
Get the field translation along z.
double fRotation
Field rotation and translation with respect to the z axis.
static const unsigned int value_n
bool WriteTextFile(const std::string &fieldmap) const
Write a text field map.
bool ReadFieldMapStream(std::istream &input)
Read the field map input stream.
void SetActualCurrent(const double current)
Set the actual current.
void ProcessOptions(QwOptions &options)
Process command line and config file options.
QwInterpolator< field_t, value_n > * fField
Field map.
void SetInterpolationMethod(const EQwInterpolationMethod method)
Set the interpolation method.
void SetInterpolationMethod(const EQwInterpolationMethod method)
Set interpolation method.
void GetCartesianFieldValue(const double point_xyz[3], double field_xyz[3]) const
Get the cartesian components of the field value.
const std::string GetFilename() const
Get the filename.
bool WriteBinaryFile(const std::string &filename) const
Write the grid values to binary file.
std::vector< double > fMin
Field map grid min, max, step, wrap.
double fReferenceCurrent
Field scale factor.
void SetReferenceCurrent(const double current)
Set the reference current.
double GetReferenceCurrent() const
Get the reference current.
EQwInterpolationMethod GetInterpolationMethod() const
Get the interpolation method.
bool ReadFieldMapZip(const std::string &filename)
Read a field map input gzip file.
std::vector< size_t > fWrap
std::vector< double > fMax
void LoadBeamProperty(const TString &map)
Load beam property.
bool ReadFieldMapFile(const std::string &filename)
Read a field map input file.
void GetFieldValue(const double point[3], double field[value_n]) const
Get the field value.
static std::ostream & endl(std::ostream &)
End of the line.
const std::string getenv_safe_string(const char *name)
An options class which parses command line, config file and environment.
static void DefineOptions(QwOptions &options)
Define command line and config file options.
bool WriteTextFile(const std::string &filename) const
Write the grid to text file.
bool WriteBinaryFile(const std::string &fieldmap) const
Write a binary field map.
void SetTranslation(const double translation)
Set the field translation along z.
#define QwWarning
Predefined log drain for warnings.
EQwInterpolationMethod GetInterpolationMethod() const
Get interpolation method.
void SetRotation(const double rotation)
Set the field rotation around z (with QwUnits)
bool TestFieldMap()
Test the field map.
virtual ~QwMagneticField()
Virtual destructor.
double GetActualCurrent() const
Get the actual current.
A multi-dimensional grid of values with interpolation methods.
bool ReadFieldMap()
Read a field map.