Skip to content

Commit 42b4d4e

Browse files
committed
Remove operation result/failure metadata structs
1 parent 7d166bf commit 42b4d4e

22 files changed

Lines changed: 793 additions & 1143 deletions

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

Lines changed: 11 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
#ifndef ALICEO2_ITSMFT_TRACKING_MATERIALPHYSICS_H_
1313
#define ALICEO2_ITSMFT_TRACKING_MATERIALPHYSICS_H_
1414

15-
#include <cstddef>
1615
#include <cstdint>
17-
#include <type_traits>
1816

1917
#include "ReconstructionDataFormats/PID.h"
2018

@@ -38,71 +36,6 @@ struct IntegratedMaterialBudget {
3836
float arealDensityGPerCm2; ///< crossed length*density, g/cm^2
3937
};
4038

41-
// Reasons a scalar material-physics operation can fail. SourceSurfaceKindMismatch,
42-
// NonFiniteState, InvalidStateKinematics, and InvalidCovariance are reserved
43-
// for future full-state operations and are never emitted by
44-
// calculateMaterialPhysics().
45-
enum class MaterialFailureReason : uint8_t {
46-
None = 0,
47-
SourceSurfaceKindMismatch = 1,
48-
NonFiniteState = 2,
49-
InvalidStateKinematics = 3,
50-
InvalidPID = 4,
51-
ChargedMasslessPID = 5,
52-
InvalidDirection = 6,
53-
InvalidMaterial = 7,
54-
StoppedInMaterial = 8,
55-
MomentumBelowMinimum = 9,
56-
ExcessiveScattering = 10,
57-
InvalidCovariance = 11,
58-
NonFiniteResult = 12
59-
};
60-
61-
enum class MaterialOperationFlags : uint8_t {
62-
None = 0,
63-
SubstepCountClamped = 1
64-
};
65-
66-
// Result of one scalar material-physics evaluation. On failure,
67-
// momentumBeforeGeV echoes the input, failure gives the reason, and all other
68-
// fields are deterministic zero/None values with no physical meaning.
69-
// reserved is always zero.
70-
struct MaterialOperationResult {
71-
float momentumBeforeGeV;
72-
float momentumAfterGeV;
73-
float signedEnergyChangeGeV;
74-
float highlandTheta2Rad2;
75-
float relativeInverseMomentumVariance;
76-
uint8_t energyLossSubsteps;
77-
MaterialOperationFlags flags;
78-
MaterialFailureReason failure;
79-
uint8_t reserved;
80-
81-
bool ok() const noexcept { return failure == MaterialFailureReason::None; }
82-
};
83-
84-
// Lock the current in-memory layout; this is not a serialized or device ABI.
85-
#define O2_ITSMFT_MATERIAL_ASSERT_LAYOUT(Type, Size, Alignment) \
86-
static_assert(std::is_standard_layout_v<Type>); \
87-
static_assert(std::is_trivially_copyable_v<Type>); \
88-
static_assert(sizeof(Type) == Size); \
89-
static_assert(alignof(Type) == Alignment)
90-
91-
O2_ITSMFT_MATERIAL_ASSERT_LAYOUT(IntegratedMaterialBudget, 8, 4);
92-
O2_ITSMFT_MATERIAL_ASSERT_LAYOUT(MaterialOperationResult, 24, 4);
93-
94-
#undef O2_ITSMFT_MATERIAL_ASSERT_LAYOUT
95-
96-
static_assert(offsetof(MaterialOperationResult, momentumBeforeGeV) == 0);
97-
static_assert(offsetof(MaterialOperationResult, momentumAfterGeV) == 4);
98-
static_assert(offsetof(MaterialOperationResult, signedEnergyChangeGeV) == 8);
99-
static_assert(offsetof(MaterialOperationResult, highlandTheta2Rad2) == 12);
100-
static_assert(offsetof(MaterialOperationResult, relativeInverseMomentumVariance) == 16);
101-
static_assert(offsetof(MaterialOperationResult, energyLossSubsteps) == 20);
102-
static_assert(offsetof(MaterialOperationResult, flags) == 21);
103-
static_assert(offsetof(MaterialOperationResult, failure) == 22);
104-
static_assert(offsetof(MaterialOperationResult, reserved) == 23);
105-
10639
// Detector-neutral, PID/absCharge-aware scalar material-physics kernel.
10740
// pid supplies the mass; absCharge supplies |q| for energy-loss and
10841
// scattering scale factors. It need not equal PID::getCharge(). For
@@ -114,7 +47,7 @@ static_assert(offsetof(MaterialOperationResult, reserved) == 23);
11447
// The PID range is checked before accessing its mass.
11548
//
11649
// For charged massive states, non-positive beta^2 is rejected before either
117-
// material-effect calculation. Failure gives NonFiniteResult.
50+
// material-effect calculation.
11851
//
11952
// For charged massive states, momentumGeV is the caller-selected physical
12053
// momentum; no covariance projection is performed. Energy loss uses the same
@@ -123,29 +56,30 @@ static_assert(offsetof(MaterialOperationResult, reserved) == 23);
12356
// requested substep count is
12457
// 1 + floor(|dE_full| / eKin * o2::track::ELoss2EKinThreshInv)
12558
// with a range-bounded float-to-int conversion, capped at
126-
// o2::track::MaxELossIter (50). flags marks SubstepCountClamped when the
127-
// request exceeds 50. All arealDensityGPerCm2 is processed; only the
59+
// o2::track::MaxELossIter (50). All arealDensityGPerCm2 is processed; only the
12860
// granularity changes. Bethe-Bloch is recomputed from the current momentum
12961
// at each substep.
13062
// MaterialTraversalDirection::AlongMomentum subtracts energy per substep;
131-
// OppositeMomentum adds it; signedEnergyChangeGeV is always
132-
// Eafter - Ebefore. A particle whose energy would fall to or below its rest
133-
// mass fails with StoppedInMaterial; a particle that completes with
134-
// momentum below 0.01 GeV/c fails with MomentumBelowMinimum.
63+
// OppositeMomentum adds it. Reject particles stopped in material or ending
64+
// with momentum below 0.01 GeV/c.
13565
//
13666
// highlandTheta2Rad2 and relativeInverseMomentumVariance use the simplified
13767
// O2 Highland variance (no logarithmic correction) and pre-material momentum,
13868
// energy, and beta. Both scale with absCharge^2. highlandTheta2Rad2 > pi^2
139-
// fails with ExcessiveScattering.
69+
// is rejected.
14070
//
14171
// This kernel does not construct track states, detector geometry, or
14272
// ITS/MFT/topology/propagation objects.
143-
MaterialOperationResult calculateMaterialPhysics(
73+
// Output values are committed only on success.
74+
bool calculateMaterialPhysics(
14475
float momentumGeV,
14576
o2::track::PID pid,
14677
uint8_t absCharge,
14778
MaterialTraversalDirection direction,
148-
IntegratedMaterialBudget material) noexcept;
79+
IntegratedMaterialBudget material,
80+
float& momentumAfterGeV,
81+
float& highlandTheta2Rad2,
82+
float& relativeInverseMomentumVariance) noexcept;
14983

