Skip to content
Snippets Groups Projects
Commit 03b40252 authored by Peter Sherwood's avatar Peter Sherwood
Browse files

Jet hypo. Mostly config work to record chainpart index info, used to report passing jets by leg.

chainDict2jetLabel.py
	for the simple scenario only,
	maintain index in the between the square brackets of the scenario arguments. Until
	now, this has been used only to provide cut values. The index must be removed
	befor the cut values are used to intialise Condtion creation  AlgTools. This is done
	in by TreeParameterExpander_simple, which is located in treeVisitors.py

ConditionsToolSetterFastReduction.py
	use the chain part index ot set the leg paramter in the  TrigJetConditionConfig_XXX tools
	dead code removal

NodeSplitterVisitor.py
	maintain chain part index. when splitting nodes.

xAODJetCollector.h
	maintain lits of passing jets by leg label

TrigHLTJetHypoUnitTests/CMakeLists.txt
	remove obolete tests.
parent 214005cd
No related branches found
No related tags found
8 merge requests!58791DataQualityConfigurations: Modify L1Calo config for web display,!46784MuonCondInterface: Enable thread-safety checking.,!46776Updated LArMonitoring config file for WD to match new files produced using MT,!45405updated ART test cron job,!42417Draft: DIRE and VINCIA Base Fragments for Pythia 8.3,!38903Partial fulfilment of ATR-20700,!38811Partial fulfilment of ATR-20700 - reporting events passing jet hypo by leg,!38707Partial fulfilment of reporting jet hypo passing jets "by leg"
Showing with 59 additions and 113 deletions
...@@ -73,51 +73,7 @@ class ConditionsToolSetterFastReduction(object): ...@@ -73,51 +73,7 @@ class ConditionsToolSetterFastReduction(object):
self._set_conditions(cn) self._set_conditions(cn)
def _remove_combgen(self, node):
"""Combination nodes represent parent children relationships.
The child may be a subtree. For now, the parent will be in the
child list at position 0, and the child subtree in position 1."""
parent_children = {}
ipos = 0
# identify the combgen nodes, and rotate them
for cn in node.children:
if cn.scenario == 'combgen':
assert (len(cn.children) == 2)
parent_children[ipos] = cn.children
ipos += 1
# rotate the first combgen child (parent) into the position of the
# combgen node, and set its child node.
for pos, p_c in parent_children.items():
node.children[pos] = p_c[0]
node.children[pos].children = [p_c[1]]
for cn in node.children:
self._remove_combgen(cn)
def _remove_scenario(self, node, scenario):
"""Remove Partgen nodes by adding their children to their
parent's children."""
def remove_scenario(node, scenario):
for cn in node.children:
if cn.scenario == scenario:
node.children.remove(cn)
node.children.extend(cn.children)
return True
return False
more = True
while(more):
more = remove_scenario(node, scenario)
for cn in node.children:
self._remove_scenario(cn, scenario)
def _get_tool_instance(self, key, extra=''): def _get_tool_instance(self, key, extra=''):
klass = self.tool_factories[key][0] klass = self.tool_factories[key][0]
...@@ -138,7 +94,15 @@ class ConditionsToolSetterFastReduction(object): ...@@ -138,7 +94,15 @@ class ConditionsToolSetterFastReduction(object):
# loop over elements of node.conf_attrs. The elements are (dict, int) # loop over elements of node.conf_attrs. The elements are (dict, int)
# int is multiplicity, dict holds Condition parameters. # int is multiplicity, dict holds Condition parameters.
for c, mult in node.conf_attrs: imax = len(node.conf_attrs)
for i in range(len(node.conf_attrs)):
c, mult = node.conf_attrs[i]
cpi = ''
if node.chainpartinds:
cpi = node.chainpartinds[i][0]
assert mult == node.chainpartinds[i][1]
condition_tools = [] # elemental conditions for this compounnd ct. condition_tools = [] # elemental conditions for this compounnd ct.
for k, v in c.items(): # loop over elemental conditions for k, v in c.items(): # loop over elemental conditions
condition_tool = self._get_tool_instance(k) condition_tool = self._get_tool_instance(k)
...@@ -159,12 +123,12 @@ class ConditionsToolSetterFastReduction(object): ...@@ -159,12 +123,12 @@ class ConditionsToolSetterFastReduction(object):
# create capacitychecked condition from elemental condition # create capacitychecked condition from elemental condition
condition_tool =self._get_tool_instance('capacitychecked') condition_tool =self._get_tool_instance('capacitychecked')
condition_tool.chainLegLabel = cpi
condition_tool.conditionMakers = condition_tools condition_tool.conditionMakers = condition_tools
condition_tool.multiplicity = mult condition_tool.multiplicity = mult
# add capacitychecked condition to list # add capacitychecked condition to list
outer_condition_tools.append(condition_tool) outer_condition_tools.append(condition_tool)
return outer_condition_tools return outer_condition_tools
def _mod_leaf(self, node): def _mod_leaf(self, node):
...@@ -186,40 +150,6 @@ class ConditionsToolSetterFastReduction(object): ...@@ -186,40 +150,6 @@ class ConditionsToolSetterFastReduction(object):
node.compound_condition_tools = self._make_compound_condition_tools( node.compound_condition_tools = self._make_compound_condition_tools(
node) node)
def _split_leaves(self, node):
"""Recursively replace leaf nodes with >1 Condition tools by nodes with
one Condition tool."""
def split_leaves(node):
for cn in node.children:
if is_leaf(cn):
if len(cn.compound_condition_tools) > 1:
new_children = []
new_node = copy.deepcopy(cn)
# set scenarrio to other than leaf results in
# the assignement of an acceptall condition
new_node.scenario = 'inserted'
new_node.compound_condition_tools = []
for ct in cn.compound_condition_tools:
new_children.append(copy.deepcopy(cn))
new_children[-1].compound_condition_tools = [ct]
new_children[-1].conf_attrs = []
new_node.children.extend(new_children)
node.children.remove(cn)
node.children.append(new_node)
return True # return after first modification
return False
more = True
while(more):
more = split_leaves(node)
for cn in node.children:
self._split_leaves(cn)
def _find_shared(self, node, shared): def _find_shared(self, node, shared):
"""Determine which nodes are "shared" - shared nodes """Determine which nodes are "shared" - shared nodes
are nodes that see the input jet collection. There are nodes that see the input jet collection. There
...@@ -258,6 +188,7 @@ class ConditionsToolSetterFastReduction(object): ...@@ -258,6 +188,7 @@ class ConditionsToolSetterFastReduction(object):
def _fill_conditions_map(self, node, cmap): def _fill_conditions_map(self, node, cmap):
if is_leaf(node): if is_leaf(node):
print(self.__class__.__name__, node)
assert (len(node.compound_condition_tools) == 1) assert (len(node.compound_condition_tools) == 1)
cmap[node.node_id] = node.compound_condition_tools[0] cmap[node.node_id] = node.compound_condition_tools[0]
...@@ -304,18 +235,8 @@ class ConditionsToolSetterFastReduction(object): ...@@ -304,18 +235,8 @@ class ConditionsToolSetterFastReduction(object):
# add Condition builders to leaf nodes. # add Condition builders to leaf nodes.
self._set_conditions(tree) self._set_conditions(tree)
# # Alg step 2: remove combgen nodes # identify the leaf nodes that are to shared
# self._remove_combgen(root)
# Alg step 3: split leaf nodes with multiple Conditions with a
# single Condition
# self._split_leaves(root)
# Alg step 4: remove partgen nodes
# single Condition
# Alg step 5: identify the leaf nodes that are to shared
# ie that see the input jet collection. Then remove And nodes # ie that see the input jet collection. Then remove And nodes
shared = [] shared = []
self.shared = self._find_shared(tree, shared) self.shared = self._find_shared(tree, shared)
......
...@@ -31,11 +31,18 @@ class NodeSplitterVisitor(object): ...@@ -31,11 +31,18 @@ class NodeSplitterVisitor(object):
new_children = [] new_children = []
for c in node.children: for c in node.children:
if c.scenario == 'simple': if c.scenario == 'simple':
for c_a in c.conf_attrs: print ('chainparts', c.chainpartinds)
print ('conf_attrs', c.conf_attrs)
assert (len(c.chainpartinds) ==
len(c.conf_attrs)) or not c.chainpartinds
for cpi, c_a in zip(c.chainpartinds, c.conf_attrs):
n_c = copy.deepcopy(c) n_c = copy.deepcopy(c)
n_c.conf_attrs = [c_a] n_c.conf_attrs = [c_a]
n_c.chainpartinds = [cpi]
new_children.append(n_c) new_children.append(n_c)
print ('node dump', self.__class__.__name__ + '::mod()', n_c)
else: else:
print ('node dump', self.__class__.__name__ + '::mod()', node)
new_children.append(c) new_children.append(c)
......
...@@ -115,6 +115,7 @@ def trigJetHypoToolFromDict(chain_dict): ...@@ -115,6 +115,7 @@ def trigJetHypoToolFromDict(chain_dict):
# controls whether debug visitor is sent to helper tool # controls whether debug visitor is sent to helper tool
debug = False # SET TO False WHEN COMMITTING debug = False # SET TO False WHEN COMMITTING
debug = True # SET TO False WHEN COMMITTING
tool.visit_debug = debug tool.visit_debug = debug
log.debug('%s', tool) log.debug('%s', tool)
......
...@@ -39,7 +39,8 @@ def _make_simple_label(chain_parts): ...@@ -39,7 +39,8 @@ def _make_simple_label(chain_parts):
'chain fails substring selection: not "simple" ' 'chain fails substring selection: not "simple" '
raise NotImplementedError(msg) raise NotImplementedError(msg)
chainpartind = 0
label = 'simple([' label = 'simple(['
for cp in chain_parts: for cp in chain_parts:
smcstr = str(cp['smc']) smcstr = str(cp['smc'])
...@@ -65,9 +66,12 @@ def _make_simple_label(chain_parts): ...@@ -65,9 +66,12 @@ def _make_simple_label(chain_parts):
condition_str += ',%s' % cut condition_str += ',%s' % cut
else: else:
condition_str += ',%s' % momstr condition_str += ',%s' % momstr
condition_str += ', chainpartind{:0>3}'.format(chainpartind)
if not condition_str.endswith(')'): if not condition_str.endswith(')'):
condition_str += ')' condition_str += ')'
label += condition_str label += condition_str
chainpartind += 1
label += '])' label += '])'
return label return label
...@@ -100,6 +104,7 @@ def _make_vbenf_label(chain_parts): ...@@ -100,6 +104,7 @@ def _make_vbenf_label(chain_parts):
# scenario requires a dijet of mass > 900, and opening angle in phi > 2.6 # scenario requires a dijet of mass > 900, and opening angle in phi > 2.6
assert len(chain_parts) == 1 assert len(chain_parts) == 1
scenario = chain_parts[0]['hypoScenario'] scenario = chain_parts[0]['hypoScenario']
assert scenario.startswith('vbenf') assert scenario.startswith('vbenf')
args = _args_from_scenario(scenario) args = _args_from_scenario(scenario)
...@@ -288,7 +293,6 @@ def _make_agg_label(chain_parts): ...@@ -288,7 +293,6 @@ def _make_agg_label(chain_parts):
print (argvals) print (argvals)
assert len(argvals) == 2*nargs, 'no of args: %d, expected %d' % (len(argvals), 2*nargs) assert len(argvals) == 2*nargs, 'no of args: %d, expected %d' % (len(argvals), 2*nargs)
print ('sent 100')
result = """ result = """
ht([(%(htlo).0fht) ht([(%(htlo).0fht)
(%(etlo).0fet) (%(etlo).0fet)
......
...@@ -33,6 +33,7 @@ class Node(object): ...@@ -33,6 +33,7 @@ class Node(object):
# self.compound_condition_tools = [] # self.compound_condition_tools = []
# self.tree_top kludge carensure top level tools get chain name # self.tree_top kludge carensure top level tools get chain name
# as Tool name # as Tool name
self.chainpartinds = []
self.tree_top = False self.tree_top = False
self.tool = None self.tool = None
...@@ -85,6 +86,7 @@ class Node(object): ...@@ -85,6 +86,7 @@ class Node(object):
indent + 'parent node id: %s' % self.parent_id, indent + 'parent node id: %s' % self.parent_id,
indent + 'is tree top? %s' % self.tree_top, indent + 'is tree top? %s' % self.tree_top,
indent + 'parameters: %s' % str(self.parameters), indent + 'parameters: %s' % str(self.parameters),
indent + 'chainpartinds %s' % str(self.chainpartinds),
indent + 'conf_attrs [%d]:' % len(self.conf_attrs)] indent + 'conf_attrs [%d]:' % len(self.conf_attrs)]
for ca in self.conf_attrs: for ca in self.conf_attrs:
s.append(indent + str(ca)) s.append(indent + str(ca))
......
...@@ -124,7 +124,7 @@ class ConditionsDictMaker(object): ...@@ -124,7 +124,7 @@ class ConditionsDictMaker(object):
r'^(?P<lo>\d*)(?P<attr>[%s]+)(?P<hi>\d*)' % lchars) r'^(?P<lo>\d*)(?P<attr>[%s]+)(?P<hi>\d*)' % lchars)
# key: substring from chain label. value: asttribute of python # key: substring from chain label. value: attribute of python
# component proxy # component proxy
def get_conditions(self, params): def get_conditions(self, params):
...@@ -155,6 +155,7 @@ class ConditionsDictMaker(object): ...@@ -155,6 +155,7 @@ class ConditionsDictMaker(object):
def makeDict(self, params): def makeDict(self, params):
# conditions example: ['10et,0eta320', '20et'] # conditions example: ['10et,0eta320', '20et']
conditions = self.get_conditions(params) conditions = self.get_conditions(params)
...@@ -164,14 +165,21 @@ class ConditionsDictMaker(object): ...@@ -164,14 +165,21 @@ class ConditionsDictMaker(object):
for c in conditions: mult_conditions[c] += 1 for c in conditions: mult_conditions[c] += 1
result = [] result = []
chainpartinds = []
msgs = [] msgs = []
# process each parameter string once. # process each parameter string once.
for c, mult in mult_conditions.items(): # c is condition string for c, mult in mult_conditions.items(): # c is condition string
cdict = defaultdict(dict) cdict = defaultdict(dict)
toks = c.split(',') # parameters in par string are separated by ',' toks = c.split(',') # parameters in par string are separated by ','
toks = [t.strip() for t in toks] toks = [t.strip() for t in toks]
cpis = [t for t in toks if t.startswith('chainpartind')]
assert len(cpis) < 2
if cpis:
chainpartinds.append((cpis[0], mult))
toks.remove(chainpartinds[-1][0])
for t in toks: for t in toks:
m = self.window_re.match(t) m = self.window_re.match(t)
...@@ -248,7 +256,7 @@ class ConditionsDictMaker(object): ...@@ -248,7 +256,7 @@ class ConditionsDictMaker(object):
msgs = ['ConditionsDict OK'] msgs = ['ConditionsDict OK']
error = False error = False
return result, error, msgs return result, chainpartinds, error, msgs
class TreeParameterExpander_simple(object): class TreeParameterExpander_simple(object):
...@@ -267,10 +275,11 @@ class TreeParameterExpander_simple(object): ...@@ -267,10 +275,11 @@ class TreeParameterExpander_simple(object):
def mod(self, node): def mod(self, node):
cdm = ConditionsDictMaker() cdm = ConditionsDictMaker()
d, error, msgs = cdm.makeDict(node.parameters) d, chainpartinds, error, msgs = cdm.makeDict(node.parameters)
self.msgs.extend(msgs) self.msgs.extend(msgs)
node.conf_attrs = d node.conf_attrs = d
node.chainpartinds = chainpartinds
def report(self): def report(self):
return '%s: ' % self.__class__.__name__ + '\n'.join(self.msgs) return '%s: ' % self.__class__.__name__ + '\n'.join(self.msgs)
...@@ -295,9 +304,10 @@ class TreeParameterExpander_dijet(object): ...@@ -295,9 +304,10 @@ class TreeParameterExpander_dijet(object):
def mod(self, node): def mod(self, node):
cdm = ConditionsDictMaker() cdm = ConditionsDictMaker()
d, error, msgs = cdm.makeDict(node.parameters) d, chainpartinds, error, msgs = cdm.makeDict(node.parameters)
self.msgs.extend(msgs) self.msgs.extend(msgs)
node.conf_attrs = d node.conf_attrs = d
node.chainpartinds = chainpartinds
def report(self): def report(self):
return '%s: ' % self.__class__.__name__ + '\n'.join(self.msgs) return '%s: ' % self.__class__.__name__ + '\n'.join(self.msgs)
......
...@@ -37,7 +37,9 @@ std::string CapacityCheckedCondition::toString() const { ...@@ -37,7 +37,9 @@ std::string CapacityCheckedCondition::toString() const {
const void* address = static_cast<const void*>(this); const void* address = static_cast<const void*>(this);
ss << "CapacityCheckedCondition (" << address << ") Multiplicity: " ss << "CapacityCheckedCondition (" << address << ") Multiplicity: "
<< m_multiplicity << '\n' << m_condition->toString(); << m_multiplicity << " label "
<< m_label << '\n'
<< m_condition->toString();
return ss.str(); return ss.str();
} }
......
...@@ -26,7 +26,7 @@ public: ...@@ -26,7 +26,7 @@ public:
void addJets(const HypoJetCIter& begin, void addJets(const HypoJetCIter& begin,
const HypoJetCIter& end, const HypoJetCIter& end,
const std::string& label=""){ const std::string& label=""){
auto& jets = m_jets.at(label); auto& jets = m_jets[label];
jets.insert(jets.end(), begin, end); jets.insert(jets.end(), begin, end);
} }
...@@ -43,7 +43,12 @@ public: ...@@ -43,7 +43,12 @@ public:
} }
std::vector<const xAOD::Jet*> xAODJets(const std::string& label) const { std::vector<const xAOD::Jet*> xAODJets(const std::string& label) const {
if (m_jets.count(label) == 0){
std::vector<const xAOD::Jet*> empty;
return empty;
}
const auto& jets = m_jets.at(label); const auto& jets = m_jets.at(label);
return xAODJets_(jets.cbegin(), jets.cend()); return xAODJets_(jets.cbegin(), jets.cend());
} }
...@@ -66,8 +71,8 @@ public: ...@@ -66,8 +71,8 @@ public:
m_jets[label].push_back(jet); m_jets[label].push_back(jet);
} }
std::size_t size() const {return m_jets.size();} std::size_t size() const {return hypoJets().size();}
bool empty() const {return m_jets.empty();} bool empty() const {return hypoJets().empty();}
private: private:
......
...@@ -33,15 +33,9 @@ atlas_add_test( TrigHLTJetHypoUnitTests ...@@ -33,15 +33,9 @@ atlas_add_test( TrigHLTJetHypoUnitTests
tests/FlowNetworkTest.cxx tests/FlowNetworkTest.cxx
tests/LlpCleanerTest.cxx tests/LlpCleanerTest.cxx
tests/LooseCleanerTest.cxx tests/LooseCleanerTest.cxx
tests/MaximumBipartiteGroupsMatcherTest.cxx
tests/MaximumBipartiteGroupsMatcherMTTest.cxx
tests/MaximumBipartiteGroupsMatcherMTTest_Multijet.cxx
tests/PartitionsGenTest.cxx
tests/PartitionsGroupsMatcherMTTest.cxx
tests/TLorentzVectorFactoryTest.cxx tests/TLorentzVectorFactoryTest.cxx
tests/TightCleanerTest.cxx tests/TightCleanerTest.cxx
tests/xAODJetCollectorTest.cxx tests/xAODJetCollectorTest.cxx
tests/PartitionsGrouperTest.cxx
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} GoogleTestTools ${GMOCK_LIBRARIES} TrigHLTJetHypoLib TrigHLTJetHypoUnitTestsLib ) LINK_LIBRARIES ${ROOT_LIBRARIES} GoogleTestTools ${GMOCK_LIBRARIES} TrigHLTJetHypoLib TrigHLTJetHypoUnitTestsLib )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment