ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConstrainedStepTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ConstrainedStepTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2018 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
12 
14 
15 namespace bdata = boost::unit_test::data;
16 namespace tt = boost::test_tools;
17 
18 namespace Acts {
19 
20 namespace Test {
21 
22 // This tests the implementation of the AbortList
23 // and the standard aborters
24 BOOST_AUTO_TEST_CASE(ConstrainedStepTest) {
25  // forward stepping test
26  ConstrainedStep stepSize_p = 0.25;
27 
28  // All of the types should be 0.25 now
29  BOOST_CHECK_EQUAL(stepSize_p.values[ConstrainedStep::accuracy],
31  BOOST_CHECK_EQUAL(stepSize_p.values[ConstrainedStep::actor],
33  BOOST_CHECK_EQUAL(stepSize_p.values[ConstrainedStep::aborter],
35  BOOST_CHECK_EQUAL(stepSize_p.values[ConstrainedStep::user], 0.25);
36 
37  // Check the cast operation to double
38  BOOST_CHECK_EQUAL(stepSize_p, 0.25);
39 
40  // now we update the accuracy
41  stepSize_p.update(0.1, ConstrainedStep::accuracy);
42  BOOST_CHECK_EQUAL(stepSize_p, 0.1);
43 
44  // now we update the actor to smaller
45  stepSize_p.update(0.05, ConstrainedStep::actor);
46  BOOST_CHECK_EQUAL(stepSize_p, 0.05);
47  // we increase the actor, but do not release the step size
48  stepSize_p.update(0.15, ConstrainedStep::actor, false);
49  BOOST_CHECK_EQUAL(stepSize_p, 0.05);
50  // we increase the actor, but now DO release the step size
51  // it falls back to the accuracy
52  stepSize_p.update(0.15, ConstrainedStep::actor, true);
53  BOOST_CHECK_EQUAL(stepSize_p, 0.1);
54 
55  // now set two and update them
56  stepSize_p.update(0.05, ConstrainedStep::user);
57  stepSize_p.update(0.03, ConstrainedStep::accuracy);
58  BOOST_CHECK_EQUAL(stepSize_p, 0.03);
59 
60  // now we release the accuracy - to the highest available value
62  BOOST_CHECK_EQUAL(stepSize_p.values[ConstrainedStep::accuracy],
64  BOOST_CHECK_EQUAL(stepSize_p, 0.05);
65 
66  // backward stepping test
67  ConstrainedStep stepSize_n = -0.25;
68 
69  // All of the types should be 0.25 now
70  BOOST_CHECK_EQUAL(stepSize_n.values[ConstrainedStep::accuracy],
72  BOOST_CHECK_EQUAL(stepSize_n.values[ConstrainedStep::actor],
74  BOOST_CHECK_EQUAL(stepSize_n.values[ConstrainedStep::aborter],
76  BOOST_CHECK_EQUAL(stepSize_n.values[ConstrainedStep::user], -0.25);
77 
78  // Check the cast operation to double
79  BOOST_CHECK_EQUAL(stepSize_n, -0.25);
80 
81  // now we update the accuracy
82  stepSize_n.update(-0.1, ConstrainedStep::accuracy);
83  BOOST_CHECK_EQUAL(stepSize_n, -0.1);
84 
85  // now we update the actor to smaller
86  stepSize_n.update(-0.05, ConstrainedStep::actor);
87  BOOST_CHECK_EQUAL(stepSize_n, -0.05);
88  // we increase the actor and accuracy is smaller again, without reset
89  stepSize_n.update(-0.15, ConstrainedStep::actor, false);
90  BOOST_CHECK_EQUAL(stepSize_n, -0.05);
91  // we increase the actor and accuracy is smaller again, with reset
92  stepSize_n.update(-0.15, ConstrainedStep::actor, true);
93  BOOST_CHECK_EQUAL(stepSize_n, -0.1);
94 
95  // now set two and update them
96  stepSize_n.update(-0.05, ConstrainedStep::user);
97  stepSize_n.update(-0.03, ConstrainedStep::accuracy);
98  BOOST_CHECK_EQUAL(stepSize_n, -0.03);
99 
100  // now we release the accuracy - to the highest available value
102  BOOST_CHECK_EQUAL(stepSize_n.values[ConstrainedStep::accuracy],
104  BOOST_CHECK_EQUAL(stepSize_n, -0.05);
105 }
106 
107 } // namespace Test
108 } // namespace Acts