|
|
|||
File indexing completed on 2025-10-29 07:53:43
0001 // This file is part of the ACTS project. 0002 // 0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project 0004 // 0005 // This Source Code Form is subject to the terms of the Mozilla Public 0006 // License, v. 2.0. If a copy of the MPL was not distributed with this 0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/. 0008 0009 #pragma once 0010 0011 #include "Acts/Definitions/Algebra.hpp" 0012 #include "Acts/Definitions/Direction.hpp" 0013 #include "Acts/Geometry/Volume.hpp" 0014 #include "Acts/Surfaces/RegularSurface.hpp" 0015 #include "Acts/Utilities/AxisDefinitions.hpp" 0016 0017 #include <cmath> 0018 #include <iostream> 0019 #include <memory> 0020 #include <numbers> 0021 #include <utility> 0022 #include <vector> 0023 0024 namespace Acts { 0025 0026 class Surface; 0027 class VolumeBounds; 0028 class Direction; 0029 0030 struct OrientedSurface { 0031 std::shared_ptr<RegularSurface> surface; 0032 Direction direction = Direction::AlongNormal(); 0033 }; 0034 0035 // Planar definitions to help construct the boundary surfaces 0036 static const Transform3 s_planeXY = Transform3::Identity(); 0037 static const Transform3 s_planeYZ = 0038 AngleAxis3(std::numbers::pi / 2., Vector3::UnitY()) * 0039 AngleAxis3(std::numbers::pi / 2., Vector3::UnitZ()) * 0040 Transform3::Identity(); 0041 static const Transform3 s_planeZX = 0042 AngleAxis3(-std::numbers::pi / 2., Vector3::UnitX()) * 0043 AngleAxis3(-std::numbers::pi / 2., Vector3::UnitZ()) * 0044 Transform3::Identity(); 0045 0046 /// @class VolumeBounds 0047 /// 0048 /// Pure Absract Base Class for Volume bounds. 0049 /// 0050 /// Acts::VolumeBounds are a set of up to six confining Surfaces that are stored 0051 /// in a std::vector. 0052 /// Each type of Acts::VolumeBounds has to implement a orientedSurfaces() and 0053 /// a inside() method. 0054 /// 0055 /// The Volume, retrieving a set of Surfaces from the VolumeBounds, can turn the 0056 /// Surfaces into BoundarySurfaces. 0057 0058 class VolumeBounds { 0059 public: 0060 // @enum BoundsType 0061 /// This is nested to the VolumeBounds, as also SurfaceBounds will have 0062 /// Bounds Type. 0063 enum class BoundsType { 0064 eCone, 0065 eCuboid, 0066 eCutoutCylinder, 0067 eCylinder, 0068 eGenericCuboid, 0069 eTrapezoid, 0070 eOther, 0071 0072 }; 0073 0074 using enum BoundsType; 0075 0076 /// Static member to get the name of the BoundsType 0077 static const std::vector<std::string> s_boundsTypeNames; 0078 0079 VolumeBounds() = default; 0080 0081 virtual ~VolumeBounds() = default; 0082 0083 /// Return the bounds type - for persistency optimization 0084 /// 0085 /// @return is a BoundsType enum 0086 virtual BoundsType type() const = 0; 0087 0088 /// Access method for bound values, this is a dynamically sized 0089 /// vector containing the parameters needed to describe these bounds 0090 /// 0091 /// @return of the stored values for this SurfaceBounds object 0092 virtual std::vector<double> values() const = 0; 0093 0094 /// Checking if position given in volume frame is inside 0095 /// 0096 /// @param gpos is the global position to be checked 0097 /// @param tol is the tolerance applied for the inside check 0098 /// 0099 /// @return boolean indicating if the position is inside 0100 virtual bool inside(const Vector3& gpos, double tol = 0.) const = 0; 0101 0102 /// Oriented surfaces, i.e. the decomposed boundary surfaces and the 0103 /// according navigation direction into the volume given the normal 0104 /// vector on the surface 0105 /// 0106 /// @param transform is the 3D transform to be applied to the boundary 0107 /// surfaces to position them in 3D space 0108 /// 0109 /// It will throw an exception if the orientation prescription is not adequate 0110 /// 0111 /// @return a vector of surfaces bounding this volume 0112 virtual std::vector<OrientedSurface> orientedSurfaces( 0113 const Transform3& transform = Transform3::Identity()) const = 0; 0114 0115 /// Construct bounding box for this shape 0116 /// @param trf Optional transform 0117 /// @param envelope Optional envelope to add / subtract from min/max 0118 /// @param entity Entity to associate this bounding box with 0119 /// @return Constructed bounding box 0120 virtual Volume::BoundingBox boundingBox( 0121 const Transform3* trf = nullptr, const Vector3& envelope = {0, 0, 0}, 0122 const Volume* entity = nullptr) const = 0; 0123 0124 /// Get the canonical axis direction 0125 /// that fully describe the shape's extent 0126 /// 0127 /// @return vector of canonical axis directions 0128 /// 0129 /// @note This is the default implementation that 0130 /// returns the bounding box binning. Individual shapes 0131 /// should override this method 0132 virtual std::vector<AxisDirection> canonicalAxes() const { 0133 using enum AxisDirection; 0134 return {AxisX, AxisY, AxisZ}; 0135 }; 0136 0137 /// Binning offset - overloaded for some R-binning types 0138 /// 0139 /// @param aDir is the binning schema used 0140 /// 0141 /// @return vector 3D to be used for the binning 0142 virtual Vector3 referenceOffset(AxisDirection aDir) const; 0143 0144 /// Binning borders in double 0145 /// 0146 /// @param aDir is the binning schema used 0147 /// 0148 /// @return float offset to be used for the binning 0149 virtual double referenceBorder(AxisDirection aDir) const; 0150 0151 /// Output Method for std::ostream, to be overloaded by child classes 0152 /// 0153 /// @param sl is the output stream to be dumped into 0154 /// @return Modified ostream for chaining 0155 virtual std::ostream& toStream(std::ostream& sl) const = 0; 0156 }; 0157 0158 /// Binning offset - overloaded for some R-binning types 0159 inline Vector3 VolumeBounds::referenceOffset( 0160 AxisDirection /*aDir*/) const { // standard offset is 0.,0.,0. 0161 return Vector3(0., 0., 0.); 0162 } 0163 0164 inline double VolumeBounds::referenceBorder(AxisDirection /*aDir*/) const { 0165 return 0.; 0166 } 0167 0168 /// Overload of << operator for std::ostream for debug output 0169 /// @param sl Output stream 0170 /// @param vb VolumeBounds to output 0171 /// @return Reference to output stream 0172 std::ostream& operator<<(std::ostream& sl, const VolumeBounds& vb); 0173 0174 /// Equality comparison for VolumeBounds 0175 /// @param lhs Left-hand side VolumeBounds 0176 /// @param rhs Right-hand side VolumeBounds 0177 /// @return True if bounds are equal 0178 inline bool operator==(const VolumeBounds& lhs, const VolumeBounds& rhs) { 0179 if (&lhs == &rhs) { 0180 return true; 0181 } 0182 return (lhs.type() == rhs.type()) && (lhs.values() == rhs.values()); 0183 } 0184 0185 /// Stream operator for VolumeBounds::BoundsType 0186 /// @param sl Output stream 0187 /// @param bt BoundsType to output 0188 /// @return Reference to output stream 0189 std::ostream& operator<<(std::ostream& sl, const VolumeBounds::BoundsType& bt); 0190 0191 } // namespace Acts
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|