ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
json_writers.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/core/concepts.hpp"
13#include "detray/io/backend/geometry_writer.hpp"
14#include "detray/io/backend/homogeneous_material_writer.hpp"
15#include "detray/io/backend/material_map_writer.hpp"
16#include "detray/io/backend/surface_grid_writer.hpp"
17#include "detray/io/frontend/detail/detector_components_writer.hpp"
18#include "detray/io/frontend/detector_writer_config.hpp"
19#include "detray/io/json/json_converter.hpp"
20
21namespace detray::io {
22
24
25namespace detail {
26
28template <class detector_t>
29void add_json_writers(detector_components_writer<detector_t>& writers,
30 const detray::io::detector_writer_config& cfg) {
31 // Always needed
32 using json_geometry_writer = json_converter<detector_t, geometry_writer>;
33
34 writers.template add<json_geometry_writer>();
35
36 // Find other writers, depending on the detector type
37 if (cfg.write_material()) {
38 // Simple material
39 if constexpr (detray::concepts::has_homogeneous_material<detector_t>) {
40 using json_homogeneous_material_writer =
41 json_converter<detector_t, homogeneous_material_writer>;
42
43 writers.template add<json_homogeneous_material_writer>();
44 }
45 // Material maps
46 if constexpr (detray::concepts::has_material_maps<detector_t>) {
47 using json_material_map_writer =
48 json_converter<detector_t, material_map_writer>;
49
50 writers.template add<json_material_map_writer>();
51 }
52 }
53 // Navigation acceleration structures
54 if constexpr (detray::concepts::has_surface_grids<detector_t>) {
55 using json_surface_grid_writer =
56 json_converter<detector_t, surface_grid_writer>;
57
58 if (cfg.write_grids()) {
59 writers.template add<json_surface_grid_writer>();
60 }
61 }
62}
63
64} // namespace detail
65
66} // namespace detray::io
The following enums are global for all detectors.
Definition concepts.hpp:18
config struct for detector writing.
Definition detector_writer_config.hpp:21
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