File indexing completed on 2025-01-18 09:11:51
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/Io/Csv/CsvSpacePointsBucketWriter.hpp"
0010
0011 #include "Acts/Definitions/Units.hpp"
0012 #include "ActsExamples/EventData/SimSeed.hpp"
0013 #include "ActsExamples/EventData/SimSpacePoint.hpp"
0014 #include "ActsExamples/Io/Csv/CsvInputOutput.hpp"
0015 #include "ActsExamples/Utilities/Paths.hpp"
0016
0017 #include <cstddef>
0018 #include <ios>
0019 #include <optional>
0020 #include <stdexcept>
0021
0022 #include "CsvOutputData.hpp"
0023
0024 ActsExamples::CsvSpacePointsBucketWriter::CsvSpacePointsBucketWriter(
0025 const ActsExamples::CsvSpacePointsBucketWriter::Config& config,
0026 Acts::Logging::Level level)
0027 : WriterT(config.inputBuckets, "CsvSpacePointsBucketWriter", level),
0028 m_cfg(config) {}
0029
0030 ActsExamples::CsvSpacePointsBucketWriter::~CsvSpacePointsBucketWriter() =
0031 default;
0032
0033 ActsExamples::ProcessCode ActsExamples::CsvSpacePointsBucketWriter::finalize() {
0034
0035 return ProcessCode::SUCCESS;
0036 }
0037
0038 ActsExamples::ProcessCode ActsExamples::CsvSpacePointsBucketWriter::writeT(
0039 const AlgorithmContext& ctx,
0040 const std::vector<SimSpacePointContainer>& buckets) {
0041
0042 std::string pathBucket =
0043 perEventFilepath(m_cfg.outputDir, "buckets.csv", ctx.eventNumber);
0044
0045 ActsExamples::NamedTupleCsvWriter<SpacePointBucketData> writerBucket(
0046 pathBucket, m_cfg.outputPrecision);
0047
0048 SpacePointBucketData bucketData{};
0049
0050 int bucketIdx = 0;
0051 for (const auto& bucket : buckets) {
0052 if (bucket.empty()) {
0053 continue;
0054 }
0055
0056 auto numLines =
0057 static_cast<int>((bucket.size() / 20) +
0058 static_cast<std::size_t>(bucket.size() % 20 != 0));
0059 for (int nLines = 0; nLines < numLines; nLines++) {
0060 bucketData.bucketIdx = bucketIdx;
0061 bucketData.bucketSize = bucket.size();
0062 int maxSPIdx =
0063 std::min(20, static_cast<int>(bucket.size() - nLines * 20));
0064 for (int SPIdx = 0; SPIdx < maxSPIdx; SPIdx++) {
0065 bucketData.measurement_id[SPIdx] = (bucket[nLines * 20 + SPIdx])
0066 .sourceLinks()[0]
0067 .get<IndexSourceLink>()
0068 .index();
0069 }
0070 writerBucket.append(bucketData);
0071 }
0072 bucketIdx++;
0073 }
0074
0075 return ActsExamples::ProcessCode::SUCCESS;
0076 }