ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
payloads.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/definitions/geometry.hpp"
13#include "detray/definitions/grid_axis.hpp"
14#include "detray/io/frontend/definitions.hpp"
15#include "detray/utils/invalid_values.hpp"
16
17// System include(s)
18#include <array>
19#include <cstdint>
20#include <iomanip>
21#include <limits>
22#include <map>
23#include <optional>
24#include <ostream>
25#include <string>
26#include <vector>
27
28//
29// Intermediate data representation as an abstraction to different IO formats
30//
31
38namespace detray::io {
39
43 std::string version{};
45 std::string detector{};
47 std::string tag{};
49 std::string date{};
50};
51
53template <typename sub_header_payload_t = bool>
58 std::optional<sub_header_payload_t> sub_header;
59};
60
64 std::size_t link{std::numeric_limits<std::size_t>::max()};
65};
66
68template <typename type_id_t>
71 using type_id = type_id_t;
72
74 type_id type{type_id::unknown};
76 std::size_t index{std::numeric_limits<std::size_t>::max()};
77};
78
81
85 std::size_t n_volumes{0ul};
87 std::size_t n_surfaces{0ul};
88};
89
92
95
98
102 std::array<io::scalar, 3u> tr{};
103 // Column major rotation matrix
106 std::array<io::scalar, 9u> rot{};
107
108 private:
109 DETRAY_HOST friend inline std::ostream& operator<<(
110 std::ostream& os, const transform_payload& transform) {
112 const auto& r = transform.rot;
114 os << "rot: ";
115 os << std::fixed << std::setw(4);
116 auto print_line = [&](std::size_t i) {
117 os << r[i] << " " << r[i + 3] << " " << r[i + 6] << "\n";
118 };
119 print_line(0);
120 os << " ";
121 print_line(1);
122 os << " ";
123 print_line(2);
124
126 const auto& t = transform.tr;
127
128 os << "tr: ";
129 os << t[0] << " " << t[1] << " " << t[2];
130 return os;
131 }
132};
133
138
140 static constexpr std::size_t end_of_world =
141 detray::detail::invalid_value<std::size_t>();
142
144 mask_shape shape{mask_shape::unknown};
149 std::vector<io::scalar> boundaries{};
150};
151
156 std::optional<std::size_t> index_in_coll;
160 std::vector<mask_payload> masks{};
162 std::optional<material_link_payload> material;
164 std::uint64_t source{};
166 std::optional<std::uint64_t> identifier{
167 detray::detail::invalid_value<std::uint64_t>()};
168
169 detray::surface_id type{detray::surface_id::e_sensitive};
170};
171
175 std::string name{};
177 detray::volume_id type{detray::volume_id::e_cylinder};
181 std::vector<surface_payload> surfaces{};
185 std::optional<std::vector<acc_links_payload>> acc_links{};
186};
187
189
192
196 std::size_t n_slabs{0ul};
198 std::size_t n_slab_surfaces{0ul};
200 std::size_t n_rods{0ul};
202 std::size_t n_rod_surfaces{0ul};
203};
204
208
219 std::array<io::scalar, 7u> params{};
220};
221
226
228 mat_type type{mat_type::unknown};
231 std::optional<std::size_t> index_in_coll;
235 io::scalar thickness{std::numeric_limits<io::scalar>::max()};
238};
239
242 // Not implemented
243};
244
251 std::optional<volume_material_payload> volume_mat;
253 std::vector<surface_material_payload> surface_mat{};
254};
255
259 std::vector<material_volume_payload> volumes{};
260};
261
263
266
270 std::size_t n_grids{0u};
271};
272
275
279 axis::binning binning{axis::binning::e_regular};
281 axis::bounds bounds{axis::bounds::e_closed};
283 axis::label label{axis::label::e_r};
284
286 std::size_t bins{0u};
288 std::vector<io::scalar> edges{};
289
290 private:
291 DETRAY_HOST friend inline std::ostream& operator<<(std::ostream& os,
292 const axis_payload& axis) {
293 os << "axis_payload{binning: " << axis.binning
294 << ", bounds: " << axis.bounds << ", label: " << axis.label
295 << ", bins: " << axis.bins << ", edges: [";
296 for (std::size_t i = 0; i < axis.edges.size(); ++i) {
297 if (i > 0) {
298 os << ", ";
299 }
300 os << axis.edges[i];
301 }
302 os << "]}";
303 return os;
304 }
305};
306
310template <typename content_t = std::size_t>
313 std::vector<unsigned int> loc_index{};
315 std::vector<content_t> content{};
316};
317
322template <typename bin_content_t = std::size_t,
323 typename grid_id_t = io::accel_id>
326 using grid_type = grid_id_t;
327 // volume-local surface or global volume index the grids belongs to
330 // Type and global index of the grid (index is optional only for debugging)
333
335 std::vector<axis_payload> axes{};
338 std::vector<grid_bin_payload<bin_content_t>> bins{};
339};
340
342template <typename bin_content_t = std::size_t,
343 typename grid_id_t = io::accel_id>
345 // A collection of grids (can be the surface search grid, volume or surface
346 // material grids) per volume index (not all volumes may contain grids)
347 std::map<std::size_t, std::vector<grid_payload<bin_content_t, grid_id_t>>>
349 grids = {};
350};
351
353
357 std::vector<volume_payload> volumes = {};
359 std::optional<grid_payload<std::size_t, io::accel_id>> volume_grid;
360};
361
362} // namespace detray::io
The following enums are global for all detectors.
Definition concepts.hpp:18
header_payload< grid_sub_header_payload > grid_header_payload
a payload for the grid file header
Definition payloads.hpp:274
std::ostream & operator<<(std::ostream &os, shape_id sid)
Write a surface-shape identifier using its enumerator name.
Definition definitions.hpp:119
shape_id
Enumerate the shape primitives globally.
Definition definitions.hpp:33
double scalar
Default scalar precision used for serialized geometry payloads.
Definition definitions.hpp:27
typed_link_payload< io::material_id > material_link_payload
A payload object to link a surface to its material.
Definition payloads.hpp:94
accel_id
Enumerate the different acceleration data structures.
Definition definitions.hpp:88
header_payload< geo_sub_header_payload > geo_header_payload
a payload for the geometry file header
Definition payloads.hpp:91
material_id
Enumerate the different material types.
Definition definitions.hpp:59
header_payload< homogeneous_material_sub_header_payload > homogeneous_material_header_payload
a payload for the homogeneous material file header
Definition payloads.hpp:206
typed_link_payload< io::accel_id > acc_links_payload
A payload object to link a volume to its acceleration data structures.
Definition payloads.hpp:97
volume_id
Shape of a detector volume.
Definition geometry.hpp:27
surface_id
surface type, resolved during navigation.
Definition geometry.hpp:41
axis definition and bin edges
Definition payloads.hpp:277
axis::label label
Label to retrieve the axis.
Definition payloads.hpp:283
std::vector< io::scalar > edges
Axis span for reg. binning or distinct bin edge values for irr. binning.
Definition payloads.hpp:288
std::size_t bins
Number of bins.
Definition payloads.hpp:286
axis::bounds bounds
Axis behaviour at final bin.
Definition payloads.hpp:281
axis::binning binning
Axis binning type.
Definition payloads.hpp:279
a payload for common information
Definition payloads.hpp:41
std::string version
Detray version number.
Definition payloads.hpp:43
std::string detector
Detector name.
Definition payloads.hpp:45
std::string tag
Type of data the file contains (e.g. geometry vs material_maps).
Definition payloads.hpp:47
std::string date
Date of file creation.
Definition payloads.hpp:49
A payload for the grid collections of a detector.
Definition payloads.hpp:344
std::map< std::size_t, std::vector< grid_payload< surface_material_payload, io::material_id > > > grids
Definition payloads.hpp:349
A payload for the homogeneous material description of a detector.
Definition payloads.hpp:257
std::vector< material_volume_payload > volumes
Material payloads grouped by detector volume.
Definition payloads.hpp:259
A payload for a detector geometry.
Definition payloads.hpp:355
std::vector< volume_payload > volumes
Material payloads grouped by detector volume.
Definition payloads.hpp:357
std::optional< grid_payload< std::size_t, io::accel_id > > volume_grid
Volume acceleration structure.
Definition payloads.hpp:359
Geometry payloads.
Definition payloads.hpp:83
std::size_t n_surfaces
Total number of surfaces in the detector.
Definition payloads.hpp:87
std::size_t n_volumes
Number of volumes in the detector.
Definition payloads.hpp:85
A payload for a single grid bin.
Definition payloads.hpp:311
std::vector< content_t > content
Bin content for the bin (e.g. coll. of surface indices or material slab).
Definition payloads.hpp:315
std::vector< unsigned int > loc_index
Bin index per axis (global index is determined by serializer).
Definition payloads.hpp:313
A payload for a grid definition.
Definition payloads.hpp:324
single_link_payload owner_link
Volume-local owner of this grid payload.
Definition payloads.hpp:329
std::vector< grid_bin_payload< bin_content_t > > bins
Bin contents in serializer-defined order.
Definition payloads.hpp:338
typed_link_payload< grid_id_t > grid_link
Grid type and index within the linked volume.
Definition payloads.hpp:332
std::vector< axis_payload > axes
Must match the number of axis in the grid type indicated by grid_link.
Definition payloads.hpp:335
grid_id_t grid_type
Identifier type used for this grid.
Definition payloads.hpp:326
Payloads for a uniform grid.
Definition payloads.hpp:268
std::size_t n_grids
Number of grid payloads described by the file.
Definition payloads.hpp:270
a payload for common and extra information
Definition payloads.hpp:54
std::optional< geo_sub_header_payload > sub_header
Definition payloads.hpp:58
common_header_payload common
Definition payloads.hpp:56
Material payloads.
Definition payloads.hpp:194
std::size_t n_rods
Total number of material rods (wire material) in the detector.
Definition payloads.hpp:200
std::size_t n_rod_surfaces
Total number of surface with material rods.
Definition payloads.hpp:202
std::size_t n_slabs
Total number of material slabs in the detector.
Definition payloads.hpp:196
std::size_t n_slab_surfaces
Total number of surface with material slabs.
Definition payloads.hpp:198
A payload object for surface masks.
Definition payloads.hpp:135
mask_shape shape
Shape used to interpret the boundary values.
Definition payloads.hpp:144
single_link_payload volume_link
Sensitive/passive surface: Mother volume index, Portal: Volume the portal leads into,...
Definition payloads.hpp:147
std::vector< io::scalar > boundaries
Boundary values according to boundaries enum of the shape in shape.
Definition payloads.hpp:149
static constexpr std::size_t end_of_world
Portal destination marking the end of the world in an I/O payload.
Definition payloads.hpp:140
io::shape_id mask_shape
Shape identifier for a surface mask.
Definition payloads.hpp:137
A payload object for a material parametrization.
Definition payloads.hpp:210
std::array< io::scalar, 7u > params
Material parametrization 0: X0 1: L0 2: Ar 3: Z 4: Mass density 5: Molar densitty (unused) 6: materia...
Definition payloads.hpp:219
A payload object for all of the [surface] material contained in a volume.
Definition payloads.hpp:247
single_link_payload volume_link
Volume index the payload belongs to.
Definition payloads.hpp:249
std::vector< surface_material_payload > surface_mat
Material slabs/rods of contained surfaces.
Definition payloads.hpp:253
std::optional< volume_material_payload > volume_mat
Material of the volume.
Definition payloads.hpp:251
A payload object for a material slab/rod.
Definition payloads.hpp:223
io::material_id mat_type
Identifier type for homogeneous material representations.
Definition payloads.hpp:225
io::scalar thickness
Thickness of the material slab.
Definition payloads.hpp:235
single_link_payload surface
Index of the surface in the volume the material belongs to.
Definition payloads.hpp:233
material_param_payload mat
Material parameters.
Definition payloads.hpp:237
std::optional< std::size_t > index_in_coll
Index of the material in the material container Optional, if no specific sorting required.
Definition payloads.hpp:231
mat_type type
Either 'slab' or 'rod'.
Definition payloads.hpp:228
A payload for surfaces.
Definition payloads.hpp:153
std::optional< std::uint64_t > identifier
Write the surface identifier as an additional information.
Definition payloads.hpp:166
detray::surface_id type
Either sensitive, passive or portal.
Definition payloads.hpp:169
std::optional< material_link_payload > material
Write the material link of the surface as additional information.
Definition payloads.hpp:162
transform_payload transform
Placement transform of the surface.
Definition payloads.hpp:158
std::optional< std::size_t > index_in_coll
Position of the surface in the volume surface container.
Definition payloads.hpp:156
std::vector< mask_payload > masks
Mask definitions attached to the surface.
Definition payloads.hpp:160
std::uint64_t source
Identifier of the source object (e.g. value of ACTS::GeometryIdentifier).
Definition payloads.hpp:164
A payload for an affine transformation in homogeneous coordinates.
Definition payloads.hpp:100
std::array< io::scalar, 9u > rot
Column-major 3 by 3 rotation matrix.
Definition payloads.hpp:106
std::array< io::scalar, 3u > tr
Translation.
Definition payloads.hpp:102
A payload for the material of a volume.
Definition payloads.hpp:241
A payload for volumes.
Definition payloads.hpp:173
std::vector< surface_payload > surfaces
Surfaces belonging to this volume.
Definition payloads.hpp:181
detray::volume_id type
Geometric shape or category of the volume.
Definition payloads.hpp:177
single_link_payload index
Index of the volume in the detector volume container.
Definition payloads.hpp:183
transform_payload transform
Placement transform of the volume.
Definition payloads.hpp:179
std::string name
Detector-local volume name.
Definition payloads.hpp:175
std::optional< std::vector< acc_links_payload > > acc_links
Optional accelerator data structures.
Definition payloads.hpp:185