ECCE @ EIC 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-2020 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 
12 #include <limits>
13 #include <random>
14 
22 #include "Dataset.hpp"
23 
24 namespace {
25 constexpr auto eps = std::numeric_limits<double>::epsilon();
26 
27 // Common test method that will be instantiated for each scattering model.
28 template <typename Scattering>
29 void test(const Scattering& scattering, uint32_t seed,
30  const ActsFatras::Particle& before) {
31  std::ranlux48 gen(seed);
32  ActsFatras::Particle after = before;
33 
34  const auto outgoing = scattering(gen, Acts::Test::makePercentSlab(), after);
35  // scattering leaves absolute energy/momentum unchanged
36  CHECK_CLOSE_REL(after.absMomentum(), before.absMomentum(), eps);
37  CHECK_CLOSE_REL(after.energy(), before.energy(), eps);
38  // scattering has changed the direction
39  BOOST_TEST(before.unitDirection().dot(after.unitDirection()) < 1);
40  // scattering creates no new particles
41  BOOST_TEST(outgoing.empty());
42 }
43 } // namespace
44 
45 BOOST_AUTO_TEST_SUITE(FatrasScattering)
46 
47 BOOST_DATA_TEST_CASE(GeneralMixture, Dataset::parameters, pdg, phi, lambda, p,
48  seed) {
50  Dataset::makeParticle(pdg, phi, lambda, p));
51 }
52 
54  seed) {
57 }
58 
62 }
63 
64 BOOST_AUTO_TEST_SUITE_END()