10 #include <boost/test/data/test_case.hpp>
11 #include <boost/test/unit_test.hpp>
28 using namespace Acts::UnitLiterals;
33 struct SplitEnergyLoss {
34 double splitMomentumMin = 5
_GeV;
36 template <
typename generator_t>
39 std::vector<ActsFatras::Particle>& generated)
const {
41 if (splitMomentumMin <
p) {
67 using ChargedPhysicsList =
70 using ChargedSimulator =
75 using NeutralSimulator =
80 NeutralSelector, NeutralSimulator>;
85 boost::unit_test::data::make(std::vector<Acts::PdgParticle>{
91 const auto rangePhi = boost::unit_test::data::make(std::vector<double>{
97 const auto rangeEta = boost::unit_test::data::make(std::vector<double>{
103 const auto rangeP = boost::unit_test::data::make(std::vector<double>{
107 const auto rangeNumParticles = boost::unit_test::data::make(std::vector<int>{
113 rangePdg * rangePhi * rangeEta * rangeP * rangeNumParticles;
116 template <
typename Container>
117 void sortByParticleId(Container& container) {
118 std::sort(container.begin(), container.end(),
119 [](
const auto& lhs,
const auto& rhs) {
120 return lhs.particleId() < rhs.particleId();
123 template <
typename Container>
124 bool areParticleIdsUnique(
const Container& sortedByParticleId) {
127 std::adjacent_find(sortedByParticleId.begin(), sortedByParticleId.end(),
128 [](
const auto& lhs,
const auto& rhs) {
129 return lhs.particleId() == rhs.particleId();
131 return ret == sortedByParticleId.end();
133 template <
typename Container,
typename Value>
134 bool containsParticleId(
const Container& sortedByParticleId,
135 const Value&
value) {
136 return std::binary_search(sortedByParticleId.begin(),
137 sortedByParticleId.end(),
value,
138 [](
const auto& lhs,
const auto& rhs) {
139 return lhs.particleId() < rhs.particleId();
147 using namespace Acts::UnitLiterals;
160 ChargedPropagator chargedPropagator(std::move(chargedStepper), navigator);
161 NeutralPropagator neutralPropagator(NeutralStepper(), navigator);
164 ChargedSimulator simulatorCharged(std::move(chargedPropagator), logLevel);
165 NeutralSimulator simulatorNeutral(std::move(neutralPropagator), logLevel);
166 Simulator simulator(std::move(simulatorCharged), std::move(simulatorNeutral));
172 std::vector<ActsFatras::Particle> input;
173 std::vector<ActsFatras::Particle> simulatedInitial;
174 std::vector<ActsFatras::Particle> simulatedFinal;
175 std::vector<ActsFatras::Hit>
hits;
178 for (
auto i = numParticles; 0 < i; --i) {
180 const auto particle =
184 input.push_back(std::move(particle));
186 BOOST_TEST_INFO(input.front());
187 BOOST_TEST(input.size() == numParticles);
190 auto result = simulator.simulate(geoCtx, magCtx,
generator, input,
191 simulatedInitial, simulatedFinal,
hits);
194 BOOST_TEST(result.ok());
197 BOOST_TEST(simulatedInitial.size() == simulatedFinal.size());
198 for (std::size_t i = 0; i < simulatedInitial.size(); ++i) {
199 const auto& initialParticle = simulatedInitial[i];
200 const auto& finalParticle = simulatedFinal[i];
202 BOOST_TEST(initialParticle.particleId() == finalParticle.particleId());
203 BOOST_TEST(initialParticle.process() == finalParticle.process());
204 BOOST_TEST(initialParticle.pdg() == finalParticle.pdg());
205 BOOST_TEST(initialParticle.charge() == finalParticle.charge());
206 BOOST_TEST(initialParticle.mass() == finalParticle.mass());
211 BOOST_TEST(input.size() <= simulatedInitial.size());
212 BOOST_TEST(input.size() <= simulatedFinal.size());
215 BOOST_TEST(0
u <
hits.size());
219 sortByParticleId(input);
220 sortByParticleId(simulatedInitial);
221 sortByParticleId(simulatedFinal);
222 sortByParticleId(
hits);
225 BOOST_TEST(areParticleIdsUnique(input));
226 BOOST_TEST(areParticleIdsUnique(simulatedInitial));
227 BOOST_TEST(areParticleIdsUnique(simulatedFinal));
230 for (
const auto& particle : input) {
231 BOOST_TEST(containsParticleId(simulatedInitial, particle));
232 BOOST_TEST(containsParticleId(simulatedFinal, particle));
235 for (
const auto& hit :
hits) {
236 BOOST_TEST(containsParticleId(simulatedInitial, hit));
237 BOOST_TEST(containsParticleId(simulatedFinal, hit));