Warning, file /include/celeritas/user/detail/SimpleCaloExecutor.hh was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <type_traits>
0010
0011 #include "corecel/Types.hh"
0012 #include "corecel/math/Atomics.hh"
0013
0014 #include "../SimpleCaloData.hh"
0015 #include "../StepData.hh"
0016
0017 namespace celeritas
0018 {
0019 namespace detail
0020 {
0021
0022
0023
0024
0025
0026
0027
0028
0029 struct SimpleCaloExecutor
0030 {
0031 NativeRef<StepStateData> const step;
0032 NativeRef<SimpleCaloStateData> calo;
0033
0034 inline CELER_FUNCTION void operator()(TrackSlotId tid);
0035 CELER_FORCEINLINE_FUNCTION void operator()(ThreadId tid)
0036 {
0037 return (*this)(TrackSlotId{tid.unchecked_get()});
0038 }
0039 };
0040
0041
0042
0043
0044
0045
0046
0047 CELER_FUNCTION void SimpleCaloExecutor::operator()(TrackSlotId tid)
0048 {
0049 CELER_EXPECT(tid < step.data.detector.size());
0050 CELER_EXPECT(!step.data.energy_deposition.empty());
0051
0052 DetectorId det = step.data.detector[tid];
0053 if (!det)
0054 {
0055
0056 return;
0057 }
0058
0059 static_assert(
0060 std::is_same_v<NativeRef<StepStateDataImpl>::Energy::unit_type,
0061 NativeRef<SimpleCaloStateData>::EnergyUnits>);
0062 real_type edep = step.data.energy_deposition[tid].value();
0063 CELER_ASSERT(edep > 0);
0064 CELER_ASSERT(det < calo.energy_deposition.size());
0065 atomic_add(&calo.energy_deposition[det], edep);
0066 }
0067
0068
0069 }
0070 }