|
|
|||
File indexing completed on 2026-05-30 07:55:52
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 /// @return Constructed bounding box pointing to this volume 0133 BoundingBox boundingBox(const Vector3& envelope = {0, 0, 0}) const; 0134 0135 /// Construct oriented bounding box for this shape 0136 /// @note This will build an oriented bounding box with an 0137 /// envelope value of (0.05, 0.05, 0.05)mm 0138 /// @return Constructed oriented bounding box pointing to this volume 0139 BoundingBox orientedBoundingBox() const; 0140 0141 /// Inside() method for checks 0142 /// 0143 /// @param gctx The current geometry context object, e.g. alignment 0144 /// @param gpos is the position to be checked 0145 /// @param tol is the tolerance parameter 0146 /// 0147 /// @return boolean indicator if the position is inside 0148 bool inside(const GeometryContext& gctx, const Vector3& gpos, 0149 double tol = 0.) const; 0150 0151 /// The binning position method 0152 /// - as default the center is given, but may be overloaded 0153 /// 0154 /// @param gctx The current geometry context object, e.g. alignment 0155 /// @param aDir is the axis direction for the reference position 0156 /// @return vector 3D that can be used for the binning 0157 Vector3 referencePosition(const GeometryContext& gctx, 0158 AxisDirection aDir) const override; 0159 0160 /// Compare this volume with another for equality 0161 /// @param other The other volume to compare with 0162 /// @return True if the volumes are equal 0163 bool operator==(const Volume& other) const; 0164 0165 /// Produces a 3D visualization of this volume 0166 /// @param helper The visualization helper describing the output format 0167 /// @param gctx The geometry context 0168 /// @param viewConfig The view configuration 0169 void visualize(IVisualization3D& helper, const GeometryContext& gctx, 0170 const ViewConfig& viewConfig) const; 0171 0172 /// VolumePlacement object that dynamically aligns the volume 0173 /// @returns Pointer to the VolumePlacement (Might be nullptr) 0174 VolumePlacementBase* volumePlacement(); 0175 0176 /// VolumePlacement object that dynamically aligns the volume 0177 /// @returns Pointer to the VolumePlacement (Might be nullptr) 0178 const VolumePlacementBase* volumePlacement() const; 0179 0180 /// Is the volume connected to the experiment's alignment system 0181 /// (I.e. it's constructed with a volumePlacement) 0182 /// @returns Whether the volume can be externally aligned 0183 bool isAlignable() const; 0184 0185 private: 0186 /// Transform matrix that positions the volume in 3D space 0187 CloneablePtr<const Transform3> m_transform{}; 0188 0189 /// Inverse of the transform matrix for efficient calculations 0190 CloneablePtr<const Transform3> m_itransform{}; 0191 0192 /// Volume bounds that define the shape and extent of the volume 0193 std::shared_ptr<VolumeBounds> m_volumeBounds; 0194 /// Pointer to the external volume placement that's connected to the alignment 0195 VolumePlacementBase* m_placement{nullptr}; 0196 }; 0197 0198 /**Overload of << operator for std::ostream for debug output*/ 0199 /// @param sl Output stream 0200 /// @param vol Volume to output 0201 /// @return Reference to output stream 0202 std::ostream& operator<<(std::ostream& sl, const Volume& vol); 0203 0204 } // 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 |
|