66// License, v. 2.0. If a copy of the MPL was not distributed with this
77// file, You can obtain one at https://mozilla.org/MPL/2.0/.
88
9- #include " Acts/Detector/GeometryIdGenerator.hpp"
109#include " Acts/Utilities/Logger.hpp"
1110#include " ActsExamples/DD4hepDetector/AlignedDD4hepDetectorElement.hpp"
1211#include " ActsExamples/DD4hepDetector/DD4hepDetector.hpp"
1312#include " ActsExamples/DD4hepDetector/OpenDataDetector.hpp"
1413#include " ActsPlugins/DD4hep/DD4hepDetectorElement.hpp"
15- #include " ActsPlugins/DD4hep/DD4hepDetectorStructure.hpp"
16- #include " ActsPlugins/DD4hep/DD4hepFieldAdapter.hpp"
17- #include " ActsPlugins/DD4hep/DD4hepIdentifierMapper.hpp"
1814#include " ActsPython/Utilities/Helpers.hpp"
1915#include " ActsPython/Utilities/Macros.hpp"
2016
2117#include < memory>
2218#include < utility>
2319
24- #include < DD4hep/DetElement.h>
25- #include < DD4hep/Fields.h>
2620#include < pybind11/functional.h>
2721#include < pybind11/pybind11.h>
2822#include < pybind11/stl.h>
@@ -34,22 +28,13 @@ using namespace pybind11::literals;
3428using namespace ActsExamples ;
3529using namespace ActsPython ;
3630
37- PYBIND11_MODULE (ActsPythonBindingsDD4hep , m) {
31+ PYBIND11_MODULE (ActsExamplesPythonBindingsDD4hep , m) {
3832 {
39- py::class_<DD4hepDetectorElement, DetectorElementBase,
40- std::shared_ptr<DD4hepDetectorElement>>(m,
41- " DD4hepDetectorElement" );
42-
4333 py::class_<AlignedDD4hepDetectorElement, DD4hepDetectorElement,
4434 std::shared_ptr<AlignedDD4hepDetectorElement>>(
4535 m, " AlignedDD4hepDetectorElement" );
4636 }
4737
48- {
49- py::class_<dd4hep::DetElement, std::shared_ptr<dd4hep::DetElement>>(
50- m, " DD4hepDetElement" );
51- }
52-
5338 {
5439 auto base =
5540 py::class_<DD4hepDetectorBase, Detector,
@@ -93,81 +78,4 @@ PYBIND11_MODULE(ActsPythonBindingsDD4hep, m) {
9378
9479 patchKwargsConstructor (c);
9580 }
96-
97- {
98- py::class_<DD4hepFieldAdapter, MagneticFieldProvider,
99- std::shared_ptr<DD4hepFieldAdapter>>(m, " DD4hepFieldAdapter" );
100- }
101-
102- {
103- m.def (
104- " createDD4hepIdGeoIdMap" ,
105- [](const TrackingGeometry& tGeometry)
106- -> std::map<DD4hepDetectorElement::DD4hepVolumeID,
107- GeometryIdentifier> {
108- // The surface visitor
109- struct DD4hepIdGrabber {
110- std::map<DD4hepDetectorElement::DD4hepVolumeID, GeometryIdentifier>
111- dd4hepIdGeoIdMap;
112-
113- void operator ()(const Surface* surface) {
114- const auto * dde = surface->associatedDetectorElement ();
115- const auto * dd4hepDetElement =
116- dynamic_cast <const DD4hepDetectorElement*>(dde);
117- // Check if it is valid
118- if (dd4hepDetElement != nullptr ) {
119- dd4hep::DDSegmentation::VolumeID dd4hepID =
120- dd4hepDetElement->sourceElement ().volumeID ();
121- auto geoID = surface->geometryId ();
122- dd4hepIdGeoIdMap[dd4hepID] = geoID;
123- }
124- }
125- };
126-
127- // Create an instance
128- DD4hepIdGrabber dd4hepIdGrabber;
129- // Visit the surfaces & return what you have
130- tGeometry.visitSurfaces (dd4hepIdGrabber);
131- return dd4hepIdGrabber.dd4hepIdGeoIdMap ;
132- });
133- }
134-
135- {
136- using Options = DD4hepDetectorStructure::Options;
137- auto o = py::class_<Options>(m, " DD4hepDetectorOptions" ).def (py::init<>());
138- ACTS_PYTHON_STRUCT (o, logLevel, emulateToGraph, geoIdGenerator,
139- materialDecorator);
140-
141- patchKwargsConstructor (o);
142-
143- m.def (" attachDD4hepGeoIdMapper" ,
144- [](DD4hepDetectorStructure::Options& options,
145- const std::map<DD4hepDetectorElement::DD4hepVolumeID,
146- GeometryIdentifier>& dd4hepIdGeoIdMap) {
147- // The Geo mapper
148- auto geoIdMapper = std::make_shared<const DD4hepIdentifierMapper>(
149- DD4hepIdentifierMapper::Config{dd4hepIdGeoIdMap},
150- getDefaultLogger (" GeometryIdMapper" , options.logLevel ));
151-
152- // A remaining recursive logger
153- auto geoIdGenerator =
154- std::make_shared<const Experimental::GeometryIdGenerator>(
155- Experimental::GeometryIdGenerator::Config{},
156- getDefaultLogger (" GeometryIdGenerator" , options.logLevel ));
157-
158- std::tuple<std::shared_ptr<const Experimental::GeometryIdGenerator>,
159- std::shared_ptr<const DD4hepIdentifierMapper>>
160- chainedGenerators = {geoIdGenerator, geoIdMapper};
161-
162- auto chainedGeoIdGenerator =
163- std::make_shared<const Experimental::ChainedGeometryIdGenerator<
164- std::shared_ptr<const Experimental::GeometryIdGenerator>,
165- std::shared_ptr<const DD4hepIdentifierMapper>>>(
166- std::move (chainedGenerators),
167- getDefaultLogger (" ChainedGeometryIdGenerator" ,
168- options.logLevel ));
169-
170- options.geoIdGenerator = chainedGeoIdGenerator;
171- });
172- }
17381}
0 commit comments