|
|
|||
File indexing completed on 2025-12-15 09:23:56
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 eDiamond, 0071 eOther, 0072 0073 }; 0074 0075 using enum BoundsType; 0076 0077 /// Static member to get the name of the BoundsType 0078 static const std::vector<std::string> s_boundsTypeNames; 0079 0080 VolumeBounds() = default; 0081 0082 virtual ~VolumeBounds() = default; 0083 0084 /// Return the bounds type - for persistency optimization 0085 /// 0086 /// @return is a BoundsType enum 0087 virtual BoundsType type() const = 0; 0088 0089 /// Access method for bound values, this is a dynamically sized 0090 /// vector containing the parameters needed to describe these bounds 0091 /// 0092 /// @return of the stored values for this SurfaceBounds object 0093 virtual std::vector<double> values() const = 0; 0094 0095 /// Checking if position given in volume frame is inside 0096 /// 0097 /// @param gpos is the global position to be checked 0098 /// @param tol is the tolerance applied for the inside check 0099 /// 0100 /// @return boolean indicating if the position is inside 0101 virtual bool inside(const Vector3& gpos, double tol = 0.) const = 0; 0102 0103 /// Oriented surfaces, i.e. the decomposed boundary surfaces and the 0104 /// according navigation direction into the volume given the normal 0105 /// vector on the surface 0106 /// 0107 /// @param transform is the 3D transform to be applied to the boundary 0108 /// surfaces to position them in 3D space 0109 /// 0110 /// It will throw an exception if the orientation prescription is not adequate 0111 /// 0112 /// @return a vector of surfaces bounding this volume 0113 virtual std::vector<OrientedSurface> orientedSurfaces( 0114 const Transform3& transform = Transform3::Identity()) const = 0; 0115 0116 /// Construct bounding box for this shape 0117 /// @param trf Optional transform 0118 /// @param envelope Optional envelope to add / subtract from min/max 0119 /// @param entity Entity to associate this bounding box with 0120 /// @return Constructed bounding box 0121 virtual Volume::BoundingBox boundingBox( 0122 const Transform3* trf = nullptr, const Vector3& envelope = {0, 0, 0}, 0123 const Volume* entity = nullptr) const = 0; 0124 0125 /// Get the canonical axis direction 0126 /// that fully describe the shape's extent 0127 /// 0128 /// @return vector of canonical axis directions 0129 /// 0130 /// @note This is the default implementation that 0131 /// returns the bounding box binning. Individual shapes 0132 /// should override this method 0133 virtual std::vector<AxisDirection> canonicalAxes() const { 0134 using enum AxisDirection; 0135 return {AxisX, AxisY, AxisZ}; 0136 }; 0137 0138 /// Binning offset - overloaded for some R-binning types 0139 /// 0140 /// @param aDir is the binning schema used 0141 /// 0142 /// @return vector 3D to be used for the binning 0143 virtual Vector3 referenceOffset(AxisDirection aDir) const; 0144 0145 /// Binning borders in double 0146 /// 0147 /// @param aDir is the binning schema used 0148 /// 0149 /// @return float offset to be used for the binning 0150 virtual double referenceBorder(AxisDirection aDir) const; 0151 0152 /// Output Method for std::ostream, to be overloaded by child classes 0153 /// 0154 /// @param sl is the output stream to be dumped into 0155 /// @return Modified ostream for chaining 0156 virtual std::ostream& toStream(std::ostream& sl) const = 0; 0157 }; 0158 0159 /// Binning offset - overloaded for some R-binning types 0160 inline Vector3 VolumeBounds::referenceOffset( 0161 AxisDirection /*aDir*/) const { // standard offset is 0.,0.,0. 0162 return Vector3(0., 0., 0.); 0163 } 0164 0165 inline double VolumeBounds::referenceBorder(AxisDirection /*aDir*/) const { 0166 return 0.; 0167 } 0168 0169 /// Overload of << operator for std::ostream for debug output 0170 /// @param sl Output stream 0171 /// @param vb VolumeBounds to output 0172 /// @return Reference to output stream 0173 std::ostream& operator<<(std::ostream& sl, const VolumeBounds& vb); 0174 0175 /// Equality comparison for VolumeBounds 0176 /// @param lhs Left-hand side VolumeBounds 0177 /// @param rhs Right-hand side VolumeBounds 0178 /// @return True if bounds are equal 0179 inline bool operator==(const VolumeBounds& lhs, const VolumeBounds& rhs) { 0180 if (&lhs == &rhs) { 0181 return true; 0182 } 0183 return (lhs.type() == rhs.type()) && (lhs.values() == rhs.values()); 0184 } 0185 0186 /// Stream operator for VolumeBounds::BoundsType 0187 /// @param sl Output stream 0188 /// @param bt BoundsType to output 0189 /// @return Reference to output stream 0190 std::ostream& operator<<(std::ostream& sl, const VolumeBounds::BoundsType& bt); 0191 0192 } // 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 |
|