File indexing completed on 2025-09-17 08:04:31
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Definitions/Units.hpp"
0012 #include "Acts/Material/MaterialSlab.hpp"
0013 #include "Acts/Tests/CommonHelpers/PredefinedMaterials.hpp"
0014 #include "ActsFatras/EventData/Barcode.hpp"
0015 #include "ActsFatras/EventData/Particle.hpp"
0016 #include "ActsFatras/Kernel/PointLikeProcess.hpp"
0017
0018 #include <algorithm>
0019 #include <array>
0020 #include <iterator>
0021 #include <random>
0022 #include <vector>
0023
0024 using namespace Acts::UnitLiterals;
0025 using namespace ActsFatras;
0026
0027 namespace {
0028
0029
0030
0031 struct MockMakeChildren {
0032 template <typename generator_t>
0033 std::pair<double, double> generatePathLimits(
0034 generator_t& , const Particle& ) const {
0035 return {0., 0.};
0036 }
0037
0038 template <class generator_t>
0039 bool run(generator_t& , Particle& ,
0040 std::vector<Particle>& generatedParticles) const {
0041 generatedParticles = {Particle().setAbsoluteMomentum(1_GeV),
0042 Particle().setAbsoluteMomentum(2_GeV),
0043 Particle().setAbsoluteMomentum(3_GeV),
0044 Particle().setAbsoluteMomentum(4_GeV)};
0045
0046 return true;
0047 }
0048 };
0049
0050
0051 struct MockEverything {
0052 bool operator()(const Particle& ) const { return true; }
0053 };
0054
0055
0056 struct MockHighP {
0057 double minP = 10_GeV;
0058
0059 bool operator()(const ActsFatras::Particle& particle) const {
0060 return (minP <= particle.absoluteMomentum());
0061 }
0062 };
0063
0064 struct Fixture {
0065 std::default_random_engine generator;
0066 Acts::MaterialSlab slab{Acts::Test::makeBeryllium(), 1_mm};
0067 Particle parent = Particle().setAbsoluteMomentum(10_GeV);
0068 std::vector<Particle> children;
0069 };
0070
0071 }
0072
0073 BOOST_AUTO_TEST_SUITE(FatrasPointLikeProcess)
0074
0075 BOOST_AUTO_TEST_CASE(NoSelectors) {
0076 Fixture f;
0077 PointLikeProcess<MockMakeChildren, MockEverything, MockEverything> process{};
0078
0079
0080 BOOST_CHECK(!process.run(f.generator, f.parent, f.children));
0081 BOOST_CHECK_EQUAL(f.children.size(), 4u);
0082 }
0083
0084 BOOST_AUTO_TEST_CASE(WithInputSelector) {
0085 Fixture f;
0086 PointLikeProcess<MockMakeChildren, MockHighP, MockEverything> process;
0087 process.selectInputParticle.minP = 10_GeV;
0088
0089
0090 f.parent.setAbsoluteMomentum(20_GeV);
0091 BOOST_CHECK(!process.run(f.generator, f.parent, f.children));
0092 BOOST_CHECK_EQUAL(f.children.size(), 4u);
0093
0094 f.parent.setAbsoluteMomentum(10_GeV);
0095 BOOST_CHECK(!process.run(f.generator, f.parent, f.children));
0096 BOOST_CHECK_EQUAL(f.children.size(), 8u);
0097
0098 f.parent.setAbsoluteMomentum(2_GeV);
0099 BOOST_CHECK(!process.run(f.generator, f.parent, f.children));
0100
0101 BOOST_CHECK_EQUAL(f.children.size(), 8u);
0102 }
0103
0104 BOOST_AUTO_TEST_CASE(WithOutputSelector) {
0105 Fixture f;
0106
0107 PointLikeProcess<MockMakeChildren, MockEverything, MockHighP, MockEverything>
0108 process;
0109 process.selectOutputParticle.minP = 10_GeV;
0110
0111
0112 f.parent.setAbsoluteMomentum(20_GeV);
0113 BOOST_CHECK(!process.run(f.generator, f.parent, f.children));
0114 BOOST_CHECK_EQUAL(f.children.size(), 4u);
0115
0116 f.parent.setAbsoluteMomentum(10_GeV);
0117 BOOST_CHECK(!process.run(f.generator, f.parent, f.children));
0118 BOOST_CHECK_EQUAL(f.children.size(), 8u);
0119
0120 f.parent.setAbsoluteMomentum(2_GeV);
0121 BOOST_CHECK(process.run(f.generator, f.parent, f.children));
0122
0123 BOOST_CHECK_EQUAL(f.children.size(), 12u);
0124 }
0125
0126 BOOST_AUTO_TEST_CASE(WithChildSelector) {
0127 Fixture f;
0128 PointLikeProcess<MockMakeChildren, MockEverything, MockEverything, MockHighP>
0129 process;
0130 process.selectChildParticle.minP = 10_GeV;
0131
0132
0133
0134 process.selectChildParticle.minP = 5_GeV;
0135 BOOST_CHECK(!process.run(f.generator, f.parent, f.children));
0136 BOOST_CHECK_EQUAL(f.children.size(), 0u);
0137
0138 process.selectChildParticle.minP = 3.5_GeV;
0139 BOOST_CHECK(!process.run(f.generator, f.parent, f.children));
0140 BOOST_CHECK_EQUAL(f.children.size(), 1u);
0141
0142 process.selectChildParticle.minP = 1.5_GeV;
0143 BOOST_CHECK(!process.run(f.generator, f.parent, f.children));
0144 BOOST_CHECK_EQUAL(f.children.size(), 4u);
0145
0146 process.selectChildParticle.minP = 0.5_GeV;
0147 BOOST_CHECK(!process.run(f.generator, f.parent, f.children));
0148 BOOST_CHECK_EQUAL(f.children.size(), 8u);
0149 }
0150
0151 BOOST_AUTO_TEST_SUITE_END()