File indexing completed on 2026-01-09 09:26:47
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/Propagation/PropagatorInterface.hpp"
0010 #include "ActsExamples/Traccc/DetrayPropagator.hpp"
0011 #include "ActsExamples/Traccc/DetrayStore.hpp"
0012 #include "ActsPlugins/Covfie/FieldConversion.hpp"
0013 #include "ActsPlugins/Detray/DetrayConversionUtils.hpp"
0014 #include "ActsPython/Utilities/Helpers.hpp"
0015
0016 #include <detray/core/detector.hpp>
0017 #include <detray/io/frontend/detector_reader.hpp>
0018 #include <detray/navigation/volume_graph.hpp>
0019 #include <detray/propagator/line_stepper.hpp>
0020 #include <detray/propagator/propagator.hpp>
0021 #include <detray/propagator/rk_stepper.hpp>
0022 #include <pybind11/pybind11.h>
0023 #include <vecmem/memory/host_memory_resource.hpp>
0024 #include <vecmem/memory/memory_resource.hpp>
0025
0026 namespace py = pybind11;
0027 using namespace pybind11::literals;
0028
0029 using namespace Acts;
0030 using namespace ActsExamples;
0031 using namespace ActsPlugins;
0032 using namespace ActsPython;
0033
0034 PYBIND11_MODULE(ActsExamplesPythonBindingsTraccc, traccc) {
0035
0036 {
0037 py::class_<DetrayHostStore, std::shared_ptr<DetrayHostStore>>(
0038 traccc, "DetrayHostStore");
0039
0040
0041
0042
0043
0044 traccc.def("readDetectorHost", [](const std::string& geometry,
0045 const std::string& materials,
0046 const std::string& grids) {
0047 auto mr = std::make_shared<vecmem::host_memory_resource>();
0048
0049 auto reader_cfg = detray::io::detector_reader_config{};
0050 reader_cfg.add_file(geometry);
0051 if (materials.empty() == false) {
0052 reader_cfg.add_file(materials);
0053 }
0054 if (grids.empty() == false) {
0055 reader_cfg.add_file(grids);
0056 }
0057
0058
0059 auto [det, names] =
0060 detray::io::read_detector<DetrayHostDetector>(*mr, reader_cfg);
0061 return DetrayHostStore{std::move(mr), std::move(det)};
0062 });
0063 }
0064
0065
0066 {
0067 traccc.def(
0068 "createSlPropagatorHost",
0069 [](std::shared_ptr<const DetrayHostStore> detrayStore,
0070 bool sterile = false) {
0071 std::shared_ptr<PropagatorInterface> detrayPropagator = nullptr;
0072
0073 using DetrayLineStepper =
0074 detray::line_stepper<typename DetrayHostDetector::algebra_type>;
0075
0076 using DetrayPropagator =
0077 DetrayPropagator<DetrayLineStepper, DetrayHostStore>;
0078
0079 DetrayPropagator::Config cfg{detrayStore, sterile};
0080 detrayPropagator = std::make_shared<DetrayPropagator>(cfg);
0081 return detrayPropagator;
0082 });
0083 }
0084
0085
0086 {
0087 traccc.def(
0088 "createConstBFieldPropagatorHost",
0089 [](std::shared_ptr<const DetrayHostStore> detrayStore,
0090 Covfie::ConstantField cfield, bool sterile = false) {
0091 std::shared_ptr<PropagatorInterface> detrayPropagator = nullptr;
0092
0093
0094 using DetrayRknStepper =
0095 detray::rk_stepper<Covfie::ConstantField::view_t,
0096 typename DetrayHostDetector::algebra_type>;
0097
0098 using DetrayPropagator =
0099 DetrayPropagator<DetrayRknStepper, DetrayHostStore,
0100 Covfie::ConstantField>;
0101
0102 DetrayPropagator::Config cfg{detrayStore, sterile, cfield};
0103 detrayPropagator = std::make_shared<DetrayPropagator>(cfg);
0104 return detrayPropagator;
0105 });
0106 }
0107
0108
0109 {
0110 traccc.def(
0111 "createInterpolatedBFieldPropagatorHost",
0112 [](std::shared_ptr<const DetrayHostStore> detrayStore,
0113 Covfie::InterpolatedField ifield, bool sterile = false) {
0114 std::shared_ptr<PropagatorInterface> detrayPropagator = nullptr;
0115
0116
0117 using DetrayRknStepper =
0118 detray::rk_stepper<Covfie::InterpolatedField::view_t,
0119 typename DetrayHostDetector::algebra_type>;
0120
0121 using DetrayPropagator =
0122 DetrayPropagator<DetrayRknStepper, DetrayHostStore,
0123 Covfie::InterpolatedField>;
0124
0125 DetrayPropagator::Config cfg{detrayStore, sterile, ifield};
0126 detrayPropagator = std::make_shared<DetrayPropagator>(cfg);
0127
0128 return detrayPropagator;
0129 });
0130 }
0131
0132 }