Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-03 07:52:00

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/BoundarySurfaceFace.hpp"
0013 #include "Acts/Geometry/Volume.hpp"
0014 #include "Acts/Geometry/VolumeBounds.hpp"
0015 #include "Acts/Utilities/AxisDefinitions.hpp"
0016 #include "Acts/Utilities/BoundingBox.hpp"
0017 
0018 #include <array>
0019 #include <cmath>
0020 #include <cstddef>
0021 #include <iomanip>
0022 #include <iosfwd>
0023 #include <memory>
0024 #include <ostream>
0025 #include <stdexcept>
0026 #include <vector>
0027 
0028 namespace Acts {
0029 
0030 class RectangleBounds;
0031 
0032 /// @class CuboidVolumeBounds
0033 ///
0034 /// Bounds for a cubical Volume, the orientedSurfaces(...) method creates a
0035 /// vector of 6 surfaces:
0036 ///
0037 ///  BoundarySurfaceFace [index]:
0038 ///
0039 ///    - negativeFaceXY [0] : Rectangular Acts::PlaneSurface, parallel to \f$ xy
0040 /// \f$ plane at negative \f$ z \f$
0041 ///    - positiveFaceXY [1] : Rectangular Acts::PlaneSurface, parallel to \f$ xy
0042 /// \f$ plane at positive \f$ z \f$
0043 ///    - negativeFaceXY [2] : Rectangular Acts::PlaneSurface, attached to \f$ yz
0044 /// \f$ plane at negative \f$ x \f$
0045 ///    - positiveFaceXY [3] : Rectangular Acts::PlaneSurface, attached to \f$ yz
0046 /// \f$ plane at negative \f$ x \f$
0047 ///    - negativeFaceXY [4] : Rectangular Acts::PlaneSurface, parallel to \f$ zx
0048 /// \f$ plane at negative \f$ y \f$
0049 ///    - positiveFaceXY [5] : Rectangular Acts::PlaneSurface, parallel to \f$ zx
0050 /// \f$ plane at positive \f$ y \f$
0051 ///
0052 class CuboidVolumeBounds : public VolumeBounds {
0053  public:
0054   /// @enum BoundValues for streaming and access
0055   enum BoundValues : unsigned int {
0056     eHalfLengthX = 0,
0057     eHalfLengthY = 1,
0058     eHalfLengthZ = 2,
0059     eSize
0060   };
0061 
0062   /// Enum describing the possible faces of a cuboid volume
0063   /// @note These values are synchronized with the BoundarySurfaceFace enum.
0064   ///       Once Gen1 is removed, this can be changed.
0065   enum class Face : unsigned int {
0066     NegativeZFace = BoundarySurfaceFace::negativeFaceXY,
0067     PositiveZFace = BoundarySurfaceFace::positiveFaceXY,
0068     NegativeXFace = BoundarySurfaceFace::negativeFaceYZ,
0069     PositiveXFace = BoundarySurfaceFace::positiveFaceYZ,
0070     NegativeYFace = BoundarySurfaceFace::negativeFaceZX,
0071     PositiveYFace = BoundarySurfaceFace::positiveFaceZX
0072   };
0073 
0074   CuboidVolumeBounds() = delete;
0075 
0076   /// Constructor - the box boundaries
0077   ///
0078   /// @param halex is the half length of the cube in x
0079   /// @param haley is the half length of the cube in y
0080   /// @param halez is the half length of the cube in z
0081   CuboidVolumeBounds(double halex, double haley, double halez) noexcept(false);
0082 
0083   /// Constructor - from a fixed size array
0084   ///
0085   /// @param values iw the bound values
0086   explicit CuboidVolumeBounds(const std::array<double, eSize>& values);
0087 
0088   CuboidVolumeBounds(
0089       std::initializer_list<std::pair<BoundValues, double>> keyValues);
0090 
0091   /// Copy Constructor
0092   ///
0093   /// @param bobo is the source volume bounds to be copied
0094   CuboidVolumeBounds(const CuboidVolumeBounds& bobo) = default;
0095 
0096   /// Assignment operator
0097   ///
0098   /// @param bobo is the source volume bounds to be assigned
0099   CuboidVolumeBounds& operator=(const CuboidVolumeBounds& bobo) = default;
0100 
0101   ~CuboidVolumeBounds() override = default;
0102 
0103   VolumeBounds::BoundsType type() const final { return VolumeBounds::eCuboid; }
0104 
0105   /// Return the bound values as dynamically sized vector
0106   ///
0107   /// @return this returns a copy of the internal values
0108   std::vector<double> values() const final;
0109 
0110   /// This method checks if position in the 3D volume
0111   /// frame is inside the cylinder
0112   ///
0113   /// @param pos is the position in volume frame to be checked
0114   /// @param tol is the absolute tolerance to be applied
0115   bool inside(const Vector3& pos, double tol = 0.) const override;
0116 
0117   /// Oriented surfaces, i.e. the decomposed boundary surfaces and the
0118   /// according navigation direction into the volume given the normal
0119   /// vector on the surface
0120   ///
0121   /// @param transform is the 3D transform to be applied to the boundary
0122   /// surfaces to position them in 3D space
0123   ///
0124   /// It will throw an exception if the orientation prescription is not adequate
0125   ///
0126   /// @return a vector of surfaces bounding this volume
0127   std::vector<OrientedSurface> orientedSurfaces(
0128       const Transform3& transform = Transform3::Identity()) const override;
0129 
0130   /// Construct bounding box for this shape
0131   /// @param trf Optional transform
0132   /// @param envelope Optional envelope to add / subtract from min/max
0133   /// @param entity Entity to associate this bounding box with
0134   /// @return Constructed bounding box
0135   Volume::BoundingBox boundingBox(const Transform3* trf = nullptr,
0136                                   const Vector3& envelope = {0, 0, 0},
0137                                   const Volume* entity = nullptr) const final;
0138 
0139   /// Get the canonical binning direction, i.e. the binning directions
0140   /// for that fully describe the shape's extent
0141   ///
0142   /// @return vector of canonical binning values
0143   std::vector<AxisDirection> canonicalAxes() const override {
0144     using enum AxisDirection;
0145     return {AxisX, AxisY, AxisZ};
0146   };
0147 
0148   /// Binning borders in double
0149   ///
0150   /// @param aDir is the axis direction for which the
0151   /// reference border is requested
0152   ///
0153   /// @return float offset to be used for the binning
0154   double referenceBorder(AxisDirection aDir) const final;
0155 
0156   /// Access to the bound values
0157   /// @param bValue the class nested enum for the array access
0158   double get(BoundValues bValue) const { return m_values[bValue]; }
0159 
0160   /// Set a bound value
0161   /// @param bValue the bound value identifier
0162   /// @param value the value to be set
0163   void set(BoundValues bValue, double value);
0164 
0165   /// Set a range of bound values
0166   /// @param keyValues the initializer list of key value pairs
0167   void set(std::initializer_list<std::pair<BoundValues, double>> keyValues);
0168 
0169   /// Convert axis direction to a corresponding bound value
0170   /// in local coordinate convention
0171   /// @param direction the axis direction to convert
0172   static BoundValues boundsFromAxisDirection(AxisDirection direction);
0173 
0174   /// Convert axis direction to a set of corresponding cuboid faces
0175   /// in local coordinate convention
0176   /// @param direction the axis direction to convert
0177   /// @return A tuple of cuboid faces with the following ordering convention:
0178   /// (1) negative face orthogonal to the axis direction
0179   /// (2) positive face orthogonal to the axis direction
0180   /// (3) list of side faces parallel to the axis direction
0181   static std::tuple<Face, Face, std::array<Face, 4>> facesFromAxisDirection(
0182       AxisDirection direction);
0183 
0184   /// Output Method for std::ostream
0185   ///
0186   /// @param os is ostream operator to be dumped into
0187   std::ostream& toStream(std::ostream& os) const override;
0188 
0189  private:
0190   /// The bound values ordered in a fixed size array
0191   std::array<double, eSize> m_values;
0192 
0193   std::shared_ptr<const RectangleBounds> m_xyBounds{nullptr};
0194   std::shared_ptr<const RectangleBounds> m_yzBounds{nullptr};
0195   std::shared_ptr<const RectangleBounds> m_zxBounds{nullptr};
0196 
0197   /// Create the surface bounds
0198   void buildSurfaceBounds();
0199 
0200   /// Check the input values for consistency,
0201   /// will throw a logic_exception if consistency is not given
0202   void checkConsistency() noexcept(false);
0203 };
0204 
0205 std::ostream& operator<<(std::ostream& os, CuboidVolumeBounds::Face face);
0206 
0207 }  // namespace Acts