ATLAS Offline Software
FastReductionMatcher.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "./FastReducer.h"
8 
9 #include <map>
10 #include <algorithm>
11 #include <sstream>
12 
14  ConditionFilters& filters,
15  const ConditionFilterInds& filterInds,
16  const Tree& tree):
17  m_conditions(std::move(conditions)),
18  m_conditionFilters(std::move(filters)),
19  m_conditionFilterInds(filterInds),
20  m_tree(tree){
21 
22  if (m_conditions[0]->capacity() != 0 or
23  m_conditions[0]-> multiplicity() != 1) {
24  m_validState= false;
25  m_msg = "Condition tree root node is not AcceptAll";
26  }
27 
28  int minNjets{0};
29  for (const auto& il : m_tree.leaves()){
30  const auto& condition = m_conditions[il];
31 
32  if (!condition->isFromChainPart()) {
33  m_validState = false;
34  m_msg = "Tree leaf condition but not from ChainPart";
35  }
36  minNjets += condition->capacity() * condition->multiplicity();
37 
38  }
39 
40  m_minNjets = std::max(1, minNjets);
41 
42  if (filterInds.size() != m_conditions.size()) {
43  m_validState = false;
44  std::stringstream ss;
45  ss << "ConditionFilterInds and Conditions sequence sizes differ: ";
46  ss << filterInds.size() << " " << m_conditions.size();
47  m_msg = ss.str();
48  }
49 
50 }
51 
52 
53 std::optional<bool>
55  xAODJetCollector& jetCollector,
56  const std::unique_ptr<ITrigJetHypoInfoCollector>& collector,
57  bool) const {
58  /*
59  Decide if the incomming jet groups satisfiy all the conditions of the
60  condition tree.
61 
62  The leaf nodes are tested first. Jet groups satisfyng the leaves
63  stored in a table. Once all leaves have been processed, the satisfying
64  groups are combined, and tested against the aprent nodes.
65 
66  The procedure is iterated until the entire tree is checked, or
67  an unsatisfied condition is found. If no unsatisfied condition,
68  there is a match.
69  */
70 
71  auto njets = jv.size();
72 
73  if (njets < m_minNjets) {
74  if (collector) {
75  collector->collect("FastReductionMatcher",
76  "have " + std::to_string(njets) +
77  " jets need " + std::to_string(m_minNjets) +
78  " pass: false");
79  }
80  return false;
81  }
82 
83  FastReducer reducer(jv,
87  m_tree,
88  jetCollector,
89  collector);
90 
91  return std::make_optional<bool>(reducer.pass());
92 }
93 
94 
95 std::string FastReductionMatcher::toString() const {
96  std::stringstream ss;
97  ss << "FastReductionMatcher:\n"
98  << " treeVector: " << m_tree << '\n'
99  << " min required jets " << m_minNjets << "\n\n"
100  << "FastReductionMatcher Conditions ["
101  << m_conditions.size() << "]: \n\n";
102 
103  std::size_t count{0u};
104  for(const auto& c : m_conditions){
105  auto sc = std::to_string(count++);
106  sc.insert(sc.begin(), 3-sc.length(), ' ');
107  ss << sc <<": "<< c->toString() + '\n';
108  }
109 
110 
111  ss << "FastReductionMatcher ConditionFilter indices ["
112  << m_conditionFilterInds.size() << "]: \n";
113 
114 
115  count = 0;
116  for(const auto& c : m_conditionFilterInds){
117  auto sc = std::to_string(count++);
118  sc.insert(sc.begin(), 3-sc.length(), ' ');
119  ss << sc <<": "<< c << '\n';
120  }
121 
122 
123  ss << "FastReductionMatcher ConditionFilters ["
124  << m_conditionFilters.size() << "]: \n";
125 
126 
127  count = 0;
128  for(const auto& c : m_conditionFilters){
129  auto sc = std::to_string(count++);
130  sc.insert(sc.begin(), 3-sc.length(), ' ');
131  ss << sc <<": "<< c->toString() + '\n';
132  }
133 
134 
135  return ss.str();
136 }
137 
139 std::string FastReductionMatcher::msg() const {return m_msg;}
PlotCalibFromCool.il
il
Definition: PlotCalibFromCool.py:381
FastReductionMatcher::FastReductionMatcher
FastReductionMatcher(ConditionPtrs &, ConditionFilters &, const ConditionFilterInds &, const Tree &)
Definition: FastReductionMatcher.cxx:13
max
#define max(a, b)
Definition: cfImp.cxx:41
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
Tree
Definition: Tree.h:18
FastReductionMatcher::m_conditionFilterInds
ConditionFilterInds m_conditionFilterInds
Definition: FastReductionMatcher.h:59
FastReducer.h
ConditionFilterInds
std::vector< int > ConditionFilterInds
Definition: FastReducer.h:33
tree
TChain * tree
Definition: tile_monitor.h:30
FastReductionMatcher::m_tree
Tree m_tree
tree structure for Conditions objects.
Definition: FastReductionMatcher.h:66
LArG4GenerateShowerLib.condition
condition
Definition: LArG4GenerateShowerLib.py:19
ITrigJetHypoInfoCollector::collect
virtual void collect(const std::string &, const std::string &)=0
FastReductionMatcher.h
FastReducer
Definition: FastReducer.h:35
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
FastReductionMatcher::m_minNjets
long unsigned int m_minNjets
Definition: FastReductionMatcher.h:70
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
FastReductionMatcher::m_conditionFilters
ConditionFilters m_conditionFilters
Definition: FastReductionMatcher.h:58
FastReductionMatcher::m_msg
std::string m_msg
Definition: FastReductionMatcher.h:74
FastReducer::pass
bool pass() const
determine whether a set of jets satisfies all hypo conditions.
Definition: FastReducer.cxx:552
HypoJetVector
std::vector< pHypoJet > HypoJetVector
Definition: HypoJetDefs.h:27
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
ConditionFilters
std::vector< std::unique_ptr< IHypoJetVectorFilter > > ConditionFilters
Definition: FastReducer.h:31
xAODJetCollector
Definition: xAODJetCollector.h:20
FastReductionMatcher::m_conditions
ConditionPtrs m_conditions
Definition: FastReductionMatcher.h:57
ITrigJetHypoInfoCollector.h
ConditionPtrs
std::vector< ConditionPtr > ConditionPtrs
Definition: RepeatedConditionsDefs.h:20
FastReductionMatcher::m_validState
bool m_validState
Definition: FastReductionMatcher.h:73
FastReductionMatcher::valid
virtual bool valid() const override
Definition: FastReductionMatcher.cxx:138
FastReductionMatcher::match
virtual std::optional< bool > match(const HypoJetVector &jv, xAODJetCollector &, const std::unique_ptr< ITrigJetHypoInfoCollector > &collector, bool) const override
determine whether a set of jets satisfies all hypo conditions.
Definition: FastReductionMatcher.cxx:54
python.compressB64.c
def c
Definition: compressB64.py:93
FastReductionMatcher::toString
std::string toString() const override
Definition: FastReductionMatcher.cxx:95
FastReductionMatcher::msg
virtual std::string msg() const override
Definition: FastReductionMatcher.cxx:139
Tree::leaves
const std::vector< std::size_t > & leaves() const
Definition: Tree.cxx:48