File indexing completed on 2025-09-18 09:09:16
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <vector>
0010
0011 #include "corecel/Assert.hh"
0012 #include "corecel/Macros.hh"
0013 #include "corecel/cont/EnumArray.hh"
0014 #include "corecel/data/PinnedAllocator.hh"
0015 #include "celeritas/Quantities.hh"
0016 #include "celeritas/Types.hh"
0017
0018 namespace celeritas
0019 {
0020
0021 template<Ownership W, MemSpace M>
0022 struct StepStateData;
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 struct DetectorStepPointOutput
0034 {
0035
0036
0037 using Energy = units::MevEnergy;
0038 template<class T>
0039 using PinnedVec = std::vector<T, PinnedAllocator<T>>;
0040
0041
0042
0043 PinnedVec<real_type> time;
0044 PinnedVec<Real3> pos;
0045 PinnedVec<Real3> dir;
0046 PinnedVec<Energy> energy;
0047
0048 PinnedVec<VolumeInstanceId> volume_instance_ids;
0049 };
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063 struct DetectorStepOutput
0064 {
0065
0066
0067 using Energy = units::MevEnergy;
0068 template<class T>
0069 using PinnedVec = std::vector<T, PinnedAllocator<T>>;
0070
0071
0072
0073
0074 EnumArray<StepPoint, DetectorStepPointOutput> points;
0075
0076
0077 PinnedVec<DetectorId> detector;
0078 PinnedVec<TrackId> track_id;
0079
0080
0081 PinnedVec<EventId> event_id;
0082 PinnedVec<TrackId> parent_id;
0083 PinnedVec<size_type> track_step_count;
0084 PinnedVec<real_type> step_length;
0085 PinnedVec<ParticleId> particle;
0086 PinnedVec<Energy> energy_deposition;
0087
0088
0089 size_type volume_instance_depth{0};
0090
0091
0092
0093
0094 size_type size() const { return detector.size(); }
0095
0096 explicit operator bool() const { return !detector.empty(); }
0097 };
0098
0099
0100
0101 template<MemSpace M>
0102 void copy_steps(DetectorStepOutput* output,
0103 StepStateData<Ownership::reference, M> const& state);
0104
0105 template<>
0106 void copy_steps<MemSpace::host>(
0107 DetectorStepOutput*,
0108 StepStateData<Ownership::reference, MemSpace::host> const&);
0109 template<>
0110 void copy_steps<MemSpace::device>(
0111 DetectorStepOutput*,
0112 StepStateData<Ownership::reference, MemSpace::device> const&);
0113
0114
0115 #if !CELER_USE_DEVICE
0116 template<>
0117 inline void copy_steps<MemSpace::device>(
0118 DetectorStepOutput*,
0119 StepStateData<Ownership::reference, MemSpace::device> const&)
0120 {
0121 CELER_NOT_CONFIGURED("CUDA or HIP");
0122 }
0123
0124 #endif
0125
0126 }