ATLAS Offline Software
JetGroupProductFactoryTest.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 
12 using vec = std::vector<std::size_t>;
13 
14 TEST(JetGroupProductFactoryTester, nosiblings) {
15  std::vector<std::size_t> siblings{};
16 
17  CondInd2JetGroupsInds satisfiedBy;
18  satisfiedBy[0] = std::vector<std::size_t>();// root node
19 
20  std::vector<std::size_t> condMult{1};
21  std::vector<unsigned int> condCap{0};
22  std::vector<int> condClique{1};
23 
24  JetGroupInd2ElemInds jg2elemjgs;
25 
26  std::size_t parCapacity{0};
27 
28  bool simpleTree{true};
29  auto collector = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr);
30 
31  auto jgp = makeJetGroupProduct(siblings,
32  satisfiedBy,
33  condMult,
34  condCap,
35  condClique,
36  jg2elemjgs,
37  parCapacity,
38  simpleTree,
39  collector);
40 
41  EXPECT_TRUE(jgp != nullptr);
42  EXPECT_TRUE(jgp->valid());
43  EXPECT_TRUE(jgp->next(collector).empty());
44 }
45 
46 
47 // Tests for simple trees - root is accept all, all other
48 // nodes are leaf nodes
49 
50 
51 TEST(JetGroupProductFactoryTester, one_clique_fail) {
52  std::vector<std::size_t> siblings{1, 2};
53 
54  CondInd2JetGroupsInds satisfiedBy;
55  satisfiedBy[0] = std::vector<std::size_t> {};
56  satisfiedBy[1] = std::vector<std::size_t> {0, 1, 2};
57  satisfiedBy[2] = std::vector<std::size_t> {0, 1, 2};
58 
59  std::vector<std::size_t> condMult{1u, 5u, 1u};
60  std::vector<unsigned int> condCap{0, 1, 1};
61  std::vector<int> condClique{-1, 0, 0};
62 
63  JetGroupInd2ElemInds jg2elemjgs;
64  jg2elemjgs[0] = std::vector<std::size_t> {0};
65  jg2elemjgs[1] = std::vector<std::size_t> {1};
66  jg2elemjgs[2] = std::vector<std::size_t> {2};
67 
68  std::size_t parCapacity{0};
69  bool simpleTree{true};
70 
71  auto collector = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr);
72 
73  auto jgp = makeJetGroupProduct(siblings,
74  satisfiedBy,
75  condMult,
76  condCap,
77  condClique,
78  jg2elemjgs,
79  parCapacity,
80  simpleTree,
81  collector);
82 
83 
84  EXPECT_TRUE(jgp != nullptr);
85  EXPECT_TRUE(jgp->valid());
86 
87  EXPECT_TRUE(jgp->next(collector).empty());
88  EXPECT_TRUE(jgp->next(collector).empty());
89 }
90 
91 TEST(JetGroupProductFactoryTester, one_clique_pass) {
92  std::vector<std::size_t> siblings{1, 2};
93 
94 
95  // just enough jets to pass mono-clique, required = 5+1 = 6 jets
96  CondInd2JetGroupsInds satisfiedBy;
97  satisfiedBy[0] = std::vector<std::size_t> {};
98  satisfiedBy[1] = std::vector<std::size_t> {0, 1, 2, 3, 4, 5};
99  satisfiedBy[2] = std::vector<std::size_t> {0, 1, 2, 3, 4, 5};
100 
101  std::vector<std::size_t> condMult{1u, 5u, 1u};
102  std::vector<unsigned int> condCap{0, 1, 1};
103  std::vector<int> condClique{-1, 0, 0};
104 
105  JetGroupInd2ElemInds jg2elemjgs;
106  jg2elemjgs[0] = std::vector<std::size_t> {0};
107  jg2elemjgs[1] = std::vector<std::size_t> {1};
108  jg2elemjgs[2] = std::vector<std::size_t> {2};
109  jg2elemjgs[3] = std::vector<std::size_t> {3};
110  jg2elemjgs[4] = std::vector<std::size_t> {4};
111  jg2elemjgs[5] = std::vector<std::size_t> {5};
112 
113 
114  std::size_t parCapacity{0};
115  bool simpleTree{true};
116 
117  auto collector = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr);
118 
119  auto jgp = makeJetGroupProduct(siblings,
120  satisfiedBy,
121  condMult,
122  condCap,
123  condClique,
124  jg2elemjgs,
125  parCapacity,
126  simpleTree,
127  collector);
128 
129  EXPECT_TRUE(jgp != nullptr);
130  EXPECT_TRUE(jgp->valid());
131 
132  vec exp0{0u, 1u, 2u, 3u, 4u, 5u};
133  EXPECT_EQ(jgp->next(collector), exp0);
134  EXPECT_TRUE(jgp->next(collector).empty());
135  EXPECT_TRUE(jgp->next(collector).empty());
136 }
137 
138 TEST(JetGroupProductFactoryTester, njets_eq_nsiblings) {
139  std::vector<std::size_t> siblings{1, 2};
140 
141 
142  // just enough jets to pass mono-clique, required = 5+1 = 6 jets
143  CondInd2JetGroupsInds satisfiedBy;
144  satisfiedBy[0] = std::vector<std::size_t> {};
145  satisfiedBy[1] = std::vector<std::size_t> {0,1};
146  satisfiedBy[2] = std::vector<std::size_t> {0,1};
147 
148  std::vector<std::size_t> condMult{1u, 1u, 1u};
149  std::vector<unsigned int> condCap{0, 1, 1};
150  std::vector<int> condClique{-1, 0, 1};
151 
152  JetGroupInd2ElemInds jg2elemjgs;
153  jg2elemjgs[0] = std::vector<std::size_t> {0};
154  jg2elemjgs[1] = std::vector<std::size_t> {1};
155 
156  std::size_t parCapacity{0};
157  bool simpleTree{true};
158 
159  auto collector = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr);
160 
161  auto jgp = makeJetGroupProduct(siblings,
162  satisfiedBy,
163  condMult,
164  condCap,
165  condClique,
166  jg2elemjgs,
167  parCapacity,
168  simpleTree,
169  collector);
170 
171 
172  EXPECT_TRUE(jgp != nullptr);
173  EXPECT_TRUE(jgp->valid());
174 
175  vec exp0{0u, 1u};
176  EXPECT_EQ(jgp->next(collector), exp0);
177  EXPECT_TRUE(jgp->next(collector).empty());
178  EXPECT_TRUE(jgp->next(collector).empty());
179 
180 
181 }
182 
183 
184 TEST(JetGroupProductFactoryTester, 3siblings_3jets_pass) {
185  std::vector<std::size_t> siblings{1, 2, 3};
186 
187  CondInd2JetGroupsInds satisfiedBy;
188  satisfiedBy[0] = std::vector<std::size_t> {};
189  satisfiedBy[1] = std::vector<std::size_t> {0,1,2};
190  satisfiedBy[2] = std::vector<std::size_t> {0};
191  satisfiedBy[3] = std::vector<std::size_t> {1};
192 
193  std::vector<std::size_t> condMult{1u, 1u, 1u, 1u};
194  std::vector<unsigned int> condCap{0, 1, 1, 1};
195  std::vector<int> condClique{-1, 0, 1, 2};
196 
197  JetGroupInd2ElemInds jg2elemjgs;
198  jg2elemjgs[0] = std::vector<std::size_t> {0};
199  jg2elemjgs[1] = std::vector<std::size_t> {1};
200  jg2elemjgs[2] = std::vector<std::size_t> {2};
201 
202  std::size_t parCapacity{0};
203  bool simpleTree{true};
204 
205  auto collector = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr);
206 
207  auto jgp = makeJetGroupProduct(siblings,
208  satisfiedBy,
209  condMult,
210  condCap,
211  condClique,
212  jg2elemjgs,
213  parCapacity,
214  simpleTree,
215  collector);
216  EXPECT_TRUE(jgp != nullptr);
217  EXPECT_TRUE(jgp->valid());
218 
219  vec exp0{0u, 1u, 2u};
220  EXPECT_EQ(jgp->next(collector), exp0);
221  EXPECT_TRUE(jgp->next(collector).empty());
222  EXPECT_TRUE(jgp->next(collector).empty());
223 }
224 
225 TEST(JetGroupProductFactoryTester, 3siblings_3jets_fail) {
226  std::vector<std::size_t> siblings{1, 2, 3};
227 
228 
229  CondInd2JetGroupsInds satisfiedBy;
230  satisfiedBy[0] = std::vector<std::size_t> {};
231  satisfiedBy[1] = std::vector<std::size_t> {0,1,2};
232  satisfiedBy[2] = std::vector<std::size_t> {1};
233  satisfiedBy[3] = std::vector<std::size_t> {1};
234 
235  std::vector<std::size_t> condMult{1u, 1u, 1u, 1u};
236  std::vector<unsigned int> condCap{0, 1, 1, 1};
237  std::vector<int> condClique{-1, 0, 1, 2};
238 
239  JetGroupInd2ElemInds jg2elemjgs;
240  jg2elemjgs[0] = std::vector<std::size_t> {0};
241  jg2elemjgs[1] = std::vector<std::size_t> {1};
242  jg2elemjgs[2] = std::vector<std::size_t> {2};
243 
244  std::size_t parCapacity{0};
245  bool simpleTree{true};
246 
247  auto collector = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr);
248 
249  auto jgp = makeJetGroupProduct(siblings,
250  satisfiedBy,
251  condMult,
252  condCap,
253  condClique,
254  jg2elemjgs,
255  parCapacity,
256  simpleTree,
257  collector);
258  EXPECT_TRUE(jgp != nullptr);
259  EXPECT_TRUE(jgp->valid());
260 
261  EXPECT_TRUE(jgp->next(collector).empty());
262  EXPECT_TRUE(jgp->next(collector).empty());
263 }
264 
265 
266 // Tests for non-AcceptAll parent
267 
268 TEST(JetGroupProductFactoryTester, dijet_jets_overlap) {
269  std::vector<std::size_t> siblings{1, 2};
270 
271 
272  CondInd2JetGroupsInds satisfiedBy;
273  satisfiedBy[0] = std::vector<std::size_t> {};
274  satisfiedBy[1] = std::vector<std::size_t> {0, 1};
275  satisfiedBy[2] = std::vector<std::size_t> {0, 1};
276 
277  std::vector<std::size_t> condMult{1u, 1u, 1u};
278  std::vector<unsigned int> condCap{2, 1, 1};
279  std::vector<int> condClique{-1, 0, 0};
280 
281  JetGroupInd2ElemInds jg2elemjgs;
282  jg2elemjgs[0] = std::vector<std::size_t> {0};
283  jg2elemjgs[1] = std::vector<std::size_t> {1};
284 
285  std::size_t parCapacity{2};
286  bool simpleTree{false};
287 
288  auto collector = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr);
289 
290  auto jgp = makeJetGroupProduct(siblings,
291  satisfiedBy,
292  condMult,
293  condCap,
294  condClique,
295  jg2elemjgs,
296  parCapacity,
297  simpleTree,
298  collector);
299 
300  EXPECT_TRUE(jgp != nullptr);
301  EXPECT_TRUE(jgp->valid());
302 
303  vec e0{0u, 1u};
304  EXPECT_EQ(jgp->next(collector), e0);
305 
306  EXPECT_TRUE(jgp->next(collector).empty());
307  EXPECT_TRUE(jgp->next(collector).empty());
308 }
309 
310 TEST(JetGroupProductFactoryTester, dijet_jets_no_overlap) {
311  std::vector<std::size_t> siblings{1, 2};
312 
313 
314  CondInd2JetGroupsInds satisfiedBy;
315  satisfiedBy[0] = std::vector<std::size_t> {};
316  satisfiedBy[1] = std::vector<std::size_t> {0, 1};
317  satisfiedBy[2] = std::vector<std::size_t> {2, 3};
318 
319  std::vector<std::size_t> condMult{1u, 1u, 1u};
320  std::vector<unsigned int> condCap{2, 1, 1};
321  std::vector<int> condClique{-1, 0, 0};
322 
323  JetGroupInd2ElemInds jg2elemjgs;
324  jg2elemjgs[0] = std::vector<std::size_t> {0};
325  jg2elemjgs[1] = std::vector<std::size_t> {1};
326  jg2elemjgs[2] = std::vector<std::size_t> {2};
327  jg2elemjgs[3] = std::vector<std::size_t> {3};
328 
329  std::size_t parCapacity{2};
330  bool simpleTree{false};
331 
332  auto collector = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr);
333 
334  auto jgp = makeJetGroupProduct(siblings,
335  satisfiedBy,
336  condMult,
337  condCap,
338  condClique,
339  jg2elemjgs,
340  parCapacity,
341  simpleTree,
342  collector);
343  EXPECT_TRUE(jgp != nullptr);
344  EXPECT_TRUE(jgp->valid());
345 
346  vec e0{0u, 2u};
347  vec e1{1u, 2u};
348  vec e2{0u, 3u};
349  vec e3{1u, 3u};
350  EXPECT_EQ(jgp->next(collector), e0);
351  EXPECT_EQ(jgp->next(collector), e1);
352  EXPECT_EQ(jgp->next(collector), e2);
353  EXPECT_EQ(jgp->next(collector), e3);
354  EXPECT_TRUE(jgp->next(collector).empty());
355  EXPECT_TRUE(jgp->next(collector).empty());
356 }
357 
358 
359 TEST(JetGroupProductFactoryTester, dijet_jets_some_overlap) {
360  std::vector<std::size_t> siblings{1, 2};
361 
362  CondInd2JetGroupsInds satisfiedBy;
363  satisfiedBy[0] = std::vector<std::size_t> {};
364  satisfiedBy[1] = std::vector<std::size_t> {0, 1, 2};
365  satisfiedBy[2] = std::vector<std::size_t> {2, 3, 4};
366 
367  std::vector<std::size_t> condMult{1u, 1u, 1u};
368  std::vector<unsigned int> condCap{2, 1, 1};
369  std::vector<int> condClique{-1, 0, 0};
370 
371  JetGroupInd2ElemInds jg2elemjgs;
372  jg2elemjgs[0] = std::vector<std::size_t> {0};
373  jg2elemjgs[1] = std::vector<std::size_t> {1};
374  jg2elemjgs[2] = std::vector<std::size_t> {2};
375  jg2elemjgs[3] = std::vector<std::size_t> {3};
376  jg2elemjgs[4] = std::vector<std::size_t> {4};
377 
378  std::size_t parCapacity{2};
379  bool simpleTree{false};
380 
381  auto collector = std::unique_ptr<ITrigJetHypoInfoCollector>(nullptr);
382 
383  auto jgp = makeJetGroupProduct(siblings,
384  satisfiedBy,
385  condMult,
386  condCap,
387  condClique,
388  jg2elemjgs,
389  parCapacity,
390  simpleTree,
391  collector);
392  EXPECT_TRUE(jgp != nullptr);
393  EXPECT_TRUE(jgp->valid());
394 
395  vec e0{0u, 2u};
396  vec e1{1u, 2u};
397  vec e2{0u, 3u};
398  vec e3{1u, 3u};
399  vec e4{2u, 3u};
400  vec e5{0u, 4u};
401  vec e6{1u, 4u};
402  vec e7{2u, 4u};
403 
404  EXPECT_EQ(jgp->next(collector), e0);
405  EXPECT_EQ(jgp->next(collector), e1);
406  EXPECT_EQ(jgp->next(collector), e2);
407  EXPECT_EQ(jgp->next(collector), e3);
408  EXPECT_EQ(jgp->next(collector), e4);
409  EXPECT_EQ(jgp->next(collector), e5);
410  EXPECT_EQ(jgp->next(collector), e6);
411  EXPECT_EQ(jgp->next(collector), e7);
412 
413  EXPECT_TRUE(jgp->next(collector).empty());
414  EXPECT_TRUE(jgp->next(collector).empty());
415 }
416 
417 
418 
419 TEST(JetGroupProductFactoryTester, max_jet_0) {
420  CondInd2JetGroupsInds satisfiedBy;
421  satisfiedBy[0] = std::vector<std::size_t> {};
422  satisfiedBy[1] = std::vector<std::size_t> {0};
423  satisfiedBy[2] = std::vector<std::size_t> {0};
424 
425  std::vector<std::size_t> siblings{1, 2};
426 
427  EXPECT_EQ(0u, max_jet(siblings, satisfiedBy));
428 }
429 
430 TEST(JetGroupProductFactoryTester, max_jet_1) {
431  CondInd2JetGroupsInds satisfiedBy;
432  satisfiedBy[0] = std::vector<std::size_t> {};
433  satisfiedBy[1] = std::vector<std::size_t> {0, 1, 2};
434  satisfiedBy[2] = std::vector<std::size_t> {2, 3, 4};
435 
436  std::vector<std::size_t> siblings{1, 2};
437 
438  EXPECT_EQ(4u, max_jet(siblings, satisfiedBy));
439 }
440 
441 
442 TEST(JetGroupProductFactoryTester, willpass_fail_0) {
443  CondInd2JetGroupsInds satisfiedBy;
444  satisfiedBy[0] = std::vector<std::size_t> {};
445  satisfiedBy[1] = std::vector<std::size_t> {0, 1, 2};
446  satisfiedBy[2] = std::vector<std::size_t> {1};
447  satisfiedBy[3] = std::vector<std::size_t> {1};
448 
449  std::vector<std::size_t> condMult{1, 1, 1, 1};
450 
451  std::vector<std::size_t> siblings{1, 2, 3};
452 
453  EXPECT_EQ(willPassSimpleTree(siblings, satisfiedBy, condMult), false);
454 }
455 
456 TEST(JetGroupProductFactoryTester, willpass_fail_1) {
457  CondInd2JetGroupsInds satisfiedBy;
458  satisfiedBy[0] = std::vector<std::size_t> {};
459  satisfiedBy[1] = std::vector<std::size_t> {0, 1, 2};
460  satisfiedBy[2] = std::vector<std::size_t> {2};
461  satisfiedBy[3] = std::vector<std::size_t> {1};
462 
463  std::vector<std::size_t> condMult{1, 2, 1, 1};
464 
465  std::vector<std::size_t> siblings{1, 2, 3};
466 
467  EXPECT_EQ(willPassSimpleTree(siblings, satisfiedBy, condMult), false);
468 }
469 
470 
471 TEST(JetGroupProductFactoryTester, willpass_fail_2) {
472  CondInd2JetGroupsInds satisfiedBy;
473  satisfiedBy[0] = std::vector<std::size_t> {};
474  satisfiedBy[1] = std::vector<std::size_t> {};
475  satisfiedBy[2] = std::vector<std::size_t> {};
476  satisfiedBy[3] = std::vector<std::size_t> {};
477 
478  std::vector<std::size_t> condMult{1, 2, 1, 1};
479 
480  std::vector<std::size_t> siblings{1, 2, 3};
481 
482  EXPECT_EQ(willPassSimpleTree(siblings, satisfiedBy, condMult), false);
483 }
484 
485 TEST(JetGroupProductFactoryTester, willpass_pass_0) {
486  CondInd2JetGroupsInds satisfiedBy;
487  satisfiedBy[0] = std::vector<std::size_t> {};
488  satisfiedBy[1] = std::vector<std::size_t> {0, 1, 2};
489  satisfiedBy[2] = std::vector<std::size_t> {2};
490  satisfiedBy[3] = std::vector<std::size_t> {1};
491 
492  std::vector<std::size_t> condMult{1, 1, 1, 1};
493 
494  std::vector<std::size_t> siblings{1, 2, 3};
495 
496  EXPECT_EQ(willPassSimpleTree(siblings, satisfiedBy, condMult), true);
497 }
498 
499 TEST(JetGroupProductFactoryTester, willpass_pass_1) {
500  CondInd2JetGroupsInds satisfiedBy;
501  satisfiedBy[0] = std::vector<std::size_t> {};
502  satisfiedBy[1] = std::vector<std::size_t> {0, 1, 2, 3};
503  satisfiedBy[2] = std::vector<std::size_t> {0, 1, 2};
504 
505  std::vector<std::size_t> condMult{1, 2, 2};
506 
507  std::vector<std::size_t> siblings{1, 2};
508 
509  EXPECT_EQ(willPassSimpleTree(siblings, satisfiedBy, condMult), true);
510 }
CondInd2JetGroupsInds
std::map< int, std::vector< std::size_t > > CondInd2JetGroupsInds
Definition: JetGroupProduct.h:15
JetGroupProductFactory.h
egammaEnergyPositionAllSamples::e1
double e1(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 1st sampling
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
willPassSimpleTree
bool willPassSimpleTree(const std::vector< std::size_t > &siblings, const CondInd2JetGroupsInds &satisfiedBy, const std::vector< std::size_t > &condMult)
Definition: JetGroupProductFactory.cxx:30
CheckAppliedSFs.e3
e3
Definition: CheckAppliedSFs.py:264
PixelAthClusterMonAlgCfg.e4
e4
Definition: PixelAthClusterMonAlgCfg.py:332
JetGroupInd2ElemInds
std::map< int, std::vector< std::size_t > > JetGroupInd2ElemInds
Definition: elementalJetGroups.h:11
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
Definition: JetGroupProductFactoryTest.cxx:6
makeJetGroupProduct
std::unique_ptr< IJetGroupProduct > makeJetGroupProduct(const std::vector< std::size_t > &siblings, const CondInd2JetGroupsInds &satisfiedBy, const std::vector< std::size_t > &condMult, const std::vector< unsigned int > &condCap, const std::vector< int > &condClique, const JetGroupInd2ElemInds &jg2elemjgs, std::size_t parentCap, bool simpleTree, const Collector &)
Definition: JetGroupProductFactory.cxx:73
TEST
TEST(JetGroupProductFactoryTester, nosiblings)
Definition: JetGroupProductFactoryTest.cxx:14
egammaEnergyPositionAllSamples::e2
double e2(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 2nd sampling
egammaEnergyPositionAllSamples::e0
double e0(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in pre-sampler
checker_macros.h
Define macros for attributes used to control the static checker.
max_jet
std::size_t max_jet(const std::vector< std::size_t > &siblings, const CondInd2JetGroupsInds &satisfiedBy)
Definition: JetGroupProductFactory.cxx:15