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