15084
} // namespace o2::itsmft::tracking::material
15185

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "ITSMFTTracking/SurfaceDescriptor.h"
2121
#include "ITSMFTTracking/SurfaceTrackState.h"
2222
#include "ITSMFTTracking/SurfaceMeasurement.h"
23-
#include "ITSMFTTracking/SurfaceStateOperationResult.h"
2423

2524
// Descriptor-driven propagation using the material and kind resolved from
2625
// SurfaceDescriptor and SurfaceCatalogView.
@@ -36,23 +35,20 @@ class Propagator
3635
static bool attachMeasurement(SurfaceTrackState& state, const SurfaceDescriptor& targetSurface,
3736
const SurfaceMeasurement& measurement, float bz,
3837
material::MaterialTraversalDirection direction,
39-
bool chi2GateEnabled, float maxChi2, float& chi2,
40-
OperationFailureReason& reason) noexcept;
38+
bool chi2GateEnabled, float maxChi2, float& chi2) noexcept;
4139

4240
// Compatibility chi2 for two states in the same surface convention. The
4341
// coordinate convention is selected from the states, never by the caller.
4442
static bool stateChi2(const SurfaceTrackState& reference, const SurfaceTrackState& candidate,
45-
float& chi2, OperationFailureReason& reason) noexcept;
43+
float& chi2) noexcept;
4644

