Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KinematicCastsTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file KinematicCastsTests.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 
10 #define BOOST_TEST_MODULE KinemtaicCast Tests
11 
12 #include <boost/test/included/unit_test.hpp>
13 // leave blank line
14 
15 #include <boost/test/data/test_case.hpp>
16 // leave blank line
17 
18 #include <boost/test/output_test_stream.hpp>
19 // leave blank line
20 
21 #include "Acts/Utilities/Units.hpp"
22 #include "Fatras/Selectors/KinematicCasts.hpp"
23 #include "Particle.hpp"
24 
25 namespace bdata = boost::unit_test::data;
26 namespace tt = boost::test_tools;
27 
28 namespace Fatras {
29 
30 namespace Test {
31 
32 double m = 134.9766 * Acts::units::_MeV;
33 
34 // This tests the implementation of kinematic cast operators
35 BOOST_AUTO_TEST_CASE(Kinematic_cast_tests) {
36 
37  // a central pion
38  Acts::Vector3D position(0., 0., 0.);
39  Acts::Vector3D momentumCentral(1500. * Acts::units::_MeV, 0., 0.);
40  Particle pionCentral(position, momentumCentral, m, -1.);
41 
42  // a forward pion
43  Acts::Vector3D positionFwd(0., 0., 100.);
44  Acts::Vector3D momentumFwd(10. * Acts::units::_MeV, 10. * Acts::units::_MeV,
45  1500. * Acts::units::_MeV);
46  Particle pionFwd(positionFwd, momentumFwd, m, -1.);
47 
48  // the list of possible casts
49  casts::eta eta_c;
50  casts::absEta absEta_c;
51  casts::pT pT_c;
52  casts::p p_c;
53  casts::E E_c;
54  casts::vR vR_c;
55  casts::vZ vZ_c;
56 
57  // test the central
58  BOOST_TEST(eta_c(pionCentral) == 0., tt::tolerance(1e-10));
59  BOOST_TEST(absEta_c(pionCentral) == 0., tt::tolerance(1e-10));
60  BOOST_TEST(pT_c(pionCentral), 1500. * Acts::units::_MeV);
61  BOOST_TEST(p_c(pionCentral), 1500. * Acts::units::_MeV);
62  BOOST_CHECK(E_c(pionCentral) > p_c(pionCentral));
63 
64  BOOST_CHECK_CLOSE(vR_c(pionCentral), 0., 10e-5);
65  BOOST_CHECK_CLOSE(vZ_c(pionCentral), 0., 10e-5);
66 
67  // test the forward
68  BOOST_CHECK(eta_c(pionFwd) > eta_c(pionCentral));
69  BOOST_TEST(vZ_c(pionFwd), 100. * Acts::units::_MeV);
70 }
71 
72 } // namespace Test
73 } // namespace Fatras