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