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/Python/Utilities.hpp"
0010 #include "Acts/Utilities/Logger.hpp"
0011 #include "ActsExamples/Digitization/DigitizationAlgorithm.hpp"
0012 #include "ActsExamples/Digitization/DigitizationConfig.hpp"
0013 #include "ActsExamples/Digitization/DigitizationConfigurator.hpp"
0014 #include "ActsExamples/Digitization/DigitizationCoordinatesConverter.hpp"
0015 #include "ActsExamples/Io/Json/JsonDigitizationConfig.hpp"
0016 
0017 #include <array>
0018 #include <memory>
0019 #include <tuple>
0020 #include <utility>
0021 
0022 #include <pybind11/pybind11.h>
0023 #include <pybind11/stl.h>
0024 
0025 namespace py = pybind11;
0026 
0027 using namespace ActsExamples;
0028 using namespace Acts;
0029 
0030 namespace Acts::Python {
0031 
0032 void addDigitization(Context& ctx) {
0033   auto [m, mex] = ctx.get("main", "examples");
0034 
0035   mex.def("readDigiConfigFromJson", ActsExamples::readDigiConfigFromJson);
0036   mex.def("writeDigiConfigToJson", ActsExamples::writeDigiConfigToJson);
0037 
0038   {
0039     using Config = ActsExamples::DigitizationAlgorithm::Config;
0040 
0041     auto a = py::class_<ActsExamples::DigitizationAlgorithm,
0042                         ActsExamples::IAlgorithm,
0043                         std::shared_ptr<ActsExamples::DigitizationAlgorithm>>(
0044                  mex, "DigitizationAlgorithm")
0045                  .def(py::init<Config&, Acts::Logging::Level>(),
0046                       py::arg("config"), py::arg("level"))
0047                  .def_property_readonly(
0048                      "config", &ActsExamples::DigitizationAlgorithm::config);
0049 
0050     auto c = py::class_<Config>(a, "Config").def(py::init<>());
0051 
0052     ACTS_PYTHON_STRUCT_BEGIN(c, Config);
0053     ACTS_PYTHON_MEMBER(inputSimHits);
0054     ACTS_PYTHON_MEMBER(outputMeasurements);
0055     ACTS_PYTHON_MEMBER(outputClusters);
0056     ACTS_PYTHON_MEMBER(outputMeasurementParticlesMap);
0057     ACTS_PYTHON_MEMBER(outputMeasurementSimHitsMap);
0058     ACTS_PYTHON_MEMBER(outputParticleMeasurementsMap);
0059     ACTS_PYTHON_MEMBER(outputSimHitMeasurementsMap);
0060     ACTS_PYTHON_MEMBER(surfaceByIdentifier);
0061     ACTS_PYTHON_MEMBER(randomNumbers);
0062     ACTS_PYTHON_MEMBER(doOutputCells);
0063     ACTS_PYTHON_MEMBER(doClusterization);
0064     ACTS_PYTHON_MEMBER(doMerge);
0065     ACTS_PYTHON_MEMBER(minEnergyDeposit);
0066     ACTS_PYTHON_MEMBER(digitizationConfigs);
0067     ACTS_PYTHON_STRUCT_END();
0068 
0069     c.def_readonly("mergeNsigma", &Config::mergeNsigma);
0070     c.def_readonly("mergeCommonCorner", &Config::mergeCommonCorner);
0071 
0072     patchKwargsConstructor(c);
0073 
0074     auto cc = py::class_<DigiComponentsConfig>(mex, "DigiComponentsConfig")
0075                   .def(py::init<>());
0076 
0077     ACTS_PYTHON_STRUCT_BEGIN(cc, DigiComponentsConfig);
0078     ACTS_PYTHON_MEMBER(geometricDigiConfig);
0079     ACTS_PYTHON_MEMBER(smearingDigiConfig);
0080     ACTS_PYTHON_STRUCT_END();
0081 
0082     py::class_<DigiConfigContainer>(mex, "DigiConfigContainer")
0083         .def(py::init<std::vector<
0084                  std::pair<GeometryIdentifier, DigiComponentsConfig>>>());
0085   }
0086 
0087   {
0088     using DC = DigitizationConfigurator;
0089     auto dc = py::class_<DC>(mex, "DigitizationConfigurator").def(py::init<>());
0090 
0091     dc.def("__call__", &DC::operator());
0092 
0093     ACTS_PYTHON_STRUCT_BEGIN(dc, DC);
0094     ACTS_PYTHON_MEMBER(inputDigiComponents);
0095     ACTS_PYTHON_MEMBER(compactify);
0096     ACTS_PYTHON_MEMBER(volumeLayerComponents);
0097     ACTS_PYTHON_MEMBER(outputDigiComponents);
0098     ACTS_PYTHON_STRUCT_END();
0099   }
0100 
0101   {
0102     py::class_<ActsExamples::DigitizationCoordinatesConverter,
0103                std::shared_ptr<ActsExamples::DigitizationCoordinatesConverter>>(
0104         mex, "DigitizationCoordinatesConverter")
0105         .def(py::init<ActsExamples::DigitizationAlgorithm::Config&>(),
0106              py::arg("config"))
0107         .def_property_readonly(
0108             "config", &ActsExamples::DigitizationCoordinatesConverter::config)
0109         .def("globalToLocal",
0110              &ActsExamples::DigitizationCoordinatesConverter::globalToLocal)
0111         .def("localToGlobal",
0112              &ActsExamples::DigitizationCoordinatesConverter::localToGlobal);
0113   }
0114 }
0115 
0116 }  // namespace Acts::Python