ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
InteractionsTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file InteractionsTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 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 
15 #include "Acts/Utilities/Units.hpp"
16 
17 namespace data = boost::unit_test::data;
18 using namespace Acts::UnitLiterals;
19 
20 // fixed material
22 // variable values for other parameters
23 // thickness
24 static double valuesThickness[] = {200_um, 1_mm};
25 static auto thickness = data::make(valuesThickness);
26 // particle type, mass, and charge
29 static double mass[] = {511_keV, 105.7_MeV, 139.6_MeV, 938.3_MeV};
30 static double charge[] = {-1_e, -1_e, 1_e, 1_e};
31 static auto particle = data::make(pdg) ^ data::make(mass) ^ data::make(charge);
32 // momentum range
33 static auto momentum_low = data::xrange(100_MeV, 10_GeV, 100_MeV);
34 static auto momentum_med = data::xrange(10_GeV, 100_GeV, 10_GeV);
35 static auto momentum_high = data::xrange(100_GeV, 10_TeV, 100_GeV);
37 
38 BOOST_AUTO_TEST_SUITE(interactions)
39 
40 // consistency checks for the energy loss values
41 BOOST_DATA_TEST_CASE(energy_loss_consistency, thickness* particle* momentum, x,
42  i, m, q, p) {
43  const auto slab = Acts::MaterialProperties(material, x);
44  const auto qOverP = q / p;
45 
46  auto dEBethe = computeEnergyLossBethe(slab, i, m, qOverP, q);
47  auto dELandau = computeEnergyLossLandau(slab, i, m, qOverP, q);
48  auto dELandauSigma = computeEnergyLossLandauSigma(slab, i, m, qOverP, q);
49  auto dELandauSigmaQOverP =
50  computeEnergyLossLandauSigmaQOverP(slab, i, m, qOverP, q);
51  auto dERad = computeEnergyLossRadiative(slab, i, m, qOverP, q);
52  auto dEMean = computeEnergyLossMean(slab, i, m, qOverP, q);
53  auto dEMode = computeEnergyLossMode(slab, i, m, qOverP, q);
54 
55  BOOST_TEST(0 < dEBethe);
56  BOOST_TEST(0 < dELandau);
57  BOOST_TEST(0 < dELandauSigma);
58  BOOST_TEST(0 < dELandauSigmaQOverP);
59  BOOST_TEST(dELandauSigma <= dEBethe);
60  // radiative terms only kick above some threshold -> can be zero
61  BOOST_TEST(0 <= dERad);
62  BOOST_TEST(0 < dEMean);
63  BOOST_TEST(0 < dEMode);
64  BOOST_TEST((dEBethe + dERad) <= dEMean);
65  // TODO verify mode/mean relation for full energy loss
66  // BOOST_TEST(dEMode <= dEMean);
67 }
68 
69 // consistency checks for multiple scattering
70 BOOST_DATA_TEST_CASE(multiple_scattering_consistency,
71  thickness* particle* momentum, x, i, m, q, p) {
72  const auto slab = Acts::MaterialProperties(material, x);
73  const auto slabDoubled = Acts::MaterialProperties(material, 2 * x);
74  const auto qOverP = q / p;
75  const auto qOver2P = q / (2 * p);
76 
77  auto t0 = computeMultipleScatteringTheta0(slab, i, m, qOverP, q);
78  BOOST_TEST(0 < t0);
79  // use the anti-particle -> same scattering
80  auto tanti = computeMultipleScatteringTheta0(slab, -i, m, -qOverP, -q);
81  BOOST_TEST(0 < tanti);
82  BOOST_TEST(t0 == tanti);
83  // double the material -> more scattering
84  auto t2x = computeMultipleScatteringTheta0(slabDoubled, i, m, qOverP, q);
85  BOOST_TEST(0 < t2x);
86  BOOST_TEST(t0 < t2x);
87  // double the momentum -> less scattering
88  auto t2p = computeMultipleScatteringTheta0(slab, i, m, qOver2P, q);
89  BOOST_TEST(0 < t2p);
90  BOOST_TEST(t2p < t0);
91 }
92 
93 // no material -> no interactions
95  const auto vacuum = Acts::MaterialProperties(Acts::Material(), x);
96  const auto qOverP = q / p;
97 
98  BOOST_TEST(computeEnergyLossBethe(vacuum, i, m, qOverP, q) == 0);
99  BOOST_TEST(computeEnergyLossLandau(vacuum, i, m, qOverP, q) == 0);
100  BOOST_TEST(computeEnergyLossLandauSigma(vacuum, i, m, qOverP, q) == 0);
101  BOOST_TEST(computeEnergyLossLandauSigmaQOverP(vacuum, i, m, qOverP, q) == 0);
102  BOOST_TEST(computeEnergyLossRadiative(vacuum, i, m, qOverP, q) == 0);
103  BOOST_TEST(computeEnergyLossMean(vacuum, i, m, qOverP, q) == 0);
104  BOOST_TEST(computeEnergyLossMode(vacuum, i, m, qOverP, q) == 0);
105  BOOST_TEST(computeMultipleScatteringTheta0(vacuum, i, m, qOverP, q) == 0);
106 }
107 
108 BOOST_AUTO_TEST_SUITE_END()