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/ProtoSupport.hpp"
0013 #include "Acts/Geometry/Extent.hpp"
0014 #include "Acts/Surfaces/Surface.hpp"
0015 #include "Acts/Utilities/Logger.hpp"
0016 #include "Acts/Utilities/ProtoAxis.hpp"
0017
0018 #include <tuple>
0019 #include <vector>
0020
0021 #include <DD4hep/DD4hepUnits.h>
0022
0023 class TGeoMatrix;
0024
0025 namespace dd4hep {
0026 class DetElement;
0027 }
0028
0029 namespace Acts {
0030
0031 class ISurfaceMaterial;
0032
0033 }
0034
0035 namespace ActsPlugins {
0036 class DD4hepDetectorElement;
0037
0038
0039
0040
0041
0042 class DD4hepDetectorSurfaceFactory {
0043 public:
0044
0045 using ElementFactory = std::function<std::shared_ptr<DD4hepDetectorElement>(
0046 const dd4hep::DetElement&, const std::string&, double, bool,
0047 std::shared_ptr<const Acts::ISurfaceMaterial>)>;
0048
0049
0050 using DD4hepSensitiveSurface =
0051 std::tuple<std::shared_ptr<DD4hepDetectorElement>,
0052 std::shared_ptr<Acts::Surface>>;
0053
0054
0055
0056 using DD4hepPassiveSurface = std::tuple<std::shared_ptr<Acts::Surface>, bool>;
0057
0058
0059 struct Config {
0060
0061 ElementFactory detectorElementFactory =
0062 [](const dd4hep::DetElement& detElem, const std::string& axes,
0063 double scalor, bool isDisc,
0064 const std::shared_ptr<const Acts::ISurfaceMaterial>& material) {
0065 return std::make_shared<DD4hepDetectorElement>(detElem, axes, scalor,
0066 isDisc, material);
0067 };
0068 };
0069
0070
0071 struct Cache {
0072
0073 std::vector<DD4hepSensitiveSurface> sensitiveSurfaces;
0074
0075 std::vector<DD4hepPassiveSurface> passiveSurfaces;
0076
0077 std::size_t convertedSurfaces = 0;
0078
0079 std::size_t convertedMaterials = 0;
0080
0081 std::vector<std::tuple<Acts::DirectedProtoAxis, std::size_t>> binnings = {};
0082
0083 std::vector<Acts::Experimental::ProtoSupport> supports = {};
0084
0085 std::optional<Acts::Extent> sExtent = std::nullopt;
0086
0087 std::optional<Acts::Extent> pExtent = std::nullopt;
0088
0089 std::vector<Acts::AxisDirection> extentConstraints = {};
0090
0091 std::size_t nExtentQSegments = 1u;
0092 };
0093
0094
0095 struct Options {
0096
0097 bool convertSensitive = true;
0098
0099 bool convertPassive = true;
0100
0101 bool convertMaterial = false;
0102
0103 double surfaceMaterialThickness = 1 * Acts::UnitConstants::mm;
0104 };
0105
0106
0107
0108
0109
0110 explicit DD4hepDetectorSurfaceFactory(
0111 const Config& config,
0112 std::unique_ptr<const Acts::Logger> mlogger = Acts::getDefaultLogger(
0113 "DD4hepDetectorSurfaceFactory", Acts::Logging::INFO));
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123 void construct(Cache& cache, const Acts::GeometryContext& gctx,
0124 const dd4hep::DetElement& dd4hepElement,
0125 const Options& options);
0126
0127 private:
0128
0129 static constexpr double unitLength =
0130 Acts::UnitConstants::mm / dd4hep::millimeter;
0131
0132
0133 Config m_config;
0134
0135
0136 std::unique_ptr<const Acts::Logger> m_logger;
0137
0138
0139 const Acts::Logger& logger() const { return *m_logger; }
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150 void recursiveConstruct(Cache& cache, const Acts::GeometryContext& gctx,
0151 const dd4hep::DetElement& dd4hepElement,
0152 const Options& options, int level);
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165 DD4hepSensitiveSurface constructSensitiveComponents(
0166 Cache& cache, const Acts::GeometryContext& gctx,
0167 const dd4hep::DetElement& dd4hepElement, const Options& options) const;
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177 DD4hepPassiveSurface constructPassiveComponents(
0178 Cache& cache, const Acts::GeometryContext& gctx,
0179 const dd4hep::DetElement& dd4hepElement, const Options& options) const;
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194 void attachSurfaceMaterial(const Acts::GeometryContext& gctx,
0195 const std::string& prefix,
0196 const dd4hep::DetElement& dd4hepElement,
0197 Acts::Surface& surface, double thickness,
0198 const Options& options) const;
0199 };
0200
0201 }