9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/unit_test.hpp>
31 using namespace Acts::UnitLiterals;
36 struct SplitEnergyLoss {
37 double splitMomentumMin = 5_GeV;
39 template <
typename generator_t>
40 bool operator()(generator_t& ,
43 std::vector<ActsFatras::Particle>& generated)
const {
45 if (splitMomentumMin <
p) {
72 using ChargedInteractions =
75 using ChargedSimulation =
82 using NeutralSimulation =
88 NeutralSelector, NeutralSimulation>;
93 boost::unit_test::data::make(std::vector<Acts::PdgParticle>{
99 const auto rangePhi = boost::unit_test::data::make(std::vector<double>{
105 const auto rangeEta = boost::unit_test::data::make(std::vector<double>{
111 const auto rangeP = boost::unit_test::data::make(std::vector<double>{
115 const auto rangeNumParticles = boost::unit_test::data::make(std::vector<int>{
121 rangePdg * rangePhi * rangeEta * rangeP * rangeNumParticles;
124 template <
typename Container>
125 void sortByParticleId(Container&
container) {
126 std::sort(container.begin(), container.end(),
127 [](
const auto&
lhs,
const auto&
rhs) {
128 return lhs.particleId() <
rhs.particleId();
131 template <
typename Container>
132 bool areParticleIdsUnique(
const Container& sortedByParticleId) {
135 std::adjacent_find(sortedByParticleId.begin(), sortedByParticleId.end(),
136 [](
const auto&
lhs,
const auto&
rhs) {
137 return lhs.particleId() ==
rhs.particleId();
139 return ret == sortedByParticleId.end();
141 template <
typename Container,
typename Value>
142 bool containsParticleId(
const Container& sortedByParticleId,
144 return std::binary_search(sortedByParticleId.begin(),
145 sortedByParticleId.end(),
value,
146 [](
const auto&
lhs,
const auto&
rhs) {
147 return lhs.particleId() <
rhs.particleId();
155 using namespace Acts::UnitLiterals;
167 ChargedStepper chargedStepper(
168 std::make_shared<Acts::ConstantBField>(
Acts::Vector3{0, 0, 1_T}));
170 NeutralPropagator neutralPropagator(NeutralStepper(),
navigator);
173 ChargedSimulation simulatorCharged(
176 NeutralSimulation simulatorNeutral(
179 Simulation simulator(
std::move(simulatorCharged),
186 std::vector<ActsFatras::Particle>
input;
187 std::vector<ActsFatras::Particle> simulatedInitial;
188 std::vector<ActsFatras::Particle> simulatedFinal;
189 std::vector<ActsFatras::Hit> hits;
192 for (
auto i = numParticles; 0 <
i; --
i) {
194 const auto particle =
200 BOOST_TEST_INFO(
input.front());
201 BOOST_CHECK_EQUAL(
input.size(), numParticles);
205 simulatedInitial, simulatedFinal, hits);
208 BOOST_CHECK(result.ok());
211 BOOST_CHECK_EQUAL(simulatedInitial.size(), simulatedFinal.size());
212 for (std::size_t
i = 0;
i < simulatedInitial.size(); ++
i) {
213 const auto& initialParticle = simulatedInitial[
i];
214 const auto& finalParticle = simulatedFinal[
i];
216 BOOST_CHECK_EQUAL(initialParticle.particleId(), finalParticle.particleId());
217 BOOST_CHECK_EQUAL(initialParticle.process(), finalParticle.process());
218 BOOST_CHECK_EQUAL(initialParticle.pdg(), finalParticle.pdg());
219 BOOST_CHECK_EQUAL(initialParticle.charge(), finalParticle.charge());
220 BOOST_CHECK_EQUAL(initialParticle.mass(), finalParticle.mass());
225 BOOST_CHECK_LE(
input.size(), simulatedInitial.size());
226 BOOST_CHECK_LE(
input.size(), simulatedFinal.size());
229 BOOST_CHECK_LT(0
u, hits.size());
233 sortByParticleId(
input);
234 sortByParticleId(simulatedInitial);
235 sortByParticleId(simulatedFinal);
236 sortByParticleId(hits);
239 BOOST_CHECK(areParticleIdsUnique(
input));
240 BOOST_CHECK(areParticleIdsUnique(simulatedInitial));
241 BOOST_CHECK(areParticleIdsUnique(simulatedFinal));
244 for (
const auto& particle :
input) {
245 BOOST_CHECK(containsParticleId(simulatedInitial, particle));
246 BOOST_CHECK(containsParticleId(simulatedFinal, particle));
249 for (
const auto& hit : hits) {
250 BOOST_CHECK(containsParticleId(simulatedInitial, hit));
251 BOOST_CHECK(containsParticleId(simulatedFinal, hit));