Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-14 08:01:08

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include "ActsExamples/Io/Csv/CsvVertexWriter.hpp"
0010 
0011 #include "ActsExamples/Framework/AlgorithmContext.hpp"
0012 #include "ActsExamples/Io/Csv/CsvInputOutput.hpp"
0013 #include "ActsExamples/Utilities/Paths.hpp"
0014 #include "ActsFatras/EventData/Barcode.hpp"
0015 #include <Acts/Definitions/Units.hpp>
0016 
0017 #include <stdexcept>
0018 
0019 #include "CsvOutputData.hpp"
0020 
0021 ActsExamples::CsvVertexWriter::CsvVertexWriter(
0022     const ActsExamples::CsvVertexWriter::Config& cfg, Acts::Logging::Level lvl)
0023     : WriterT(cfg.inputVertices, "CsvVertexWriter", lvl), m_cfg(cfg) {
0024   // inputVertices is already checked by base constructor
0025   if (m_cfg.outputStem.empty()) {
0026     throw std::invalid_argument("Missing output filename stem");
0027   }
0028 }
0029 
0030 ActsExamples::ProcessCode ActsExamples::CsvVertexWriter::writeT(
0031     const ActsExamples::AlgorithmContext& ctx,
0032     const SimVertexContainerV& vertices) {
0033   auto pathVertices = perEventFilepath(
0034       m_cfg.outputDir, m_cfg.outputStem + ".csv", ctx.eventNumber);
0035   ActsExamples::NamedTupleCsvWriter<VertexData> writer(pathVertices,
0036                                                        m_cfg.outputPrecision);
0037 
0038   // Iterate over the vertices, and write out the 4 positions
0039   VertexData data;
0040   for (const auto& vertex : vertices) {
0041     data.x = vertex.fullPosition()[Acts::CoordinateIndices::eX];
0042     data.y = vertex.fullPosition()[Acts::CoordinateIndices::eY];
0043     data.z = vertex.fullPosition()[Acts::CoordinateIndices::eZ];
0044     data.T = vertex.fullPosition()[Acts::CoordinateIndices::eTime];
0045 
0046     writer.append(data);
0047   }
0048 
0049   return ProcessCode::SUCCESS;
0050 }