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