Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Material.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Material.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 <map>
23 #include <memory>
24 #include <tuple>
25 #include <utility>
26 #include <vector>
27 
28 #include <pybind11/pybind11.h>
29 #include <pybind11/stl.h>
30 
31 namespace Acts {
32 class TrackingGeometry;
33 } // namespace Acts
34 namespace ActsExamples {
35 class IAlgorithm;
36 } // namespace ActsExamples
37 
38 namespace py = pybind11;
39 using namespace pybind11::literals;
40 
41 using namespace ActsExamples;
42 
43 namespace Acts::Python {
44 void addMaterial(Context& ctx) {
45  auto [m, mex] = ctx.get("main", "examples");
46  {
47  py::class_<Acts::IMaterialDecorator,
48  std::shared_ptr<Acts::IMaterialDecorator>>(m,
49  "IMaterialDecorator");
50  }
51 
52  {
53  auto rmd =
55  std::shared_ptr<RootMaterialDecorator>>(
56  mex, "RootMaterialDecorator")
57  .def(
58  py::init<RootMaterialDecorator::Config, Acts::Logging::Level>(),
59  py::arg("config"), py::arg("level"));
60 
62  auto c = py::class_<Config>(rmd, "Config").def(py::init<>());
63 
64  ACTS_PYTHON_STRUCT_BEGIN(c, Config);
65  ACTS_PYTHON_MEMBER(voltag);
66  ACTS_PYTHON_MEMBER(boutag);
67  ACTS_PYTHON_MEMBER(laytag);
68  ACTS_PYTHON_MEMBER(apptag);
69  ACTS_PYTHON_MEMBER(sentag);
70  ACTS_PYTHON_MEMBER(ntag);
71  ACTS_PYTHON_MEMBER(vtag);
72  ACTS_PYTHON_MEMBER(otag);
73  ACTS_PYTHON_MEMBER(mintag);
74  ACTS_PYTHON_MEMBER(maxtag);
75  ACTS_PYTHON_MEMBER(ttag);
76  ACTS_PYTHON_MEMBER(x0tag);
77  ACTS_PYTHON_MEMBER(l0tag);
78  ACTS_PYTHON_MEMBER(atag);
79  ACTS_PYTHON_MEMBER(ztag);
80  ACTS_PYTHON_MEMBER(rhotag);
81  ACTS_PYTHON_MEMBER(fileName);
83  }
84 
85  {
87  std::shared_ptr<MappingMaterialDecorator>>(
88  m, "MappingMaterialDecorator")
90  bool>(),
91  py::arg("tGeometry"), py::arg("level"),
92  py::arg("clearSurfaceMaterial") = true,
93  py::arg("clearVolumeMaterial") = true)
94  .def("binningMap", &MappingMaterialDecorator::binningMap)
95  .def("setBinningMap", &MappingMaterialDecorator::setBinningMap);
96  }
97 
98  {
100 
101  auto alg = py::class_<Alg, ActsExamples::IAlgorithm, std::shared_ptr<Alg>>(
102  mex, "MaterialMapping")
103  .def(py::init<const Alg::Config&, Acts::Logging::Level>(),
104  py::arg("config"), py::arg("level"))
105  .def("scoringParameters", &Alg::scoringParameters)
106  .def_property_readonly("config", &Alg::config);
107 
108  auto c = py::class_<Alg::Config>(alg, "Config")
109  .def(py::init<const Acts::GeometryContext&,
110  const Acts::MagneticFieldContext&>());
111 
113  ACTS_PYTHON_MEMBER(collection);
114  ACTS_PYTHON_MEMBER(mappingMaterialCollection);
115  ACTS_PYTHON_MEMBER(materialSurfaceMapper);
116  ACTS_PYTHON_MEMBER(materialVolumeMapper);
117  ACTS_PYTHON_MEMBER(materialWriters);
122  }
123 
124  {
125  auto cls =
126  py::class_<SurfaceMaterialMapper,
127  std::shared_ptr<SurfaceMaterialMapper>>(
128  m, "SurfaceMaterialMapper")
132  return std::make_shared<SurfaceMaterialMapper>(
133  config, std::move(prop),
134  getDefaultLogger("SurfaceMaterialMapper", level));
135  }),
136  py::arg("config"), py::arg("propagator"), py::arg("level"));
137 
138  auto c = py::class_<SurfaceMaterialMapper::Config>(cls, "Config")
139  .def(py::init<>());
141  ACTS_PYTHON_MEMBER(etaRange);
142  ACTS_PYTHON_MEMBER(emptyBinCorrection);
143  ACTS_PYTHON_MEMBER(mapperDebugOutput);
144  ACTS_PYTHON_MEMBER(computeVariance);
146  }
147 
148  {
149  auto cls =
150  py::class_<VolumeMaterialMapper, std::shared_ptr<VolumeMaterialMapper>>(
151  m, "VolumeMaterialMapper")
155  return std::make_shared<VolumeMaterialMapper>(
156  config, std::move(prop),
157  getDefaultLogger("VolumeMaterialMapper", level));
158  }),
159  py::arg("config"), py::arg("propagator"), py::arg("level"));
160 
161  auto c = py::class_<VolumeMaterialMapper::Config>(cls, "Config")
162  .def(py::init<>());
164  ACTS_PYTHON_MEMBER(mappingStep);
166  }
167 }
168 } // namespace Acts::Python