ATLAS Offline Software
make_jetstream.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRIGHLTJETHYPO_MAKE_JETSTREAM_H
6 #define TRIGHLTJETHYPO_MAKE_JETSTREAM_H
7 
8 /*
9  * make_jetstream creates a linled list of IJetStreams.
10  * The first arguement of type vector<vector<std::size>> contains
11  * jet indices that pass a RepeatedCondition. There is one entry in the outer
12  * vector per Condition being considered.
13  *
14  * The vector<std:size_t> contains the repeat values of the RepeatedConditions.
15  *
16  * The concrete types in the list
17  * will be a SimpleJetStream if the repeat value for the corresponding
18  * Condition is 1, and a CombinationsJetStream otherwise.
19  */
20 
21 #include "SimpleJetStream.h"
22 #include "CombinationsJetStream.h"
23 #include "JetStreamer.h"
24 #include <memory>
25 #include <vector>
26 
27 std::unique_ptr<IJetStream>
28 make_jetstream(std::vector<std::vector<std::size_t>> indices,
29  std::vector<std::size_t> repeats,
30  std::size_t sid) {
31  if (indices.size()==1) {
32  auto null_stream = std::unique_ptr<IJetStream>{nullptr};
33  auto base_case = std::unique_ptr<IJetStream>(nullptr);
34  auto repeat = repeats.at(0);
35  if (repeat == 1) {
36  base_case.reset(new SimpleJetStream(indices.at(0),
37  std::move(null_stream),
38  sid));
39  } else {
40  base_case.reset(new CombinationsJetStream(indices.at(0),
41  std::move(null_stream),
42  repeat,
43  sid));
44  }
45  return base_case;
46 
47  }
48 
49  auto inds = indices.back();
50  indices.pop_back();
51 
52  auto repeat = repeats.back();
53  repeats.pop_back();
54 
55  auto n_sid = sid;
56  auto right_stream = make_jetstream(indices, repeats, ++n_sid);
57  auto stream = std::unique_ptr<IJetStream>(nullptr);
58  if (repeat == 1) {
59  stream.reset(new SimpleJetStream(inds,
60  std::move(right_stream),
61  sid));
62  } else {
63  stream.reset(new CombinationsJetStream(inds,
64  std::move(right_stream),
65  repeat,
66  sid));
67  }
68 
69  return stream;
70 }
71 
72 #endif
SimpleJetStream.h
Trk::indices
std::pair< long int, long int > indices
Definition: AlSymMatBase.h:24
JetStreamer.h
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
CombinationsJetStream.h
CombinationsJetStream
Definition: CombinationsJetStream.h:35
SimpleJetStream
Definition: SimpleJetStream.h:26
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