Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-13 09:20:36

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 <iosfwd>
0018 #include <memory>
0019 #include <ostream>
0020 #include <vector>
0021 
0022 namespace Acts {
0023 
0024 class RectangleBounds;
0025 class DiamondBounds;
0026 
0027 /// @class DiamondVolumeBounds
0028 ///
0029 /// Bounds for a polygonal prism shaped Volume, the orientedSurface(...) method
0030 /// creates a vector of 8 surfaces:
0031 /// 2 Diamond Shape Surfaces (see
0032 /// @image html DiamondBounds.svg)
0033 /// and 6 Rectangular Shape Surfaces.
0034 ///
0035 ///  BoundarySurfaceFace [index]:
0036 ///
0037 ///  - negativeFaceXY     [0] : Diamond Acts::PlaneSurface,
0038 ///                             parallel to \f$ xy \f$ plane at negative \f$ z \f$
0039 ///  - positiveFaceXY     [1] : Diamond Acts::PlaneSurface,
0040 ///                             parallel to \f$ xy \f$ plane at positive \f$ z \f$
0041 ///  - negativeXFaceYZ12  [2] : Rectangular  Acts::PlaneSurface,
0042 ///                             parallel to \f$ yz \f$ plane at negative \f$ x \f$ attached at [-x1,-y1] and [-x2,0]
0043 ///  - positiveXFaceYZ12  [3] : Rectangular  Acts::PlaneSurface,
0044 ///                             parallel to \f$ yz \f$ plane at positive \f$ x \f$ attached at [x1,-y1] and [x2,0]
0045 ///  - negativeXFaceYZ23  [4] : Rectangular  Acts::PlaneSurface,
0046 ///                             parallel to \f$ yz \f$ plane at negative \f$ x \f$ attached at [-x2,0] and [-x3,y2]
0047 ///  - positiveXFaceYZ23  [5] : Rectangular  Acts::PlaneSurface,
0048 ///                             parallel to \f$ yz \f$ plane at positive \f$ x \f$ attached at [x2,0] and [x3,y2]
0049 ///  - negativeYFaceZX   [6] : Rectangular  Acts::PlaneSurface,
0050 ///                             parallel to \f$ zx \f$ plane at negative \f$ y \f$
0051 ///  - positiveYFaceZX   [7] : Rectangular  Acts::PlaneSurface,
0052 ///                             parallel to \f$ zx \f$ plane at positive \f$ y \f$
0053 ///
0054 class DiamondVolumeBounds : public VolumeBounds {
0055  public:
0056   /// @enum BoundValues for access / streaming
0057   enum BoundValues : unsigned int {
0058     eHalfLengthX1 = 0,  //!< half length in x at positive y1
0059     eHalfLengthX2 = 1,  //!< half length in x at y=0
0060     eHalfLengthX3 = 2,  //!< half length in x at negative y2
0061     eLengthY1 = 3,      //!<  length in positive y1
0062     eLengthY2 = 4,      //!<  length in negative y2
0063     eHalfLengthZ = 5,   //!< half length in z
0064     eAlphaAngle = 6,    //!< angle alpha between negYFaceZX and faceYZ12
0065     eBetaAngle = 7,     //!< angle beta between FaceYZ12 and FaceYZ23
0066     eSize               //!< length of the bounds vector
0067   };
0068 
0069   enum class Face : unsigned int {
0070 
0071     NegativeZFaceXY = 0,
0072     PositiveZFaceXY = 1,
0073     NegativeXFaceYZ12 = 2,  // Acts::PlaneSurface attached to [-x1,-y1] and
0074                             // [-x2,0] at negative x
0075     PositiveXFaceYZ12 =
0076         3,  // Acts::PlaneSurface attached to [x1,-y1] and [x2,0] at positive x
0077     NegativeXFaceYZ23 =
0078         4,  // Acts::PlaneSurface attached to [-x2,0] and [-x3,y2] at negative x
0079     PositiveXFaceYZ23 =
0080         5,  // Acts::PlaneSurface attached to [x2,0] and [x3,y2] at positive x
0081     NegativeYFaceZX = 6,
0082     PositiveYFaceZX = 7
0083 
0084   };
0085 
0086   /// Constructor - the polygonal prism boundaries
0087   ///
0088   /// @param x1 is the half length in x at negative y1
0089   /// @param x2 is the half length in x at y=0
0090   /// @param x3 is the half length in x at positive y2
0091   /// @param y1 is the positive y extent
0092   /// @param y2 is the negative y extent
0093   /// @param halez is the half length in z
0094   DiamondVolumeBounds(double x1, double x2, double x3, double y1, double y2,
0095                       double halez) noexcept(false);
0096 
0097   /// Copy constructor
0098   /// @param other The other DiamondVolumeBounds to copy from
0099   DiamondVolumeBounds(const DiamondVolumeBounds& other) = default;
0100 
0101   /// Move constructor
0102   /// @param other The other DiamondVolumeBounds to move from
0103   DiamondVolumeBounds(DiamondVolumeBounds&& other) = default;
0104 
0105   /// Copy constructor assignment
0106   /// @param other The other DiamondVolumeBounds to copy from
0107   DiamondVolumeBounds& operator=(const DiamondVolumeBounds& other) = default;
0108 
0109   /// Move constructor assignment
0110   /// @param other The other DiamondVolumeBounds to move from
0111   DiamondVolumeBounds& operator=(DiamondVolumeBounds&& other) = default;
0112 
0113   /// Default destructor
0114   ~DiamondVolumeBounds() override = default;
0115 
0116   VolumeBounds::BoundsType type() const final {
0117     return VolumeBounds::BoundsType::eDiamond;
0118   }
0119 
0120   /// Return the bound values as dynamically sized vector
0121   ///
0122   /// @return this returns a copy of the internal values
0123   std::vector<double> values() const final;
0124 
0125   /// This method checks if position in the 3D volume frame
0126   /// is inside the cylinder
0127   ///
0128   /// @param pos is the global position to be checked
0129   /// @param tol is the tolerance applied
0130   ///
0131   /// @return boolean indicator if position is inside
0132   bool inside(const Vector3& pos, double tol = 0.) const final;
0133 
0134   /// Oriented surfaces, i.e. the decomposed boundary surfaces and the
0135   /// according navigation direction into the volume given the normal
0136   /// vector on the surface
0137   ///
0138   /// @param transform is the 3D transform to be applied to the boundary
0139   /// surfaces to position them in 3D space
0140   ///
0141   /// It will throw an exception if the orientation prescription is not adequate
0142   ///
0143   /// @return a vector of surfaces bounding this volume
0144   std::vector<OrientedSurface> orientedSurfaces(
0145       const Transform3& transform = Transform3::Identity()) const final;
0146 
0147   /// Construct bounding box for this shape
0148   /// @param trf Optional transform
0149   /// @param envelope Optional envelope to add / subtract from min/max
0150   /// @param entity Entity to associate this bounding box with
0151   /// @return Constructed bounding box
0152   Volume::BoundingBox boundingBox(const Transform3* trf = nullptr,
0153                                   const Vector3& envelope = {0, 0, 0},
0154                                   const Volume* entity = nullptr) const final;
0155 
0156   /// Output Method for std::ostream
0157   /// @param os is the output stream
0158   /// @return Modified ostream for chaining
0159   std::ostream& toStream(std::ostream& os) const override;
0160 
0161   /// Access to the bound values
0162   /// @param bValue the class nested enum for the array access
0163   /// @return The bound value at the specified index
0164   double get(BoundValues bValue) const { return m_values[bValue]; }
0165 
0166  private:
0167   /// The bound values stored in an array
0168   std::array<double, eSize> m_values{};
0169   /// The face plane surface parallel to YZ at positive X attached to [x1,y1]
0170   /// and [x2,0]
0171   std::shared_ptr<Acts::RectangleBounds> m_FaceYZ12Bounds;
0172   /// The face plane surface parallel to YZ attached to [x2,0] and [x3,y2]
0173   std::shared_ptr<Acts::RectangleBounds> m_FaceYZ23Bounds;
0174   // The face plane surface parallel to ZX at negative Y
0175   std::shared_ptr<Acts::RectangleBounds> m_negYFaceZXBounds;
0176   // The face plane surface parallel to ZX at positive Y
0177   std::shared_ptr<Acts::RectangleBounds> m_posYFaceZXBounds;
0178   /// The face diamond surface parallel to XY
0179   std::shared_ptr<Acts::DiamondBounds> m_FaceXYBounds;
0180 
0181   // Helper method to build the surface bounds
0182   void buildSurfaceBounds();
0183 
0184   // Check the input values for consistency,
0185   // will throw a logic_exception if consistency is not given
0186   void checkConsistency() noexcept(false);
0187 };
0188 
0189 /// @cond
0190 /// @brief Streaming operator for the polygon volume surfaces
0191 inline std::ostream& operator<<(std::ostream& os,
0192                                 DiamondVolumeBounds::Face face) {
0193   switch (face) {
0194     case DiamondVolumeBounds::Face::NegativeZFaceXY:
0195       return os << "NegativeZFaceXY";
0196     case DiamondVolumeBounds::Face::PositiveZFaceXY:
0197       return os << "PositiveZFaceXY";
0198     case DiamondVolumeBounds::Face::NegativeXFaceYZ12:
0199       return os << "NegativeXFaceYZ12";
0200     case DiamondVolumeBounds::Face::PositiveXFaceYZ12:
0201       return os << "PositiveXFaceYZ12";
0202     case DiamondVolumeBounds::Face::NegativeXFaceYZ23:
0203       return os << "NegativeXFaceYZ23";
0204     case DiamondVolumeBounds::Face::PositiveXFaceYZ23:
0205       return os << "PositiveXFaceYZ23";
0206     case DiamondVolumeBounds::Face::NegativeYFaceZX:
0207       return os << "NegativeYFaceZX";
0208     case DiamondVolumeBounds::Face::PositiveYFaceZX:
0209       return os << "PositiveYFaceZX";
0210     default:
0211       return os << "Unknown";
0212   }
0213 }
0214 /// @endcond
0215 
0216 }  // namespace Acts