Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-14 09:39:27

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 #include "Acts/Utilities/BoundingBox.hpp"
0015 
0016 #include <array>
0017 #include <iomanip>
0018 #include <memory>
0019 #include <ostream>
0020 #include <vector>
0021 
0022 namespace Acts {
0023 
0024 class CylinderBounds;
0025 class ConeBounds;
0026 class RadialBounds;
0027 class PlanarBounds;
0028 
0029 /// @class ConeVolumeBounds
0030 ///
0031 /// Volume bound class for describing conical volumes
0032 /// either with cylindrical inlay or outer boundary, it also allows
0033 /// for a sectoral description
0034 class ConeVolumeBounds : public VolumeBounds {
0035  public:
0036   /// @enum BoundValues for readability
0037   enum BoundValues : unsigned int {
0038     eInnerAlpha = 0,
0039     eInnerOffsetZ = 1,
0040     eOuterAlpha = 2,
0041     eOuterOffsetZ = 3,
0042     eHalfLengthZ = 4,
0043     eAveragePhi = 5,
0044     eHalfPhiSector = 6,
0045     eSize
0046   };
0047 
0048   ConeVolumeBounds() = delete;
0049 
0050   /// Constructor - for general cone-cone setups
0051   ///
0052   /// @param innerAlpha The opening angle of the inner cone (0 if no cone)
0053   /// @param innerOffsetZ The tip z position in of the inner cone, w.r.t center
0054   /// @param outerAlpha  The opening angle of the outer cone (0 if no cone)
0055   /// @param outerOffsetZ The tip z position in of the outer cone, w.r.t center
0056   /// @param halflengthZ The minimum z value of the inner and outer cones
0057   /// @param averagePhi The phi orientation of the sector
0058   /// @param halfPhiSector The opening angle phi sector
0059   ConeVolumeBounds(double innerAlpha, double innerOffsetZ, double outerAlpha,
0060                    double outerOffsetZ, double halflengthZ, double averagePhi,
0061                    double halfPhiSector) noexcept(false);
0062 
0063   /// Constructor - for general cylidner-cone setups
0064   ///
0065   /// @param cylinderR The inner radius of the cylinder
0066   /// @param alpha  The opening angle of the cone (0 if no cone)
0067   /// @param offsetZ The tip  z position in of the cone, w.r.t center
0068   /// @param halflengthZ The minimum z value of the inner and outer cones
0069   /// @param averagePhi The phi orientation of the sector (defaulted to 0)
0070   /// @param halfPhiSector The opening angle phi sector
0071   ///
0072   /// @note depending on cylinderR > coneR it is constructing a cone with
0073   /// cylindrical cutout or a cylinder with conical cutout
0074   ConeVolumeBounds(double cylinderR, double alpha, double offsetZ,
0075                    double halflengthZ, double averagePhi,
0076                    double halfPhiSector) noexcept(false);
0077 
0078   /// Constructor - from a fixed size array
0079   ///
0080   /// @param values The bound values
0081   explicit ConeVolumeBounds(const std::array<double, eSize>& values) noexcept(
0082       false)
0083       : m_values(values) {
0084     checkConsistency();
0085     buildSurfaceBounds();
0086   }
0087 
0088   /// Copy constructor
0089   /// @param cobo Cone volume bounds to copy
0090   ConeVolumeBounds(const ConeVolumeBounds& cobo) = default;
0091   ~ConeVolumeBounds() override = default;
0092   /// Assignment operator
0093   /// @param cobo Cone volume bounds to assign
0094   /// @return Reference to this object
0095   ConeVolumeBounds& operator=(const ConeVolumeBounds& cobo) = default;
0096 
0097   VolumeBounds::BoundsType type() const final { return VolumeBounds::eCone; }
0098 
0099   /// Return the bound values as dynamically sized vector
0100   ///
0101   /// @return this returns a copy of the internal values
0102   std::vector<double> values() const final;
0103 
0104   /// This method checks if position in the 3D volume
0105   /// frame is inside the cylinder
0106   ///
0107   /// @param pos is the position in volume frame to be checked
0108   /// @param tol is the absolute tolerance to be applied
0109   /// @return True if the position is inside the cone volume bounds
0110   bool inside(const Vector3& pos, double tol = 0.) const final;
0111 
0112   /// Oriented surfaces, i.e. the decomposed boundary surfaces and the
0113   /// according navigation direction into the volume given the normal
0114   /// vector on the surface
0115   ///
0116   /// @param transform is the 3D transform to be applied to the boundary
0117   /// surfaces to position them in 3D space
0118   ///
0119   /// It will throw an exception if the orientation prescription is not adequate
0120   ///
0121   /// @return a vector of surfaces bounding this volume
0122   std::vector<OrientedSurface> orientedSurfaces(
0123       const Transform3& transform = Transform3::Identity()) const final;
0124 
0125   /// Construct bounding box for this shape
0126   /// @param trf Optional transform
0127   /// @param envelope Optional envelope to add / subtract from min/max
0128   /// @param entity Entity to associate this bounding box with
0129   /// @return Constructed bounding box
0130   Volume::BoundingBox boundingBox(const Transform3* trf = nullptr,
0131                                   const Vector3& envelope = {0, 0, 0},
0132                                   const Volume* entity = nullptr) const final;
0133 
0134   /// Access to the bound values
0135   /// @param bValue the class nested enum for the array access
0136   /// @return Value of the specified bound parameter
0137   double get(BoundValues bValue) const { return m_values[bValue]; }
0138 
0139   /// Return the derived inner minimum radius
0140   /// @return Inner minimum radius at the smallest z position
0141   double innerRmin() const;
0142 
0143   /// Return the derived inner maximum radius
0144   /// @return Inner maximum radius at the largest z position
0145   double innerRmax() const;
0146 
0147   /// Return the derived inner tangent of the cone opening angle
0148   /// @return Tangent of the inner cone opening angle
0149   double innerTanAlpha() const;
0150 
0151   /// Return the derived outer minimum radius
0152   /// @return Outer minimum radius at the smallest z position
0153   double outerRmin() const;
0154 
0155   /// Return the derived outer maximum radius
0156   /// @return Outer maximum radius at the largest z position
0157   double outerRmax() const;
0158 
0159   /// Return the derived outer tangent of the cone opening angle
0160   /// @return Tangent of the outer cone opening angle
0161   double outerTanAlpha() const;
0162 
0163   /// Output Method for std::ostream
0164   ///
0165   /// @param os is ostream operator to be dumped into
0166   /// @return Reference to the output stream after writing
0167   std::ostream& toStream(std::ostream& os) const final;
0168 
0169  private:
0170   /// Check the input values for consistency,
0171   /// will throw a logic_exception if consistency is not given
0172   void checkConsistency() noexcept(false);
0173 
0174   /// Create the surface bounds
0175   void buildSurfaceBounds();
0176 
0177   /// The bound values
0178   std::array<double, eSize> m_values;
0179   std::shared_ptr<CylinderBounds> m_innerCylinderBounds{nullptr};
0180   std::shared_ptr<ConeBounds> m_innerConeBounds{nullptr};
0181   std::shared_ptr<ConeBounds> m_outerConeBounds{nullptr};
0182   std::shared_ptr<CylinderBounds> m_outerCylinderBounds{nullptr};
0183   std::shared_ptr<RadialBounds> m_negativeDiscBounds{nullptr};
0184   std::shared_ptr<RadialBounds> m_positiveDiscBounds{nullptr};
0185   std::shared_ptr<PlanarBounds> m_sectorBounds{nullptr};
0186 
0187   /// Derived values
0188   double m_innerRmin = 0.;
0189   double m_innerRmax = 0.;
0190   double m_innerTanAlpha = 0.;
0191   double m_outerRmin = 0.;
0192   double m_outerRmax = 0.;
0193   double m_outerTanAlpha = 0.;
0194 };
0195 
0196 }  // namespace Acts