ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
detector_writer_config.hpp
1// This file is part of the ACTS project.
2//
3// Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/.
8
9#pragma once
10
11// Project include(s)
12#include "detray/io/frontend/definitions.hpp"
13
14// System include(s)
15#include <ostream>
16#include <string>
17
18namespace detray::io {
19
23 std::string m_path{"./"};
25 detray::io::format m_format = detray::io::format::json;
27 bool m_replace = false;
29 bool m_compact_io = false;
31 bool m_write_material = true;
33 bool m_write_grids = true;
34
39 const std::string& path() const { return m_path; }
45 bool replace_files() const { return m_replace; }
48 bool compactify_json() const { return m_compact_io; }
51 bool write_material() const { return m_write_material; }
54 bool write_grids() const { return m_write_grids; }
56
62 detector_writer_config& path(std::string p) {
63 m_path = std::move(p);
64 return *this;
65 }
66
70 m_format = f;
71 return *this;
72 }
73
77 m_replace = flag;
78 return *this;
79 }
80
84 m_compact_io = flag;
85 return *this;
86 }
87
91 m_write_material = flag;
92 return *this;
93 }
94
98 m_write_grids = flag;
99 return *this;
100 }
101
102
104 friend std::ostream& operator<<(std::ostream& out,
105 const detector_writer_config& cfg) {
106 out << "\nDetector writer\n"
107 << "----------------------------\n"
108 << " Path : " << cfg.path() << "\n"
109 << " Write grids : " << std::boolalpha << cfg.write_grids()
110 << "\n"
111 << " Write material : " << cfg.write_material() << "\n";
112
113 if (cfg.format() == detray::io::format::json) {
114 out << " Compactify json : " << cfg.compactify_json() << "\n";
115 }
116 // Reset state
117 out << std::noboolalpha;
118
119 return out;
120 }
121};
122
123} // namespace detray::io
The following enums are global for all detectors.
Definition concepts.hpp:18
format
Supported serialization formats.
Definition definitions.hpp:30
config struct for detector writing.
Definition detector_writer_config.hpp:21
friend std::ostream & operator<<(std::ostream &out, const detector_writer_config &cfg)
Print the detector writer configuration.
Definition detector_writer_config.hpp:104
bool write_grids() const
Return whether accelerator grids are written.
Definition detector_writer_config.hpp:54
bool write_material() const
Return whether material data is written.
Definition detector_writer_config.hpp:51
std::string m_path
The path to the output files.
Definition detector_writer_config.hpp:23
bool m_write_grids
Whether to write the accelerator grids to file.
Definition detector_writer_config.hpp:33
detector_writer_config & compactify_json(bool flag)
Configure whether to compactify JSON output.
Definition detector_writer_config.hpp:83
bool m_write_material
Whether to write the material to file.
Definition detector_writer_config.hpp:31
bool m_replace
Replace files in case they already exists.
Definition detector_writer_config.hpp:27
detector_writer_config & write_grids(bool flag)
Configure whether to include accelerator-grid data.
Definition detector_writer_config.hpp:97
bool m_compact_io
Compactify json output, if not json format this flag does nothing.
Definition detector_writer_config.hpp:29
detray::io::format m_format
The output file format.
Definition detector_writer_config.hpp:25
detray::io::format format() const
Return the selected output format.
Definition detector_writer_config.hpp:42
detector_writer_config & path(std::string p)
SettersSet the output directory.
Definition detector_writer_config.hpp:62
bool compactify_json() const
Return whether JSON output is compacted.
Definition detector_writer_config.hpp:48
detector_writer_config & format(detray::io::format f)
Select the serialization format.
Definition detector_writer_config.hpp:69
detector_writer_config & replace_files(bool flag)
Configure whether to replace existing files.
Definition detector_writer_config.hpp:76
bool replace_files() const
Return whether existing output files are replaced.
Definition detector_writer_config.hpp:45
const std::string & path() const
GettersReturn the output directory used for detector files.
Definition detector_writer_config.hpp:39
detector_writer_config & write_material(bool flag)
Configure whether to include material data.
Definition detector_writer_config.hpp:90