1 #ifndef RecoTracker_MkFitCore_interface_binnor_h 2 #define RecoTracker_MkFitCore_interface_binnor_h 22 template <
typename R,
typename I,
unsigned M,
unsigned N>
24 static_assert(M >=
N);
56 assert(M_size <= (1 << M));
80 template <
typename R,
typename I,
unsigned M,
unsigned N>
95 template <
typename R,
typename I,
unsigned int M,
unsigned int N>
118 template <
typename R,
typename I,
unsigned int M,
unsigned int N>
125 template <
typename R,
typename I,
unsigned M = 8 * sizeof(I),
unsigned N = 8 * sizeof(I)>
136 unsigned int n_bins =
std::ceil(extent / bin_width);
137 R extra = (n_bins * bin_width - extent) / 2;
166 template <
typename C,
169 unsigned int NB_first = 8 *
sizeof(
C),
170 unsigned int NB_count = 8 *
sizeof(
C)>
172 static_assert(std::is_same<C, unsigned short>() || std::is_same<C, unsigned int>());
173 static_assert(std::is_same<typename A1::real_t, typename A2::real_t>());
174 static_assert(A1::c_M + A2::c_M <= 32);
216 binnor(
const A1 &
a1,
const A2 &
a2,
bool radix =
true,
bool keep_cons =
false)
227 return {
m_a1.from_M_bin_to_N_bin(m_bin.bin1()),
m_a2.from_M_bin_to_N_bin(m_bin.bin2())};
230 B_pair
get_n_bin(
typename A1::index_t n1,
typename A2::index_t n2)
const {
return {n1, n2}; }
232 B_pair
get_n_bin(
typename A1::real_t r1,
typename A2::real_t
r2)
const {
233 return {
m_a1.from_R_to_N_bin(r1),
m_a2.from_R_to_N_bin(
r2)};
242 C_pair
get_content(
typename A1::index_t n1,
typename A2::index_t n2)
const {
309 if (c_bin.count == 0)
315 printf(
"i=%4u j=%4u %u %u %u %u\n",
i,
j, n_pair.bin1, n_pair.bin2, c_bin.first, c_bin.count);
constexpr int32_t ceil(float num)
I from_R_to_M_bin_safe(R r) const
axis(R min, R max, R bin_width)
static constexpr unsigned int c_M
I from_R_to_M_bin(R r) const
B_pair get_n_bin(typename A1::index_t n1, typename A2::index_t n2) const
void register_entry(B_pair bp)
I_pair from_R_rdr_to_N_bins(R r, R dr) const
static constexpr unsigned int c_N_end
std::vector< unsigned int > m_cons_masked
C_pair get_content(B_pair n_bin) const
I from_R_to_M_bin_safe(R r) const
I next_N_bin(I bin) const
axis_base(R min, R max, unsigned int M_size, unsigned int N_size)
axis_pow2_base(R min, R max)
std::vector< B_pair > m_cons
std::vector< C_pair > m_bins
const unsigned int m_num_N_bins
void finalize_registration()
void register_entry(typename A1::real_t r1, typename A2::real_t r2)
axis_base< R, I, M, N >::I_pair from_R_rdr_to_N_bins(R r, R dr) const
axis_pow2_u1(R min, R max)
unsigned int size_of_N() const
I from_R_to_N_bin_safe(R r) const
void register_entry_safe(typename A1::real_t r1, typename A2::real_t r2)
axis_base< R, I, M, N >::I_pair from_R_minmax_to_N_bins(R rmin, R rmax) const
static constexpr unsigned int c_N
const std::complex< double > I
I from_M_bin_to_N_bin(I m) const
I from_R_to_N_bin(R r) const
void register_m_bins(typename A1::index_t m1, typename A2::index_t m2)
binnor(const A1 &a1, const A2 &a2, bool radix=true, bool keep_cons=false)
void begin_registration(C n_items)
C_pair get_content(typename A1::real_t r1, typename A2::real_t r2) const
unsigned int size_of_M() const
axis(R min, R max, unsigned n_bins)
static constexpr unsigned int c_M2N_shift
static constexpr unsigned int c_A2_Mout_mask
B_pair(typename A1::index_t i1, typename A2::index_t i2)
static constexpr unsigned int c_A1_mask
static constexpr I c_M_mask
unsigned int mask_A2_M_bins() const
unsigned int packed_value
const unsigned int m_num_M_bins
unsigned int size_of_N() const
void sort(const std::vector< V > &values, std::vector< R > &ranks)
I_pair from_R_minmax_to_N_bins(R rmin, R rmax) const
static constexpr I c_N_mask
unsigned int size_of_M() const
B_pair get_n_bin(typename A1::real_t r1, typename A2::real_t r2) const
static constexpr unsigned int c_M_end
I next_N_bin(I bin) const
C_pair get_content(typename A1::index_t n1, typename A2::index_t n2) const
B_pair m_bin_to_n_bin(B_pair m_bin)
void reset_contents(bool shrink_vectors=true)
C_pair & ref_content(B_pair n_bin)
I from_R_to_N_bin_safe(R r) const