Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:04

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include "Acts/Plugins/Detray/DetrayConversionUtils.hpp"
0010 #include "Acts/Plugins/Detray/DetrayConverter.hpp"
0011 #include "Acts/Plugins/Python/Utilities.hpp"
0012 #include "ActsExamples/Propagation/PropagatorInterface.hpp"
0013 #include "ActsExamples/Traccc/DetrayPropagator.hpp"
0014 #include "ActsExamples/Traccc/DetrayStore.hpp"
0015 
0016 #include <detray/propagator/line_stepper.hpp>
0017 #include <pybind11/pybind11.h>
0018 #include <vecmem/memory/host_memory_resource.hpp>
0019 #include <vecmem/memory/memory_resource.hpp>
0020 
0021 namespace py = pybind11;
0022 using namespace pybind11::literals;
0023 
0024 using namespace Acts;
0025 using namespace ActsExamples;
0026 
0027 namespace Acts::Python {
0028 
0029 void addTraccc(Context& ctx) {
0030   auto [m, mex] = ctx.get("main", "examples");
0031 
0032   auto traccc = mex.def_submodule("traccc");
0033 
0034   /// Define host detray store
0035   {
0036     py::class_<DetrayHostStore, std::shared_ptr<DetrayHostStore>>(
0037         traccc, "DetrayHostStore");
0038 
0039     /// Convert the detector and create a DetrayHostStore
0040     ///
0041     /// @param gctx the geometry context
0042     /// @param detector the detector to be converted
0043     /// @param options the conversion options
0044     traccc.def("convertDetectorHost", [](const GeometryContext& gctx,
0045                                          const Experimental::Detector& detector,
0046                                          DetrayConverter::Options options) {
0047       return DetrayHostStore::create(gctx, detector, options);
0048     });
0049   }
0050 
0051   /// Define the DetrayPropagator
0052   {
0053     traccc.def(
0054         "createSlPropagatorHost",
0055         [](std::shared_ptr<const DetrayHostStore> detrayStore,
0056            bool sterile = false) {
0057           std::shared_ptr<PropagatorInterface> detrayProagator = nullptr;
0058 
0059           using DetrayLineStepper =
0060               detray::line_stepper<typename DetrayHostDetector::algebra_type>;
0061 
0062           using DetrayPropagator =
0063               DetrayPropagator<DetrayLineStepper, DetrayHostStore>;
0064 
0065           DetrayPropagator::Config cfg{detrayStore, sterile};
0066           detrayProagator = std::make_shared<DetrayPropagator>(cfg);
0067           return detrayProagator;
0068         });
0069   }
0070 }
0071 }  // namespace Acts::Python