File indexing completed on 2025-01-31 09:17:03
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/Io/Obj/ObjPropagationStepsWriter.hpp"
0010
0011 namespace ActsExamples {
0012
0013 ObjPropagationStepsWriter::ObjPropagationStepsWriter(const Config& cfg,
0014 Acts::Logging::Level level)
0015 : WriterT<PropagationSummaries>(cfg.collection, "ObjPropagationStepsWriter",
0016 level),
0017 m_cfg(cfg) {
0018 if (m_cfg.collection.empty()) {
0019 throw std::invalid_argument("Missing input collection");
0020 }
0021 }
0022
0023
0024
0025 ProcessCode ObjPropagationStepsWriter::writeT(
0026 const AlgorithmContext& context, const PropagationSummaries& summaries) {
0027
0028 std::string path = ActsExamples::perEventFilepath(
0029 m_cfg.outputDir, "propagation-steps.obj", context.eventNumber);
0030 std::ofstream os(path, std::ofstream::out | std::ofstream::trunc);
0031 if (!os) {
0032 throw std::ios_base::failure("Could not open '" + path + "' to write");
0033 }
0034
0035
0036 unsigned int vCounter = 0;
0037
0038 for (const auto& summary : summaries) {
0039 const auto& steps = summary.steps;
0040
0041 if (steps.size() > 2) {
0042
0043 ++vCounter;
0044 for (auto& step : steps) {
0045
0046 os << "v " << m_cfg.outputScalor * step.position.x() << " "
0047 << m_cfg.outputScalor * step.position.y() << " "
0048 << m_cfg.outputScalor * step.position.z() << '\n';
0049 }
0050
0051 std::size_t vBreak = vCounter + steps.size() - 1;
0052 for (; vCounter < vBreak; ++vCounter) {
0053 os << "l " << vCounter << " " << vCounter + 1 << '\n';
0054 }
0055 }
0056 }
0057 return ActsExamples::ProcessCode::SUCCESS;
0058 }
0059
0060 }