34 #include <unordered_map>
38 #include <G4RunManager.hh>
39 #include <G4Transform3D.hh>
40 #include <G4UserEventAction.hh>
41 #include <G4UserRunAction.hh>
42 #include <pybind11/pybind11.h>
43 #include <pybind11/stl.h>
45 class G4UserSteppingAction;
46 class G4VUserPhysicsList;
52 namespace ActsExamples {
56 namespace py = pybind11;
57 using namespace pybind11::literals;
59 using namespace ActsExamples;
61 using namespace Acts::Python;
63 namespace Acts::Python {
69 std::shared_ptr<DetectorConstructionFactory>>(
70 mod,
"DetectorConstructionFactory");
72 py::class_<Geant4Manager, std::unique_ptr<Geant4Manager, py::nodelete>>(
74 .def_static(
"instance", &Geant4Manager::instance,
75 py::return_value_policy::reference)
76 .def(
"currentHandle", &Geant4Manager::currentHandle);
78 py::class_<Geant4Handle, std::shared_ptr<Geant4Handle>>(mod,
"Geant4Handle")
79 .def(
"tweakLogging", &Geant4Handle::tweakLogging);
85 py::class_<Algorithm, IAlgorithm, std::shared_ptr<Algorithm>>(
86 mod,
"Geant4SimulationBase")
87 .def_property_readonly(
"geant4Handle", &Algorithm::geant4Handle);
89 auto c1 = py::class_<Config, std::shared_ptr<Config>>(alg,
"Config")
103 py::class_<Algorithm, Geant4SimulationBase, std::shared_ptr<Algorithm>>(
104 mod,
"Geant4Simulation")
105 .def(py::init<const Config&, Acts::Logging::Level>(),
106 py::arg(
"config"), py::arg(
"level"))
110 std::shared_ptr<Config>>(alg,
"Config")
133 py::class_<Algorithm, Geant4SimulationBase, std::shared_ptr<Algorithm>>(
134 mod,
"Geant4MaterialRecording")
135 .def(py::init<const Config&, Acts::Logging::Level>(),
136 py::arg(
"config"), py::arg(
"level"))
140 std::shared_ptr<Config>>(alg,
"Config")
149 std::shared_ptr<GdmlDetectorConstructionFactory>>(
150 mod,
"GdmlDetectorConstructionFactory")
151 .def(py::init<std::string>());
157 DetectorConstructionFactory,
158 std::shared_ptr<Telescope::TelescopeG4DetectorConstructionFactory>>(
159 mod,
"TelescopeG4DetectorConstructionFactory")
160 .def(py::init<const Telescope::TelescopeDetector::Config&>());
165 auto is = py::class_<ISelector, std::shared_ptr<ISelector>>(
166 mod,
"IVolumeSelector");
169 auto ns = py::class_<NameSelector, std::shared_ptr<NameSelector>>(
170 mod,
"VolumeNameSelector", is)
171 .def(
py::init<
const std::vector<std::string>&,
bool>());
174 auto o = py::class_<Factory::Options>(mod,
"SurfaceFactoryOptions")
187 std::shared_ptr<Acts::Geant4DetectorElement>>(
188 mod,
"Geant4DetectorElement");
193 py::class_<Geant4Detector, std::shared_ptr<Geant4Detector>>(
194 mod,
"Geant4Detector")
201 return self.constructDetector(cfg, *
logger);
205 "constructTrackingGeometry",
209 return self.constructTrackingGeometry(cfg, *
logger);
213 auto c = py::class_<Geant4Detector::Config>(
g,
"Config").def(py::init<>());
230 mod.def(
"convertSurfaces", [](
const std::string& gdmlFileName,
231 const std::vector<std::string>&
233 const std::vector<std::string>&
237 const auto* world = gdmlContruction.
Construct();
240 auto sensitiveSelectors =
241 std::make_shared<Acts::Geant4PhysicalVolumeSelectors::NameSelector>(
242 sensitiveMatches,
false);
243 auto passiveSelectors =
244 std::make_shared<Acts::Geant4PhysicalVolumeSelectors::NameSelector>(
245 passiveMatches,
false);
254 factory.
construct(cache, nominal, *world, options);
258 std::vector<std::shared_ptr<Acts::Geant4DetectorElement>>;
259 Elements detectorElements;
260 detectorElements.reserve(cache.sensitiveSurfaces.size());
261 using Surfaces = std::vector<std::shared_ptr<Acts::Surface>>;
263 surfaces.reserve(cache.sensitiveSurfaces.size());
264 std::for_each(cache.sensitiveSurfaces.begin(),
265 cache.sensitiveSurfaces.end(), [&](
const auto& sensitive) {
266 detectorElements.push_back(std::get<0>(sensitive));
267 surfaces.push_back(std::get<1>(sensitive));
271 Surfaces passiveSurfaces;
272 passiveSurfaces.reserve(cache.passiveSurfaces.size());
273 for (
const auto&
passive : cache.passiveSurfaces) {
274 passiveSurfaces.push_back(
passive);
278 return std::tuple<Elements, Surfaces, Surfaces>(
290 py::class_<MockupSectorBuilder, std::shared_ptr<MockupSectorBuilder>>(
291 mod,
"MockupSectorBuilder")
292 .def(py::init<const Config&>())
293 .def(
"buildChamber", &MockupSectorBuilder::buildChamber)
294 .def(
"buildSector", &MockupSectorBuilder::buildSector)
295 .def(
"drawSector", &MockupSectorBuilder::drawSector);
297 auto c = py::class_<Config>(
ms,
"Config").def(py::init<>());
304 auto cch = py::class_<ChamberConfig>(
ms,
"ChamberConfig").def(py::init<>());