ECCE @ EIC 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-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 #include "Dataset.hpp"
14 
15 namespace {
16 const auto& backward = Dataset::backwardPion;
17 const auto& central = Dataset::centralPion;
18 const auto& forward = Dataset::forwardPion;
19 
20 // mock-ups for input objects (particles)
21 
22 struct Object {
23  int feature = 0;
24  std::string name = "";
25 };
26 
28 struct FeatureSelector {
29  int select_on = 0;
30 
31  bool operator()(const Object& object) const {
32  return object.feature == select_on;
33  }
34 };
35 
37 struct NameSelector {
38  std::string select_on = "";
39 
40  bool operator()(const Object& object) const {
41  return object.name == select_on;
42  }
43 };
44 
45 struct CombineFixture {
46  FeatureSelector selectObjectFeature = {1};
47  NameSelector selectObjectName = {"same_name"};
48  Object obj = {1, "same_name"};
49  Object objWrongFeature = {2, "same_name"};
50  Object objWrongName = {1, "another_name"};
51 };
52 
53 } // namespace
54 
55 BOOST_AUTO_TEST_SUITE(FatrasSelectorHelpers)
56 
58  // require a minimum eta value of 0.5
60  BOOST_TEST(not minEta(backward));
61  BOOST_TEST(not minEta(central));
62  BOOST_TEST(minEta(forward));
63 
64  // require a mininum absolute eta value of 0.5
66  BOOST_TEST(minAbsEta(backward));
67  BOOST_TEST(not minAbsEta(central));
68  BOOST_TEST(minAbsEta(forward));
69 }
70 
72  // require a maximum eta value of 0.5
74  BOOST_TEST(maxEta(backward));
75  BOOST_TEST(maxEta(central));
76  BOOST_TEST(not maxEta(forward));
77 
78  // require a maximum absolute eta value of 0.5
80  BOOST_TEST(not maxAbsEta(backward));
81  BOOST_TEST(maxAbsEta(central));
82  BOOST_TEST(not maxAbsEta(forward));
83 }
84 
86  ActsFatras::Range<ActsFatras::Casts::Eta> rangeEta{-6.0, -0.5};
87  BOOST_TEST(rangeEta(backward));
88  BOOST_TEST(not rangeEta(central));
89  BOOST_TEST(not rangeEta(forward));
90 
92  BOOST_TEST(rangeAbsEta(backward));
93  BOOST_TEST(not rangeAbsEta(central));
94  BOOST_TEST(rangeAbsEta(forward));
95 }
96 
98  CombineFixture f;
100  select.get<FeatureSelector>() = f.selectObjectFeature;
101  BOOST_TEST(select(f.obj));
102  BOOST_TEST(not select(f.objWrongFeature));
103  BOOST_TEST(select(f.objWrongName));
104 }
105 
107  CombineFixture f;
109  select.get<FeatureSelector>() = f.selectObjectFeature;
110  select.get<NameSelector>() = f.selectObjectName;
111  BOOST_TEST(select(f.obj));
112  BOOST_TEST(not select(f.objWrongFeature));
113  BOOST_TEST(not select(f.objWrongName));
114 }
115 
117  CombineFixture f;
119  select.get<FeatureSelector>() = f.selectObjectFeature;
120  BOOST_TEST(select(f.obj));
121  BOOST_TEST(not select(f.objWrongFeature));
122  BOOST_TEST(select(f.objWrongName));
123 }
124 
126  CombineFixture f;
128  select.get<FeatureSelector>() = f.selectObjectFeature;
129  select.get<NameSelector>() = f.selectObjectName;
130  BOOST_TEST(select(f.obj));
131  BOOST_TEST(select(f.objWrongFeature));
132  BOOST_TEST(select(f.objWrongName));
133 }
134 
135 BOOST_AUTO_TEST_SUITE_END()