Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Scattering.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Scattering.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2018-2021 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 http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
18 
19 #include <array>
20 #include <random>
21 
22 namespace ActsFatras {
23 namespace detail {
24 
28 template <typename scattering_model_t>
31  scattering_model_t angle;
32 
41  template <typename generator_t>
42  std::array<Particle, 0> operator()(generator_t &generator,
43  const Acts::MaterialSlab &slab,
44  Particle &particle) const {
45  // the scattered direction can be computed by rotating the initial
46  // direction around a vector orthogonal to the initial direction, i.e. the
47  // scattering deflector, by the scattering angle. there are an infinite
48  // number of vectors orthogonal to the initial direction. the deflector is
49  // rotated by some angle relative to some fixpoint.
50  //
51  // thus two random angles are required: the random deflector orientation
52  // angle drawn uniformly from the [-pi,pi) range and the scattering angle
53  // drawn from the specific scattering model distribution.
54 
55  // draw the random orientation angle
56  const auto psi =
57  std::uniform_real_distribution<double>(-M_PI, M_PI)(generator);
58  // draw the scattering angle
59  const auto theta = angle(generator, slab, particle);
60 
61  Acts::Vector3 direction = particle.direction();
62  // construct the combined rotation to the scattered direction
63  Acts::RotationMatrix3 rotation(
64  // rotation of the scattering deflector axis relative to the reference
65  Acts::AngleAxis3(psi, direction) *
66  // rotation by the scattering angle around the deflector axis
68  direction.applyOnTheLeft(rotation);
69  particle.setDirection(direction);
70 
71  // scattering is non-destructive and produces no secondaries
72  return {};
73  }
74 };
75 
76 } // namespace detail
77 
82 
83 } // namespace ActsFatras