Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-13 09:37:07

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 
0017 #include <array>
0018 #include <initializer_list>
0019 #include <iosfwd>
0020 #include <memory>
0021 #include <numbers>
0022 #include <ostream>
0023 #include <vector>
0024 
0025 namespace Acts {
0026 
0027 class CylinderBounds;
0028 class RadialBounds;
0029 class PlanarBounds;
0030 
0031 /// @class CylinderVolumeBounds
0032 ///
0033 /// Bounds for a cylindrical Volume, the orientedSurfaces(..) method creates a
0034 /// vector of up to 6 surfaces:
0035 ///
0036 /// case A) 3 Surfaces (full cylindrical tube):
0037 ///  BoundarySurfaceFace [index]:
0038 ///  - negativeFaceXY [0] : Acts::DiscSurface with \f$ r_{inner}=0 \f$,
0039 ///                         parallel to \f$ xy \f$ plane at negative \f$ z\f$
0040 ///  - positiveFaceXY [1] : Acts::DiscSurface with \f$ r_{inner}=0 \f$,
0041 ///                         parallel to \f$ xy \f$ plane at positive \f$ z\f$
0042 ///  - cylinderCover  [2] : Acts::CylinderSurface confining the Acts::Volume
0043 ///
0044 /// case B) 4 Surfaces (tube with inner and outer radius):
0045 ///  BoundarySurfaceFace [index]:
0046 ///  - negativeFaceXY [0] : Acts::DiscSurface with \f$ r_{inner}>0 \f$,
0047 ///                         parallel to \f$ xy \f$ plane at negative \f$ z\f$
0048 ///  - positiveFaceXY [1] : Acts::DiscSurface with \f$ r_{inner}>0 \f$,
0049 ///                         parallel to \f$ xy \f$ plane at positive \f$ z\f$
0050 ///  - tubeOuterCover [2] : Acts::CylinderSurface with \f$ r = r_{outer} \f$
0051 ///  - tubeInnerCover [3] : Acts::CylinderSurface with \f$ r = r_{inner} \f$
0052 ///
0053 /// case C) 6 Surfaces (sectoral tube with inner and outer radius):
0054 ///  BoundarySurfaceFace [index]:
0055 ///   - negativeFaceXY  [0] : Acts::DiscSurface with \f$ r_{inner}>0\f$
0056 ///                           and \f$ \phi < \pi \f$,
0057 ///                           parallel to \f$ xy \f$ plane at negative \f$z\f$
0058 ///   - positiveFaceXY  [1] : Acts::DiscSurface with \f$ r_{inner}>0 \f$
0059 ///                           and \f$ \phi < \pi \f$,
0060 ///                           parallel to \f$ xy \f$ plane at positive \f$z\f$
0061 ///   - tubeSectorOuterCover  [2] : Acts::CylinderSurface with
0062 ///                                 \f$ r = r_{outer}\f$
0063 ///   - tubeSectorInnerCover  [3] : Acts::CylinderSurface with
0064 ///                                 \f$ r = r_{inner} \f$
0065 ///   - tubeSectorNegativePhi [4] : Rectangular Acts::PlaneSurface attached to
0066 ///                 [0] and [1] at negative \f$ \phi \f$
0067 ///                      - tubeSectorNegativePhi [5] :
0068 //                          Rectangular Acts::PlaneSurface attached to
0069 ///                 [0] and [1] at positive \f$ \phi \f$
0070 ///
0071 class CylinderVolumeBounds : public VolumeBounds {
0072  public:
0073   /// @enum BoundValues for streaming and access
0074   enum BoundValues : unsigned int {
0075     eMinR = 0,
0076     eMaxR = 1,
0077     eHalfLengthZ = 2,
0078     eHalfPhiSector = 3,
0079     eAveragePhi = 4,
0080     eSize
0081   };
0082 
0083   /// Enum describing the possible faces of a cylinder volume
0084   /// @note These values are synchronized with the BoundarySurfaceFace enum.
0085   ///       Once Gen1 is removed, this can be changed.
0086   enum class Face : unsigned int {
0087     PositiveDisc = BoundarySurfaceFace::positiveFaceXY,
0088     NegativeDisc = BoundarySurfaceFace::negativeFaceXY,
0089     OuterCylinder = BoundarySurfaceFace::tubeOuterCover,
0090     InnerCylinder = BoundarySurfaceFace::tubeInnerCover,
0091     NegativePhiPlane = BoundarySurfaceFace::tubeSectorNegativePhi,
0092     PositivePhiPlane = BoundarySurfaceFace::tubeSectorPositivePhi
0093   };
0094 
0095   CylinderVolumeBounds() = delete;
0096 
0097   /// Constructor
0098   ///
0099   /// @param rmin The inner radius of the cylinder
0100   /// @param rmax The outer radius of the cylinder
0101   /// @param halfz The half length in z
0102   /// @param halfphi The half lopening angle
0103   /// @param avgphi The average phi value
0104   CylinderVolumeBounds(double rmin, double rmax, double halfz,
0105                        double halfphi = std::numbers::pi, double avgphi = 0.);
0106 
0107   /// Constructor - from a fixed size array
0108   ///
0109   /// @param values The bound values
0110   explicit CylinderVolumeBounds(const std::array<double, eSize>& values);
0111 
0112   /// Constructor - extruded from cylinder bounds and thickness
0113   ///
0114   /// @param cBounds the cylinder bounds
0115   /// @param thickness of the extrusion
0116   CylinderVolumeBounds(const CylinderBounds& cBounds, double thickness);
0117 
0118   /// Constructor - extruded from radial bounds and thickness
0119   ///
0120   /// @param rBounds the Radial bounds
0121   /// @param thickness
0122   CylinderVolumeBounds(const RadialBounds& rBounds, double thickness);
0123 
0124   /// Copy Constructor
0125   ///
0126   /// @param cylbo is the source cylinder volume bounds for the copy
0127   CylinderVolumeBounds(const CylinderVolumeBounds& cylbo) = default;
0128 
0129   ~CylinderVolumeBounds() override = default;
0130   /// Assignment operator
0131   /// @param cylbo Source cylinder volume bounds to copy from
0132   /// @return Reference to this object after assignment
0133   CylinderVolumeBounds& operator=(const CylinderVolumeBounds& cylbo) = default;
0134 
0135   VolumeBounds::BoundsType type() const final {
0136     return VolumeBounds::eCylinder;
0137   }
0138 
0139   /// Return the bound values as dynamically sized vector
0140   ///
0141   /// @return this returns a copy of the internal values
0142   std::vector<double> values() const final;
0143 
0144   /// This method checks if position in the 3D volume
0145   /// frame is inside the cylinder
0146   ///
0147   /// @param pos is a global position to be checked
0148   /// @param tol is the tolerance for the check
0149   /// @return True if the position is inside the cylinder bounds
0150   bool inside(const Vector3& pos, double tol = 0.) const override;
0151 
0152   /// Oriented surfaces, i.e. the decomposed boundary surfaces and the
0153   /// according navigation direction into the volume given the normal
0154   /// vector on the surface
0155   ///
0156   /// @param transform is the 3D transform to be applied to the boundary
0157   /// surfaces to position them in 3D space
0158   ///
0159   /// It will throw an exception if the orientation prescription is not adequate
0160   ///
0161   /// @return a vector of surfaces bounding this volume
0162   std::vector<OrientedSurface> orientedSurfaces(
0163       const Transform3& transform = Transform3::Identity()) const override;
0164 
0165   /// Construct bounding box for this shape
0166   /// @param trf Optional transform
0167   /// @param envelope Optional envelope to add / subtract from min/max
0168   /// @param entity Entity to associate this bounding box with
0169   /// @return Constructed bounding box
0170   Volume::BoundingBox boundingBox(const Transform3* trf = nullptr,
0171                                   const Vector3& envelope = {0, 0, 0},
0172                                   const Volume* entity = nullptr) const final;
0173 
0174   /// Get the canonical binning directions, i.e. the axis directions
0175   /// that fully describe the shape's extent
0176   ///
0177   /// @return vector of canonical binning values
0178   std::vector<AxisDirection> canonicalAxes() const override {
0179     using enum AxisDirection;
0180     return {AxisR, AxisPhi, AxisZ};
0181   };
0182 
0183   /// Binning offset - overloaded for some R-binning types
0184   ///
0185   /// @param aDir is the axis direction used for the binning
0186   /// @return Reference offset vector for the given axis direction
0187   Vector3 referenceOffset(AxisDirection aDir) const override;
0188 
0189   /// Binning borders in double
0190   ///
0191   /// @param aDir is the axis direction used for the binning
0192   /// @return Reference border value for the given axis direction
0193   double referenceBorder(AxisDirection aDir) const override;
0194 
0195   /// Output Method for std::ostream
0196   /// @param os is the output stream
0197   /// @return Reference to the output stream after writing
0198   std::ostream& toStream(std::ostream& os) const override;
0199 
0200   /// Access to the bound values
0201   /// @param bValue the class nested enum for the array access
0202   /// @return The requested bound value
0203   double get(BoundValues bValue) const { return m_values[bValue]; }
0204 
0205   /// Set a bound value
0206   /// @param bValue the bound value identifier
0207   /// @param value the value to be set
0208   void set(BoundValues bValue, double value);
0209 
0210   /// Set a range of bound values
0211   /// @param keyValues the initializer list of key value pairs
0212   void set(std::initializer_list<std::pair<BoundValues, double>> keyValues);
0213 
0214  private:
0215   /// The internal version of the bounds can be float/double
0216   std::array<double, eSize> m_values{};
0217 
0218   /// Bounds of the inner CylinderBounds
0219   std::shared_ptr<const CylinderBounds> m_innerCylinderBounds{nullptr};
0220   /// Bounds of the inner CylinderBounds
0221   std::shared_ptr<const CylinderBounds> m_outerCylinderBounds{nullptr};
0222   /// Bounds of the bottom/top Radial
0223   std::shared_ptr<const RadialBounds> m_discBounds{nullptr};
0224   /// Bounds of the sector planes
0225   std::shared_ptr<const PlanarBounds> m_sectorPlaneBounds{nullptr};
0226 
0227   /// Check the input values for consistency,
0228   /// will throw a logic_exception if consistency is not given
0229   void checkConsistency();
0230 
0231   /// Helper method to create the surface bounds
0232   void buildSurfaceBounds();
0233 };
0234 
0235 }  // namespace Acts