ATLAS Offline Software
Loading...
Searching...
No Matches
FastReductionMatcher.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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
53std::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
95std::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
139std::string FastReductionMatcher::msg() const {return m_msg;}
std::vector< int > ConditionFilterInds
std::vector< std::unique_ptr< IHypoJetVectorFilter > > ConditionFilters
std::vector< pHypoJet > HypoJetVector
Definition HypoJetDefs.h:27
static Double_t ss
static Double_t sc
std::vector< ConditionPtr > ConditionPtrs
bool pass() const
determine whether a set of jets satisfies all hypo conditions.
std::string toString() const override
FastReductionMatcher(ConditionPtrs &&, ConditionFilters &&, const ConditionFilterInds &, const Tree &)
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.
Tree m_tree
tree structure for Conditions objects.
virtual std::string msg() const override
ConditionFilterInds m_conditionFilterInds
virtual bool valid() const override
ConditionFilters m_conditionFilters
long unsigned int m_minNjets
Definition Tree.h:18
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
STL namespace.
TChain * tree