13 #include <xmmintrin.h>
77 unsigned int*
C,
unsigned int* bins_start,
78 unsigned int* bins_end) {
79 unsigned int SIZE = A.size();
80 std::vector<BinEntryPair5D>
B(SIZE);
82 for (
unsigned int i = 0; i < SIZE; ++i) {
87 bins_end[0] = C[0] - 1;
88 for (
unsigned int i = 1; i < MAX; ++i) {
89 bins_start[i] = C[i - 1];
91 bins_end[i] = C[i] - 1;
94 for (
int i = SIZE - 1; i >= 0; --i) {
95 B[C[A[i].bin] - 1] = A[i];
99 for (
unsigned int i = 0; i < SIZE; ++i) {
105 unsigned int*
B,
unsigned int*
C,
106 unsigned int* bins_start,
unsigned int* bins_end) {
107 for (
unsigned int i = 0; i < SIZE; ++i) {
108 C[(A[i]) >> 20] += 1;
111 bins_end[0] = C[0] - 1;
112 for (
unsigned int i = 1; i < MAX; ++i) {
113 bins_start[i] = C[i - 1];
115 bins_end[i] = C[i] - 1;
117 for (
int i = (SIZE - 1); i >= 0; --i) {
118 B[C[A[i] >> 20] - 1] = A[i];
121 for (
unsigned int i = 0; i < SIZE; ++i) {
127 float inv_phi_range_val,
float low_phi_a,
float high_phi_a,
128 unsigned int* philow1,
unsigned int* philow2,
129 unsigned int* phihi1,
unsigned int* phihi2) {
130 const unsigned int zero_int_a[4]
__attribute__((aligned(16))) = {
131 0x00000000, 0x00000000, 0x00000000, 0x00000000};
132 __m128i zero_int = _mm_load_si128((__m128i*)zero_int_a);
133 const unsigned int neg1_int_a[4]
__attribute__((aligned(16))) = {
134 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF};
135 __m128i neg1_int = _mm_load_si128((__m128i*)neg1_int_a);
136 const unsigned int one_int_a[4]
__attribute__((aligned(16))) = {
137 0x00000001, 0x00000001, 0x00000001, 0x00000001};
138 __m128i one_int = _mm_load_si128((__m128i*)one_int_a);
140 __m128 min_phi = _mm_load_ps(min_phi_a);
141 __m128 max_phi = _mm_load_ps(max_phi_a);
142 __m128 n_phi = _mm_load1_ps(&(n_phi_val));
143 __m128i n_phi_min1 = _mm_cvtps_epi32(n_phi);
144 n_phi_min1 = _mm_sub_epi32(n_phi_min1, one_int);
145 __m128 inv_phi_range = _mm_load1_ps(&(inv_phi_range_val));
146 __m128 low_phi = _mm_load1_ps(&(low_phi_a));
147 __m128 high_phi = _mm_load1_ps(&(high_phi_a));
149 __m128i low_phi_bin_1 =
150 _mm_cvttps_epi32((((min_phi - low_phi) * inv_phi_range) * ((n_phi))));
151 __m128i high_phi_bin_1 =
152 _mm_cvttps_epi32((((max_phi - low_phi) * inv_phi_range) * ((n_phi))));
153 __m128i low_phi_bin_2 = _mm_cvttps_epi32(
154 (((min_phi +
twopi - low_phi) * inv_phi_range) * ((n_phi))));
156 __m128i cmp1 = (__m128i)(_mm_cmplt_ps(min_phi, low_phi));
157 __m128i cmp2 = (__m128i)(_mm_cmplt_ps(high_phi, max_phi));
158 __m128i cmp3 = (__m128i)(_mm_cmplt_ps(min_phi +
twopi, low_phi));
159 __m128i cmp4 = (__m128i)(_mm_cmplt_ps(
zero, min_phi));
161 __m128i cmp5 = (__m128i)(_mm_cmplt_ps(high_phi, min_phi +
twopi));
162 __m128i cmptmp1 = (__m128i)(_mm_cmplt_ps(max_phi, low_phi));
163 cmp5 = _mm_and_si128(cmp5, cmptmp1);
165 __m128i cmp5_1 = (__m128i)(_mm_cmplt_ps(min_phi +
twopi, high_phi));
166 cmptmp1 = (__m128i)(_mm_cmplt_ps(max_phi, low_phi));
167 cmp5_1 = _mm_and_si128(cmp5_1, cmptmp1);
169 __m128i cmp5_2 = (__m128i)(_mm_cmplt_ps(high_phi, min_phi +
twopi));
170 cmptmp1 = (__m128i)(_mm_cmplt_ps(low_phi, max_phi));
171 cmp5_2 = _mm_and_si128(cmp5_2, cmptmp1);
173 __m128i cmp5_3 = (__m128i)(_mm_cmplt_ps(min_phi +
twopi, high_phi));
174 cmptmp1 = (__m128i)(_mm_cmplt_ps(low_phi, max_phi));
175 cmp5_3 = _mm_and_si128(cmp5_3, cmptmp1);
176 cmp5_1 = _mm_or_si128(cmp5_1, cmp5_3);
177 cmp5_2 = _mm_or_si128(cmp5_2, cmp5_3);
179 __m128i cmp6 = (__m128i)(_mm_cmplt_ps(max_phi, low_phi));
180 cmptmp1 = (__m128i)(_mm_cmplt_ps(high_phi, min_phi));
181 cmp6 = _mm_or_si128(cmp6, cmptmp1);
188 __m128i
tmp1 = _mm_and_si128(cmp3, zero_int);
189 __m128i
tmp2 = _mm_andnot_si128(cmp3, low_phi_bin_2);
190 __m128i lowphi_sel_1 = _mm_xor_si128(tmp1, tmp2);
192 tmp1 = _mm_andnot_si128(cmp5_1, neg1_int);
193 tmp2 = _mm_and_si128(cmp5_1, lowphi_sel_1);
194 lowphi_sel_1 = _mm_xor_si128(tmp1, tmp2);
196 tmp1 = _mm_and_si128(cmp1, zero_int);
197 tmp2 = _mm_andnot_si128(cmp1, low_phi_bin_1);
198 __m128i
tmp4 = _mm_xor_si128(tmp1, tmp2);
199 tmp1 = _mm_and_si128(cmp6, neg1_int);
200 tmp2 = _mm_andnot_si128(cmp6, tmp4);
201 __m128i
tmp3 = _mm_xor_si128(tmp1, tmp2);
202 tmp1 = _mm_and_si128(cmp4, tmp3);
203 tmp2 = _mm_andnot_si128(cmp4, lowphi_sel_1);
204 lowphi_sel_1 = _mm_xor_si128(tmp1, tmp2);
207 tmp1 = _mm_and_si128(cmp2, n_phi_min1);
208 tmp2 = _mm_andnot_si128(cmp2, high_phi_bin_1);
209 tmp4 = _mm_xor_si128(tmp1, tmp2);
210 tmp1 = _mm_and_si128(cmp6, neg1_int);
211 tmp2 = _mm_andnot_si128(cmp6, tmp4);
212 tmp4 = _mm_xor_si128(tmp1, tmp2);
213 tmp1 = _mm_and_si128(cmp5, neg1_int);
214 tmp2 = _mm_andnot_si128(cmp5, n_phi_min1);
215 tmp3 = _mm_xor_si128(tmp1, tmp2);
216 tmp1 = _mm_and_si128(cmp4, tmp4);
217 tmp2 = _mm_andnot_si128(cmp4, tmp3);
218 __m128i highphi_sel_1 = _mm_xor_si128(tmp1, tmp2);
220 tmp1 = _mm_and_si128(cmp5_2, zero_int);
221 tmp2 = _mm_andnot_si128(cmp5_2, neg1_int);
222 tmp4 = _mm_xor_si128(tmp1, tmp2);
223 tmp1 = _mm_and_si128(cmp4, neg1_int);
224 tmp2 = _mm_andnot_si128(cmp4, tmp4);
225 __m128i lowphi_sel_2 = _mm_xor_si128(tmp1, tmp2);
226 tmp1 = _mm_and_si128(cmp2, n_phi_min1);
227 tmp2 = _mm_andnot_si128(cmp2, high_phi_bin_1);
228 tmp4 = _mm_xor_si128(tmp1, tmp2);
229 tmp1 = _mm_and_si128(cmp4, neg1_int);
230 tmp2 = _mm_andnot_si128(cmp4, tmp4);
231 __m128i highphi_sel_2 = _mm_xor_si128(tmp1, tmp2);
233 _mm_store_si128((__m128i*)philow1, lowphi_sel_1);
234 _mm_store_si128((__m128i*)philow2, lowphi_sel_2);
235 _mm_store_si128((__m128i*)phihi1, highphi_sel_1);
236 _mm_store_si128((__m128i*)phihi2, highphi_sel_2);
240 float* min_phi_a,
float* max_phi_a,
241 vector<SimpleHit3D>& four_hits,
fastvec2d& z_bins,
242 unsigned int n_d,
unsigned int n_k,
243 unsigned int n_dzdl,
unsigned int n_z0,
244 unsigned int d_bin,
unsigned int k_bin,
245 unsigned int n_phi,
unsigned int ,
246 float low_phi,
float high_phi,
float inv_phi_range,
248 unsigned int buffer[(1 << 10)];
249 unsigned int bufnum = 0;
250 unsigned int zbuffer[1 << 10];
251 unsigned int zbufnum[8];
252 unsigned int size2 = n_z0 * n_dzdl;
255 0x00000000, 0x00000000, 0x00000000, 0x00000000};
257 0x00000000, 0x00000000, 0x00000000, 0x00000000};
259 0x00000000, 0x00000000, 0x00000000, 0x00000000};
261 0x00000000, 0x00000000, 0x00000000, 0x00000000};
263 z_bins.
fetch(four_hits[0].get_id(), four_hits[hit_counter - 1].get_id(), zbuffer,
266 unsigned int zoff = n_z0 * n_dzdl * (k_bin + n_k * d_bin);
267 unsigned int binprod = n_z0 * n_dzdl * n_k * n_d;
269 unsigned int count = hit_counter;
271 unsigned int cur = 4;
278 for (
unsigned int i = 0; i < cur; ++i) {
279 minphi_a[i] = min_phi_a[i +
offset];
280 maxphi_a[i] = max_phi_a[i +
offset];
283 fillBins4_sse(minphi_a, maxphi_a, (
float)n_phi, inv_phi_range, low_phi,
284 high_phi, philow1, philow2, phihi1, phihi2);
286 for (
unsigned int i = 0; i < cur; ++i) {
287 unsigned int index = four_hits[i +
offset].get_id();
290 for (
unsigned int zbin = 0; zbin < zbufnum[i +
offset]; ++zbin) {
291 unsigned int zint = zbuffer[
pos];
293 unsigned int zstart = (zint & 65535) + n_z0 * (zint >> 16) + zoff;
295 for (
unsigned int b = philow1[i];
b <= phihi1[i]; ++
b) {
296 if (philow1[i] == 4294967295) {
302 unsigned int zadd = binprod *
b;
303 unsigned int bin = zstart + zadd;
304 buffer[bufnum] = ((bin << 20) ^ index);
307 for (
unsigned int b = philow2[i];
b <= phihi2[i]; ++
b) {
308 if (philow2[i] == 4294967295) {
314 unsigned int zadd = binprod *
b;
315 unsigned int bin = zstart + zadd;
316 buffer[bufnum] = ((bin << 20) ^ index);
335 unsigned int ,
unsigned int ,
unsigned int n_dzdl,
338 (zoomranges[zoomlevel].max_z0 - zoomranges[zoomlevel].min_z0) /
341 (zoomranges[zoomlevel].max_dzdl - zoomranges[zoomlevel].min_dzdl) /
343 float low_phi = zoomranges[zoomlevel].min_phi;
344 float high_phi = zoomranges[zoomlevel].max_phi;
345 float low_dzdl = zoomranges[zoomlevel].min_dzdl;
346 float high_dzdl = zoomranges[zoomlevel].max_dzdl;
347 float dzdl_bin_size_inv = 1. / dzdl_size;
350 float min_cos = cos(zoomranges[zoomlevel].min_phi);
351 float max_cos = cos(zoomranges[zoomlevel].max_phi);
352 float min_sin = sin(zoomranges[zoomlevel].min_phi);
353 float max_sin = sin(zoomranges[zoomlevel].max_phi);
354 if ((high_phi - low_phi) >
M_PI) {
361 unsigned int one_z_bin;
363 float min_kappa = pow(zoomranges[zoomlevel].min_k, pwr);
364 float max_kappa = pow(zoomranges[zoomlevel].max_k, pwr);
366 unsigned int hit_counter = 0;
367 float x_a[4]
__attribute__((aligned(16))) = {0., 0., 0., 0.};
368 float y_a[4]
__attribute__((aligned(16))) = {0., 0., 0., 0.};
369 float z_a[4]
__attribute__((aligned(16))) = {0., 0., 0., 0.};
370 float min_dzdl_a[4]
__attribute__((aligned(16))) = {0., 0., 0., 0.};
371 float max_dzdl_a[4]
__attribute__((aligned(16))) = {0., 0., 0., 0.};
372 float min_z0_a[4]
__attribute__((aligned(16))) = {0., 0., 0., 0.};
373 float max_z0_a[4]
__attribute__((aligned(16))) = {0., 0., 0., 0.};
374 float dz_a[4] = {0., 0., 0., 0.};
375 vector<SimpleHit3D> four_hits;
377 four_hits.assign(4, temphit);
378 unsigned int temp_zcount[4];
379 unsigned buffer[4][1 << 8];
380 for (
unsigned int i = 0; i < hits_vec[zoomlevel]->size(); i++) {
381 x_a[hit_counter] = (*(hits_vec[zoomlevel]))[i].get_x();
382 y_a[hit_counter] = (*(hits_vec[zoomlevel]))[i].get_y();
383 z_a[hit_counter] = (*(hits_vec[zoomlevel]))[i].get_z();
385 dz_a[hit_counter] = (2.0*sqrt((*(hits_vec[zoomlevel]))[i].get_size(2,2)));
386 four_hits[hit_counter] = (*(hits_vec[zoomlevel]))[i];
390 if (hit_counter == 4) {
391 for (
unsigned int h = 0;
h < hit_counter; ++
h) {
395 for (
unsigned int zz = 0;
zz < n_z0; ++
zz) {
396 float min_z0 = zoomranges[zoomlevel].min_z0 + ((float)(
zz)) * z0_size;
397 float max_z0 = min_z0 + z0_size;
399 float avg = 0.5 * (min_z0 + max_z0);
400 float width = 0.5 * (max_z0 - min_z0);
401 max_z0 = avg + width * z_bin_scale;
402 min_z0 = avg - width * z_bin_scale;
404 for (
unsigned int h = 0;
h < hit_counter; ++
h) {
406 min_z0_a[
h] = min_z0 -
dz;
407 max_z0_a[
h] = max_z0 +
dz;
410 dzdlRange_sse(x_a, y_a, z_a, min_cos, min_sin, max_cos, max_sin,
411 min_kappa, max_kappa, zoomranges[zoomlevel].min_d,
412 zoomranges[zoomlevel].max_d, min_z0_a, max_z0_a,
413 min_dzdl_a, max_dzdl_a);
415 unsigned int low_bin = 0;
416 unsigned int high_bin = 0;
418 for (
unsigned int h = 0;
h < hit_counter; ++
h) {
419 float d_dzdl = dzdlError(
420 four_hits[
h], min_kappa, max_kappa, zoomranges[zoomlevel].min_d,
421 zoomranges[zoomlevel].max_d, min_z0, max_z0,
422 zoomranges[zoomlevel].min_dzdl, zoomranges[zoomlevel].max_dzdl);
424 float min_dzdl = min_dzdl_a[
h] - d_dzdl;
425 float max_dzdl = max_dzdl_a[
h] + d_dzdl;
427 if ((min_dzdl > high_dzdl) || (max_dzdl < low_dzdl)) {
431 if (min_dzdl > low_dzdl) {
433 (
unsigned int)((min_dzdl - low_dzdl) * dzdl_bin_size_inv);
438 if (max_dzdl < high_dzdl) {
440 (
unsigned int)((max_dzdl - low_dzdl) * dzdl_bin_size_inv);
442 high_bin = n_dzdl - 1;
445 for (
unsigned int bb = low_bin;
bb <= high_bin;
bb++) {
449 one_z_bin = (
zz ^ (
bb << 16));
450 buffer[
h][temp_zcount[
h]] = one_z_bin;
451 temp_zcount[
h] += 1.;
455 for (
unsigned int h = 0;
h < hit_counter; ++
h) {
456 z_bins.
fill(buffer[
h], temp_zcount[h]);
461 if (hit_counter != 0) {
462 for (
unsigned int h = 0;
h < hit_counter; ++
h) {
466 for (
unsigned int zz = 0;
zz < n_z0; ++
zz) {
467 float min_z0 = zoomranges[zoomlevel].min_z0 + ((float)(
zz)) * z0_size;
468 float max_z0 = min_z0 + z0_size;
470 float avg = 0.5 * (min_z0 + max_z0);
471 float width = 0.5 * (max_z0 - min_z0);
472 max_z0 = avg + width * z_bin_scale;
473 min_z0 = avg - width * z_bin_scale;
475 for (
unsigned int h = 0;
h < hit_counter; ++
h) {
477 min_z0_a[
h] = min_z0 -
dz;
478 max_z0_a[
h] = max_z0 +
dz;
481 dzdlRange_sse(x_a, y_a, z_a, min_cos, min_sin, max_cos, max_sin,
482 min_kappa, max_kappa, zoomranges[zoomlevel].min_d,
483 zoomranges[zoomlevel].max_d, min_z0_a, max_z0_a, min_dzdl_a,
486 unsigned int low_bin = 0;
487 unsigned int high_bin = 0;
489 for (
unsigned int h = 0;
h < hit_counter; ++
h) {
490 float d_dzdl = dzdlError(
491 four_hits[
h], min_kappa, max_kappa, zoomranges[zoomlevel].min_d,
492 zoomranges[zoomlevel].max_d, min_z0, max_z0,
493 zoomranges[zoomlevel].min_dzdl, zoomranges[zoomlevel].max_dzdl);
495 float min_dzdl = min_dzdl_a[
h] - d_dzdl;
496 float max_dzdl = max_dzdl_a[
h] + d_dzdl;
498 if ((min_dzdl > high_dzdl) || (max_dzdl < low_dzdl)) {
502 if (min_dzdl > low_dzdl) {
503 low_bin = (
unsigned int)((min_dzdl - low_dzdl) * dzdl_bin_size_inv);
508 if (max_dzdl < high_dzdl) {
510 (
unsigned int)((max_dzdl - low_dzdl) * dzdl_bin_size_inv);
512 high_bin = n_dzdl - 1;
515 for (
unsigned int bb = low_bin;
bb <= high_bin;
bb++) {
519 one_z_bin = (
zz ^ (
bb << 16));
520 buffer[
h][temp_zcount[
h]] = one_z_bin;
521 temp_zcount[
h] += 1.;
525 for (
unsigned int h = 0;
h < hit_counter; ++
h) {
526 z_bins.
fill(buffer[
h], temp_zcount[h]);
533 bins_vec[zoomlevel]->clear();
536 unsigned int n_phi = n_phi_bins[zoomlevel];
537 unsigned int n_d = n_d_bins[zoomlevel];
538 unsigned int n_k = n_k_bins[zoomlevel];
539 unsigned int n_dzdl = n_dzdl_bins[zoomlevel];
540 unsigned int n_z0 = n_z0_bins[zoomlevel];
544 unsigned int total_bins = n_phi * n_d * n_k * n_dzdl * n_z0;
546 float d_size = (zoomranges[zoomlevel].max_d - zoomranges[zoomlevel].min_d) /
548 float k_size = (zoomranges[zoomlevel].max_k - zoomranges[zoomlevel].min_k) /
550 float low_phi = zoomranges[zoomlevel].min_phi;
551 float high_phi = zoomranges[zoomlevel].max_phi;
552 float inv_phi_range = 1. / (high_phi - low_phi);
555 float min_kappa = pow(zoomranges[zoomlevel].min_k, pwr);
556 float max_kappa = pow(zoomranges[zoomlevel].max_k, pwr);
561 if (print_timings ==
true) {
562 gettimeofday(&t1, NULL);
564 vote_z(zoomlevel, n_phi, n_d, n_k, n_dzdl, n_z0, z_bins);
565 if (print_timings ==
true) {
566 gettimeofday(&t2, NULL);
567 time1 = ((double)(t1.tv_sec) + (double)(t1.tv_usec) / 1000000.);
568 time2 = ((double)(t2.tv_sec) + (double)(t2.tv_usec) / 1000000.);
569 z_vote_time += (time2 - time1);
581 unsigned int hit_counter = 0;
582 float x_a[4]
__attribute__((aligned(16))) = {0., 0., 0., 0.};
583 float y_a[4]
__attribute__((aligned(16))) = {0., 0., 0., 0.};
584 float x_a_2[4]
__attribute__((aligned(16))) = {0., 0., 0., 0.};
585 float y_a_2[4]
__attribute__((aligned(16))) = {0., 0., 0., 0.};
586 vector<SimpleHit3D> four_hits;
588 four_hits.assign(4, temphit);
589 vector<SimpleHit3D> four_hits_2;
590 four_hits_2.assign(4, temphit);
591 vector<SimpleHit3D> eight_hits;
592 eight_hits.assign(8, temphit);
593 float min_phi_1_a[4]
__attribute__((aligned(16))) = {0., 0., 0., 0.};
594 float max_phi_1_a[4]
__attribute__((aligned(16))) = {0., 0., 0., 0.};
595 float min_phi_2_a[4]
__attribute__((aligned(16))) = {0., 0., 0., 0.};
596 float max_phi_2_a[4]
__attribute__((aligned(16))) = {0., 0., 0., 0.};
599 if (print_timings ==
true) {
600 gettimeofday(&t1, NULL);
602 float min_k_array[1 << 8];
603 float max_k_array[1 << 8];
604 min_k_array[0] = zoomranges[zoomlevel].min_k;
605 max_k_array[0] = zoomranges[zoomlevel].min_k + k_size;
606 for (
unsigned int k_bin = 1; k_bin < n_k; ++k_bin) {
607 min_k_array[k_bin] = min_k_array[k_bin - 1] + k_size;
608 max_k_array[k_bin] = max_k_array[k_bin - 1] + k_size;
610 for (
unsigned int k_bin = 0; k_bin < n_k; ++k_bin) {
611 min_k_array[k_bin] = pow(min_k_array[k_bin], pwr);
612 max_k_array[k_bin] = pow(max_k_array[k_bin], pwr);
614 float min_d_array[1 << 8];
615 float max_d_array[1 << 8];
616 min_d_array[0] = zoomranges[zoomlevel].min_d;
617 max_d_array[0] = zoomranges[zoomlevel].min_d + d_size;
618 for (
unsigned int d_bin = 1; d_bin < n_d; ++d_bin) {
619 min_d_array[d_bin] = min_d_array[d_bin - 1] + d_size;
620 max_d_array[d_bin] = max_d_array[d_bin - 1] + d_size;
623 for (
unsigned int k_bin = 0; k_bin < n_k; ++k_bin) {
624 float avg = 0.5 * (max_k_array[k_bin] + min_k_array[k_bin]);
625 float width = 0.5 * (max_k_array[k_bin] - min_k_array[k_bin]);
626 max_k_array[k_bin] = avg + width * bin_scale;
627 min_k_array[k_bin] = avg - width * bin_scale;
629 for (
unsigned int d_bin = 0; d_bin < n_d; ++d_bin) {
630 float avg = 0.5 * (max_d_array[d_bin] + min_d_array[d_bin]);
631 float width = 0.5 * (max_d_array[d_bin] - min_d_array[d_bin]);
632 max_d_array[d_bin] = avg + width * bin_scale;
633 min_d_array[d_bin] = avg - width * bin_scale;
636 for (
unsigned int i = 0; i < hits_vec[zoomlevel]->size(); i++) {
637 if (hit_counter < 4) {
638 four_hits[hit_counter] = ((*(hits_vec[zoomlevel]))[i]);
639 x_a[hit_counter] = four_hits[hit_counter].get_x();
640 y_a[hit_counter] = four_hits[hit_counter].get_y();
641 four_hits[hit_counter].set_id(i);
642 eight_hits[hit_counter] = four_hits[hit_counter];
644 four_hits_2[hit_counter - 4] = ((*(hits_vec[zoomlevel]))[i]);
645 x_a_2[hit_counter - 4] = four_hits_2[hit_counter - 4].get_x();
646 y_a_2[hit_counter - 4] = four_hits_2[hit_counter - 4].get_y();
647 four_hits_2[hit_counter - 4].set_id(i);
648 eight_hits[hit_counter] = four_hits_2[hit_counter - 4];
651 if ((hit_counter == 8) && (separate_by_helicity ==
true)) {
652 for (
unsigned int d_bin = 0; d_bin < n_d; ++d_bin) {
654 min_d_array[d_bin], min_d_array[d_bin], min_d_array[d_bin],
657 max_d_array[d_bin], max_d_array[d_bin], max_d_array[d_bin],
660 for (
unsigned int k_bin = 0; k_bin < n_k; ++k_bin) {
662 min_k_array[k_bin], min_k_array[k_bin], min_k_array[k_bin],
665 max_k_array[k_bin], max_k_array[k_bin], max_k_array[k_bin],
668 if (helicity ==
true) {
673 x_a, y_a, min_d_a, max_d_a, min_k_a, max_k_a, min_phi_1_a,
674 max_phi_1_a, min_phi_2_a, max_phi_2_a, hel, phi_3_out,
675 phi_4_out, x_a_2, y_a_2, phi_3_out_2, phi_4_out_2);
677 phi_3_in = phi_3_out;
678 phi_4_in = phi_4_out;
679 phi_3_in_2 = phi_3_out_2;
680 phi_4_in_2 = phi_4_out_2;
683 x_a, y_a, min_d_a, max_d_a, min_k_a, max_k_a, min_phi_1_a,
684 max_phi_1_a, min_phi_2_a, max_phi_2_a, hel, phi_3_in, phi_4_in,
685 phi_3_out, phi_4_out, x_a_2, y_a_2, phi_3_in_2, phi_4_in_2,
686 phi_3_out_2, phi_4_out_2);
688 phi_3_in = phi_3_out;
689 phi_4_in = phi_4_out;
690 phi_3_in_2 = phi_3_out_2;
691 phi_4_in_2 = phi_4_out_2;
693 for (
unsigned int h = 0;
h < hit_counter; ++
h) {
696 float dphi = sqrt(((2.0*sqrt(four_hits[
h].get_size(0,0))) *
697 (2.0*sqrt(four_hits[
h].get_size(0,0))) +
698 (2.0*sqrt(four_hits[
h].get_size(1,1))) *
699 (2.0*sqrt(four_hits[
h].get_size(1,1)))) /
700 (four_hits[
h].get_x() * four_hits[
h].get_x() +
701 four_hits[
h].get_y() * four_hits[
h].get_y()));
703 four_hits[
h], min_kappa, max_kappa, min_d_array[d_bin],
704 max_d_array[d_bin], zoomranges[zoomlevel].min_z0,
705 zoomranges[zoomlevel].max_z0, zoomranges[zoomlevel].min_dzdl,
706 zoomranges[zoomlevel].max_dzdl);
708 min_phi_1_a[
h] -= dphi;
709 max_phi_1_a[
h] += dphi;
710 min_phi_8[
h] = min_phi_1_a[
h];
711 max_phi_8[
h] = max_phi_1_a[
h];
714 sqrt(((2.0*sqrt(four_hits_2[
h - 4].get_size(0,0))) *
715 (2.0*sqrt(four_hits_2[
h - 4].get_size(0,0))) +
716 (2.0*sqrt(four_hits_2[
h - 4].get_size(1,1))) *
717 (2.0*sqrt(four_hits_2[
h - 4].get_size(1,1)))) /
718 (four_hits_2[
h - 4].get_x() * four_hits_2[
h - 4].get_x() +
719 four_hits_2[
h - 4].get_y() * four_hits_2[
h - 4].get_y()));
721 four_hits[
h - 4], min_kappa, max_kappa, min_d_array[d_bin],
722 max_d_array[d_bin], zoomranges[zoomlevel].min_z0,
723 zoomranges[zoomlevel].max_z0, zoomranges[zoomlevel].min_dzdl,
724 zoomranges[zoomlevel].max_dzdl);
726 min_phi_2_a[
h - 4] -= dphi;
727 max_phi_2_a[
h - 4] += dphi;
728 min_phi_8[
h] = min_phi_2_a[
h - 4];
729 max_phi_8[
h] = max_phi_2_a[
h - 4];
732 fillBins(total_bins, 8, min_phi_8, max_phi_8, eight_hits, z_bins, n_d,
733 n_k, n_dzdl, n_z0, d_bin, k_bin, n_phi, zoomlevel, low_phi,
734 high_phi, inv_phi_range, vote_array);
739 if ((hit_counter == 4) && (((hits_vec[zoomlevel]->size() - (i + 1)) < 4) ||
740 (separate_by_helicity ==
false))) {
741 for (
unsigned int d_bin = 0; d_bin < n_d; ++d_bin) {
743 min_d_array[d_bin], min_d_array[d_bin], min_d_array[d_bin],
746 max_d_array[d_bin], max_d_array[d_bin], max_d_array[d_bin],
749 for (
unsigned int k_bin = 0; k_bin < n_k; ++k_bin) {
751 min_k_array[k_bin], min_k_array[k_bin], min_k_array[k_bin],
754 max_k_array[k_bin], max_k_array[k_bin], max_k_array[k_bin],
756 if (separate_by_helicity ==
true) {
758 if (helicity ==
true) {
763 max_k_a, min_phi_1_a, max_phi_1_a, hel,
764 phi_3_out, phi_4_out);
765 phi_3_in = phi_3_out;
766 phi_4_in = phi_4_out;
769 min_phi_1_a, max_phi_1_a, hel, phi_3_in,
770 phi_4_in, phi_3_out, phi_4_out);
771 phi_3_in = phi_3_out;
772 phi_4_in = phi_4_out;
776 max_k_a, min_phi_1_a, max_phi_1_a,
777 min_phi_2_a, max_phi_2_a);
779 for (
unsigned int h = 0;
h < hit_counter; ++
h) {
781 float dphi = sqrt((2.0*sqrt(four_hits[
h].get_size(0,0))) *
782 (2.0*sqrt(four_hits[
h].get_size(0,0))) +
783 (2.0*sqrt(four_hits[
h].get_size(1,1))) *
784 (2.0*sqrt(four_hits[
h].get_size(1,1)))) /
785 (four_hits[
h].get_x() * four_hits[
h].get_x() +
786 four_hits[
h].get_y() * four_hits[
h].get_y());
788 four_hits[
h], min_kappa, max_kappa, min_d_array[d_bin],
789 max_d_array[d_bin], zoomranges[zoomlevel].min_z0,
790 zoomranges[zoomlevel].max_z0, zoomranges[zoomlevel].min_dzdl,
791 zoomranges[zoomlevel].max_dzdl);
793 min_phi_1_a[
h] -= dphi;
794 min_phi_2_a[
h] -= dphi;
795 max_phi_1_a[
h] += dphi;
796 max_phi_2_a[
h] += dphi;
798 if (separate_by_helicity ==
true) {
799 fillBins(total_bins, hit_counter, min_phi_1_a, max_phi_1_a,
800 four_hits, z_bins, n_d, n_k, n_dzdl, n_z0, d_bin, k_bin,
801 n_phi, zoomlevel, low_phi, high_phi, inv_phi_range,
804 fillBins(total_bins, hit_counter, min_phi_1_a, max_phi_1_a,
805 four_hits, z_bins, n_d, n_k, n_dzdl, n_z0, d_bin, k_bin,
806 n_phi, zoomlevel, low_phi, high_phi, inv_phi_range,
808 fillBins(total_bins, hit_counter, min_phi_2_a, max_phi_2_a,
809 four_hits, z_bins, n_d, n_k, n_dzdl, n_z0, d_bin, k_bin,
810 n_phi, zoomlevel, low_phi, high_phi, inv_phi_range,
818 if (hit_counter != 0) {
819 for (
unsigned int d_bin = 0; d_bin < n_d; ++d_bin) {
821 min_d_array[d_bin], min_d_array[d_bin], min_d_array[d_bin],
824 max_d_array[d_bin], max_d_array[d_bin], max_d_array[d_bin],
827 for (
unsigned int k_bin = 0; k_bin < n_k; ++k_bin) {
829 min_k_array[k_bin], min_k_array[k_bin], min_k_array[k_bin],
832 max_k_array[k_bin], max_k_array[k_bin], max_k_array[k_bin],
834 if (separate_by_helicity ==
true) {
836 if (helicity ==
true) {
841 max_k_a, min_phi_1_a, max_phi_1_a, hel,
842 phi_3_out, phi_4_out);
844 phi_3_in = phi_3_out;
845 phi_4_in = phi_4_out;
848 min_phi_1_a, max_phi_1_a, hel, phi_3_in,
849 phi_4_in, phi_3_out, phi_4_out);
850 phi_3_in = phi_3_out;
851 phi_4_in = phi_4_out;
855 min_phi_1_a, max_phi_1_a, min_phi_2_a,
858 for (
unsigned int h = 0;
h < hit_counter; ++
h) {
860 float dphi = sqrt(((2.0*sqrt(four_hits[
h].get_size(0,0))) *
861 (2.0*sqrt(four_hits[
h].get_size(0,0))) +
862 (2.0*sqrt(four_hits[
h].get_size(1,1))) *
863 (2.0*sqrt(four_hits[
h].get_size(1,1)))) /
864 (four_hits[
h].get_x() * four_hits[
h].get_x() +
865 four_hits[
h].get_y() * four_hits[
h].get_y()));
867 four_hits[
h], min_kappa, max_kappa, min_d_array[d_bin],
868 max_d_array[d_bin], zoomranges[zoomlevel].min_z0,
869 zoomranges[zoomlevel].max_z0, zoomranges[zoomlevel].min_dzdl,
870 zoomranges[zoomlevel].max_dzdl);
872 min_phi_1_a[
h] -= dphi;
873 min_phi_2_a[
h] -= dphi;
874 max_phi_1_a[
h] += dphi;
875 max_phi_2_a[
h] += dphi;
877 if (separate_by_helicity ==
true) {
878 fillBins(total_bins, hit_counter, min_phi_1_a, max_phi_1_a, four_hits,
879 z_bins, n_d, n_k, n_dzdl, n_z0, d_bin, k_bin, n_phi,
880 zoomlevel, low_phi, high_phi, inv_phi_range, vote_array);
882 fillBins(total_bins, hit_counter, min_phi_1_a, max_phi_1_a, four_hits,
883 z_bins, n_d, n_k, n_dzdl, n_z0, d_bin, k_bin, n_phi,
884 zoomlevel, low_phi, high_phi, inv_phi_range, vote_array);
885 fillBins(total_bins, hit_counter, min_phi_2_a, max_phi_2_a, four_hits,
886 z_bins, n_d, n_k, n_dzdl, n_z0, d_bin, k_bin, n_phi,
887 zoomlevel, low_phi, high_phi, inv_phi_range, vote_array);
893 if (print_timings ==
true) {
894 gettimeofday(&t2, NULL);
895 time1 = ((double)(t1.tv_sec) + (double)(t1.tv_usec) / 1000000.);
896 time2 = ((double)(t2.tv_sec) + (double)(t2.tv_usec) / 1000000.);
897 xy_vote_time += (time2 - time1);
899 if (vote_array.
size == 0) {
902 unsigned int C[(1 << 12)] = {0};
903 if (vote_array.
size < (1 << 14)) {
904 unsigned int B[1 << 14];
908 for (
unsigned int i = 0; i < vote_array.
size; ++i) {
909 (*(bins_vec[zoomlevel]))[i].bin = (vote_array.
arr[i]) >> 20;
910 (*(bins_vec[zoomlevel]))[i].entry =
911 (vote_array.
arr[i]) & ((
unsigned int)1048575);
912 (*(bins_vec[zoomlevel]))[i].is_seed =
false;
916 for (
unsigned int i = 0; i < vote_array.
size; ++i) {
917 (*(bins_vec[zoomlevel]))[i].bin = (vote_array[i]) >> 20;
918 (*(bins_vec[zoomlevel]))[i].entry =
919 (vote_array[i]) & ((
unsigned int)1048575);
920 (*(bins_vec[zoomlevel]))[i].is_seed =
false;
922 counting_sort(total_bins, *(bins_vec[zoomlevel]),
C, bins_start, bins_end);