Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove naming conflicts with module keyword #600

Merged
merged 2 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,25 @@ namespace traccc::details {

/// Function used for retrieving the cell signal based on the module id
TRACCC_HOST_DEVICE
inline scalar signal_cell_modelling(scalar signal_in,
const cell_module& module);
inline scalar signal_cell_modelling(scalar signal_in, const cell_module& mod);

/// Function for pixel segmentation
TRACCC_HOST_DEVICE
inline vector2 position_from_cell(const cell& cell, const cell_module& module);
inline vector2 position_from_cell(const cell& cell, const cell_module& mod);

/// Function used for calculating the properties of the cluster during
/// measurement creation
///
/// @param[in] cluster The vector of cells describing the identified cluster
/// @param[in] module The cell module
/// @param[in] mod The cell module
/// @param[out] mean The mean position of the cluster/measurement
/// @param[out] var The variation on the mean position of the
/// cluster/measurement
/// @param[out] totalWeight The total weight of the cluster/measurement
///
TRACCC_HOST_DEVICE inline void calc_cluster_properties(
const cell_collection_types::const_device& cluster,
const cell_module& module, point2& mean, point2& var, scalar& totalWeight);
const cell_collection_types::const_device& cluster, const cell_module& mod,
point2& mean, point2& var, scalar& totalWeight);

/// Function used for calculating the properties of the cluster during
/// measurement creation
Expand All @@ -45,14 +44,14 @@ TRACCC_HOST_DEVICE inline void calc_cluster_properties(
/// object will be filled
/// @param[in] measurement_index is the index of the measurement object to fill
/// @param[in] cluster is the input cell vector
/// @param[in] module is the cell module where the cluster belongs to
/// @param[in] module_link is the module index
/// @param[in] mod is the cell module where the cluster belongs to
/// @param[in] mod_link is the module index
///
TRACCC_HOST_DEVICE inline void fill_measurement(
measurement_collection_types::device& measurements,
std::size_t measurement_index,
const cell_collection_types::const_device& cluster,
const cell_module& module, const unsigned int module_link);
const cell_collection_types::const_device& cluster, const cell_module& mod,
const unsigned int mod_link);

} // namespace traccc::details

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ namespace traccc::details {
///
/// @param sp The spacepoint to fill / set up
/// @param measurement The measurement to create the spacepoint out of
/// @param module The module that the measurement belongs to
/// @param mod The module that the measurement belongs to
///
TRACCC_HOST_DEVICE inline void fill_spacepoint(spacepoint& sp,
const measurement& meas,
const cell_module& module);
const cell_module& mod);

} // namespace traccc::details

