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/BoundingBox.hpp"
0015 
0016 #include <array>
0017 #include <cmath>
0018 #include <iomanip>
0019 #include <iosfwd>
0020 #include <memory>
0021 #include <ostream>
0022 #include <stdexcept>
0023 #include <vector>
0024 
0025 namespace Acts {
0026 
0027 class RectangleBounds;
0028 
0029 /// @class CuboidVolumeBounds
0030 ///
0031 /// Bounds for a cubical Volume, the orientedSurfaces(...) method creates a
0032 /// vector of 6 surfaces:
0033 ///
0034 ///  BoundarySurfaceFace [index]:
0035 ///
0036 ///    - negativeFaceXY [0] : Rectangular Acts::PlaneSurface, parallel to \f$ xy
0037 /// \f$ plane at negative \f$ z \f$
0038 ///    - positiveFaceXY [1] : Rectangular Acts::PlaneSurface, parallel to \f$ xy
0039 /// \f$ plane at positive \f$ z \f$
0040 ///    - negativeFaceXY [2] : Rectangular Acts::PlaneSurface, attached to \f$ yz
0041 /// \f$ plane at negative \f$ x \f$
0042 ///    - positiveFaceXY [3] : Rectangular Acts::PlaneSurface, attached to \f$ yz
0043 /// \f$ plane at negative \f$ x \f$
0044 ///    - negativeFaceXY [4] : Rectangular Acts::PlaneSurface, parallel to \f$ zx
0045 /// \f$ plane at negative \f$ y \f$
0046 ///    - positiveFaceXY [5] : Rectangular Acts::PlaneSurface, parallel to \f$ zx
0047 /// \f$ plane at positive \f$ y \f$
0048 ///
0049 class CuboidVolumeBounds : public VolumeBounds {
0050  public:
0051   /// @enum BoundValues for streaming and access
0052   enum BoundValues : unsigned int {
0053     eHalfLengthX = 0,
0054     eHalfLengthY = 1,
0055     eHalfLengthZ = 2,
0056     eSize
0057   };
0058 
0059   CuboidVolumeBounds() = delete;
0060 
0061   /// Constructor - the box boundaries
0062   ///
0063   /// @param halex is the half length of the cube in x
0064   /// @param haley is the half length of the cube in y
0065   /// @param halez is the half length of the cube in z
0066   CuboidVolumeBounds(ActsScalar halex, ActsScalar haley,
0067                      ActsScalar halez) noexcept(false);
0068 
0069   /// Constructor - from a fixed size array
0070   ///
0071   /// @param values iw the bound values
0072   CuboidVolumeBounds(const std::array<ActsScalar, eSize>& values);
0073 
0074   /// Copy Constructor
0075   ///
0076   /// @param bobo is the source volume bounds to be copied
0077   CuboidVolumeBounds(const CuboidVolumeBounds& bobo) = default;
0078 
0079   /// Assignment operator
0080   ///
0081   /// @param bobo is the source volume bounds to be assigned
0082   CuboidVolumeBounds& operator=(const CuboidVolumeBounds& bobo) = default;
0083 
0084   ~CuboidVolumeBounds() override = default;
0085 
0086   VolumeBounds::BoundsType type() const final { return VolumeBounds::eCuboid; }
0087 
0088   /// Return the bound values as dynamically sized vector
0089   ///
0090   /// @return this returns a copy of the internal values
0091   std::vector<ActsScalar> values() const final;
0092 
0093   /// This method checks if position in the 3D volume
0094   /// frame is inside the cylinder
0095   ///
0096   /// @param pos is the position in volume frame to be checked
0097   /// @param tol is the absolute tolerance to be applied
0098   bool inside(const Vector3& pos, ActsScalar tol = 0.) const override;
0099 
0100   /// Oriented surfaces, i.e. the decomposed boundary surfaces and the
0101   /// according navigation direction into the volume given the normal
0102   /// vector on the surface
0103   ///
0104   /// @param transform is the 3D transform to be applied to the boundary
0105   /// surfaces to position them in 3D space
0106   ///
0107   /// It will throw an exception if the orientation prescription is not adequate
0108   ///
0109   /// @return a vector of surfaces bounding this volume
0110   std::vector<OrientedSurface> orientedSurfaces(
0111       const Transform3& transform = Transform3::Identity()) const override;
0112 
0113   /// Construct bounding box for this shape
0114   /// @param trf Optional transform
0115   /// @param envelope Optional envelope to add / subtract from min/max
0116   /// @param entity Entity to associate this bounding box with
0117   /// @return Constructed bounding box
0118   Volume::BoundingBox boundingBox(const Transform3* trf = nullptr,
0119                                   const Vector3& envelope = {0, 0, 0},
0120                                   const Volume* entity = nullptr) const final;
0121 
0122   /// Get the canonical binning values, i.e. the binning values
0123   /// for that fully describe the shape's extent
0124   ///
0125   /// @return vector of canonical binning values
0126   std::vector<Acts::BinningValue> canonicalBinning() const override {
0127     return {Acts::binX, Acts::binY, Acts::binZ};
0128   };
0129 
0130   /// Binning borders in ActsScalar
0131   ///
0132   /// @param bValue is the binning schema used
0133   ///
0134   /// @return float offset to be used for the binning
0135   ActsScalar binningBorder(BinningValue bValue) const final;
0136 
0137   /// Access to the bound values
0138   /// @param bValue the class nested enum for the array access
0139   ActsScalar get(BoundValues bValue) const { return m_values[bValue]; }
0140 
0141   /// Set a bound value
0142   /// @param bValue the bound value identifier
0143   /// @param value the value to be set
0144   void set(BoundValues bValue, ActsScalar value);
0145 
0146   /// Set a range of bound values
0147   /// @param keyValues the initializer list of key value pairs
0148   void set(std::initializer_list<std::pair<BoundValues, ActsScalar>> keyValues);
0149 
0150   /// Output Method for std::ostream
0151   ///
0152   /// @param os is ostream operator to be dumped into
0153   std::ostream& toStream(std::ostream& os) const override;
0154 
0155  private:
0156   /// The bound values ordered in a fixed size array
0157   std::array<ActsScalar, eSize> m_values;
0158 
0159   std::shared_ptr<const RectangleBounds> m_xyBounds{nullptr};
0160   std::shared_ptr<const RectangleBounds> m_yzBounds{nullptr};
0161   std::shared_ptr<const RectangleBounds> m_zxBounds{nullptr};
0162 
0163   /// Create the surface bounds
0164   void buildSurfaceBounds();
0165 
0166   /// Check the input values for consistency,
0167   /// will throw a logic_exception if consistency is not given
0168   void checkConsistency() noexcept(false);
0169 };
0170 }  // namespace Acts