31 #include "ActsPodioEdm/Surface.h"
36 namespace Acts::PodioUtil {
39 template <
typename bounds_t>
40 std::shared_ptr<const bounds_t> createBounds(
42 constexpr
size_t S = bounds_t::eSize;
44 "Unexpected number of bound values");
46 std::array<double, S>
values{};
47 for (
size_t i = 0;
i <
S;
i++) {
48 values.at(
i) = surface.boundValues.at(
i);
50 return std::make_shared<bounds_t>(
values);
59 if (identifier.has_value()) {
60 result.identifier = identifier.value();
64 "Unidentified surface does not have detector element");
66 result.surfaceType = surface.
type();
72 if (
values.size() > result.boundValues.size()) {
73 throw std::runtime_error{
"Too many bound values to store"};
76 for (
size_t i = 0;
i <
values.size();
i++) {
77 result.boundValues.at(
i) =
values.at(
i);
79 result.boundValuesSize =
values.size();
81 Eigen::Map<ActsSquareMatrix<4>> trf{result.transform.data()};
98 Eigen::Map<const ActsSquareMatrix<4>> mat{surface.transform.data()};
104 std::shared_ptr<const Surface> result;
108 result = srf->getSharedPtr();
115 switch (surface.surfaceType) {
117 throw std::runtime_error{
"Invalid surface type encountered"};
120 throw_assert(surface.boundsType == B::eCone,
"Unexpected bounds type");
121 result = Acts::Surface::makeShared<ConeSurface>(
127 "Unexpected bounds type");
128 result = Acts::Surface::makeShared<CylinderSurface>(
133 std::shared_ptr<const DiscBounds> dBounds;
134 switch (surface.boundsType) {
136 throw std::runtime_error{
"Invalid bounds type encountered"};
139 dBounds = createBounds<RadialBounds>(
surface);
143 dBounds = createBounds<AnnulusBounds>(
surface);
146 case B::eDiscTrapezoid:
147 dBounds = createBounds<DiscTrapezoidBounds>(
surface);
150 result = Acts::Surface::makeShared<DiscSurface>(
transform, dBounds);
156 "Unexpected bounds type");
157 result = Acts::Surface::makeShared<PerigeeSurface>(
transform);
161 std::shared_ptr<const PlanarBounds> pBounds;
162 switch (surface.boundsType) {
164 throw std::runtime_error{
"Invalid bounds type encountered"};
167 pBounds = createBounds<DiamondBounds>(
surface);
170 pBounds = createBounds<EllipseBounds>(
surface);
173 pBounds = createBounds<RectangleBounds>(
surface);
175 case B::eConvexPolygon:
176 template_switch_lambda<6, 32>(surface.boundValuesSize, [&](
auto N) {
177 constexpr
size_t nValues = decltype(
N)::
value;
178 constexpr
size_t nVertices = nValues / 2;
179 pBounds = createBounds<ConvexPolygonBounds<nVertices>>(
surface);
184 assert(pBounds &&
"No PlanarBounds");
185 result = Acts::Surface::makeShared<PlaneSurface>(
transform, pBounds);
191 throw_assert(surface.boundsType == B::eLine,
"Unexpected bounds type");
192 result = Acts::Surface::makeShared<StrawSurface>(
198 "Unexpected bounds type");
199 result = Acts::Surface::makeShared<PlaneSurface>(
transform);