Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:11:40

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2018-2021 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/data/test_case.hpp>
0010 #include <boost/test/unit_test.hpp>
0011 
0012 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0013 #include "Acts/Tests/CommonHelpers/PredefinedMaterials.hpp"
0014 #include "ActsFatras/EventData/Particle.hpp"
0015 #include "ActsFatras/Physics/ElectroMagnetic/Scattering.hpp"
0016 
0017 #include <cstdint>
0018 #include <limits>
0019 #include <random>
0020 
0021 #include "Dataset.hpp"
0022 
0023 namespace {
0024 constexpr auto eps = std::numeric_limits<double>::epsilon();
0025 
0026 // Common test method that will be instantiated for each scattering model.
0027 template <typename Scattering>
0028 void test(const Scattering& scattering, uint32_t seed,
0029           const ActsFatras::Particle& before) {
0030   std::ranlux48 gen(seed);
0031   ActsFatras::Particle after = before;
0032 
0033   const auto outgoing = scattering(gen, Acts::Test::makePercentSlab(), after);
0034   // scattering leaves absolute energy/momentum unchanged
0035   CHECK_CLOSE_REL(after.absoluteMomentum(), before.absoluteMomentum(), eps);
0036   CHECK_CLOSE_REL(after.energy(), before.energy(), eps);
0037   // scattering has changed the direction
0038   BOOST_CHECK_LT(before.direction().dot(after.direction()), 1);
0039   // scattering creates no new particles
0040   BOOST_CHECK(outgoing.empty());
0041 }
0042 }  // namespace
0043 
0044 BOOST_AUTO_TEST_SUITE(FatrasScattering)
0045 
0046 BOOST_DATA_TEST_CASE(GeneralMixture, Dataset::parameters, pdg, phi, lambda, p,
0047                      seed) {
0048   test(ActsFatras::GeneralMixtureScattering(), seed,
0049        Dataset::makeParticle(pdg, phi, lambda, p));
0050 }
0051 
0052 BOOST_DATA_TEST_CASE(GaussianMixture, Dataset::parameters, pdg, phi, lambda, p,
0053                      seed) {
0054   test(ActsFatras::GaussianMixtureScattering(), seed,
0055        Dataset::makeParticle(pdg, phi, lambda, p));
0056 }
0057 
0058 BOOST_DATA_TEST_CASE(Highland, Dataset::parameters, pdg, phi, lambda, p, seed) {
0059   test(ActsFatras::HighlandScattering(), seed,
0060        Dataset::makeParticle(pdg, phi, lambda, p));
0061 }
0062 
0063 BOOST_AUTO_TEST_SUITE_END()