Skip to content

Commit 824fcf0

Browse files
committed
Cleanup indextable configuration
1 parent 1b6f096 commit 824fcf0

4 files changed

Lines changed: 30 additions & 43 deletions

File tree

‎Detectors/ITSMFT/common/tracking/include/ITSMFTTracking/IndexTableConfiguration.h‎

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
#ifndef ALICEO2_ITSMFT_TRACKING_INDEXTABLECONFIGURATION_H_
1313
#define ALICEO2_ITSMFT_TRACKING_INDEXTABLECONFIGURATION_H_
1414

15-
#include <cstdint>
16-
1715
// Host-only: DetectorParameters owns std::vector members and is not
18-
// device-compatible. Keep this boundary separate so existing host-binding
16+
// device-compatible. Keep this boundary separate so existing host-configuration
1917
// consumers do not inherit IndexTableUtils.h's extra dependencies.
2018
#ifndef GPUCA_GPUCODE
2119

@@ -30,27 +28,16 @@
3028
namespace o2::itsmft::tracking
3129
{
3230

33-
enum class IndexTableConfigError : uint8_t {
34-
None,
35-
NonPositiveRowBins,
36-
NonPositiveColBins,
37-
RowColBinCountExceedsIndexRange, // Product exceeds int, the bin-index type.
38-
InvalidActiveLayerCount, // Invalid active surface count.
39-
InsufficientChartRanges, // Fewer descriptor chart ranges than active surfaces.
40-
NonFiniteChartRange, // Chart bound is NaN or +/-Inf.
41-
InvalidChartRange, // Chart maximum does not exceed its minimum.
42-
InvalidSurfaceKind, // Neither Cylinder nor Disk.
43-
};
44-
45-
/// Validates and binds detector inputs into `staged` for one coordinate kind.
31+
/// Validates detector inputs and configures `destination` for one coordinate kind.
4632
/// Resolve `kind` from the validated DetectorConfiguration, never from NLayers or DetId.
47-
/// On error, `staged` is unchanged. Call once per present kind during detector
33+
/// Returns true on success; on failure, returns false and leaves `destination` unchanged.
34+
/// Call once per present kind during detector
4835
/// initialization, outside iteration and candidate loops.
49-
IndexTableConfigError bindIndexTableConfiguration(o2::itsmft::IndexTableUtilsCore& staged,
50-
const DetectorParameters& params,
51-
int activeSurfaceCount,
52-
SurfaceKind kind,
53-
gsl::span<const SurfaceChartRange> chartRanges) noexcept;
36+
bool configureIndexTableUtils(o2::itsmft::IndexTableUtilsCore& destination,
37+
const DetectorParameters& params,
38+
int activeSurfaceCount,
39+
SurfaceKind kind,
40+
gsl::span<const SurfaceChartRange> chartRanges) noexcept;
5441

5542
/// True iff all fields stored by setIndexTableParams match between `a` and
5643
/// `b`. Used to verify that a non-FirstPass iteration matches the

‎Detectors/ITSMFT/common/tracking/src/IndexTableConfiguration.cxx‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,52 +23,52 @@ namespace o2::itsmft::tracking
2323

2424
using o2::itsmft::IndexTableCoordType;
2525

26-
IndexTableConfigError bindIndexTableConfiguration(o2::itsmft::IndexTableUtilsCore& staged,
27-
const DetectorParameters& params,
28-
int activeSurfaceCount,
29-
SurfaceKind kind,
30-
gsl::span<const SurfaceChartRange> chartRanges) noexcept
26+
bool configureIndexTableUtils(o2::itsmft::IndexTableUtilsCore& destination,
27+
const DetectorParameters& params,
28+
int activeSurfaceCount,
29+
SurfaceKind kind,
30+
gsl::span<const SurfaceChartRange> chartRanges) noexcept
3131
{
3232
if (kind != SurfaceKind::Cylinder && kind != SurfaceKind::Disk) {
33-
return IndexTableConfigError::InvalidSurfaceKind;
33+
return false;
3434
}
3535
if (!(activeSurfaceCount > 0 && activeSurfaceCount <= o2::itsmft::IndexTableUtilsCore::MaxLayers)) {
36-
return IndexTableConfigError::InvalidActiveLayerCount;
36+
return false;
3737
}
3838
if (params.RowBins <= 0) {
39-
return IndexTableConfigError::NonPositiveRowBins;
39+
return false;
4040
}
4141
if (params.ColBins <= 0) {
42-
return IndexTableConfigError::NonPositiveColBins;
42+
return false;
4343
}
4444

4545
const std::uint64_t binCount = static_cast<std::uint64_t>(params.RowBins) * static_cast<std::uint64_t>(params.ColBins);
4646
if (binCount > static_cast<std::uint64_t>(std::numeric_limits<int>::max())) {
47-
return IndexTableConfigError::RowColBinCountExceedsIndexRange;
47+
return false;
4848
}
4949

5050
if (chartRanges.size() < static_cast<std::size_t>(activeSurfaceCount)) {
51-
return IndexTableConfigError::InsufficientChartRanges;
51+
return false;
5252
}
5353
std::array<float, o2::itsmft::IndexTableUtilsCore::MaxLayers> colMin{};
5454
std::array<float, o2::itsmft::IndexTableUtilsCore::MaxLayers> colMax{};
5555
for (int iLayer = 0; iLayer < activeSurfaceCount; ++iLayer) {
5656
if (!o2::gpu::GPUCommonMath::Finite(chartRanges[iLayer].min) ||
5757
!o2::gpu::GPUCommonMath::Finite(chartRanges[iLayer].max)) {
58-
return IndexTableConfigError::NonFiniteChartRange;
58+
return false;
5959
}
6060
if (!(chartRanges[iLayer].max > chartRanges[iLayer].min)) {
61-
return IndexTableConfigError::InvalidChartRange;
61+
return false;
6262
}
6363
colMin[iLayer] = chartRanges[iLayer].min;
6464
colMax[iLayer] = chartRanges[iLayer].max;
6565
}
6666

67-
staged.setIndexTableParams(kind == SurfaceKind::Disk ? IndexTableCoordType::PhiR : IndexTableCoordType::PhiZ,
68-
params.RowBins, params.ColBins, 0.f, o2::constants::math::TwoPI,
69-
gsl::span<const float>{colMin.data(), static_cast<std::size_t>(activeSurfaceCount)},
70-
gsl::span<const float>{colMax.data(), static_cast<std::size_t>(activeSurfaceCount)});
71-
return IndexTableConfigError::None;
67+
destination.setIndexTableParams(kind == SurfaceKind::Disk ? IndexTableCoordType::PhiR : IndexTableCoordType::PhiZ,
68+
params.RowBins, params.ColBins, 0.f, o2::constants::math::TwoPI,
69+
gsl::span<const float>{colMin.data(), static_cast<std::size_t>(activeSurfaceCount)},
70+
gsl::span<const float>{colMax.data(), static_cast<std::size_t>(activeSurfaceCount)});
71+
return true;
7272
}
7373

7474
} // namespace o2::itsmft::tracking

