File indexing completed on 2025-08-03 08:09:25
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #define BOOST_TEST_MODULE AbortList Tests
0011
0012 #include <boost/test/included/unit_test.hpp>
0013
0014
0015 #include <boost/test/data/test_case.hpp>
0016
0017
0018 #include <boost/test/output_test_stream.hpp>
0019
0020
0021 #include "Acts/Utilities/Definitions.hpp"
0022 #include "Fatras/Kernel/PhysicsList.hpp"
0023 #include "Fatras/Kernel/Process.hpp"
0024 #include "Fatras/Kernel/SelectorList.hpp"
0025 #include "Particle.hpp"
0026 #include <algorithm>
0027 #include <random>
0028
0029 namespace bdata = boost::unit_test::data;
0030 namespace tt = boost::test_tools;
0031
0032 namespace Fatras {
0033
0034 namespace Test {
0035
0036
0037 typedef std::mt19937 Generator;
0038
0039
0040 struct Detector {};
0041
0042
0043 struct Selector {
0044
0045
0046 template <typename detector_t, typename particle_t>
0047 bool operator()(const detector_t &, const particle_t &) const {
0048 return true;
0049 }
0050 };
0051
0052
0053 struct EnergyDecreaser {
0054
0055
0056 double cvalue = 0.90;
0057
0058 template <typename generator_t, typename detector_t, typename particle_t>
0059 std::vector<particle_t> operator()(generator_t &, const detector_t &,
0060 particle_t &in) const {
0061
0062 in.energyLoss((1. - cvalue) * in.E());
0063 return {};
0064 }
0065 };
0066
0067
0068 BOOST_DATA_TEST_CASE(
0069 Process_test_,
0070 bdata::random(
0071 (bdata::seed = 20,
0072 bdata::distribution = std::uniform_real_distribution<>(0., 1.))) ^
0073 bdata::random(
0074 (bdata::seed = 21,
0075 bdata::distribution = std::uniform_real_distribution<>(0., 1.))) ^
0076 bdata::random(
0077 (bdata::seed = 22,
0078 bdata::distribution = std::uniform_real_distribution<>(0., 1.))) ^
0079 bdata::random((
0080 bdata::seed = 23,
0081 bdata::distribution = std::uniform_real_distribution<>(1., 100.))) ^
0082 bdata::xrange(100),
0083 x, y, z, p, index) {
0084
0085 Generator generator;
0086
0087
0088 Detector detector;
0089
0090
0091
0092 Acts::Vector3D position{0., 0., 0.};
0093
0094 Acts::Vector3D momentum =
0095 p * Acts::units::_GeV * Acts::Vector3D(x, y, z).normalized();
0096
0097 double q = 1.;
0098 double m = 105.658367 * Acts::units::_MeV;
0099
0100
0101 Particle particle(position, momentum, m, q, 13, 1);
0102
0103
0104 std::vector<Particle> outgoing;
0105
0106
0107 typedef SelectorListAND<Selector> All;
0108 typedef Process<EnergyDecreaser, All, All, All> EnergyLoss;
0109 EnergyLoss cEnergyLoss;
0110
0111
0112 BOOST_CHECK(!cEnergyLoss(generator, detector, particle, outgoing));
0113
0114
0115 BOOST_CHECK(momentum.norm() != particle.momentum().norm());
0116
0117
0118 PhysicsList<EnergyLoss> energyLossPhysics;
0119
0120
0121 BOOST_CHECK(!energyLossPhysics(generator, detector, particle, outgoing));
0122 }
0123
0124 }
0125 }