Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SelectorHelpersTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SelectorHelpersTests.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 "Fatras/Selectors/SelectorHelpers.hpp"
24 #include "Particle.hpp"
25 
26 namespace bdata = boost::unit_test::data;
27 namespace tt = boost::test_tools;
28 
29 namespace Fatras {
30 
31 namespace Test {
32 
33 struct Detector {};
34 
35 double m_pion = 134.9766 * Acts::units::_MeV; // pi0 rest mass
36 
37 // This tests the implementation of kinematic cast operators
38 BOOST_AUTO_TEST_CASE(SelectorHelper_tests) {
39 
41 
42  Acts::Vector3D position(0., 0., 0.);
43  Acts::Vector3D momentumCast(1500. * Acts::units::_MeV, 0., 0.);
44 
45  // e central electron
46  Particle pionCast(position, momentumCast, m_pion, -1.);
47  Acts::Vector3D positionForward(0., 0., 100. * Acts::units::_mm);
48  Acts::Vector3D momentumForward(10. * Acts::units::_MeV,
49  10. * Acts::units::_MeV,
50  1500. * Acts::units::_MeV);
51 
52  Particle pionForward(positionForward, momentumForward, m_pion, -1.);
53 
54  Acts::Vector3D positionBackward(0., 0., 0.);
55  Acts::Vector3D momentumBackward(10. * Acts::units::_MeV,
56  10. * Acts::units::_MeV,
57  -1500. * Acts::units::_MeV);
58 
59  Particle pionBackward(positionBackward, momentumBackward, m_pion, -1.);
60 
61  // the list of possible casts
62  casts::eta etaCast;
63  casts::absEta etaAbsCast;
64 
65  // A minimum of 0.5 Eta is required
66  Min<casts::eta> minEta05;
67  minEta05.valMin = 0.5;
68 
69  Min<casts::absEta> minEtaAbs05;
70  minEtaAbs05.valMin = 0.5;
71 
72  // the central will fail both
73  BOOST_CHECK(!minEta05(detector, pionCast));
74  BOOST_CHECK(!minEtaAbs05(detector, pionCast));
75 
76  // the forward will satisfy both
77  BOOST_CHECK(minEta05(detector, pionForward));
78  BOOST_CHECK(minEtaAbs05(detector, pionForward));
79 
80  // A maximum of 0.5 Eta is required
81  Max<casts::eta> maxEta05;
82  maxEta05.valMax = 0.5;
83 
84  // the central will satisfy both
85  BOOST_CHECK(maxEta05(detector, pionCast));
86  BOOST_CHECK(maxEta05(detector, pionCast));
87 
88  // the forward will fail both
89  BOOST_CHECK(!maxEta05(detector, pionForward));
90  BOOST_CHECK(!maxEta05(detector, pionForward));
91 
92  // a range test
93  Range<casts::eta> rangeEtaM0;
94  rangeEtaM0.valMin = -6.;
95  rangeEtaM0.valMax = -0.5;
96 
97  Range<casts::absEta> rangeEtaM1;
98  rangeEtaM1.valMin = -6.;
99  rangeEtaM1.valMax = -0.5;
100 
101  // the central will fail both
102  BOOST_CHECK(!rangeEtaM0(detector, pionCast));
103  BOOST_CHECK(!rangeEtaM1(detector, pionCast));
104 
105  // the forward will fail both
106  BOOST_CHECK(!rangeEtaM0(detector, pionForward));
107  BOOST_CHECK(!rangeEtaM1(detector, pionForward));
108 
109  // the backeard will satsify the eta cast, not the abs(eta)
110  BOOST_CHECK(rangeEtaM0(detector, pionBackward));
111  BOOST_CHECK(!rangeEtaM1(detector, pionBackward));
112 }
113 
114 } // namespace Test
115 } // namespace Fatras