‎Detectors/ITSMFT/common/tracking/src/Tracker.cxx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ void prepareDetectorConfiguration(DetectorConfiguration& configuration, const De
145145
const gsl::span<const SurfaceChartRange> chartRangeView{chartRanges.data(), surfaceCount};
146146
for (const auto kind : {SurfaceKind::Cylinder, SurfaceKind::Disk}) {
147147
if (configuration.indexTableConfigs.hasKind(kind) &&
148-
bindIndexTableConfiguration(configuration.indexTableConfigs.forKind(kind), parameters,
149-
static_cast<int>(surfaceCount), kind, chartRangeView) != IndexTableConfigError::None) {
148+
!configureIndexTableUtils(configuration.indexTableConfigs.forKind(kind), parameters,
149+
static_cast<int>(surfaceCount), kind, chartRangeView)) {
150150
throw std::invalid_argument{"CA traversal: invalid index table configuration"};
151151
}
152152
}

‎Detectors/ITSMFT/common/tracking/test/testMFTCATrackingConfiguration.cxx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ BOOST_AUTO_TEST_CASE(PublicMFTIndexBinsControlRadiusAndPhiLookup)
171171
std::array<SurfaceChartRange, MFTNLayers> ranges;
172172
ranges.fill({0.f, 16.f});
173173
IndexTableUtilsCore index;
174-
BOOST_REQUIRE(bindIndexTableConfiguration(index, parameters, MFTNLayers, SurfaceKind::Disk, ranges) == IndexTableConfigError::None);
174+
BOOST_REQUIRE(configureIndexTableUtils(index, parameters, MFTNLayers, SurfaceKind::Disk, ranges));
175175
BOOST_CHECK(index.getCoordType() == IndexTableCoordType::PhiR);
176176
BOOST_CHECK_EQUAL(index.getRowBinIndex(o2::constants::math::PI), 12);
177177
BOOST_CHECK_EQUAL(index.getColBinIndex(0, 8.f), 16);

0 commit comments

Comments
 (0)