Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:09:24

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 #include "Acts/Definitions/Algebra.hpp"
0011 #include "Acts/Surfaces/BoundaryCheck.hpp"
0012 
0013 #include <ostream>
0014 
0015 namespace Acts {
0016 
0017 /// @class SurfaceBounds
0018 ///
0019 /// Interface for surface bounds.
0020 ///
0021 /// Surface bounds provide:
0022 /// - inside() checks
0023 /// - distance to boundary calculations
0024 /// - the BoundsType and a set of parameters to simplify persistency
0025 ///
0026 class SurfaceBounds {
0027  public:
0028   /// @enum BoundsType
0029   /// This is nested to the SurfaceBounds, as also VolumeBounds will have
0030   /// Bounds Type.
0031   enum BoundsType : int {
0032     eCone = 0,
0033     eCylinder = 1,
0034     eDiamond = 2,
0035     eDisc = 3,
0036     eEllipse = 4,
0037     eLine = 5,
0038     eRectangle = 6,
0039     eTrapezoid = 7,
0040     eTriangle = 8,
0041     eDiscTrapezoid = 9,
0042     eConvexPolygon = 10,
0043     eAnnulus = 11,
0044     eBoundless = 12,
0045     eOther = 13
0046   };
0047 
0048   virtual ~SurfaceBounds() = default;
0049 
0050   /// Return the bounds type - for persistency optimization
0051   ///
0052   /// @return is a BoundsType enum
0053   virtual BoundsType type() const = 0;
0054 
0055   /// Access method for bound values, this is a dynamically sized
0056   /// vector containing the parameters needed to describe these bounds
0057   ///
0058   /// @return of the stored values for this SurfaceBounds object
0059   virtual std::vector<double> values() const = 0;
0060 
0061   /// Inside check for the bounds object driven by the boundary check directive
0062   /// Each Bounds has a method inside, which checks if a LocalPosition is inside
0063   /// the bounds  Inside can be called without/with tolerances.
0064   ///
0065   /// @param lposition Local position (assumed to be in right surface frame)
0066   /// @param bcheck boundary check directive
0067   /// @return boolean indicator for the success of this operation
0068   virtual bool inside(const Vector2& lposition,
0069                       const BoundaryCheck& bcheck) const = 0;
0070 
0071   /// Output Method for std::ostream, to be overloaded by child classes
0072   ///
0073   /// @param os is the outstream in which the string dump is done
0074   virtual std::ostream& toStream(std::ostream& os) const = 0;
0075 };
0076 
0077 inline bool operator==(const SurfaceBounds& lhs, const SurfaceBounds& rhs) {
0078   if (&lhs == &rhs) {
0079     return true;
0080   }
0081   return (lhs.type() == rhs.type()) && (lhs.values() == rhs.values());
0082 }
0083 
0084 inline bool operator!=(const SurfaceBounds& lhs, const SurfaceBounds& rhs) {
0085   return !(lhs == rhs);
0086 }
0087 
0088 inline std::ostream& operator<<(std::ostream& os, const SurfaceBounds& sb) {
0089   return sb.toStream(os);
0090 }
0091 
0092 }  // namespace Acts