Back to home page

EIC code displayed by LXR

 
 

    


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

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/Covfie/FieldConversion.hpp"
0010 #include "Acts/Plugins/Python/Utilities.hpp"
0011 
0012 #include <string>
0013 
0014 #include <pybind11/pybind11.h>
0015 #include <pybind11/stl.h>
0016 
0017 namespace py = pybind11;
0018 using namespace pybind11::literals;
0019 
0020 namespace Acts::Python {
0021 
0022 namespace {
0023 template <typename field_t>
0024 void declareCovfieField(py::module& m, const std::string& fieldName) {
0025   using view_t = typename field_t::view_t;
0026   m.def("toView",
0027         [](const field_t& field) { return typename field_t::view_t(field); });
0028   py::class_<field_t, std::shared_ptr<field_t>>(m, fieldName.c_str());
0029   py::class_<view_t, std::shared_ptr<view_t>>(
0030       m, (fieldName + std::string("View")).c_str())
0031       .def("at", &view_t::template at<float, float, float>);
0032 }
0033 }  // namespace
0034 
0035 void addCovfie(Context& ctx) {
0036   auto main = ctx.get("main");
0037   auto m = main.def_submodule("covfie", "Submodule for covfie conversion");
0038 
0039   declareCovfieField<Acts::CovfiePlugin::ConstantField>(m,
0040                                                         "CovfieConstantField");
0041   declareCovfieField<Acts::CovfiePlugin::InterpolatedField>(
0042       m, "CovfieAffineLinearStridedField");
0043 
0044   m.def("makeCovfieField",
0045         py::overload_cast<const Acts::InterpolatedMagneticField&>(
0046             &Acts::CovfiePlugin::covfieField));
0047   m.def("makeCovfieField", py::overload_cast<const Acts::ConstantBField&>(
0048                                &Acts::CovfiePlugin::covfieField));
0049   m.def("makeCovfieField",
0050         py::overload_cast<const Acts::MagneticFieldProvider&,
0051                           Acts::MagneticFieldProvider::Cache&,
0052                           const std::array<std::size_t, 3>&,
0053                           const Acts::Vector3&, const Acts::Vector3&>(
0054             &Acts::CovfiePlugin::covfieField));
0055 }
0056 
0057 }  // namespace Acts::Python