4745
// Propagate in the state’s current surface convention to its target
4846
// reference coordinate. Disk transport uses helix propagation for
4947
// |bz| > 0.01f and linear transport otherwise. Both objects are unchanged
5048
// on failure when a linearization reference is supplied.
51-
static bool propagateToReference(SurfaceTrackState& state, float targetReferenceCoordinate, float bz,
52-
OperationFailureReason& reason) noexcept;
49+
static bool propagateToReference(SurfaceTrackState& state, float targetReferenceCoordinate, float bz) noexcept;
5350
static bool propagateToReference(SurfaceTrackState& state, SurfaceTrackParameters& linRef,
54-
float targetReferenceCoordinate, float bz,
55-
OperationFailureReason& reason) noexcept;
51+
float targetReferenceCoordinate, float bz) noexcept;
5652

5753
// Re-express the state on the fixed target plane through its nominal point:
5854
// fixed z for Disk, fixed local x and radial alpha for Cylinder. Transport
@@ -62,8 +58,7 @@ class Propagator
6258
// Preserves absCharge, PID, and all fields outside the parameter convention.
6359
// Rejects tangent/unsupported directions and non-finite conversions without
6460
// changing the state. Cylinder targets require an outward radial direction.
65-
static bool convertKind(SurfaceTrackState& state, SurfaceKind targetKind, float bz,
66-
OperationFailureReason& reason) noexcept;
61+
static bool convertKind(SurfaceTrackState& state, SurfaceKind targetKind, float bz) noexcept;
6762

6863
// Propagate to a measurement, converting the state to the target surface
6964
// kind when needed, then applying material, the chi2 gate, and the update.
@@ -75,7 +70,7 @@ class Propagator
7570
const SurfaceDescriptor& targetSurface, const SurfaceMeasurement& targetMeasurement,
7671
float bz, material::MaterialTraversalDirection direction,
7772
bool chi2GateEnabled, float maxChi2, float& chi2,
78-
bool shiftReferenceToMeasurement, OperationFailureReason& reason) noexcept;
73+
bool shiftReferenceToMeasurement) noexcept;
7974
};
8075

8176
} // namespace o2::itsmft::tracking

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

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "ITSMFTTracking/TimeFrame.h"
2828
#include "ITSMFTTracking/Propagator.h"
2929
#include "ITSMFTTracking/SurfaceDescriptor.h"
30-
#include "ITSMFTTracking/SurfaceStateOperationResult.h"
3130
#include "ReconstructionDataFormats/TrackParametrization.h"
3231

