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

fix: remove narrowing conversion from std::size_t to int #3932

Merged
merged 3 commits into from
Dec 5, 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
20 changes: 6 additions & 14 deletions Core/src/Detector/detail/IndexedGridFiller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,39 +47,31 @@ std::vector<std::size_t> Acts::Experimental::detail::binSequence(
rBins.reserve(bmax - bmin + 1u + 2 * expand);
// handle bmin:/max expand it down (for bound, don't fill underflow)
if (type == Acts::AxisBoundaryType::Bound) {
bmin = (static_cast<int>(bmin) - static_cast<int>(expand) > 0)
? bmin - expand
: 1u;
bmin = bmin > expand ? bmin - expand : 1u;
bmax = (bmax + expand <= nBins) ? bmax + expand : nBins;
} else if (type == Acts::AxisBoundaryType::Open) {
bmin = (static_cast<int>(bmin) - static_cast<int>(expand) >= 0)
? bmin - expand
: 0u;
bmin = bmin >= expand ? bmin - expand : 0u;
bmax = (bmax + expand <= nBins + 1u) ? bmax + expand : nBins + 1u;
}
fill_linear(bmin, bmax);
} else {
// Close case
std::size_t span = bmax - bmin + 1u + 2 * expand;
// Safe with respect to the closure point, treat as bound
if (2 * span < nBins && (bmax + expand <= nBins) &&
(static_cast<int>(bmin) - static_cast<int>(expand) > 0)) {
if (2 * span < nBins && (bmax + expand <= nBins) && (bmin > expand)) {
return binSequence({bmin, bmax}, expand, nBins,
Acts::AxisBoundaryType::Bound);
} else if (2 * span < nBins) {
bmin = static_cast<int>(bmin) - static_cast<int>(expand) > 0
? bmin - expand
: 1u;
bmin = bmin > expand ? bmin - expand : 1u;
bmax = bmax + expand <= nBins ? bmax + expand : nBins;
fill_linear(bmin, bmax);
// deal with expansions over the phi boundary
if (bmax + expand > nBins) {
std::size_t overstep = (bmax + expand - nBins);
fill_linear(1u, overstep);
}
if (static_cast<int>(bmin) - static_cast<int>(expand) < 1) {
std::size_t understep =
abs(static_cast<int>(bmin) - static_cast<int>(expand));
if (bmin <= expand) {
std::size_t understep = expand - bmin;
fill_linear(nBins - understep, nBins);
}
std::ranges::sort(rBins);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class DigitizationAlgorithm final : public IAlgorithm {
Config m_cfg;
/// Digitizers within geometry hierarchy
Acts::GeometryHierarchyMap<Digitizer> m_digitizers;
/// Geometric digtizer
/// Geometric digitizer
ActsFatras::Channelizer m_channelizer;

using CellsMap =
Expand Down Expand Up @@ -153,7 +153,7 @@ class DigitizationAlgorithm final : public IAlgorithm {
// Copy the geometric configuration
impl.geometric = cfg.geometricDigiConfig;
// Prepare the smearing configuration
for (int i = 0; i < static_cast<int>(kSmearDIM); ++i) {
for (std::size_t i = 0; i < kSmearDIM; ++i) {
impl.smearing.indices[i] = cfg.smearingDigiConfig.at(i).index;
impl.smearing.smearFunctions[i] =
cfg.smearingDigiConfig.at(i).smearFunction;
Expand Down
3 changes: 2 additions & 1 deletion Examples/Algorithms/TrackFitting/src/RefittingAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ ActsExamples::ProcessCode ActsExamples::RefittingAlgorithm::execute(
auto itrack = 0ul;
for (const auto& track : inputTracks) {
// Check if you are not in picking mode
if (m_cfg.pickTrack > -1 && m_cfg.pickTrack != static_cast<int>(itrack++)) {
if (m_cfg.pickTrack > -1 &&
static_cast<std::size_t>(m_cfg.pickTrack) != itrack++) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ ActsExamples::ProcessCode ActsExamples::TrackFittingAlgorithm::execute(
std::vector<Acts::SourceLink> trackSourceLinks;
for (std::size_t itrack = 0; itrack < protoTracks.size(); ++itrack) {
// Check if you are not in picking mode
if (m_cfg.pickTrack > -1 && m_cfg.pickTrack != static_cast<int>(itrack)) {
if (m_cfg.pickTrack > -1 &&
static_cast<std::size_t>(m_cfg.pickTrack) != itrack) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ struct BoundParametersSmearer {

ParametersVector par = ParametersVector::Zero();
CovarianceMatrix cov = CovarianceMatrix::Zero();
for (int i = 0; i < static_cast<int>(kSize); ++i) {
for (std::size_t i = 0; i < kSize; ++i) {
auto res = smearFunctions[i](boundParams[indices[i]], rng);
if (!res.ok()) {
return Result::failure(res.error());
Expand Down
Loading