28 #include <type_traits>
31 #include <pybind11/pybind11.h>
32 #include <pybind11/stl.h>
34 namespace py = pybind11;
35 using namespace pybind11::literals;
37 namespace Acts::Python {
40 auto [
m, mex, prop] = ctx.
get(
"main",
"examples",
"propagation");
43 std::shared_ptr<Acts::MagneticFieldProvider>>(
44 m,
"MagneticFieldProvider");
47 std::shared_ptr<Acts::InterpolatedMagneticField>>(
48 m,
"InterpolatedMagneticField");
51 py::arg(
"zlim"), py::arg(
"nbins"), py::arg(
"field"));
54 std::shared_ptr<Acts::ConstantBField>>(
m,
"ConstantBField")
55 .def(py::init<Acts::Vector3>());
58 Acts::InterpolatedMagneticField, Acts::MagneticFieldProvider,
59 std::shared_ptr<ActsExamples::detail::InterpolatedMagneticField2>>(
60 mex,
"InterpolatedMagneticField2");
63 Acts::InterpolatedMagneticField, Acts::MagneticFieldProvider,
64 std::shared_ptr<ActsExamples::detail::InterpolatedMagneticField3>>(
65 mex,
"InterpolatedMagneticField3");
68 std::shared_ptr<Acts::NullBField>>(
m,
"NullBField")
76 std::shared_ptr<Acts::SolenoidBField>>(
m,
"SolenoidBField")
77 .def(py::init<Config>())
80 return Acts::SolenoidBField{
83 py::arg(
"radius"), py::arg(
"length"), py::arg(
"nCoils"),
84 py::arg(
"bMagCenter"));
86 py::class_<Config>(sol,
"Config")
88 .def_readwrite(
"radius", &Config::radius)
95 "MagneticFieldMapXyz",
97 double lengthUnit,
double BFieldUnit,
bool firstOctant) {
100 auto mapBins = [](std::array<size_t, 3>
bins,
101 std::array<size_t, 3> sizes) {
102 return (bins[0] * (sizes[1] * sizes[2]) + bins[1] * sizes[2] +
106 if (file.extension() ==
".root") {
110 return std::make_shared<
111 ActsExamples::detail::InterpolatedMagneticField3>(
std::move(map));
112 }
else if (file.extension() ==
".txt") {
116 return std::make_shared<
117 ActsExamples::detail::InterpolatedMagneticField3>(
std::move(map));
119 throw std::runtime_error(
"Unsupported magnetic field map file type");
122 py::arg(
"file"), py::arg(
"tree") =
"bField",
125 py::arg(
"firstOctant") =
false);
128 "MagneticFieldMapRz",
130 double lengthUnit,
double BFieldUnit,
bool firstQuadrant) {
133 auto mapBins = [](std::array<size_t, 2>
bins,
134 std::array<size_t, 2> sizes) {
135 return (bins[1] * sizes[0] + bins[0]);
138 if (file.extension() ==
".root") {
142 return std::make_shared<
143 ActsExamples::detail::InterpolatedMagneticField2>(
std::move(map));
144 }
else if (file.extension() ==
".txt") {
148 return std::make_shared<
149 ActsExamples::detail::InterpolatedMagneticField2>(
std::move(map));
151 throw std::runtime_error(
"Unsupported magnetic field map file type");
154 py::arg(
"file"), py::arg(
"tree") =
"bField",
157 py::arg(
"firstQuadrant") =
false);