116 int eta_coord_start = 0, eta_coord_end = 0, phi_coord_start = 0, phi_coord_end = 0;
117 int phi_coord_extra_neg = 0, phi_coord_extra_pos = 0;
118 float eta_fraction_start = 0.f, eta_fraction_end = 0.f, phi_fraction_start = 0.f, phi_fraction_end = 0.f;
119 float phi_fraction_extra_neg = 0.f, phi_fraction_extra_pos = 0.f;
121 eta_coord_start =
eta_coordinate(cell_eta - cell_deta / 2, eta_fraction_start);
122 eta_coord_end =
eta_coordinate(cell_eta + cell_deta / 2, eta_fraction_end);
123 phi_coord_start =
phi_coordinate(cell_phi - cell_dphi / 2, phi_fraction_start);
124 phi_coord_end =
phi_coordinate(cell_phi + cell_dphi / 2, phi_fraction_end);
126 phi_coord_extra_neg =
phi_coordinate(cell_phi + cell_dphi / 2 - 2 * Helpers::Constants::pi<float>, phi_fraction_extra_neg);
127 phi_coord_extra_pos =
phi_coordinate(cell_phi - cell_dphi / 2 + 2 * Helpers::Constants::pi<float>, phi_fraction_extra_pos);
129 if ((eta_coord_end == eta_coord_start && (eta_fraction_start > 0 || eta_fraction_end < 1)) ||
130 (phi_coord_end == phi_coord_start && (phi_fraction_start > 0 || phi_fraction_end < 1)) )
133 printf(
"Something strange going on with cell %d: %f %f %f %f %f %f (%d %d %f %f | %d %d %f %f)\n",
135 eta_coord_start, eta_coord_end, eta_fraction_start, eta_fraction_end,
136 phi_coord_start, phi_coord_end, phi_fraction_start, phi_fraction_end);
141 if (eta_coord_start < 0 || eta_coord_end < 0 || phi_coord_start < 0 || phi_coord_end < 0 ||
142 eta_fraction_start < 0 || eta_fraction_end < 0 || phi_fraction_start < 0 || phi_fraction_end < 0)
145 printf(
"Underflowing cell %d: %f %f %f %f %f %f (%d %d %f %f | %d %d %f %f) [%f %f]\n",
146 cell, cell_eta, cell_deta, cell_eta - cell_deta / 2, cell_phi, cell_dphi, cell_phi - cell_dphi / 2,
147 eta_coord_start, eta_coord_end, eta_fraction_start, eta_fraction_end,
148 phi_coord_start, phi_coord_end, phi_fraction_start, phi_fraction_end,
154 if (eta_coord_start >= eta_grid || eta_coord_end >= eta_grid || phi_coord_start >= phi_grid || phi_coord_end >= phi_grid ||
155 eta_fraction_start > 1 || eta_fraction_end > 1 || phi_fraction_start > 1 || phi_fraction_end > 1)
158 printf(
"Overflowing cell %d: %f %f %f %f %f %f (%d %d %f %f | %d %d %f %f) [%f %f]\n",
159 cell, cell_eta, cell_deta, cell_eta + cell_deta / 2, cell_phi, cell_dphi, cell_phi + cell_dphi / 2,
160 eta_coord_start, eta_coord_end, eta_fraction_start, eta_fraction_end,
161 phi_coord_start, phi_coord_end, phi_fraction_start, phi_fraction_end,
167 for (
int eta_c = eta_coord_start; eta_c <= eta_coord_end; ++eta_c)
169 const float eta_corner = ( eta_c == eta_coord_start ?
170 -eta_fraction_start : ( eta_c == eta_coord_end ?
171 eta_fraction_end : 0.f )
173 for (
int phi_c = 0; phi_c <= phi_coord_extra_neg; ++phi_c)
175 const float phi_corner = ( phi_c == phi_coord_extra_neg ?
176 phi_fraction_extra_neg : 0.f );
181 for (
int phi_c = phi_coord_start; phi_c <= phi_coord_end; ++phi_c)
183 const float phi_corner = ( phi_c == phi_coord_start ?
184 -phi_fraction_start : ( phi_c == phi_coord_end ?
185 phi_fraction_end : 0.f )
189 for (
int phi_c = phi_coord_extra_pos; phi_c < phi_grid; ++phi_c)
191 const float phi_corner = ( phi_c == phi_coord_extra_pos ?
192 -phi_fraction_extra_pos : 0.f );