File indexing completed on 2026-11-09 10:15:02
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "corecel/Assert.hh"
0010 #include "corecel/Macros.hh"
0011 #include "corecel/math/Algorithms.hh"
0012 #include "corecel/math/Atomics.hh"
0013 #include "celeritas/optical/CoreTrackView.hh"
0014 #include "celeritas/user/ParticleTallyData.hh"
0015
0016 namespace celeritas
0017 {
0018 namespace optical
0019 {
0020 namespace detail
0021 {
0022
0023 struct StepDiagnosticExecutor
0024 {
0025 NativeCRef<ParticleTallyParamsData> const params;
0026 NativeRef<ParticleTallyStateData> const state;
0027
0028 inline CELER_FUNCTION void operator()(CoreTrackView const& track);
0029 };
0030
0031
0032
0033
0034
0035 CELER_FUNCTION void StepDiagnosticExecutor::operator()(
0036 CoreTrackView const& track)
0037 {
0038 CELER_EXPECT(params);
0039 CELER_EXPECT(state);
0040
0041
0042 auto sim = track.sim();
0043 if (sim.status() == TrackStatus::killed)
0044 {
0045 size_type index = celeritas::min(sim.num_steps(), params.num_bins - 1);
0046 using namespace celeritas::literals;
0047 atomic_add(&state.counts[ItemId<size_type>(index)], 1_sz);
0048 }
0049 }
0050
0051
0052 }
0053 }
0054 }