EIC Software
Reference for
EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
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 "
Acts/Material/MaterialSlab.hpp
"
13
#include "
Acts/Tests/CommonHelpers/FloatComparisons.hpp
"
14
#include "
Acts/Tests/CommonHelpers/PredefinedMaterials.hpp
"
15
#include "
ActsFatras/EventData/Particle.hpp
"
16
#include "
ActsFatras/Physics/Scattering/GaussianMixture.hpp
"
17
#include "
ActsFatras/Physics/Scattering/GeneralMixture.hpp
"
18
#include "
ActsFatras/Physics/Scattering/Highland.hpp
"
19
20
#include <limits>
21
#include <random>
22
23
#include "
Dataset.hpp
"
24
25
namespace
{
26
constexpr
auto
eps
=
std::numeric_limits<double>::epsilon
();
27
28
// Common test method that will be instantiated for each scattering model.
29
template
<
typename
Scattering>
30
void
test(
const
Scattering& scattering,
uint32_t
seed,
31
const
ActsFatras::Particle
& before) {
32
std::ranlux48 gen(seed);
33
ActsFatras::Particle
after = before;
34
35
const
auto
outgoing = scattering(gen,
Acts::Test::makePercentSlab
(), after);
36
// scattering leaves absolute energy/momentum unchanged
37
CHECK_CLOSE_REL
(after.
absMomentum
(), before.
absMomentum
(),
eps
);
38
CHECK_CLOSE_REL
(after.
energy
(), before.
energy
(),
eps
);
39
// scattering has changed the direction
40
BOOST_CHECK_LT(before.
unitDirection
().dot(after.
unitDirection
()), 1);
41
// scattering creates no new particles
42
BOOST_CHECK(outgoing.empty());
43
}
44
}
// namespace
45
46
BOOST_AUTO_TEST_SUITE(FatrasScattering)
47
48
BOOST_DATA_TEST_CASE
(GeneralMixture, Dataset::
parameters
,
pdg
,
phi
, lambda,
p
,
49
seed) {
50
test(
ActsFatras::GeneralMixtureScattering
(), seed,
51
Dataset::makeParticle
(pdg, phi, lambda, p));
52
}
53
54
BOOST_DATA_TEST_CASE
(GaussianMixture,
Dataset::parameters
,
pdg
,
phi
, lambda,
p
,
55
seed) {
56
test(
ActsFatras::GaussianMixtureScattering
(), seed,
57
Dataset::makeParticle
(
pdg
,
phi
, lambda,
p
));
58
}
59
60
BOOST_DATA_TEST_CASE
(Highland,
Dataset::parameters
,
pdg
,
phi
, lambda,
p
, seed) {
61
test(
ActsFatras::HighlandScattering
(), seed,
62
Dataset::makeParticle
(
pdg
,
phi
, lambda,
p
));
63
}
64
65
BOOST_AUTO_TEST_SUITE_END()
acts
blob
sPHENIX
Tests
UnitTests
Fatras
Physics
ScatteringTests.cpp
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:28
using
1.8.2 with
EIC GitHub integration