Expand Down
34 changes: 17 additions & 17 deletions core/include/traccc/clusterization/impl/measurement_creation.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,34 @@ namespace traccc::details {

TRACCC_HOST_DEVICE
inline scalar signal_cell_modelling(scalar signal_in,
const cell_module& /*module*/) {
const cell_module& /*mod*/) {
return signal_in;
}

TRACCC_HOST_DEVICE
inline vector2 position_from_cell(const cell& cell, const cell_module& module) {
inline vector2 position_from_cell(const cell& cell, const cell_module& mod) {

// Retrieve the specific values based on module idx
return {module.pixel.min_center_x + cell.channel0 * module.pixel.pitch_x,
module.pixel.min_center_y + cell.channel1 * module.pixel.pitch_y};
return {mod.pixel.min_center_x + cell.channel0 * mod.pixel.pitch_x,
mod.pixel.min_center_y + cell.channel1 * mod.pixel.pitch_y};
}

TRACCC_HOST_DEVICE inline void calc_cluster_properties(
const cell_collection_types::const_device& cluster,
const cell_module& module, point2& mean, point2& var, scalar& totalWeight) {
const cell_collection_types::const_device& cluster, const cell_module& mod,
point2& mean, point2& var, scalar& totalWeight) {

// Loop over the cells of the cluster.
for (const cell& cell : cluster) {

// Translate the cell readout value into a weight.
const scalar weight = signal_cell_modelling(cell.activation, module);
const scalar weight = signal_cell_modelling(cell.activation, mod);

// Only consider cells over a minimum threshold.
if (weight > module.threshold) {
if (weight > mod.threshold) {

// Update all output properties with this cell.
totalWeight += cell.activation;
const point2 cell_position = position_from_cell(cell, module);
const point2 cell_position = position_from_cell(cell, mod);
const point2 prev = mean;
const point2 diff = cell_position - prev;

Expand All @@ -54,8 +54,8 @@ TRACCC_HOST_DEVICE inline void calc_cluster_properties(
TRACCC_HOST_DEVICE inline void fill_measurement(
measurement_collection_types::device& measurements,
std::size_t measurement_index,
const cell_collection_types::const_device& cluster,
const cell_module& module, const unsigned int module_link) {
const cell_collection_types::const_device& cluster, const cell_module& mod,
const unsigned int mod_link) {

// To calculate the mean and variance with high numerical stability
// we use a weighted variant of Welford's algorithm. This is a
Expand All @@ -70,22 +70,22 @@ TRACCC_HOST_DEVICE inline void fill_measurement(
// Calculate the cluster properties
scalar totalWeight = 0.;
point2 mean{0., 0.}, var{0., 0.};
calc_cluster_properties(cluster, module, mean, var, totalWeight);
calc_cluster_properties(cluster, mod, mean, var, totalWeight);

if (totalWeight > 0.) {

// Access the measurement in question.
measurement& m = measurements[measurement_index];

m.module_link = module_link;
m.surface_link = module.surface_link;
m.module_link = mod_link;
m.surface_link = mod.surface_link;
// normalize the cell position
m.local = mean;
// normalize the variance
m.variance[0] = var[0] / totalWeight;
m.variance[1] = var[1] / totalWeight;
// plus pitch^2 / 12
const auto pitch = module.pixel.get_pitch();
const auto pitch = mod.pixel.get_pitch();
m.variance =
m.variance + point2{pitch[0] * pitch[0] / static_cast<scalar>(12.),
pitch[1] * pitch[1] / static_cast<scalar>(12.)};
Expand All @@ -95,10 +95,10 @@ TRACCC_HOST_DEVICE inline void fill_measurement(
m.measurement_id = measurement_index;

// Adjust the measurement object for 1D surfaces.
if (module.pixel.dimension == 1) {
if (mod.pixel.dimension == 1) {
m.meas_dim = 1;
m.local[1] = 0.f;
m.variance[1] = module.pixel.variance_y;
m.variance[1] = mod.pixel.variance_y;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ namespace traccc::details {

TRACCC_HOST_DEVICE inline void fill_spacepoint(spacepoint& sp,
const measurement& meas,
const cell_module& module) {
const cell_module& mod) {

// Transform measurement position to 3D
const point3 local_3d = {meas.local[0], meas.local[1], 0.f};
sp.global = module.placement.point_to_global(local_3d);
sp.global = mod.placement.point_to_global(local_3d);
sp.meas = meas;
}

Expand Down
7 changes: 3 additions & 4 deletions core/src/clusterization/measurement_creation_algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ measurement_creation_algorithm::operator()(
assert(cluster.empty() == false);

// Get the cell module
const unsigned int module_link = cluster.at(0).module_link;
const auto &module = modules.at(module_link);
const unsigned int mod_link = cluster.at(0).module_link;
const auto &mod = modules.at(mod_link);

// Fill measurement from cluster
details::fill_measurement(measurements, i, cluster, module,
module_link);
details::fill_measurement(measurements, i, cluster, mod, mod_link);
}

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ inline void form_spacepoints(
// Get the measurement for this index
const measurement& measurement = measurements.at(globalIndex);
// Get the current cell module
const cell_module& module = modules.at(measurement.module_link);
const cell_module& mod = modules.at(measurement.module_link);

// Fill the spacepoint using the common function.
details::fill_spacepoint(spacepoints.at(globalIndex), measurement, module);
details::fill_spacepoint(spacepoints.at(globalIndex), measurement, mod);
}

} // namespace traccc::device
4 changes: 2 additions & 2 deletions device/futhark/src/component_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ component_connection::output_type component_connection::operator()(
for (std::size_t i = 0, k = 0; i < data.size(); ++i) {
for (std::size_t j = 0; j < data.at(i).items.size(); ++j, ++k) {
host_event[k] = 0;
host_geometry[k] = data.at(i).header.module;
host_geometry[k] = data.at(i).header.mod;
host_channel0[k] = data.at(i).items.at(j).channel0;
host_channel1[k] = data.at(i).items.at(j).channel1;
host_activation[k] = data.at(i).items.at(j).activation;
Expand All @@ -66,7 +66,7 @@ component_connection::output_type component_connection::operator()(
v.reserve(data.at(i).items.size());

for (std::size_t j = 0; j < std::get<1>(r).size(); ++j) {
if (std::get<1>(r)[j] == data.at(i).header.module) {
if (std::get<1>(r)[j] == data.at(i).header.mod) {
measurement m;

m.local = {std::get<2>(r)[j], std::get<3>(r)[j]};
Expand Down
2 changes: 1 addition & 1 deletion device/futhark/src/spacepoint_formation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ spacepoint_formation::output_type spacepoint_formation::operator()(
for (std::size_t j = 0; j < data.at(i).items.size(); ++j) {
++total_measurements;
measurements.push_back(data.at(i).items.at(j));
geom_ids.push_back(data.at(i).header.module);
geom_ids.push_back(data.at(i).header.mod);
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/cpu/seq_single_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ TEST(algorithms, seq_single_module) {
{11, 13, 8, 0, 0},
{4, 14, 9, 0, 0}},
&resource};
traccc::cell_module module;
traccc::cell_module mod;
traccc::cell_module_collection_types::host modules(&resource);
modules.push_back(module);
modules.push_back(mod);

auto clusters = cc(vecmem::get_data(cells));
EXPECT_EQ(clusters.size(), 4u);
Expand Down
2 changes: 1 addition & 1 deletion tests/futhark/test_cca.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cca_function_t f = [](const traccc::cell_container_types::host &data) {
msv.push_back(mss.at(i).items.at(j));
}

result.emplace(mss.at(i).header.module, std::move(msv));
result.emplace(mss.at(i).header.mod, std::move(msv));
}

return result;
Expand Down
4 changes: 2 additions & 2 deletions tests/io/test_csv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ TEST_F(io, csv_read_single_module) {
auto& modules = single_module_cells.modules;
ASSERT_EQ(cells.size(), 6u);
ASSERT_EQ(modules.size(), 1u);
auto module = single_module_cells.modules.at(0);
auto mod = single_module_cells.modules.at(0);

ASSERT_EQ(module.surface_link.value(), 0u);
ASSERT_EQ(mod.surface_link.value(), 0u);
ASSERT_EQ(cells.at(0).channel0, 123u);
ASSERT_EQ(cells.at(0).channel1, 32u);
ASSERT_EQ(cells.at(5).channel0, 174u);
Expand Down
Loading