Analysis Software
Documentation for sPHENIX simulation 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 #include <array>
13 
14 namespace Acts {
15 namespace detail {
40 
44  VoidAuctioneer() = default;
45 
50  template <long unsigned int N>
51  std::array<bool, N> operator()(std::array<int, N> vCandidates) const {
52  std::array<bool, N> valids{};
53 
54  for (unsigned int i = 0; i < vCandidates.size(); i++) {
55  valids[i] = (vCandidates[i] > 0) ? true : false;
56  }
57  return valids;
58  }
59 };
60 
64  FirstValidAuctioneer() = default;
65 
71  template <long unsigned int N>
72  std::array<bool, N> operator()(std::array<int, N> vCandidates) const {
73  std::array<bool, N> valids = {};
74 
75  for (unsigned int i = 0; i < vCandidates.size(); i++) {
76  if (vCandidates[i] > 0) {
77  valids[i] = true;
78  return valids;
79  }
80  }
81  return valids;
82  }
83 };
84 
90  HighestValidAuctioneer() = default;
91 
98  template <long unsigned int N>
99  std::array<bool, N> operator()(std::array<int, N> vCandidates) const {
100  std::array<bool, N> valids = {};
101 
102  auto highscore = std::max_element(vCandidates.begin(), vCandidates.end());
103  valids.at(std::distance(vCandidates.begin(), highscore)) = true;
104 
105  return valids;
106  }
107 };
108 
109 } // namespace detail
110 } // namespace Acts