Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:10:53

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/Definitions/Direction.hpp"
0013 #include "Acts/Geometry/Volume.hpp"
0014 #include "Acts/Surfaces/RegularSurface.hpp"
0015 #include "Acts/Utilities/AxisDefinitions.hpp"
0016 
0017 #include <cmath>
0018 #include <iostream>
0019 #include <memory>
0020 #include <numbers>
0021 #include <utility>
0022 #include <vector>
0023 
0024 namespace Acts {
0025 
0026 class Surface;
0027 class VolumeBounds;
0028 class Direction;
0029 
0030 struct OrientedSurface {
0031   std::shared_ptr<RegularSurface> surface;
0032   Direction direction = Direction::AlongNormal();
0033 };
0034 
0035 // Planar definitions to help construct the boundary surfaces
0036 static const Transform3 s_planeXY = Transform3::Identity();
0037 static const Transform3 s_planeYZ =
0038     AngleAxis3(std::numbers::pi / 2., Vector3::UnitY()) *
0039     AngleAxis3(std::numbers::pi / 2., Vector3::UnitZ()) *
0040     Transform3::Identity();
0041 static const Transform3 s_planeZX =
0042     AngleAxis3(-std::numbers::pi / 2., Vector3::UnitX()) *
0043     AngleAxis3(-std::numbers::pi / 2., Vector3::UnitZ()) *
0044     Transform3::Identity();
0045 
0046 /// @class VolumeBounds
0047 ///
0048 /// Pure Absract Base Class for Volume bounds.
0049 ///
0050 /// Acts::VolumeBounds are a set of up to six confining Surfaces that are stored
0051 /// in a std::vector.
0052 /// Each type of Acts::VolumeBounds has to implement a orientedSurfaces() and
0053 /// a inside() method.
0054 ///
0055 /// The Volume, retrieving a set of Surfaces from the VolumeBounds, can turn the
0056 /// Surfaces into BoundarySurfaces.
0057 
0058 class VolumeBounds {
0059  public:
0060   // @enum BoundsType
0061   /// This is nested to the VolumeBounds, as also SurfaceBounds will have
0062   /// Bounds Type.
0063   enum class BoundsType {
0064     eCone,
0065     eCuboid,
0066     eCutoutCylinder,
0067     eCylinder,
0068     eGenericCuboid,
0069     eTrapezoid,
0070     eOther,
0071 
0072   };
0073 
0074   using enum BoundsType;
0075 
0076   /// Static member to get the name of the BoundsType
0077   static const std::vector<std::string> s_boundsTypeNames;
0078 
0079   VolumeBounds() = default;
0080 
0081   virtual ~VolumeBounds() = default;
0082 
0083   /// Return the bounds type - for persistency optimization
0084   ///
0085   /// @return is a BoundsType enum
0086   virtual BoundsType type() const = 0;
0087 
0088   /// Access method for bound values, this is a dynamically sized
0089   /// vector containing the parameters needed to describe these bounds
0090   ///
0091   /// @return of the stored values for this SurfaceBounds object
0092   virtual std::vector<double> values() const = 0;
0093 
0094   /// Checking if position given in volume frame is inside
0095   ///
0096   /// @param gpos is the global position to be checked
0097   /// @param tol is the tolerance applied for the inside check
0098   ///
0099   /// @return boolean indicating if the position is inside
0100   virtual bool inside(const Vector3& gpos, double tol = 0.) const = 0;
0101 
0102   /// Oriented surfaces, i.e. the decomposed boundary surfaces and the
0103   /// according navigation direction into the volume given the normal
0104   /// vector on the surface
0105   ///
0106   /// @param transform is the 3D transform to be applied to the boundary
0107   /// surfaces to position them in 3D space
0108   ///
0109   /// It will throw an exception if the orientation prescription is not adequate
0110   ///
0111   /// @return a vector of surfaces bounding this volume
0112   virtual std::vector<OrientedSurface> orientedSurfaces(
0113       const Transform3& transform = Transform3::Identity()) const = 0;
0114 
0115   /// Construct bounding box for this shape
0116   /// @param trf Optional transform
0117   /// @param envelope Optional envelope to add / subtract from min/max
0118   /// @param entity Entity to associate this bounding box with
0119   /// @return Constructed bounding box
0120   virtual Volume::BoundingBox boundingBox(
0121       const Transform3* trf = nullptr, const Vector3& envelope = {0, 0, 0},
0122       const Volume* entity = nullptr) const = 0;
0123 
0124   /// Get the canonical axis direction
0125   /// that fully describe the shape's extent
0126   ///
0127   /// @return vector of canonical axis directions
0128   ///
0129   /// @note This is the default implementation that
0130   /// returns the bounding box binning. Individual shapes
0131   /// should override this method
0132   virtual std::vector<AxisDirection> canonicalAxes() const {
0133     using enum AxisDirection;
0134     return {AxisX, AxisY, AxisZ};
0135   };
0136 
0137   /// Binning offset - overloaded for some R-binning types
0138   ///
0139   /// @param aDir is the binning schema used
0140   ///
0141   /// @return vector 3D to be used for the binning
0142   virtual Vector3 referenceOffset(AxisDirection aDir) const;
0143 
0144   /// Binning borders in double
0145   ///
0146   /// @param aDir is the binning schema used
0147   ///
0148   /// @return float offset to be used for the binning
0149   virtual double referenceBorder(AxisDirection aDir) const;
0150 
0151   /// Output Method for std::ostream, to be overloaded by child classes
0152   ///
0153   /// @param sl is the output stream to be dumped into
0154   virtual std::ostream& toStream(std::ostream& sl) const = 0;
0155 };
0156 
0157 /// Binning offset - overloaded for some R-binning types
0158 inline Vector3 VolumeBounds::referenceOffset(
0159     AxisDirection /*aDir*/) const {  // standard offset is 0.,0.,0.
0160   return Vector3(0., 0., 0.);
0161 }
0162 
0163 inline double VolumeBounds::referenceBorder(AxisDirection /*aDir*/) const {
0164   return 0.;
0165 }
0166 
0167 /// Overload of << operator for std::ostream for debug output
0168 std::ostream& operator<<(std::ostream& sl, const VolumeBounds& vb);
0169 
0170 inline bool operator==(const VolumeBounds& lhs, const VolumeBounds& rhs) {
0171   if (&lhs == &rhs) {
0172     return true;
0173   }
0174   return (lhs.type() == rhs.type()) && (lhs.values() == rhs.values());
0175 }
0176 
0177 std::ostream& operator<<(std::ostream& sl, const VolumeBounds::BoundsType& bt);
0178 
0179 }  // namespace Acts