Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Digitization.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Digitization.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2021 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
20 
21 #include <array>
22 #include <memory>
23 #include <tuple>
24 #include <utility>
25 #include <vector>
26 
27 #include <pybind11/pybind11.h>
28 #include <pybind11/stl.h>
29 
30 namespace Acts {
31 class GeometryIdentifier;
32 } // namespace Acts
33 namespace ActsExamples {
34 class IAlgorithm;
35 } // namespace ActsExamples
36 
37 namespace py = pybind11;
38 
39 using namespace ActsExamples;
40 using namespace Acts;
41 
42 namespace Acts::Python {
43 
45  auto [m, mex] = ctx.get("main", "examples");
46 
47  mex.def("readDigiConfigFromJson", ActsExamples::readDigiConfigFromJson);
48  mex.def("writeDigiConfigToJson", ActsExamples::writeDigiConfigToJson);
49 
50  {
52 
54  std::shared_ptr<ActsExamples::DigitizationAlgorithm>>(
55  mex, "DigitizationAlgorithm")
56  .def(py::init<Config&, Acts::Logging::Level>(), py::arg("config"),
57  py::arg("level"))
58  .def_property_readonly("config",
60 
61  auto c = py::class_<Config>(mex, "DigitizationConfig")
64 
66  ACTS_PYTHON_MEMBER(inputSimHits);
67  ACTS_PYTHON_MEMBER(outputSourceLinks);
68  ACTS_PYTHON_MEMBER(outputMeasurements);
69  ACTS_PYTHON_MEMBER(outputClusters);
70  ACTS_PYTHON_MEMBER(outputMeasurementParticlesMap);
71  ACTS_PYTHON_MEMBER(outputMeasurementSimHitsMap);
74  ACTS_PYTHON_MEMBER(doMerge);
75  ACTS_PYTHON_MEMBER(minEnergyDeposit);
76  ACTS_PYTHON_MEMBER(digitizationConfigs);
78 
79  c.def_readonly("mergeNsigma", &Config::mergeNsigma);
80  c.def_readonly("mergeCommonCorner", &Config::mergeCommonCorner);
81 
83 
84  py::class_<DigiComponentsConfig>(mex, "DigiComponentsConfig");
85 
86  py::class_<Acts::GeometryHierarchyMap<ActsExamples::DigiComponentsConfig>>(
87  mex, "GeometryHierarchyMap_DigiComponentsConfig")
88  .def(py::init<std::vector<
89  std::pair<GeometryIdentifier, DigiComponentsConfig>>>());
90  }
91 
92  {
94 
95  auto alg = py::class_<Alg, ActsExamples::IAlgorithm, std::shared_ptr<Alg>>(
96  mex, "PlanarSteppingAlgorithm")
97  .def(py::init<const Alg::Config&, Acts::Logging::Level>(),
98  py::arg("config"), py::arg("level"))
99  .def_property_readonly("config", &Alg::config);
100 
101  auto c = py::class_<Alg::Config>(alg, "Config").def(py::init<>());
102 
104  ACTS_PYTHON_MEMBER(inputSimHits);
105  ACTS_PYTHON_MEMBER(outputClusters);
106  ACTS_PYTHON_MEMBER(outputSourceLinks);
107  ACTS_PYTHON_MEMBER(outputDigiSourceLinks);
108  ACTS_PYTHON_MEMBER(outputMeasurements);
109  ACTS_PYTHON_MEMBER(outputMeasurementParticlesMap);
110  ACTS_PYTHON_MEMBER(outputMeasurementSimHitsMap);
112  ACTS_PYTHON_MEMBER(planarModuleStepper);
115  }
116 
117  {
118  py::class_<PlanarModuleStepper, std::shared_ptr<PlanarModuleStepper>>(
119  m, "PlanarModuleStepper")
120  .def(py::init<>())
121  .def(py::init([](Logging::Level level) {
122  return std::make_shared<PlanarModuleStepper>(
123  getDefaultLogger("PlanarModuleStepper", level));
124  }));
125  }
126 
127  {
128  using DC = DigitizationConfigurator;
129  auto dc = py::class_<DC>(mex, "DigitizationConfigurator").def(py::init<>());
130 
131  dc.def("__call__", &DC::operator());
132 
133  ACTS_PYTHON_STRUCT_BEGIN(dc, DC);
134  ACTS_PYTHON_MEMBER(inputDigiComponents);
135  ACTS_PYTHON_MEMBER(compactify);
136  ACTS_PYTHON_MEMBER(volumeLayerComponents);
137  ACTS_PYTHON_MEMBER(outputDigiComponents);
139  }
140 }
141 
142 } // namespace Acts::Python