CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Public Attributes | Static Public Attributes
mkfit::binnor< C, A1, A2, NB_first, NB_count > Struct Template Reference

#include <binnor.h>

Classes

struct  B_pair
 
struct  C_pair
 

Public Member Functions

void begin_registration (C n_items)
 
 binnor (const A1 &a1, const A2 &a2, bool radix=true, bool keep_cons=false)
 
void finalize_registration ()
 
C_pair get_content (B_pair n_bin) const
 
C_pair get_content (typename A1::index_t n1, typename A2::index_t n2) const
 
C_pair get_content (typename A1::real_t r1, typename A2::real_t r2) const
 
B_pair get_n_bin (typename A1::index_t n1, typename A2::index_t n2) const
 
B_pair get_n_bin (typename A1::real_t r1, typename A2::real_t r2) const
 
B_pair m_bin_to_n_bin (B_pair m_bin)
 
C_pairref_content (B_pair n_bin)
 
void register_entry (B_pair bp)
 
void register_entry (typename A1::real_t r1, typename A2::real_t r2)
 
void register_entry_safe (typename A1::real_t r1, typename A2::real_t r2)
 
void register_m_bins (typename A1::index_t m1, typename A2::index_t m2)
 
void reset_contents (bool shrink_vectors=true)
 

Public Attributes

const A1 & m_a1
 
const A2 & m_a2
 
std::vector< C_pairm_bins
 
std::vector< B_pairm_cons
 
std::vector< unsigned int > m_cons_masked
 
const bool m_do_masked
 
const bool m_keep_cons
 
const bool m_radix_sort
 
std::vector< C > m_ranks
 

Static Public Attributes

static constexpr unsigned int c_A1_mask = (1 << A1::c_M) - 1
 
static constexpr unsigned int c_A2_Mout_mask = ~(((1 << A2::c_M2N_shift) - 1) << A1::c_M)
 

Detailed Description

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
struct mkfit::binnor< C, A1, A2, NB_first, NB_count >

Definition at line 171 of file binnor.h.

Constructor & Destructor Documentation

◆ binnor()

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
mkfit::binnor< C, A1, A2, NB_first, NB_count >::binnor ( const A1 &  a1,
const A2 &  a2,
bool  radix = true,
bool  keep_cons = false 
)
inline

Definition at line 216 of file binnor.h.

217  : m_a1(a1),
218  m_a2(a2),
219  m_bins(m_a1.size_of_N() * m_a2.size_of_N()),
220  m_radix_sort(radix),
221  m_keep_cons(keep_cons),
222  m_do_masked(radix || !keep_cons) {}
const A2 & m_a2
Definition: binnor.h:207
std::vector< C_pair > m_bins
Definition: binnor.h:210
const bool m_radix_sort
Definition: binnor.h:212
const bool m_do_masked
Definition: binnor.h:214
const A1 & m_a1
Definition: binnor.h:206
const bool m_keep_cons
Definition: binnor.h:213

Member Function Documentation

◆ begin_registration()

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
void mkfit::binnor< C, A1, A2, NB_first, NB_count >::begin_registration ( n_items)
inline

Definition at line 264 of file binnor.h.

Referenced by mkfit::LayerOfHits::beginRegistrationOfHits(), mkfit::StdSeq::clean_cms_seedtracks_iter(), mkfit::MkBuilder::import_seeds(), and mkfit::LayerOfHits::suckInHits().

264  {
265  if (m_keep_cons)
266  m_cons.reserve(n_items);
267  if (m_do_masked)
268  m_cons_masked.reserve(n_items);
269  }
std::vector< unsigned int > m_cons_masked
Definition: binnor.h:209
std::vector< B_pair > m_cons
Definition: binnor.h:208
const bool m_do_masked
Definition: binnor.h:214
const bool m_keep_cons
Definition: binnor.h:213

◆ finalize_registration()

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
void mkfit::binnor< C, A1, A2, NB_first, NB_count >::finalize_registration ( )
inline

