Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-15 08:11: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/BoundarySurfaceFace.hpp"
0013 #include "Acts/Geometry/Volume.hpp"
0014 #include "Acts/Geometry/VolumeBounds.hpp"
0015 
0016 #include <array>
0017 #include <iomanip>
0018 #include <iosfwd>
0019 #include <memory>
0020 #include <ostream>
0021 #include <stdexcept>
0022 #include <vector>
0023 
0024 namespace Acts {
0025 
0026 class RectangleBounds;
0027 class TrapezoidBounds;
0028 
0029 /// @class TrapezoidVolumeBounds
0030 ///
0031 /// Bounds for a trapezoidal shaped Volume, the orientedSurface(...) method
0032 /// creates a vector of 6 surfaces:
0033 ///
0034 ///  BoundarySurfaceFace [index]:
0035 ///
0036 ///  - negativeFaceXY     [0] : Trazpezoidal Acts::PlaneSurface,
0037 ///                             parallel to \f$ xy \f$ plane at negative \f$z\f$
0038 ///  - positiveFaceXY     [1] : Trazpezoidal Acts::PlaneSurface,
0039 ///                             parallel to \f$ xy \f$ plane at positive \f$z\f$
0040 ///  - trapezoidFaceAlpha [2] : Rectangular  Acts::PlaneSurface,
0041 ///                             attached to [0] and [1] at negative \f$x\f$
0042 ///  (associated to alpha)
0043 ///  - trapezoidFaceBeta  [3] : Rectangular  Acts::PlaneSurface,
0044 ///                             attached to [0] and [1] at positive \f$ x\f$
0045 ///  (associated to beta)
0046 ///  - negativeFaceZX     [4] : Rectangular  Acts::PlaneSurface,
0047 ///                             parallel to \f$ zx \f$ plane at negative \f$y\f$
0048 ///  - positiveFaceZX     [5] : Rectangular  Acts::PlaneSurface,
0049 ///                             parallel to \f$ zx \f$ plane at positive \f$y\f$
0050 ///
0051 /// ```
0052 /// PositiveZFaceXY--------+          PositiveYFaceZX
0053 ///                        |                   |
0054 /// TrapezoidFaceAlpha     |                   v
0055 ///          |             | +----------------------------------+
0056 ///          |             v |                                  |
0057 ///          |    +       +--+------------------------------++  |
0058 ///          |   /|      /   |                            +-+   |
0059 ///          |  / |     /    |                          +-+     |           +
0060 ///      +---+ /  |    /     |                        +-+       |          ++
0061 ///      |    /   |   /      +----------------------+-+---------+        +-+|
0062 ///      |   /    |  /                            +-+                  +-+  |
0063 ///      |  /     + /                           +-+                  +-+    |
0064 ///      | /     / /                          +-+                  +-+      |
0065 ///      v/     / /                         +-+                  +-+        +
0066 ///      /     / /                        +-+                  +-+         +-
0067 ///     /     / /    +------------------+-+------------++    +-+         +-+
0068 ///    /     / /    /                 +-+            +-+   +-+         +-+
0069 ///   /     / /    /                +-+            +-+   +-+         +-+
0070 ///  /     / +----X-----------------+            +-+   +-+         +-+
0071 /// +     /      /                             +-+   +-+         +-+
0072 /// | +--X------X------------+               +-+    -+         +-+
0073 /// | | /      /             |             +-+     +         +-+
0074 /// | |/      /              |           +-+       |       +-+  ^
0075 /// | X      /               |         +-+         |     +-+    |
0076 /// |/|     /                |       +-+           |   +-+      |
0077 /// + |    /                 |     +-+             | +-+        |  z ^   ^ y
0078 ///   +---X------------------+   +-+  ^            |-+    +-----+    |  /
0079 ///      /        ^            +-+    |            +      |          | /
0080 ///     +---------++-----------+      |                   |          |/
0081 ///                |                  |                   |          X------> x
0082 ///       NegativeYFaceZX      NegativeZFaceXY            |
0083 ///                                              TrapezoidFaceBeta
0084 /// ```
0085 class TrapezoidVolumeBounds : public VolumeBounds {
0086  public:
0087   /// @enum BoundValues for access / streaming
0088   enum BoundValues : unsigned int {
0089     eHalfLengthXnegY = 0,  //!< halflength in x at negative y
0090     eHalfLengthXposY = 1,  //!< halflength in x at positive y
0091     eHalfLengthY = 2,      //!< halflength in y
0092     eHalfLengthZ = 3,      //!< halflength in z
0093     eAlpha = 4,            //!< opening angle alpha (in point A)
0094     eBeta = 5,             //!< opening angle beta  (in point B)
0095     eSize                  //!< length of the bounds vector
0096   };
0097 
0098   /// Enum describing the possible faces of a trapezoidal volume
0099   /// @note These values are synchronized with the BoundarySurfaceFace enum.
0100   ///       Once Gen1 is removed, this can be changed.
0101   enum class Face : unsigned int {
0102 
0103     NegativeZFaceXY = BoundarySurfaceFace::negativeFaceXY,
0104     PositiveZFaceXY = BoundarySurfaceFace::positiveFaceXY,
0105     TrapezoidFaceAlpha =
0106         BoundarySurfaceFace::trapezoidFaceAlpha,  // Acts::PlaneSurface attached
0107                                                   // to [0] and [1] at negative
0108                                                   // x
0109     TrapezoidFaceBeta =
0110         BoundarySurfaceFace::trapezoidFaceBeta,  // Acts::PlaneSurface attached
0111                                                  // to [0] and [1] at positive x
0112     NegativeYFaceZX = BoundarySurfaceFace::negativeFaceZX,
0113     PositiveYFaceZX = BoundarySurfaceFace::positiveFaceZX
0114 
0115   };
0116 
0117   TrapezoidVolumeBounds() = delete;
0118 
0119   /// Constructor - the trapezoid boundaries (symmetric trapezoid)
0120   ///
0121   /// @param minhalex is the half length in x at minimal y
0122   /// @param maxhalex is the half length in x at maximal y
0123   /// @param haley is the half length in y
0124   /// @param halez is the half length in z
0125   TrapezoidVolumeBounds(double minhalex, double maxhalex, double haley,
0126                         double halez) noexcept(false);
0127 
0128   /// Constructor - the trapezoid boundaries (arbitrary trapezoid)
0129   ///
0130   /// @param minhalex is the half length in x at minimal y
0131   /// @param haley is the half length in y
0132   /// @param halez is the half length in z
0133   /// @param alpha is the opening angle at -x,-y
0134   /// @param beta is the opening angle at +x,-y
0135   TrapezoidVolumeBounds(double minhalex, double haley, double halez,
0136                         double alpha, double beta) noexcept(false);
0137 
0138   /// Constructor - from a fixed size array
0139   ///
0140   /// @param values The bound values
0141   explicit TrapezoidVolumeBounds(
0142       const std::array<double, eSize>& values) noexcept(false)
0143       : m_values(values) {
0144     checkConsistency();
0145     buildSurfaceBounds();
0146   }
0147 
0148   TrapezoidVolumeBounds(const TrapezoidVolumeBounds& trabo) = default;
0149   ~TrapezoidVolumeBounds() override = default;
0150   TrapezoidVolumeBounds& operator=(const TrapezoidVolumeBounds& trabo) =
0151       default;
0152 
0153   VolumeBounds::BoundsType type() const final {
0154     return VolumeBounds::eTrapezoid;
0155   }
0156 
0157   /// Return the bound values as dynamically sized vector
0158   ///
0159   /// @return this returns a copy of the internal values
0160   std::vector<double> values() const final;
0161 
0162   /// This method checks if position in the 3D volume frame
0163   /// is inside the cylinder
0164   ///
0165   /// @param pos is the global position to be checked
0166   /// @param tol is the tolerance applied
0167   ///
0168   /// @return boolean indicator if position is inside
0169   bool inside(const Vector3& pos, double tol = 0.) const override;
0170 
0171   /// Oriented surfaces, i.e. the decomposed boundary surfaces and the
0172   /// according navigation direction into the volume given the normal
0173   /// vector on the surface
0174   ///
0175   /// @param transform is the 3D transform to be applied to the boundary
0176   /// surfaces to position them in 3D space
0177   ///
0178   /// It will throw an exception if the orientation prescription is not adequate
0179   ///
0180   /// @return a vector of surfaces bounding this volume
0181   std::vector<OrientedSurface> orientedSurfaces(
0182       const Transform3& transform = Transform3::Identity()) const override;
0183 
0184   /// Construct bounding box for this shape
0185   /// @param trf Optional transform
0186   /// @param envelope Optional envelope to add / subtract from min/max
0187   /// @param entity Entity to associate this bounding box with
0188   /// @return Constructed bounding box
0189   Volume::BoundingBox boundingBox(const Transform3* trf = nullptr,
0190                                   const Vector3& envelope = {0, 0, 0},
0191                                   const Volume* entity = nullptr) const final;
0192 
0193   /// Output Method for std::ostream
0194   /// @param os is the output stream
0195   std::ostream& toStream(std::ostream& os) const override;
0196 
0197   /// Access to the bound values
0198   /// @param bValue the class nested enum for the array access
0199   double get(BoundValues bValue) const { return m_values[bValue]; }
0200 
0201  private:
0202   /// The internal version of the bounds can be float/double
0203   std::array<double, eSize> m_values{};
0204   /// The face PlaneSurface parallel to local xy plane
0205   std::shared_ptr<const TrapezoidBounds> m_faceXYTrapezoidBounds{nullptr};
0206   /// Thhe face PlaneSurface attached to alpha (negative local x)
0207   std::shared_ptr<const RectangleBounds> m_faceAlphaRectangleBounds{nullptr};
0208   /// The face PlaneSurface attached to beta (positive local x)
0209   std::shared_ptr<const RectangleBounds> m_faceBetaRectangleBounds{nullptr};
0210   /// The face PlaneSurface parallel to local zx plane, negative local y
0211   std::shared_ptr<const RectangleBounds> m_faceZXRectangleBoundsBottom{nullptr};
0212   /// The face PlaneSurface parallel to local zx plane, positive local y
0213   std::shared_ptr<const RectangleBounds> m_faceZXRectangleBoundsTop{nullptr};
0214 
0215   /// Check the input values for consistency,
0216   /// will throw a logic_exception if consistency is not given
0217   void checkConsistency() noexcept(false);
0218 
0219   /// Helper method to create the surface bounds
0220   void buildSurfaceBounds();
0221 };
0222 
0223 }  // namespace Acts