ATLAS Offline Software
Loading...
Searching...
No Matches
EtaPhiMap.h
Go to the documentation of this file.
1//
2// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3//
4// Dear emacs, this is -*- c++ -*-
5//
6
7#ifndef CALORECGPU_ETAPHIMAP_H
8#define CALORECGPU_ETAPHIMAP_H
9
10#include "BaseDefinitions.h"
11#include "Helpers.h"
12
13#include <utility>
14#include <cmath>
15#include <new>
16#include <algorithm>
17
18namespace CaloRecGPU
19{
20
33 template <int eta_grid, int phi_grid, bool respect_deltas, bool continuous, int sampling_number>
35 {
36 static constexpr int s_max_overlap_cells = 8;
37
38 private:
39
40 static constexpr float s_phi_min = - Helpers::Constants::pi<float>;
41 static constexpr float s_phi_max = + Helpers::Constants::pi<float>;
42 static constexpr float s_delta_phi = (s_phi_max - s_phi_min) / phi_grid;
43
44 float m_eta_limits[1 + !continuous];
46
47 static constexpr int s_eta_grid_size = eta_grid * (1 + !continuous);
48
52 //If respect_deltas is true:
53 // -> m_{eta, phi}_coordinates[h][f][n] > 0
54 // means the cell ends at this fraction of the grid.
55 // -> m_{eta, phi}_coordinates[h][f][n] < 0
56 // means the cell starts at this fraction of the grid.
57 // -> m_{eta, phi}_coordinates[h][f][n] == 0
58 // means the cell covers the entire part of the grid.
59 //If respect_deltas is false, this stores simply
60 //the eta, phi of the centers of the cells.
61
62 public:
63
64 constexpr float delta_eta() const
65 {
66 return m_delta_eta;
67 }
68
69 constexpr float delta_phi() const
70 {
71 return s_delta_phi;
72 }
73
74 constexpr float start_eta(const bool positive = true) const
75 {
76 if (continuous)
77 {
78 return -m_eta_limits[0];
79 }
80 else if (positive)
81 {
82 return m_eta_limits[0];
83 }
84 else
85 {
86 return -m_eta_limits[1];
87 }
88 }
89
90 constexpr float start_phi() const
91 {
92 return s_phi_min;
93 }
94
95 constexpr float end_eta(const bool positive = true) const
96 {
97 if (continuous)
98 {
99 return m_eta_limits[0];
100 }
101 else if (positive)
102 {
103 return m_eta_limits[1];
104 }
105 else
106 {
107 return -m_eta_limits[0];
108 }
109 }
110
111 constexpr float end_phi() const
112 {
113 return s_phi_max;
114 }
115
116 constexpr int eta_coordinate(const float eta, float & interval) const
117 {
118 using namespace std;
119 const float frac = (eta - start_eta(eta > 0)) / delta_eta();
120 const float rounded = floorf(frac);
121 interval = frac - rounded;
122 const int casted = static_cast<int>(rounded);
123 if ((casted == eta_grid || casted == 2 * eta_grid) && interval == 0.f)
124 {
125 interval = 1.f;
126 return casted - 1 + (eta > 0 && !continuous) * eta_grid;
127 }
128 else
129 {
130 return casted + (eta > 0 && !continuous) * eta_grid;
131 }
132 }
133
134 constexpr int eta_coordinate(const float eta) const
135 {
136 float dummy = 0.f;
137 return eta_coordinate(eta, dummy);
138 }
139
140 constexpr int phi_coordinate(const float phi, float & interval) const
141 {
142 using namespace std;
143 const float frac = (phi - start_phi()) / delta_phi();
144 const float rounded = floorf(frac);
145 interval = frac - rounded;
146 const int to_return = static_cast<int>(rounded) % phi_grid;
147 return to_return + (to_return < 0) * phi_grid;
148 }
149
150 constexpr int phi_coordinate(const float phi) const
151 {
152 float dummy = 0.f;
153 return phi_coordinate(phi, dummy);
154 }
155
156 constexpr bool coordinates_in_range(const float eta, const float /*phi*/) const
157 {
158 const bool eta_in_range = eta >= start_eta(eta > 0) && eta <= end_eta(eta > 0);
159 const bool phi_in_range = true; //By definition, we wrap around in phi...
160 return eta_in_range && phi_in_range;
161 }
162
163 constexpr float eta_value(const int eta_coord) const
164 {
165 if (!continuous && eta_coord >= eta_grid)
166 {
167 return start_eta(true) + (eta_coord - eta_grid) * delta_eta();
168 }
169 else
170 {
171 return start_eta(false) + eta_coord * delta_eta();
172 }
173 }
174
175 constexpr float phi_value(const int phi_coord) const
176 {
177 return start_phi() + phi_coord * delta_phi();
178 }
179
180 private:
181
182 constexpr void add_cell_to_grid(const int cell, const float eta_fraction, const float phi_fraction, const int eta, const int phi)
183 {
185 {
186#if CALORECGPU_ETA_PHI_MAP_DEBUG
187 printf("CALORECGPU ETA PHI MAP DEBUG OUTPUT: Attempt out of bounds store %d (%d): %f %f (%d / %d, %d / %d)\n",
188 cell, sampling_number, eta_fraction, phi_fraction, eta, eta_grid, phi, phi_grid);
189#endif
190 return;
191 }
192
193 for (int i = 0; i < s_max_overlap_cells; ++i)
194 {
195 if (m_cells[eta][phi][i] < 0)
196 {
197 m_cells [eta][phi][i] = cell;
198 m_eta_coordinates [eta][phi][i] = eta_fraction;
199 m_phi_coordinates [eta][phi][i] = phi_fraction;
200 return;
201 }
202 }
203
204#if CALORECGPU_ETA_PHI_MAP_DEBUG
205 printf("CALORECGPU ETA PHI MAP DEBUG OUTPUT: Unable to store %d (%d): ", cell, sampling_number);
206 for (int i = 0; i < s_max_overlap_cells; ++i)
207 {
208 printf("%d ", m_cells[eta][phi][i]);
209 }
210 printf("(%d / %d , %d / %d)\n", eta, s_eta_grid_size, phi, phi_grid);
211
212 if (!respect_deltas)
213 {
214 const float this_eta = eta_value(eta);
215 const float this_phi = phi_value(phi);
216 for (int i = 0; i < s_max_overlap_cells; ++i)
217 {
218 const float cell_eta = m_eta_coordinates [eta][phi][i];
219 const float cell_phi = m_phi_coordinates [eta][phi][i];
220
221 const float d_eta_1 = fabsf(this_eta - cell_eta);
222 const float d_eta_2 = fabsf(this_eta + delta_eta() - cell_eta);
223
224 const float d_phi_1 = fabsf(Helpers::angular_difference(this_phi, cell_phi));
225 const float d_phi_2 = fabsf(Helpers::angular_difference(this_phi + delta_phi(), cell_phi));
226
227 printf(" %f %f %f %f | %f %f %f %f (%f %f | %f %f %f %f)\n",
228 d_eta_1 + d_phi_1,
229 d_eta_1 + d_phi_2,
230 d_eta_2 + d_phi_1,
231 d_eta_2 + d_phi_2,
232 d_eta_1,
233 d_eta_2,
234 d_phi_1,
235 d_phi_2,
236 cell_eta,
237 cell_phi,
238 this_eta,
239 this_eta + delta_eta(),
240 this_phi,
241 this_phi + delta_phi());
242 }
243 }
244#endif
245 }
246
247 public:
248
249 constexpr void register_cell(const int cell, const float cell_eta, const float cell_phi, const float cell_deta, const float cell_dphi)
250 {
251 int start_eta_coord = -1, end_eta_coord = -1;
252 float start_eta_frac = 0.f, end_eta_frac = 0.f;
253
254 start_eta_coord = eta_coordinate(cell_eta - cell_deta / 2, start_eta_frac);
255 end_eta_coord = eta_coordinate(cell_eta + cell_deta / 2, end_eta_frac);
256
257 int start_phi_coord = -1, end_phi_coord = -1;
258 float start_phi_frac = 0.f, end_phi_frac = 0.f;
259 int start_phi_extra = -1, end_phi_extra = -1;
260 float start_phi_extra_frac = 0.f, end_phi_extra_frac = 0.f;
261
262
263 if (cell_phi - cell_dphi / 2 < s_phi_min && cell_phi + cell_dphi / 2 > s_phi_max)
264 //The (impossible) case of a full wraparound in phi
265 {
266 start_phi_coord = 0;
267 start_phi_frac = 0.f;
268
269 end_phi_coord = phi_grid - 1;
270 end_phi_frac = 1.f;
271 }
272 else if (cell_phi - cell_dphi / 2 < s_phi_min)
273 {
274 start_phi_coord = 0;
275 start_phi_frac = 0.f;
276
277 end_phi_coord = phi_coordinate(cell_phi + cell_dphi / 2, end_phi_frac);
278
279 start_phi_extra = phi_coordinate(Helpers::regularize_angle(cell_phi - cell_dphi / 2), start_phi_extra_frac);
280
281 end_phi_extra = phi_grid - 1;
282 end_phi_extra_frac = 1.f;
283 }
284 else if (cell_phi + cell_dphi / 2 > s_phi_max)
285 {
286 start_phi_coord = phi_coordinate(cell_phi - cell_dphi / 2, start_phi_frac);
287
288 end_phi_coord = phi_grid - 1;
289 end_phi_frac = 1.f;
290
291 start_phi_extra = phi_coordinate(Helpers::regularize_angle(cell_phi - cell_dphi / 2), start_phi_extra_frac);
292
293 start_phi_extra = 0;
294 start_phi_extra_frac = 1.f;
295
296 end_phi_extra = phi_coordinate(Helpers::regularize_angle(cell_phi + cell_dphi / 2), end_phi_extra_frac);
297 }
298 else
299 {
300 start_phi_coord = phi_coordinate(cell_phi - cell_dphi / 2, start_phi_frac);
301 end_phi_coord = phi_coordinate(cell_phi + cell_dphi / 2, end_phi_frac);
302 }
303
304 for (int i = start_eta_coord; i <= end_eta_coord; ++i)
305 {
306 const float eta_frac = (i == start_eta_coord ? -start_eta_frac : i == end_eta_coord ? end_eta_frac : 0.f);
307
308 for (int j = start_phi_coord; j <= end_phi_coord; ++j)
309 {
310 const float phi_frac = (j == start_phi_coord ? -start_phi_frac : j == end_phi_coord ? end_phi_frac : 0.f);
311
312 add_cell_to_grid(cell, (respect_deltas ? eta_frac : cell_eta), (respect_deltas ? phi_frac : cell_phi), i, j);
313 }
314
315 if (start_phi_extra >= 0)
316 {
317 for (int j = start_phi_extra; j <= end_phi_extra; ++j)
318 {
319 const float phi_frac = (j == start_phi_extra ? -start_phi_extra_frac : j == end_phi_extra ? end_phi_extra_frac : 0.f);
320
321 add_cell_to_grid(cell, (respect_deltas ? eta_frac : cell_eta), (respect_deltas ? phi_frac : cell_phi), i, j);
322 }
323 }
324 }
325 }
326
327 constexpr void initialize()
328 {
329 for (int i = 0; i < s_eta_grid_size; ++i)
330 {
331 for (int j = 0; j < phi_grid; ++j)
332 {
333 for (int k = 0; k < s_max_overlap_cells; ++k)
334 {
335 m_cells[i][j][k] = -1;
336 }
337 }
338 }
339 }
340
341 constexpr void initialize(const float min_eta, const float max_eta)
342 {
343 initialize();
344
345 if (continuous)
346 {
347 m_eta_limits[0] = max_eta;
348
349 m_delta_eta = (max_eta / eta_grid) * 2;
350 }
351 else
352 {
353 m_eta_limits[0] = min_eta;
354 m_eta_limits[1] = max_eta;
355
356 m_delta_eta = ((max_eta - min_eta) / eta_grid) * 2;
357 }
358
359#if CALORECGPU_ETA_PHI_MAP_DEBUG
360 if (sampling_number < 24)
361 {
362 printf("CALORECGPU ETA PHI MAP DEBUG OUTPUT: %d | %d | %f %f | %f %f | %f %f | %f %f\n",
363 sampling_number, static_cast<int>(continuous),
364 start_eta(false), end_eta(false),
365 start_eta(true), end_eta(true),
366 start_phi(), end_phi(),
367 delta_eta(), delta_phi());
368 }
369#endif
370 }
371
372 private:
373
375 {
379
380 static constexpr int s_max_cells = phi_grid * s_eta_grid_size;
381
383 int counter[2];
384 bool select;
386
387 constexpr const int & get_counter() const
388 {
389 return counter[select];
390 }
391 constexpr int & get_counter()
392 {
393 return counter[select];
394 }
395 constexpr const int & get_next_counter() const
396 {
397 return counter[!select];
398 }
399 constexpr int & get_next_counter()
400 {
401 return counter[!select];
402 }
403 constexpr const int * get_gridcells() const
404 {
405 return grid_list[select];
406 }
407 constexpr int * get_gridcells()
408 {
409 return grid_list[select];
410 }
411 constexpr const int * get_next_gridcells() const
412 {
413 return grid_list[!select];
414 }
415 constexpr int * get_next_gridcells()
416 {
417 return grid_list[!select];
418 }
419
420 constexpr void swap()
421 {
422 for (int i = 0; i < s_max_cells; ++i)
423 {
424 added[i] = 0;
425 }
426 select = !select;
427 }
428
429 constexpr void clear_next_gridcells()
430 {
431 get_next_counter() = 0;
432 }
433
434 constexpr bool add_next_gridcell(const int value)
435 {
437 {
438#if CALORECGPU_ETA_PHI_MAP_DEBUG
439 printf("CALORECGPU ETA PHI MAP DEBUG OUTPUT: cannot add more cells! (%d)\n", sampling_number);
440#endif
441 return false;
442 }
445 return true;
446 }
447
448 constexpr bool add_next_gridcell(const int eta, const int phi)
449 {
450 return add_next_gridcell(eta * phi_grid + phi);
451 }
452
453 constexpr bool try_add_next_gridcell(const int eta, const int phi)
454 {
455 const int value = eta * phi_grid + phi;
456
457 if (added[value])
458 {
459 return false;
460 }
461
462 added[value] = 1;
463
464 return add_next_gridcell(value);
465 }
466
467 constexpr void get_gridcell(const int i, int & eta, int & phi)
468 {
469 const int v = get_gridcells()[i];
470
471 eta = v / phi_grid;
472 phi = v % phi_grid;
473 }
474 };
475
476 public:
477
478 constexpr static size_t finish_initializing_buffer_size()
479 {
480 return sizeof(FinishInitializingTemporaries);
481 }
482
485 {
486 if (!respect_deltas)
487 {
488 using namespace std;
489
491
492 FinishInitializingTemporaries & temps = *temp_ptr;
493
494 auto calculate_minima = [&](float & min_dist_eta, float & min_dist_phi,
495 const float this_eta, const float this_phi,
496 const float gridcell_eta, const float gridcell_phi)
497 {
498 if (this_eta >= gridcell_eta && this_eta <= gridcell_eta + delta_eta())
499 {
500 min_dist_eta = this_eta;
501 }
502 else
503 {
504 if (this_eta < gridcell_eta)
505 {
506 min_dist_eta = gridcell_eta;
507 }
508#if CALORECGPU_ETA_PHI_MAP_DEBUG
509 else if (this_eta <= gridcell_eta + delta_eta())
510 {
511 printf("CALORECGPU ETA PHI MAP DEBUG OUTPUT: Strange things going on with eta distance (%d): %f | %f %f\n",
512 sampling_number, this_eta, gridcell_eta, gridcell_eta + delta_eta());
513 }
514#endif
515 else
516 {
517 min_dist_eta = gridcell_eta + delta_eta();
518 }
519 }
520
521 if (this_phi >= gridcell_phi && this_phi <= gridcell_phi + delta_phi())
522 {
523 min_dist_phi = this_phi;
524 }
525 else
526 {
527 const float d1 = fabsf(Helpers::angular_difference(gridcell_phi, this_phi));
528 const float d2 = fabsf(Helpers::angular_difference(gridcell_phi + delta_phi(), this_phi));
529 if (d1 < d2)
530 {
531 min_dist_phi = gridcell_phi;
532 }
533#if CALORECGPU_ETA_PHI_MAP_DEBUG
534 else if (d1 == d2)
535 {
536 printf("CALORECGPU ETA PHI MAP DEBUG OUTPUT: Strange things going on with phi distance (%d): %f | %f %f\n",
537 sampling_number, this_phi, gridcell_phi, gridcell_phi + delta_phi());
538 }
539#endif
540 else
541 {
542 min_dist_phi = gridcell_phi + delta_phi();
543 }
544 }
545 };
546
547 auto calculate_dist = [](const float e_1, const float p_1,
548 const float e_2, const float p_2)
549 {
550 return fabsf(e_1 - e_2) + fabsf(Helpers::angular_difference(p_1, p_2));
551 };
552
553 auto update_cell_list = [&](int (&cells) [s_max_overlap_cells],
554 float (&etas) [s_max_overlap_cells],
555 float (&phis) [s_max_overlap_cells],
556 float (&min_etas) [s_max_overlap_cells],
557 float (&min_phis) [s_max_overlap_cells],
558 const int this_cell,
559 const float this_eta,
560 const float this_phi,
561 const float min_dist_eta,
562 const float min_dist_phi)
563 {
564 int i = 0;
565 int to_replace[s_max_overlap_cells];
566 int replace_count = 0;
567
568 const float new_dist_at_new_minimum = calculate_dist(this_eta, this_phi, min_dist_eta, min_dist_phi);
569
570 for (i = 0; i < s_max_overlap_cells; ++i)
571 {
572 if (cells[i] < 0)
573 {
574 break;
575 }
576
577 if (cells[i] == this_cell)
578 {
579 //Already part of the list...
580 return false;
581 }
582
583 const float old_dist_at_new_minimum = calculate_dist(etas[i], phis[i], min_dist_eta, min_dist_phi);
584
585 if (old_dist_at_new_minimum <= new_dist_at_new_minimum)
586 {
587 //There is a cell that will always be closer
588 return false;
589 }
590
591 const float new_dist_at_old_minimum = calculate_dist(this_eta, this_phi, min_etas[i], min_phis[i]);
592 const float old_dist_at_old_minimum = calculate_dist(etas[i], phis[i], min_etas[i], min_phis[i]);
593
594 if (new_dist_at_old_minimum < old_dist_at_old_minimum)
595 {
596 //An old cell was actually further away.
597 to_replace[replace_count] = i;
598 ++replace_count;
599 }
600 }
601
602 while (replace_count > 0 && i > 0)
603 {
604 const int orig = to_replace[replace_count - 1];
605 if (orig != i - 1)
606 {
607 cells [orig] = cells [i - 1];
608 etas [orig] = etas [i - 1];
609 phis [orig] = phis [i - 1];
610 min_etas [orig] = min_etas [i - 1];
611 min_phis [orig] = min_phis [i - 1];
612 }
613 cells[i - i] = -1;
614 --replace_count;
615 --i;
616 if (i < 0 || (i == 0 && replace_count > 0))
617 {
618#if CALORECGPU_ETA_PHI_MAP_DEBUG
619 printf("CALORECGPU ETA PHI MAP DEBUG OUTPUT: Negative count on cell list update, somehow... (%d)\n", sampling_number);
620#endif
621 break;
622 }
623 }
624
625 if (i < s_max_overlap_cells)
626 {
627 cells [i] = this_cell;
628 etas [i] = this_eta;
629 phis [i] = this_phi;
630 min_etas [i] = min_dist_eta;
631 min_phis [i] = min_dist_phi;
632 return true;
633 }
634#if CALORECGPU_ETA_PHI_MAP_DEBUG
635 else
636 {
637 printf("CALORECGPU ETA PHI MAP DEBUG OUTPUT: Warning: overfull list of overlapping cells: %d (%d)\n", i, sampling_number);
638 }
639#endif
640 return false;
641 };
642
643 auto add_possible_cells = [&](int (&cells) [s_max_overlap_cells],
644 float (&etas) [s_max_overlap_cells],
645 float (&phis) [s_max_overlap_cells],
646 float (&min_etas) [s_max_overlap_cells],
647 float (&min_phis) [s_max_overlap_cells],
648 const float gridcell_eta,
649 const float gridcell_phi,
650 const int orig_eta,
651 const int orig_phi)
652 {
653 bool updated = false;
654 for (int i = 0; i < s_max_overlap_cells; ++i)
655 {
656 const int this_cell = m_cells[orig_eta][orig_phi][i];
657
658 if (this_cell < 0)
659 {
660 break;
661 }
662
663 const float this_eta = m_eta_coordinates[orig_eta][orig_phi][i];
664 const float this_phi = m_phi_coordinates[orig_eta][orig_phi][i];
665
666 float min_dist_eta = 0.f, min_dist_phi = 0.f;
667
668 calculate_minima(min_dist_eta, min_dist_phi, this_eta, this_phi, gridcell_eta, gridcell_phi);
669
670 updated = updated || update_cell_list(cells, etas, phis, min_etas, min_phis,
671 this_cell, this_eta, this_phi, min_dist_eta, min_dist_phi);
672
673 }
674
675 return updated;
676 };
677
678 auto process_cell = [&](const int eta, const int phi)
679 {
680 const int phi_before = (phi == 0 ? phi_grid - 1 : phi - 1);
681 const int phi_after = (phi == phi_grid - 1 ? 0 : phi + 1);
682 const int eta_before = (eta == 0 || eta == eta_grid ? -1 : eta - 1);
683 const int eta_after = (eta == eta_grid - 1 || eta == 2 * eta_grid - 1 ? -1 : eta + 1);
684
685 const float this_grid_eta = eta_value(eta);
686 const float this_grid_phi = phi_value(phi);
687
688 float min_etas[s_max_overlap_cells], min_phis[s_max_overlap_cells];
689
690 for (int i = 0; i < s_max_overlap_cells; ++i)
691 {
692 if (temps.cells[eta][phi][i] < 0)
693 {
694 break;
695 }
696
697 const float this_eta = m_eta_coordinates[eta][phi][i];
698 const float this_phi = m_phi_coordinates[eta][phi][i];
699
700 calculate_minima(min_etas[i], min_phis[i], this_eta, this_phi, this_grid_eta, this_grid_phi);
701 }
702
703 bool added = false;
704
705 added = added || add_possible_cells(temps.cells[eta][phi],
706 temps.etas[eta][phi], temps.phis[eta][phi],
707 min_etas, min_phis,
708 this_grid_eta, this_grid_phi,
709 eta, phi_before);
710 added = added || add_possible_cells(temps.cells[eta][phi],
711 temps.etas[eta][phi], temps.phis[eta][phi],
712 min_etas, min_phis,
713 this_grid_eta, this_grid_phi,
714 eta, phi_after);
715
716 if (eta_before >= 0)
717 {
718 added = added || add_possible_cells(temps.cells[eta][phi],
719 temps.etas[eta][phi], temps.phis[eta][phi],
720 min_etas, min_phis,
721 this_grid_eta, this_grid_phi,
722 eta_before, phi);
723 }
724 if (eta_after >= 0)
725 {
726 added = added || add_possible_cells(temps.cells[eta][phi],
727 temps.etas[eta][phi], temps.phis[eta][phi],
728 min_etas, min_phis,
729 this_grid_eta, this_grid_phi,
730 eta_after, phi);
731 }
732
733 bool ret = false;
734
735 if (added)
736 {
737 ret = ret || temps.try_add_next_gridcell(eta, phi_before);
738 ret = ret || temps.try_add_next_gridcell(eta, phi_after);
739 if (eta_before >= 0)
740 {
741 ret = ret || temps.try_add_next_gridcell(eta_before, phi);
742 }
743 if (eta_after >= 0)
744 {
745 ret = ret || temps.try_add_next_gridcell(eta_after, phi);
746 }
747 }
748
749 return ret;
750 };
751
752 temps.counter[0] = 0;
753 temps.counter[1] = 0;
754 temps.select = false;
755
756 temps.swap();
757
758 for (int eta = 0; eta < s_eta_grid_size; ++eta)
759 {
760 for (int phi = 0; phi < phi_grid; ++phi)
761 {
762 memcpy(temps.cells[eta][phi], m_cells[eta][phi], s_max_overlap_cells * sizeof(int));
763
764 if (m_cells[eta][phi][0] >= 0)
765 {
766 memcpy(temps.etas[eta][phi], m_eta_coordinates[eta][phi], s_max_overlap_cells * sizeof(float));
767 memcpy(temps.phis[eta][phi], m_phi_coordinates[eta][phi], s_max_overlap_cells * sizeof(float));
768
769 const int phi_before = (phi == 0 ? phi_grid - 1 : phi - 1);
770 const int phi_after = (phi == phi_grid - 1 ? 0 : phi + 1);
771 const int eta_before = (eta == 0 || eta == eta_grid ? -1 : eta - 1);
772 const int eta_after = (eta == eta_grid - 1 || eta == s_eta_grid_size - 1 ? -1 : eta + 1);
773
775
776 temps.try_add_next_gridcell(eta, phi_before);
777 temps.try_add_next_gridcell(eta, phi_after);
778 if (eta_before >= 0)
779 {
780 temps.try_add_next_gridcell(eta_before, phi);
781 }
782 if (eta_after >= 0)
783 {
784 temps.try_add_next_gridcell(eta_after, phi);
785 }
786 }
787 }
788 }
789
790 temps.swap();
791 temps.clear_next_gridcells();
792
793#if CALORECGPU_ETA_PHI_MAP_DEBUG
794 int iter_count = 0;
795 int equal_iter_counter = 0;
796#endif
797
798 while (temps.get_counter() > 0)
799 {
800 for (int i = 0; i < temps.get_counter(); ++i)
801 {
802 int eta, phi;
803 temps.get_gridcell(i, eta, phi);
804 process_cell(eta, phi);
805 }
806
807#if CALORECGPU_ETA_PHI_MAP_DEBUG
808 ++iter_count;
809
810 printf("CALORECGPU ETA PHI MAP DEBUG OUTPUT: Init %d: %d | %d %d (%d)\n",
811 sampling_number, iter_count, temps.get_counter(), temps.get_next_counter(), equal_iter_counter);
812
813 if (temps.get_counter() == temps.get_next_counter())
814 {
815 int count_same = 0;
816
817 for (int i = 0; i < temps.get_counter(); ++i)
818 {
819 count_same += (temps.get_gridcells()[i] == temps.get_next_gridcells()[i]);
820 }
821 if (count_same == temps.get_counter())
822 {
823 ++equal_iter_counter;
824 if (equal_iter_counter >= 4)
825 //Assume we got stuck in some weird loop...
826 {
827 temps.clear_next_gridcells();
828 }
829 if (temps.get_counter() < 10)
830 {
831 for (int i = 0; i < temps.get_counter(); ++i)
832 {
833 int eta, phi;
834 temps.get_gridcell(i, eta, phi);
835 printf(" %d %d", eta, phi);
836 for (int j = 0; j < s_max_overlap_cells; ++j)
837 {
838 if (temps.cells[eta][phi][j] < 0)
839 {
840 break;
841 }
842 printf(" (%d: %f %f)", temps.cells[eta][phi][j], temps.etas[eta][phi][j], temps.phis[eta][phi][j]);
843 }
844 printf("\n");
845 }
846 }
847 }
848 else
849 {
850 equal_iter_counter = 0;
851 }
852 }
853 else
854 {
855 equal_iter_counter = 0;
856 }
857#endif
858
859 for (int i = 0; i < temps.get_counter(); ++i)
860 {
861 int eta, phi;
862 temps.get_gridcell(i, eta, phi);
863
864 memcpy(m_cells [eta][phi], temps.cells[eta][phi], s_max_overlap_cells * sizeof(int) );
865 memcpy(m_eta_coordinates[eta][phi], temps.etas [eta][phi], s_max_overlap_cells * sizeof(float));
866 memcpy(m_phi_coordinates[eta][phi], temps.phis [eta][phi], s_max_overlap_cells * sizeof(float));
867 }
868
869 temps.swap();
870 temps.clear_next_gridcells();
871
872 }
873
874#if CALORECGPU_ETA_PHI_MAP_DEBUG
875 printf("CALORECGPU ETA PHI MAP DEBUG OUTPUT: Finished %d: %d (%d %d)\n",
876 sampling_number, get_max_real_overlap(), iter_count, equal_iter_counter);
877#endif
878 }
879 else
880 {
881 //Do nothing: when respecting deltas,
882 //cells get properly initialized outright...
883 }
884 }
885
887 constexpr int get_possible_cells_from_coords(const float test_eta, const float test_phi, int * cell_arr) const
888 {
889 if (!coordinates_in_range(test_eta, test_phi))
890 {
891 return 0;
892 }
893
894 int num_cells = 0;
895
896 float frac_eta = 0.f, frac_phi = 0.f;
897
898 const int eta_coord = eta_coordinate(test_eta, frac_eta);
899 const int phi_coord = phi_coordinate(test_phi, frac_phi);
900
901 if (eta_coord < 0 || eta_coord >= s_eta_grid_size || phi_coord < 0 || phi_coord >= phi_grid)
902 {
903 return 0;
904 }
905
906 if (respect_deltas)
907 {
908 auto check_coord = [](const float test, const float target)
909 {
910 using namespace std;
911 if (target > 0 && fabsf(test) <= fabsf(target))
912 {
913 return true;
914 }
915 else if (target < 0 && fabsf(test) >= fabsf(target))
916 {
917 return true;
918 }
919 else if (target == 0)
920 {
921 return true;
922 }
923 else
924 {
925 return false;
926 }
927 };
928
929 for (int i = 0; i < s_max_overlap_cells; ++i)
930 {
931 const int this_cell = m_cells[eta_coord][phi_coord][i];
932
933 if (this_cell < 0)
934 {
935 break;
936 }
937
938 if (check_coord(frac_eta, m_eta_coordinates[eta_coord][phi_coord][i]) &&
939 check_coord(frac_phi, m_phi_coordinates[eta_coord][phi_coord][i]) )
940 {
941 cell_arr[num_cells] = this_cell;
942 ++num_cells;
943 }
944 }
945 }
946 else
947 {
948 float distance = 1e38f;
949 int ret = -1;
950
951 for (int i = 0; i < s_max_overlap_cells; ++i)
952 {
953 const int this_cell = m_cells[eta_coord][phi_coord][i];
954
955 if (this_cell < 0)
956 {
957 break;
958 }
959
960 const float this_delta_eta = m_eta_coordinates[eta_coord][phi_coord][i] - test_eta;
961
962 const float this_delta_phi = Helpers::angular_difference(m_phi_coordinates[eta_coord][phi_coord][i], test_phi);
963
964 using namespace std;
965
966 const float this_dist = fabsf(this_delta_eta) + fabsf(this_delta_phi);
967
968 if (this_dist < distance || (this_dist == distance && this_cell > ret))
969 {
970 distance = this_dist;
971 ret = this_cell;
972 }
973 }
974
975 if (ret > 0)
976 {
977 cell_arr[0] = ret;
978 num_cells = 1;
979 }
980 }
981
982 return num_cells;
983 }
984
985 constexpr bool has_cell_in_coords(const float test_eta, const float test_phi) const
986 {
987 if (!coordinates_in_range(test_eta, test_phi))
988 {
989 return false;
990 }
991
992 float frac_eta = 0.f, frac_phi = 0.f;
993
994 const int eta_coord = eta_coordinate(test_eta, frac_eta);
995 const int phi_coord = phi_coordinate(test_phi, frac_phi);
996
997 if (eta_coord < 0 || eta_coord >= s_eta_grid_size || phi_coord < 0 || phi_coord >= phi_grid)
998 {
999 return false;
1000 }
1001
1002 if (respect_deltas)
1003 {
1004 auto check_coord = [](const float test, const float target)
1005 {
1006 using namespace std;
1007 if (target > 0 && fabsf(test) <= fabsf(target))
1008 {
1009 return true;
1010 }
1011 else if (target < 0 && fabsf(test) >= fabsf(target))
1012 {
1013 return true;
1014 }
1015 else if (target == 0)
1016 {
1017 return true;
1018 }
1019 else
1020 {
1021 return false;
1022 }
1023 };
1024
1025 for (int i = 0; i < s_max_overlap_cells; ++i)
1026 {
1027 if (m_cells[eta_coord][phi_coord][i] < 0)
1028 {
1029 break;
1030 }
1031 if ( check_coord(frac_eta, m_eta_coordinates[eta_coord][phi_coord][i]) &&
1032 check_coord(frac_phi, m_phi_coordinates[eta_coord][phi_coord][i]) )
1033 {
1034 return true;
1035 }
1036 }
1037 return false;
1038 }
1039 else
1040 {
1041 return true;
1042 //Except for being out-of-bounds,
1043 //if respect_deltas == false
1044 //we can always find a closest cell
1045 //for each coordinate.
1046 }
1047 }
1048
1049 constexpr int get_max_real_overlap() const
1050 {
1051 int ret = 0;
1052
1053 for (int eta = 0; eta < s_eta_grid_size; ++eta)
1054 {
1055 for (int phi = 0; phi < phi_grid; ++phi)
1056 {
1057 int this_count = 0;
1058
1059 for (int i = 0; i < s_max_overlap_cells; ++i)
1060 {
1061 if (m_cells[eta][phi][i] >= 0)
1062 {
1063 ++this_count;
1064 }
1065 else
1066 {
1067 break;
1068 }
1069 }
1070
1071 if (this_count > ret)
1072 {
1073 ret = this_count;
1074 }
1075 }
1076 }
1077
1078 return ret;
1079 }
1080
1081 };
1082
1083
1085 {
1087
1088 //Samplings have custom, hard-coded sizes to save space.
1089 //Could've gone with one-size-fits all maxima,
1090 //but it'd likely be unnecessarily wasteful.
1119
1120 static_assert(NumSamplings == 28, "Written under the assumption there are 28 samplings.");
1121
1123 template <class Func, class ... Args>
1124 constexpr void apply_to_all_samplings(Func && F, Args && ... args)
1125 {
1126 F(sampling_0, args...);
1127 F(sampling_1, args...);
1128 F(sampling_2, args...);
1129 F(sampling_3, args...);
1130 F(sampling_4, args...);
1131 F(sampling_5, args...);
1132 F(sampling_6, args...);
1133 F(sampling_7, args...);
1134 F(sampling_8, args...);
1135 F(sampling_9, args...);
1136 F(sampling_10, args...);
1137 F(sampling_11, args...);
1138 F(sampling_12, args...);
1139 F(sampling_13, args...);
1140 F(sampling_14, args...);
1141 F(sampling_15, args...);
1142 F(sampling_16, args...);
1143 F(sampling_17, args...);
1144 F(sampling_18, args...);
1145 F(sampling_19, args...);
1146 F(sampling_20, args...);
1147 F(sampling_21, args...);
1148 F(sampling_22, args...);
1149 F(sampling_23, args...);
1150 F(sampling_24, args...);
1151 F(sampling_25, args...);
1152 F(sampling_26, args...);
1153 F(sampling_27, args...);
1154 }
1155
1157 template <class Func, class ... Args>
1158 constexpr void apply_to_all_samplings(Func && F, Args && ... args) const
1159 {
1160 F(sampling_0, args...);
1161 F(sampling_1, args...);
1162 F(sampling_2, args...);
1163 F(sampling_3, args...);
1164 F(sampling_4, args...);
1165 F(sampling_5, args...);
1166 F(sampling_6, args...);
1167 F(sampling_7, args...);
1168 F(sampling_8, args...);
1169 F(sampling_9, args...);
1170 F(sampling_10, args...);
1171 F(sampling_11, args...);
1172 F(sampling_12, args...);
1173 F(sampling_13, args...);
1174 F(sampling_14, args...);
1175 F(sampling_15, args...);
1176 F(sampling_16, args...);
1177 F(sampling_17, args...);
1178 F(sampling_18, args...);
1179 F(sampling_19, args...);
1180 F(sampling_20, args...);
1181 F(sampling_21, args...);
1182 F(sampling_22, args...);
1183 F(sampling_23, args...);
1184 F(sampling_24, args...);
1185 F(sampling_25, args...);
1186 F(sampling_26, args...);
1187 F(sampling_27, args...);
1188 }
1189
1191 template <class Func, class ... Args>
1192 constexpr void apply_to_sampling(const int sampling, Func && F, Args && ... args)
1193 {
1194 switch (sampling)
1195 {
1196 case 0:
1197 F(sampling_0, std::forward<Args>(args)...);
1198 break;
1199 case 1:
1200 F(sampling_1, std::forward<Args>(args)...);
1201 break;
1202 case 2:
1203 F(sampling_2, std::forward<Args>(args)...);
1204 break;
1205 case 3:
1206 F(sampling_3, std::forward<Args>(args)...);
1207 break;
1208 case 4:
1209 F(sampling_4, std::forward<Args>(args)...);
1210 break;
1211 case 5:
1212 F(sampling_5, std::forward<Args>(args)...);
1213 break;
1214 case 6:
1215 F(sampling_6, std::forward<Args>(args)...);
1216 break;
1217 case 7:
1218 F(sampling_7, std::forward<Args>(args)...);
1219 break;
1220 case 8:
1221 F(sampling_8, std::forward<Args>(args)...);
1222 break;
1223 case 9:
1224 F(sampling_9, std::forward<Args>(args)...);
1225 break;
1226 case 10:
1227 F(sampling_10, std::forward<Args>(args)...);
1228 break;
1229 case 11:
1230 F(sampling_11, std::forward<Args>(args)...);
1231 break;
1232 case 12:
1233 F(sampling_12, std::forward<Args>(args)...);
1234 break;
1235 case 13:
1236 F(sampling_13, std::forward<Args>(args)...);
1237 break;
1238 case 14:
1239 F(sampling_14, std::forward<Args>(args)...);
1240 break;
1241 case 15:
1242 F(sampling_15, std::forward<Args>(args)...);
1243 break;
1244 case 16:
1245 F(sampling_16, std::forward<Args>(args)...);
1246 break;
1247 case 17:
1248 F(sampling_17, std::forward<Args>(args)...);
1249 break;
1250 case 18:
1251 F(sampling_18, std::forward<Args>(args)...);
1252 break;
1253 case 19:
1254 F(sampling_19, std::forward<Args>(args)...);
1255 break;
1256 case 20:
1257 F(sampling_20, std::forward<Args>(args)...);
1258 break;
1259 case 21:
1260 F(sampling_21, std::forward<Args>(args)...);
1261 break;
1262 case 22:
1263 F(sampling_22, std::forward<Args>(args)...);
1264 break;
1265 case 23:
1266 F(sampling_23, std::forward<Args>(args)...);
1267 break;
1268 case 24:
1269 F(sampling_24, std::forward<Args>(args)...);
1270 break;
1271 case 25:
1272 F(sampling_25, std::forward<Args>(args)...);
1273 break;
1274 case 26:
1275 F(sampling_26, std::forward<Args>(args)...);
1276 break;
1277 case 27:
1278 F(sampling_27, std::forward<Args>(args)...);
1279 break;
1280 default:
1281 break;
1282 }
1283 }
1284
1286 template <class Func, class ... Args>
1287 constexpr void apply_to_sampling(const int sampling, Func && F, Args && ... args) const
1288 {
1289 switch (sampling)
1290 {
1291 case 0:
1292 F(sampling_0, std::forward<Args>(args)...);
1293 break;
1294 case 1:
1295 F(sampling_1, std::forward<Args>(args)...);
1296 break;
1297 case 2:
1298 F(sampling_2, std::forward<Args>(args)...);
1299 break;
1300 case 3:
1301 F(sampling_3, std::forward<Args>(args)...);
1302 break;
1303 case 4:
1304 F(sampling_4, std::forward<Args>(args)...);
1305 break;
1306 case 5:
1307 F(sampling_5, std::forward<Args>(args)...);
1308 break;
1309 case 6:
1310 F(sampling_6, std::forward<Args>(args)...);
1311 break;
1312 case 7:
1313 F(sampling_7, std::forward<Args>(args)...);
1314 break;
1315 case 8:
1316 F(sampling_8, std::forward<Args>(args)...);
1317 break;
1318 case 9:
1319 F(sampling_9, std::forward<Args>(args)...);
1320 break;
1321 case 10:
1322 F(sampling_10, std::forward<Args>(args)...);
1323 break;
1324 case 11:
1325 F(sampling_11, std::forward<Args>(args)...);
1326 break;
1327 case 12:
1328 F(sampling_12, std::forward<Args>(args)...);
1329 break;
1330 case 13:
1331 F(sampling_13, std::forward<Args>(args)...);
1332 break;
1333 case 14:
1334 F(sampling_14, std::forward<Args>(args)...);
1335 break;
1336 case 15:
1337 F(sampling_15, std::forward<Args>(args)...);
1338 break;
1339 case 16:
1340 F(sampling_16, std::forward<Args>(args)...);
1341 break;
1342 case 17:
1343 F(sampling_17, std::forward<Args>(args)...);
1344 break;
1345 case 18:
1346 F(sampling_18, std::forward<Args>(args)...);
1347 break;
1348 case 19:
1349 F(sampling_19, std::forward<Args>(args)...);
1350 break;
1351 case 20:
1352 F(sampling_20, std::forward<Args>(args)...);
1353 break;
1354 case 21:
1355 F(sampling_21, std::forward<Args>(args)...);
1356 break;
1357 case 22:
1358 F(sampling_22, std::forward<Args>(args)...);
1359 break;
1360 case 23:
1361 F(sampling_23, std::forward<Args>(args)...);
1362 break;
1363 case 24:
1364 F(sampling_24, std::forward<Args>(args)...);
1365 break;
1366 case 25:
1367 F(sampling_25, std::forward<Args>(args)...);
1368 break;
1369 case 26:
1370 F(sampling_26, std::forward<Args>(args)...);
1371 break;
1372 case 27:
1373 F(sampling_27, std::forward<Args>(args)...);
1374 break;
1375 default:
1376 break;
1377 }
1378 }
1379
1380 private:
1381
1382 //CUDA and lambdas is still a bit tricky,
1383 //hence we'll use explicitly written functors
1384 //to implement several things.
1385
1387 {
1388 template <class Entry>
1389 constexpr void operator() (Entry & entry) const
1390 {
1391 entry.initialize();
1392 }
1393 };
1394
1396 {
1397 template <class Entry>
1398 constexpr void operator() (Entry & entry, const float min_eta, const float max_eta) const
1399 {
1400 entry.initialize(min_eta, max_eta);
1401 }
1402 };
1403
1405 {
1406 template <class Entry>
1407 constexpr void operator() (Entry & entry, const int cell,
1408 const float cell_eta, const float cell_phi,
1409 const float cell_deta, const float cell_dphi ) const
1410 {
1411 entry.register_cell(cell, cell_eta, cell_phi, cell_deta, cell_dphi);
1412 }
1413 };
1414
1416 {
1417 template <class Entry>
1418 constexpr void operator() (Entry & entry, size_t & ret) const
1419 {
1420 using namespace std;
1421 ret = max(ret, entry.finish_initializing_buffer_size());
1422 }
1423 };
1424
1426 {
1427 template <class Entry>
1428 constexpr void operator() (Entry & entry, void * buffer) const
1429 {
1430 entry.finish_initializing(buffer);
1431 }
1432 };
1433 //Aliohjelma-olio?
1434 //(To not go with the obvious funktio-olio...)
1435
1437 {
1438 template <class Entry>
1439 constexpr void operator() (Entry & entry, int & ret, const float test_eta, const float test_phi, int * cell_arr) const
1440 {
1441 ret = entry.get_possible_cells_from_coords(test_eta, test_phi, cell_arr);
1442 }
1443 };
1444
1446 {
1447 template <class Entry>
1448 constexpr void operator() (Entry & entry, bool & ret, const float test_eta, const float test_phi) const
1449 {
1450 ret = entry.has_cell_in_coords(test_eta, test_phi);
1451 }
1452 };
1453
1455 {
1456 template <class Entry>
1457 constexpr void operator() (Entry & entry, int & ret, const float test_eta, const float test_phi, int * cell_arr) const
1458 {
1459 ret += entry.get_possible_cells_from_coords(test_eta, test_phi, cell_arr + ret);
1460 }
1461 };
1462
1464 {
1465 template <class Entry>
1466 constexpr void operator() (Entry & entry, bool & ret, const float test_eta, const float test_phi) const
1467 {
1468 ret = ( ret || entry.has_cell_in_coords(test_eta, test_phi) );
1469 //Short circuit evaluation?
1470 }
1471 };
1472
1474 {
1475 template <class Entry>
1476 constexpr void operator() (const Entry & entry, int & ret) const
1477 {
1478 using namespace std;
1479 ret = max(ret, entry.get_max_real_overlap());
1480 }
1481 };
1482
1483 public:
1484
1486 constexpr void initialize()
1487 {
1489 }
1490
1492 constexpr void initialize(const int sampling, const float min_eta, const float max_eta)
1493 {
1494 apply_to_sampling(sampling, initialize_sampling_functor{}, min_eta, max_eta);
1495 }
1496
1497 constexpr void register_cell(const int cell, const int sampling, const float cell_eta, const float cell_phi, const float cell_deta, const float cell_dphi)
1498 {
1499 apply_to_sampling(sampling, register_cell_functor{}, cell, cell_eta, cell_phi, cell_deta, cell_dphi);
1500 }
1501
1502
1503 constexpr size_t finish_initializing_buffer_size() const
1504 {
1505 size_t ret = 0;
1506
1508
1509 return ret;
1510 }
1511
1514 {
1516 }
1517
1519 constexpr int get_possible_cells_from_coords(const int sampling, const float test_eta, const float test_phi, int * cell_arr) const
1520 {
1521 int ret = 0;
1522
1523 apply_to_sampling(sampling, get_cell_from_sampling_functor{}, ret, test_eta, test_phi, cell_arr);
1524
1525 return ret;
1526 }
1527
1528 constexpr bool has_cell_in_coords(const int sampling, const float test_eta, const float test_phi) const
1529 {
1530 bool ret = false;
1531
1532 apply_to_sampling(sampling, check_cell_in_sampling_functor{}, ret, test_eta, test_phi);
1533
1534 return ret;
1535 }
1536
1538 constexpr int get_possible_cells_from_coords(const float test_eta, const float test_phi, int * cell_arr) const
1539 {
1540 int ret = 0;
1541
1542 apply_to_all_samplings(get_cell_from_all_functor{}, ret, test_eta, test_phi, cell_arr);
1543
1544 return ret;
1545 }
1546
1547 constexpr bool has_cell_in_coords(const float test_eta, const float test_phi) const
1548 {
1549 bool ret = false;
1550
1551 apply_to_all_samplings(check_cell_in_all_functor{}, ret, test_eta, test_phi);
1552
1553 return ret;
1554 }
1555
1556 constexpr int get_max_real_overlap() const
1557 {
1558 int ret = 0;
1559
1561
1562 return ret;
1563 }
1564
1565 };
1566
1567}
1568
1569#endif //CALORECGPU_ETAPHIMAP_H
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define F(x, y, z)
Definition MD5.cxx:112
#define max(a, b)
Definition cfImp.cxx:41
static CUDA_HOS_DEV float regularize_angle(const float b, const float a=0.f)
static CUDA_HOS_DEV T angular_difference(const T x, const T y)
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration.
constexpr int NumSamplings
STL namespace.
constexpr bool try_add_next_gridcell(const int eta, const int phi)
Definition EtaPhiMap.h:453
float phis[s_eta_grid_size][phi_grid][s_max_overlap_cells]
Definition EtaPhiMap.h:378
float etas[s_eta_grid_size][phi_grid][s_max_overlap_cells]
Definition EtaPhiMap.h:377
constexpr void get_gridcell(const int i, int &eta, int &phi)
Definition EtaPhiMap.h:467
constexpr bool add_next_gridcell(const int eta, const int phi)
Definition EtaPhiMap.h:448
int cells[s_eta_grid_size][phi_grid][s_max_overlap_cells]
Definition EtaPhiMap.h:376
Holds an (eta, phi) to cell map for a given sampling.
Definition EtaPhiMap.h:35
float m_phi_coordinates[s_eta_grid_size][phi_grid][s_max_overlap_cells]
Definition EtaPhiMap.h:51
static constexpr float s_phi_max
Definition EtaPhiMap.h:41
constexpr void add_cell_to_grid(const int cell, const float eta_fraction, const float phi_fraction, const int eta, const int phi)
Definition EtaPhiMap.h:182
static constexpr int s_eta_grid_size
Definition EtaPhiMap.h:47
constexpr void register_cell(const int cell, const float cell_eta, const float cell_phi, const float cell_deta, const float cell_dphi)
Definition EtaPhiMap.h:249
int m_cells[s_eta_grid_size][phi_grid][s_max_overlap_cells]
Definition EtaPhiMap.h:49
constexpr float delta_phi() const
Definition EtaPhiMap.h:69
float m_eta_limits[1+!continuous]
Definition EtaPhiMap.h:44
constexpr int phi_coordinate(const float phi) const
Definition EtaPhiMap.h:150
static constexpr size_t finish_initializing_buffer_size()
Definition EtaPhiMap.h:478
constexpr float end_eta(const bool positive=true) const
Definition EtaPhiMap.h:95
constexpr bool has_cell_in_coords(const float test_eta, const float test_phi) const
Definition EtaPhiMap.h:985
constexpr void initialize(const float min_eta, const float max_eta)
Definition EtaPhiMap.h:341
constexpr int get_possible_cells_from_coords(const float test_eta, const float test_phi, int *cell_arr) const
We assume cell_arr is large enough.
Definition EtaPhiMap.h:887
constexpr float start_phi() const
Definition EtaPhiMap.h:90
static constexpr float s_delta_phi
Definition EtaPhiMap.h:42
constexpr int get_max_real_overlap() const
Definition EtaPhiMap.h:1049
constexpr float end_phi() const
Definition EtaPhiMap.h:111
CUDA_HOS_DEV void finish_initializing(void *buffer)
!
Definition EtaPhiMap.h:484
static constexpr int s_max_overlap_cells
Definition EtaPhiMap.h:36
float m_eta_coordinates[s_eta_grid_size][phi_grid][s_max_overlap_cells]
Definition EtaPhiMap.h:50
constexpr float phi_value(const int phi_coord) const
Definition EtaPhiMap.h:175
constexpr int eta_coordinate(const float eta, float &interval) const
Definition EtaPhiMap.h:116
constexpr float start_eta(const bool positive=true) const
Definition EtaPhiMap.h:74
constexpr float eta_value(const int eta_coord) const
Definition EtaPhiMap.h:163
static constexpr float s_phi_min
Definition EtaPhiMap.h:40
constexpr int phi_coordinate(const float phi, float &interval) const
Definition EtaPhiMap.h:140
constexpr float delta_eta() const
Definition EtaPhiMap.h:64
constexpr bool coordinates_in_range(const float eta, const float) const
Definition EtaPhiMap.h:156
constexpr void initialize()
Definition EtaPhiMap.h:327
constexpr int eta_coordinate(const float eta) const
Definition EtaPhiMap.h:134
constexpr void operator()(Entry &entry, size_t &ret) const
Definition EtaPhiMap.h:1418
constexpr void operator()(Entry &entry, bool &ret, const float test_eta, const float test_phi) const
Definition EtaPhiMap.h:1466
constexpr void operator()(Entry &entry, bool &ret, const float test_eta, const float test_phi) const
Definition EtaPhiMap.h:1448
constexpr void operator()(Entry &entry, void *buffer) const
Definition EtaPhiMap.h:1428
constexpr void operator()(Entry &entry, int &ret, const float test_eta, const float test_phi, int *cell_arr) const
Definition EtaPhiMap.h:1457
constexpr void operator()(Entry &entry, int &ret, const float test_eta, const float test_phi, int *cell_arr) const
Definition EtaPhiMap.h:1439
constexpr void operator()(Entry &entry) const
Definition EtaPhiMap.h:1389
constexpr void operator()(Entry &entry, const float min_eta, const float max_eta) const
Definition EtaPhiMap.h:1398
constexpr void operator()(const Entry &entry, int &ret) const
Definition EtaPhiMap.h:1476
constexpr void operator()(Entry &entry, const int cell, const float cell_eta, const float cell_phi, const float cell_deta, const float cell_dphi) const
Definition EtaPhiMap.h:1407
CUDA_HOS_DEV void finish_initializing(void *buffer)
!
Definition EtaPhiMap.h:1513
EtaPhiMapEntry< 34, 66, false, false, 11 > sampling_11
Definition EtaPhiMap.h:1102
static constexpr int s_max_overlap_cells
Definition EtaPhiMap.h:1086
EtaPhiMapEntry< 148, 232, false, false, 21 > sampling_21
Definition EtaPhiMap.h:1112
EtaPhiMapEntry< 150, 260, false, false, 6 > sampling_6
Definition EtaPhiMap.h:1097
constexpr bool has_cell_in_coords(const float test_eta, const float test_phi) const
Definition EtaPhiMap.h:1547
constexpr int get_possible_cells_from_coords(const int sampling, const float test_eta, const float test_phi, int *cell_arr) const
We assume cell_arr is large enough.
Definition EtaPhiMap.h:1519
EtaPhiMapEntry< 1, 1, true, true, 25 > sampling_25
Definition EtaPhiMap.h:1116
EtaPhiMapEntry< 12, 66, true, false, 19 > sampling_19
Definition EtaPhiMap.h:1110
EtaPhiMapEntry< 12, 66, true, false, 18 > sampling_18
Definition EtaPhiMap.h:1109
EtaPhiMapEntry< 6, 66, true, false, 16 > sampling_16
Definition EtaPhiMap.h:1107
constexpr void register_cell(const int cell, const int sampling, const float cell_eta, const float cell_phi, const float cell_deta, const float cell_dphi)
Definition EtaPhiMap.h:1497
constexpr void initialize()
Initialize all cells of all samplings.
Definition EtaPhiMap.h:1486
EtaPhiMapEntry< 10, 66, true, true, 14 > sampling_14
Definition EtaPhiMap.h:1105
constexpr size_t finish_initializing_buffer_size() const
Definition EtaPhiMap.h:1503
EtaPhiMapEntry< 6, 66, true, false, 15 > sampling_15
Definition EtaPhiMap.h:1106
EtaPhiMapEntry< 958, 262, false, false, 1 > sampling_1
Definition EtaPhiMap.h:1092
EtaPhiMapEntry< 732, 68, false, false, 5 > sampling_5
Definition EtaPhiMap.h:1096
constexpr void apply_to_all_samplings(Func &&F, Args &&... args) const
F must be prepared to receive as first argument a EtaPhiMapEntry<N, M>, as well as any arguments.
Definition EtaPhiMap.h:1158
constexpr int get_possible_cells_from_coords(const float test_eta, const float test_phi, int *cell_arr) const
We assume cell_arr is large enough.
Definition EtaPhiMap.h:1538
EtaPhiMapEntry< 1, 1, true, true, 26 > sampling_26
Definition EtaPhiMap.h:1117
EtaPhiMapEntry< 98, 164, false, false, 22 > sampling_22
Definition EtaPhiMap.h:1113
EtaPhiMapEntry< 6, 66, true, false, 20 > sampling_20
Definition EtaPhiMap.h:1111
EtaPhiMapEntry< 24, 66, true, true, 12 > sampling_12
Definition EtaPhiMap.h:1103
EtaPhiMapEntry< 25, 68, false, false, 4 > sampling_4
Definition EtaPhiMap.h:1095
EtaPhiMapEntry< 64, 130, false, false, 23 > sampling_23
Definition EtaPhiMap.h:1114
EtaPhiMapEntry< 58, 262, false, false, 3 > sampling_3
Definition EtaPhiMap.h:1094
constexpr void apply_to_all_samplings(Func &&F, Args &&... args)
F must be prepared to receive as first argument a EtaPhiMapEntry<N, M>, as well as any arguments.
Definition EtaPhiMap.h:1124
constexpr int get_max_real_overlap() const
Definition EtaPhiMap.h:1556
EtaPhiMapEntry< 124, 262, false, false, 2 > sampling_2
Definition EtaPhiMap.h:1093
EtaPhiMapEntry< 1, 1, true, true, 27 > sampling_27
Definition EtaPhiMap.h:1118
constexpr void apply_to_sampling(const int sampling, Func &&F, Args &&... args)
F must be prepared to receive as first argument a EtaPhiMapEntry<N, M>, as well as any arguments.
Definition EtaPhiMap.h:1192
constexpr bool has_cell_in_coords(const int sampling, const float test_eta, const float test_phi) const
Definition EtaPhiMap.h:1528
EtaPhiMapEntry< 34, 66, false, false, 9 > sampling_9
Definition EtaPhiMap.h:1100
EtaPhiMapEntry< 1, 1, true, true, 24 > sampling_24
Definition EtaPhiMap.h:1115
constexpr void apply_to_sampling(const int sampling, Func &&F, Args &&... args) const
F must be prepared to receive as first argument a EtaPhiMapEntry<N, M>, as well as any arguments.
Definition EtaPhiMap.h:1287
EtaPhiMapEntry< 72, 260, false, false, 7 > sampling_7
Definition EtaPhiMap.h:1098
EtaPhiMapEntry< 40, 66, false, false, 8 > sampling_8
Definition EtaPhiMap.h:1099
constexpr void initialize(const int sampling, const float min_eta, const float max_eta)
Initialize a specific sampling with known eta and phi ranges.
Definition EtaPhiMap.h:1492
EtaPhiMapEntry< 20, 66, true, true, 13 > sampling_13
Definition EtaPhiMap.h:1104
EtaPhiMapEntry< 16, 66, true, false, 17 > sampling_17
Definition EtaPhiMap.h:1108
EtaPhiMapEntry< 32, 66, false, false, 10 > sampling_10
Definition EtaPhiMap.h:1101
EtaPhiMapEntry< 126, 66, false, true, 0 > sampling_0
Definition EtaPhiMap.h:1091