ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
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. More...
 
 IPartCombItr (const std::vector< std::tuple< std::size_t, LInfoItr_t, LInfoItr_t >> &pieces, std::function< bool(const VecLInfo_t &)> filter)
 The direct constructor. More...
 
 IPartCombItr (const std::vector< std::tuple< std::size_t, LInfoItr_t, LInfoItr_t >> &pieces, FilterType filter=FilterType::UniqueObjects)
 The direct constructor. More...
 
std::size_t size () const
 The size of each combination. More...
 
std::size_t nLegs () const
 The number of legs. More...
 
void reset ()
 Reset the iterator to its starting point. More...
 
bool exhausted () const
 True if this iterator is past the end. More...
 
reference operator* () const
 Dereference. More...
 
pointer operator-> () const
 
IPartCombItroperator++ ()
 Pre-increment operator. More...
 
IPartCombItr operator++ (int)
 Post-increment operator. More...
 
bool operator== (const IPartCombItr &other) const
 Iterator comparison functions. More...
 
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

Definition at line 48 of file IPartCombItr.h.

◆ VecLInfo_t

Definition at line 44 of file IPartCombItr.h.

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  }

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

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!=()

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  }

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

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

◆ 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:
TrigCompositeUtils::IPartCombItr::m_idxItr
ProductItr< KFromNItr > m_idxItr
Definition: IPartCombItr.h:117
TrigCompositeUtils::IPartCombItr::m_filter
std::function< bool(const VecLInfo_t &)> m_filter
Definition: IPartCombItr.h:115
TrigCompositeUtils::ProductItr
Iterates over all combinations of the provided input iterators.
Definition: ProductItr.h:43
TrigCompositeUtils::IPartCombItr::nLegs
std::size_t nLegs() const
The number of legs.
Definition: IPartCombItr.h:86
Trk::indices
std::pair< long int, long int > indices
Definition: AlSymMatBase.h:24
TrigCompositeUtils::IPartCombItr::readCurrent
void readCurrent()
Definition: IPartCombItr.cxx:173
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
TrigCompositeUtils::IPartCombItr
Definition: IPartCombItr.h:42
TrigCompositeUtils::IPartCombItr::IPartCombItr
IPartCombItr()
A default constructed iterator acts as a past-the-end iterator.
Definition: IPartCombItr.cxx:85
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
TrigCompositeUtils::IPartCombItr::size
std::size_t size() const
The size of each combination.
Definition: IPartCombItr.h:83
covarianceTool.filter
filter
Definition: covarianceTool.py:514
TrigCompositeUtils::IPartCombItr::m_current
VecLInfo_t m_current
Definition: IPartCombItr.h:119
TrigCompositeUtils::IPartCombItr::LInfoItr_t
VecLInfo_t::const_iterator LInfoItr_t
Definition: IPartCombItr.h:45
TrigCompositeUtils::IPartCombItr::operator++
IPartCombItr & operator++()
Pre-increment operator.
Definition: IPartCombItr.cxx:143
TrigCompositeUtils::getFilter
std::function< bool(const std::vector< LinkInfo< xAOD::IParticleContainer >> &)> getFilter(FilterType filter)
Get a lambda corresponding to the specified FilterType enum.
Definition: IPartCombItr.cxx:69
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
TrigCompositeUtils::IPartCombItr::exhausted
bool exhausted() const
True if this iterator is past the end.
Definition: IPartCombItr.cxx:124
TrigCompositeUtils::IPartCombItr::m_linkInfoItrs
std::vector< LInfoItr_t > m_linkInfoItrs
Definition: IPartCombItr.h:116
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54