ATLAS Offline Software
make_jetstreamTest.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 <memory>
12 
13 using vec = std::vector<std::size_t>;
14 
15 TEST(make_jetstreamTester, SimpleSimpleSimpleChain) {
16 
17  std::vector<std::vector<std::size_t>> v;
18  v.push_back(std::vector<std::size_t>{1,2});
19  v.push_back(std::vector<std::size_t>{3,4, 5});
20  v.push_back(std::vector<std::size_t>{6,7});
21 
22  std::vector<std::size_t> repeats{1,1,1};
23 
24  std::size_t sid{0};
25 
26  auto stream = make_jetstream(v, repeats, sid);
27 
28  JetStreamer streamer(std::move(stream));
29 
30  vec v0{1, 3, 6};
31  vec v1{2, 3, 6};
32  vec v2{1, 4, 6};
33  vec v3{2, 4, 6};
34  vec v4{1, 5, 6};
35  vec v5{2, 5, 6};
36  vec v6{1, 3, 7};
37  vec v7{2, 3, 7};
38  vec v8{1, 4, 7};
39  vec v9{2, 4, 7};
40  vec v10{1, 5, 7};
41  vec v11{2, 5, 7};
42 
43 
44  EXPECT_EQ (v0, streamer.next());
45  EXPECT_EQ (v1, streamer.next());
46  EXPECT_EQ (v2, streamer.next());
47  EXPECT_EQ (v3, streamer.next());
48  EXPECT_EQ (v4, streamer.next());
49  EXPECT_EQ (v5, streamer.next());
50  EXPECT_EQ (v6, streamer.next());
51  EXPECT_EQ (v7, streamer.next());
52  EXPECT_EQ (v8, streamer.next());
53  EXPECT_EQ (v9, streamer.next());
54  EXPECT_EQ (v10, streamer.next());
55  EXPECT_EQ (v11, streamer.next());
56 
57  EXPECT_EQ (vec{}, streamer.next());
58 }
59 
60 
61 TEST(make_jetstreamTester, SimpleCompoundSimpleChain) {
62  std::vector<std::vector<std::size_t>> v;
63  v.push_back(std::vector<std::size_t>{1,2});
64  v.push_back(std::vector<std::size_t>{3,4, 5});
65  v.push_back(std::vector<std::size_t>{6,7});
66 
67  std::vector<std::size_t> repeats{1,2,1};
68 
69  std::size_t sid{0};
70 
71  auto stream = make_jetstream(v, repeats, sid);
72 
73  JetStreamer streamer(std::move(stream));
74 
75  vec v0{1, 3, 4, 6};
76  vec v1{2, 3, 4, 6};
77  vec v2{1, 3, 5, 6};
78  vec v3{2, 3, 5, 6};
79  vec v4{1, 4, 5, 6};
80  vec v5{2, 4, 5, 6};
81  vec v6{1, 3, 4, 7};
82  vec v7{2, 3, 4, 7};
83  vec v8{1, 3, 5, 7};
84  vec v9{2, 3, 5, 7};
85  vec v10{1, 4, 5, 7};
86  vec v11{2, 4, 5, 7};
87 
88  EXPECT_EQ (v0, streamer.next());
89  EXPECT_EQ (v1, streamer.next());
90  EXPECT_EQ (v2, streamer.next());
91  EXPECT_EQ (v3, streamer.next());
92  EXPECT_EQ (v4, streamer.next());
93  EXPECT_EQ (v5, streamer.next());
94  EXPECT_EQ (v6, streamer.next());
95  EXPECT_EQ (v7, streamer.next());
96  EXPECT_EQ (v8, streamer.next());
97  EXPECT_EQ (v9, streamer.next());
98  EXPECT_EQ (v10, streamer.next());
99  EXPECT_EQ (v11, streamer.next());
100 
101  EXPECT_EQ (vec{}, streamer.next());
102 }
103 
104 TEST(make_jetstreamTester, reallife) {
105  std::vector<std::vector<std::size_t>> v;
106  v.push_back(std::vector<std::size_t>{0, 1, 2});
107  v.push_back(std::vector<std::size_t>{
108  0, 1, 2, 3, 4, 6, 7, 9, 10, 11, 12, 13,
109  14, 15, 17, 19, 21, 25, 26, 29, 33});
110 
111 
112 
113  std::vector<std::size_t> repeats{1,3};
114 
115  std::size_t sid{0};
116 
117  auto stream = make_jetstream(v, repeats, sid);
118 
119  JetStreamer streamer(std::move(stream));
120 
121  std::size_t ipass{0};
122 
123  while (true) {
124  auto indices = streamer.next();
125  if (indices.empty()){break;}
126  ++ipass;
127  }
128 
129  // 3990 = 3*C(21,3)
130  EXPECT_EQ (ipass, 3990u);
131 }
Trk::indices
std::pair< long int, long int > indices
Definition: AlSymMatBase.h:24
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
make_jetstream.h
parseMapping.v0
def v0
Definition: parseMapping.py:149
TEST
TEST(make_jetstreamTester, SimpleSimpleSimpleChain)
Definition: make_jetstreamTest.cxx:15
JetStreamer::next
std::vector< std::size_t > next()
Definition: JetStreamer.h:40
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
Definition: make_jetstreamTest.cxx:6
ReadCellNoiseFromCoolCompare.v2
v2
Definition: ReadCellNoiseFromCoolCompare.py:364
python.PyAthena.v
v
Definition: PyAthena.py:154
JetStreamer
Definition: JetStreamer.h:25
checker_macros.h
Define macros for attributes used to control the static checker.
make_jetstream
std::unique_ptr< IJetStream > make_jetstream(std::vector< std::vector< std::size_t >> indices, std::vector< std::size_t > repeats, std::size_t sid)
Definition: make_jetstream.h:28