Warning, file /acts/Examples/Io/HepMC3/src/HepMC3Writer.cpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/Io/HepMC3/HepMC3Writer.hpp"
0010
0011 #include "ActsExamples/Utilities/Paths.hpp"
0012
0013 namespace ActsExamples {
0014
0015 HepMC3AsciiWriter::HepMC3AsciiWriter(const Config& config,
0016 Acts::Logging::Level level)
0017 : WriterT(config.inputEvents, "HepMC3AsciiWriter", level), m_cfg(config) {
0018 if (m_cfg.outputStem.empty()) {
0019 throw std::invalid_argument("Missing output stem file name");
0020 }
0021 }
0022
0023 ProcessCode HepMC3AsciiWriter::writeT(
0024 const AlgorithmContext& ctx, const std::vector<HepMC3::GenEvent>& events) {
0025 auto path = perEventFilepath(m_cfg.outputDir, m_cfg.outputStem + ".hepmc3",
0026 ctx.eventNumber);
0027
0028 ACTS_DEBUG("Attempting to write event to " << path);
0029 HepMC3::WriterAscii writer(path);
0030
0031 for (const auto& event : events) {
0032 writer.write_event(event);
0033 if (writer.failed()) {
0034 return ProcessCode::ABORT;
0035 }
0036 }
0037
0038 writer.close();
0039 return ProcessCode::SUCCESS;
0040 }
0041
0042 }