File GeometryHierarchyMap.hpp

namespace Acts

Set the Geometry Context PLUGIN.

Set the Calibration Context PLUGIN.

Convenience functions to ease creation of and Acts::InterpolatedMaterialMap and to avoid code duplication.

Set the Mangetic Field Context PLUGIN.

Convenience functions to ease creation of and Acts::InterpolatedBFieldMap and to avoid code duplication.

Currently implemented for the two most common formats: rz and xyz.

template<typename value_t>
class GeometryHierarchyMap
#include <Acts/Geometry/GeometryHierarchyMap.hpp>

Store values mapped into the geometry hierarchy.

The core functionality is to find an equivalent element, i.e. an identifier-value pair, for a given geometry identifier via

auto it = container.find(GeometryIdentifier(...));
if (it != container.end()) {
    ...
}
tparam value_t

stored value type

Trailing zero levels of stored geometry identifiers are used as broadcast values to refer to higher-level objects within the geometry, e.g. a geometry identifier with vanishing approach and sensitive index identifies a layer. An entry will all geometry identifier levels set to zero acts as the global default value.

The container also supports range-based iteration over all stored elements

for (const auto& element : container) {
    ...
}

and index-based access to stored elements and associated geometry identifiers

GeometryIdentifier id3 = container.idAt(3);
const auto& element4 = container.valueAt(4);

Adding elements is potentially expensive as the internal lookup structure must be updated. In addition, modifying an element in-place could change its identifier which would also break the lookup. Thus, the container can not be modified after construction to prevent misuse.

Note

No guarantees are given for the element order when using range-based or index-based access. Any apparent ordering must be considered an implementation detail and might change.

Public Types

using InputElement = typename std::pair<GeometryIdentifier, value_t>

Combined geometry identifier and value element. Only used for input.

using Iterator = typename std::vector<value_t>::const_iterator
using Size = typename std::vector<value_t>::size_type
using Value = value_t

Public Functions

inline GeometryHierarchyMap(std::vector<InputElement> elements)

Construct the container from the given elements.

Parameters

elements – input elements (must be unique with respect to identifier)

inline GeometryHierarchyMap(std::initializer_list<InputElement> elements)

Construct the container from an initializer list.

Parameters

elements – input initializer list

GeometryHierarchyMap() = default
GeometryHierarchyMap(const GeometryHierarchyMap&) = default
GeometryHierarchyMap(GeometryHierarchyMap&&) = default
~GeometryHierarchyMap() = default
inline Iterator begin() const

Return an iterator pointing to the beginning of the stored values.

inline bool empty() const

Check if any elements are stored.

inline Iterator end() const

Return an iterator pointing to the end of the stored values.

inline Iterator find(GeometryIdentifier id) const

Find the most specific value for a given geometry identifier.

This can be either from the element matching exactly to the given geometry id, if it exists, or from the element for the next available higher level within the geometry hierachy.

Parameters

id – geometry identifier for which information is requested

Returns

  • iterator – to an existing value

  • <tt>.end()</tt> – iterator if no matching element exists

inline GeometryIdentifier idAt(Size index) const

Access the geometry identifier for the i-th element with bounds check.

Throws

std::out_of_range – for invalid indices

GeometryHierarchyMap &operator=(const GeometryHierarchyMap&) = default
GeometryHierarchyMap &operator=(GeometryHierarchyMap&&) = default
inline Size size() const

Return the number of stored elements.

inline const Value &valueAt(Size index) const

Access the value of the i-th element in the container with bounds check.

Throws

std::out_of_range – for invalid indices

Private Types

using Identifier = GeometryIdentifier::Value

Private Functions

template<typename iterator_t>
inline void fill(iterator_t beg, iterator_t end)

Fill the container from the input elements.

This assumes that the elements are ordered and unique with respect to their identifiers.

Private Members

std::vector<Identifier> m_ids
std::vector<Identifier> m_masks
std::vector<Value> m_values

Private Static Functions

static inline constexpr bool equalWithinMask(Identifier lhs, Identifier rhs, Identifier mask)

Compare the two identifiers only within the masked bits.

static inline constexpr Identifier makeHighestLevelMask()

Construct a mask where only the highest level is set.

static inline constexpr Identifier makeLeadingLevelsMask(GeometryIdentifier id)

Construct a mask where all leading non-zero levels are set.

template<typename iterator_t>
static inline void sortAndCheckDuplicates(iterator_t beg, iterator_t end)

Ensure identifier ordering and uniqueness.