CMS 3D CMS Logo

trackAlgoPriorityOrder.h
Go to the documentation of this file.
1 #ifndef RecoTracker_FinalTrackSelectors_trackAlgoPriorityOrder_h
2 #define RecoTracker_FinalTrackSelectors_trackAlgoPriorityOrder_h
3 
5 
6 #include <array>
7 
18 namespace impl {
19 
74 
75  static_assert(reco::TrackBase::algoSize == sizeof(algoPriorityOrder) / sizeof(unsigned int),
76  "Please update me too after adding new enumerators to reco::TrackBase::TrackAlgorithm");
77 
86  constexpr unsigned int findIndex(const reco::TrackBase::TrackAlgorithm algo, const unsigned int index) {
87  return index < sizeof(algoPriorityOrder)/sizeof(unsigned int) ?
89  throw "Index out of bounds, this means that some reco::TrackBase::TrackAlgorithm enumerator is missing from impl::algoPriorityOrder array.";
90  }
91 
101  constexpr unsigned int priorityForAlgo(const reco::TrackBase::TrackAlgorithm algo) { return findIndex(algo, 0); }
102 
118  template <typename T, size_t N, size_t I>
119  struct MakeArray {
120  template <typename... Args>
121  constexpr static std::array<T, N> value(Args&&... args) {
122  return MakeArray<T, N, I - 1>::value(priorityForAlgo(static_cast<reco::TrackBase::TrackAlgorithm>(I - 1)),
123  std::forward<Args>(args)...);
124  }
125  };
126 
130  template <typename T, size_t N>
131  struct MakeArray<T, N, 0> {
132  template <typename... Args>
133  constexpr static std::array<T, N> value(Args&&... args) {
134  return std::array<T, N>{{std::forward<Args>(args)...}};
135  }
136  };
137 
146  template <typename T, size_t N>
147  constexpr std::array<T, N> makeArray() {
148  return MakeArray<T, N, N>::value();
149  }
150 
151 } // namespace impl
152 
157 constexpr std::array<unsigned int, reco::TrackBase::algoSize> trackAlgoPriorityOrder =
158  impl::makeArray<unsigned int, reco::TrackBase::algoSize>();
159 
160 #endif // DataFormats_TrackReco_trackAlgoPriorityOrder_h
static constexpr std::array< T, N > value(Args &&... args)
TrackAlgorithm
track algorithm
Definition: TrackBase.h:89
constexpr unsigned int findIndex(const reco::TrackBase::TrackAlgorithm algo, const unsigned int index)
constexpr std::array< T, N > makeArray()
const std::complex< double > I
Definition: I.h:8
constexpr reco::TrackBase::TrackAlgorithm algoPriorityOrder[]
#define N
Definition: blowfish.cc:9
constexpr std::array< unsigned int, reco::TrackBase::algoSize > trackAlgoPriorityOrder
constexpr unsigned int priorityForAlgo(const reco::TrackBase::TrackAlgorithm algo)
long double T
static constexpr std::array< T, N > value(Args &&... args)