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