Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-29 07:54:48

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/Definitions/Direction.hpp"
0010 #include "Acts/EventData/TrackParameters.hpp"
0011 #include "Acts/Navigation/DetectorNavigator.hpp"
0012 #include "Acts/Propagator/AtlasStepper.hpp"
0013 #include "Acts/Propagator/EigenStepper.hpp"
0014 #include "Acts/Propagator/Navigator.hpp"
0015 #include "Acts/Propagator/Propagator.hpp"
0016 #include "Acts/Propagator/StraightLineStepper.hpp"
0017 #include "Acts/Propagator/SympyStepper.hpp"
0018 #include "Acts/Utilities/Logger.hpp"
0019 #include "ActsExamples/Propagation/PropagationAlgorithm.hpp"
0020 #include "ActsExamples/Propagation/PropagatorInterface.hpp"
0021 #include "ActsPython/Utilities/Helpers.hpp"
0022 #include "ActsPython/Utilities/Macros.hpp"
0023 
0024 #include <algorithm>
0025 #include <array>
0026 #include <map>
0027 #include <memory>
0028 #include <optional>
0029 #include <string>
0030 #include <tuple>
0031 #include <utility>
0032 #include <vector>
0033 
0034 #include <pybind11/pybind11.h>
0035 #include <pybind11/stl.h>
0036 
0037 namespace Acts {
0038 class MagneticFieldProvider;
0039 }  // namespace Acts
0040 
0041 namespace py = pybind11;
0042 using namespace Acts;
0043 using namespace ActsExamples;
0044 
0045 namespace {
0046 
0047 template <typename stepper_t, typename navigator_t>
0048 void addPropagator(py::module_& m, const std::string& prefix) {
0049   using propagator_t = Propagator<stepper_t, navigator_t>;
0050   py::class_<propagator_t>(m, (prefix + "Propagator").c_str())
0051       .def(py::init<>([=](stepper_t stepper, navigator_t navigator,
0052                           Logging::Level level = Logging::Level::INFO) {
0053              return propagator_t{
0054                  std::move(stepper), std::move(navigator),
0055                  getDefaultLogger(prefix + "Propagator", level)};
0056            }),
0057            py::arg("stepper"), py::arg("navigator"),
0058            py::arg("level") = Logging::INFO);
0059 
0060   using prop_if_t = ConcretePropagator<propagator_t>;
0061   py::class_<prop_if_t, PropagatorInterface, std::shared_ptr<prop_if_t>>(
0062       m, (prefix + "ConcretePropagator").c_str())
0063       .def(py::init<propagator_t>());
0064 }
0065 
0066 }  // namespace
0067 
0068 namespace ActsPython {
0069 void addPropagation(Context& ctx) {
0070   auto [prop, mex] = ctx.get("propagation", "examples");
0071 
0072   ACTS_PYTHON_DECLARE_ALGORITHM(
0073       PropagationAlgorithm, mex, "PropagationAlgorithm", propagatorImpl,
0074       sterileLogger, debugOutput, energyLoss, multipleScattering,
0075       recordMaterialInteractions, ptLoopers, maxStepSize, covarianceTransport,
0076       inputTrackParameters, outputSummaryCollection, outputMaterialCollection);
0077 
0078   py::class_<PropagatorInterface, std::shared_ptr<PropagatorInterface>>(
0079       mex, "PropagatorInterface");
0080 
0081   // Eigen stepper based propagator
0082   {
0083     addPropagator<EigenStepper<>, Navigator>(prop, "Eigen");
0084     addPropagator<EigenStepper<>, Experimental::DetectorNavigator>(
0085         prop, "EigenDetector");
0086   }
0087 
0088   // ATLAS stepper based propagator
0089   {
0090     addPropagator<AtlasStepper, Navigator>(prop, "Atlas");
0091     addPropagator<AtlasStepper, Experimental::DetectorNavigator>(
0092         prop, "AtlasDetector");
0093   }
0094 
0095   // Sympy stepper based propagator
0096   {
0097     addPropagator<SympyStepper, Navigator>(prop, "Sympy");
0098     addPropagator<SympyStepper, Experimental::DetectorNavigator>(
0099         prop, "SympyDetector");
0100   }
0101 
0102   // Straight line stepper
0103   {
0104     addPropagator<StraightLineStepper, Navigator>(prop, "StraightLine");
0105     addPropagator<StraightLineStepper, Experimental::DetectorNavigator>(
0106         prop, "StraightLineDetector");
0107   }
0108 }
0109 
0110 }  // namespace ActsPython