File indexing completed on 2025-09-18 09:09:06
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <memory>
0010 #include <string>
0011 #include <vector>
0012
0013 #include "corecel/Config.hh"
0014
0015 #include "corecel/Assert.hh"
0016 #include "corecel/Macros.hh"
0017 #include "corecel/Types.hh"
0018
0019 #include "EventIOInterface.hh"
0020
0021 namespace HepMC3
0022 {
0023 class Reader;
0024 }
0025
0026 namespace celeritas
0027 {
0028
0029 class ParticleParams;
0030 struct Primary;
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 class EventReader : public EventReaderInterface
0043 {
0044 public:
0045
0046
0047 using SPConstParticles = std::shared_ptr<ParticleParams const>;
0048 using result_type = std::vector<Primary>;
0049
0050
0051 public:
0052
0053 EventReader(std::string const& filename, SPConstParticles particles);
0054
0055
0056 CELER_DELETE_COPY_MOVE(EventReader);
0057
0058 ~EventReader() override = default;
0059
0060
0061 result_type operator()() final;
0062
0063
0064 size_type num_events() const final { return num_events_; }
0065
0066 private:
0067 using SPReader = std::shared_ptr<HepMC3::Reader>;
0068
0069
0070 SPConstParticles particles_;
0071
0072
0073 SPReader reader_;
0074
0075
0076 size_type event_count_{0};
0077
0078
0079 size_type num_events_;
0080 };
0081
0082
0083
0084 void set_hepmc3_verbosity_from_env();
0085
0086
0087
0088 std::shared_ptr<HepMC3::Reader> open_hepmc3(std::string const& filename);
0089
0090
0091
0092
0093 #if !CELERITAS_USE_HEPMC3
0094 inline EventReader::EventReader(std::string const&, SPConstParticles)
0095 {
0096 CELER_DISCARD(particles_);
0097 CELER_DISCARD(reader_);
0098 CELER_DISCARD(event_count_);
0099 CELER_DISCARD(num_events_);
0100 CELER_NOT_CONFIGURED("HepMC3");
0101 }
0102
0103 inline auto EventReader::operator()() -> result_type
0104 {
0105 CELER_ASSERT_UNREACHABLE();
0106 }
0107
0108 inline void set_hepmc3_verbosity_from_env() {}
0109 #endif
0110
0111
0112 }