File indexing completed on 2026-07-16 08:08:12
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/Io/Csv/CsvGnnGraphReader.hpp"
0010
0011 #include "Acts/Utilities/Logger.hpp"
0012 #include "ActsExamples/EventData/SimParticle.hpp"
0013 #include "ActsExamples/Framework/AlgorithmContext.hpp"
0014 #include "ActsExamples/Io/Csv/CsvInputOutput.hpp"
0015 #include "ActsExamples/Utilities/Paths.hpp"
0016 #include <ActsExamples/Utilities/Paths.hpp>
0017
0018 #include <stdexcept>
0019 #include <string>
0020
0021 #include "CsvOutputData.hpp"
0022
0023 namespace ActsExamples {
0024
0025 CsvGnnGraphReader::CsvGnnGraphReader(const Config& config,
0026 Acts::Logging::Level level)
0027 : m_cfg(config),
0028 m_eventsRange(
0029 determineEventFilesRange(m_cfg.inputDir, m_cfg.inputStem + ".csv")),
0030 m_logger(Acts::getDefaultLogger("CsvGnnGraphReader", level)) {
0031 if (m_cfg.inputStem.empty()) {
0032 throw std::invalid_argument("Missing input filename stem");
0033 }
0034
0035 m_outputGraph.initialize(m_cfg.outputGraph);
0036 }
0037
0038 std::pair<std::size_t, std::size_t> CsvGnnGraphReader::availableEvents() const {
0039 return m_eventsRange;
0040 }
0041
0042 ProcessCode CsvGnnGraphReader::read(const AlgorithmContext& ctx) {
0043 SimParticleContainer::sequence_type unordered;
0044
0045 auto path = perEventFilepath(m_cfg.inputDir, m_cfg.inputStem + ".csv",
0046 ctx.eventNumber);
0047
0048 NamedTupleCsvReader<GraphData> reader(path, {"vt", "m"});
0049 GraphData data;
0050
0051 Graph g;
0052
0053 while (reader.read(data)) {
0054 g.edges.push_back(data.edge0);
0055 g.edges.push_back(data.edge1);
0056 g.weights.push_back(data.weight);
0057 }
0058
0059 m_outputGraph(ctx, std::move(g));
0060
0061 return ProcessCode::SUCCESS;
0062 }
0063
0064 }