File indexing completed on 2025-01-18 09:11:52
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/Io/EDM4hep/EDM4hepTrackWriter.hpp"
0010
0011 #include "Acts/Plugins/EDM4hep/EDM4hepUtil.hpp"
0012 #include "ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp"
0013
0014 #include <stdexcept>
0015
0016 #include <edm4hep/TrackCollection.h>
0017 #include <podio/Frame.h>
0018
0019 namespace ActsExamples {
0020
0021 EDM4hepTrackWriter::EDM4hepTrackWriter(const Config& config,
0022 Acts::Logging::Level level)
0023 : WriterT<ConstTrackContainer>(config.inputTracks, "EDM4hepTrackWriter",
0024 level),
0025 m_cfg(config),
0026 m_writer(config.outputPath) {
0027 if (m_cfg.inputTracks.empty()) {
0028 throw std::invalid_argument("Missing input trajectories collection");
0029 }
0030 }
0031
0032 ActsExamples::ProcessCode EDM4hepTrackWriter::finalize() {
0033 m_writer.finish();
0034
0035 return ProcessCode::SUCCESS;
0036 }
0037
0038 ProcessCode EDM4hepTrackWriter::writeT(const AlgorithmContext& context,
0039 const ConstTrackContainer& tracks) {
0040 podio::Frame frame{};
0041
0042 edm4hep::TrackCollection trackCollection;
0043
0044 for (const auto& from : tracks) {
0045 auto to = trackCollection.create();
0046 Acts::EDM4hepUtil::writeTrack(context.geoContext, from, to, m_cfg.Bz);
0047 }
0048
0049 frame.put(std::move(trackCollection), m_cfg.outputTracks);
0050
0051 std::lock_guard guard(m_writeMutex);
0052 m_writer.writeFrame(frame, "events");
0053
0054 return ProcessCode::SUCCESS;
0055 }
0056
0057 }