ATLAS Offline Software
JetGroupReducerTest.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 #include "gtest/gtest.h"
10 #include <vector>
11 #include <map>
12 
13 using res = std::pair<std::vector<unsigned int>, bool>;
14 using vec = std::vector<unsigned int>;
15 
16 TEST(JetGroupReducerTester, empty) {
17  std::vector<std::size_t> siblings;
18  CondInd2JetGroupsInds satisfiedBy;
19  JetGroupInd2ElemInds jg2elem;
20 
21  auto collector = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr);
22 
23  JetGroupReducer jgr(siblings, satisfiedBy, jg2elem);
24 
25  EXPECT_TRUE(jgr.valid());
26  EXPECT_TRUE(jgr.next(collector).empty());
27 }
28 
29 TEST(JetGroupReducerTester, emptyCondition) {
30  std::vector<std::size_t> siblings{1, 2, 3};
31  CondInd2JetGroupsInds satisfiedBy;
32  satisfiedBy[0] = std::vector<std::size_t> {0, 1, 2};
33  satisfiedBy[1] = std::vector<std::size_t> {};
34  satisfiedBy[2] = std::vector<std::size_t> {3, 4, 5};
35  JetGroupInd2ElemInds jg2elem;
36 
37 
38 
39  auto collector = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr);
40 
41  JetGroupReducer jgr(siblings, satisfiedBy, jg2elem);
42 
43  EXPECT_TRUE(jgr.valid());
44  EXPECT_TRUE(jgr.next(collector).empty());
45 }
46 
47 
48 TEST(JetGroupReducerTester, one_condition_elem) {
49 
50  // condition is satisfied by an elementary jet group
51  std::vector<std::size_t> siblings{1};
52 
53  CondInd2JetGroupsInds satisfiedBy;
54  satisfiedBy[1] = std::vector<std::size_t> {0};
55  JetGroupInd2ElemInds jg2elem;
56  jg2elem[0] = std::vector<std::size_t> {0};
57  jg2elem[1] = std::vector<std::size_t> {1};
58  jg2elem[2] = std::vector<std::size_t> {0, 1};
59 
60 
61  auto collector = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr);
62 
63  JetGroupReducer jgr(siblings, satisfiedBy, jg2elem);
64 
65  auto exp = std::vector<std::size_t>{0};
66  EXPECT_EQ(jgr.next(collector), exp);
67  EXPECT_TRUE(jgr.next(collector).empty());
68 }
69 
70 
71 TEST(JetGroupReducerTester, one_condition_non_elem) {
72 
73  // condition is satisfied by an non-elementary jet group
74  std::vector<std::size_t> siblings{1};
75 
76  CondInd2JetGroupsInds satisfiedBy;
77  satisfiedBy[1] = std::vector<std::size_t> {2};
78  JetGroupInd2ElemInds jg2elem;
79  jg2elem[0] = std::vector<std::size_t> {0};
80  jg2elem[1] = std::vector<std::size_t> {1};
81  jg2elem[2] = std::vector<std::size_t> {0, 1};
82 
83 
84  auto collector = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr);
85 
86  JetGroupReducer jgr(siblings, satisfiedBy, jg2elem);
87 
88  auto exp = std::vector<std::size_t>{0, 1};
89  EXPECT_EQ(jgr.next(collector), exp);
90  EXPECT_TRUE(jgr.next(collector).empty());
91 }
92 
93 TEST(JetGroupReducerTester, two_conditions_nooverlap_elem_elem) {
94  std::vector<std::size_t> siblings{1, 2};
95 
96  CondInd2JetGroupsInds satisfiedBy;
97  satisfiedBy[1] = std::vector<std::size_t> {0, 1};
98  satisfiedBy[2] = std::vector<std::size_t> {2};
99  auto collector = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr);
100 
101  JetGroupInd2ElemInds jg2elem;
102 
103  jg2elem[0] = std::vector<std::size_t> {0};
104  jg2elem[1] = std::vector<std::size_t> {1};
105  jg2elem[2] = std::vector<std::size_t> {2};
106  jg2elem[3] = std::vector<std::size_t> {3};
107  jg2elem[4] = std::vector<std::size_t> {4};
108  jg2elem[5] = std::vector<std::size_t> {5};
109  jg2elem[6] = std::vector<std::size_t> {0, 1};
110  jg2elem[7] = std::vector<std::size_t> {2, 3};
111  jg2elem[8] = std::vector<std::size_t> {4, 5};
112 
113 
114  JetGroupReducer jgr(siblings, satisfiedBy, jg2elem);
115 
116  auto exp = std::vector<std::size_t>{0, 1, 2};
117  EXPECT_EQ(jgr.next(collector), exp);
118  EXPECT_TRUE(jgr.next(collector).empty());
119 }
120 
121 TEST(JetGroupReducerTester, two_conditions_nooverlap_elem_non_elem) {
122  std::vector<std::size_t> siblings{1, 2};
123 
124  CondInd2JetGroupsInds satisfiedBy;
125  satisfiedBy[1] = std::vector<std::size_t> {0, 1};
126  satisfiedBy[2] = std::vector<std::size_t> {7};
127  auto collector = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr);
128 
129  JetGroupInd2ElemInds jg2elem;
130 
131  jg2elem[0] = std::vector<std::size_t> {0};
132  jg2elem[1] = std::vector<std::size_t> {1};
133  jg2elem[2] = std::vector<std::size_t> {2};
134  jg2elem[3] = std::vector<std::size_t> {3};
135  jg2elem[4] = std::vector<std::size_t> {4};
136  jg2elem[5] = std::vector<std::size_t> {5};
137  jg2elem[6] = std::vector<std::size_t> {0, 1};
138  jg2elem[7] = std::vector<std::size_t> {2, 3};
139  jg2elem[8] = std::vector<std::size_t> {4, 5};
140 
141 
142  JetGroupReducer jgr(siblings, satisfiedBy, jg2elem);
143 
144  auto exp = std::vector<std::size_t>{0, 1, 2, 3};
145  EXPECT_EQ(jgr.next(collector), exp);
146  EXPECT_TRUE(jgr.next(collector).empty());
147 }
148 
149 TEST(JetGroupReducerTester, two_conditions_overlap_elem_non_elem) {
150  std::vector<std::size_t> siblings{1, 2};
151 
152  CondInd2JetGroupsInds satisfiedBy;
153  satisfiedBy[1] = std::vector<std::size_t> {0, 1};
154  satisfiedBy[2] = std::vector<std::size_t> {6};
155  auto collector = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr);
156 
157  JetGroupInd2ElemInds jg2elem;
158 
159  jg2elem[0] = std::vector<std::size_t> {0};
160  jg2elem[1] = std::vector<std::size_t> {1};
161  jg2elem[2] = std::vector<std::size_t> {2};
162  jg2elem[3] = std::vector<std::size_t> {3};
163  jg2elem[4] = std::vector<std::size_t> {4};
164  jg2elem[5] = std::vector<std::size_t> {5};
165  jg2elem[6] = std::vector<std::size_t> {0, 1};
166  jg2elem[7] = std::vector<std::size_t> {2, 3};
167  jg2elem[8] = std::vector<std::size_t> {4, 5};
168 
169 
170  JetGroupReducer jgr(siblings, satisfiedBy, jg2elem);
171 
172  auto exp = std::vector<std::size_t>{0, 1};
173  EXPECT_EQ(jgr.next(collector), exp);
174  EXPECT_TRUE(jgr.next(collector).empty());
175 }
176 
177 TEST(JetGroupReducerTester, two_conditions_no_overlap_non_elem_non_elem) {
178  std::vector<std::size_t> siblings{1, 2};
179 
180  CondInd2JetGroupsInds satisfiedBy;
181  satisfiedBy[1] = std::vector<std::size_t> {6, 7};
182  satisfiedBy[2] = std::vector<std::size_t> {8};
183  auto collector = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr);
184 
185  JetGroupInd2ElemInds jg2elem;
186 
187  jg2elem[0] = std::vector<std::size_t> {0};
188  jg2elem[1] = std::vector<std::size_t> {1};
189  jg2elem[2] = std::vector<std::size_t> {2};
190  jg2elem[3] = std::vector<std::size_t> {3};
191  jg2elem[4] = std::vector<std::size_t> {4};
192  jg2elem[5] = std::vector<std::size_t> {5};
193  jg2elem[6] = std::vector<std::size_t> {0, 1};
194  jg2elem[7] = std::vector<std::size_t> {2, 3};
195  jg2elem[8] = std::vector<std::size_t> {4, 5};
196 
197 
198  JetGroupReducer jgr(siblings, satisfiedBy, jg2elem);
199 
200  auto exp = std::vector<std::size_t>{0, 1, 2, 3, 4, 5};
201  EXPECT_EQ(jgr.next(collector), exp);
202  EXPECT_TRUE(jgr.next(collector).empty());
203 }
204 
205 TEST(JetGroupReducerTester, two_conditions_overlap_non_elem_non_elem) {
206  std::vector<std::size_t> siblings{1, 2};
207 
208  CondInd2JetGroupsInds satisfiedBy;
209  satisfiedBy[1] = std::vector<std::size_t> {6, 7};
210  satisfiedBy[2] = std::vector<std::size_t> {9};
211  auto collector = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr);
212 
213  JetGroupInd2ElemInds jg2elem;
214 
215  jg2elem[0] = std::vector<std::size_t> {0};
216  jg2elem[1] = std::vector<std::size_t> {1};
217  jg2elem[2] = std::vector<std::size_t> {2};
218  jg2elem[3] = std::vector<std::size_t> {3};
219  jg2elem[4] = std::vector<std::size_t> {4};
220  jg2elem[5] = std::vector<std::size_t> {5};
221  jg2elem[6] = std::vector<std::size_t> {0, 1};
222  jg2elem[7] = std::vector<std::size_t> {2, 3};
223  jg2elem[8] = std::vector<std::size_t> {4, 5};
224  jg2elem[9] = std::vector<std::size_t> {1, 5};
225 
226 
227  JetGroupReducer jgr(siblings, satisfiedBy, jg2elem);
228 
229  auto exp = std::vector<std::size_t>{0, 1, 2, 3, 5};
230  EXPECT_EQ(jgr.next(collector), exp);
231  EXPECT_TRUE(jgr.next(collector).empty());
232 }
233 
CondInd2JetGroupsInds
std::map< int, std::vector< std::size_t > > CondInd2JetGroupsInds
Definition: JetGroupProduct.h:15
JetGroupReducer.h
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
JetGroupReducer
Definition: JetGroupReducer.h:29
JetGroupInd2ElemInds
std::map< int, std::vector< std::size_t > > JetGroupInd2ElemInds
Definition: elementalJetGroups.h:11
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
TEST
TEST(JetGroupReducerTester, empty)
Definition: JetGroupReducerTest.cxx:16
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
Definition: JetGroupReducerTest.cxx:6
JetGroupReducer::valid
virtual bool valid() const override
Definition: JetGroupReducer.cxx:93
JetGroupReducer::next
virtual std::vector< std::size_t > next(const Collector &) override
Definition: JetGroupReducer.cxx:77
checker_macros.h
Define macros for attributes used to control the static checker.