Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-27 07:55:12

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/Utilities/BoundingBox.hpp"
0015 #include "Acts/Utilities/Logger.hpp"
0016 
0017 #include <iosfwd>
0018 #include <memory>
0019 #include <optional>
0020 
0021 namespace Acts {
0022 
0023 class VolumeBounds;
0024 
0025 /// @class Volume
0026 ///
0027 /// It inherits from GeometryObject for geometry identification
0028 ///
0029 /// Base class for all volumes inside the tracking realm, it defines the
0030 /// interface for inherited Volume classes regarding the geometrical
0031 /// information.
0032 class Volume : public GeometryObject {
0033  public:
0034   /// @brief Type alias for the axis-aligned bounding box of the volume
0035   /// @details Used to define the spatial extent of the volume in 3D space
0036   using BoundingBox = AxisAlignedBoundingBox<Volume, double, 3>;
0037 
0038   /// Explicit constructor with shared arguments
0039   ///
0040   /// @param transform is the transform to position the volume in 3D space
0041   /// @param volbounds is the volume boundary definitions
0042   Volume(const Transform3& transform, std::shared_ptr<VolumeBounds> volbounds);
0043 
0044   /// Copy Constructor - with optional shift
0045   ///
0046   /// @param vol is the source volume for the copy
0047   /// @param shift is the optional shift applied as : shift * vol.transform()
0048   Volume(const Volume& vol, const Transform3& shift = Transform3::Identity());
0049 
0050   ~Volume() noexcept override = default;
0051 
0052   /// Assignment operator
0053   ///
0054   /// @param vol is the source volume to be copied
0055   /// @return Reference to this volume for assignment chaining
0056   Volume& operator=(const Volume& vol);
0057 
0058   /// @brief Get the transform matrix that positions the volume in 3D space
0059   /// @return Const reference to the transform matrix
0060   const Transform3& transform() const;
0061 
0062   /// @brief Get the inverse transform matrix of the volume
0063   /// @return Const reference to the inverse transform matrix
0064   const Transform3& itransform() const;
0065 
0066   /// @brief Set the transform matrix for the volume and update internal state
0067   /// @param transform The new transform matrix to be applied
0068   void setTransform(const Transform3& transform);
0069 
0070   /// @brief Get the center position of the volume
0071   /// @return Const reference to the center position vector
0072   const Vector3& center() const;
0073 
0074   /// @brief Get the volume bounds that define the shape of the volume
0075   /// @return Const reference to the volume bounds object
0076   const VolumeBounds& volumeBounds() const;
0077 
0078   /// @brief Get mutable access to the volume bounds
0079   /// @return Reference to the volume bounds object
0080   VolumeBounds& volumeBounds();
0081 
0082   /// @brief Get shared pointer to the const volume bounds
0083   /// @return Const shared pointer to the volume bounds object
0084   std::shared_ptr<const VolumeBounds> volumeBoundsPtr() const;
0085 
0086   /// @brief Get shared pointer to the mutable volume bounds
0087   /// @return Shared pointer to the volume bounds object
0088   std::shared_ptr<VolumeBounds> volumeBoundsPtr();
0089 
0090   /// Set volume bounds and update volume bounding boxes implicitly
0091   /// @param volbounds The volume bounds to be assigned
0092   void assignVolumeBounds(std::shared_ptr<VolumeBounds> volbounds);
0093 
0094   /// Set the volume bounds and optionally also update the volume transform
0095   /// @param volbounds The volume bounds to be assigned
0096   /// @param transform The transform to be assigned, can be optional
0097   /// @param logger A logger object to log messages
0098   virtual void update(std::shared_ptr<VolumeBounds> volbounds,
0099                       std::optional<Transform3> transform = std::nullopt,
0100                       const Logger& logger = Acts::getDummyLogger());
0101 
0102   /// Construct bounding box for this shape
0103   /// @param envelope Optional envelope to add / subtract from min/max
0104   /// @return Constructed bounding box pointing to this volume
0105   BoundingBox boundingBox(const Vector3& envelope = {0, 0, 0}) const;
0106 
0107   /// Construct oriented bounding box for this shape
0108   /// @note This will build an oriented bounding box with an
0109   ///       envelope value of (0.05, 0.05, 0.05)mm
0110   /// @return Constructed oriented bounding box pointing to this volume
0111   BoundingBox orientedBoundingBox() const;
0112 
0113   /// Inside() method for checks
0114   ///
0115   /// @param gpos is the position to be checked
0116   /// @param tol is the tolerance parameter
0117   ///
0118   /// @return boolean indicator if the position is inside
0119   bool inside(const Vector3& gpos, double tol = 0.) const;
0120 
0121   /// The binning position method
0122   /// - as default the center is given, but may be overloaded
0123   ///
0124   /// @param gctx The current geometry context object, e.g. alignment
0125   /// @param aDir is the axis direction for the reference position
0126   /// @return vector 3D that can be used for the binning
0127   Vector3 referencePosition(const GeometryContext& gctx,
0128                             AxisDirection aDir) const override;
0129 
0130   /// @brief Compare this volume with another for equality
0131   /// @param other The other volume to compare with
0132   /// @return True if the volumes are equal
0133   bool operator==(const Volume& other) const;
0134 
0135   /// Produces a 3D visualization of this volume
0136   /// @param helper The visualization helper describing the output format
0137   /// @param gctx The geometry context
0138   /// @param viewConfig The view configuration
0139   void visualize(IVisualization3D& helper, const GeometryContext& gctx,
0140                  const ViewConfig& viewConfig) const;
0141 
0142  protected:
0143   /// @brief Transform matrix that positions the volume in 3D space
0144   Transform3 m_transform;
0145 
0146   /// @brief Inverse of the transform matrix for efficient calculations
0147   Transform3 m_itransform;
0148 
0149   /// @brief Center position of the volume in global coordinates
0150   Vector3 m_center;
0151 
0152  private:
0153   /// @brief Volume bounds that define the shape and extent of the volume
0154   std::shared_ptr<VolumeBounds> m_volumeBounds;
0155 };
0156 
0157 /**Overload of << operator for std::ostream for debug output*/
0158 /// @param sl Output stream
0159 /// @param vol Volume to output
0160 /// @return Reference to output stream
0161 std::ostream& operator<<(std::ostream& sl, const Volume& vol);
0162 
0163 }  // namespace Acts