Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-01 07:32:37

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/Geometry/Extent.hpp"
0012 #include "Acts/Geometry/GeometryContext.hpp"
0013 #include "Acts/Surfaces/Surface.hpp"
0014 
0015 #include <utility>
0016 #include <vector>
0017 
0018 namespace Acts {
0019 
0020 /// Helper to compare surfaces for binning equivalence.
0021 struct SurfaceBinningMatcher {
0022   /// The binning tolerance parameters
0023   using Range = std::pair<double, double>;
0024   /// Tolerance ranges for each axis direction
0025   std::vector<Range> tolerances{static_cast<int>(numAxisDirections()),
0026                                 {0., 0.}};
0027 
0028   SurfaceBinningMatcher() = default;
0029 
0030   /// Constructor with tolerance parameters
0031   /// @param tolpars The tolerance ranges for binning comparison
0032   explicit SurfaceBinningMatcher(const std::vector<Range>& tolpars)
0033       : tolerances(tolpars) {}
0034 
0035   /// Check function for surface equivalent
0036   ///
0037   /// @param gctx [in] gctx the geometry context for this check
0038   /// @param aDir the axis direction value for the binning
0039   /// @param one first surface for checking
0040   /// @param other second surface for checking
0041   /// @return True if surfaces are binning-equivalent
0042   bool operator()(const Acts::GeometryContext& gctx, Acts::AxisDirection aDir,
0043                   const Acts::Surface* one, const Acts::Surface* other) const {
0044     // Fast exit
0045     if (one == other) {
0046       return true;
0047     }
0048 
0049     auto oneExt = one->polyhedronRepresentation(gctx, 1).extent();
0050     auto otherExt = other->polyhedronRepresentation(gctx, 1).extent();
0051 
0052     double oneMin = oneExt.min(aDir);
0053     double oneMax = oneExt.max(aDir);
0054 
0055     double otherMin = otherExt.min(aDir);
0056     double otherMax = otherExt.max(aDir);
0057 
0058     return (
0059         std::abs(oneMin - otherMin) <= tolerances[toUnderlying(aDir)].first &&
0060         std::abs(oneMax - otherMax) <= tolerances[toUnderlying(aDir)].second);
0061   }
0062 };
0063 
0064 }  // namespace Acts