1 #ifndef LARCOREALG_GEOMETRY_DETAILS_GEOMETRY_ITERATORS_H 2 #define LARCOREALG_GEOMETRY_DETAILS_GEOMETRY_ITERATORS_H 47 template <
typename LocalID,
typename GEOID>
50 template <
typename GEOID>
58 static_assert(std::is_base_of<LocalID_t, GEOID>{},
"template type GEOID is not a LocalID_t");
107 GeoID_t const& ID()
const {
return id; }
115 if (at_end())
return;
116 if (++local_index() < limit)
return;
117 localID().isValid =
false;
121 bool at_end()
const {
return local_index() == limit; }
125 ID_t limit = LocalID_t::InvalidID;
128 LocalID_t const& localID()
const {
return ID(); }
134 ID_t const& local_index()
const {
return localID().deepestIndex(); }
157 template <
typename LocalID,
typename GEOID>
165 static_assert(std::is_base_of<LocalID_t, GEOID>{},
"template type GEOID is not a LocalID_t");
217 using ID_t = std::remove_reference_t<
218 decltype(std::declval<LocalID_t>().deepestIndex())>;
224 if (upper_iterator::at_end())
return;
227 if (++local_index() < limit)
return;
231 upper_iterator::next();
245 ID_t limit = LocalID_t::InvalidID;
254 template <
typename LocalID>
258 template <
typename GEOIT>
259 std::enable_if_t<std::is_base_of_v<geometry_iterator_base, GEOIT>, std::ostream&>
operator<<(
263 return out <<
"geometry_iterator{ " << *it <<
" }";
282 template <
typename Element,
typename GEOIDITER>
287 static_assert(std::is_base_of<geometry_iterator_base, id_iterator_t>{},
288 "template class for geometry_element_iterator" 289 " must be a geometry iterator");
296 using GeoID_t =
typename id_iterator_t::GeoID_t;
342 if (ptr)
return *ptr;
344 <<
"iterator attempted to obtain geometry element " << std::string(ID());
380 template <
typename Element>
386 #endif // LARCOREALG_GEOMETRY_DETAILS_GEOMETRY_ITERATORS_H std::forward_iterator_tag iterator_category
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
LocalID LocalID_t
type of the ID we change
geometry_element_iterator(GeometryCore const *geo, GeoID_t const &start_from)
Constructor: points to the specified geometry element.
bool operator!=(iterator const &as) const
Returns true if the two iterators point to different objects.
value_type const & reference
iterator operator++(int)
Postfix increment: returns the current iterator, then increments it.
geometry_iterator_base()=default
Default constructor; do not use a default-constructed iterator as-is!
bool validElement(GeometryCore const *geom, CryostatID const &id)
CryostatGeo const * getElementPtr(GeometryCore const *geom, CryostatID const &id)
Classes identifying readout-related concepts.
Base forward iterator browsing all cryostat IDs in the detector.
bool operator!=(id_iterator_base const &as) const
id_iterator_base< LocalID, LocalID > id_iterator
std::ptrdiff_t difference_type
value_type const * pointer
typename id_iterator_t::LocalID_t LocalID_t
ID_t const & local_index() const
Returns the index (part if the ID) this iterator runs on.
value_type const * pointer
constexpr bool operator==(CryostatID const &a, CryostatID const &b)
Comparison: the IDs point to the same cryostat (validity is ignored)
geometry_element_iterator(GeometryCore const *geo, id_iterator_t &&iter)
Constructor: points to the same element as the specified ID iterator.
id_iterator_base(GeometryCore const *geom, GeoID_t const &start_from)
Constructor: points to the specified cryostat.
typename id_iterator_t::GeoID_t GeoID_t
unsigned int NSiblings(GeometryCore const *geom, CryostatID const &id)
pointer operator->() const
Returns the element ID the iterator points to.
LocalID_t const & localID() const
Returns the type of ID we act on.
pointer operator->() const
Returns a pointer to the ID the iterator points to.
GeometryCore const * geometry() const
Returns a pointer to the geometry.
value_type const * pointer
std::enable_if_t< std::is_base_of_v< geometry_iterator_base, GEOIT >, std::ostream & > operator<<(std::ostream &out, GEOIT const &it)
Stream output for all geometry ID iterator types: prints the pointed ID.
typename upper_iterator::GeoID_t GeoID_t
value_type const & reference
iterator operator++(int)
Postfix increment: returns the current iterator, then increments it.
bool operator!=(id_iterator_base const &as) const
Returns true if the two iterators point to different elements.
geo::GeometryCore const * geom
bool operator==(iterator const &as) const
Returns true if the two iterators point to the same object.
pointer operator->() const
Returns a pointer to the element the iterator points to (or nullptr)
std::forward_iterator_tag iterator_category
Description of geometry of one entire detector.
ID_t & local_index()
Returns the index (part if the ID) this iterator runs on (non-const)
Definition of data types for geometry description.
geometry_iterator_base(GeometryCore const *geom)
Constructor: associates with the specified geometry.
void next()
Skips to the next cryostat.
std::ptrdiff_t difference_type
std::ptrdiff_t difference_type
iterator operator++(int)
Postfix increment: returns the current iterator, then increments it.
reference operator*() const
Returns the ID the iterator points to.
void next()
Skips to the next element.
reference operator*() const
Returns the element ID the iterator points to.
std::remove_reference_t< decltype(std::declval< LocalID_t >().deepestIndex())> ID_t
specific type for element ID
id_iterator_t id_iterator
unsigned int CryostatID_t
Type for the ID number.
LocalID_t & localID()
Returns the type of ID we act on (non-const version)
bool operator==(id_iterator_base const &as) const
Returns true if the two iterators point to the same cryostat.
LocalID_t & localID()
Returns the type of ID we act on.
GeometryCore const * pGeo
pointer to the geometry
iterator & operator++()
Prefix increment: returns this iterator pointing to the next element.
GEOID GeoID_t
type of the actual ID stored in the iterator
geo::GeometryCore const * geom
Base class for geometry iterators (note: this is not an iterator)
id_iterator_base(GeometryCore const *geo, GeoID_t const &start_from)
Constructor: points to the specified element.
iterator & operator++()
Prefix increment: returns this iterator pointing to the next element.
iterator & operator++()
Prefix increment: returns this iterator pointing to the next cryostat.
ID_t & local_index()
Returns the index (part if the ID) this iterator runs on.
std::forward_iterator_tag iterator_category
geometry_element_iterator(GeometryCore const *geo, id_iterator_t const &iter)
Constructor: points to the same element as the specified ID iterator.
Forward iterator browsing all geometry elements in the detector.
bool at_end() const
Returns whether this iterator has reached the end.
value_type const & reference
bool operator==(id_iterator_base const &as) const
Returns true if the two iterators point to the same element.
Namespace collecting geometry-related classes utilities.
GeoID_t & ID()
Returns the actual type of ID we store.
reference operator*() const
Returns the geometry element the iterator points to.
cet::coded_exception< error, detail::translate > exception
The data type to uniquely identify a cryostat.
typename LocalID_t::CryostatID_t ID_t
LocalID_t const & ID() const
Returns the ID of the pointed geometry element.
Element const * ElementPtr_t