Back to home page

EIC code displayed by LXR

 
 

    


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

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