3332
// Descriptor-driven refit built on Propagator operations.
@@ -82,10 +81,9 @@ inline bool driveRefitLeg(SurfaceTrackState& state, SurfaceTrackParameters& linR
8281
float& chi2, uint32_t& acceptedHitCount,
8382
gsl::span<const RefitMeasurementSlot> orderedSlots, SurfaceCatalogView surfaceCatalog,
8483
float bz, material::MaterialTraversalDirection direction,
85-
bool shiftReferenceToMeasurement, float maxChi2, OperationFailureReason& reason) noexcept
84+
bool shiftReferenceToMeasurement, float maxChi2) noexcept
8685
{
8786
if (chi2 < 0.f) {
88-
reason = OperationFailureReason::PredictedChi2Failure;
8987
return false;
9088
}
9189

@@ -100,13 +98,12 @@ inline bool driveRefitLeg(SurfaceTrackState& state, SurfaceTrackParameters& linR
10098
}
10199
if (!slot.surface.isValid() || !(surfaceCatalog.nSurfaces == 0 || surfaceCatalog.surfaces != nullptr) ||
102100
!(slot.surface.value() < surfaceCatalog.nSurfaces)) {
103-
reason = OperationFailureReason::InvalidSurfaceCatalogAssociation;
104101
return false;
105102
}
106103
const SurfaceDescriptor& descriptor = surfaceCatalog.getSurface(slot.surface);
107104
if (!Propagator::propagateToMeasurement(scratchState, scratchLinRef, descriptor, slot.measurement, bz, direction,
108105
scratchAcceptedHitCount >= kChi2GateMinAcceptedHits, maxChi2, scratchChi2,
109-
shiftReferenceToMeasurement, reason)) {
106+
shiftReferenceToMeasurement)) {
110107
return false;
111108
}
112109
++scratchAcceptedHitCount;
@@ -171,11 +168,9 @@ inline bool fitTrackSeedLegs(
171168
gsl::span<const float> minPt,
172169
SurfaceTrackState& outParamIn,
173170
SurfaceTrackState& outParamOut,
174-
float& outChi2,
175-
OperationFailureReason& reason) noexcept
171+
float& outChi2) noexcept
176172
{
177173
if (layerGlobals.empty() || layerGlobals.size() > MaxLayoutSurfaces) {
178-
reason = OperationFailureReason::InvalidSurfaceCatalogAssociation;
179174
return false;
180175
}
181176
// Legs run sequentially; reuse bounded storage without allocating inside
@@ -200,16 +195,14 @@ inline bool fitTrackSeedLegs(
200195
bool validSlots = false;
201196
const auto slotsA = detail::assembleRefitLegSlots(seed, frame, layerGlobals, 0, activeSurfaceCount, 1, activeSlots, validSlots);
202197
if (!validSlots) {
203-
reason = OperationFailureReason::InvalidSurfaceCatalogAssociation;
204198
return false;
205199
}
206200
if (!detail::driveRefitLeg(stateA, linRefA, chi2A, acceptedA, slotsA, surfaceCatalog, bz,
207201
material::MaterialTraversalDirection::AlongMomentum, shiftReferenceToMeasurement,
208-
maxChi2ClusterAttachment, reason)) {
202+
maxChi2ClusterAttachment)) {
209203
return false;
210204
}
211205
if (!legAcceptable(stateA, chi2A, acceptedA, o2::constants::math::VeryBig, maxChi2NDF)) {
212-
reason = OperationFailureReason::LegAcceptanceFailure;
213206
return false;
214207
}
215208

@@ -221,16 +214,14 @@ inline bool fitTrackSeedLegs(
221214
uint32_t acceptedB = 0;
222215
const auto slotsB = detail::assembleRefitLegSlots(seed, frame, layerGlobals, activeSurfaceCount - 1, -1, -1, activeSlots, validSlots);
223216
if (!validSlots) {
224-
reason = OperationFailureReason::InvalidSurfaceCatalogAssociation;
225217
return false;
226218
}
227219
if (!detail::driveRefitLeg(stateB, linRefB, chi2B, acceptedB, slotsB, surfaceCatalog, bz,
228220
material::MaterialTraversalDirection::OppositeMomentum, shiftReferenceToMeasurement,
229-
maxChi2ClusterAttachment, reason)) {
221+
maxChi2ClusterAttachment)) {
230222
return false;
231223
}
232224
if (!legAcceptable(stateB, chi2B, acceptedB, 50.f, maxChi2NDF)) {
233-
reason = OperationFailureReason::LegAcceptanceFailure;
234225
return false;
235226
}
236227

@@ -240,7 +231,6 @@ inline bool fitTrackSeedLegs(
240231
if (minPtSlot >= 0 && minPtSlot < static_cast<int>(minPt.size())) {
241232
const float minPtThreshold = minPt[minPtSlot];
242233
if (minPtThreshold > 0.f && ptFromQOverPt(stateB.parameters[4], stateB.absCharge) < minPtThreshold) {
243-
reason = OperationFailureReason::MinPtFailure;
244234
return false;
245235
}
246236
}
@@ -255,16 +245,14 @@ inline bool fitTrackSeedLegs(
255245
uint32_t acceptedC = 0;
256246
const auto slotsC = detail::assembleRefitLegSlots(seed, frame, layerGlobals, 0, activeSurfaceCount, 1, activeSlots, validSlots);
257247
if (!validSlots) {
258-
reason = OperationFailureReason::InvalidSurfaceCatalogAssociation;
259248
return false;
260249
}
261250
if (!detail::driveRefitLeg(stateC, linRefC, chi2C, acceptedC, slotsC, surfaceCatalog, bz,
262251
material::MaterialTraversalDirection::AlongMomentum, shiftReferenceToMeasurement,
263-
maxChi2ClusterAttachment, reason)) {
252+
maxChi2ClusterAttachment)) {
264253
return false;
265254
}
266255
if (!legAcceptable(stateC, chi2C, acceptedC, o2::constants::math::VeryBig, maxChi2NDF)) {
267-
reason = OperationFailureReason::LegAcceptanceFailure;
268256
return false;
269257
}
270258
stateOut = stateC;

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

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)