ATLAS Offline Software
Typedefs | Functions
JetGroupProductFactory.h File Reference
#include "./JetGroupProduct.h"
Include dependency graph for JetGroupProductFactory.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

using JetGroupInd2ElemInds = std::map< int, std::vector< std::size_t > >
 

Functions

bool willPassSimpleTree (const std::vector< std::size_t > &siblings, const CondInd2JetGroupsInds &satisfiedBy, const std::vector< std::size_t > &condMult)
 
std::size_t max_jet (const std::vector< std::size_t > &siblings, const CondInd2JetGroupsInds &satisfiedBy)
 
std::unique_ptr< IJetGroupProductmakeJetGroupProduct (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 parCapacity, bool simpleTree, const Collector &collector)
 

Typedef Documentation

◆ JetGroupInd2ElemInds

using JetGroupInd2ElemInds = std::map<int, std::vector<std::size_t> >

Definition at line 13 of file JetGroupProductFactory.h.

Function Documentation

◆ 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  parCapacity,
bool  simpleTree,
const Collector collector 
)

Definition at line 73 of file JetGroupProductFactory.cxx.

81  {
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 }

◆ max_jet()

std::size_t max_jet ( const std::vector< std::size_t > &  siblings,
const CondInd2JetGroupsInds satisfiedBy 
)

Definition at line 15 of file JetGroupProductFactory.cxx.

16  {
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 }

◆ willPassSimpleTree()

bool willPassSimpleTree ( const std::vector< std::size_t > &  siblings,
const CondInd2JetGroupsInds satisfiedBy,
const std::vector< std::size_t > &  condMult 
)

Definition at line 30 of file JetGroupProductFactory.cxx.

32  {
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 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
JetGroupUnion
Definition: JetGroupUnion.h:20
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
EmptyJetGroupProduct
Definition: EmptyJetGroupProduct.h:11
accumulate
bool accumulate(AccumulateMap &map, std::vector< module_t > const &modules, FPGATrackSimMatrixAccumulator const &acc)
Accumulates an accumulator (e.g.
Definition: FPGATrackSimMatrixAccumulator.cxx:22
JetGroupProduct
Definition: JetGroupProduct.h:20
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
JetGroupReducer
Definition: JetGroupReducer.h:29
JetGroupSingleClique
Definition: JetGroupSingleClique.h:20
willPassSimpleTree
bool willPassSimpleTree(const std::vector< std::size_t > &siblings, const CondInd2JetGroupsInds &satisfiedBy, const std::vector< std::size_t > &condMult)
Definition: JetGroupProductFactory.cxx:30
parseMapping.v0
def v0
Definition: parseMapping.py:149
lumiFormat.i
int i
Definition: lumiFormat.py:85
python.PyAthena.v
v
Definition: PyAthena.py:154
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
max_jet
std::size_t max_jet(const std::vector< std::size_t > &siblings, const CondInd2JetGroupsInds &satisfiedBy)
Definition: JetGroupProductFactory.cxx:15
checkFileSG.ind
list ind
Definition: checkFileSG.py:118