ATLAS Offline Software
MaxCombinationCondition.icc
Go to the documentation of this file.
1 #ifndef MAXCOMBINATIONCONDITION_ICC
2 #define MAXCOMBINATIONCONDITION_ICC
3 
4 #include "CombinationsIterator.h"
5 #include <algorithm>
6 
7 template<typename T>
8 MaxCombinationCondition<T>::MaxCombinationCondition(std::size_t k,
9  std::unique_ptr<ICondition> cond, const T& cmp):
10  m_k{k},m_acceptingCondition{std::move(cond)}, m_cmp{cmp} {
11 }
12 
13 template<typename T>
14 bool
15 MaxCombinationCondition<T>::isSatisfied(const HypoJetVector& hjv,
16  const std::unique_ptr<ITrigJetHypoInfoCollector>& c) const {
17  auto n = hjv.size();
18  if (n < m_k) {return false;}
19  auto begin = CombinationsIterator(m_k, hjv);
20  auto end = begin.endIter();
21 
22 
23  return m_acceptingCondition->isSatisfied(*std::max_element(begin,
24  end,
25  m_cmp), c);
26 }
27 
28 
29 template<typename T>
30 std::string MaxCombinationCondition<T>::toString() const {
31  std::stringstream ss;
32  ss << "MaxCombinationCondition:"
33  << " k " << m_k
34  << " capacity " << m_k
35  << " accepting condition " << m_acceptingCondition->toString()
36  << '\n';
37  return ss.str();
38 
39 }
40 #endif