Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:27:38

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2019-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 
0015 #include <array>
0016 #include <cstddef>
0017 #include <ostream>
0018 #include <vector>
0019 
0020 namespace Acts {
0021 
0022 class IVisualization3D;
0023 
0024 class GenericCuboidVolumeBounds : public VolumeBounds {
0025  public:
0026   /// @brief  This struct helps to symmetrize with the
0027   /// the other volume bounds classes
0028   struct BoundValues {
0029     static constexpr std::size_t eSize = 24;
0030   };
0031 
0032   GenericCuboidVolumeBounds() = delete;
0033 
0034   /// Constructor from a set of vertices
0035   ///
0036   /// @param vertices The set of input vertices
0037   ///
0038   /// The ordering is considered to be:
0039   /// - the first 4 vertices are the "top" face
0040   /// - the second 4 vertices are the "bottom" face
0041   /// - both faces are given in counter clock wise order
0042   GenericCuboidVolumeBounds(
0043       const std::array<Acts::Vector3, 8>& vertices) noexcept(false);
0044 
0045   /// Constructor from a fixed size array
0046   ///
0047   /// @param values The input values
0048   GenericCuboidVolumeBounds(
0049       const std::array<double, BoundValues::eSize>& values) noexcept(false);
0050 
0051   ~GenericCuboidVolumeBounds() override = default;
0052 
0053   VolumeBounds::BoundsType type() const final {
0054     return VolumeBounds::eGenericCuboid;
0055   }
0056 
0057   /// Return the bound values as dynamically sized vector
0058   ///
0059   /// @return this returns a copy of the internal values
0060   std::vector<double> values() const final;
0061 
0062   /// Checking if position given in volume frame is inside
0063   ///
0064   /// @param gpos is the global position to be checked
0065   /// @param tol is the tolerance applied for the inside check
0066   ///
0067   /// @return boolean indicating if the position is inside
0068   bool inside(const Vector3& gpos, double tol = 0.) const override;
0069 
0070   /// Oriented surfaces, i.e. the decomposed boundary surfaces and the
0071   /// according navigation direction into the volume given the normal
0072   /// vector on the surface
0073   ///
0074   /// @param transform is the 3D transform to be applied to the boundary
0075   /// surfaces to position them in 3D space
0076   ///
0077   /// It will throw an exception if the orientation prescription is not adequate
0078   ///
0079   /// @return a vector of surfaces bounding this volume
0080   std::vector<OrientedSurface> orientedSurfaces(
0081       const Transform3& transform = Transform3::Identity()) const override;
0082 
0083   /// Construct bounding box for this shape
0084   /// @param trf Optional transform
0085   /// @param envelope Optional envelope to add / subtract from min/max
0086   /// @param entity Entity to associate this bounding box with
0087   /// @return Constructed bounding box
0088   Volume::BoundingBox boundingBox(const Transform3* trf = nullptr,
0089                                   const Vector3& envelope = {0, 0, 0},
0090                                   const Volume* entity = nullptr) const final;
0091 
0092   /// Get the canonical binning values, i.e. the binning values
0093   /// for that fully describe the shape's extent
0094   ///
0095   /// @return vector of canonical binning values
0096   std::vector<Acts::BinningValue> canonicalBinning() const override {
0097     return {Acts::binX, Acts::binY, Acts::binZ};
0098   };
0099 
0100   /// @param sl is the output stream to be written into
0101   std::ostream& toStream(std::ostream& sl) const override;
0102 
0103   /// Draw this shape using a visualization helper
0104   /// @param helper The visualizatin helper
0105   /// @param transform Optional transformation matrix
0106   ///
0107   void draw(IVisualization3D& helper,
0108             const Transform3& transform = Transform3::Identity()) const;
0109 
0110  private:
0111   std::array<Vector3, 8> m_vertices;
0112   std::array<Vector3, 6> m_normals;
0113 
0114   /// Private helper method to construct the Volume bounds
0115   /// to be called by the constructors, from the ordered input vertices
0116   void construct() noexcept(false);
0117 };
0118 
0119 }  // namespace Acts