Warning, file /acts/Python/Plugins/src/DD4hep.cpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Geometry/GeometryIdentifier.hpp"
0010 #include "Acts/Geometry/TrackingGeometry.hpp"
0011 #include "Acts/Surfaces/Surface.hpp"
0012 #include "ActsPlugins/DD4hep/DD4hepDetectorElement.hpp"
0013 #include "ActsPlugins/DD4hep/DD4hepFieldAdapter.hpp"
0014 #include "ActsPython/Utilities/Helpers.hpp"
0015 #include "ActsPython/Utilities/Macros.hpp"
0016
0017 #include <memory>
0018 #include <string>
0019
0020 #include <DD4hep/DetElement.h>
0021 #include <DD4hep/Fields.h>
0022 #include <pybind11/pybind11.h>
0023
0024 namespace py = pybind11;
0025 using namespace pybind11::literals;
0026
0027 PYBIND11_MODULE(ActsPluginsPythonBindingsDD4hep, dd4hep) {
0028 using namespace Acts;
0029 using namespace ActsPlugins;
0030 using namespace ActsPython;
0031
0032
0033 {
0034
0035 py::class_<dd4hep::DetElement, std::shared_ptr<dd4hep::DetElement>>(
0036 dd4hep, "DD4hepDetElement");
0037
0038
0039 py::class_<DD4hepDetectorElement, DetectorElementBase,
0040 std::shared_ptr<DD4hepDetectorElement>>(dd4hep,
0041 "DD4hepDetectorElement");
0042
0043 py::class_<DD4hepFieldAdapter, MagneticFieldProvider,
0044 std::shared_ptr<DD4hepFieldAdapter>>(dd4hep,
0045 "DD4hepFieldAdapter");
0046 }
0047
0048
0049 {
0050 dd4hep.def(
0051 "createDD4hepIdGeoIdMap",
0052 [](const TrackingGeometry& tGeometry)
0053 -> std::map<DD4hepDetectorElement::DD4hepVolumeID,
0054 GeometryIdentifier> {
0055
0056 struct DD4hepIdGrabber {
0057 std::map<DD4hepDetectorElement::DD4hepVolumeID, GeometryIdentifier>
0058 dd4hepIdGeoIdMap;
0059
0060 void operator()(const Surface* surface) {
0061 const auto* dde = surface->associatedDetectorElement();
0062 const auto* dd4hepDetElement =
0063 dynamic_cast<const DD4hepDetectorElement*>(dde);
0064
0065 if (dd4hepDetElement != nullptr) {
0066 dd4hep::DDSegmentation::VolumeID dd4hepID =
0067 dd4hepDetElement->sourceElement().volumeID();
0068 auto geoID = surface->geometryId();
0069 dd4hepIdGeoIdMap[dd4hepID] = geoID;
0070 }
0071 }
0072 };
0073
0074
0075 DD4hepIdGrabber dd4hepIdGrabber;
0076
0077 tGeometry.visitSurfaces(dd4hepIdGrabber);
0078 return dd4hepIdGrabber.dd4hepIdGeoIdMap;
0079 });
0080 }
0081 }