9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/unit_test.hpp>
30 using namespace Acts::UnitLiterals;
35 struct SplitEnergyLoss {
36 double splitMomentumMin = 5_GeV;
38 template <
typename generator_t>
41 std::vector<ActsFatras::Particle>& generated)
const {
43 if (splitMomentumMin <
p) {
69 using ChargedPhysicsList =
72 using ChargedSimulator =
77 using NeutralSimulator =
82 NeutralSelector, NeutralSimulator>;
87 boost::unit_test::data::make(std::vector<Acts::PdgParticle>{
93 const auto rangePhi = boost::unit_test::data::make(std::vector<double>{
99 const auto rangeEta = boost::unit_test::data::make(std::vector<double>{
105 const auto rangeP = boost::unit_test::data::make(std::vector<double>{
109 const auto rangeNumParticles = boost::unit_test::data::make(std::vector<int>{
115 rangePdg * rangePhi * rangeEta * rangeP * rangeNumParticles;
118 template <
typename Container>
119 void sortByParticleId(Container& container) {
120 std::sort(container.begin(), container.end(),
121 [](
const auto& lhs,
const auto& rhs) {
122 return lhs.particleId() < rhs.particleId();
125 template <
typename Container>
126 bool areParticleIdsUnique(
const Container& sortedByParticleId) {
129 std::adjacent_find(sortedByParticleId.begin(), sortedByParticleId.end(),
130 [](
const auto& lhs,
const auto& rhs) {
131 return lhs.particleId() == rhs.particleId();
133 return ret == sortedByParticleId.end();
135 template <
typename Container,
typename Value>
136 bool containsParticleId(
const Container& sortedByParticleId,
137 const Value&
value) {
138 return std::binary_search(sortedByParticleId.begin(),
139 sortedByParticleId.end(),
value,
140 [](
const auto& lhs,
const auto& rhs) {
141 return lhs.particleId() < rhs.particleId();
149 using namespace Acts::UnitLiterals;
162 ChargedPropagator chargedPropagator(std::move(chargedStepper), navigator);
163 NeutralPropagator neutralPropagator(NeutralStepper(), navigator);
166 ChargedSimulator simulatorCharged(std::move(chargedPropagator), logLevel);
167 NeutralSimulator simulatorNeutral(std::move(neutralPropagator), logLevel);
168 Simulator simulator(std::move(simulatorCharged), std::move(simulatorNeutral));
174 std::vector<ActsFatras::Particle> input;
175 std::vector<ActsFatras::Particle> simulatedInitial;
176 std::vector<ActsFatras::Particle> simulatedFinal;
177 std::vector<ActsFatras::Hit> hits;
180 for (
auto i = numParticles; 0 < i; --i) {
182 const auto particle =
186 input.push_back(std::move(particle));
188 BOOST_TEST_INFO(input.front());
189 BOOST_CHECK_EQUAL(input.size(), numParticles);
193 simulatedInitial, simulatedFinal, hits);
196 BOOST_CHECK(result.ok());
199 BOOST_CHECK_EQUAL(simulatedInitial.size(), simulatedFinal.size());
200 for (std::size_t i = 0; i < simulatedInitial.size(); ++i) {
201 const auto& initialParticle = simulatedInitial[i];
202 const auto& finalParticle = simulatedFinal[i];
204 BOOST_CHECK_EQUAL(initialParticle.particleId(), finalParticle.particleId());
205 BOOST_CHECK_EQUAL(initialParticle.process(), finalParticle.process());
206 BOOST_CHECK_EQUAL(initialParticle.pdg(), finalParticle.pdg());
207 BOOST_CHECK_EQUAL(initialParticle.charge(), finalParticle.charge());
208 BOOST_CHECK_EQUAL(initialParticle.mass(), finalParticle.mass());
213 BOOST_CHECK_LE(input.size(), simulatedInitial.size());
214 BOOST_CHECK_LE(input.size(), simulatedFinal.size());
217 BOOST_CHECK_LT(0
u, hits.size());
221 sortByParticleId(input);
222 sortByParticleId(simulatedInitial);
223 sortByParticleId(simulatedFinal);
224 sortByParticleId(hits);
227 BOOST_CHECK(areParticleIdsUnique(input));
228 BOOST_CHECK(areParticleIdsUnique(simulatedInitial));
229 BOOST_CHECK(areParticleIdsUnique(simulatedFinal));
232 for (
const auto& particle : input) {
233 BOOST_CHECK(containsParticleId(simulatedInitial, particle));
234 BOOST_CHECK(containsParticleId(simulatedFinal, particle));
237 for (
const auto& hit : hits) {
238 BOOST_CHECK(containsParticleId(simulatedInitial, hit));
239 BOOST_CHECK(containsParticleId(simulatedFinal, hit));