Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 08:22:19

0001 /** TRACCC library, part of the ACTS project (R&D line)
0002  *
0003  * (c) 2024-2025 CERN for the benefit of the ACTS project
0004  *
0005  * Mozilla Public License Version 2.0
0006  */
0007 
0008 // Local include(s).
0009 #include "write_spacepoints.hpp"
0010 
0011 // System include(s).
0012 #include <fstream>
0013 
0014 namespace traccc::io::obj {
0015 
0016 void write_spacepoints(
0017     std::string_view filename,
0018     edm::spacepoint_collection::const_view spacepoints_view) {
0019   // Open the output file.
0020   std::ofstream file(filename.data());
0021   if (!file.is_open()) {
0022     throw std::runtime_error("Failed to open file: " + std::string(filename));
0023   }
0024 
0025   // Create a device collection around the spacepoint view.
0026   const edm::spacepoint_collection::const_device spacepoints(spacepoints_view);
0027 
0028   // Write the spacepoints.
0029   for (edm::spacepoint_collection::const_device::size_type i = 0u;
0030        i < spacepoints.size(); ++i) {
0031     const edm::spacepoint sp = spacepoints.at(i);
0032     file << "v " << sp.x() << " " << sp.y() << " " << sp.z() << "\n";
0033   }
0034 }
0035 
0036 }  // namespace traccc::io::obj