Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ScatteringTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ScatteringTests.cpp
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 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/unit_test.hpp>
11 
16 
17 #include <cstdint>
18 #include <limits>
19 #include <random>
20 
21 #include "Dataset.hpp"
22 
23 namespace {
24 constexpr auto eps = std::numeric_limits<double>::epsilon();
25 
26 // Common test method that will be instantiated for each scattering model.
27 template <typename Scattering>
28 void test(const Scattering& scattering, uint32_t seed,
29  const ActsFatras::Particle& before) {
30  std::ranlux48 gen(seed);
31  ActsFatras::Particle after = before;
32 
33  const auto outgoing = scattering(gen, Acts::Test::makePercentSlab(), after);
34  // scattering leaves absolute energy/momentum unchanged
36  CHECK_CLOSE_REL(after.energy(), before.energy(), eps);
37  // scattering has changed the direction
38  BOOST_CHECK_LT(before.direction().dot(after.direction()), 1);
39  // scattering creates no new particles
40  BOOST_CHECK(outgoing.empty());
41 }
42 } // namespace
43 
44 BOOST_AUTO_TEST_SUITE(FatrasScattering)
45 
46 BOOST_DATA_TEST_CASE(GeneralMixture, Dataset::parameters, pdg, phi, lambda, p,
47  seed) {
49  Dataset::makeParticle(pdg, phi, lambda, p));
50 }
51 
52 BOOST_DATA_TEST_CASE(GaussianMixture, Dataset::parameters, pdg, phi, lambda, p,
53  seed) {
55  Dataset::makeParticle(pdg, phi, lambda, p));
56 }
57 
58 BOOST_DATA_TEST_CASE(Highland, Dataset::parameters, pdg, phi, lambda, p, seed) {
60  Dataset::makeParticle(pdg, phi, lambda, p));
61 }
62 
63 BOOST_AUTO_TEST_SUITE_END()