diff --git a/Tests/UnitTests/Core/Propagator/AtlasStepperTests.cpp b/Tests/UnitTests/Core/Propagator/AtlasStepperTests.cpp index dacff8b837d..a05aad48f21 100644 --- a/Tests/UnitTests/Core/Propagator/AtlasStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/AtlasStepperTests.cpp @@ -98,16 +98,19 @@ static const Covariance cov = Covariance::Identity(); static const GeometryContext geoCtx; static const MagneticFieldContext magCtx; -static const Stepper::Options options(geoCtx, magCtx); - BOOST_AUTO_TEST_SUITE(AtlasStepper) // test state construction from parameters w/o covariance BOOST_AUTO_TEST_CASE(ConstructState) { - Stepper::State state( - options, magneticField->makeCache(magCtx), - CurvilinearTrackParameters(pos4, unitDir, charge / absMom, std::nullopt, - particleHypothesis)); + CurvilinearTrackParameters cp(pos4, unitDir, charge / absMom, std::nullopt, + particleHypothesis); + + Stepper stepper(magneticField); + + Stepper::Options options(geoCtx, magCtx); + options.maxStepSize = stepSize; + + Stepper::State state = stepper.makeState(options, cp); BOOST_CHECK(!state.covTransport); BOOST_CHECK_EQUAL(state.covariance, nullptr); @@ -126,10 +129,15 @@ BOOST_AUTO_TEST_CASE(ConstructState) { // test state construction from parameters w/ covariance BOOST_AUTO_TEST_CASE(ConstructStateWithCovariance) { - Stepper::State state( - options, magneticField->makeCache(magCtx), - CurvilinearTrackParameters(pos4, unitDir, charge / absMom, cov, - particleHypothesis)); + CurvilinearTrackParameters cp(pos4, unitDir, charge / absMom, cov, + particleHypothesis); + + Stepper stepper(magneticField); + + Stepper::Options options(geoCtx, magCtx); + options.maxStepSize = stepSize; + + Stepper::State state = stepper.makeState(options, cp); BOOST_CHECK(state.covTransport); BOOST_CHECK_EQUAL(*state.covariance, cov); @@ -148,11 +156,15 @@ BOOST_AUTO_TEST_CASE(ConstructStateWithCovariance) { // test stepper getters for particle state BOOST_AUTO_TEST_CASE(Getters) { + CurvilinearTrackParameters cp(pos4, unitDir, charge / absMom, cov, + particleHypothesis); + Stepper stepper(magneticField); - Stepper::State state( - options, magneticField->makeCache(magCtx), - CurvilinearTrackParameters(pos4, unitDir, charge / absMom, cov, - particleHypothesis)); + + Stepper::Options options(geoCtx, magCtx); + options.maxStepSize = stepSize; + + Stepper::State state = stepper.makeState(options, cp); CHECK_CLOSE_ABS(stepper.position(state), pos, eps); CHECK_CLOSE_ABS(stepper.time(state), time, eps); @@ -163,11 +175,15 @@ BOOST_AUTO_TEST_CASE(Getters) { // test stepper update methods with bound state as input BOOST_AUTO_TEST_CASE(UpdateFromBound) { + CurvilinearTrackParameters cp(pos4, unitDir, charge / absMom, cov, + particleHypothesis); + Stepper stepper(magneticField); - Stepper::State state( - options, magneticField->makeCache(magCtx), - CurvilinearTrackParameters(pos4, unitDir, charge / absMom, cov, - particleHypothesis)); + + Stepper::Options options(geoCtx, magCtx); + options.maxStepSize = stepSize; + + Stepper::State state = stepper.makeState(options, cp); auto newPos4 = (pos4 + Vector4(1_mm, 2_mm, 3_mm, 20_ns)).eval(); auto newPos = newPos4.segment<3>(ePos0); @@ -206,11 +222,15 @@ BOOST_AUTO_TEST_CASE(UpdateFromBound) { // test stepper update methods with individual components as input BOOST_AUTO_TEST_CASE(UpdateFromComponents) { + CurvilinearTrackParameters cp(pos4, unitDir, charge / absMom, cov, + particleHypothesis); + Stepper stepper(magneticField); - Stepper::State state( - options, magneticField->makeCache(magCtx), - CurvilinearTrackParameters(pos4, unitDir, charge / absMom, cov, - particleHypothesis)); + + Stepper::Options options(geoCtx, magCtx); + options.maxStepSize = stepSize; + + Stepper::State state = stepper.makeState(options, cp); auto newPos = (pos + Vector3(1_mm, 2_mm, 3_mm)).eval(); auto newTime = time + 20_ns; @@ -227,11 +247,16 @@ BOOST_AUTO_TEST_CASE(UpdateFromComponents) { // test building a bound state object from the stepper state BOOST_AUTO_TEST_CASE(BuildBound) { + CurvilinearTrackParameters cp(pos4, unitDir, charge / absMom, cov, + particleHypothesis); + Stepper stepper(magneticField); - Stepper::State state( - options, magneticField->makeCache(magCtx), - CurvilinearTrackParameters(pos4, unitDir, charge / absMom, cov, - particleHypothesis)); + + Stepper::Options options(geoCtx, magCtx); + options.maxStepSize = stepSize; + + Stepper::State state = stepper.makeState(options, cp); + // example surface at the current state position auto plane = CurvilinearSurface(pos, unitDir).planeSurface(); @@ -251,11 +276,15 @@ BOOST_AUTO_TEST_CASE(BuildBound) { // test building a curvilinear state object from the stepper state BOOST_AUTO_TEST_CASE(BuildCurvilinear) { + CurvilinearTrackParameters cp(pos4, unitDir, charge / absMom, cov, + particleHypothesis); + Stepper stepper(magneticField); - Stepper::State state( - options, magneticField->makeCache(magCtx), - CurvilinearTrackParameters(pos4, unitDir, charge / absMom, cov, - particleHypothesis)); + + Stepper::Options options(geoCtx, magCtx); + options.maxStepSize = stepSize; + + Stepper::State state = stepper.makeState(options, cp); auto&& [pars, jac, pathLength] = stepper.curvilinearState(state); // check parameters @@ -273,11 +302,15 @@ BOOST_AUTO_TEST_CASE(BuildCurvilinear) { // test step method without covariance transport BOOST_AUTO_TEST_CASE(Step) { + CurvilinearTrackParameters cp(pos4, unitDir, charge / absMom, cov, + particleHypothesis); + Stepper stepper(magneticField); - MockPropagatorState state( - Stepper::State(options, magneticField->makeCache(magCtx), - CurvilinearTrackParameters(pos4, unitDir, charge / absMom, - cov, particleHypothesis))); + + Stepper::Options options(geoCtx, magCtx); + options.maxStepSize = stepSize; + + MockPropagatorState state(stepper.makeState(options, cp)); state.stepping.covTransport = false; // ensure step does not result in an error @@ -306,11 +339,15 @@ BOOST_AUTO_TEST_CASE(Step) { // test step method with covariance transport BOOST_AUTO_TEST_CASE(StepWithCovariance) { + CurvilinearTrackParameters cp(pos4, unitDir, charge / absMom, cov, + particleHypothesis); + Stepper stepper(magneticField); - MockPropagatorState state( - Stepper::State(options, magneticField->makeCache(magCtx), - CurvilinearTrackParameters(pos4, unitDir, charge / absMom, - cov, particleHypothesis))); + + Stepper::Options options(geoCtx, magCtx); + options.maxStepSize = stepSize; + + MockPropagatorState state(stepper.makeState(options, cp)); state.stepping.covTransport = true; // ensure step does not result in an error @@ -342,11 +379,15 @@ BOOST_AUTO_TEST_CASE(StepWithCovariance) { // test state reset method BOOST_AUTO_TEST_CASE(Reset) { + CurvilinearTrackParameters cp(pos4, unitDir, charge / absMom, cov, + particleHypothesis); + Stepper stepper(magneticField); - MockPropagatorState state( - Stepper::State(options, magneticField->makeCache(magCtx), - CurvilinearTrackParameters(pos4, unitDir, charge / absMom, - cov, particleHypothesis))); + + Stepper::Options options(geoCtx, magCtx); + options.maxStepSize = stepSize; + + MockPropagatorState state(stepper.makeState(options, cp)); state.stepping.covTransport = true; // ensure step does not result in an error @@ -358,9 +399,9 @@ BOOST_AUTO_TEST_CASE(Reset) { double newTime = 7.5; double newCharge = 1.; BoundSquareMatrix newCov = 8.5 * Covariance::Identity(); - CurvilinearTrackParameters cp(makeVector4(newPos, newTime), unitDir, - newCharge / newAbsMom, newCov, - particleHypothesis); + cp = CurvilinearTrackParameters(makeVector4(newPos, newTime), unitDir, + newCharge / newAbsMom, newCov, + particleHypothesis); FreeVector freeParams = transformBoundToFreeParameters( cp.referenceSurface(), geoCtx, cp.parameters()); Direction navDir = Direction::Forward; @@ -402,7 +443,7 @@ BOOST_AUTO_TEST_CASE(Reset) { }; // Reset all possible parameters - Stepper::State stateCopy(copyState(*magneticField, state.stepping)); + Stepper::State stateCopy = copyState(*magneticField, state.stepping); BOOST_CHECK(cp.covariance().has_value()); stepper.resetState(stateCopy, cp.parameters(), *cp.covariance(), cp.referenceSurface(), stepSize); @@ -534,11 +575,15 @@ BOOST_AUTO_TEST_CASE(Reset) { } BOOST_AUTO_TEST_CASE(StepSize) { + CurvilinearTrackParameters cp(pos4, unitDir, charge / absMom, cov, + particleHypothesis); + Stepper stepper(magneticField); - Stepper::State state( - options, magneticField->makeCache(magCtx), - CurvilinearTrackParameters(pos4, unitDir, charge / absMom, cov, - particleHypothesis)); + + Stepper::Options options(geoCtx, magCtx); + options.maxStepSize = stepSize; + + Stepper::State state = stepper.makeState(options, cp); stepper.updateStepSize(state, -5_cm, ConstrainedStep::navigator, true); BOOST_CHECK_EQUAL(state.previousStepSize, stepSize); @@ -550,11 +595,15 @@ BOOST_AUTO_TEST_CASE(StepSize) { // test step size modification with target surfaces BOOST_AUTO_TEST_CASE(StepSizeSurface) { + CurvilinearTrackParameters cp(pos4, unitDir, charge / absMom, cov, + particleHypothesis); + Stepper stepper(magneticField); - Stepper::State state( - options, magneticField->makeCache(magCtx), - CurvilinearTrackParameters(pos4, unitDir, charge / absMom, cov, - particleHypothesis)); + + Stepper::Options options(geoCtx, magCtx); + options.maxStepSize = stepSize; + + Stepper::State state = stepper.makeState(options, cp); auto distance = 10_mm; auto target = CurvilinearSurface(pos + navDir * distance * unitDir, unitDir) diff --git a/Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp b/Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp index d2e6e63952a..cbb9b701d28 100644 --- a/Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp @@ -188,13 +188,13 @@ BOOST_AUTO_TEST_CASE(eigen_stepper_state_test) { double absMom = 8.; double charge = -1.; + EigenStepper<>::Options esOptions(tgContext, mfContext); + // Test charged parameters without covariance matrix CurvilinearTrackParameters cp(makeVector4(pos, time), dir, charge / absMom, std::nullopt, ParticleHypothesis::pion()); - EigenStepper<>::State esState(EigenStepper<>::Options(tgContext, mfContext), - bField->makeCache(mfContext), cp); - EigenStepper<> es(bField); + EigenStepper<>::State esState = es.makeState(esOptions, cp); // Test the result & compare with the input/test for reasonable members BOOST_CHECK_EQUAL(esState.jacToGlobal, BoundToFreeMatrix::Zero()); @@ -208,16 +208,15 @@ BOOST_AUTO_TEST_CASE(eigen_stepper_state_test) { // Test without charge and covariance matrix CurvilinearTrackParameters ncp(makeVector4(pos, time), dir, 1 / absMom, std::nullopt, ParticleHypothesis::pion0()); - esState = EigenStepper<>::State(EigenStepper<>::Options(tgContext, mfContext), - bField->makeCache(mfContext), ncp); + esOptions = EigenStepper<>::Options(tgContext, mfContext); + esState = es.makeState(esOptions, ncp); BOOST_CHECK_EQUAL(es.charge(esState), 0.); // Test with covariance matrix Covariance cov = 8. * Covariance::Identity(); ncp = CurvilinearTrackParameters(makeVector4(pos, time), dir, 1 / absMom, cov, ParticleHypothesis::pion0()); - esState = EigenStepper<>::State(EigenStepper<>::Options(tgContext, mfContext), - bField->makeCache(mfContext), ncp); + esState = es.makeState(esOptions, ncp); BOOST_CHECK_NE(esState.jacToGlobal, BoundToFreeMatrix::Zero()); BOOST_CHECK(esState.covTransport); BOOST_CHECK_EQUAL(esState.cov, cov); @@ -242,12 +241,12 @@ BOOST_AUTO_TEST_CASE(eigen_stepper_test) { CurvilinearTrackParameters cp(makeVector4(pos, time), dir, charge / absMom, cov, ParticleHypothesis::pion()); - EigenStepper<>::Options options(tgContext, mfContext); - options.maxStepSize = stepSize; + EigenStepper<>::Options esOptions(tgContext, mfContext); + esOptions.maxStepSize = stepSize; - // Build the state and the stepper - EigenStepper<>::State esState(options, bField->makeCache(mfContext), cp); + // Build the stepper and the state EigenStepper<> es(bField); + EigenStepper<>::State esState = es.makeState(esOptions, cp); // Test the getters CHECK_CLOSE_ABS(es.position(esState), pos, eps); @@ -369,7 +368,7 @@ BOOST_AUTO_TEST_CASE(eigen_stepper_test) { }; // Reset all possible parameters - EigenStepper<>::State esStateCopy(copyState(*bField, ps.stepping)); + EigenStepper<>::State esStateCopy = copyState(*bField, ps.stepping); BOOST_CHECK(cp2.covariance().has_value()); es.resetState(esStateCopy, cp2.parameters(), *cp2.covariance(), cp2.referenceSurface(), stepSize2); @@ -446,8 +445,7 @@ BOOST_AUTO_TEST_CASE(eigen_stepper_test) { plane, tgContext, makeVector4(pos, time), dir, charge / absMom, cov, ParticleHypothesis::pion()) .value(); - esState = EigenStepper<>::State(EigenStepper<>::Options(tgContext, mfContext), - bField->makeCache(mfContext), cp); + esState = es.makeState(esOptions, bp); // Test the intersection in the context of a surface auto targetSurface = @@ -519,8 +517,8 @@ BOOST_AUTO_TEST_CASE(eigen_stepper_test) { // Produce some errors auto nBfield = std::make_shared(); EigenStepper<> nes(nBfield); - EigenStepper<>::State nesState(EigenStepper<>::Options(tgContext, mfContext), - nBfield->makeCache(mfContext), cp); + EigenStepper<>::Options nesOptions(tgContext, mfContext); + EigenStepper<>::State nesState = nes.makeState(nesOptions, cp); PropState nps(navDir, copyState(*nBfield, nesState)); // Test that we can reach the minimum step size nps.options.stepping.stepTolerance = 1e-21; diff --git a/Tests/UnitTests/Core/Propagator/StraightLineStepperTests.cpp b/Tests/UnitTests/Core/Propagator/StraightLineStepperTests.cpp index d6d8694087b..c66847912b2 100644 --- a/Tests/UnitTests/Core/Propagator/StraightLineStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/StraightLineStepperTests.cpp @@ -73,15 +73,15 @@ BOOST_AUTO_TEST_CASE(straight_line_stepper_state_test) { double absMom = 8.; double charge = -1.; - StraightLineStepper::Options options(tgContext, mfContext); - options.maxStepSize = stepSize; + StraightLineStepper::Options slsOptions(tgContext, mfContext); + slsOptions.maxStepSize = stepSize; // Test charged parameters without covariance matrix CurvilinearTrackParameters cp(makeVector4(pos, time), dir, charge / absMom, std::nullopt, ParticleHypothesis::pion()); - StraightLineStepper::State slsState(options, cp); StraightLineStepper sls; + StraightLineStepper::State slsState = sls.makeState(slsOptions, cp); // Test the result & compare with the input/test for reasonable members BOOST_CHECK_EQUAL(slsState.jacToGlobal, BoundToFreeMatrix::Zero()); @@ -101,15 +101,13 @@ BOOST_AUTO_TEST_CASE(straight_line_stepper_state_test) { // Test without charge and covariance matrix CurvilinearTrackParameters ncp(makeVector4(pos, time), dir, 1 / absMom, std::nullopt, ParticleHypothesis::pion0()); - slsState = StraightLineStepper::State( - StraightLineStepper::Options(tgContext, mfContext), ncp); + slsState = sls.makeState(slsOptions, ncp); // Test with covariance matrix Covariance cov = 8. * Covariance::Identity(); ncp = CurvilinearTrackParameters(makeVector4(pos, time), dir, 1 / absMom, cov, ParticleHypothesis::pion0()); - slsState = StraightLineStepper::State( - StraightLineStepper::Options(tgContext, mfContext), ncp); + slsState = sls.makeState(slsOptions, ncp); BOOST_CHECK_NE(slsState.jacToGlobal, BoundToFreeMatrix::Zero()); BOOST_CHECK(slsState.covTransport); BOOST_CHECK_EQUAL(slsState.cov, cov); diff --git a/Tests/UnitTests/Core/Propagator/SympyStepperTests.cpp b/Tests/UnitTests/Core/Propagator/SympyStepperTests.cpp index d6f0a2adaef..47abcef87e0 100644 --- a/Tests/UnitTests/Core/Propagator/SympyStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/SympyStepperTests.cpp @@ -216,10 +216,12 @@ BOOST_AUTO_TEST_CASE(sympy_stepper_test) { CurvilinearTrackParameters cp(makeVector4(pos, time), dir, charge / absMom, cov, ParticleHypothesis::pion()); - // Build the state and the stepper - SympyStepper::State esState(SympyStepper::Options(tgContext, mfContext), - bField->makeCache(mfContext), cp); + SympyStepper::Options esOptions(tgContext, mfContext); + esOptions.maxStepSize = stepSize; + + // Build the stepper and the state SympyStepper es(bField); + SympyStepper::State esState = es.makeState(esOptions, cp); // Test the getters CHECK_CLOSE_ABS(es.position(esState), pos, eps); @@ -338,7 +340,7 @@ BOOST_AUTO_TEST_CASE(sympy_stepper_test) { }; // Reset all possible parameters - SympyStepper::State esStateCopy(copyState(*bField, ps.stepping)); + SympyStepper::State esStateCopy = copyState(*bField, ps.stepping); BOOST_CHECK(cp2.covariance().has_value()); es.resetState(esStateCopy, cp2.parameters(), *cp2.covariance(), cp2.referenceSurface(), stepSize2); @@ -415,8 +417,8 @@ BOOST_AUTO_TEST_CASE(sympy_stepper_test) { plane, tgContext, makeVector4(pos, time), dir, charge / absMom, cov, ParticleHypothesis::pion()) .value(); - esState = SympyStepper::State(SympyStepper::Options(tgContext, mfContext), - bField->makeCache(mfContext), cp); + esOptions = SympyStepper::Options(tgContext, mfContext); + esState = es.makeState(esOptions, bp); // Test the intersection in the context of a surface auto targetSurface =