Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:27:39

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 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 
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>(binValues), {0., 0.}};
0024 
0025   SurfaceBinningMatcher() = default;
0026 
0027   SurfaceBinningMatcher(const std::vector<Range>& tolpars)
0028       : tolerances(tolpars) {}
0029 
0030   /// Check function for surface equivalent
0031   ///
0032   /// @param gctx [in] gctx the geometry context for this check
0033   /// @param bValue the binning value for the binning
0034   /// @param one first surface for checking
0035   /// @param other second surface for checking
0036   bool operator()(const Acts::GeometryContext& gctx, Acts::BinningValue bValue,
0037                   const Acts::Surface* one, const Acts::Surface* other) const {
0038     // Fast exit
0039     if (one == other) {
0040       return true;
0041     }
0042 
0043     auto oneExt = one->polyhedronRepresentation(gctx, 1).extent();
0044     auto otherExt = other->polyhedronRepresentation(gctx, 1).extent();
0045 
0046     double oneMin = oneExt.min(bValue);
0047     double oneMax = oneExt.max(bValue);
0048 
0049     double otherMin = otherExt.min(bValue);
0050     double otherMax = otherExt.max(bValue);
0051 
0052     return (std::abs(oneMin - otherMin) <= tolerances[bValue].first &&
0053             std::abs(oneMax - otherMax) <= tolerances[bValue].second);
0054   }
0055 };
0056 
0057 }  // namespace Acts