Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-13 08:18:25

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/ActsVersion.hpp"
0010 #include "ActsPython/Utilities/Helpers.hpp"
0011 
0012 #include <pybind11/pybind11.h>
0013 
0014 namespace py = pybind11;
0015 
0016 /// This adds the core module entries to the Python module
0017 /// There is a certain order necessary as py::class_ definitions
0018 /// need to be registered before they can be used in other modules.
0019 namespace ActsPython {
0020 
0021 void addDefinitions(py::module_& m);
0022 void addMagneticField(py::module_& m);
0023 void addUtilities(py::module_& m);
0024 void addVisualization(py::module_& m);
0025 
0026 void addMaterial(py::module_& m);
0027 void addSurfaces(py::module_& m);
0028 void addGeometry(py::module_& m);
0029 void addGeometryGen1(py::module_& m);
0030 void addGeometryGen2(py::module_& m);
0031 void addGeometryGen3(py::module_& m);
0032 void addNavigation(py::module_& m);
0033 void addPropagation(py::module_& m);
0034 void addSeeding(py::module_& mt);
0035 void addTrackFinding(py::module_& m);
0036 
0037 /// Legacy python modules
0038 void addModuleEntry(Context& ctx);
0039 
0040 }  // namespace ActsPython
0041 
0042 namespace py = pybind11;
0043 
0044 PYBIND11_MODULE(ActsPythonBindings, m) {
0045   using namespace ActsPython;
0046 
0047   m.doc() = "Acts";
0048   m.attr("__version__") =
0049       std::tuple{Acts::VersionMajor, Acts::VersionMinor, Acts::VersionPatch};
0050 
0051   {
0052     auto mv = m.def_submodule("version");
0053 
0054     mv.attr("major") = Acts::VersionMajor;
0055     mv.attr("minor") = Acts::VersionMinor;
0056     mv.attr("patch") = Acts::VersionPatch;
0057 
0058     mv.attr("commit_hash") = std::string{Acts::CommitHash.value_or("UNKNOWN")};
0059     mv.attr("commit_hash_short") =
0060         std::string{Acts::CommitHashShort.value_or("UNKNOWN")};
0061   }
0062 
0063   addDefinitions(m);
0064   addMagneticField(m);
0065   addMaterial(m);
0066   addUtilities(m);
0067   addVisualization(m);
0068 
0069   addSurfaces(m);
0070   addGeometry(m);
0071   addGeometryGen1(m);
0072   addGeometryGen2(m);
0073   addGeometryGen3(m);
0074   addNavigation(m);
0075   addPropagation(m);
0076   addSeeding(m);
0077   addTrackFinding(m);
0078 
0079   // Legacy python modules
0080   Context ctx;
0081   ctx.modules["main"] = m;
0082   auto mex = m.def_submodule("_examples");
0083   ctx.modules["examples"] = mex;
0084   auto prop = m.def_submodule("_propagator");
0085   ctx.modules["propagation"] = prop;
0086 
0087   addModuleEntry(ctx);
0088 }