ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigHypothesis
TrigHLTJetHypo
src
CombinationsJetStream.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_COMBINATIONSJETSTREAM_H
6
#define TRIGHLTJETHYPO_COMBINATIONSJETSTREAM_H
7
8
/*
9
* CompoundJetStream is an implementation of IJetStream.
10
* on every call to bump(), it makes available a vector of k
11
* indices chosen from a vector of n indices.
12
*
13
* The positions in the k chosen jets in the jet indices list
14
* is claculated by an instance of CombinationsGenerator, held
15
* as attribute of this class.
16
*
17
* On each call to bump(), the right neighbor is checked for
18
* having cycled. If this is rthe case, or if there is no such neighbor,
19
* the instance will bump itself by
20
* asking its CombinationsGenerator which positions to
21
* use, and makes these values availble for collection.
22
* When all combinations have been exhausted by succesive calls to
23
* bump, the bump() returns true, and the cycle is restarted.
24
*
25
*/
26
27
28
#include "
IJetStream.h
"
29
#include "
CombinationsGenerator.h
"
30
#include <vector>
31
#include <sstream>
32
#include <memory>
33
#include <string>
34
35
class
CombinationsJetStream
:
public
IJetStream
{
36
37
public
:
38
friend
std::ostream&
operator <<
(std::ostream&,
39
const
CombinationsJetStream
&);
40
friend
std::stringstream&
operator <<
(std::stringstream&,
41
const
CombinationsJetStream
&);
42
43
CombinationsJetStream
(
const
std::vector<std::size_t>& jets,
44
std::unique_ptr<IJetStream> neigh,
45
std::size_t k,
46
std::size_t
id
):
47
m_jets
(jets),
48
m_neigh
(
std
::move(neigh)),
49
m_id
{id}
50
{
51
auto
n =
m_jets
.size();
52
53
m_valid
= k <= n and !jets.empty();
54
if
(
m_valid
) {
55
m_combgen
.reset(
new
CombinationsGenerator
(n, k));
56
auto
indices =
m_combgen
->get();
57
m_data
.clear();
58
for
(
const
auto
i : indices) {
m_data
.push_back(
m_jets
.at(i));}
59
}
60
}
61
62
virtual
std::vector<std::size_t>
get
()
override
{
63
64
65
auto
result =
m_neigh
?
m_neigh
->get() : std::vector<std::size_t>();
66
result.insert(result.end(),
m_data
.begin(),
m_data
.end());
67
return
result;
68
}
69
70
71
virtual
bool
bump
()
override
{
72
73
// if there is a neighor, bump it. If it returns
74
// true, it has cycled, in which case try bumping this stream
75
76
bool
cycled{
false
};
77
if
(
m_neigh
) {
78
bool
neigh_cycled =
m_neigh
->bump();
79
if
(!neigh_cycled) {
return
false
;}
80
81
cycled =
m_combgen
->bump();
82
83
auto
indices =
m_combgen
->get();
84
m_data
.clear();
85
for
(
const
auto
i : indices) {
m_data
.push_back(
m_jets
.at(i));}
86
return
cycled;
87
}
else
{
88
// no neighbor
89
cycled =
m_combgen
->bump();
90
91
auto
indices =
m_combgen
->get();
92
m_data
.clear();
93
for
(
const
auto
& i : indices) {
94
m_data
.push_back(
m_jets
.at(i));
95
}
96
return
cycled;
97
}
98
}
99
100
101
virtual
bool
valid
()
const override
{
102
if
(!
m_valid
){
return
false
;}
103
104
if
(
m_neigh
) {
return
m_neigh
->valid();}
105
return
true
;
106
}
107
108
virtual
std::string
dump
()
const override
{
109
110
auto
result =
m_neigh
?
m_neigh
->dump() :
""
;
111
112
std::stringstream
ss
;
113
ss
<< *
this
;
114
result +=
ss
.str();
115
116
return
result;
117
}
118
119
private
:
120
std::vector<std::size_t>
m_jets
;
121
std::unique_ptr<IJetStream>
m_neigh
{
nullptr
};
122
std::size_t
m_id
;
123
std::vector<std::size_t>
m_data
;
124
std::unique_ptr<CombinationsGenerator>
m_combgen
{
nullptr
};
125
bool
m_valid
{
false
};
126
127
128
129
bool
empty
()
const
{
130
return
m_jets
.empty();
131
}
132
133
};
134
135
std::ostream&
operator <<
(std::ostream&,
136
const
CombinationsJetStream
&);
137
138
std::stringstream&
operator <<
(std::stringstream&,
139
const
CombinationsJetStream
&);
140
141
#endif
CombinationsGenerator.h
operator<<
std::ostream & operator<<(std::ostream &, const CombinationsJetStream &)
Definition
CombinationsJetStream.cxx:8
IJetStream.h
ss
static Double_t ss
Definition
LArPhysWaveHECTool.cxx:37
CombinationsGenerator
generate all possible combinations of objects
CombinationsJetStream
Definition
CombinationsJetStream.h:35
CombinationsJetStream::m_jets
std::vector< std::size_t > m_jets
Definition
CombinationsJetStream.h:120
CombinationsJetStream::m_valid
bool m_valid
Definition
CombinationsJetStream.h:125
CombinationsJetStream::empty
bool empty() const
Definition
CombinationsJetStream.h:129
CombinationsJetStream::valid
virtual bool valid() const override
Definition
CombinationsJetStream.h:101
CombinationsJetStream::m_id
std::size_t m_id
Definition
CombinationsJetStream.h:122
CombinationsJetStream::bump
virtual bool bump() override
Definition
CombinationsJetStream.h:71
CombinationsJetStream::m_data
std::vector< std::size_t > m_data
Definition
CombinationsJetStream.h:123
CombinationsJetStream::dump
virtual std::string dump() const override
Definition
CombinationsJetStream.h:108
CombinationsJetStream::m_combgen
std::unique_ptr< CombinationsGenerator > m_combgen
Definition
CombinationsJetStream.h:124
CombinationsJetStream::get
virtual std::vector< std::size_t > get() override
Definition
CombinationsJetStream.h:62
CombinationsJetStream::operator<<
friend std::ostream & operator<<(std::ostream &, const CombinationsJetStream &)
Definition
CombinationsJetStream.cxx:8
CombinationsJetStream::m_neigh
std::unique_ptr< IJetStream > m_neigh
Definition
CombinationsJetStream.h:121
CombinationsJetStream::CombinationsJetStream
CombinationsJetStream(const std::vector< std::size_t > &jets, std::unique_ptr< IJetStream > neigh, std::size_t k, std::size_t id)
Definition
CombinationsJetStream.h:43
IJetStream
Definition
IJetStream.h:31
std
STL namespace.
Generated on
for ATLAS Offline Software by
1.17.0