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

88{}

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

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

116 : IPartCombItr(pieces, getFilter(filter))
117 {
118 }
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 127 of file IPartCombItr.cxx.

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

◆ getFilter()

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

Get a function corresponding to the specified FilterType enum.

Definition at line 74 of file IPartCombItr.cxx.

75 {
76 switch (filter){
77 case FilterType::All:
78 return [](const VecLInfo_t &) { return true; };
80 return uniqueObjects;
82 return uniqueRoIs;
83 default:
84 throw std::runtime_error("Unhandled FilterType enum value!");
85 }
86 }
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 171 of file IPartCombItr.cxx.

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

◆ operator*()

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

Dereference.

Definition at line 132 of file IPartCombItr.cxx.

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

◆ operator++() [1/2]

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

Pre-increment operator.

Definition at line 146 of file IPartCombItr.cxx.

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

◆ operator++() [2/2]

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

Post-increment operator.

Definition at line 156 of file IPartCombItr.cxx.

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

◆ operator->()

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

Definition at line 139 of file IPartCombItr.cxx.

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

◆ operator==()

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

Iterator comparison functions.

Definition at line 163 of file IPartCombItr.cxx.

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

◆ readCurrent()

void TrigCompositeUtils::IPartCombItr::readCurrent ( )
private

Definition at line 176 of file IPartCombItr.cxx.

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

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

◆ 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: