Skip to content

Commit

Permalink
feat: Safety checks for CylindricalContainerBuilder BluePrint constru…
Browse files Browse the repository at this point in the history
…ctor (#2883)

Adding empty builders container and specific binning types safety checks to the BluePrint constructor of the CyllindricalContainerBuilder.
  • Loading branch information
ssdetlab authored Jan 19, 2024
1 parent a8c79de commit 390dd30
Showing 1 changed file with 40 additions and 11 deletions.
51 changes: 40 additions & 11 deletions Core/src/Detector/CylindricalContainerBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,36 @@ Acts::Experimental::CylindricalContainerBuilder::CylindricalContainerBuilder(
}
}

if (m_cfg.builders.empty()) {
throw std::invalid_argument(
"CylindricalContainerBuilder: no sub builders provided.");
}
m_cfg.binning = bpNode.binning;
// Check if binning value is correctly chosen
if (m_cfg.binning.size() == 1u) {
// 1-dimensional case
auto b = m_cfg.binning.front();
if (b != Acts::binR && b != Acts::binZ && b != Acts::binPhi) {
throw std::invalid_argument(
"CylindricalContainerBuilder: 1D binning only supported in z, r, or "
"phi");
}
} else if (m_cfg.binning.size() == 2u) {
// 2-dimensional case, this is for wrapping
if (m_cfg.binning !=
std::vector<Acts::BinningValue>{Acts::binZ, Acts::binR}) {
throw std::invalid_argument(
"CylindricalContainerBuilder: 2D binning only supports wrapping in "
"z-r.");
} else if (m_cfg.builders.size() != 2u) {
// Wrapping needs exactly one inner (volume or container) and one outer
// volume
throw std::invalid_argument(
"CylindricalContainerBuilder: 2D wrapping in z-r requires exactly "
"two builders.");
}
}

m_cfg.auxiliary = "*** acts auto-generated from proxy ***";
m_cfg.geoIdGenerator = bpNode.geoIdGenerator;
m_cfg.rootVolumeFinderBuilder = bpNode.rootVolumeFinderBuilder;
Expand Down Expand Up @@ -205,17 +234,6 @@ Acts::Experimental::CylindricalContainerBuilder::construct(
}
ACTS_VERBOSE("Number of root volumes: " << rootVolumes.size());

// Check if a root volume finder is provided
if (m_cfg.rootVolumeFinderBuilder) {
// Return the container
return Acts::Experimental::DetectorComponent{
{},
portalContainer,
RootDetectorVolumes{
rootVolumes,
m_cfg.rootVolumeFinderBuilder->construct(gctx, rootVolumes)}};
}

// Geometry Id generation
if (m_cfg.geoIdGenerator != nullptr) {
ACTS_DEBUG("Assigning geometry ids to the detector");
Expand Down Expand Up @@ -244,6 +262,17 @@ Acts::Experimental::CylindricalContainerBuilder::construct(
}
}

// Check if a root volume finder is provided
if (m_cfg.rootVolumeFinderBuilder) {
// Return the container
return Acts::Experimental::DetectorComponent{
{},
portalContainer,
RootDetectorVolumes{
rootVolumes,
m_cfg.rootVolumeFinderBuilder->construct(gctx, rootVolumes)}};
}

// Return the container
return Acts::Experimental::DetectorComponent{
{}, portalContainer, RootDetectorVolumes{rootVolumes, tryRootVolumes()}};
Expand Down

0 comments on commit 390dd30

Please sign in to comment.