Warning, file /acts/Examples/Io/HepMC3/src/HepMC3FactoryWrappers.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/HepMC3Util.hpp"
0010
0011 #include <stdexcept>
0012
0013
0014
0015 #include <HepMC3/ReaderFactory.h>
0016 #include <HepMC3/Writer.h>
0017 #include <HepMC3/WriterAscii.h>
0018
0019 #ifdef HEPMC3_USE_COMPRESSION
0020 #include <HepMC3/WriterGZ.h>
0021 #endif
0022
0023 #ifdef HEPMC3_ROOT_SUPPORT
0024 #include <HepMC3/WriterRootTree.h>
0025 #endif
0026
0027 namespace ActsExamples::HepMC3Util {
0028
0029 std::shared_ptr<HepMC3::Reader> deduceReader(const std::string& filename) {
0030 return HepMC3::deduce_reader(filename);
0031 }
0032
0033 std::unique_ptr<HepMC3::Writer> createWriter(const std::filesystem::path& path,
0034 Format format,
0035 Compression compression) {
0036 if (format == Format::root) {
0037 #ifdef HEPMC3_ROOT_SUPPORT
0038 if (compression != Compression::none) {
0039 throw std::invalid_argument("Compression not supported for ROOT format");
0040 }
0041 return std::make_unique<HepMC3::WriterRootTree>(path.string());
0042 #else
0043 throw std::runtime_error("ROOT support not enabled in HepMC3");
0044 #endif
0045 } else {
0046
0047 switch (compression) {
0048 using enum Compression;
0049 case none:
0050 return std::make_unique<HepMC3::WriterAscii>(path.string());
0051 #ifdef HEPMC3_USE_COMPRESSION
0052 case zlib:
0053 return std::make_unique<
0054 HepMC3::WriterGZ<HepMC3::WriterAscii, HepMC3::Compression::z>>(
0055 path.string());
0056 case lzma:
0057 return std::make_unique<
0058 HepMC3::WriterGZ<HepMC3::WriterAscii, HepMC3::Compression::lzma>>(
0059 path.string());
0060 case bzip2:
0061 return std::make_unique<
0062 HepMC3::WriterGZ<HepMC3::WriterAscii, HepMC3::Compression::bz2>>(
0063 path.string());
0064 case zstd:
0065 return std::make_unique<
0066 HepMC3::WriterGZ<HepMC3::WriterAscii, HepMC3::Compression::zstd>>(
0067 path.string());
0068 #endif
0069 default:
0070 throw std::invalid_argument("Unknown or unsupported compression type");
0071 }
0072 }
0073 }
0074
0075 }