ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
scattering_helper.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/algebra.hpp"
13#include "detray/definitions/detail/qualifiers.hpp"
14#include "detray/definitions/units.hpp"
15#include "detray/utils/axis_rotation.hpp"
16#include "detray/utils/unit_vectors.hpp"
17
18// System include(s).
19#include <random>
20
21namespace detray {
22
24template <concepts::algebra algebra_t>
26 public:
31
38 template <typename generator_t>
39 DETRAY_HOST inline vector3_type operator()(const vector3_type& dir,
40 const scalar_type angle,
41 generator_t& generator) const {
42 // Generate theta and phi for random scattering
43 const scalar_type r_theta{
44 angle == 0.f
45 ? 0.f
46 : std::normal_distribution<scalar_type>(0.f, angle)(generator)};
47
48 const scalar_type r_phi{std::uniform_real_distribution<scalar_type>(
50
51 // xaxis of curvilinear plane
52 const vector3_type u =
54
55 vector3_type new_dir = axis_rotation<algebra_t>(u, r_theta)(dir);
56 return axis_rotation<algebra_t>(dir, r_phi)(new_dir);
57 }
58};
59
60} // namespace detray
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
get_vector3D_t< A, T > dvector3D
Three-dimensional vector type for algebra A and value type T.
Definition algebra.hpp:80
Helper struct to rotate a vector around a given axis and angle counterclockwisely.
Definition axis_rotation.hpp:21
static constexpr scalar_t pi
π
Definition units.hpp:136
Generates a random direction after multiple scattering.
Definition scattering_helper.hpp:25
dvector3D< algebra_t > vector3_type
3D vector type used for directions.
Definition scattering_helper.hpp:30
dscalar< algebra_t > scalar_type
Scalar type used for angles.
Definition scattering_helper.hpp:28
vector3_type operator()(const vector3_type &dir, const scalar_type angle, generator_t &generator) const
Operator to scatter the direction with scattering angle.
Definition scattering_helper.hpp:39
Build the curvilinear unit basis perpendicular to a three-dimensional direction.
Definition unit_vectors.hpp:22
vector3_t make_curvilinear_unit_u(const vector3_t &dir)
Construct the first curvilinear unit vector U for the given direction.
Definition unit_vectors.hpp:31