|
|
|||
File indexing completed on 2026-08-28 08:20:37
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/Geometry/GeometryContext.hpp" 0013 #include "Acts/Geometry/GeometryObject.hpp" 0014 #include "Acts/Geometry/VolumePlacementBase.hpp" 0015 #include "Acts/Utilities/BoundingBox.hpp" 0016 #include "Acts/Utilities/CloneablePtr.hpp" 0017 #include "Acts/Utilities/Logger.hpp" 0018 0019 #include <iosfwd> 0020 #include <memory> 0021 #include <optional> 0022 0023 namespace Acts { 0024 0025 class VolumeBounds; 0026 0027 /// @class Volume 0028 /// 0029 /// It inherits from GeometryObject for geometry identification 0030 /// 0031 /// Base class for all volumes inside the tracking realm, it defines the 0032 /// interface for inherited Volume classes regarding the geometrical 0033 /// information. 0034 class Volume : public GeometryObject { 0035 public: 0036 /// Type alias for the axis-aligned bounding box of the volume 0037 /// @details Used to define the spatial extent of the volume in 3D space 0038 using BoundingBox = AxisAlignedBoundingBox<Volume, double, 3>; 0039 0040 /// Explicit constructor with shared arguments 0041 /// 0042 /// @param transform is the transform to position the volume in 3D space 0043 /// @param volbounds is the volume boundary definitions 0044 Volume(const Transform3& transform, 0045 std::shared_ptr<VolumeBounds> volbounds) noexcept; 0046 /// Constructor that connects the volume to an external alignment 0047 /// I.e. the volume may move with the alignment of the surfaces 0048 /// The placement of the volume is delegated to the positioner 0049 /// @param positioner: Reference to the object aligning the volume 0050 /// @param volbounds is the volume boundary definitions 0051 Volume(VolumePlacementBase& positioner, 0052 std::shared_ptr<VolumeBounds> volbounds) noexcept; 0053 0054 /// Copy Constructor 0055 /// @param vol is the source volume for the copy 0056 Volume(const Volume& vol) noexcept = default; 0057 0058 /// Shift the volume by a transform 0059 /// 0060 /// @param shift is the transform to shift the volume by 0061 /// @param gctx The current geometry context object, e.g. alignment 0062 /// @return The shifted volume 0063 Volume shifted(const GeometryContext& gctx, const Transform3& shift) const; 0064 0065 ~Volume() noexcept override = default; 0066 0067 /// Assignment operator 0068 /// 0069 /// @param vol is the source volume to be copied 0070 /// @return Reference to this volume for assignment chaining 0071 Volume& operator=(const Volume& vol) noexcept = default; 0072 0073 /// Move assignment operator 0074 /// 0075 /// @param other is the other volume to be moved 0076 /// @return Reference to this volume for assignment chaining 0077 Volume& operator=(Volume&& other) noexcept = default; 0078 0079 /// Get the transformation matrix from the local volume frame to the global 0080 /// experiment's frame 0081 /// @param gctx The current geometry context object, e.g. alignment 0082 /// @return The local to global transformation matrix 0083 const Transform3& localToGlobalTransform(const GeometryContext& gctx) const; 0084 0085 /// Get the transformation matrix from the global experiment's frame to the 0086 /// local volume frame 0087 /// @param gctx The current geometry context object, e.g. alignment 0088 /// @return The global to local transformation matrix 0089 const Transform3& globalToLocalTransform(const GeometryContext& gctx) const; 0090 0091 /// Set the transform matrix for the volume and update internal state 0092 /// @param transform The new transform matrix to be applied 0093 void setTransform(const Transform3& transform); 0094 0095 /// Get the center position of the volume 0096 /// @param gctx The current geometry context object, e.g. alignment 0097 /// @return Const reference to the center position vector 0098 Vector3 center(const GeometryContext& gctx) const; 0099 0100 /// Get the volume bounds that define the shape of the volume 0101 /// @return Const reference to the volume bounds object 0102 const VolumeBounds& volumeBounds() const; 0103 0104 /// Get mutable access to the volume bounds 0105 /// @return Reference to the volume bounds object 0106 VolumeBounds& volumeBounds(); 0107 0108 /// Get shared pointer to the const volume bounds 0109 /// @return Const shared pointer to the volume bounds object 0110 std::shared_ptr<const VolumeBounds> volumeBoundsPtr() const; 0111 0112 /// Get shared pointer to the mutable volume bounds 0113 /// @return Shared pointer to the volume bounds object 0114 std::shared_ptr<VolumeBounds> volumeBoundsPtr(); 0115 0116 /// Set volume bounds and update volume bounding boxes implicitly 0117 /// @param volbounds The volume bounds to be assigned 0118 void assignVolumeBounds(std::shared_ptr<VolumeBounds> volbounds); 0119 0120 /// Set the volume bounds and optionally also update the volume transform 0121 /// @param gctx The current geometry context object, e.g. alignment 0122 /// @param volbounds The volume bounds to be assigned 0123 /// @param transform The transform to be assigned, can be optional 0124 /// @param logger A logger object to log messages 0125 virtual void update(const GeometryContext& gctx, 0126 std::shared_ptr<VolumeBounds> volbounds, 0127 std::optional<Transform3> transform = std::nullopt, 0128 const Logger& logger = Acts::getDummyLogger()); 0129 0130 /// Construct bounding box for this shape 0131 /// @param envelope Optional envelope to add / subtract from min/max 0132 /// @param gctx The current geometry context object, e.g. alignment 0133 /// @return Constructed bounding box pointing to this volume 0134 BoundingBox boundingBox(const GeometryContext& gctx, 0135 const Vector3& envelope = Vector3::Zero()) const; 0136 0137 /// Construct oriented bounding box for this shape 0138 /// @note This will build an oriented bounding box with an 0139 /// envelope value of (0.05, 0.05, 0.05)mm 0140 /// @return Constructed oriented bounding box pointing to this volume 0141 BoundingBox orientedBoundingBox() const; 0142 0143 /// Inside() method for checks 0144 /// 0145 /// @param gctx The current geometry context object, e.g. alignment 0146 /// @param gpos is the position to be checked 0147 /// @param tol is the tolerance parameter 0148 /// 0149 /// @return boolean indicator if the position is inside 0150 bool inside(const GeometryContext& gctx, const Vector3& gpos, 0151 double tol = 0.) const; 0152 0153 /// The binning position method 0154 /// - as default the center is given, but may be overloaded 0155 /// 0156 /// @param gctx The current geometry context object, e.g. alignment 0157 /// @param aDir is the axis direction for the reference position 0158 /// @return vector 3D that can be used for the binning 0159 Vector3 referencePosition(const GeometryContext& gctx, 0160 AxisDirection aDir) const override; 0161 0162 /// Compare this volume with another for equality 0163 /// @param other The other volume to compare with 0164 /// @return True if the volumes are equal 0165 bool operator==(const Volume& other) const; 0166 0167 /// Produces a 3D visualization of this volume 0168 /// @param helper The visualization helper describing the output format 0169 /// @param gctx The geometry context 0170 /// @param viewConfig The view configuration 0171 void visualize(IVisualization3D& helper, const GeometryContext& gctx, 0172 const ViewConfig& viewConfig) const; 0173 0174 /// VolumePlacement object that dynamically aligns the volume 0175 /// @returns Pointer to the VolumePlacement (Might be nullptr) 0176 VolumePlacementBase* volumePlacement(); 0177 0178 /// VolumePlacement object that dynamically aligns the volume 0179 /// @returns Pointer to the VolumePlacement (Might be nullptr) 0180 const VolumePlacementBase* volumePlacement() const; 0181 0182 /// Is the volume connected to the experiment's alignment system 0183 /// (I.e. it's constructed with a volumePlacement) 0184 /// @returns Whether the volume can be externally aligned 0185 bool isAlignable() const; 0186 0187 private: 0188 /// Transform matrix that positions the volume in 3D space 0189 CloneablePtr<const Transform3> m_transform{}; 0190 0191 /// Inverse of the transform matrix for efficient calculations 0192 CloneablePtr<const Transform3> m_itransform{}; 0193 0194 /// Volume bounds that define the shape and extent of the volume 0195 std::shared_ptr<VolumeBounds> m_volumeBounds; 0196 /// Pointer to the external volume placement that's connected to the alignment 0197 VolumePlacementBase* m_placement{nullptr}; 0198 }; 0199 0200 /**Overload of << operator for std::ostream for debug output*/ 0201 /// @param sl Output stream 0202 /// @param vol Volume to output 0203 /// @return Reference to output stream 0204 std::ostream& operator<<(std::ostream& sl, const Volume& vol); 0205 0206 } // 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 |
|