ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigHypothesis
TrigHLTJetHypo
src
JetGroupProductFactory.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
./JetGroupProductFactory.h
"
6
#include "
./JetGroupProduct.h
"
7
#include "
./EmptyJetGroupProduct.h
"
8
#include "
./JetGroupUnion.h
"
9
#include "
./JetGroupReducer.h
"
10
#include "
./JetGroupSingleClique.h
"
11
12
#include <algorithm>
13
#include <numeric>
// std::accumulate
14
15
std::size_t
max_jet
(
const
std::vector<std::size_t>& siblings,
16
const
CondInd2JetGroupsInds
& satisfiedBy) {
17
std::vector<std::size_t> inds;
18
for
(
const
auto
& s : siblings) {
19
inds.insert(inds.end(),
20
satisfiedBy.at(s).cbegin(),
21
satisfiedBy.at(s).cend());
22
}
23
24
auto
iter = std::max_element(inds.begin(), inds.end());
25
if
(iter == inds.end()) {
return
0;}
26
return
*iter;
27
}
28
29
30
bool
willPassSimpleTree
(
const
std::vector<std::size_t>& siblings,
31
const
CondInd2JetGroupsInds
& satisfiedBy,
32
const
std::vector<std::size_t>& condMult){
33
34
for
(
const
auto
& s : siblings) {
35
if
(satisfiedBy.at(s).empty()) {
return
false
;}
36
}
37
38
std::vector<std::vector<std::size_t>> ind_stack;
39
40
for
(
const
auto
& s : siblings) {
41
auto
repeat = condMult.at(s);
42
for
(std::size_t i = 0; i != repeat; ++i) {
43
auto
c_inds = satisfiedBy.at(s);
44
ind_stack.emplace_back(c_inds);
45
}
46
}
47
48
49
std::sort
(ind_stack.begin(), ind_stack.end(),
50
[](
const
auto
& v0,
const
auto
& v1) {
51
return v0.size() < v1.size();
52
});
53
54
auto
max_ind =
max_jet
(siblings, satisfiedBy);
55
56
std::vector<bool> mask(max_ind+1,
false
);
//why +1? : what if only jet = 0
57
58
for
(
const
auto
& v : ind_stack){
59
bool
found{
false
};
60
for
(
const
auto
& e : v) {
61
if
(!mask.at(e)){
// looking for a false
62
mask.at(e) =
true
;
// found one, not blocked
63
found =
true
;
64
break
;
65
}
66
}
67
if
(!found) {
return
false
;}
68
}
69
return
true
;
70
}
71
72
std::unique_ptr<IJetGroupProduct>
73
makeJetGroupProduct
(
const
std::vector<std::size_t>& siblings,
74
const
CondInd2JetGroupsInds
& satisfiedBy,
75
const
std::vector<std::size_t>& condMult,
76
const
std::vector<unsigned int>& condCap,
77
const
std::vector<int>& condClique,
78
const
JetGroupInd2ElemInds
& jg2elemjgs,
79
std::size_t parentCap,
80
bool
simpleTree,
81
const
Collector
&) {
82
83
84
// simpleTree - flags with the tree has an AceptAll root (mult 1, cap 0)
85
// with all other nodes being children.
86
// leaves - one entry per sibling
87
88
// satisfiedBy map. key:Condition val: vector of satisfying jets,
89
// includes the root node. size = nConditions
90
91
// condMult - multiplicity, all conditions, size = nConditions
92
// condCap - capacity, all conditions, size = nConditions
93
// condClique - clique index, size = nConditions
94
95
96
// jg2elemjgs - jet group index to elementary jet groups
97
// not needed for simpleTrees as all jet groups are elementary jet groups
98
// for simple trees.
99
100
std::unique_ptr<IJetGroupProduct> jgp (
nullptr
);
101
102
if
(siblings.empty()) {
103
jgp.reset(
new
EmptyJetGroupProduct
);
104
return
jgp;
105
}
106
107
108
for
(
const
auto
& s : siblings) {
109
if
(satisfiedBy.at(s).empty()) {
110
jgp.reset(
new
EmptyJetGroupProduct
);
111
return
jgp;
112
}
113
}
114
115
116
std::map<int, std::vector<std::size_t>> clique_map;
117
std::for_each(siblings.begin(),
118
siblings.end(),
119
[&clique_map, &condClique](std::size_t s){
120
auto clique = condClique[s];
121
if (clique != -1) {
122
clique_map[clique].push_back(s);}});
123
124
125
126
auto
n_required = std::accumulate(siblings.cbegin(),
127
siblings.cend(),
128
0u,
129
[&condMult, &condCap](
const
auto
& sofar,
130
const
auto
& ind){
131
return sofar +
132
condMult.at(ind)*condCap.at(ind);});
133
134
135
bool
cap1{
true
};
136
for
(
const
auto
& s: siblings) {
137
if
(condCap.at(s) != 1) {
138
cap1 =
false
;
139
break
;
140
}
141
}
142
143
if
(simpleTree and cap1) {
144
if
(clique_map.size() == 1){
145
jgp.reset(
new
JetGroupSingleClique
(satisfiedBy.at(1),
// first child
146
n_required));
147
return
jgp;
148
}
149
150
151
// check whether all Conditions have at least
152
// n_required jets. If so, a JetGroupUnion
153
// can be used to provide the single
154
// relevant jet group.
155
bool
enough{
true
};
156
for
(
const
auto
& s : siblings) {
157
if
((satisfiedBy.at(s)).size() < n_required) {
158
enough =
false
;
159
break
;
160
}
161
}
162
163
if
(enough) {
164
jgp.reset(
new
JetGroupUnion
(siblings,
165
satisfiedBy));
166
return
jgp;
167
}
168
169
if
(
willPassSimpleTree
(siblings, satisfiedBy, condMult)) {
170
jgp.reset(
new
JetGroupUnion
(siblings,
171
satisfiedBy));
172
return
jgp;
173
}
174
175
jgp.reset(
new
EmptyJetGroupProduct
);
176
return
jgp;
177
}
178
179
// tree is non-simple or there are siblings are not all capacity 1.
180
// Special case: parent node is AcceptAll, one child.
181
// Examples:
182
// Dijet scenario (non-simple tree, root node has one child).
183
// HT scenario (simple tree, child node has cap != 1)
184
if
(parentCap == 0 and siblings.size() == 1) {
185
186
jgp.reset(
new
JetGroupReducer
(siblings,
187
satisfiedBy,
188
jg2elemjgs));
189
return
jgp;
190
}
191
192
193
// Otherwise need a group product that will step
194
// through the external products of the sets
195
// Note - if a tree contained an AcceptAll node internally,
196
// for which all children had capactity = 1, a JetGroupReducer
197
// could be used. This would be a very unusual case, and is
198
// not treated here.
199
200
jgp.reset(
new
JetGroupProduct
(siblings, satisfiedBy, condMult,
201
jg2elemjgs));
202
return
jgp;
203
}
204
EmptyJetGroupProduct.h
Collector
std::unique_ptr< ITrigJetHypoInfoCollector > Collector
Definition
FastReducer.h:22
willPassSimpleTree
bool willPassSimpleTree(const std::vector< std::size_t > &siblings, const CondInd2JetGroupsInds &satisfiedBy, const std::vector< std::size_t > &condMult)
Definition
JetGroupProductFactory.cxx:30
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
max_jet
std::size_t max_jet(const std::vector< std::size_t > &siblings, const CondInd2JetGroupsInds &satisfiedBy)
Definition
JetGroupProductFactory.cxx:15
JetGroupProductFactory.h
JetGroupProduct.h
CondInd2JetGroupsInds
std::map< int, std::vector< std::size_t > > CondInd2JetGroupsInds
Definition
JetGroupProduct.h:15
JetGroupReducer.h
JetGroupSingleClique.h
JetGroupUnion.h
EmptyJetGroupProduct
Definition
EmptyJetGroupProduct.h:11
JetGroupProduct
Definition
JetGroupProduct.h:20
JetGroupReducer
Definition
JetGroupReducer.h:29
JetGroupSingleClique
Definition
JetGroupSingleClique.h:20
JetGroupUnion
Definition
JetGroupUnion.h:20
JetGroupInd2ElemInds
std::map< int, std::vector< std::size_t > > JetGroupInd2ElemInds
Definition
elementalJetGroups.h:11
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition
DVL_algorithms.h:554
Generated on
for ATLAS Offline Software by
1.17.0