9 #include <boost/test/unit_test.hpp>
21 using namespace ActsFatras;
26 struct MockPhysicsList {
27 double energyLoss = 0;
29 template <
typename generator_t>
32 generated.push_back(particle);
39 struct MockStepperState {
40 using Scalar = double;
50 using Scalar = MockStepperState::Scalar;
51 using Vector3 = MockStepperState::Vector3;
53 auto position(MockStepperState &state)
const {
return state.position; }
54 auto time(MockStepperState &state)
const {
return state.time; }
55 auto direction(MockStepperState &state)
const {
return state.direction; }
56 auto momentum(MockStepperState &state)
const {
return state.momentum; }
58 const Vector3 &direction, Scalar
momentum, Scalar
time) {
61 state.direction = direction;
66 struct MockPropagatorState {
68 bool targetReached =
false;
71 MockStepperState stepping;
75 template <
typename SurfaceSelector>
83 std::shared_ptr<Acts::Surface>
surface;
86 MockPropagatorState state;
89 Fixture(
double energyLoss, std::shared_ptr<Acts::Surface> surface_)
99 interactor.physics.energyLoss = energyLoss;
101 state.navigation.currentSurface =
surface.get();
102 state.stepping.position = particle.
position();
103 state.stepping.time = particle.
time();
110 std::shared_ptr<Acts::Surface> makeEmptySurface() {
111 auto surface = Acts::Surface::makeShared<Acts::PlaneSurface>(
117 std::shared_ptr<Acts::Surface> makeMaterialSurface() {
118 auto surface = makeEmptySurface();
120 surface->assignSurfaceMaterial(
121 std::make_shared<Acts::HomogeneousSurfaceMaterial>(std::move(slab)));
126 BOOST_AUTO_TEST_SUITE(FatrasInteractor)
129 Fixture<EverySurface>
f(0.5, makeEmptySurface());
132 f.interactor(f.state, f.stepper, f.result);
133 BOOST_TEST(f.result.generatedParticles.size() == 0
u);
134 BOOST_TEST(f.result.hits.size() == 1
u);
135 BOOST_TEST(f.result.hits[0].index() == 0
u);
138 f.interactor(f.state, f.stepper, f.result);
139 BOOST_TEST(f.result.generatedParticles.size() == 0
u);
140 BOOST_TEST(f.result.hits.size() == 2
u);
141 BOOST_TEST(f.result.hits[0].index() == 0
u);
142 BOOST_TEST(f.result.hits[1].index() == 1
u);
145 BOOST_TEST(f.result.particle.particleId() ==
146 f.interactor.particle.particleId());
147 BOOST_TEST(f.result.particle.process() == f.interactor.particle.process());
148 BOOST_TEST(f.result.particle.pdg() == f.interactor.particle.pdg());
149 BOOST_TEST(f.result.particle.charge() == f.interactor.particle.charge());
150 BOOST_TEST(f.result.particle.mass() == f.interactor.particle.mass());
152 CHECK_CLOSE_REL(f.result.particle.energy(), f.interactor.particle.energy(),
157 Fixture<EverySurface>
f(0.5, makeMaterialSurface());
160 f.interactor(f.state, f.stepper, f.result);
161 BOOST_TEST(f.result.generatedParticles.size() == 1
u);
162 BOOST_TEST(f.result.hits.size() == 1
u);
163 BOOST_TEST(f.result.hits[0].index() == 0
u);
166 f.interactor(f.state, f.stepper, f.result);
167 BOOST_TEST(f.result.generatedParticles.size() == 2
u);
168 BOOST_TEST(f.result.hits.size() == 2
u);
169 BOOST_TEST(f.result.hits[0].index() == 0
u);
170 BOOST_TEST(f.result.hits[1].index() == 1
u);
173 BOOST_TEST(f.result.particle.particleId() ==
174 f.interactor.particle.particleId());
175 BOOST_TEST(f.result.particle.process() == f.interactor.particle.process());
176 BOOST_TEST(f.result.particle.pdg() == f.interactor.particle.pdg());
177 BOOST_TEST(f.result.particle.charge() == f.interactor.particle.charge());
178 BOOST_TEST(f.result.particle.mass() == f.interactor.particle.mass());
181 f.interactor.particle.energy(),
eps);
185 Fixture<NoSurface>
f(0.5, makeEmptySurface());
188 f.interactor(f.state, f.stepper, f.result);
189 BOOST_TEST(f.result.generatedParticles.size() == 0
u);
190 BOOST_TEST(f.result.hits.size() == 0
u);
193 f.interactor(f.state, f.stepper, f.result);
194 BOOST_TEST(f.result.generatedParticles.size() == 0
u);
195 BOOST_TEST(f.result.hits.size() == 0
u);
198 BOOST_TEST(f.result.particle.particleId() ==
199 f.interactor.particle.particleId());
200 BOOST_TEST(f.result.particle.process() == f.interactor.particle.process());
201 BOOST_TEST(f.result.particle.pdg() == f.interactor.particle.pdg());
202 BOOST_TEST(f.result.particle.charge() == f.interactor.particle.charge());
203 BOOST_TEST(f.result.particle.mass() == f.interactor.particle.mass());
205 CHECK_CLOSE_REL(f.result.particle.energy(), f.interactor.particle.energy(),
210 Fixture<NoSurface>
f(0.5, makeMaterialSurface());
213 f.interactor(f.state, f.stepper, f.result);
214 BOOST_TEST(f.result.generatedParticles.size() == 1
u);
215 BOOST_TEST(f.result.hits.size() == 0
u);
218 f.interactor(f.state, f.stepper, f.result);
219 BOOST_TEST(f.result.generatedParticles.size() == 2
u);
220 BOOST_TEST(f.result.hits.size() == 0
u);
223 BOOST_TEST(f.result.particle.particleId() ==
224 f.interactor.particle.particleId());
225 BOOST_TEST(f.result.particle.process() == f.interactor.particle.process());
226 BOOST_TEST(f.result.particle.pdg() == f.interactor.particle.pdg());
227 BOOST_TEST(f.result.particle.charge() == f.interactor.particle.charge());
228 BOOST_TEST(f.result.particle.mass() == f.interactor.particle.mass());
231 f.interactor.particle.energy(),
eps);
234 BOOST_AUTO_TEST_SUITE_END()