9 #include <boost/test/unit_test.hpp>
22 using namespace ActsFatras;
28 struct MockPhysicsList {
29 double energyLoss = 0;
31 template <
typename generator_t>
33 std::vector<Particle> &generated)
const {
34 generated.push_back(particle);
41 struct MockStepperState {
55 auto position(MockStepperState &state)
const {
return state.position; }
56 auto time(MockStepperState &state)
const {
return state.time; }
57 auto direction(MockStepperState &state)
const {
return state.direction; }
58 auto momentum(MockStepperState &state)
const {
return state.momentum; }
63 state.direction = direction;
68 struct MockPropagatorState {
70 bool targetReached =
false;
73 MockStepperState stepping;
77 template <
typename SurfaceSelector>
83 using InteractorResult =
typename Interactor::result_type;
86 std::shared_ptr<Acts::Surface>
surface;
87 Interactor interactor;
88 InteractorResult result;
89 MockPropagatorState state;
92 Fixture(
double energyLoss, std::shared_ptr<Acts::Surface> surface_)
98 .setPosition4(1, 2, 3, 4)
99 .setDirection(1, 0, 0)
100 .setAbsMomentum(100);
102 interactor.physics.energyLoss = energyLoss;
104 state.navigation.currentSurface =
surface.get();
105 state.stepping.position = particle.
position();
106 state.stepping.time = particle.
time();
113 std::shared_ptr<Acts::Surface> makeEmptySurface() {
114 auto surface = Acts::Surface::makeShared<Acts::PlaneSurface>(
120 std::shared_ptr<Acts::Surface> makeMaterialSurface() {
121 auto surface = makeEmptySurface();
123 surface->assignSurfaceMaterial(
124 std::make_shared<Acts::HomogeneousSurfaceMaterial>(std::move(slab)));
130 BOOST_AUTO_TEST_SUITE(FatrasInteractor)
133 Fixture<EverySurface> f(0.5, makeEmptySurface());
136 f.interactor(f.state, f.stepper, f.result);
137 BOOST_CHECK_EQUAL(f.result.generatedParticles.size(), 0
u);
138 BOOST_CHECK_EQUAL(f.result.hits.size(), 1
u);
139 BOOST_CHECK_EQUAL(f.result.hits[0].index(), 0
u);
142 f.interactor(f.state, f.stepper, f.result);
143 BOOST_CHECK_EQUAL(f.result.generatedParticles.size(), 0
u);
144 BOOST_CHECK_EQUAL(f.result.hits.size(), 2
u);
145 BOOST_CHECK_EQUAL(f.result.hits[0].index(), 0
u);
146 BOOST_CHECK_EQUAL(f.result.hits[1].index(), 1
u);
149 BOOST_CHECK_EQUAL(f.result.particle.particleId(),
150 f.interactor.particle.particleId());
151 BOOST_CHECK_EQUAL(f.result.particle.process(),
152 f.interactor.particle.process());
153 BOOST_CHECK_EQUAL(f.result.particle.pdg(), f.interactor.particle.pdg());
154 BOOST_CHECK_EQUAL(f.result.particle.charge(), f.interactor.particle.charge());
155 BOOST_CHECK_EQUAL(f.result.particle.mass(), f.interactor.particle.mass());
157 CHECK_CLOSE_REL(f.result.particle.energy(), f.interactor.particle.energy(),
162 Fixture<EverySurface> f(0.5, makeMaterialSurface());
165 f.interactor(f.state, f.stepper, f.result);
166 BOOST_CHECK_EQUAL(f.result.generatedParticles.size(), 1
u);
167 BOOST_CHECK_EQUAL(f.result.hits.size(), 1
u);
168 BOOST_CHECK_EQUAL(f.result.hits[0].index(), 0
u);
171 f.interactor(f.state, f.stepper, f.result);
172 BOOST_CHECK_EQUAL(f.result.generatedParticles.size(), 2
u);
173 BOOST_CHECK_EQUAL(f.result.hits.size(), 2
u);
174 BOOST_CHECK_EQUAL(f.result.hits[0].index(), 0
u);
175 BOOST_CHECK_EQUAL(f.result.hits[1].index(), 1
u);
178 BOOST_CHECK_EQUAL(f.result.particle.particleId(),
179 f.interactor.particle.particleId());
180 BOOST_CHECK_EQUAL(f.result.particle.process(),
181 f.interactor.particle.process());
182 BOOST_CHECK_EQUAL(f.result.particle.pdg(), f.interactor.particle.pdg());
183 BOOST_CHECK_EQUAL(f.result.particle.charge(), f.interactor.particle.charge());
184 BOOST_CHECK_EQUAL(f.result.particle.mass(), f.interactor.particle.mass());
187 f.interactor.particle.energy(),
eps);
191 Fixture<NoSurface> f(0.5, makeEmptySurface());
194 f.interactor(f.state, f.stepper, f.result);
195 BOOST_CHECK_EQUAL(f.result.generatedParticles.size(), 0
u);
196 BOOST_CHECK_EQUAL(f.result.hits.size(), 0
u);
199 f.interactor(f.state, f.stepper, f.result);
200 BOOST_CHECK_EQUAL(f.result.generatedParticles.size(), 0
u);
201 BOOST_CHECK_EQUAL(f.result.hits.size(), 0
u);
204 BOOST_CHECK_EQUAL(f.result.particle.particleId(),
205 f.interactor.particle.particleId());
206 BOOST_CHECK_EQUAL(f.result.particle.process(),
207 f.interactor.particle.process());
208 BOOST_CHECK_EQUAL(f.result.particle.pdg(), f.interactor.particle.pdg());
209 BOOST_CHECK_EQUAL(f.result.particle.charge(), f.interactor.particle.charge());
210 BOOST_CHECK_EQUAL(f.result.particle.mass(), f.interactor.particle.mass());
212 CHECK_CLOSE_REL(f.result.particle.energy(), f.interactor.particle.energy(),
217 Fixture<NoSurface> f(0.5, makeMaterialSurface());
220 f.interactor(f.state, f.stepper, f.result);
221 BOOST_CHECK_EQUAL(f.result.generatedParticles.size(), 1
u);
222 BOOST_CHECK_EQUAL(f.result.hits.size(), 0
u);
225 f.interactor(f.state, f.stepper, f.result);
226 BOOST_CHECK_EQUAL(f.result.generatedParticles.size(), 2
u);
227 BOOST_CHECK_EQUAL(f.result.hits.size(), 0
u);
230 BOOST_CHECK_EQUAL(f.result.particle.particleId(),
231 f.interactor.particle.particleId());
232 BOOST_CHECK_EQUAL(f.result.particle.process(),
233 f.interactor.particle.process());
234 BOOST_CHECK_EQUAL(f.result.particle.pdg(), f.interactor.particle.pdg());
235 BOOST_CHECK_EQUAL(f.result.particle.charge(), f.interactor.particle.charge());
236 BOOST_CHECK_EQUAL(f.result.particle.mass(), f.interactor.particle.mass());
239 f.interactor.particle.energy(),
eps);
242 BOOST_AUTO_TEST_SUITE_END()