EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HelixHoughSpace_v1.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file HelixHoughSpace_v1.cc
1 #include "HelixHoughSpace_v1.h"
2 
3 using namespace std;
4 
6  : _para_min(),
7  _para_max(),
8  _zoom_profile(),
9  _max_zoom() {
10 
11  for (unsigned int i=0; i<5; i++)
12  {
13  _para_min[i] = -9999;
14  _para_max[i] = -9999;
15 
16  for (unsigned int j=0; j<ZOOMLEVEL_MAX; j++)
17  {
18  _zoom_profile[j][i]= 1;
19  }
20  }
21  _max_zoom = 0;
22 }
23 
25  *this = hough_space;
26  return;
27 }
28 
29 void HelixHoughSpace_v1::add_one_zoom(std::vector<unsigned int>& one_zoom) {
30 
31 // cout<<"one_zoom added "<< one_zoom[0]<<endl;
32  _zoom_profile[_max_zoom][0] = one_zoom[0];
33  _zoom_profile[_max_zoom][1] = one_zoom[1];
34  _zoom_profile[_max_zoom][2] = one_zoom[2];
35  _zoom_profile[_max_zoom][3] = one_zoom[3];
36  _zoom_profile[_max_zoom][4] = one_zoom[4];
37 // cout<<"zoom_profile "<<_zoom_profile[_max_zoom][0]<<endl;
38  _max_zoom++;
39 // cout<<"max_zoom "<< _max_zoom<<endl;
40 }
41 
43 
44  return _max_zoom;
45 
46 }
47 
49 
50  cout << "HelixHoughSpace::print_zoom_profile:" << endl;
51 
52  for (unsigned int i=0; i<5; i++) {
53  for (unsigned int j=0; j<_max_zoom; j++) {
54  cout << "[" << j << "][" << i << "] = " << _zoom_profile[j][i] << endl;
55  }
56  }
57 }
58 
60 
61  cout << "HelixHoughSpace::print_para_range:" <<endl;
62 
63  cout << "kappa max = " << _para_max[0] << endl;
64  cout << "kappa min = " << _para_min[0] << endl;
65  cout << "phi max = " << _para_max[1] << endl;
66  cout << "phi min = " << _para_min[1] << endl;
67  cout << "d max = " << _para_max[2] << endl;
68  cout << "d min = " << _para_min[2] << endl;
69  cout << "dzdl max = " << _para_max[3] << endl;
70  cout << "dzdl min = " << _para_min[3] << endl;
71  cout << "z0 max = " << _para_max[4] << endl;
72  cout << "z0 min = " << _para_min[4] << endl;
73 
74 }
75 
76 float HelixHoughSpace_v1::get_kappa_bin_size(unsigned int zoomlevel) const {
77 
78  float binsize = _para_max[0]-_para_min[0];
79  for (unsigned int izoom = 0; izoom<zoomlevel+1; izoom++){
80  binsize /= (float) _zoom_profile[izoom][0];
81  }
82  return binsize;
83 }
84 
85 float HelixHoughSpace_v1::get_phi_bin_size(unsigned int zoomlevel) const {
86 
87  float binsize = _para_max[1]-_para_min[1];
88  for (unsigned int izoom = 0; izoom<zoomlevel+1; izoom++){
89  binsize /= (float) _zoom_profile[izoom][1];
90  }
91  return binsize;
92 }
93 
94 float HelixHoughSpace_v1::get_d_bin_size(unsigned int zoomlevel) const {
95 
96  float binsize = _para_max[2]-_para_min[2];
97  for (unsigned int izoom = 0; izoom<zoomlevel+1; izoom++){
98  binsize /= (float) _zoom_profile[izoom][2];
99  }
100  return binsize;
101 }
102 
103 float HelixHoughSpace_v1::get_dzdl_bin_size(unsigned int zoomlevel) const {
104 
105  float binsize = _para_max[3]-_para_min[3];
106  for (unsigned int izoom = 0; izoom<zoomlevel+1; izoom++){
107  binsize /= (float) _zoom_profile[izoom][3];
108  }
109  return binsize;
110 }
111 
112 float HelixHoughSpace_v1::get_z0_bin_size(unsigned int zoomlevel) const {
113 
114  float binsize = _para_max[4]-_para_min[4];
115 // cout<<"z0_bin_size "<<binsize<<endl;
116  for (unsigned int izoom = 0; izoom<zoomlevel+1; izoom++){
117  binsize /= (float) _zoom_profile[izoom][4];
118  }
119 // cout<<"z0_bin_size after "<<binsize<<endl;
120  return binsize;
121 }
122 /*
123 float HelixHoughSpace_v1::get_kappa_center(unsigned int zoomlevel, std::vector<unsigned int>& v_ik) const {
124  float center = get_kappa_min();
125  for (unsigned int i=0; i<zoomlevel+1; i++){
126  center += get_kappa_bin_size(i)*v_ik[i];
127  }
128  center += 0.5*get_kappa_bin_size(zoomlevel);
129  return center;
130 }
131 
132 float HelixHoughSpace_v1::get_phi_center(unsigned int zoomlevel, std::vector<unsigned int>& v_ip) const {
133  float center = get_phi_min();
134  for (unsigned int i=0; i<zoomlevel+1; i++){
135  center += get_phi_bin_size(i)*v_ip[i];
136  }
137  center += 0.5*get_phi_bin_size(zoomlevel);
138  return center;
139 }
140 float HelixHoughSpace_v1::get_d_center(unsigned int zoomlevel, std::vector<unsigned int>& v_id) const {
141  float center = get_d_min();
142  for (unsigned int i=0; i<zoomlevel+1; i++){
143  center += get_d_bin_size(i)*v_id[i];
144  }
145  center += 0.5*get_d_bin_size(zoomlevel);
146  return center;
147 }
148 
149 float HelixHoughSpace_v1::get_dzdl_center(unsigned int zoomlevel, std::vector<unsigned int>& v_il) const {
150  float center = get_dzdl_min();
151  for (unsigned int i=0; i<zoomlevel+1; i++) {
152  center += get_dzdl_bin_size(i)*v_il[i];
153  }
154  center += 0.5*get_dzdl_bin_size(zoomlevel);
155  return center;
156 }
157 float HelixHoughSpace_v1::get_z0_center(unsigned int zoomlevel, std::vector<unsigned int>& v_iz) const {
158  float center = get_z0_min();
159  for (unsigned int i=0; i<zoomlevel+1; i++){
160  center += get_z0_bin_size(i)*v_iz[i];
161  }
162  center += 0.5*get_z0_bin_size(zoomlevel);
163  return center;
164 }
165 */
166 unsigned int HelixHoughSpace_v1::get_kappa_bin(unsigned int zoomlevel, float kappa) const {
167  unsigned int kbin=0;
168  kappa -= get_kappa_min();
169  for (unsigned int i=0; i<zoomlevel+1; i++ ) {
170  kbin = kappa/get_kappa_bin_size(i);
171  kappa -= (kbin)*get_kappa_bin_size(i);
172  }
173  return kbin;
174 }
175 
176 unsigned int HelixHoughSpace_v1::get_phi_bin(unsigned int zoomlevel, float phi) const {
177  unsigned int pbin =0;
178 // cout<<"phi "<< phi<<endl;
179  phi -= get_phi_min();
180 // cout<<"phi-phi_min "<<phi<<endl;
181  for (unsigned int i=0; i<zoomlevel+1; i++) {
182 // cout<<"phi-phi_min-phi_prev "<< phi<<endl;
183 // cout<<"phi_bin_size "<<get_phi_bin_size(i)<<endl;
184  pbin = phi/get_phi_bin_size(i);
185  phi -= (pbin)*get_phi_bin_size(i);
186  }
187 
188  return pbin;
189 }
190 
191 unsigned int HelixHoughSpace_v1::get_d_bin(unsigned int zoomlevel, float d) const {
192  unsigned int dbin =0;
193  d -= get_d_min();
194  for (unsigned int i=0; i<zoomlevel+1; i++) {
195  dbin = d/get_d_bin_size(i);
196  d -= (dbin)*get_d_bin_size(zoomlevel);
197  }
198  return dbin;
199 }
200 
201 unsigned int HelixHoughSpace_v1::get_dzdl_bin(unsigned int zoomlevel, float dzdl) const {
202  unsigned int lbin =0;
203 // cout<<"dzdl "<<dzdl<<endl;
204 // cout<<"dzdl_min "<<get_dzdl_min()<<endl;
205  dzdl -= get_dzdl_min();
206 // cout<<"dzdl-dzdl_min "<<dzdl<<endl;
207  for (unsigned int i=0; i<zoomlevel+1; i++) {
208 // dzdl -= (lbin)*get_dzdl_bin_size(i);
209  lbin = dzdl/get_dzdl_bin_size(i);
210  dzdl -= (lbin)*get_dzdl_bin_size(i);
211 // cout<<"dzdl_bin_size "<<get_dzdl_bin_size(i)<<endl;
212 // cout<<"dzdl-prevzoom "<<dzdl<<endl;
213 // if (zoomlevel==1) cout<<"i "<<i<<" lbin "<<lbin<<endl;
214  if (lbin >= get_n_dzdl_bins(i)) return 999;
215 // if (lbin<0) return 9999; // lbin is unsigned - test for <0 is non sensical
216  }
217 // cout<<"lbin "<<lbin<<endl;
218  return lbin;
219 }
220 
221 unsigned int HelixHoughSpace_v1::get_z0_bin(unsigned int zoomlevel, float z0) const {
222  unsigned int zbin =0;
223  for (unsigned int i =0; i<zoomlevel+1; i++) {
224  zbin = z0/get_z0_bin_size(i);
225  z0 -= (zbin)*get_z0_bin_size(i);
226  }
227  return zbin;
228 }
229 
230 unsigned int HelixHoughSpace_v1::get_bin(unsigned int zoomlevel, unsigned int* bins) const {
231 
232 // cout<<"HoughSpace:: zoom "<<zoomlevel<<" kappa "<<bins[0]<<endl;
233  unsigned int bin = 0;
234  for (unsigned int izoom = 0; izoom<zoomlevel; izoom++) bin += get_n_kappa_bins(izoom)*get_n_phi_bins(izoom)*get_n_d_bins(izoom)*get_n_dzdl_bins(izoom)*get_n_z0_bins(izoom);
235  bin = bins[0] + _zoom_profile[zoomlevel][0] * (bins[1] + _zoom_profile[zoomlevel][1] * (bins[2] + _zoom_profile[zoomlevel][2] *( bins[3] + _zoom_profile[zoomlevel][3] * bins[4])));
236  return bin;
237 
238 // bin = kappabin + nkappabin* (phibin + nphibin* (dbin + ndbin *( dzdlbin + ndzdlbin*z0bin) ) )
239 
240 }
241 /*
242 unsigned int HelixHoughSpace_v1::get_bin() {
243  cout<<"HoughSpace:: zoom "<<zoomlevel<<" kappa "<<kappa_bin<<endl;
244  unsigned int bin =0;
245  //= kappa_bin + _zoom_profile[zoomlevel][0] * (phi_bin + _zoom_profile[zoomlevel][1] * (d_bin + _zoom_profile[zoomlevel][2] *( dzdl_bin + _zoom_profile[zoomlevel][3] * z0_bin)));
246  cout<<"HoughSpace:: bin "<<bin<<endl;
247  return bin;
248 }
249 */