Definition at line 289 of file binnor.h.

Referenced by mkfit::StdSeq::clean_cms_seedtracks_iter(), mkfit::LayerOfHits::endRegistrationOfHits(), mkfit::MkBuilder::import_seeds(), and mkfit::LayerOfHits::suckInHits().

289  {
290  unsigned int n_entries = m_do_masked ? m_cons_masked.size() : m_cons.size();
291  if (m_radix_sort && n_entries >= (m_keep_cons ? 128 : 256)) {
292  radix_sort<unsigned int, C> radix;
293  radix.sort(m_cons_masked, m_ranks);
294  } else {
295  m_ranks.resize(n_entries);
296  std::iota(m_ranks.begin(), m_ranks.end(), 0);
297  if (m_do_masked)
298  std::sort(
299  m_ranks.begin(), m_ranks.end(), [&](auto &a, auto &b) { return m_cons_masked[a] < m_cons_masked[b]; });
300  else
301  std::sort(m_ranks.begin(), m_ranks.end(), [&](auto &a, auto &b) {
302  return m_cons[a].mask_A2_M_bins() < m_cons[b].mask_A2_M_bins();
303  });
304  }
305 
306  for (C i = 0; i < m_ranks.size(); ++i) {
307  C j = m_ranks[i];
308  C_pair &c_bin = ref_content(m_bin_to_n_bin(m_keep_cons ? m_cons[j] : B_pair(m_cons_masked[j])));
309  if (c_bin.count == 0)
310  c_bin.first = i;
311  ++c_bin.count;
312 
313 #ifdef DEBUG
314  B_pair n_pair = m_bin_to_n_bin(m_cons[j]);
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);
316 #endif
317  }
318 
319  if (m_keep_cons)
320  m_cons.shrink_to_fit();
321  if (m_do_masked) {
322  m_cons_masked.clear();
323  m_cons_masked.shrink_to_fit();
324  }
325  }
std::vector< unsigned int > m_cons_masked
Definition: binnor.h:209
std::vector< B_pair > m_cons
Definition: binnor.h:208
const bool m_radix_sort
Definition: binnor.h:212
std::vector< C > m_ranks
Definition: binnor.h:211
const bool m_do_masked
Definition: binnor.h:214
double b
Definition: hdecay.h:118
const bool m_keep_cons
Definition: binnor.h:213
double a
Definition: hdecay.h:119
B_pair m_bin_to_n_bin(B_pair m_bin)
Definition: binnor.h:226
C_pair & ref_content(B_pair n_bin)
Definition: binnor.h:238

◆ get_content() [1/3]

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
C_pair mkfit::binnor< C, A1, A2, NB_first, NB_count >::get_content ( B_pair  n_bin) const
inline

Definition at line 240 of file binnor.h.

Referenced by mkfit::StdSeq::clean_cms_seedtracks_iter(), mkfit::binnor< bin_content_t, axis_phi_t, axis_eta_t, 18, 14 >::get_content(), mkfit::LayerOfHits::phiQBinContent(), and mkfit::LayerOfHits::printBins().

240 { return m_bins[n_bin.bin2() * m_a1.size_of_N() + n_bin.bin1()]; }
std::vector< C_pair > m_bins
Definition: binnor.h:210
const A1 & m_a1
Definition: binnor.h:206

◆ get_content() [2/3]

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
C_pair mkfit::binnor< C, A1, A2, NB_first, NB_count >::get_content ( typename A1::index_t  n1,
typename A2::index_t  n2 
) const
inline

Definition at line 242 of file binnor.h.

242  {
243  return m_bins[n2 * m_a1.size_of_N() + n1];
244  }
std::vector< C_pair > m_bins
Definition: binnor.h:210
const A1 & m_a1
Definition: binnor.h:206

◆ get_content() [3/3]

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
C_pair mkfit::binnor< C, A1, A2, NB_first, NB_count >::get_content ( typename A1::real_t  r1,
typename A2::real_t  r2 
) const
inline

