13 #include "Acts/Geometry/GeometryIdentifier.hpp"
14 #include "Acts/Surfaces/Surface.hpp"
20 #include <boost/container/flat_map.hpp>
21 #include <boost/container/flat_set.hpp>
26 struct GeometryIdGetter {
28 constexpr Acts::GeometryIdentifier
operator()(Acts::GeometryIdentifier geometryId)
const {
32 constexpr Acts::GeometryIdentifier
operator()(Acts::GeometryIdentifier::Value encoded)
const {
33 return Acts::GeometryIdentifier(encoded);
38 const std::pair<Acts::GeometryIdentifier, T>& mapItem)
const {
44 -> decltype(thing.geometryId(), Acts::GeometryIdentifier()) {
45 return thing.geometryId();
49 inline auto operator()(std::reference_wrapper<T> thing)
const
50 -> decltype(thing.get().geometryId(), Acts::GeometryIdentifier()) {
51 return thing.get().geometryId();
55 struct CompareGeometryId {
59 template <
typename Left,
typename Right>
60 constexpr
bool operator()(Left&& lhs, Right&& rhs)
const {
78 boost::container::flat_multiset<T, detail::CompareGeometryId>;
98 inline Range<typename GeometryIdMultiset<T>::const_iterator>
selectVolume(
99 const GeometryIdMultiset<T>& container, Acts::GeometryIdentifier::Value volume) {
100 auto cmp = Acts::GeometryIdentifier().setVolume(volume);
101 auto beg = std::lower_bound(container.begin(), container.end(), cmp,
102 detail::CompareGeometryId{});
104 cmp = Acts::GeometryIdentifier().setVolume(volume + 1u);
109 std::lower_bound(beg, container.end(), cmp, detail::CompareGeometryId{});
112 template <
typename T>
113 inline auto selectVolume(
const GeometryIdMultiset<T>& container,
114 Acts::GeometryIdentifier
id) {
119 template <
typename T>
120 inline Range<typename GeometryIdMultiset<T>::const_iterator>
selectLayer(
121 const GeometryIdMultiset<T>& container, Acts::GeometryIdentifier::Value volume,
122 Acts::GeometryIdentifier::Value layer) {
123 auto cmp = Acts::GeometryIdentifier().setVolume(volume).setLayer(layer);
124 auto beg = std::lower_bound(container.begin(), container.end(), cmp,
125 detail::CompareGeometryId{});
127 cmp = Acts::GeometryIdentifier().setVolume(volume).setLayer(layer + 1u);
132 std::lower_bound(beg, container.end(), cmp, detail::CompareGeometryId{});
135 template <
typename T>
136 inline auto selectLayer(
const GeometryIdMultiset<T>& container,
137 Acts::GeometryIdentifier
id) {
138 return selectLayer(container,
id.volume(),
id.layer());
142 template <
typename T>
143 inline Range<typename GeometryIdMultiset<T>::const_iterator>
selectModule(
144 const GeometryIdMultiset<T>& container, Acts::GeometryIdentifier geoId) {
146 return makeRange(container.equal_range(geoId));
148 template <
typename T>
149 inline auto selectModule(
const GeometryIdMultiset<T>& container,
150 Acts::GeometryIdentifier::Value volume,
151 Acts::GeometryIdentifier::Value layer,
152 Acts::GeometryIdentifier::Value module) {
155 Acts::GeometryIdentifier().setVolume(volume).setLayer(layer).setSensitive(
160 template <
typename T>
161 inline GroupBy<typename GeometryIdMultiset<T>::const_iterator,
162 detail::GeometryIdGetter>
164 return makeGroupBy(container, detail::GeometryIdGetter());
171 template <
typename T>
174 using Key = Acts::GeometryIdentifier;
182 std::pair<Iterator, Iterator>
range(
const Acts::Surface& surface)
const {
184 return container->equal_range(surface.geometryId());