EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Auctioneer.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Auctioneer.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2018 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
11 #include <algorithm>
12 
13 namespace Acts {
14 namespace detail {
39 
43  VoidAuctioneer() = default;
44 
49  template <long unsigned int N>
50  std::array<bool, N> operator()(std::array<int, N> vCandidates) const {
51  std::array<bool, N> valids;
52 
53  for (unsigned int i = 0; i < vCandidates.size(); i++) {
54  valids[i] = (vCandidates[i] > 0) ? true : false;
55  }
56  return valids;
57  }
58 };
59 
63  FirstValidAuctioneer() = default;
64 
70  template <long unsigned int N>
71  std::array<bool, N> operator()(std::array<int, N> vCandidates) const {
72  std::array<bool, N> valids = {};
73 
74  for (unsigned int i = 0; i < vCandidates.size(); i++) {
75  if (vCandidates[i] > 0) {
76  valids[i] = true;
77  return valids;
78  }
79  }
80  return valids;
81  }
82 };
83 
89  HighestValidAuctioneer() = default;
90 
97  template <long unsigned int N>
98  std::array<bool, N> operator()(std::array<int, N> vCandidates) const {
99  std::array<bool, N> valids = {};
100 
101  auto highscore = std::max_element(vCandidates.begin(), vCandidates.end());
102  valids.at(std::distance(vCandidates.begin(), highscore)) = true;
103 
104  return valids;
105  }
106 };
107 
108 } // namespace detail
109 } // namespace Acts