Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-03-30 07:46:17

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/CsvProtoTrackWriter.hpp"
0010 
0011 #include "ActsExamples/EventData/Index.hpp"
0012 #include "ActsExamples/Io/Csv/CsvInputOutput.hpp"
0013 #include "ActsExamples/Utilities/EventDataTransforms.hpp"
0014 #include "ActsExamples/Utilities/Paths.hpp"
0015 
0016 #include "CsvOutputData.hpp"
0017 
0018 namespace ActsExamples {
0019 
0020 CsvProtoTrackWriter::CsvProtoTrackWriter(const Config& config,
0021                                          Acts::Logging::Level level)
0022     : WriterT(config.inputProtoTracks, "CsvProtoTrackWriter", level),
0023       m_cfg(config) {
0024   m_inputSpacePoints.initialize(m_cfg.inputSpacePoints);
0025 }
0026 
0027 CsvProtoTrackWriter::~CsvProtoTrackWriter() = default;
0028 
0029 ProcessCode CsvProtoTrackWriter::finalize() {
0030   // Write the tree
0031   return ProcessCode::SUCCESS;
0032 }
0033 
0034 ProcessCode CsvProtoTrackWriter::writeT(const AlgorithmContext& ctx,
0035                                         const ProtoTrackContainer& tracks) {
0036   const auto& spacePoints = m_inputSpacePoints(ctx);
0037 
0038   // Open per-event file for all components
0039   std::string path =
0040       perEventFilepath(m_cfg.outputDir, "prototracks.csv", ctx.eventNumber);
0041 
0042   BoostDescribeCsvWriter<ProtoTrackData> writer(path, m_cfg.outputPrecision);
0043 
0044   for (auto trackId = 0ul; trackId < tracks.size(); ++trackId) {
0045     for (Index measurementId : tracks[trackId]) {
0046       const std::optional<ConstSpacePointProxy> sp =
0047           findSpacePointForIndex(measurementId, spacePoints);
0048       if (!sp.has_value()) {
0049         ACTS_WARNING("Could not convert index " << measurementId
0050                                                 << " to space point");
0051         continue;
0052       }
0053       writer.append({trackId, measurementId, sp->x(), sp->y(), sp->z()});
0054     }
0055   }
0056   return ProcessCode::SUCCESS;
0057 }
0058 
0059 }  // namespace ActsExamples