File indexing completed on 2025-12-15 10:11:02
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <memory>
0010 #include <random>
0011
0012 #include "celeritas/io/EventIOInterface.hh"
0013 #include "celeritas/io/RootEventReader.hh"
0014
0015 namespace celeritas
0016 {
0017
0018
0019
0020
0021 class RootEventSampler : public EventReaderInterface
0022 {
0023 public:
0024
0025
0026 using SPConstParticles = std::shared_ptr<ParticleParams const>;
0027 using UPRootEventReader = std::unique_ptr<RootEventReader>;
0028 using result_type = std::vector<Primary>;
0029
0030
0031 public:
0032
0033 RootEventSampler(std::string const& filename,
0034 SPConstParticles particles,
0035 size_type num_sampled_events,
0036 size_type num_merged_events,
0037 unsigned int seed);
0038
0039
0040 result_type operator()() final;
0041
0042
0043 size_type num_events() const final { return num_sampled_events_; }
0044
0045 private:
0046 size_type num_sampled_events_;
0047 size_type num_merged_events_;
0048 UPRootEventReader reader_;
0049 std::mt19937 rng_;
0050 std::uniform_int_distribution<size_type> select_event_;
0051 EventId event_count_{0};
0052 };
0053
0054
0055 #if !CELERITAS_USE_ROOT
0056 inline RootEventSampler::RootEventSampler(
0057 std::string const&, SPConstParticles, size_type, size_type, unsigned int)
0058 {
0059 CELER_DISCARD(num_sampled_events_);
0060 CELER_DISCARD(num_merged_events_);
0061 CELER_DISCARD(reader_);
0062 CELER_DISCARD(rng_);
0063 CELER_DISCARD(select_event_);
0064 CELER_DISCARD(event_count_);
0065 CELER_NOT_CONFIGURED("ROOT");
0066 }
0067
0068 inline RootEventSampler::result_type RootEventSampler::operator()()
0069 {
0070 CELER_ASSERT_UNREACHABLE();
0071 }
0072 #endif
0073
0074
0075 }