Skip to content

Commit

Permalink
chore: move nested Support to ProtoSupport (#2497)
Browse files Browse the repository at this point in the history
This PR is part 2 of the odd + detector series:
- it promotes the `LayerStructure::Support` to `ProtoSupport`, just as
done with the `ProtoBinning`.

It sits on top of #2496 and is thus marked blocked.
  • Loading branch information
asalzburger committed Oct 3, 2023
1 parent c50a62d commit fa0a8d4
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 21 deletions.
17 changes: 2 additions & 15 deletions Core/include/Acts/Detector/LayerStructureBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Detector/DetectorComponents.hpp"
#include "Acts/Detector/ProtoBinning.hpp"
#include "Acts/Detector/ProtoSupport.hpp"
#include "Acts/Detector/interface/IInternalStructureBuilder.hpp"
#include "Acts/Detector/interface/ISurfacesProvider.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
Expand Down Expand Up @@ -72,20 +73,6 @@ class LayerStructureBuilder : public IInternalStructureBuilder {
std::vector<std::shared_ptr<Surface>> m_surfaces = {};
};

/// @brief Support parameter definitions
struct Support {
/// Define whether you want to build support structures
std::array<ActsScalar, 5u> values = {};
/// The surface type to be built
Surface::SurfaceType type = Surface::SurfaceType::Other;
/// Define in which values the support should be constrained
std::vector<BinningValue> constraints = s_binningValues;
/// Potential splits into planar approximations
unsigned int splits = 1u;
/// The (optional) layer transform
std::optional<Transform3> transform = std::nullopt;
};

/// @brief Configuration struct for the LayerStructureBuilder
///
/// It contain:
Expand All @@ -96,7 +83,7 @@ class LayerStructureBuilder : public IInternalStructureBuilder {
/// Connection point for a function to provide surfaces
std::shared_ptr<ISurfacesProvider> surfacesProvider = nullptr;
/// Definition of Supports
std::vector<Support> supports = {};
std::vector<ProtoSupport> supports = {};
/// Definition of Binnings
std::vector<ProtoBinning> binnings = {};
/// Polyhedron approximations
Expand Down
43 changes: 43 additions & 0 deletions Core/include/Acts/Detector/ProtoSupport.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// This file is part of the Acts project.
//
// Copyright (C) 2023 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#pragma once

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/Common.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Utilities/BinningData.hpp"
#include "Acts/Utilities/detail/AxisFwd.hpp"

#include <optional>
#include <stdexcept>
#include <vector>

namespace Acts {

namespace Experimental {
/// @brief Support parameter definitions
struct ProtoSupport {
/// Define whether you want to build support structures
std::array<ActsScalar, 5u> values = {};
/// The surface type to be built
Surface::SurfaceType type = Surface::SurfaceType::Other;
/// Define in which values the support should be constrained
std::vector<BinningValue> constraints = s_binningValues;
/// Potential splits into planar approximations
unsigned int splits = 1u;
/// The (optional) layer transform
std::optional<Transform3> transform = std::nullopt;
/// Alternatively - the support surface can already be provided
std::shared_ptr<Surface> surface = nullptr;
/// Indicate if the support surface should always be addressed in navigation
bool assignToAll = false;
};

} // namespace Experimental
} // namespace Acts
22 changes: 18 additions & 4 deletions Core/src/Detector/LayerStructureBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ Acts::Experimental::LayerStructureBuilder::construct(
}

// Retrieve the layer surfaces
SurfaceCandidatesUpdator internalCandidatesUpdator;
SurfaceCandidatesUpdator internalCandidatesUpdator =
tryAllPortalsAndSurfaces();
auto internalSurfaces = m_cfg.surfacesProvider->surfaces(gctx);
ACTS_DEBUG("Building internal layer structure from "
<< internalSurfaces.size() << " provided surfaces.");
Expand All @@ -179,6 +180,17 @@ Acts::Experimental::LayerStructureBuilder::construct(
ACTS_DEBUG("Adding " << m_cfg.supports.size() << " support structures.")
// The surface candidate updator
for (const auto& support : m_cfg.supports) {
// Check if the supportsurface has already been built
if (support.surface != nullptr) {
ACTS_VERBOSE("- Use provided support surface directly.");
if (support.assignToAll) {
assignToAll.push_back(internalSurfaces.size());
ACTS_VERBOSE(" Support surface is assigned to all bins.");
}
internalSurfaces.push_back(support.surface);
continue;
}

// Throw an exception is misconfigured
if (support.type == Surface::SurfaceType::Other) {
throw std::invalid_argument(
Expand All @@ -202,9 +214,11 @@ Acts::Experimental::LayerStructureBuilder::construct(
support.values, support.transform, support.splits);
}
}

// Create the indexed surface grids
if (m_cfg.binnings.size() == 1u) {
if (m_cfg.binnings.empty()) {
ACTS_DEBUG(
"No surface binning provided, navigation will be 'tryAll' (potentially "
"slow).");
} else if (m_cfg.binnings.size() == 1u) {
ACTS_DEBUG("- 1-dimensional surface binning detected.");
// Capture the binning
auto binning = m_cfg.binnings[0u];
Expand Down
1 change: 1 addition & 0 deletions Plugins/TGeo/src/TGeoMaterialConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Acts::MaterialSlab Acts::TGeoMaterialConverter::materialSlab(
ActsScalar uScalor = options.unitLengthScalor;
ActsScalar rScalar =
options.unitMassScalor / pow(options.unitLengthScalor, 3);

auto material = Material::fromMassDensity(
matX0 * uScalor / cFactor, matL0 * uScalor / cFactor, tgMaterial.GetA(),
tgMaterial.GetZ(), matRho * rScalar * cFactor);
Expand Down
4 changes: 2 additions & 2 deletions Tests/UnitTests/Core/Detector/LayerStructureBuilderTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ BOOST_AUTO_TEST_CASE(LayerStructureBuilder_creationRing) {
BOOST_CHECK(volumes0.empty());
BOOST_CHECK(volumeUpdator0.connected());

using LayerSupport = Acts::Experimental::LayerStructureBuilder::Support;
using LayerSupport = Acts::Experimental::ProtoSupport;

lsConfig.auxiliary = "*** Endcap with 22 surfaces + 1 support disc ***";
lsConfig.supports = {LayerSupport{
Expand Down Expand Up @@ -148,7 +148,7 @@ BOOST_AUTO_TEST_CASE(LayerStructureBuilder_creationCylinder) {
BOOST_CHECK(volumes0.empty());
BOOST_CHECK(volumeUpdator0.connected());

using LayerSupport = Acts::Experimental::LayerStructureBuilder::Support;
using LayerSupport = Acts::Experimental::ProtoSupport;

lsConfig.auxiliary = "*** Barrel with 448 surfaces + 1 support cylinder ***";
lsConfig.supports = {LayerSupport{{15., 10., 10., 0., 0.},
Expand Down

0 comments on commit fa0a8d4

Please sign in to comment.