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