ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
bin_fillers.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/builders/detail/bin_association.hpp"
13#include "detray/core/concepts.hpp"
14#include "detray/utils/grid/axis.hpp"
15#include "detray/utils/grid/concepts.hpp"
16#include "detray/utils/grid/populators.hpp"
17
18// System include(s)
19#include <cassert>
20#include <vector>
21
22namespace detray {
23
32 template <std::size_t DIM, typename value_t>
40
42 template <concepts::grid grid_t>
44
48 template <concepts::grid grid_t, typename volume_t,
49 typename surface_container_t, typename mask_container,
50 typename transform_container, typename context_t, typename... Args>
51 DETRAY_HOST auto operator()(grid_t &grid, const volume_t & /*unused*/,
52 const surface_container_t & /*unused*/,
53 const mask_container & /*unused*/,
54 const context_t /*unused*/,
55 std::vector<bin_data_type<grid_t>> &bins) const
56 -> void {
57 for (const bin_data_type<grid_t> &bd : bins) {
58 grid.template populate<attach<>>(bd.local_bin_idx, bd.single_element);
59 }
60 }
61};
62
76 template <concepts::surface_grid grid_t, typename volume_t,
77 typename surface_container_t, typename mask_container,
78 typename transform_container, typename context_t, typename... Args>
79 DETRAY_HOST auto operator()(grid_t &grid, const volume_t &vol,
80 const surface_container_t &surfaces,
81 const transform_container &transforms,
82 const mask_container & /*masks*/,
83 const context_t ctx, Args &&.../*unused*/) const
84 -> void {
85 // Fill the volumes surfaces into the grid
86 for (const auto &sf : surfaces) {
87 // no portals in grids allowed
88 if (sf.volume() == vol.index() && sf.is_sensitive()) {
89 const auto &sf_trf = transforms.at(sf.transform(), ctx);
90 const auto &t = sf_trf.translation();
91
92 // transform to axis coordinate system
93 const auto loc_pos = grid.project(vol.transform(), t, t);
94
95 // Populate
96 grid.template populate<attach<>>(loc_pos, sf);
97 }
98 }
99 }
100};
101
114 template <concepts::detector detector_t, typename volume_type,
115 concepts::surface_grid grid_t, typename... Args>
116 DETRAY_HOST auto operator()(grid_t &grid, detector_t &det,
117 const volume_type &vol,
118 const typename detector_t::geometry_context ctx,
119 Args &&.../*unused*/) const -> void {
120 this->operator()(grid, det.surfaces(vol), det.mask_store(),
121 det.transform_store(), ctx);
122 }
123
130 template <concepts::surface_grid grid_t, typename volume_t,
131 typename surface_container_t, typename mask_container,
132 typename transform_container, typename context_t, typename... Args>
133 DETRAY_HOST auto operator()(grid_t &grid, const volume_t & /*unused*/,
134 const surface_container_t &surfaces,
135 const transform_container &transforms,
136 const mask_container &masks, const context_t ctx,
137 Args &&.../*unused*/) const -> void {
139
140 // Fill the surfaces into the grid by matching their contour onto the
141 // grid bins
142 bin_association(ctx, surfaces, transforms, masks, grid,
143 darray<scalar_t, 2>{0.1f, 0.1f}, false);
144 }
145};
146
147} // namespace detray
Check if a type can be used as a detector.
Definition concepts.hpp:47
Definition concepts.hpp:64
Grid that contains surfaces (used e.g.
Definition concepts.hpp:115
Detray include(s).
Definition array_operators.hpp:18
get_scalar_t< A, T > dscalar
Scalar type for algebra A and value type T.
Definition algebra.hpp:64
std::array< value_t, kDIM > darray
Fixed-size array container.
Definition containers.hpp:30
grid_impl< coordinate_axes< axes_t, algebra_t, ownership, containers >, bin_t, simple_serializer > grid
Type alias for easier construction.
Definition grid.hpp:422
Multi-bin: contains bin indices from multiple axes.
Definition axis.hpp:36
Fill a grid surface finder by bin association.
Definition bin_fillers.hpp:108
auto operator()(grid_t &grid, const volume_t &, const surface_container_t &surfaces, const transform_container &transforms, const mask_container &masks, const context_t ctx, Args &&...) const -> void
Associate supplied surfaces with bins by matching their contours.
Definition bin_fillers.hpp:133
auto operator()(grid_t &grid, detector_t &det, const volume_type &vol, const typename detector_t::geometry_context ctx, Args &&...) const -> void
Associate detector surfaces with bins based on their boundaries.
Definition bin_fillers.hpp:116
Single piece of data for a grid bin.
Definition bin_fillers.hpp:33
typename grid_t::value_type single_element
Definition bin_fillers.hpp:38
detray::axis::multi_bin< DIM > local_bin_idx
Definition bin_fillers.hpp:35
Fill a surface grid using a local bin index of the grid and a payload.
Definition bin_fillers.hpp:30
bin_data< grid_t::dim, typename grid_t::value_type > bin_data_type
Grid-bin payload type used by the bin filler.
Definition bin_fillers.hpp:43
auto operator()(grid_t &grid, const volume_t &, const surface_container_t &, const mask_container &, const context_t, std::vector< bin_data_type< grid_t > > &bins) const -> void
Populate a grid from the supplied bin indices and payload values.
Definition bin_fillers.hpp:51
Fill a surface grid using the surface translation.
Definition bin_fillers.hpp:69
auto operator()(grid_t &grid, const volume_t &vol, const surface_container_t &surfaces, const transform_container &transforms, const mask_container &, const context_t ctx, Args &&...) const -> void
Populate a surface grid from the translations of its sensitive surfaces.
Definition bin_fillers.hpp:79