Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /acts/Python/Plugins/src/Covfie.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 "ActsPlugins/Covfie/FieldConversion.hpp"
0010 #include "ActsPython/Utilities/Helpers.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 {
0021 template <typename field_t, typename scalar_type>
0022 void declareCovfieField(py::module& m, const std::string& fieldName) {
0023   using view_t = typename field_t::view_t;
0024   m.def("toView",
0025         [](const field_t& field) { return typename field_t::view_t(field); });
0026   py::class_<field_t, std::shared_ptr<field_t>>(m, fieldName.c_str());
0027   py::class_<view_t, std::shared_ptr<view_t>>(
0028       m, (fieldName + std::string("View")).c_str())
0029       .def("at", &view_t::template at<scalar_type, scalar_type, scalar_type>);
0030 }
0031 }  // namespace
0032 
0033 PYBIND11_MODULE(ActsPluginsPythonBindingsCovfie, covfie) {
0034   using namespace Acts;
0035   using namespace ActsPython;
0036   using namespace ActsPlugins;
0037 
0038   py::class_<covfie::array::array<float, 3ul>,
0039              std::shared_ptr<covfie::array::array<float, 3ul>>>(covfie,
0040                                                                 "ArrayFloat3")
0041       .def("at", [](const covfie::array::array<float, 3ul>& self,
0042                     std::size_t i) { return self[i]; });
0043 
0044   declareCovfieField<Covfie::ConstantField, float>(covfie,
0045                                                    "CovfieConstantField");
0046   declareCovfieField<Covfie::InterpolatedField, float>(
0047       covfie, "CovfieAffineLinearStridedField");
0048 
0049   covfie.def("makeCovfieField",
0050              py::overload_cast<const InterpolatedMagneticField&>(
0051                  &Covfie::covfieField));
0052   covfie.def("makeCovfieField",
0053              py::overload_cast<const ConstantBField&>(&Covfie::covfieField));
0054   covfie.def(
0055       "makeCovfieField",
0056       py::overload_cast<
0057           const MagneticFieldProvider&, MagneticFieldProvider::Cache&,
0058           const std::array<std::size_t, 3>&, const Vector3&, const Vector3&>(
0059           &Covfie::covfieField));
0060 }