ATLAS Offline Software
TrigCompositeUtils/TrigCompositeUtils/Combinators.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 #ifndef TRIGCOMPOSITEUTILS_COMBINATORS_H
7 #define TRIGCOMPOSITEUTILS_COMBINATORS_H
8 
9 #include <vector>
10 #include <set>
11 #include <functional>
12 
13 namespace HLT {
19  public:
23  CombinationGenerator( const std::initializer_list<size_t>& collectionSizes );
24  void add( size_t nextColl) { m_maxes.push_back( nextColl ); reset(); }
25  void reset();
26  size_t size() const { return m_maxes.size(); }
30  const std::vector<size_t>& operator()() const { return m_current; }
31  const std::vector<size_t>& current() const { return m_current; }
32 
36  void operator++();
37 
41  operator bool() const;
42  private:
43  std::vector<size_t> m_maxes;
44  std::vector<size_t> m_current;
45  };
46 
52  public:
53  UniqueCombinationGenerator( size_t nelems, size_t comblen);
54  void reset();
55  size_t size() const { return m_combLen; }
56  const std::vector<size_t>& operator()() const { return current(); }
57  const std::vector<size_t>& current() const { return m_current; }
58 
59  void operator++();
60  operator bool() const;
61  private:
62  size_t m_nElements;
63  size_t m_combLen;
64  std::vector<size_t> m_current;
65  std::vector<bool> m_bitmask;
66  };
67 
73  public:
74  void add( const UniqueCombinationGenerator& gen );
75  void reset();
76  size_t size() const;
77  const std::vector<size_t>& operator()() const { return current(); }
78  const std::vector<size_t>& current() const { return m_current; }
79 
80  void operator++();
81  operator bool() const;
82 
83 
84  private:
85  std::vector<UniqueCombinationGenerator> m_generators;
86  std::vector<size_t> m_current;
87  void cache();
88  };
89 
101  template<typename ... Collections>
103  public:
104 
107 
108  template<typename ... Iterators>
109  void operator()( Iterators ... iter ) const;
110 
111  void reset() { }
115  operator bool() const;
116 
120  void operator++();
121  private:
123  };
124 
125 
139  typedef std::vector<size_t> Index1DVec;
140  typedef std::vector< Index1DVec > Index2DVec;
141 
142  void elementsInUniqueCombinations( const Index2DVec& indices, std::set<size_t>& participants, std::function<bool(const Index1DVec&)>&& filter = [](const Index1DVec&){ return true; } );
143 
149  void findUniqueCombinations( const Index2DVec& indices, std::vector<std::vector<size_t> >& combinations, std::function<bool(const Index1DVec&)>&& filter = [](const Index1DVec&){ return true; } );
150 
151 
152 
153 }
154 
155 #endif // DECISIONHANDLING_COMBINATORS_H
HLT::UniqueCombinationGenerator::m_nElements
size_t m_nElements
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:62
HLT::NestedUniqueCombinationGenerator::m_current
std::vector< size_t > m_current
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:86
HLT::UniqueCombinationGenerator::size
size_t size() const
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:55
HLT::UniqueCombinationGenerator::operator++
void operator++()
Definition: Combinators.cxx:67
HLT::NestedUniqueCombinationGenerator::reset
void reset()
Definition: Combinators.cxx:87
HLT::UniqueCombinationGenerator::reset
void reset()
Definition: Combinators.cxx:56
Trk::indices
std::pair< long int, long int > indices
Definition: AlSymMatBase.h:24
HLT::NestedUniqueCombinationGenerator
An ensemble of UniqueCombinationGenerator API description.
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:72
HLT::UniqueCombinationGenerator::UniqueCombinationGenerator
UniqueCombinationGenerator(size_t nelems, size_t comblen)
Definition: Combinators.cxx:44
MuonSegmentReaderConfig.Collections
Collections
Definition: MuonSegmentReaderConfig.py:77
HLT::findUniqueCombinations
void findUniqueCombinations(const Index2DVec &indices, std::vector< std::vector< size_t > > &combinations, std::function< bool(const Index1DVec &)> &&filter)
Creates unique combinations of elements.
Definition: Combinators.cxx:159
HLT::CombinationGenerator::operator++
void operator++()
moves to the next combination
Definition: Combinators.cxx:29
master.gen
gen
Definition: master.py:32
HLT::CombinationIterator::reset
void reset()
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:111
covarianceTool.filter
filter
Definition: covarianceTool.py:514
HLT::Index1DVec
std::vector< size_t > Index1DVec
Unique combinations for case when one can not repeat the index (i.e.
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:139
HLT::UniqueCombinationGenerator::current
const std::vector< size_t > & current() const
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:57
HLT::NestedUniqueCombinationGenerator::operator()
const std::vector< size_t > & operator()() const
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:77
HLT::CombinationGenerator::CombinationGenerator
CombinationGenerator(const std::initializer_list< size_t > &collectionSizes)
construct combnations maker with the sizes of collection to which it should be applied
Definition: Combinators.cxx:12
HLT::UniqueCombinationGenerator::m_current
std::vector< size_t > m_current
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:64
HLT::CombinationIterator::m_generator
CombinationGenerator m_generator
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:122
HLT::UniqueCombinationGenerator::operator()
const std::vector< size_t > & operator()() const
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:56
HLT
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
Definition: HLTResultReader.h:26
HLT::CombinationGenerator
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:18
HLT::CombinationIterator
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:102
HLT::NestedUniqueCombinationGenerator::operator++
void operator++()
Definition: Combinators.cxx:102
HLT::CombinationGenerator::reset
void reset()
Definition: Combinators.cxx:19
HLT::NestedUniqueCombinationGenerator::add
void add(const UniqueCombinationGenerator &gen)
Definition: Combinators.cxx:83
HLT::NestedUniqueCombinationGenerator::current
const std::vector< size_t > & current() const
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:78
HLT::NestedUniqueCombinationGenerator::size
size_t size() const
Definition: Combinators.cxx:95
HLT::CombinationGenerator::add
void add(size_t nextColl)
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:24
HLT::UniqueCombinationGenerator::m_combLen
size_t m_combLen
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:63
HLT::elementsInUniqueCombinations
void elementsInUniqueCombinations(const Index2DVec &indices, std::set< size_t > &participants, std::function< bool(const Index1DVec &)> &&filter)
Definition: Combinators.cxx:154
HLT::NestedUniqueCombinationGenerator::cache
void cache()
Definition: Combinators.cxx:120
HLT::CombinationGenerator::m_current
std::vector< size_t > m_current
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:44
HLT::NestedUniqueCombinationGenerator::m_generators
std::vector< UniqueCombinationGenerator > m_generators
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:85
HLT::UniqueCombinationGenerator
Generator of unique combinations (no indices are repeated) API description.
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:51
python.combo.combinations
def combinations(items, n)
Definition: combo.py:85
HLT::CombinationGenerator::operator()
const std::vector< size_t > & operator()() const
returns current combination
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:30
HLT::CombinationGenerator::current
const std::vector< size_t > & current() const
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:31
HLT::CombinationGenerator::m_maxes
std::vector< size_t > m_maxes
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:43
HLT::CombinationIterator::operator++
void operator++()
moves to the next combination
HLT::CombinationIterator::operator()
void operator()(Iterators ... iter) const
HLT::Index2DVec
std::vector< Index1DVec > Index2DVec
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:140
HLT::CombinationIterator::~CombinationIterator
~CombinationIterator()
HLT::UniqueCombinationGenerator::m_bitmask
std::vector< bool > m_bitmask
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:65
HLT::CombinationIterator::CombinationIterator
CombinationIterator(Collections ... coll)
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
HLT::CombinationGenerator::size
size_t size() const
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:26