File indexing completed on 2025-12-11 09:40:21
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Units.hpp"
0012 #include "Acts/Detector/Blueprint.hpp"
0013 #include "Acts/Detector/interface/IGeometryIdGenerator.hpp"
0014 #include "Acts/Detector/interface/IInternalStructureBuilder.hpp"
0015 #include "Acts/Detector/interface/IRootVolumeFinderBuilder.hpp"
0016 #include "Acts/Geometry/Extent.hpp"
0017 #include "Acts/Geometry/GeometryContext.hpp"
0018 #include "Acts/Geometry/VolumeBounds.hpp"
0019 #include "Acts/Utilities/Logger.hpp"
0020 #include "ActsPlugins/DD4hep/DD4hepDetectorElement.hpp"
0021 #include "ActsPlugins/DD4hep/DD4hepLayerStructure.hpp"
0022
0023 #include <memory>
0024 #include <optional>
0025 #include <tuple>
0026 #include <vector>
0027
0028 #include <DD4hep/DD4hepUnits.h>
0029 #include <DD4hep/DetElement.h>
0030
0031 namespace ActsPlugins {
0032
0033 class DD4hepBlueprintFactory {
0034 public:
0035
0036 struct Config {
0037 std::shared_ptr<ActsPlugins::DD4hepLayerStructure> layerStructure = nullptr;
0038
0039
0040
0041 unsigned int maxPortals = 8u;
0042 };
0043
0044
0045 struct Cache {
0046
0047 DD4hepDetectorElement::Store dd4hepStore;
0048 };
0049
0050
0051
0052
0053
0054 explicit DD4hepBlueprintFactory(
0055 const Config& cfg,
0056 std::unique_ptr<const Acts::Logger> mlogger = Acts::getDefaultLogger(
0057 "DD4hepBlueprintFactory", Acts::Logging::INFO));
0058
0059
0060
0061
0062
0063
0064
0065
0066 std::unique_ptr<Acts::Experimental::Gen2Blueprint::Node> create(
0067 Cache& cache, const Acts::GeometryContext& gctx,
0068 const dd4hep::DetElement& dd4hepElement) const;
0069
0070 private:
0071
0072 static constexpr double unitLength =
0073 Acts::UnitConstants::mm / dd4hep::millimeter;
0074
0075
0076 Config m_cfg;
0077
0078
0079 std::unique_ptr<const Acts::Logger> m_logger;
0080
0081
0082 const Acts::Logger& logger() const { return *m_logger; }
0083
0084
0085
0086
0087
0088
0089
0090
0091 void recursiveParse(Cache& cache,
0092 Acts::Experimental::Gen2Blueprint::Node& mother,
0093 const Acts::GeometryContext& gctx,
0094 const dd4hep::DetElement& dd4hepElement,
0095 unsigned int hiearchyLevel = 0) const;
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105 std::tuple<Acts::Transform3, Acts::VolumeBounds::BoundsType,
0106 std::vector<double>, std::vector<Acts::AxisDirection>, std::string>
0107 extractExternals(
0108 [[maybe_unused]] const Acts::GeometryContext& gctx,
0109 const dd4hep::DetElement& dd4hepElement, const std::string& baseName,
0110 const std::optional<Acts::Extent>& extOpt = std::nullopt) const;
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127 std::tuple<
0128 std::shared_ptr<const Acts::Experimental::IInternalStructureBuilder>,
0129 std::shared_ptr<const Acts::Experimental::IRootVolumeFinderBuilder>,
0130 std::shared_ptr<const Acts::Experimental::IGeometryIdGenerator>,
0131 std::array<std::string, 3u>, std::optional<Acts::Extent>>
0132 extractInternals(DD4hepDetectorElement::Store& dd4hepStore,
0133 const Acts::GeometryContext& gctx,
0134 const dd4hep::DetElement& dd4hepElement,
0135 const std::string& baseName) const;
0136 };
0137
0138 }