ATLAS Offline Software
Loading...
Searching...
No Matches
IDTPM2::bins Namespace Reference

Functions

template<typename T, typename U = T>
size_t find_bin (const std::vector< T > &v, const U &x)

Function Documentation

◆ find_bin()

template<typename T, typename U = T>
size_t IDTPM2::bins::find_bin ( const std::vector< T > & v,
const U & x )

Definition at line 24 of file find_bin.h.

24 {
25 if ( v.size()<2) throw std::runtime_error("cannot define a bin range with fewer than two limits");
26 if ( x>=v.back() ) return v.size()-2;
27 if ( x<v.front() ) return 0;
28 typename std::vector<T>::const_iterator itr = std::lower_bound( v.begin(), v.end(), x );
29 return (itr-v.begin())-1;
30}
#define x