59 using clock_type = boost::chrono::thread_clock;
60 auto time_cast = [](
const auto & before,
const auto & after)
62 return boost::chrono::duration_cast<boost::chrono::microseconds>(after - before).count();
70 cd.m_geometry.allocate();
83 max_eta_pos[
i] = std::numeric_limits<float>::lowest();
85 max_eta_neg[
i] = std::numeric_limits<float>::lowest();
87 max_phi_pos[
i] = std::numeric_limits<float>::lowest();
89 max_phi_neg[
i] = std::numeric_limits<float>::lowest();
98 const Identifier cell_identifier = calo_id->cell_id((IdentifierHash)
cell);
100 const int sampling = calo_id->calo_sample(cell_identifier);
101 const int intra_calo_sampling = calo_id->sampling(cell_identifier);
102 const int subcalo = caloElement->
getSubCalo();
103 const int region = calo_id->region(cell_identifier);
111 ConstantEnumConversion::from_intra_calorimeter_sampling_enum(intra_calo_sampling),
112 ConstantEnumConversion::from_subcalo_enum(subcalo),
113 ConstantEnumConversion::from_region_enum(region),
116 cd.m_geometry->x[
cell] = caloElement->
x();
117 cd.m_geometry->y[
cell] = caloElement->
y();
118 cd.m_geometry->z[
cell] = caloElement->
z();
119 cd.m_geometry->r[
cell] = caloElement->
r();
120 cd.m_geometry->eta[
cell] = caloElement->
eta();
121 cd.m_geometry->phi[
cell] = caloElement->
phi();
123 cd.m_geometry->dx[
cell] = caloElement->
dx();
124 cd.m_geometry->dy[
cell] = caloElement->
dy();
125 cd.m_geometry->dz[
cell] = caloElement->
dz();
126 cd.m_geometry->dr[
cell] = caloElement->
dr();
127 cd.m_geometry->deta[
cell] = caloElement->
deta();
128 cd.m_geometry->dphi[
cell] = caloElement->
dphi();
131 cd.m_geometry->neighbours.offsets[
cell] = 0;
133 if (caloElement->
eta() >= 0)
135 min_eta_pos[sampling] =
std::min(min_eta_pos[sampling], caloElement->
eta() - caloElement->
deta() / 2);
136 min_phi_pos[sampling] =
std::min(min_phi_pos[sampling], caloElement->
phi() - caloElement->
dphi() / 2);
137 max_eta_pos[sampling] =
std::max(max_eta_pos[sampling], caloElement->
eta() + caloElement->
deta() / 2);
138 max_phi_pos[sampling] =
std::max(max_phi_pos[sampling], caloElement->
phi() + caloElement->
dphi() / 2);
142 min_eta_neg[sampling] =
std::min(min_eta_neg[sampling], caloElement->
eta() - caloElement->
deta() / 2);
143 min_phi_neg[sampling] =
std::min(min_phi_neg[sampling], caloElement->
phi() - caloElement->
dphi() / 2);
144 max_eta_neg[sampling] =
std::max(max_eta_neg[sampling], caloElement->
eta() + caloElement->
deta() / 2);
145 max_phi_neg[sampling] =
std::max(max_phi_neg[sampling], caloElement->
phi() + caloElement->
dphi() / 2);
147 min_deta[sampling] =
std::min(min_deta[sampling], caloElement->
deta());
148 min_dphi[sampling] =
std::min(min_dphi[sampling], caloElement->
dphi());
154 constexpr
float corrective_factor = 0.99f;
155 cd.m_geometry->etaPhiToCell.initialize(
i, min_eta_neg[
i], min_phi_neg[
i], max_eta_neg[
i], max_phi_neg[
i],
156 min_eta_pos[
i], min_phi_pos[
i], max_eta_pos[
i], max_phi_pos[
i],
157 min_deta[
i]*corrective_factor, min_dphi[
i]*corrective_factor);
160 cd.m_geometry->fill_eta_phi_map();
162 std::vector<IdentifierHash> neighbour_vector, full_neighs, prev_neighs;
166 for (
int neigh_bit_set = 0; neigh_bit_set <
NumNeighOptions; ++neigh_bit_set)
168 const unsigned int curr_neigh_opt = (1U << neigh_bit_set);
180 calo_id->get_neighbours((IdentifierHash)
cell,
186 calo_id->get_neighbours((IdentifierHash)
cell,
189 calo_id->get_neighbours((IdentifierHash)
cell,
197 std::sort(neighbour_vector.begin(), neighbour_vector.end());
198 std::sort(prev_neighs.begin(), prev_neighs.end());
202 std::set_difference( prev_neighs.begin(), prev_neighs.end(),
203 neighbour_vector.begin(), neighbour_vector.end(),
204 std::back_inserter(full_neighs) );
208 prev_neighs.resize(
cd.m_geometry->neighbours.get_total_number_of_neighbours(
cell));
211 for (
size_t neigh = 0; neigh < prev_neighs.size(); ++neigh)
213 prev_neighs[neigh] =
cd.m_geometry->neighbours.get_neighbour(
cell, neigh);
216 std::sort(full_neighs.begin(), full_neighs.end());
217 std::sort(prev_neighs.begin(), prev_neighs.end());
219 neighbour_vector.clear();
221 std::set_difference( full_neighs.begin(), full_neighs.end(),
222 prev_neighs.begin(), prev_neighs.end(),
223 std::back_inserter(neighbour_vector) );
230 std::sort(neighbour_vector.begin(), neighbour_vector.end());
232 const int neighs_start =
cd.m_geometry->neighbours.get_total_number_of_neighbours(
cell);
234 for (
size_t neigh_num = 0; neigh_num < neighbour_vector.size(); ++neigh_num)
236 cd.m_geometry->neighbours.set_neighbour(
cell, neighs_start + neigh_num, neighbour_vector[neigh_num]);
239 cd.m_geometry->neighbours.offsets[
cell] += NeighOffset::offset_delta(neigh_bit_set) * neighbour_vector.size();
244 #if CALORECGPU_ADD_FULL_PAIRS_LIST_TO_CONSTANT_INFORMATION
253 auto add_neighbours = [&](
const int cell,
const unsigned int curr_neigh_opt)
257 const int num_neighs =
cd.m_geometry->neighbours.get_neighbours(curr_neigh_opt,
cell, neighbours);
259 for (
int neigh = 0; neigh < num_neighs; ++neigh)
261 cd.m_geometry->neighPairs.cell_A[num_pairs] =
cell;
262 cd.m_geometry->neighPairs.cell_B[num_pairs] = neighbours[neigh];
267 for (
int neigh_bit_set = 0; neigh_bit_set <
NumNeighOptions; ++neigh_bit_set)
269 const unsigned int curr_neigh_opt = (1U << neigh_bit_set);
273 if (
cd.m_geometry->is_PS(
cell) ||
cd.m_geometry->is_HECIW_or_FCal(
cell))
278 add_neighbours(
cell, curr_neigh_opt);
285 if (!
cd.m_geometry->is_PS(
cell))
290 add_neighbours(
cell, curr_neigh_opt);
297 if (!
cd.m_geometry->is_HECIW_or_FCal(
cell))
302 add_neighbours(
cell, curr_neigh_opt);
344 const CaloNoise * noise_tool = *noise_handle;
346 IdentifierHash t_start, t_end;
360 cd.m_cell_noise.allocate();
364 cd.m_cell_noise->noise_properties = CellNoiseProperties::invalid_value();
371 cd.m_cell_noise->luminosity = noise_tool->
getLumi();
377 cd.m_cell_noise->noise[
cell][gain_state] = noise_tool->
larStorage()[(gain_state > 2 ? 0 : gain_state)][
cell];
385 cd.m_cell_noise->double_gaussian_constants[0][
cell - t_start][gain_state] =
blob->getData(
cell - t_start, gain_state, 2);
386 cd.m_cell_noise->double_gaussian_constants[1][
cell - t_start][gain_state] =
blob->getData(
cell - t_start, gain_state, 3);
387 cd.m_cell_noise->double_gaussian_constants[2][
cell - t_start][gain_state] =
blob->getData(
cell - t_start, gain_state, 4);
388 cd.m_cell_noise->double_gaussian_constants[3][
cell - t_start][gain_state] =
blob->getData(
cell - t_start, gain_state, 1);
395 cd.m_cell_noise->noise[
cell][gain_state] = 0;
409 time_cast(after_geo, after_noise),
410 time_cast(after_noise, after_send)
414 return StatusCode::SUCCESS;