File indexing completed on 2025-08-05 08:09:37
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Geometry/ProtoLayer.hpp"
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Geometry/Polyhedron.hpp"
0013 #include "Acts/Surfaces/RegularSurface.hpp"
0014 #include "Acts/Utilities/Helpers.hpp"
0015
0016 #include <algorithm>
0017 #include <array>
0018 #include <string>
0019 #include <utility>
0020
0021 using Acts::VectorHelpers::perp;
0022 using Acts::VectorHelpers::phi;
0023
0024 namespace Acts {
0025
0026 ProtoLayer::ProtoLayer(const GeometryContext& gctx,
0027 const std::vector<const Surface*>& surfaces)
0028 : m_surfaces(surfaces) {
0029 measure(gctx, surfaces);
0030 }
0031
0032 ProtoLayer::ProtoLayer(
0033 const GeometryContext& gctx,
0034 const std::vector<std::shared_ptr<const Surface>>& surfaces)
0035 : m_surfaces(unpack_shared_vector(surfaces)) {
0036 measure(gctx, m_surfaces);
0037 }
0038
0039 double ProtoLayer::min(BinningValue bval, bool addenv) const {
0040 if (addenv) {
0041 return extent.min(bval) - envelope[bval][0u];
0042 }
0043 return extent.min(bval);
0044 }
0045
0046 double ProtoLayer::max(BinningValue bval, bool addenv) const {
0047 if (addenv) {
0048 return extent.max(bval) + envelope[bval][1u];
0049 }
0050 return extent.max(bval);
0051 }
0052
0053 double ProtoLayer::medium(BinningValue bval, bool addenv) const {
0054 return 0.5 * (min(bval, addenv) + max(bval, addenv));
0055 }
0056
0057 double ProtoLayer::range(BinningValue bval, bool addenv) const {
0058 return std::abs(max(bval, addenv) - min(bval, addenv));
0059 }
0060
0061 std::ostream& ProtoLayer::toStream(std::ostream& sl) const {
0062 sl << "ProtoLayer with dimensions (min/max)" << std::endl;
0063 sl << extent.toString();
0064 return sl;
0065 }
0066
0067 void ProtoLayer::measure(const GeometryContext& gctx,
0068 const std::vector<const Surface*>& surfaces) {
0069 for (const auto& sf : surfaces) {
0070 auto sfPolyhedron = sf->polyhedronRepresentation(gctx, 1);
0071 const DetectorElementBase* element = sf->associatedDetectorElement();
0072 const auto* regSurface = dynamic_cast<const RegularSurface*>(sf);
0073 if (element != nullptr && regSurface != nullptr) {
0074
0075 double thickness = element->thickness();
0076
0077 Vector3 sfNormal = regSurface->normal(gctx, sf->center(gctx));
0078 std::vector<double> deltaT = {-0.5 * thickness, 0.5 * thickness};
0079 for (const auto& dT : deltaT) {
0080 Transform3 dtransform = Transform3::Identity();
0081 dtransform.pretranslate(dT * sfNormal);
0082 extent.extend(sfPolyhedron.extent(dtransform));
0083 }
0084 continue;
0085 }
0086 extent.extend(sfPolyhedron.extent());
0087 }
0088 }
0089
0090 void ProtoLayer::add(const GeometryContext& gctx, const Surface& surface) {
0091 m_surfaces.push_back(&surface);
0092 measure(gctx, m_surfaces);
0093 }
0094
0095 }