Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CsvProtoTrackWriter.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CsvProtoTrackWriter.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2023 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
20 
21 #include <ios>
22 #include <optional>
23 #include <stdexcept>
24 
25 #include <dfe/dfe_io_dsv.hpp>
26 
27 #include "CsvOutputData.hpp"
28 
32  : WriterT(config.inputPrototracks, "CsvProtoTrackWriter", level),
33  m_cfg(config) {
35 }
36 
38 
40  // Write the tree
41  return ProcessCode::SUCCESS;
42 }
43 
45  const AlgorithmContext& ctx, const ProtoTrackContainer& tracks) {
46  const auto& spacepoints = m_inputSpacepoints(ctx);
47 
48  // Open per-event file for all components
50  perEventFilepath(m_cfg.outputDir, "prototracks.csv", ctx.eventNumber);
51 
52  dfe::NamedTupleCsvWriter<ProtoTrackData> writer(path, m_cfg.outputPrecision);
53 
54  for (auto trackId = 0ul; trackId < tracks.size(); ++trackId) {
55  for (Index measurmentId : tracks[trackId]) {
56  const auto spr = findSpacePointForIndex(measurmentId, spacepoints);
57  if (spr == nullptr) {
58  ACTS_WARNING("Could not convert index " << measurmentId
59  << " to spacepoint");
60  continue;
61  }
62  const auto& sp = *spr;
63  writer.append({trackId, measurmentId, sp.x(), sp.y(), sp.z()});
64  }
65  }
67 }