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 const double valuesThickness[] = {200_um, 1_mm};
25 static auto thickness = data::make(valuesThickness);
26 // particle type, mass, and charge
29 static const double mass[] = {511_keV, 105.7_MeV, 139.6_MeV, 938.3_MeV};
30 static const double charge[] = {-1_e, -1_e, 1_e, 1_e};
31 static const auto particle =
32  data::make(pdg) ^ data::make(mass) ^ data::make(charge);
33 // momentum range
34 static const auto momentum_low = data::xrange(100_MeV, 10_GeV, 100_MeV);
35 static const auto momentum_med = data::xrange(10_GeV, 100_GeV, 10_GeV);
36 static const auto momentum_high = data::xrange(100_GeV, 10_TeV, 100_GeV);
38 
39 BOOST_AUTO_TEST_SUITE(interactions)
40 
41 // consistency checks for the energy loss values
42 BOOST_DATA_TEST_CASE(energy_loss_consistency, thickness* particle* momentum, x,
43  i, m, q, p) {
44  const auto slab = Acts::MaterialSlab(material, x);
45  const auto qOverP = q / p;
46 
47  auto dEBethe = computeEnergyLossBethe(slab, i, m, qOverP, q);
48  auto dELandau = computeEnergyLossLandau(slab, i, m, qOverP, q);
49  auto dELandauSigma = computeEnergyLossLandauSigma(slab, i, m, qOverP, q);
50  auto dELandauSigmaQOverP =
51  computeEnergyLossLandauSigmaQOverP(slab, i, m, qOverP, q);
52  auto dERad = computeEnergyLossRadiative(slab, i, m, qOverP, q);
53  auto dEMean = computeEnergyLossMean(slab, i, m, qOverP, q);
54  auto dEMode = computeEnergyLossMode(slab, i, m, qOverP, q);
55 
56  BOOST_CHECK_LT(0, dEBethe);
57  BOOST_CHECK_LT(0, dELandau);
58  BOOST_CHECK_LT(0, dELandauSigma);
59  BOOST_CHECK_LT(0, dELandauSigmaQOverP);
60  BOOST_CHECK_LE(dELandauSigma, dEBethe);
61  // radiative terms only kick above some threshold -> can be zero
62  BOOST_CHECK_LE(0, dERad);
63  BOOST_CHECK_LT(0, dEMean);
64  BOOST_CHECK_LT(0, dEMode);
65  BOOST_CHECK_LE((dEBethe + dERad), dEMean);
66  // TODO verify mode/mean relation for full energy loss
67  // BOOST_CHECK_LE(dEMode, dEMean);
68 }
69 
70 // consistency checks for multiple scattering
71 BOOST_DATA_TEST_CASE(multiple_scattering_consistency,
72  thickness* particle* momentum, x, i, m, q, p) {
73  const auto slab = Acts::MaterialSlab(material, x);
74  const auto slabDoubled = Acts::MaterialSlab(material, 2 * x);
75  const auto qOverP = q / p;
76  const auto qOver2P = q / (2 * p);
77 
78  auto t0 = computeMultipleScatteringTheta0(slab, i, m, qOverP, q);
79  BOOST_CHECK_LT(0, t0);
80  // use the anti-particle -> same scattering
81  auto tanti = computeMultipleScatteringTheta0(slab, -i, m, -qOverP, -q);
82  BOOST_CHECK_LT(0, tanti);
83  BOOST_CHECK_EQUAL(t0, tanti);
84  // double the material -> more scattering
85  auto t2x = computeMultipleScatteringTheta0(slabDoubled, i, m, qOverP, q);
86  BOOST_CHECK_LT(0, t2x);
87  BOOST_CHECK_LT(t0, t2x);
88  // double the momentum -> less scattering
89  auto t2p = computeMultipleScatteringTheta0(slab, i, m, qOver2P, q);
90  BOOST_CHECK_LT(0, t2p);
91  BOOST_CHECK_LT(t2p, t0);
92 }
93 
94 // no material -> no interactions
96  const auto vacuum = Acts::MaterialSlab(Acts::Material(), x);
97  const auto qOverP = q / p;
98 
99  BOOST_CHECK_EQUAL(computeEnergyLossBethe(vacuum, i, m, qOverP, q), 0);
100  BOOST_CHECK_EQUAL(computeEnergyLossLandau(vacuum, i, m, qOverP, q), 0);
101  BOOST_CHECK_EQUAL(computeEnergyLossLandauSigma(vacuum, i, m, qOverP, q), 0);
102  BOOST_CHECK_EQUAL(computeEnergyLossLandauSigmaQOverP(vacuum, i, m, qOverP, q),
103  0);
104  BOOST_CHECK_EQUAL(computeEnergyLossRadiative(vacuum, i, m, qOverP, q), 0);
105  BOOST_CHECK_EQUAL(computeEnergyLossMean(vacuum, i, m, qOverP, q), 0);
106  BOOST_CHECK_EQUAL(computeEnergyLossMode(vacuum, i, m, qOverP, q), 0);
107  BOOST_CHECK_EQUAL(computeMultipleScatteringTheta0(vacuum, i, m, qOverP, q),
108  0);
109 }
110 
111 BOOST_AUTO_TEST_SUITE_END()