Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:10:53

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   using BoundingBox = AxisAlignedBoundingBox<Volume, double, 3>;
0035 
0036   /// Explicit constructor with shared arguments
0037   ///
0038   /// @param transform is the transform to position the volume in 3D space
0039   /// @param volbounds is the volume boundary definitions
0040   Volume(const Transform3& transform, std::shared_ptr<VolumeBounds> volbounds);
0041 
0042   /// Copy Constructor - with optional shift
0043   ///
0044   /// @param vol is the source volume for the copy
0045   /// @param shift is the optional shift applied as : shift * vol.transform()
0046   Volume(const Volume& vol, const Transform3& shift = Transform3::Identity());
0047 
0048   Volume() = delete;
0049   virtual ~Volume() = default;
0050 
0051   /// Assignment operator
0052   ///
0053   /// @param vol is the source volume to be copied
0054   Volume& operator=(const Volume& vol);
0055 
0056   /// Return methods for geometry transform
0057   const Transform3& transform() const;
0058 
0059   /// Returns the inverted transform of this volume.
0060   const Transform3& itransform() const;
0061 
0062   void setTransform(const Transform3& transform);
0063 
0064   /// returns the center of the volume
0065   const Vector3& center() const;
0066 
0067   /// Returns a const reference to the volume bounds
0068   const VolumeBounds& volumeBounds() const;
0069 
0070   /// Returns a mutable reference to the volume bounds
0071   VolumeBounds& volumeBounds();
0072 
0073   /// Returns shared pointer to the volume bounds
0074   std::shared_ptr<const VolumeBounds> volumeBoundsPtr() const;
0075 
0076   /// Returns shared pointer to the volume bounds
0077   std::shared_ptr<VolumeBounds> volumeBoundsPtr();
0078 
0079   /// Set volume bounds and update volume bounding boxes implicitly
0080   /// @param volbounds The volume bounds to be assigned
0081   void assignVolumeBounds(std::shared_ptr<VolumeBounds> volbounds);
0082 
0083   /// Set the volume bounds and optionally also update the volume transform
0084   /// @param volbounds The volume bounds to be assigned
0085   /// @param transform The transform to be assigned, can be optional
0086   /// @param logger A logger object to log messages
0087   virtual void update(std::shared_ptr<VolumeBounds> volbounds,
0088                       std::optional<Transform3> transform = std::nullopt,
0089                       const Logger& logger = Acts::getDummyLogger());
0090 
0091   /// Construct bounding box for this shape
0092   /// @param envelope Optional envelope to add / subtract from min/max
0093   /// @return Constructed bounding box pointing to this volume
0094   BoundingBox boundingBox(const Vector3& envelope = {0, 0, 0}) const;
0095 
0096   /// Construct oriented bounding box for this shape
0097   /// @note This will build an oriented bounding box with an
0098   ///       envelope value of (0.05, 0.05, 0.05)mm
0099   /// @return Constructed oriented bounding box pointing to this volume
0100   BoundingBox orientedBoundingBox() const;
0101 
0102   /// Inside() method for checks
0103   ///
0104   /// @param gpos is the position to be checked
0105   /// @param tol is the tolerance parameter
0106   ///
0107   /// @return boolean indicator if the position is inside
0108   bool inside(const Vector3& gpos, double tol = 0.) const;
0109 
0110   /// The binning position method
0111   /// - as default the center is given, but may be overloaded
0112   ///
0113   /// @param gctx The current geometry context object, e.g. alignment
0114   /// @param aDir is the axis direction for the reference position
0115   /// @return vector 3D that can be used for the binning
0116   Vector3 referencePosition(const GeometryContext& gctx,
0117                             AxisDirection aDir) const override;
0118 
0119   bool operator==(const Volume& other) const;
0120 
0121   /// Produces a 3D visualization of this volume
0122   /// @param helper The visualization helper describing the output format
0123   /// @param gctx The geometry context
0124   /// @param viewConfig The view configuration
0125   void visualize(IVisualization3D& helper, const GeometryContext& gctx,
0126                  const ViewConfig& viewConfig) const;
0127 
0128  protected:
0129   Transform3 m_transform;
0130   Transform3 m_itransform;
0131   Vector3 m_center;
0132 
0133  private:
0134   std::shared_ptr<VolumeBounds> m_volumeBounds;
0135 };
0136 
0137 /**Overload of << operator for std::ostream for debug output*/
0138 std::ostream& operator<<(std::ostream& sl, const Volume& vol);
0139 
0140 }  // namespace Acts