Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:23:23

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2016-2020 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 http://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(ActsScalar minhalex, ActsScalar maxhalex,
0072                         ActsScalar haley, ActsScalar 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(ActsScalar minhalex, ActsScalar haley, ActsScalar halez,
0082                         ActsScalar alpha, ActsScalar beta) noexcept(false);
0083 
0084   /// Constructor - from a fixed size array
0085   ///
0086   /// @param values The bound values
0087   TrapezoidVolumeBounds(const std::array<ActsScalar, eSize>& values) noexcept(
0088       false)
0089       : m_values(values) {
0090     checkConsistency();
0091     buildSurfaceBounds();
0092   }
0093 
0094   TrapezoidVolumeBounds(const TrapezoidVolumeBounds& trabo) = default;
0095   ~TrapezoidVolumeBounds() override = default;
0096   TrapezoidVolumeBounds& operator=(const TrapezoidVolumeBounds& trabo) =
0097       default;
0098 
0099   VolumeBounds::BoundsType type() const final {
0100     return VolumeBounds::eTrapezoid;
0101   }
0102 
0103   /// Return the bound values as dynamically sized vector
0104   ///
0105   /// @return this returns a copy of the internal values
0106   std::vector<ActsScalar> values() const final;
0107 
0108   /// This method checks if position in the 3D volume frame
0109   /// is inside the cylinder
0110   ///
0111   /// @param pos is the global position to be checked
0112   /// @param tol is the tolerance applied
0113   ///
0114   /// @return boolean indicator if position is inside
0115   bool inside(const Vector3& pos, ActsScalar 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   /// Output Method for std::ostream
0140   /// @param os is the output stream
0141   std::ostream& toStream(std::ostream& os) const override;
0142 
0143   /// Access to the bound values
0144   /// @param bValue the class nested enum for the array access
0145   ActsScalar get(BoundValues bValue) const { return m_values[bValue]; }
0146 
0147  private:
0148   /// The internal version of the bounds can be float/ActsScalar
0149   std::array<ActsScalar, eSize> m_values{};
0150   /// The face PlaneSurface parallel to local xy plane
0151   std::shared_ptr<const TrapezoidBounds> m_faceXYTrapezoidBounds{nullptr};
0152   /// Thhe face PlaneSurface attached to alpha (negative local x)
0153   std::shared_ptr<const RectangleBounds> m_faceAlphaRectangleBounds{nullptr};
0154   /// The face PlaneSurface attached to beta (positive local x)
0155   std::shared_ptr<const RectangleBounds> m_faceBetaRectangleBounds{nullptr};
0156   /// The face PlaneSurface parallel to local zx plane, negative local y
0157   std::shared_ptr<const RectangleBounds> m_faceZXRectangleBoundsBottom{nullptr};
0158   /// The face PlaneSurface parallel to local zx plane, positive local y
0159   std::shared_ptr<const RectangleBounds> m_faceZXRectangleBoundsTop{nullptr};
0160 
0161   /// Check the input values for consistency,
0162   /// will throw a logic_exception if consistency is not given
0163   void checkConsistency() noexcept(false);
0164 
0165   /// Helper method to create the surface bounds
0166   void buildSurfaceBounds();
0167 };
0168 
0169 }  // namespace Acts