Skip to content

Commit

Permalink
refactor: Remove some bound value access from CylindricalDetectorHelp…
Browse files Browse the repository at this point in the history
…er (#3056)

This removes some external bounds value access that we don't need if we perform a downcast.
  • Loading branch information
paulgessinger authored Mar 27, 2024
1 parent 6e95af5 commit aefffb3
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions Core/src/Detector/detail/CylindricalDetectorHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,18 +813,22 @@ Acts::Experimental::detail::CylindricalDetectorHelper::wrapInZR(
// If needed, insert new cylinder
if (volumes[0u]->portalPtrs().size() == 4u &&
volumes[1u]->portalPtrs().size() == 8u) {
const auto* cylVolBounds =
dynamic_cast<const CylinderVolumeBounds*>(&volumes[0u]->volumeBounds());
const auto* ccylVolBounds = dynamic_cast<const CutoutCylinderVolumeBounds*>(
&volumes[1u]->volumeBounds());
if (cylVolBounds == nullptr || ccylVolBounds == nullptr) {
throw std::invalid_argument(
"Wrapping the detector volume requires a cylinder and a cutout "
"cylinder volume.");
}
// We need a new cylinder spanning over the entire inner tube
ActsScalar hlZ =
volumes[0u]
->volumeBounds()
.values()[Acts::CylinderVolumeBounds::BoundValues::eHalfLengthZ];
ActsScalar HlZ =
volumes[1u]->volumeBounds().values()
[Acts::CutoutCylinderVolumeBounds::BoundValues::eHalfLengthZ];
ActsScalar hlZ = cylVolBounds->get(
Acts::CylinderVolumeBounds::BoundValues::eHalfLengthZ);
ActsScalar HlZ = ccylVolBounds->get(
Acts::CutoutCylinderVolumeBounds::BoundValues::eHalfLengthZ);
ActsScalar innerR =
volumes[0u]
->volumeBounds()
.values()[Acts::CylinderVolumeBounds::BoundValues::eMinR];
cylVolBounds->get(CylinderVolumeBounds::BoundValues::eMinR);
// Create the inner replacement
std::vector<PortalReplacement> pReplacements;
pReplacements.push_back(createCylinderReplacement(
Expand Down Expand Up @@ -1140,7 +1144,14 @@ Acts::Experimental::detail::CylindricalDetectorHelper::wrapInZR(
// Loop over side volume and register the z boundaries
for (auto& svs : sideVolumes) {
for (auto& v : svs.second) {
ActsScalar hlZ = v->volumeBounds().values()[2u];
const auto* cylVolBounds =
dynamic_cast<const CylinderVolumeBounds*>(&v->volumeBounds());
if (cylVolBounds == nullptr) {
throw std::invalid_argument(
"CylindricalDetectorHelper: side volume must be a cylinder.");
}
ActsScalar hlZ =
cylVolBounds->get(CylinderVolumeBounds::BoundValues::eHalfLengthZ);
zBoundaries.push_back(zBoundaries.back() + 2 * hlZ);
innerVolumes.push_back(v);
}
Expand Down

0 comments on commit aefffb3

Please sign in to comment.