ATLAS Offline Software
Loading...
Searching...
No Matches
TrigCompositeUtils::IPartCombItr Class Reference

#include <IPartCombItr.h>

Collaboration diagram for TrigCompositeUtils::IPartCombItr:

Public Types

using VecLInfo_t = std::vector<LinkInfo<xAOD::IParticleContainer>>
using LInfoItr_t = VecLInfo_t::const_iterator
using iterator_category = std::input_iterator_tag
using value_type = VecLInfo_t
using reference = const value_type &
using pointer = const value_type *
using difference_type = std::ptrdiff_t

Public Member Functions

 IPartCombItr ()
 A default constructed iterator acts as a past-the-end iterator.
 IPartCombItr (const std::vector< std::tuple< std::size_t, LInfoItr_t, LInfoItr_t > > &pieces, std::function< bool(const VecLInfo_t &)> filter)
 The direct constructor.
 IPartCombItr (const std::vector< std::tuple< std::size_t, LInfoItr_t, LInfoItr_t > > &pieces, FilterType filter=FilterType::UniqueObjects)
 The direct constructor.
std::size_t size () const
 The size of each combination.
std::size_t nLegs () const
 The number of legs.
void reset ()
 Reset the iterator to its starting point.
bool exhausted () const
 True if this iterator is past the end.
reference operator* () const
 Dereference.
pointer operator-> () const
IPartCombItroperator++ ()
 Pre-increment operator.
IPartCombItr operator++ (int)
 Post-increment operator.
bool operator== (const IPartCombItr &other) const
 Iterator comparison functions.
bool operator!= (const IPartCombItr &other) const

Private Member Functions

void readCurrent ()

Private Attributes

std::function< bool(const VecLInfo_t &)> m_filter
std::vector< LInfoItr_tm_linkInfoItrs
ProductItr< KFromNItrm_idxItr
VecLInfo_t m_current

Detailed Description

Definition at line 41 of file IPartCombItr.h.

Member Typedef Documentation

◆ difference_type

Definition at line 51 of file IPartCombItr.h.

◆ iterator_category

using TrigCompositeUtils::IPartCombItr::iterator_category = std::input_iterator_tag

Definition at line 47 of file IPartCombItr.h.

◆ LInfoItr_t

using TrigCompositeUtils::IPartCombItr::LInfoItr_t = VecLInfo_t::const_iterator

Definition at line 45 of file IPartCombItr.h.

◆ pointer

Definition at line 50 of file IPartCombItr.h.

◆ reference

Definition at line 49 of file IPartCombItr.h.

◆ value_type

◆ VecLInfo_t

Constructor & Destructor Documentation

◆ IPartCombItr() [1/3]

TrigCompositeUtils::IPartCombItr::IPartCombItr ( )

A default constructed iterator acts as a past-the-end iterator.

Definition at line 85 of file IPartCombItr.cxx.

85{}

◆ IPartCombItr() [2/3]

TrigCompositeUtils::IPartCombItr::IPartCombItr ( const std::vector< std::tuple< std::size_t, LInfoItr_t, LInfoItr_t > > & pieces,
std::function< bool(const VecLInfo_t &)> filter )

The direct constructor.

Takes a vector of tuples. The last two elements of each tuple are start and end iterators describing ranges of IParticleContainer LinkInfos. The first element describes how many particles from this range are used in the output combinations

Definition at line 87 of file IPartCombItr.cxx.

90 : m_filter(std::move(filter))
91 {
92 std::vector<KFromNItr> idxItrs;
93 idxItrs.reserve(pieces.size());
94 m_linkInfoItrs.reserve(pieces.size());
95 std::size_t size = 0;
96 for (const auto &tup : pieces)
97 {
98 std::size_t multiplicity = std::get<0>(tup);
99 LInfoItr_t begin = std::get<1>(tup);
100 LInfoItr_t end = std::get<2>(tup);
101 idxItrs.emplace_back(multiplicity, std::distance(begin, end));
102 m_linkInfoItrs.push_back(begin);
103 size += multiplicity;
104 }
105 m_idxItr = ProductItr<KFromNItr>(idxItrs, std::vector<KFromNItr>(idxItrs.size()));
106 m_current.assign(size, {});
107 readCurrent();
108 }
std::vector< LInfoItr_t > m_linkInfoItrs
std::size_t size() const
The size of each combination.
std::function< bool(const VecLInfo_t &)> m_filter
VecLInfo_t::const_iterator LInfoItr_t
ProductItr< KFromNItr > m_idxItr

◆ IPartCombItr() [3/3]

TrigCompositeUtils::IPartCombItr::IPartCombItr ( const std::vector< std::tuple< std::size_t, LInfoItr_t, LInfoItr_t > > & pieces,
FilterType filter = FilterType::UniqueObjects )

The direct constructor.

Takes a vector of tuples. The last two elements of each tuple are start and end iterators describing ranges of IParticleContainer LinkInfos. The first element describes how many particles from this range are used in the output combinations

Definition at line 110 of file IPartCombItr.cxx.

