File indexing completed on 2025-02-22 10:31:24
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include <memory>
0011 #include <string>
0012
0013 #include "corecel/Config.hh"
0014
0015 #include "corecel/Assert.hh"
0016 #include "corecel/Macros.hh"
0017 #include "celeritas/Types.hh"
0018
0019 #include "EventIOInterface.hh"
0020
0021 namespace HepMC3
0022 {
0023 class Writer;
0024 }
0025
0026 namespace celeritas
0027 {
0028
0029 class ParticleParams;
0030
0031
0032
0033
0034
0035 class EventWriter : public EventWriterInterface
0036 {
0037 public:
0038
0039
0040 using SPConstParticles = std::shared_ptr<ParticleParams const>;
0041
0042
0043
0044 enum class Format
0045 {
0046 hepevt,
0047 hepmc2,
0048 hepmc3,
0049 size_
0050 };
0051
0052 public:
0053
0054 EventWriter(std::string const& filename, SPConstParticles params);
0055
0056
0057 EventWriter(std::string const& filename,
0058 SPConstParticles params,
0059 Format fmt);
0060
0061
0062 CELER_DELETE_COPY_MOVE(EventWriter);
0063
0064
0065 void operator()(VecPrimary const& primaries) final;
0066
0067 private:
0068
0069 SPConstParticles particles_;
0070
0071 Format fmt_;
0072
0073
0074 std::shared_ptr<HepMC3::Writer> writer_;
0075
0076
0077 EventId::size_type event_count_{0};
0078 };
0079
0080
0081
0082
0083 char const* to_cstring(EventWriter::Format);
0084
0085
0086
0087
0088 #if !CELERITAS_USE_HEPMC3
0089 inline EventWriter::EventWriter(std::string const& s, SPConstParticles p)
0090 : EventWriter{s, p, Format::size_}
0091 {
0092 }
0093 inline EventWriter::EventWriter(std::string const&, SPConstParticles, Format)
0094 {
0095 CELER_DISCARD(particles_);
0096 CELER_DISCARD(fmt_);
0097 CELER_DISCARD(writer_);
0098 CELER_DISCARD(event_count_);
0099 CELER_NOT_CONFIGURED("HepMC3");
0100 }
0101
0102 inline void EventWriter::operator()(argument_type)
0103 {
0104 CELER_ASSERT_UNREACHABLE();
0105 }
0106 #endif
0107
0108
0109 }