File indexing completed on 2025-01-18 09:11:24
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 using Acts::VectorHelpers::perp;
0017 using Acts::VectorHelpers::phi;
0018
0019 namespace Acts {
0020
0021 ProtoLayer::ProtoLayer(const GeometryContext& gctx,
0022 const std::vector<const Surface*>& surfaces,
0023 const Transform3& transformIn)
0024 : transform(transformIn), m_surfaces(surfaces) {
0025 measure(gctx, surfaces);
0026 }
0027
0028 ProtoLayer::ProtoLayer(
0029 const GeometryContext& gctx,
0030 const std::vector<std::shared_ptr<const Surface>>& surfaces,
0031 const Transform3& transformIn)
0032 : transform(transformIn), m_surfaces(unpack_shared_vector(surfaces)) {
0033 measure(gctx, m_surfaces);
0034 }
0035
0036 ProtoLayer::ProtoLayer(const GeometryContext& gctx,
0037 const std::vector<std::shared_ptr<Surface>>& surfaces,
0038 const Transform3& transformIn)
0039 : transform(transformIn) {
0040 m_surfaces.reserve(surfaces.size());
0041 for (const auto& sf : surfaces) {
0042 m_surfaces.push_back(sf.get());
0043 }
0044 measure(gctx, m_surfaces);
0045 }
0046
0047 double ProtoLayer::min(AxisDirection aDir, bool addenv) const {
0048 if (addenv) {
0049 return extent.min(aDir) - envelope[aDir][0u];
0050 }
0051 return extent.min(aDir);
0052 }
0053
0054 double ProtoLayer::max(AxisDirection aDir, bool addenv) const {
0055 if (addenv) {
0056 return extent.max(aDir) + envelope[aDir][1u];
0057 }
0058 return extent.max(aDir);
0059 }
0060
0061 double ProtoLayer::medium(AxisDirection aDir, bool addenv) const {
0062 return 0.5 * (min(aDir, addenv) + max(aDir, addenv));
0063 }
0064
0065 double ProtoLayer::range(AxisDirection aDir, bool addenv) const {
0066 return std::abs(max(aDir, addenv) - min(aDir, addenv));
0067 }
0068
0069 std::ostream& ProtoLayer::toStream(std::ostream& sl) const {
0070 sl << "ProtoLayer with dimensions (min/max)" << std::endl;
0071 sl << extent.toString();
0072 return sl;
0073 }
0074
0075 void ProtoLayer::measure(const GeometryContext& gctx,
0076 const std::vector<const Surface*>& surfaces) {
0077 for (const auto& sf : surfaces) {
0078
0079
0080 int lseg = (sf->type() != Surface::Straw) ? 1 : 2;
0081 auto sfPolyhedron = sf->polyhedronRepresentation(gctx, lseg);
0082 const DetectorElementBase* element = sf->associatedDetectorElement();
0083 const auto* regSurface = dynamic_cast<const RegularSurface*>(sf);
0084 if (element != nullptr && regSurface != nullptr) {
0085
0086 double thickness = element->thickness();
0087
0088 Vector3 sfNormal = regSurface->normal(gctx, sf->center(gctx));
0089 for (const auto& dT : {-0.5 * thickness, 0.5 * thickness}) {
0090 Transform3 dtransform = transform * Translation3{dT * sfNormal};
0091 extent.extend(sfPolyhedron.extent(dtransform));
0092 }
0093 continue;
0094 }
0095 extent.extend(sfPolyhedron.extent(transform));
0096 }
0097 }
0098
0099 void ProtoLayer::add(const GeometryContext& gctx, const Surface& surface) {
0100 m_surfaces.push_back(&surface);
0101 measure(gctx, m_surfaces);
0102 }
0103
0104 }