Definition at line 246 of file binnor.h.

246  {
247  return get_content(m_a1.from_R_to_N_bin(r1), m_a2.from_R_to_N_bin(r2));
248  }
const A2 & m_a2
Definition: binnor.h:207
C_pair get_content(B_pair n_bin) const
Definition: binnor.h:240
const A1 & m_a1
Definition: binnor.h:206

◆ get_n_bin() [1/2]

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
B_pair mkfit::binnor< C, A1, A2, NB_first, NB_count >::get_n_bin ( typename A1::index_t  n1,
typename A2::index_t  n2 
) const
inline

Definition at line 230 of file binnor.h.

230 { return {n1, n2}; }

◆ get_n_bin() [2/2]

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
B_pair mkfit::binnor< C, A1, A2, NB_first, NB_count >::get_n_bin ( typename A1::real_t  r1,
typename A2::real_t  r2 
) const
inline

Definition at line 232 of file binnor.h.

232  {
233  return {m_a1.from_R_to_N_bin(r1), m_a2.from_R_to_N_bin(r2)};
234  }
const A2 & m_a2
Definition: binnor.h:207
const A1 & m_a1
Definition: binnor.h:206

◆ m_bin_to_n_bin()

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
B_pair mkfit::binnor< C, A1, A2, NB_first, NB_count >::m_bin_to_n_bin ( B_pair  m_bin)
inline

Definition at line 226 of file binnor.h.

Referenced by mkfit::binnor< bin_content_t, axis_phi_t, axis_eta_t, 18, 14 >::finalize_registration().

226  {
227  return {m_a1.from_M_bin_to_N_bin(m_bin.bin1()), m_a2.from_M_bin_to_N_bin(m_bin.bin2())};
228  }
const A2 & m_a2
Definition: binnor.h:207
const A1 & m_a1
Definition: binnor.h:206

◆ ref_content()

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
C_pair& mkfit::binnor< C, A1, A2, NB_first, NB_count >::ref_content ( B_pair  n_bin)
inline

Definition at line 238 of file binnor.h.

Referenced by mkfit::binnor< bin_content_t, axis_phi_t, axis_eta_t, 18, 14 >::finalize_registration().

238 { return m_bins[n_bin.bin2() * m_a1.size_of_N() + n_bin.bin1()]; }
std::vector< C_pair > m_bins
Definition: binnor.h:210
const A1 & m_a1
Definition: binnor.h:206

◆ register_entry() [1/2]

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
void mkfit::binnor< C, A1, A2, NB_first, NB_count >::register_entry ( B_pair  bp)
inline

Definition at line 271 of file binnor.h.

Referenced by mkfit::binnor< bin_content_t, axis_phi_t, axis_eta_t, 18, 14 >::register_entry(), mkfit::binnor< bin_content_t, axis_phi_t, axis_eta_t, 18, 14 >::register_entry_safe(), and mkfit::binnor< bin_content_t, axis_phi_t, axis_eta_t, 18, 14 >::register_m_bins().

271  {
272  if (m_keep_cons)
273  m_cons.push_back(bp);
274  if (m_do_masked)
275  m_cons_masked.push_back(bp.mask_A2_M_bins());
276  }
std::vector< unsigned int > m_cons_masked
Definition: binnor.h:209
std::vector< B_pair > m_cons
Definition: binnor.h:208
const bool m_do_masked
Definition: binnor.h:214
const bool m_keep_cons
Definition: binnor.h:213

◆ register_entry() [2/2]

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
void mkfit::binnor< C, A1, A2, NB_first, NB_count >::register_entry ( typename A1::real_t  r1,
typename A2::real_t  r2 
)
inline

Definition at line 278 of file binnor.h.

278  {
279  register_entry({m_a1.from_R_to_M_bin(r1), m_a2.from_R_to_M_bin(r2)});
280  }
const A2 & m_a2
Definition: binnor.h:207
void register_entry(B_pair bp)
Definition: binnor.h:271
const A1 & m_a1
Definition: binnor.h:206

