ATLAS Offline Software
JetGroupReducer.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 "./JetGroupReducer.h"
6 #include "./elementalJetGroups.h"
7 
8 #include <set>
9 #include <string>
10 #include <sstream>
11 
12 
13 JetGroupReducer::JetGroupReducer(const std::vector<std::size_t>& siblings,
14  const CondInd2JetGroupsInds& satisfiedBy,
15  const JetGroupInd2ElemInds& jg2elemjgs){
16 
17  // make a vector of the jet indices that satisfy the sibling Conditions
18  // with no duplicates
19 
20  // edge cases
21  if (siblings.empty()){
22  m_done = true;
23  return;
24  }
25 
26  for (const auto& s : siblings){
27  if (satisfiedBy.at(s).empty()) {
28  m_done = true;
29  return;
30  }
31  }
32 
33  std::vector<std::size_t> satisfying;
34 
35  for (const auto& s :siblings){
36  satisfying.insert(satisfying.end(),
37  satisfiedBy.at(s).cbegin(),
38  satisfiedBy.at(s).cend()
39  );
40  }
41 
42  // If more there are more than one siblings, there could be
43  // duplicates in the combined list of (non-elementary) jet groups.
44  // Eliminate these.
45 
46  auto end = satisfying.end();
47  if (siblings.size() > 1) {
48  std::sort(satisfying.begin(),
49  satisfying.end());
50 
51  end = std::unique(satisfying.begin(),
52  satisfying.end());
53  }
54 
55  std::vector<std::size_t> jet_indices;
56  for(auto iter = satisfying.begin(); iter != end; ++iter) {
57  jet_indices.insert(jet_indices.end(),
58  jg2elemjgs.at(*iter).begin(),
59  jg2elemjgs.at(*iter).end());
60  }
61 
62  std::sort(jet_indices.begin(),
63  jet_indices.end());
64 
65  auto final_end = std::unique(jet_indices.begin(),
66  jet_indices.end());
67 
68 
69  jet_indices.resize(final_end-jet_indices.begin());
70 
71  m_jetIndices = elementalJetGroups(jet_indices,
72  jg2elemjgs);
73  m_done = false;
74  }
75 
76 
77 std::vector<std::size_t> JetGroupReducer::next(const Collector& collector){
78  if(collector){
79  std::stringstream sstr;
80  sstr << "no of indices " << m_jetIndices.size()
81  << " done " << std::boolalpha << m_done;
82  collector->collect("JetGroupReducer::next()", sstr.str());
83  }
84 
85  if (m_done) {
86  return std::vector<std::size_t>();
87  }
88 
89  m_done = true;
90  return m_jetIndices;
91 }
92 
93 bool JetGroupReducer::valid() const {return true;}
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
CondInd2JetGroupsInds
std::map< int, std::vector< std::size_t > > CondInd2JetGroupsInds
Definition: JetGroupProduct.h:15
JetGroupReducer.h
JetGroupReducer::JetGroupReducer
JetGroupReducer(const std::vector< std::size_t > &siblings, const CondInd2JetGroupsInds &satisfiedBy, const JetGroupInd2ElemInds &)
Definition: JetGroupReducer.cxx:13
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
elementalJetGroups
std::vector< std::size_t > elementalJetGroups(const std::vector< std::size_t > &non_elemental, const JetGroupInd2ElemInds &jg2elemjg)
Definition: elementalJetGroups.cxx:9
JetGroupInd2ElemInds
std::map< int, std::vector< std::size_t > > JetGroupInd2ElemInds
Definition: elementalJetGroups.h:11
Collector
std::unique_ptr< ITrigJetHypoInfoCollector > Collector
Definition: FastReducer.h:22
JetGroupReducer::m_jetIndices
std::vector< std::size_t > m_jetIndices
Definition: JetGroupReducer.h:42
JetGroupReducer::valid
virtual bool valid() const override
Definition: JetGroupReducer.cxx:93
JetGroupReducer::next
virtual std::vector< std::size_t > next(const Collector &) override
Definition: JetGroupReducer.cxx:77
elementalJetGroups.h
JetGroupReducer::m_done
bool m_done
Definition: JetGroupReducer.h:43