113 : IPartCombItr(pieces, getFilter(filter))
114 {
115 }
IPartCombItr()
A default constructed iterator acts as a past-the-end iterator.
std::function< bool(const std::vector< LinkInfo< xAOD::IParticleContainer > > &)> getFilter(FilterType filter)
Get a lambda corresponding to the specified FilterType enum.

Member Function Documentation

◆ exhausted()

bool TrigCompositeUtils::IPartCombItr::exhausted ( ) const

True if this iterator is past the end.

Definition at line 124 of file IPartCombItr.cxx.

125 {
126 return m_idxItr.exhausted();
127 }

◆ nLegs()

std::size_t TrigCompositeUtils::IPartCombItr::nLegs ( ) const
inline

The number of legs.

Definition at line 86 of file IPartCombItr.h.

86{ return m_linkInfoItrs.size(); }

◆ operator!=()

bool TrigCompositeUtils::IPartCombItr::operator!= ( const IPartCombItr & other) const

Definition at line 168 of file IPartCombItr.cxx.

169 {
170 return !(*this == other);
171 }

◆ operator*()

IPartCombItr::reference TrigCompositeUtils::IPartCombItr::operator* ( ) const

Dereference.

Definition at line 129 of file IPartCombItr.cxx.

130 {
131 if (exhausted())
132 throw std::runtime_error("Dereferencing past-the-end iterator");
133 return m_current;
134 }
bool exhausted() const
True if this iterator is past the end.

◆ operator++() [1/2]

IPartCombItr & TrigCompositeUtils::IPartCombItr::operator++ ( )

Pre-increment operator.

Definition at line 143 of file IPartCombItr.cxx.

144 {
145 if (exhausted())
146 // Don't iterate an iterator that is already past the end
147 return *this;
148 ++m_idxItr;
149 readCurrent();
150 return *this;
151 }

◆ operator++() [2/2]

IPartCombItr TrigCompositeUtils::IPartCombItr::operator++ ( int )

Post-increment operator.

Definition at line 153 of file IPartCombItr.cxx.

154 {
155 IPartCombItr ret(*this);
156 this->operator++();
157 return ret;
158 }
IPartCombItr & operator++()
Pre-increment operator.

◆ operator->()

IPartCombItr::pointer TrigCompositeUtils::IPartCombItr::operator-> ( ) const

Definition at line 136 of file IPartCombItr.cxx.

137 {
138 if (exhausted())
139 throw std::runtime_error("Dereferencing past-the-end iterator");
140 return &m_current;
141 }

◆ operator==()

bool TrigCompositeUtils::IPartCombItr::operator== ( const IPartCombItr & other) const

Iterator comparison functions.

Definition at line 160 of file IPartCombItr.cxx.

161 {
162 // All past-the-end iterators compare equal
163 if (exhausted() && other.exhausted())
164 return true;
165 return m_idxItr == other.m_idxItr && m_linkInfoItrs == other.m_linkInfoItrs;
166 }

◆ readCurrent()

void TrigCompositeUtils::IPartCombItr::readCurrent ( )
private

Definition at line 173 of file IPartCombItr.cxx.

174 {
175 if (exhausted())
176 m_current.assign(m_current.size(), {});
177 else
178 {
179 auto currentItr = m_current.begin();
180 for (std::size_t iLeg = 0; iLeg < nLegs(); ++iLeg)
181 {
182 std::vector<std::size_t> indices = *(*m_idxItr)[iLeg];
183 for (std::size_t idx : indices)
184 *(currentItr++) = *(m_linkInfoItrs[iLeg] + idx);
185 }
186 if (!m_filter(m_current))
187 // If we fail the filter condition, advance the iterator again
188 this->operator++();
189 }
190 }
std::size_t nLegs() const
The number of legs.
std::pair< long int, long int > indices

◆ reset()

void TrigCompositeUtils::IPartCombItr::reset ( )

Reset the iterator to its starting point.

Note that this resets all component iterators, so it will not reset this object to its starting point if any of the iterators passed to it were not initially in their starting positions

Definition at line 117 of file IPartCombItr.cxx.

118 {
119 // Reset each individual iterator and set our current value accordingly
120 m_idxItr.reset();
121 readCurrent();
122 }

◆ size()

std::size_t TrigCompositeUtils::IPartCombItr::size ( ) const
inline

The size of each combination.

Definition at line 83 of file IPartCombItr.h.

83{ return m_current.size(); }

Member Data Documentation

◆ m_current

VecLInfo_t TrigCompositeUtils::IPartCombItr::m_current
private

Definition at line 119 of file IPartCombItr.h.

◆ m_filter

std::function<bool(const VecLInfo_t &)> TrigCompositeUtils::IPartCombItr::m_filter
private

Definition at line 115 of file IPartCombItr.h.

◆ m_idxItr

ProductItr<KFromNItr> TrigCompositeUtils::IPartCombItr::m_idxItr
private

Definition at line 117 of file IPartCombItr.h.

◆ m_linkInfoItrs

std::vector<LInfoItr_t> TrigCompositeUtils::IPartCombItr::m_linkInfoItrs
private

Definition at line 116 of file IPartCombItr.h.


The documentation for this class was generated from the following files: