|
|
|||
File indexing completed on 2026-03-29 07:46:36
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 /// Helper bundle of a surface and its orientation. 0031 struct OrientedSurface { 0032 std::shared_ptr<RegularSurface> surface; ///< The surface 0033 Direction direction = Direction::AlongNormal(); ///< Surface orientation 0034 }; 0035 0036 /// XY plane transformation (identity) 0037 static const Transform3 s_planeXY = Transform3::Identity(); 0038 /// YZ plane transformation 0039 static const Transform3 s_planeYZ = 0040 AngleAxis3(std::numbers::pi / 2., Vector3::UnitY()) * 0041 AngleAxis3(std::numbers::pi / 2., Vector3::UnitZ()) * 0042 Transform3::Identity(); 0043 /// ZX plane transformation 0044 static const Transform3 s_planeZX = 0045 AngleAxis3(-std::numbers::pi / 2., Vector3::UnitX()) * 0046 AngleAxis3(-std::numbers::pi / 2., Vector3::UnitZ()) * 0047 Transform3::Identity(); 0048 0049 /// @class VolumeBounds 0050 /// 0051 /// Pure Absract Base Class for Volume bounds. 0052 /// 0053 /// Acts::VolumeBounds are a set of up to six confining Surfaces that are stored 0054 /// in a std::vector. 0055 /// Each type of Acts::VolumeBounds has to implement a orientedSurfaces() and 0056 /// a inside() method. 0057 /// 0058 /// The Volume, retrieving a set of Surfaces from the VolumeBounds, can turn the 0059 /// Surfaces into BoundarySurfaces. 0060 0061 class VolumeBounds { 0062 public: 0063 // @enum BoundsType 0064 /// This is nested to the VolumeBounds, as also SurfaceBounds will have 0065 /// Bounds Type. 0066 enum class BoundsType { 0067 eCone, 0068 eCuboid, 0069 eCutoutCylinder, 0070 eCylinder, 0071 eGenericCuboid, 0072 eTrapezoid, 0073 eDiamond, 0074 eOther, 0075 0076 }; 0077 0078 using enum BoundsType; 0079 0080 /// Static member to get the name of the BoundsType 0081 static const std::vector<std::string> s_boundsTypeNames; 0082 0083 VolumeBounds() = default; 0084 0085 virtual ~VolumeBounds() = default; 0086 0087 /// Return the bounds type - for persistency optimization 0088 /// 0089 /// @return is a BoundsType enum 0090 virtual BoundsType type() const = 0; 0091 0092 /// Access method for bound values, this is a dynamically sized 0093 /// vector containing the parameters needed to describe these bounds 0094 /// 0095 /// @return of the stored values for this SurfaceBounds object 0096 virtual std::vector<double> values() const = 0; 0097 0098 /// Checking if position given in volume frame is inside 0099 /// 0100 /// @param gpos is the global position to be checked 0101 /// @param tol is the tolerance applied for the inside check 0102 /// 0103 /// @return boolean indicating if the position is inside 0104 virtual bool inside(const Vector3& gpos, double tol = 0.) const = 0; 0105 0106 /// Oriented surfaces, i.e. the decomposed boundary surfaces and the 0107 /// according navigation direction into the volume given the normal 0108 /// vector on the surface 0109 /// 0110 /// @param transform is the 3D transform to be applied to the boundary 0111 /// surfaces to position them in 3D space 0112 /// 0113 /// It will throw an exception if the orientation prescription is not adequate 0114 /// 0115 /// @return a vector of surfaces bounding this volume 0116 virtual std::vector<OrientedSurface> orientedSurfaces( 0117 const Transform3& transform = Transform3::Identity()) const = 0; 0118 0119 /// Construct bounding box for this shape 0120 /// @param trf Optional transform 0121 /// @param envelope Optional envelope to add / subtract from min/max 0122 /// @param entity Entity to associate this bounding box with 0123 /// @return Constructed bounding box 0124 virtual Volume::BoundingBox boundingBox( 0125 const Transform3* trf = nullptr, const Vector3& envelope = {0, 0, 0}, 0126 const Volume* entity = nullptr) const = 0; 0127 0128 /// Get the canonical axis direction 0129 /// that fully describe the shape's extent 0130 /// 0131 /// @return vector of canonical axis directions 0132 /// 0133 /// @note This is the default implementation that 0134 /// returns the bounding box binning. Individual shapes 0135 /// should override this method 0136 virtual std::vector<AxisDirection> canonicalAxes() const { 0137 using enum AxisDirection; 0138 return {AxisX, AxisY, AxisZ}; 0139 }; 0140 0141 /// Binning offset - overloaded for some R-binning types 0142 /// 0143 /// @param aDir is the binning schema used 0144 /// 0145 /// @return vector 3D to be used for the binning 0146 virtual Vector3 referenceOffset(AxisDirection aDir) const; 0147 0148 /// Binning borders in double 0149 /// 0150 /// @param aDir is the binning schema used 0151 /// 0152 /// @return float offset to be used for the binning 0153 virtual double referenceBorder(AxisDirection aDir) const; 0154 0155 /// Output Method for std::ostream, to be overloaded by child classes 0156 /// 0157 /// @param sl is the output stream to be dumped into 0158 /// @return Modified ostream for chaining 0159 virtual std::ostream& toStream(std::ostream& sl) const = 0; 0160 }; 0161 0162 /// Binning offset - overloaded for some R-binning types 0163 inline Vector3 VolumeBounds::referenceOffset( 0164 AxisDirection /*aDir*/) const { // standard offset is 0.,0.,0. 0165 return Vector3(0., 0., 0.); 0166 } 0167 0168 inline double VolumeBounds::referenceBorder(AxisDirection /*aDir*/) const { 0169 return 0.; 0170 } 0171 0172 /// Overload of << operator for std::ostream for debug output 0173 /// @param sl Output stream 0174 /// @param vb VolumeBounds to output 0175 /// @return Reference to output stream 0176 std::ostream& operator<<(std::ostream& sl, const VolumeBounds& vb); 0177 0178 /// Equality comparison for VolumeBounds 0179 /// @param lhs Left-hand side VolumeBounds 0180 /// @param rhs Right-hand side VolumeBounds 0181 /// @return True if bounds are equal 0182 inline bool operator==(const VolumeBounds& lhs, const VolumeBounds& rhs) { 0183 if (&lhs == &rhs) { 0184 return true; 0185 } 0186 return (lhs.type() == rhs.type()) && (lhs.values() == rhs.values()); 0187 } 0188 0189 /// Stream operator for VolumeBounds::BoundsType 0190 /// @param sl Output stream 0191 /// @param bt BoundsType to output 0192 /// @return Reference to output stream 0193 std::ostream& operator<<(std::ostream& sl, const VolumeBounds::BoundsType& bt); 0194 0195 } // 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 |
|