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 
75  };
76 
77  static_assert(reco::TrackBase::algoSize == sizeof(algoPriorityOrder)/sizeof(unsigned int), "Please update me too after adding new enumerators to reco::TrackBase::TrackAlgorithm");
78 
87  constexpr unsigned int findIndex(const reco::TrackBase::TrackAlgorithm algo, const unsigned int index) {
88  return index < sizeof(algoPriorityOrder)/sizeof(unsigned int) ?
89  (algo == algoPriorityOrder[index] ? index : findIndex(algo, index+1)) :
90  throw "Index out of bounds, this means that some reco::TrackBase::TrackAlgorithm enumerator is missing from impl::algoPriorityOrder array.";
91  }
92 
103  return findIndex(algo, 0);
104  }
105 
106 
122  template <typename T, size_t N, size_t I>
123  struct MakeArray {
124  template <typename ...Args>
125  constexpr static
126  std::array<T, N> value(Args&&... args) {
127  return MakeArray<T, N, I-1>::value(priorityForAlgo(static_cast<reco::TrackBase::TrackAlgorithm>(I-1)), std::forward<Args>(args)...);
128  }
129  };
130 
134  template <typename T, size_t N>
135  struct MakeArray<T, N, 0> {
136  template <typename ...Args>
137  constexpr static
138  std::array<T, N> value(Args&&... args) {
139  return std::array<T, N>{{std::forward<Args>(args)...}};
140  }
141  };
142 
143 
152  template <typename T, size_t N>
153  constexpr
154  std::array<T, N> makeArray() {
155  return MakeArray<T, N, N>::value();
156  }
157 
158 }
159 
164 constexpr std::array<unsigned int, reco::TrackBase::algoSize> trackAlgoPriorityOrder = impl::makeArray<unsigned int, reco::TrackBase::algoSize>();
165 
166 
167 #endif // DataFormats_TrackReco_trackAlgoPriorityOrder_h
168 
static std::array< T, N > value(Args &&...args)
std::array< T, N > makeArray()
unsigned int findIndex(const reco::TrackBase::TrackAlgorithm algo, const unsigned int index)
#define constexpr
unsigned int priorityForAlgo(const reco::TrackBase::TrackAlgorithm algo)
TrackAlgorithm
track algorithm
Definition: TrackBase.h:99
const std::complex< double > I
Definition: I.h:8
#define N
Definition: blowfish.cc:9
static std::array< T, N > value(Args &&...args)
std::array< unsigned int, reco::TrackBase::algoSize > trackAlgoPriorityOrder
reco::TrackBase::TrackAlgorithm algoPriorityOrder[]
long double T