File indexing completed on 2026-12-01 10:05:02
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <memory>
0010 #include <optional>
0011
0012 #include "corecel/math/NumericLimits.hh"
0013 #include "celeritas/Types.hh"
0014 #include "celeritas/optical/Types.hh"
0015 #include "celeritas/phys/GeneratorCounters.hh"
0016 #include "celeritas/phys/GeneratorRegistry.hh"
0017 #include "celeritas/user/ActionTimes.hh"
0018
0019 #include "CoreParams.hh"
0020 #include "Model.hh"
0021 #include "gen/OffloadData.hh"
0022
0023 namespace celeritas
0024 {
0025
0026 class ActionRegistry;
0027 class AuxStateVec;
0028 class CherenkovParams;
0029 class CoreStateInterface;
0030 class CoreParams;
0031 template<GeneratorType G>
0032 class OffloadAction;
0033 template<StepActionOrder S>
0034 class OffloadGatherAction;
0035 class ScintillationParams;
0036
0037 namespace optical
0038 {
0039 class CoreStateBase;
0040 class GeneratorAction;
0041 }
0042
0043 namespace detail
0044 {
0045 class OpticalLaunchAction;
0046 }
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068 class OpticalCollector
0069 {
0070 public:
0071
0072
0073 using OpticalBufferSize = GeneratorCounters<size_type>;
0074 using SPConstOpticalParams = std::shared_ptr<optical::CoreParams const>;
0075 using MapStrDbl = ActionTimes::MapStrDbl;
0076
0077
0078 struct Input
0079 {
0080
0081 std::shared_ptr<optical::CoreParams> optical_params;
0082
0083
0084 size_type num_track_slots{};
0085
0086
0087 size_type buffer_capacity{};
0088
0089
0090 size_type auto_flush{};
0091
0092
0093 bool action_times{false};
0094
0095
0096 explicit operator bool() const
0097 {
0098 return optical_params
0099 && (optical_params->scintillation()
0100 || optical_params->cherenkov())
0101 && num_track_slots > 0 && buffer_capacity > 0
0102 && auto_flush > 0;
0103 }
0104 };
0105
0106 public:
0107
0108 OpticalCollector(CoreParams const&, Input&&);
0109
0110
0111
0112
0113 SPConstOpticalParams const& optical_params() const
0114 {
0115 return optical_params_;
0116 }
0117
0118
0119 optical::CoreStateBase const& optical_state(
0120 CoreStateInterface const& core) const;
0121
0122
0123
0124
0125 GeneratorRegistry const& gen_reg() const;
0126
0127
0128 CounterAccumStats exchange_counters(AuxStateVec& aux) const;
0129
0130
0131 OpticalBufferSize buffer_counts(AuxStateVec const& aux) const;
0132
0133
0134 MapStrDbl get_action_times(AuxStateVec const&) const;
0135
0136 private:
0137
0138
0139 using GT = GeneratorType;
0140 using SPCherenkovOffload = std::shared_ptr<OffloadAction<GT::cherenkov>>;
0141 using SPScintOffload = std::shared_ptr<OffloadAction<GT::scintillation>>;
0142 using SPPreGatherAction
0143 = std::shared_ptr<OffloadGatherAction<StepActionOrder::pre>>;
0144 using SPPrePostGatherAction
0145 = std::shared_ptr<OffloadGatherAction<StepActionOrder::pre_post>>;
0146 using SPGenerator = std::shared_ptr<optical::GeneratorAction>;
0147 using SPLaunchAction = std::shared_ptr<detail::OpticalLaunchAction>;
0148 using SPActionTimes = std::shared_ptr<ActionTimes>;
0149
0150
0151
0152 SPConstOpticalParams optical_params_;
0153 SPPreGatherAction pre_gather_;
0154 SPPrePostGatherAction pre_post_gather_;
0155 SPCherenkovOffload cherenkov_offload_;
0156 SPScintOffload scint_offload_;
0157 SPGenerator generate_;
0158 SPLaunchAction launch_;
0159 SPActionTimes action_times_;
0160 };
0161
0162
0163 }