Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:11:25

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2018 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/data/test_case.hpp>
0010 #include <boost/test/tools/output_test_stream.hpp>
0011 #include <boost/test/unit_test.hpp>
0012 
0013 #include "Acts/Propagator/ConstrainedStep.hpp"
0014 
0015 #include <limits>
0016 
0017 namespace Acts::Test {
0018 
0019 // This tests the implementation of the AbortList
0020 // and the standard aborters
0021 BOOST_AUTO_TEST_CASE(ConstrainedStepTest) {
0022   // forward stepping test
0023   ConstrainedStep stepSize_p(0.25);
0024 
0025   // All of the types should be 0.25 now
0026   BOOST_CHECK_EQUAL(stepSize_p.accuracy(), std::numeric_limits<double>::max());
0027   BOOST_CHECK_EQUAL(stepSize_p.value(ConstrainedStep::actor),
0028                     std::numeric_limits<double>::max());
0029   BOOST_CHECK_EQUAL(stepSize_p.value(ConstrainedStep::aborter),
0030                     std::numeric_limits<double>::max());
0031   BOOST_CHECK_EQUAL(stepSize_p.value(ConstrainedStep::user), 0.25);
0032 
0033   // Check the cast operation to double
0034   BOOST_CHECK_EQUAL(stepSize_p.value(), 0.25);
0035 
0036   // now we set the accuracy
0037   stepSize_p.setAccuracy(0.1);
0038   BOOST_CHECK_EQUAL(stepSize_p.value(), 0.1);
0039 
0040   // now we update the actor to smaller
0041   stepSize_p.update(0.05, ConstrainedStep::actor);
0042   BOOST_CHECK_EQUAL(stepSize_p.value(), 0.05);
0043   // we increase the actor, but do not release the step size
0044   stepSize_p.update(0.15, ConstrainedStep::actor, false);
0045   BOOST_CHECK_EQUAL(stepSize_p.value(), 0.05);
0046   // we increase the actor, but now DO release the step size
0047   // it falls back to the accuracy
0048   stepSize_p.update(0.15, ConstrainedStep::actor, true);
0049   BOOST_CHECK_EQUAL(stepSize_p.value(), 0.1);
0050 
0051   // now set two and update them
0052   stepSize_p.update(0.05, ConstrainedStep::user);
0053   stepSize_p.setAccuracy(0.03);
0054   BOOST_CHECK_EQUAL(stepSize_p.value(), 0.03);
0055 
0056   // now we release the accuracy - to the highest available value
0057   stepSize_p.releaseAccuracy();
0058   BOOST_CHECK_EQUAL(stepSize_p.accuracy(), std::numeric_limits<double>::max());
0059   BOOST_CHECK_EQUAL(stepSize_p.value(), 0.05);
0060 }
0061 
0062 }  // namespace Acts::Test