File indexing completed on 2025-01-18 09:12:04
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Definitions/Direction.hpp"
0010 #include "Acts/EventData/TrackParameters.hpp"
0011 #include "Acts/Navigation/DetectorNavigator.hpp"
0012 #include "Acts/Plugins/Python/Utilities.hpp"
0013 #include "Acts/Propagator/AtlasStepper.hpp"
0014 #include "Acts/Propagator/EigenStepper.hpp"
0015 #include "Acts/Propagator/Navigator.hpp"
0016 #include "Acts/Propagator/Propagator.hpp"
0017 #include "Acts/Propagator/StraightLineStepper.hpp"
0018 #include "Acts/Propagator/SympyStepper.hpp"
0019 #include "Acts/Utilities/Logger.hpp"
0020 #include "ActsExamples/Propagation/PropagationAlgorithm.hpp"
0021 #include "ActsExamples/Propagation/PropagatorInterface.hpp"
0022
0023 #include <algorithm>
0024 #include <array>
0025 #include <map>
0026 #include <memory>
0027 #include <optional>
0028 #include <string>
0029 #include <tuple>
0030 #include <utility>
0031 #include <vector>
0032
0033 #include <pybind11/pybind11.h>
0034 #include <pybind11/stl.h>
0035
0036 namespace Acts {
0037 class MagneticFieldProvider;
0038 }
0039
0040 namespace py = pybind11;
0041
0042 namespace {
0043
0044 template <typename stepper_t, typename navigator_t>
0045 void addPropagator(py::module_& m, const std::string& prefix) {
0046 using propagator_t = Acts::Propagator<stepper_t, navigator_t>;
0047 py::class_<propagator_t>(m, (prefix + "Propagator").c_str())
0048 .def(py::init<>(
0049 [=](stepper_t stepper, navigator_t navigator,
0050 Acts::Logging::Level level = Acts::Logging::Level::INFO) {
0051 return propagator_t{
0052 std::move(stepper), std::move(navigator),
0053 Acts::getDefaultLogger(prefix + "Propagator", level)};
0054 }),
0055 py::arg("stepper"), py::arg("navigator"),
0056 py::arg("level") = Acts::Logging::INFO);
0057
0058 using prop_if_t = ActsExamples::ConcretePropagator<propagator_t>;
0059 py::class_<prop_if_t, ActsExamples::PropagatorInterface,
0060 std::shared_ptr<prop_if_t>>(
0061 m, (prefix + "ConcretePropagator").c_str())
0062 .def(py::init<propagator_t>());
0063 }
0064
0065 }
0066
0067 namespace Acts::Python {
0068 void addPropagation(Context& ctx) {
0069 auto [m, prop, mex] = ctx.get("main", "propagation", "examples");
0070
0071 {
0072 using Config = Acts::Navigator::Config;
0073 auto nav =
0074 py::class_<Acts::Navigator, std::shared_ptr<Acts::Navigator>>(
0075 m, "Navigator")
0076 .def(py::init<>([](Config cfg,
0077 Logging::Level level = Logging::INFO) {
0078 return Navigator{cfg, getDefaultLogger("Navigator", level)};
0079 }),
0080 py::arg("cfg"), py::arg("level") = Logging::INFO);
0081
0082 auto c = py::class_<Config>(nav, "Config").def(py::init<>());
0083
0084 ACTS_PYTHON_STRUCT_BEGIN(c, Config);
0085 ACTS_PYTHON_MEMBER(resolveMaterial);
0086 ACTS_PYTHON_MEMBER(resolvePassive);
0087 ACTS_PYTHON_MEMBER(resolveSensitive);
0088 ACTS_PYTHON_MEMBER(trackingGeometry);
0089 ACTS_PYTHON_STRUCT_END();
0090 }
0091
0092 {
0093 using Config = Acts::Experimental::DetectorNavigator::Config;
0094 auto nav =
0095 py::class_<Acts::Experimental::DetectorNavigator,
0096 std::shared_ptr<Acts::Experimental::DetectorNavigator>>(
0097 m, "DetectorNavigator")
0098 .def(py::init<>(
0099 [](Config cfg, Logging::Level level = Logging::INFO) {
0100 return Acts::Experimental::DetectorNavigator{
0101 cfg, getDefaultLogger("DetectorNavigator", level)};
0102 }),
0103 py::arg("cfg"), py::arg("level") = Logging::INFO);
0104
0105 auto c = py::class_<Config>(nav, "Config").def(py::init<>());
0106
0107 ACTS_PYTHON_STRUCT_BEGIN(c, Config);
0108 ACTS_PYTHON_MEMBER(resolveMaterial);
0109 ACTS_PYTHON_MEMBER(resolvePassive);
0110 ACTS_PYTHON_MEMBER(resolveSensitive);
0111 ACTS_PYTHON_MEMBER(detector);
0112 ACTS_PYTHON_STRUCT_END();
0113 }
0114
0115 ACTS_PYTHON_DECLARE_ALGORITHM(
0116 ActsExamples::PropagationAlgorithm, mex, "PropagationAlgorithm",
0117 propagatorImpl, sterileLogger, debugOutput, energyLoss,
0118 multipleScattering, recordMaterialInteractions, ptLoopers, maxStepSize,
0119 covarianceTransport, inputTrackParameters, outputSummaryCollection,
0120 outputMaterialCollection);
0121
0122 py::class_<ActsExamples::PropagatorInterface,
0123 std::shared_ptr<ActsExamples::PropagatorInterface>>(
0124 mex, "PropagatorInterface");
0125
0126
0127 {
0128 auto stepper = py::class_<Acts::EigenStepper<>>(m, "EigenStepper");
0129 stepper.def(py::init<std::shared_ptr<const Acts::MagneticFieldProvider>>());
0130
0131 addPropagator<Acts::EigenStepper<>, Acts::Navigator>(prop, "Eigen");
0132 }
0133
0134 {
0135 addPropagator<Acts::EigenStepper<>, Acts::Experimental::DetectorNavigator>(
0136 prop, "EigenDetector");
0137 }
0138
0139
0140 {
0141 auto stepper = py::class_<Acts::AtlasStepper>(m, "AtlasStepper");
0142 stepper.def(py::init<std::shared_ptr<const Acts::MagneticFieldProvider>>());
0143
0144 addPropagator<Acts::AtlasStepper, Acts::Navigator>(prop, "Atlas");
0145 }
0146
0147 {
0148 addPropagator<Acts::AtlasStepper, Acts::Experimental::DetectorNavigator>(
0149 prop, "AtlasDetector");
0150 }
0151
0152
0153 {
0154 auto stepper = py::class_<Acts::SympyStepper>(m, "SympyStepper");
0155 stepper.def(py::init<std::shared_ptr<const Acts::MagneticFieldProvider>>());
0156
0157 addPropagator<Acts::SympyStepper, Acts::Navigator>(prop, "Sympy");
0158 }
0159
0160 {
0161 addPropagator<Acts::SympyStepper, Acts::Experimental::DetectorNavigator>(
0162 prop, "SympyDetector");
0163 }
0164
0165
0166 {
0167 auto stepper =
0168 py::class_<Acts::StraightLineStepper>(m, "StraightLineStepper");
0169 stepper.def(py::init<>());
0170
0171 addPropagator<Acts::StraightLineStepper, Acts::Navigator>(prop,
0172 "StraightLine");
0173 }
0174
0175 {
0176 addPropagator<Acts::StraightLineStepper,
0177 Acts::Experimental::DetectorNavigator>(
0178 prop, "StraightLineDetector");
0179 }
0180 }
0181
0182 }