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