diff --git a/Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx b/Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx index 2ebfbfe235c5b..8ae0549bd1595 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx @@ -596,20 +596,14 @@ void TrackerTraits::findCellsNeighbours(const int iteration) mTimeFrame->getCellsNeighbours()[iLayer].reserve(cellsNeighbours.size()); std::ranges::transform(cellsNeighbours, std::back_inserter(mTimeFrame->getCellsNeighbours()[iLayer]), [](const auto& neigh) { return neigh.cell; }); - auto it = cellsNeighbours.begin(); - int current = it->nextCell; - int maxLvl = it->level; - ++it; - for (; it != cellsNeighbours.end(); ++it) { - if (it->nextCell == current) { + for (auto it = cellsNeighbours.begin(); it != cellsNeighbours.end();) { + int cellIdx = it->nextCell; + int maxLvl = it->level; + while (++it != cellsNeighbours.end() && it->nextCell == cellIdx) { maxLvl = std::max(maxLvl, it->level); - } else { - mTimeFrame->getCells()[iLayer + 1][current].setLevel(maxLvl); - current = it->nextCell; - maxLvl = it->level; } + o2::gpu::CAMath::AtomicMax(mTimeFrame->getCells()[iLayer + 1][cellIdx].getLevelPtr(), maxLvl); } - mTimeFrame->getCells()[iLayer + 1][current].setLevel(maxLvl); } }); }