ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
data_generator.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 "algebra/eigen.hpp"
13#include "detray/algebra/concepts.hpp"
14
15// System include(s)
16#include <algorithm>
17#include <random>
18
19namespace detray::algebra {
20
22template <detray::concepts::vector vector_t>
23inline void fill_random_vec(std::vector<vector_t> &collection) {
24 auto rand_obj = []() { return vector_t::Random(); };
25
26 collection.resize(collection.capacity());
27 std::ranges::generate(collection, rand_obj);
28}
29
31template <detray::concepts::transform3D transform3_t>
32inline void fill_random_trf(std::vector<transform3_t> &collection) {
33 using vector_t = typename transform3_t::vector3;
34
35 auto rand_obj = []() {
36 vector_t x_axis;
37 vector_t z_axis;
38 vector_t t;
39
40 x_axis = detray::vector::normalize(vector_t::Random());
41 z_axis = vector_t::Random();
42 t = detray::vector::normalize(vector_t::Random());
43
44 // Gram-Schmidt projection
45 typename transform3_t::scalar_type coeff =
46 detray::vector::dot(x_axis, z_axis) / detray::vector::norm(x_axis);
47 z_axis = x_axis - coeff * z_axis;
48
49 return transform3_t{t, x_axis, detray::vector::normalize(z_axis)};
50 };
51
52 collection.resize(collection.capacity());
53 std::ranges::generate(collection, rand_obj);
54}
55
57template <detray::concepts::matrix matrix_t>
58inline void fill_random_matrix(std::vector<matrix_t> &collection) {
59 auto rand_obj = []() { return matrix_t::Random(); };
60
61 collection.resize(collection.capacity());
62 std::ranges::generate(collection, rand_obj);
63}
64
65} // namespace detray::algebra