40 std::unique_ptr<const Logger>
logger)
45 std::unique_ptr<const Acts::TrackingGeometry>
48 using MeasuredSurface =
49 std::pair<std::array<ActsScalar, 2u>, std::shared_ptr<Surface>>;
51 std::vector<MeasuredSurface> surfacesMeasured;
52 surfacesMeasured.reserve(
m_cfg.surfaces.size());
53 for (
auto&
s :
m_cfg.surfaces) {
54 auto ext =
s->polyhedronRepresentation(gctx, 1
u).extent();
55 surfacesMeasured.push_back(MeasuredSurface{
56 std::array<ActsScalar, 2u>{ext.medium(
binZ), ext.medium(
binR)},
s});
60 ACTS_INFO(
"Full KDTree has " << surfacesMeasured.size() <<
" surfaces.");
64 auto protoWorld =
m_cfg.protoDetector.worldVolume;
68 auto worldTrackingVolume =
69 translateVolume(cCache, gctx, surfaceKDT, protoWorld);
72 <<
" surfaces from the KDTree.");
75 return std::make_unique<const Acts::TrackingGeometry>(worldTrackingVolume);
78 std::shared_ptr<Acts::TrackingVolume>
83 std::vector<std::shared_ptr<const TrackingVolume>> translatedVolumes = {};
93 auto tVolume =
m_cfg.trackingVolumeHelper->createGapTrackingVolume(
94 gctx, mtv,
nullptr, rangeR.min(), rangeR.max(), rangeZ.min(),
95 rangeZ.max(), 0,
false, ptVolume.
name);
96 ACTS_DEBUG(indent <<
"> translated into gap volume bounds: "
97 << tVolume->volumeBounds());
104 if (cts.constituentVolumes.empty()) {
105 throw std::invalid_argument(
106 "KDTreeTrackingGeometryBuilder: no constituents given.");
110 if (not cts.layerContainer) {
112 << cts.constituentVolumes.size() <<
" constituents.");
113 for (
auto& cVolume : cts.constituentVolumes) {
114 auto dtVolume = translateVolume(cCache, gctx, kdt, cVolume,
115 indent +
m_cfg.hierarchyIndent);
116 translatedVolumes.push_back(dtVolume);
118 auto tVolume =
m_cfg.trackingVolumeHelper->createContainerTrackingVolume(
119 gctx, translatedVolumes);
120 ACTS_DEBUG(indent <<
"> translated into container volume bounds: "
121 << tVolume->volumeBounds());
125 std::vector<std::shared_ptr<const Layer>> layers = {};
127 << cts.constituentVolumes.size() <<
" layers.");
128 for (
auto& plVolume : cts.constituentVolumes) {
129 if (plVolume.internal.has_value()) {
130 layers.push_back(translateLayer(cCache, gctx, kdt, plVolume,
131 indent +
m_cfg.hierarchyIndent));
133 ACTS_WARNING(indent <<
"> layer type volume has no internal "
134 "description, layer not built.");
138 auto tVolume =
m_cfg.trackingVolumeHelper->createTrackingVolume(
139 gctx, layers, {},
nullptr, rangeR.min(), rangeR.max(), rangeZ.min(),
140 rangeZ.max(), ptVolume.
name);
141 ACTS_DEBUG(indent <<
"> translated into bounds: "
142 << tVolume->volumeBounds());
151 std::shared_ptr<const Acts::Layer>
158 auto& its = plVolume.
internal.value();
167 ACTS_VERBOSE(indent +
">> found " << layerSurfaces.size()
168 <<
" surfaces in the KDTree.");
171 std::shared_ptr<const Acts::Layer> tLayer =
nullptr;
173 if (layerSurfaces.size() == 1
u) {
174 auto surface = layerSurfaces[0
u].second;
176 if (its.layerType == Acts::Surface::SurfaceType::Cylinder) {
178 ">> creating cylinder layer from a single surface.");
180 auto cylinderBounds =
182 auto cylinderBoundsClone =
183 std::make_shared<const CylinderBounds>(*cylinderBounds);
186 cylinderLayer->assignSurfaceMaterial(
surface->surfaceMaterialSharedPtr());
187 tLayer = cylinderLayer;
188 }
else if (its.layerType == Acts::Surface::SurfaceType::Disc) {
190 ">> creating cylinder layer from a single surface.");
194 auto radialBoundsClone =
195 std::make_shared<const RadialBounds>(*radialBounds);
198 discLayer->assignSurfaceMaterial(
surface->surfaceMaterialSharedPtr());
201 throw std::invalid_argument(
202 "KDTreeTrackingGeometryBuilder: layer type is neither cylinder nor "
206 }
else if (layerSurfaces.size() > 1
u) {
208 std::vector<std::shared_ptr<const Surface>> cLayerSurfaces;
209 cLayerSurfaces.reserve(layerSurfaces.size());
210 for (
const auto&
s : layerSurfaces) {
211 cLayerSurfaces.push_back(
s.second);
216 std::size_t bins0 = 0;
217 std::size_t bins1 = 0;
219 if (its.surfaceBinning.size() == 2
u) {
220 bType0 = its.surfaceBinning[0
u].type;
221 bType1 = its.surfaceBinning[1
u].type;
224 its.surfaceBinning[0
u].bins() > 1
u and
225 its.surfaceBinning[1
u].bins() > 1
u) {
226 bins0 = its.surfaceBinning[0
u].bins();
227 bins1 = its.surfaceBinning[1
u].bins();
228 ACTS_VERBOSE(indent +
">> binning provided externally to be "
229 << bins0 <<
" x " << bins1 <<
".");
235 if (its.layerType == Acts::Surface::SurfaceType::Cylinder) {
236 ACTS_VERBOSE(indent +
">> creating cylinder layer with "
237 << cLayerSurfaces.size() <<
" surfaces.");
239 tLayer = (bins0 * bins1 > 0)
240 ?
m_cfg.layerCreator->cylinderLayer(gctx, cLayerSurfaces,
241 bins0, bins1, pLayer)
242 :
m_cfg.layerCreator->cylinderLayer(gctx, cLayerSurfaces,
243 bType0, bType1, pLayer);
245 }
else if (its.layerType == Acts::Surface::SurfaceType::Disc) {
247 << cLayerSurfaces.size() <<
" surfaces.");
249 tLayer = (bins0 * bins1 > 0)
250 ?
m_cfg.layerCreator->discLayer(gctx, cLayerSurfaces, bins0,
253 :
m_cfg.layerCreator->discLayer(gctx, cLayerSurfaces, bType0,
256 throw std::invalid_argument(
257 "KDTreeTrackingGeometryBuilder: layer type is neither cylinder nor "
261 if (tLayer !=
nullptr and tLayer->representingVolume() !=
nullptr) {
262 ACTS_DEBUG(indent <<
"> translated into layer bounds: "
263 << tLayer->representingVolume()->volumeBounds());
265 throw std::runtime_error(
266 "KDTreeTrackingGeometryBuilder: layer was not built.");