Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:51

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/CsvSpacePointWriter.hpp"
0010 
0011 #include "Acts/EventData/SourceLink.hpp"
0012 #include "Acts/Geometry/GeometryIdentifier.hpp"
0013 #include "Acts/Utilities/Logger.hpp"
0014 #include "ActsExamples/EventData/IndexSourceLink.hpp"
0015 #include "ActsExamples/EventData/SimSpacePoint.hpp"
0016 #include "ActsExamples/Framework/AlgorithmContext.hpp"
0017 #include "ActsExamples/Framework/ProcessCode.hpp"
0018 #include "ActsExamples/Framework/WriterT.hpp"
0019 #include "ActsExamples/Io/Csv/CsvInputOutput.hpp"
0020 #include "ActsExamples/Utilities/Paths.hpp"
0021 
0022 #include <string>
0023 #include <vector>
0024 
0025 #include "CsvOutputData.hpp"
0026 
0027 ActsExamples::CsvSpacePointWriter::CsvSpacePointWriter(
0028     const ActsExamples::CsvSpacePointWriter::Config& config,
0029     Acts::Logging::Level level)
0030     : WriterT(config.inputSpacepoints, "CsvSpacePointWriter", level),
0031       m_cfg(config) {}
0032 
0033 ActsExamples::CsvSpacePointWriter::~CsvSpacePointWriter() = default;
0034 
0035 ActsExamples::ProcessCode ActsExamples::CsvSpacePointWriter::finalize() {
0036   // Write the tree
0037   return ProcessCode::SUCCESS;
0038 }
0039 
0040 ActsExamples::ProcessCode ActsExamples::CsvSpacePointWriter::writeT(
0041     const AlgorithmContext& ctx, const SimSpacePointContainer& spacepoints) {
0042   // Open per-event file for all components
0043   std::string pathSP =
0044       perEventFilepath(m_cfg.outputDir, "spacepoint.csv", ctx.eventNumber);
0045 
0046   ActsExamples::NamedTupleCsvWriter<SpacepointData> writerSP(
0047       pathSP, m_cfg.outputPrecision);
0048 
0049   SpacepointData spData{};
0050   for (const auto& sp : spacepoints) {
0051     const auto slink = sp.sourceLinks()[0].get<IndexSourceLink>();
0052 
0053     spData.measurement_id = slink.index();
0054     spData.geometry_id = slink.geometryId().value();
0055     spData.x = sp.x();
0056     spData.y = sp.y();
0057     spData.z = sp.z();
0058     spData.var_r = sp.varianceR();
0059     spData.var_z = sp.varianceZ();
0060     writerSP.append(spData);
0061   }
0062   return ActsExamples::ProcessCode::SUCCESS;
0063 }