Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-17 08:35:36

0001 #ifndef VECGEOM_PLANAR_IMPL_H
0002 #define VECGEOM_PLANAR_IMPL_H
0003 
0004 #include <VecGeom/surfaces/surf/SurfaceHelper.h>
0005 
0006 namespace vgbrep {
0007 
0008 /// @brief Partial specialization of surface helper for planar surfaces.
0009 /// @tparam Real_t Floating-point precision type
0010 template <typename Real_t>
0011 struct SurfaceHelper<SurfaceType::kPlanar, Real_t> {
0012 
0013   SurfaceHelper() = default;
0014 
0015   VECGEOM_FORCE_INLINE
0016   VECCORE_ATT_HOST_DEVICE
0017   /// @brief Inside half-space function
0018   /// @param point Point in local surface coordinates
0019   /// @param tol tolerance for determining if a point is inside or not
0020   /// @return True if the point is behind the normal within kTolerance (surface is included)
0021   bool Inside(Vector3D<Real_t> const &point, bool flip, Real_t tol = vecgeom::kToleranceStrict<Real_t>)
0022   {
0023     int flipsign = !flip ? 1 : -1;
0024     return point.z() < flipsign * tol;
0025   }
0026 
0027   VECGEOM_FORCE_INLINE
0028   VECCORE_ATT_HOST_DEVICE
0029   /// @brief Find signed distance to next intersection from local point.
0030   /// @param point Point in local surface coordinates
0031   /// @param dir Direction in the local surface coordinates
0032   /// @param left_side Flag specifying if the surface is intersected from the left-side that defines the normal
0033   /// @param distance Computed distance to surface
0034   /// @return Validity of the intersection
0035   bool Intersect(Vector3D<Real_t> const &point, Vector3D<Real_t> const &dir, bool left_side, Real_t &distance,
0036                  bool &two_solutions, Real_t &safety)
0037   {
0038     // Just need to propagate to (xOy) plane
0039     bool surfhit = left_side ^ (dir[2] < 0);
0040     distance     = -point[2] / vecgeom::NonZero(dir[2]);
0041     safety       = point[2];
0042     return surfhit;
0043   }
0044 
0045   VECGEOM_FORCE_INLINE
0046   VECCORE_ATT_HOST_DEVICE
0047   /// @brief Computes the isotropic safe distance to unplaced surfaces
0048   /// @param point Point in local surface coordinates
0049   /// @param left_side Flag specifying if the surface is intersected from the left-side that defines the normal
0050   /// @param distance Computed isotropic safety
0051   /// @param onsurf Projection of the point on surface
0052   /// @return Validity of the calculation
0053   bool Safety(Vector3D<Real_t> const &point, bool left_side, Real_t &distance, Vector3D<Real_t> &onsurf) const
0054   {
0055     distance = left_side ? -point[2] : point[2];
0056     // Computing onsurf is cheap
0057     onsurf.Set(point[0], point[1], 0);
0058     return distance > -vecgeom::kToleranceDist<Real_t>;
0059   }
0060 };
0061 
0062 } // namespace vgbrep
0063 
0064 #endif