24 std::unique_ptr<const Acts::Logger> mlogger)
28 throw std::invalid_argument(
29 "VolumeStructureBuilder: no extent nor boundary values given");
33 throw std::invalid_argument(
34 "VolumeStructureBuilder: no known volume bounds type provided.");
42 if (not
m_cfg.auxiliary.empty()) {
47 std::unique_ptr<VolumeBounds> volumeBounds =
nullptr;
50 auto eTransform = Transform3::Identity();
51 std::vector<ActsScalar> boundValues =
m_cfg.boundValues;
54 switch (
m_cfg.boundsType) {
55 case VolumeBounds::BoundsType::eCone: {
58 if (boundValues.size() < 5
u) {
59 throw std::runtime_error(
60 "VolumeStructureBuilder: parameters for cone volume bounds need to "
61 "be fully provided, they can not be estimated from an Extent "
62 "object. It needs at least 5 parameters, while " +
65 auto bArray = to_array<ConeVolumeBounds::BoundValues::eSize, ActsScalar>(
67 volumeBounds = std::make_unique<ConeVolumeBounds>(bArray);
69 case VolumeBounds::BoundsType::eCuboid: {
72 if (boundValues.empty() and
m_cfg.extent.has_value()) {
73 ACTS_VERBOSE(
"Cuboid: estimate parameters from Extent.");
74 const auto& vExtent =
m_cfg.extent.value();
75 if (vExtent.constrains(
binX) and vExtent.constrains(
binY) and
76 vExtent.constrains(
binZ)) {
77 eTransform.pretranslate(
Vector3(vExtent.medium(
binX),
79 vExtent.medium(
binZ)));
80 boundValues = {0.5 * vExtent.interval(
binX),
81 0.5 * vExtent.interval(
binY),
82 0.5 * vExtent.interval(
binZ)};
85 throw std::runtime_error(
86 "VolumeStructureBuilder: translation to cuboid does not work as "
87 "the extent does not constrain all necessary value.");
89 }
else if (boundValues.size() < 3
u) {
90 throw std::runtime_error(
91 "VolumeStructureBuilder: parameters for cuboid volume bounds need "
92 "to be fully provided, it needs exactly 3 parameters, while " +
96 to_array<CuboidVolumeBounds::BoundValues::eSize>(boundValues);
97 volumeBounds = std::make_unique<CuboidVolumeBounds>(bArray);
99 case VolumeBounds::BoundsType::eCutoutCylinder: {
100 ACTS_VERBOSE(
"Building cutout cylindrical volume bounds.");
102 if (boundValues.size() < 5
u) {
103 throw std::runtime_error(
104 "VolumeStructureBuilder: parameters for cutout cylinder volume "
105 "bounds need to be fully provided, they can not be estimated from "
106 "an Extent object. It needs exactly 3 parameters, while " +
110 to_array<CutoutCylinderVolumeBounds::BoundValues::eSize>(boundValues);
111 volumeBounds = std::make_unique<CutoutCylinderVolumeBounds>(bArray);
113 case VolumeBounds::BoundsType::eCylinder: {
116 if (boundValues.empty() and
m_cfg.extent.has_value()) {
117 ACTS_VERBOSE(
"Cylinder: estimate parameters from Extent.");
118 const auto& vExtent =
m_cfg.extent.value();
119 if (vExtent.constrains(
binR) and vExtent.constrains(
binZ)) {
120 eTransform.pretranslate(
Vector3(0., 0., vExtent.medium(
binZ)));
121 boundValues = {vExtent.min(
binR), vExtent.max(
binR),
122 0.5 * vExtent.interval(
binZ)};
123 if (vExtent.constrains(
binPhi)) {
124 boundValues.push_back(0.5 * vExtent.interval(
binPhi));
125 boundValues.push_back(vExtent.medium(
binPhi));
128 throw std::runtime_error(
129 "VolumeStructureBuilder: translation to cuboid does not work as "
130 "the extent does not constrain all necessary values.");
132 }
else if (boundValues.size() < 3
u) {
133 throw std::runtime_error(
134 "VolumeStructureBuilder: parameters for cylinder volume "
135 "bounds need to be fully provided, it needs at least 3 parameters, "
140 if (boundValues.size() == 3
u) {
141 boundValues.push_back(M_PI);
142 boundValues.push_back(0.);
144 ACTS_VERBOSE(
" - cylindrical shape with [iR, oR, hZ, sPhi, mPhi] = "
145 << boundValues[0] <<
", " << boundValues[1] <<
", "
146 << boundValues[2] <<
", " << boundValues[3] <<
", "
149 to_array<CylinderVolumeBounds::BoundValues::eSize>(boundValues);
150 volumeBounds = std::make_unique<CylinderVolumeBounds>(bArray);
152 case VolumeBounds::BoundsType::eGenericCuboid: {
156 throw std::runtime_error(
157 "VolumeStructureBuilder: parameters for generic cuboid volume "
158 "bounds need to be provided, they can not be estimated from an "
159 "Extent object. It needs exactly 24 parameters, while " +
163 to_array<GenericCuboidVolumeBounds::BoundValues::eSize>(boundValues);
164 volumeBounds = std::make_unique<GenericCuboidVolumeBounds>(bArray);
166 case VolumeBounds::BoundsType::eTrapezoid: {
169 if (boundValues.size() < 4
u) {
170 throw std::runtime_error(
171 "VolumeStructureBuilder: parameters for trapezoid volume bounds "
172 "need to be provided, they can not be estimated from an Extent "
173 "object. It needs at least 4 parameters, while " +
177 to_array<TrapezoidVolumeBounds::BoundValues::eSize>(boundValues);
178 volumeBounds = std::make_unique<TrapezoidVolumeBounds>(bArray);
186 if (not fTransform.rotation().isApprox(
187 Acts::Transform3::Identity().rotation())) {