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/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 struct SurfaceBinningMatcher {
0021   /// The binning tolerance parameters
0022   using Range = std::pair<double, double>;
0023   std::vector<Range> tolerances{static_cast<int>(numAxisDirections()),
0024                                 {0., 0.}};
0025 
0026   SurfaceBinningMatcher() = default;
0027 
0028   SurfaceBinningMatcher(const std::vector<Range>& tolpars)
0029       : tolerances(tolpars) {}
0030 
0031   /// Check function for surface equivalent
0032   ///
0033   /// @param gctx [in] gctx the geometry context for this check
0034   /// @param aDir the axis direction value for the binning
0035   /// @param one first surface for checking
0036   /// @param other second surface for checking
0037   bool operator()(const Acts::GeometryContext& gctx, Acts::AxisDirection aDir,
0038                   const Acts::Surface* one, const Acts::Surface* other) const {
0039     // Fast exit
0040     if (one == other) {
0041       return true;
0042     }
0043 
0044     auto oneExt = one->polyhedronRepresentation(gctx, 1).extent();
0045     auto otherExt = other->polyhedronRepresentation(gctx, 1).extent();
0046 
0047     double oneMin = oneExt.min(aDir);
0048     double oneMax = oneExt.max(aDir);
0049 
0050     double otherMin = otherExt.min(aDir);
0051     double otherMax = otherExt.max(aDir);
0052 
0053     return (
0054         std::abs(oneMin - otherMin) <= tolerances[toUnderlying(aDir)].first &&
0055         std::abs(oneMax - otherMax) <= tolerances[toUnderlying(aDir)].second);
0056   }
0057 };
0058 
0059 }  // namespace Acts