Back to home page

EIC code displayed by LXR

 
 

    


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

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/Geometry/CylinderVolumeHelper.hpp"
0010 #include "Acts/Geometry/Layer.hpp"
0011 #include "Acts/Geometry/LayerArrayCreator.hpp"
0012 #include "Acts/Geometry/LayerCreator.hpp"
0013 #include "Acts/Geometry/SurfaceArrayCreator.hpp"
0014 #include "Acts/Geometry/TrackingVolume.hpp"
0015 #include "Acts/Geometry/TrackingVolumeArrayCreator.hpp"
0016 #include "Acts/Geometry/VolumeBounds.hpp"
0017 #include "ActsPython/Utilities/Helpers.hpp"
0018 #include "ActsPython/Utilities/Macros.hpp"
0019 
0020 #include <memory>
0021 #include <vector>
0022 
0023 #include <pybind11/pybind11.h>
0024 #include <pybind11/stl.h>
0025 
0026 namespace py = pybind11;
0027 using namespace pybind11::literals;
0028 using namespace Acts;
0029 
0030 namespace ActsPython {
0031 
0032 /// This adds the geometry building bindings for the Gen1 geometry
0033 /// @param m the module to add the bindings to
0034 void addGeometryGen1(py::module_ &m) {
0035   using SurfacePtrVector = std::vector<std::shared_ptr<const Surface>>;
0036 
0037   py::class_<Layer, std::shared_ptr<Layer>>(m, "Layer");
0038 
0039   {
0040     auto creator =
0041         py::class_<LayerCreator>(m, "LayerCreator")
0042             .def(py::init([](const LayerCreator::Config &cfg,
0043                              Logging::Level level) {
0044               return LayerCreator(cfg, getDefaultLogger("LayerCreator", level));
0045             }))
0046             .def(
0047                 "cylinderLayer",
0048                 [](const LayerCreator &self, const GeometryContext &gctx,
0049                    SurfacePtrVector surfaces, std::size_t binsPhi,
0050                    std::size_t binsZ) {
0051                   return self.cylinderLayer(gctx, std::move(surfaces), binsPhi,
0052                                             binsZ);
0053                 },
0054                 "gctx"_a, "surfaces"_a, "binsPhi"_a, "binsZ"_a)
0055             .def(
0056                 "discLayer",
0057                 [](const LayerCreator &self, const GeometryContext &gctx,
0058                    SurfacePtrVector surfaces, std::size_t binsR,
0059                    std::size_t binsPhi) {
0060                   return self.discLayer(gctx, std::move(surfaces), binsR,
0061                                         binsPhi);
0062                 },
0063                 "gctx"_a, "surfaces"_a, "binsR"_a, "binsPhi"_a);
0064 
0065     auto config =
0066         py::class_<LayerCreator::Config>(creator, "Config").def(py::init<>());
0067 
0068     ACTS_PYTHON_STRUCT(config, surfaceArrayCreator, cylinderZtolerance,
0069                        cylinderPhiTolerance, defaultEnvelopeR,
0070                        defaultEnvelopeZ);
0071   }
0072 
0073   {
0074     using Creator = SurfaceArrayCreator;
0075     using Config = typename Creator::Config;
0076 
0077     auto creator =
0078         py::class_<Creator, std::shared_ptr<Creator>>(m, "SurfaceArrayCreator")
0079             .def(py::init<Config>());
0080 
0081     py::class_<Config>(creator, "Config").def(py::init<>());
0082   }
0083 
0084   {
0085     using Base = ILayerArrayCreator;
0086     using Creator = LayerArrayCreator;
0087     using Config = typename Creator::Config;
0088 
0089     py::class_<Base, std::shared_ptr<Base>>(m, "ILayerArrayCreator");
0090 
0091     auto creator = py::class_<Creator, std::shared_ptr<Creator>, Base>(
0092                        m, "LayerArrayCreator")
0093                        .def(py::init<Config>());
0094 
0095     py::class_<Config>(creator, "Config").def(py::init<>());
0096   }
0097 
0098   {
0099     using Base = ITrackingVolumeArrayCreator;
0100     using Creator = TrackingVolumeArrayCreator;
0101     using Config = typename Creator::Config;
0102 
0103     py::class_<Base, std::shared_ptr<Base>>(m, "ITrackingVolumeArrayCreator");
0104 
0105     auto creator = py::class_<Creator, std::shared_ptr<Creator>, Base>(
0106                        m, "TrackingVolumeArrayCreator")
0107                        .def(py::init<Config>());
0108 
0109     py::class_<Config>(creator, "Config").def(py::init<>());
0110   }
0111 
0112   {
0113     auto helper =
0114         py::class_<CylinderVolumeHelper>(m, "CylinderVolumeHelper")
0115             .def(py::init([](const CylinderVolumeHelper::Config &cfg,
0116                              Logging::Level level) {
0117               return CylinderVolumeHelper(
0118                   cfg, getDefaultLogger("CylinderVolumeHelper", level));
0119             }))
0120             .def("createTrackingVolume",
0121                  [](const CylinderVolumeHelper &self, GeometryContext gctx,
0122                     const LayerVector &layers,
0123                     std::shared_ptr<VolumeBounds> volumeBounds,
0124                     const Transform3 &trafo, const std::string &name) {
0125                    return self.createTrackingVolume(gctx, layers, {},
0126                                                     std::move(volumeBounds), {},
0127                                                     trafo, name);
0128                  })
0129             .def("createContainerTrackingVolume",
0130                  &CylinderVolumeHelper::createContainerTrackingVolume);
0131 
0132     auto config = py::class_<CylinderVolumeHelper::Config>(helper, "Config")
0133                       .def(py::init<>());
0134 
0135     ACTS_PYTHON_STRUCT(config, layerArrayCreator, trackingVolumeArrayCreator,
0136                        passiveLayerThickness, passiveLayerPhiBins,
0137                        passiveLayerRzBins);
0138   }
0139 }
0140 
0141 }  // namespace ActsPython