EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HelixHough_split.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file HelixHough_split.cpp
1 #include "HelixHough.h"
2 
3 #include "HelixRange.h"
4 #include "SimpleHit3D.h"
5 
6 #include <memory>
7 #include <vector>
8 
9 using namespace std;
10 
11 void HelixHough::splitIntoBins(unsigned int /*min_hits*/, unsigned int /*max_hits*/,
12  vector<HelixRange>& ranges,
13  vector<vector<SimpleHit3D> >& split_hits,
14  unsigned int zoomlevel) {
15  index_mapping.clear();
16  index_mapping.resize(hits_vec[zoomlevel]->size(), 0);
17  for (unsigned int i = 0; i < hits_vec[zoomlevel]->size(); i++) {
18  index_mapping[i] = (*(hits_vec[zoomlevel]))[i].get_id();
19  (*(hits_vec[zoomlevel]))[i].set_id(i);
20  }
21 
22  ranges.clear();
23  split_hits.clear();
24 
25  vote(zoomlevel);
26 
27  unsigned int n_entries = bins_vec[zoomlevel]->size();
28  if (n_entries == 0) {
29  return;
30  }
31 
32  unsigned int n_phi = n_phi_bins[zoomlevel];
33  unsigned int n_d = n_d_bins[zoomlevel];
34  unsigned int n_k = n_k_bins[zoomlevel];
35  unsigned int n_dzdl = n_dzdl_bins[zoomlevel];
36  unsigned int n_z0 = n_z0_bins[zoomlevel];
37 
38  unsigned int count = 0;
39  hits_vec[zoomlevel + 1]->clear();
40  setRange((*(bins_vec[zoomlevel]))[count], zoomranges[zoomlevel],
41  zoomranges[zoomlevel + 1], n_phi, n_d, n_k, n_dzdl, n_z0);
42  // scan over the bins in 5-D hough space
43  while (count < n_entries) {
44  hits_vec[zoomlevel + 1]->push_back(
45  (*(hits_vec[zoomlevel]))[(*(bins_vec[zoomlevel]))[count].entry]);
46  hits_vec[zoomlevel + 1]->back().set_id(
47  index_mapping[hits_vec[zoomlevel + 1]->back().get_id()]);
48 
49  count += 1;
50  if ((count == n_entries) || ((*(bins_vec[zoomlevel]))[count].bin !=
51  (*(bins_vec[zoomlevel]))[count - 1].bin)) {
52  if (((*(bins_vec[zoomlevel]))[count - 1].bin != 0) &&
53  (split_hits.size() == 0)) {
54  for (unsigned int b = 0; b < (*(bins_vec[zoomlevel]))[count - 1].bin;
55  ++b) {
56  BinEntryPair5D bp;
57  bp.bin = b;
58  setRange(bp, zoomranges[zoomlevel], zoomranges[zoomlevel + 1], n_phi,
59  n_d, n_k, n_dzdl, n_z0);
60  ranges.push_back(zoomranges[zoomlevel + 1]);
61  split_hits.push_back(vector<SimpleHit3D>());
62  }
63  setRange((*(bins_vec[zoomlevel]))[count - 1], zoomranges[zoomlevel],
64  zoomranges[zoomlevel + 1], n_phi, n_d, n_k, n_dzdl, n_z0);
65  }
66 
67  ranges.push_back(zoomranges[zoomlevel + 1]);
68  split_hits.push_back(*(hits_vec[zoomlevel + 1]));
69  if (count == n_entries) {
70  break;
71  }
72  hits_vec[zoomlevel + 1]->clear();
73 
74  unsigned int bin1 = (*(bins_vec[zoomlevel]))[count - 1].bin;
75  unsigned int bin2 = (*(bins_vec[zoomlevel]))[count].bin;
76  for (unsigned int b = (bin1 + 1); b < bin2; ++b) {
77  BinEntryPair5D bp;
78  bp.bin = b;
79  setRange(bp, zoomranges[zoomlevel], zoomranges[zoomlevel + 1], n_phi,
80  n_d, n_k, n_dzdl, n_z0);
81  ranges.push_back(zoomranges[zoomlevel + 1]);
82  split_hits.push_back(vector<SimpleHit3D>());
83  }
84 
85  setRange((*(bins_vec[zoomlevel]))[count], zoomranges[zoomlevel],
86  zoomranges[zoomlevel + 1], n_phi, n_d, n_k, n_dzdl, n_z0);
87  }
88  }
89 
90  unsigned int total_bins = n_phi * n_d * n_k * n_dzdl * n_z0;
91  for (unsigned int b = (1 + (*(bins_vec[zoomlevel]))[count - 1].bin);
92  b < total_bins; ++b) {
93  BinEntryPair5D bp;
94  bp.bin = b;
95  setRange(bp, zoomranges[zoomlevel], zoomranges[zoomlevel + 1], n_phi, n_d,
96  n_k, n_dzdl, n_z0);
97  ranges.push_back(zoomranges[zoomlevel + 1]);
98  split_hits.push_back(vector<SimpleHit3D>());
99  }
100 }