ATLAS Offline Software
IPartCombItr.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRIGCOMPOSITEUTILS_IPARTCOMBITR_H
6 #define TRIGCOMPOSITEUTILS_IPARTCOMBITR_H
7 
8 #include <iterator>
9 #include <vector>
10 #include <tuple>
11 #include <utility>
12 #include <algorithm>
13 #include <functional>
18 
19 namespace TrigCompositeUtils
20 {
21  enum class FilterType
22  {
24  All,
28  UniqueRoIs,
31  };
33  bool uniqueObjects(const std::vector<LinkInfo<xAOD::IParticleContainer>> &links);
35  bool uniqueInitialRoIs(const std::vector<LinkInfo<xAOD::IParticleContainer>> &links);
37  bool uniqueRoIs(const std::vector<LinkInfo<xAOD::IParticleContainer>> &links);
38 
40  std::function<bool(const std::vector<LinkInfo<xAOD::IParticleContainer>> &)> getFilter(FilterType filter);
42  {
43  public:
44  using VecLInfo_t = std::vector<LinkInfo<xAOD::IParticleContainer>>;
45  using LInfoItr_t = VecLInfo_t::const_iterator;
46 
47  using iterator_category = std::input_iterator_tag;
49  using reference = const value_type &;
50  using pointer = const value_type *;
51  using difference_type = std::ptrdiff_t;
52 
54  IPartCombItr();
55 
66  const std::vector<std::tuple<std::size_t, LInfoItr_t, LInfoItr_t>> &pieces,
67  std::function<bool(const VecLInfo_t &)> filter);
68 
79  const std::vector<std::tuple<std::size_t, LInfoItr_t, LInfoItr_t>> &pieces,
81 
83  std::size_t size() const { return m_current.size(); }
84 
86  std::size_t nLegs() const { return m_linkInfoItrs.size(); }
87 
95  void reset();
96 
98  bool exhausted() const;
99 
101  reference operator*() const;
102  pointer operator->() const;
103 
106 
109 
111  bool operator==(const IPartCombItr &other) const;
112  bool operator!=(const IPartCombItr &other) const;
113 
114  private:
115  std::function<bool(const VecLInfo_t &)> m_filter;
116  std::vector<LInfoItr_t> m_linkInfoItrs;
118  void readCurrent();
120 
121  }; //> end class IPartCombItr
122 } // namespace TrigCompositeUtils
123 
124 #endif //> !TRIGCOMPOSITEUTILS_IPARTCOMBITR_H
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::uniqueRoIs
bool uniqueRoIs(const std::vector< LinkInfo< xAOD::IParticleContainer >> &links)
Helper function that returns true if no objects share a final RoI.
Definition: IPartCombItr.cxx:56
TrigCompositeUtils::FilterType::UniqueRoIs
@ UniqueRoIs
Do not allow any two objects to share an RoI.
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
TrigCompositeUtils::uniqueObjects
bool uniqueObjects(const std::vector< LinkInfo< xAOD::IParticleContainer >> &links)
Helper fucntion that returns true if no objects are repeated.
Definition: IPartCombItr.cxx:34
TrigCompositeUtils::FilterType::UniqueObjects
@ UniqueObjects
Do not allow any repeated objects.
TrigCompositeUtils::IPartCombItr::readCurrent
void readCurrent()
Definition: IPartCombItr.cxx:173
TrigCompositeUtils::IPartCombItr::operator*
reference operator*() const
Dereference.
Definition: IPartCombItr.cxx:129
TrigCompositeUtils::IPartCombItr::reset
void reset()
Reset the iterator to its starting point.
Definition: IPartCombItr.cxx:117
TrigCompositeUtils::FilterType::All
@ All
Allow all combinations.
reference
Definition: hcg.cxx:437
TrigCompositeUtils::IPartCombItr::difference_type
std::ptrdiff_t difference_type
Definition: IPartCombItr.h:51
TrigCompositeUtils::IPartCombItr
Definition: IPartCombItr.h:42
TrigCompositeUtils::IPartCombItr::VecLInfo_t
std::vector< LinkInfo< xAOD::IParticleContainer > > VecLInfo_t
Definition: IPartCombItr.h:44
KFromNItr.h
TrigCompositeUtils::IPartCombItr::IPartCombItr
IPartCombItr()
A default constructed iterator acts as a past-the-end iterator.
Definition: IPartCombItr.cxx:85
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::FilterType
FilterType
Definition: IPartCombItr.h:22
TrigCompositeUtils::IPartCombItr::reference
const value_type & reference
Definition: IPartCombItr.h:49
TrigCompositeUtils::IPartCombItr::value_type
VecLInfo_t value_type
Definition: IPartCombItr.h:48
DMTest::links
links
Definition: CLinks_v1.cxx:22
IParticleContainer.h
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==
bool operator==(const IPartCombItr &other) const
Iterator comparison functions.
Definition: IPartCombItr.cxx:160
TrigCompositeUtils::IPartCombItr::operator++
IPartCombItr & operator++()
Pre-increment operator.
Definition: IPartCombItr.cxx:143
TrigCompositeUtils::IPartCombItr::operator!=
bool operator!=(const IPartCombItr &other) const
Definition: IPartCombItr.cxx:168
TrigCompositeUtils::IPartCombItr::iterator_category
std::input_iterator_tag iterator_category
Definition: IPartCombItr.h:47
LinkInfo.h
TrigCompositeUtils::IPartCombItr::pointer
const value_type * pointer
Definition: IPartCombItr.h:50
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
TrigCompositeUtils::IPartCombItr::operator->
pointer operator->() const
Definition: IPartCombItr.cxx:136
TrigCompositeUtils::uniqueInitialRoIs
bool uniqueInitialRoIs(const std::vector< LinkInfo< xAOD::IParticleContainer >> &links)
Helper function that returns true if no objects share an initial RoI.
Definition: IPartCombItr.cxx:43
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
TrigCompositeUtils::IPartCombItr::exhausted
bool exhausted() const
True if this iterator is past the end.
Definition: IPartCombItr.cxx:124
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
ProductItr.h
TrigCompositeUtils::FilterType::UniqueInitialRoIs
@ UniqueInitialRoIs
Do not allow any two objects to share an initial RoI.
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
TrigCompositeUtils::IPartCombItr::m_linkInfoItrs
std::vector< LInfoItr_t > m_linkInfoItrs
Definition: IPartCombItr.h:116