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