◆ register_entry_safe()

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
void mkfit::binnor< C, A1, A2, NB_first, NB_count >::register_entry_safe ( typename A1::real_t  r1,
typename A2::real_t  r2 
)
inline

Definition at line 282 of file binnor.h.

Referenced by mkfit::StdSeq::clean_cms_seedtracks_iter(), mkfit::MkBuilder::import_seeds(), mkfit::LayerOfHits::registerHit(), and mkfit::LayerOfHits::suckInHits().

282  {
283  register_entry({m_a1.from_R_to_M_bin_safe(r1), m_a2.from_R_to_M_bin_safe(r2)});
284  }
const A2 & m_a2
Definition: binnor.h:207
void register_entry(B_pair bp)
Definition: binnor.h:271
const A1 & m_a1
Definition: binnor.h:206

◆ register_m_bins()

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
void mkfit::binnor< C, A1, A2, NB_first, NB_count >::register_m_bins ( typename A1::index_t  m1,
typename A2::index_t  m2 
)
inline

Definition at line 287 of file binnor.h.

287 { register_entry({m1, m2}); }
void register_entry(B_pair bp)
Definition: binnor.h:271

◆ reset_contents()

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
void mkfit::binnor< C, A1, A2, NB_first, NB_count >::reset_contents ( bool  shrink_vectors = true)
inline

Definition at line 252 of file binnor.h.

Referenced by mkfit::LayerOfHits::beginRegistrationOfHits(), and mkfit::LayerOfHits::suckInHits().

252  {
253  if (m_keep_cons) {
254  m_cons.clear();
255  if (shrink_vectors)
256  m_cons.shrink_to_fit();
257  }
258  m_bins.assign(m_bins.size(), C_pair());
259  m_ranks.clear();
260  if (shrink_vectors)
261  m_ranks.shrink_to_fit();
262  }
std::vector< B_pair > m_cons
Definition: binnor.h:208
std::vector< C_pair > m_bins
Definition: binnor.h:210
std::vector< C > m_ranks
Definition: binnor.h:211
const bool m_keep_cons
Definition: binnor.h:213

Member Data Documentation

◆ c_A1_mask

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
constexpr unsigned int mkfit::binnor< C, A1, A2, NB_first, NB_count >::c_A1_mask = (1 << A1::c_M) - 1
static

◆ c_A2_Mout_mask

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
constexpr unsigned int mkfit::binnor< C, A1, A2, NB_first, NB_count >::c_A2_Mout_mask = ~(((1 << A2::c_M2N_shift) - 1) << A1::c_M)
static

◆ m_a1

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
const A1& mkfit::binnor< C, A1, A2, NB_first, NB_count >::m_a1

◆ m_a2

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
const A2& mkfit::binnor< C, A1, A2, NB_first, NB_count >::m_a2

◆ m_bins

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
std::vector<C_pair> mkfit::binnor< C, A1, A2, NB_first, NB_count >::m_bins

◆ m_cons

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
std::vector<B_pair> mkfit::binnor< C, A1, A2, NB_first, NB_count >::m_cons

◆ m_cons_masked

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
std::vector<unsigned int> mkfit::binnor< C, A1, A2, NB_first, NB_count >::m_cons_masked

◆ m_do_masked

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
const bool mkfit::binnor< C, A1, A2, NB_first, NB_count >::m_do_masked

◆ m_keep_cons

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
const bool mkfit::binnor< C, A1, A2, NB_first, NB_count >::m_keep_cons

◆ m_radix_sort

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
const bool mkfit::binnor< C, A1, A2, NB_first, NB_count >::m_radix_sort

◆ m_ranks

template<typename C, typename A1, typename A2, unsigned int NB_first = 8 * sizeof(C), unsigned int NB_count = 8 * sizeof(C)>
std::vector<C> mkfit::binnor< C, A1, A2, NB_first, NB_count >::m_ranks