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 FilterFunc_t = std::function<bool(const IPartCombItr::VecLInfo_t &)>
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, FilterFunc_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

Static Public Member Functions

static FilterFunc_t getFilter (FilterType filter)
 Get a function corresponding to the specified FilterType enum.

Private Member Functions

void readCurrent ()

Private Attributes

FilterFunc_t m_filter
std::vector< LInfoItr_tm_linkInfoItrs
ProductItr< KFromNItrm_idxItr
VecLInfo_t m_current

Detailed Description

Definition at line 40 of file IPartCombItr.h.

Member Typedef Documentation

◆ difference_type

Definition at line 51 of file IPartCombItr.h.

◆ FilterFunc_t

Definition at line 45 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 44 of file IPartCombItr.h.

◆ pointer

◆ reference

◆ 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 89 of file IPartCombItr.cxx.

89{}

◆ IPartCombItr() [2/3]

TrigCompositeUtils::IPartCombItr::IPartCombItr ( const std::vector< std::tuple< std::size_t, LInfoItr_t, LInfoItr_t > > & pieces,
FilterFunc_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 91 of file IPartCombItr.cxx.

94 : m_filter(std::move(filter))
95 {
96 std::vector<KFromNItr> idxItrs;
97 idxItrs.reserve(pieces.size());
98 m_linkInfoItrs.reserve(pieces.size());
99 std::size_t size = 0;
100 for (const auto &tup : pieces)
101 {
102 std::size_t multiplicity = std::get<0>(tup);
103 LInfoItr_t begin = std::get<1>(tup);
104 LInfoItr_t end = std::get<2>(tup);
105 idxItrs.emplace_back(multiplicity, std::distance(begin, end));
106 m_linkInfoItrs.push_back(begin);
107 size += multiplicity;
108 }
109 m_idxItr = ProductItr<KFromNItr>(idxItrs, std::vector<KFromNItr>(idxItrs.size()));
110 m_current.assign(size, {});
111 readCurrent();
112 }
std::vector< LInfoItr_t > m_linkInfoItrs
std::size_t size() const
The size of each combination.
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 114 of file IPartCombItr.cxx.

117 : IPartCombItr(pieces, getFilter(filter))
118 {
119 }
IPartCombItr()
A default constructed iterator acts as a past-the-end iterator.
static FilterFunc_t getFilter(FilterType filter)
Get a function 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 128 of file IPartCombItr.cxx.

129 {
130 return m_idxItr.exhausted();
131 }

◆ getFilter()

IPartCombItr::FilterFunc_t TrigCompositeUtils::IPartCombItr::getFilter ( FilterType filter)
static

Get a function corresponding to the specified FilterType enum.

Definition at line 75 of file IPartCombItr.cxx.

76 {
77 switch (filter){
78 case FilterType::All:
79 return [](const VecLInfo_t &) { return true; };
81 return uniqueObjects;
83 return uniqueRoIs;
84 default:
85 throw std::runtime_error("Unhandled FilterType enum value!");
86 }
87 }
std::vector< LinkInfo< xAOD::IParticleContainer > > VecLInfo_t
bool uniqueObjects(const std::vector< LinkInfo< xAOD::IParticleContainer > > &links)
Helper function that returns true if no objects are repeated.
bool uniqueRoIs(const std::vector< LinkInfo< xAOD::IParticleContainer > > &links)
Helper function that returns true if no objects share a final RoI.
@ UniqueRoIs
Do not allow any two objects to share an RoI.
@ All
Allow all combinations.
@ UniqueObjects
Do not allow any repeated objects.

◆ nLegs()

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

The number of legs.

Definition at line 89 of file IPartCombItr.h.

89{ return m_linkInfoItrs.size(); }

◆ operator!=()

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

Definition at line 172 of file IPartCombItr.cxx.

173 {
174 return !(*this == other);
175 }

◆ operator*()

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

Dereference.

Definition at line 133 of file IPartCombItr.cxx.

134 {
135 if (exhausted())
136 throw std::runtime_error("Dereferencing past-the-end iterator");
137 return m_current;
138 }
bool exhausted() const
True if this iterator is past the end.

◆ operator++() [1/2]

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

Pre-increment operator.

Definition at line 147 of file IPartCombItr.cxx.

148 {
149 if (exhausted())
150 // Don't iterate an iterator that is already past the end
151 return *this;
152 ++m_idxItr;
153 readCurrent();
154 return *this;
155 }

◆ operator++() [2/2]

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

Post-increment operator.

Definition at line 157 of file IPartCombItr.cxx.

158 {
159 IPartCombItr ret(*this);
160 this->operator++();
161 return ret;
162 }
IPartCombItr & operator++()
Pre-increment operator.

◆ operator->()

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

Definition at line 140 of file IPartCombItr.cxx.

141 {
142 if (exhausted())
143 throw std::runtime_error("Dereferencing past-the-end iterator");
144 return &m_current;
145 }

◆ operator==()

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

Iterator comparison functions.

Definition at line 164 of file IPartCombItr.cxx.

165 {
166 // All past-the-end iterators compare equal
167 if (exhausted() && other.exhausted())
168 return true;
169 return m_idxItr == other.m_idxItr && m_linkInfoItrs == other.m_linkInfoItrs;
170 }

◆ readCurrent()

void TrigCompositeUtils::IPartCombItr::readCurrent ( )
private

Definition at line 177 of file IPartCombItr.cxx.

178 {
179 if (exhausted())
180 m_current.assign(m_current.size(), {});
181 else
182 {
183 auto currentItr = m_current.begin();
184 for (std::size_t iLeg = 0; iLeg < nLegs(); ++iLeg)
185 {
186 std::vector<std::size_t> indices = *(*m_idxItr)[iLeg];
187 for (std::size_t idx : indices)
188 *(currentItr++) = *(m_linkInfoItrs[iLeg] + idx);
189 }
190 if (!m_filter(m_current))
191 // If we fail the filter condition, advance the iterator again
192 this->operator++();
193 }
194 }
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 121 of file IPartCombItr.cxx.

122 {
123 // Reset each individual iterator and set our current value accordingly
124 m_idxItr.reset();
125 readCurrent();
126 }

◆ size()

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

The size of each combination.

Definition at line 86 of file IPartCombItr.h.

86{ return m_current.size(); }

Member Data Documentation

◆ m_current

VecLInfo_t TrigCompositeUtils::IPartCombItr::m_current
private

Definition at line 122 of file IPartCombItr.h.

◆ m_filter

FilterFunc_t TrigCompositeUtils::IPartCombItr::m_filter
private

Definition at line 118 of file IPartCombItr.h.

◆ m_idxItr

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

Definition at line 120 of file IPartCombItr.h.

◆ m_linkInfoItrs

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

Definition at line 119 of file IPartCombItr.h.


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