ATLAS Offline Software
JetStreamer.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_JETSTEAMER_H
6 #define TRIGHLTJETHYPO_JETSTEAMER_H
7 
8 /*
9  * JetStreamer owns a linked list of IJetStream objects.
10  * These provide vectors of indices according to the conrete types.
11  * The stream objects cycle, which allows for stepping through
12  * all possible combinations of jets. On each call to bump an element
13  * in the list informs its left neigbor if the fact. The
14  * the cycle state is relayed back to JetStreamer: when all elements
15  * in the list have cycled, the iteration stops.
16  */
17 
18 #include "./IJetStream.h"
19 #include "./SimpleJetStream.h"
21 
22 #include <sstream>
23 #include <ostream>
24 
25 class JetStreamer {
26 
27  public:
28 
29  friend std::ostream& operator << (std::ostream&, const JetStreamer&);
30  friend std::ostream& operator << (std::stringstream&, const JetStreamer&);
31 
32 
33  JetStreamer(std::unique_ptr<IJetStream>&& stream) :
34  m_stream(std::move(stream))
35  {
36  m_valid = m_stream != nullptr and m_stream->valid();
37  }
38 
39 
40  std::vector<std::size_t> next() {
41 
42  if (!m_valid) {
43  return std::vector<std::size_t>();
44  }
45 
46  if (m_done) {return std::vector<std::size_t>();}
47  auto result = m_stream->get(); // stream always as legal data
48 
49  m_done = m_stream->bump();
50 
51  return result;
52  }
53 
54  bool isValid() const {return m_valid;}
55 
56  private:
57  std::unique_ptr<IJetStream> m_stream;
58  bool m_done{false};
59  bool m_valid{false};
60 };
61 
62 std::ostream& operator << (std::ostream&, const JetStreamer&);
63 
64 #endif
SimpleJetStream.h
get_generator_info.result
result
Definition: get_generator_info.py:21
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
JetStreamer::m_stream
std::unique_ptr< IJetStream > m_stream
Definition: JetStreamer.h:57
JetStreamer::isValid
bool isValid() const
Definition: JetStreamer.h:54
JetStreamer::m_valid
bool m_valid
Definition: JetStreamer.h:59
JetStreamer::JetStreamer
JetStreamer(std::unique_ptr< IJetStream > &&stream)
Definition: JetStreamer.h:33
JetStreamer::next
std::vector< std::size_t > next()
Definition: JetStreamer.h:40
IJetStream.h
CombinationsJetStream.h
operator<<
std::ostream & operator<<(std::ostream &, const JetStreamer &)
Definition: JetStreamer.cxx:9
JetStreamer::m_done
bool m_done
Definition: JetStreamer.h:58
JetStreamer::operator<<
friend std::ostream & operator<<(std::ostream &, const JetStreamer &)
Definition: JetStreamer.cxx:9
JetStreamer
Definition: JetStreamer.h:25