16#include <boost/python.hpp>
31 "field module enables user to get the field at a point";
34 "Get the field value at a point in the field map.\n"
35 "Only available in Cyclotron mode.\n"
37 "The field lookup is performed against the last RINGDEFINITION that was\n"
38 "instantiated. This should be instantiated by calling\n"
39 "pyopal.parser.initialise_from_opal_file\n"
54 "The function returns a tuple containing 7 values:\n"
55 "out of bounds : int\n"
56 " 1 if the event was out of the field map boundary, else 0.\n"
58 " x magnetic field [T]\n"
60 " y magnetic field [T]\n"
62 " z magnetic field [T]\n"
68 " z electric field\n";
75 if (tracker ==
nullptr) {
77 "ParallelCyclotronTracker was nullptr"));
82 boost::python::tuple value = boost::python::make_tuple(outOfBounds,
83 B[0], B[1], B[2], E[0], E[1], E[2]);
92 if (trackerCycl !=
nullptr) {
96 "Could not find a ParallelCyclotronTracker - get_field_value only works in OPAL-CYCL mode"));
106 if (ring ==
nullptr) {
108 "Internal PyOpal error - failed to cast to a Ring object");
115"Return a string holding the name of the i^th element [m].\n\n";
119 if (component ==
nullptr) {
121 "Internal PyOpal error - failed to cast to a Component");
127"Return a tuple holding the start position of the element (x, y, z) [m].\n\n";
132 return boost::python::make_tuple(pos[0], pos[1], pos[2]);
136"Return a tuple holding the end position of the element (x, y, z) [m].\n\n";
140 return boost::python::make_tuple(pos[0], pos[1], pos[2]);
144"Return a tuple holding the vector (x, y, z) normal to the face of the\n"
145"element start, pointing towards the element and having length 1.\n\n";
149 return boost::python::make_tuple(dir[0], dir[1], dir[2]);
153"Return a tuple holding the vector (x, y, z) normal to the face of the\n"
154"element end, pointing towards the next element and having length 1.\n\n";
158 return boost::python::make_tuple(dir[0], dir[1], dir[2]);
162"Return an integer corresponding to the number of elements stored in the Ring\n"
163"If this is 0, check that the track has been executed - the element\n"
164"placements are done during Track setup.\n\n";
174 py::def(
"get_field_value",
176 py::args(
"x",
"y",
"z",
"t"),
179 py::def(
"get_number_of_elements",
182 py::def(
"get_element_start_position",
Tps< T > sec(const Tps< T > &x)
Secant.
void registerExceptions()
boost::python::object getElementStartNormal(int i)
py::object get_field_value_cyclotron(double x, double y, double z, double t, ParallelCyclotronTracker *tracker)
BOOST_PYTHON_MODULE(field)
boost::python::object getElementEndPosition(int i)
size_t getNumberOfElements()
std::string end_pos_docstring
boost::python::object getElementStartPosition(int i)
std::string num_elements_docstring
std::string start_pos_docstring
std::string start_norm_docstring
std::string field_docstring
std::string element_name_docstring
py::object get_field_value(double x, double y, double z, double t)
std::string getElementName(int i)
boost::python::object getElementEndNormal(int i)
std::string get_field_value_docstring
std::string end_norm_docstring
bool computeExternalFields_m(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &Efield, Vector_t &Bfield)
Calculate the field map at an arbitrary point.
Interface for a single beam element.
virtual const std::string & getName() const
Get element name.
Ring describes a ring type geometry for tracking.
size_t getNumberOfRingSections() const
RingSection * getSection(int i) const
Component placement handler in ring geometry.
static std::shared_ptr< Tracker > getTracker()
The base class for all OPAL exceptions.
Vektor< double, 3 > Vector_t