ECCE @ EIC 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-2020 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/unit_test.hpp>
10 
11 #include <limits>
12 
15 #include "Dataset.hpp"
16 
17 using namespace Acts::UnitLiterals;
18 using namespace ActsFatras::Casts;
19 
20 namespace {
21 // TODO why does this have to be so high to avoid failure in eta tests?
22 constexpr auto eps = 128 * std::numeric_limits<double>::epsilon();
23 } // namespace
24 
25 BOOST_AUTO_TEST_SUITE(FatrasKinematicCasts)
26 
27 BOOST_AUTO_TEST_CASE(BackwardParticle) {
28  const auto& particle = Dataset::backwardPion;
29 
31  CHECK_CLOSE_REL(Vz()(particle), -100_mm, eps);
33  CHECK_CLOSE_REL(Eta()(particle), -4.5, eps);
35  CHECK_CLOSE_REL(Pt()(particle), 1.5_GeV / std::cosh(4.5), eps);
37  // allow higher threshold to allow for potential mass term differences
38  CHECK_CLOSE_REL(E()(particle), std::hypot(1.5_GeV, 139.57018_MeV), 1e-7);
39 }
40 
41 BOOST_AUTO_TEST_CASE(CentralParticle) {
42  const auto& particle = Dataset::centralPion;
43 
51  // allow higher threshold to allow for potential mass term differences
52  CHECK_CLOSE_REL(E()(particle), std::hypot(1.5_GeV, 139.57018_MeV), 1e-7);
53 }
54 
55 BOOST_AUTO_TEST_CASE(ForwardParticle) {
56  const auto& particle = Dataset::forwardPion;
57 
61  CHECK_CLOSE_REL(Eta()(particle), 4.5, eps);
63  CHECK_CLOSE_REL(Pt()(particle), 1.5_GeV / std::cosh(4.5), eps);
65  // allow higher threshold to allow for potential mass term differences
66  CHECK_CLOSE_REL(E()(particle), std::hypot(1.5_GeV, 139.57018_MeV), 1e-7);
67 }
68 
69 BOOST_AUTO_TEST_SUITE_END()