|
|
|||
File indexing completed on 2026-06-06 07:49:14
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/Utilities/IAxis.hpp" 0012 0013 #include <algorithm> 0014 #include <any> 0015 #include <typeinfo> 0016 0017 #include <boost/container/small_vector.hpp> 0018 0019 namespace Acts { 0020 0021 namespace detail { 0022 0023 template <typename> 0024 class AnyGridView; 0025 template <typename> 0026 class AnyGridConstView; 0027 0028 } // namespace detail 0029 0030 /// Base class for all grid types 0031 class IGrid { 0032 public: 0033 virtual ~IGrid() = default; 0034 0035 /// Get a dynamically sized vector of axis objects for inspection 0036 /// @return a vector of axis pointers 0037 virtual boost::container::small_vector<const IAxis*, 3> axes() const = 0; 0038 0039 /// Get the number of dimensions of the grid 0040 /// @return The number of dimensions of the grid 0041 virtual std::size_t dimensions() const = 0; 0042 0043 /// Get the type of the values stored in the grid 0044 /// @return The type of the values stored in the grid 0045 virtual std::type_info const& valueType() const = 0; 0046 0047 /// Type-erased interface to access the contents of the grid 0048 /// 0049 /// @note This interface has non-negligible runtime overhead due to packing 0050 /// and unpacking from/to @c std::any and the dynamically sized index and 0051 /// point types. **USE WITH CARE!** 0052 /// 0053 /// @{ 0054 using AnyIndexType = boost::container::small_vector<std::size_t, 3>; 0055 /// Type alias for dynamic point type (coordinates as vector of doubles) 0056 using AnyPointType = boost::container::small_vector<double, 3>; 0057 0058 /// Get the lower left edge of a bin for a given set of indices 0059 /// @param indices The indices to get the lower left edge of the bin for 0060 /// @return The lower left edge of the bin 0061 virtual AnyPointType lowerLeftBinEdgeAny(AnyIndexType indices) const = 0; 0062 0063 /// Get the upper right edge of a bin for a given set of indices 0064 /// @param indices The indices to get the upper right edge of the bin for 0065 /// @return The upper right edge of the bin 0066 virtual AnyPointType upperRightBinEdgeAny(AnyIndexType indices) const = 0; 0067 0068 /// Get the center of a bin for a given set of indices 0069 /// @param indices The indices to get the center of the bin for 0070 /// @return The center of the bin 0071 virtual AnyPointType binCenterAny(AnyIndexType indices) const = 0; 0072 0073 /// Get the number of local bins for a given set of indices 0074 /// @return The number of local bins 0075 virtual AnyIndexType numLocalBinsAny() const = 0; 0076 0077 /// @} 0078 0079 /// Helper to print out the grid 0080 /// @param os the output stream 0081 /// @param grid the grid to print 0082 /// @return the output stream 0083 friend std::ostream& operator<<(std::ostream& os, const IGrid& grid) { 0084 grid.toStream(os); 0085 return os; 0086 } 0087 0088 friend bool operator==(const IGrid& lhs, const IGrid& rhs) { 0089 auto lhsAxes = lhs.axes(); 0090 auto rhsAxes = rhs.axes(); 0091 return lhsAxes.size() == rhsAxes.size() && 0092 std::equal(lhsAxes.begin(), lhsAxes.end(), rhsAxes.begin(), 0093 [](const IAxis* a, const IAxis* b) { return *a == *b; }); 0094 } 0095 0096 protected: 0097 /// @param os Output stream to write grid representation to 0098 virtual void toStream(std::ostream& os) const = 0; 0099 0100 /// Get the value of a bin for a given set of indices 0101 /// @param indices The indices to get the value of the bin for 0102 /// @return The value of the bin: the @c std::any contains a const pointer to 0103 /// the value 0104 virtual std::any atLocalBinsAny(AnyIndexType indices) const = 0; 0105 0106 /// Get the value of a bin for a given set of indices 0107 /// @param indices The indices to get the value of the bin for 0108 /// @return The value of the bin: the @c std::any contains a pointer to the 0109 /// value 0110 virtual std::any atLocalBinsAny(AnyIndexType indices) = 0; 0111 0112 template <typename> 0113 friend class AnyGridView; 0114 template <typename> 0115 friend class AnyGridConstView; 0116 }; 0117 0118 } // namespace Acts
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|