Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:21:36

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   py::class_<BoundarySurfaceT<TrackingVolume>>(
0040       m, "BoundarySurfaceT_TrackingVolume");
0041 
0042   {
0043     auto creator =
0044         py::class_<LayerCreator>(m, "LayerCreator")
0045             .def(py::init([](const LayerCreator::Config &cfg,
0046                              Logging::Level level) {
0047               return LayerCreator(cfg, getDefaultLogger("LayerCreator", level));
0048             }))
0049             .def(
0050                 "cylinderLayer",
0051                 [](const LayerCreator &self, const GeometryContext &gctx,
0052                    SurfacePtrVector surfaces, std::size_t binsPhi,
0053                    std::size_t binsZ) {
0054                   return self.cylinderLayer(gctx, std::move(surfaces), binsPhi,
0055                                             binsZ);
0056                 },
0057                 "gctx"_a, "surfaces"_a, "binsPhi"_a, "binsZ"_a)
0058             .def(
0059                 "discLayer",
0060                 [](const LayerCreator &self, const GeometryContext &gctx,
0061                    SurfacePtrVector surfaces, std::size_t binsR,
0062                    std::size_t binsPhi) {
0063                   return self.discLayer(gctx, std::move(surfaces), binsR,
0064                                         binsPhi);
0065                 },
0066                 "gctx"_a, "surfaces"_a, "binsR"_a, "binsPhi"_a);
0067 
0068     auto config =
0069         py::class_<LayerCreator::Config>(creator, "Config").def(py::init<>());
0070 
0071     ACTS_PYTHON_STRUCT(config, surfaceArrayCreator, cylinderZtolerance,
0072                        cylinderPhiTolerance, defaultEnvelopeR,
0073                        defaultEnvelopeZ);
0074   }
0075 
0076   {
0077     using Creator = SurfaceArrayCreator;
0078     using Config = typename Creator::Config;
0079 
0080     auto creator =
0081         py::class_<Creator, std::shared_ptr<Creator>>(m, "SurfaceArrayCreator")
0082             .def(py::init<Config>());
0083 
0084     py::class_<Config>(creator, "Config").def(py::init<>());
0085   }
0086 
0087   {
0088     using Base = ILayerArrayCreator;
0089     using Creator = LayerArrayCreator;
0090     using Config = typename Creator::Config;
0091 
0092     py::class_<Base, std::shared_ptr<Base>>(m, "ILayerArrayCreator");
0093 
0094     auto creator = py::class_<Creator, std::shared_ptr<Creator>, Base>(
0095                        m, "LayerArrayCreator")
0096                        .def(py::init<Config>());
0097 
0098     py::class_<Config>(creator, "Config").def(py::init<>());
0099   }
0100 
0101   {
0102     using Base = ITrackingVolumeArrayCreator;
0103     using Creator = TrackingVolumeArrayCreator;
0104     using Config = typename Creator::Config;
0105 
0106     py::class_<Base, std::shared_ptr<Base>>(m, "ITrackingVolumeArrayCreator");
0107 
0108     auto creator = py::class_<Creator, std::shared_ptr<Creator>, Base>(
0109                        m, "TrackingVolumeArrayCreator")
0110                        .def(py::init<Config>());
0111 
0112     py::class_<Config>(creator, "Config").def(py::init<>());
0113   }
0114 
0115   {
0116     auto helper =
0117         py::class_<CylinderVolumeHelper>(m, "CylinderVolumeHelper")
0118             .def(py::init([](const CylinderVolumeHelper::Config &cfg,
0119                              Logging::Level level) {
0120               return CylinderVolumeHelper(
0121                   cfg, getDefaultLogger("CylinderVolumeHelper", level));
0122             }))
0123             .def("createTrackingVolume",
0124                  [](const CylinderVolumeHelper &self, GeometryContext gctx,
0125                     const LayerVector &layers,
0126                     std::shared_ptr<VolumeBounds> volumeBounds,
0127                     const Transform3 &trafo, const std::string &name) {
0128                    return self.createTrackingVolume(gctx, layers, {},
0129                                                     std::move(volumeBounds), {},
0130                                                     trafo, name);
0131                  })
0132             .def("createContainerTrackingVolume",
0133                  &CylinderVolumeHelper::createContainerTrackingVolume);
0134 
0135     auto config = py::class_<CylinderVolumeHelper::Config>(helper, "Config")
0136                       .def(py::init<>());
0137 
0138     ACTS_PYTHON_STRUCT(config, layerArrayCreator, trackingVolumeArrayCreator,
0139                        passiveLayerThickness, passiveLayerPhiBins,
0140                        passiveLayerRzBins);
0141   }
0142 }
0143 
0144 }  // namespace ActsPython