Skip to content
Snippets Groups Projects
Commit 67c4a2a1 authored by Edward Moyse's avatar Edward Moyse
Browse files

Merge branch 'master-ATR-20700-3' into 'master'

Partial fulfilment of ATR-20700

See merge request atlas/athena!38903
parents b985a3d4 03333a26
No related branches found
No related tags found
6 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
Showing
with 189 additions and 118 deletions
......@@ -48,12 +48,10 @@ def preprocess(s):
s = ss
check_parens(s)
print(s)
from TrigHLTJetHypo.constants import alphabet
for c in s:
if c not in alphabet:
raise RuntimeError('bad character %s in string %s' % (c, s))
print('end of preprocess: ', s)
check_parens(s)
return s
......
......@@ -122,9 +122,12 @@ class ConditionsToolSetterFastReduction(object):
condition_tool =self._get_tool_instance('capacitychecked')
if cpi:
condition_tool.chainLegLabel = cpi
# convert label from string to int for more efficient
# processing in C++ land.
condition_tool.chainPartInd = int(cpi[len('leg'):])
else:
condition_tool.chainLegLabel = ''
condition_tool.chainPartInd = 0
condition_tool.conditionMakers = condition_tools
condition_tool.multiplicity = mult
......@@ -242,3 +245,5 @@ class ConditionsToolSetterFastReduction(object):
helper_tool.parent_id = tree.parent_id
self.tool = helper_tool
print (self.tool)
......@@ -69,7 +69,6 @@ class ConditionsToolSetterHT(object):
assert node.scenario == 'ht'
print (node)
conditionMaker = self._get_tool_instance('htcondition')
config_tool = self._get_tool_instance('htconfig')
cut_windows = {}
......@@ -78,7 +77,7 @@ class ConditionsToolSetterHT(object):
for d in node.conf_attrs: assert d[1] == 1
[cut_windows.update(d[0]) for d in node.conf_attrs]
print (cut_windows)
conditionMaker.htmin = cut_windows['ht']['min']
conditionMaker.etmin = cut_windows['et']['min']
conditionMaker.etamin = cut_windows['eta']['min']
......
......@@ -74,7 +74,7 @@ def trigJetHypoToolHelperFromDict(chain_dict):
Tool tree structure."""
log.debug('trigJetHypoToolFromDictc chainDict %s', str(chain_dict))
log.debug('trigJetHypoToolFromDict chainDict %s', str(chain_dict))
try:
chain_label = chainDict2jetLabel(chain_dict)
......@@ -102,24 +102,26 @@ def trigJetHypoToolHelperFromDict(chain_dict):
toolSetter)
def trigJetHypoToolFromDict_(chain_dict, tool):
def trigJetHypoToolFromDict_(chain_dict, hypo_tool, debug=False):
"""Produce a jet trigger hypo tool from a chainDict"""
log.debug('trigJetHypoToolFromDict_ tool type ',
tool.__class__.__name__,
hypo_tool.__class__.__name__,
' chainDict ',
str(chain_dict))
# obtain a Helper Tool (possibly a tree of tools) to
# make the hypo decision.
tool.helper_tool = trigJetHypoToolHelperFromDict(chain_dict)
hypo_tool.helper_tool = trigJetHypoToolHelperFromDict(chain_dict)
# controls whether debug visitor is sent to helper tool
debug = False # SET TO False WHEN COMMITTING
tool.visit_debug = debug
log.debug('%s', tool)
hypo_tool.visit_debug = debug
return tool
hypo_tool.chain_name = chain_dict['chainName']
log.debug('%s', hypo_tool)
return hypo_tool
def trigJetTLAHypoToolFromDict(chain_dict):
......@@ -128,8 +130,9 @@ def trigJetTLAHypoToolFromDict(chain_dict):
def trigJetHypoToolFromDict(chain_dict):
debug = False # SET TO FALSE WHEN COMMITTING
tool = CompFactory.TrigJetHypoToolMT(name=chain_dict['chainName'])
return trigJetHypoToolFromDict_(chain_dict, tool)
return trigJetHypoToolFromDict_(chain_dict, tool, debug)
import unittest
......
......@@ -10,8 +10,8 @@
CapacityCheckedCondition::CapacityCheckedCondition(std::unique_ptr<IConditionMT> cp,
std::size_t mult,
const std::string& label):
m_condition{std::move(cp)}, m_multiplicity{mult}, m_label{label}{}
int cpInd):
m_condition{std::move(cp)}, m_multiplicity{mult}, m_chainPartInd{cpInd}{}
CapacityCheckedCondition::~CapacityCheckedCondition(){}
......@@ -37,15 +37,19 @@ std::string CapacityCheckedCondition::toString() const {
const void* address = static_cast<const void*>(this);
ss << "CapacityCheckedCondition (" << address << ") Multiplicity: "
<< m_multiplicity << " label "
<< m_label << '\n'
<< m_multiplicity
<< " chainPartInd " << m_chainPartInd << '\n'
<< m_condition->toString();
return ss.str();
}
std::string CapacityCheckedCondition::label() const {
return m_label;
int CapacityCheckedCondition::label() const {
return m_chainPartInd;
}
bool CapacityCheckedCondition::isFromChainPart() const {
return m_chainPartInd >= 0;
}
std::ostream& operator<<(std::ostream& out,
......
......@@ -30,7 +30,7 @@ class CapacityCheckedCondition: public ICapacityCheckedCondition {
public:
CapacityCheckedCondition(std::unique_ptr<IConditionMT> cp,
std::size_t mult,
const std::string& label="");
int chainPartind = -1);
virtual ~CapacityCheckedCondition();
virtual bool
......@@ -44,13 +44,17 @@ class CapacityCheckedCondition: public ICapacityCheckedCondition {
virtual std::string toString() const override;
virtual std::string label() const override;
virtual int label() const override;
virtual bool isFromChainPart() const override;
private:
std::unique_ptr<IConditionMT> m_condition;
std::size_t m_multiplicity;
std::string m_label;
std::size_t m_multiplicity{1};
// record of which chain part in the chainDict this conditions comes from
int m_chainPartInd{-1};
};
std::ostream& operator<<(std::ostream&,
......
......@@ -15,6 +15,8 @@ DebugInfoCollector::DebugInfoCollector(const std::string& name,
m_timer.start();
}
DebugInfoCollector::~DebugInfoCollector(){write();}
void DebugInfoCollector::collect(const std::string& key,
const std::string& info){
m_info[key].emplace_back(m_timer.elapsed(), info);
......
......@@ -15,6 +15,9 @@ class DebugInfoCollector: public ITrigJetHypoInfoCollector {
public:
DebugInfoCollector(const std::string& name="Unknown",
bool byTime=true);
~DebugInfoCollector();
virtual void collect(const std::string&, const std::string&) override;
virtual std::string toString() const override;
......
......@@ -16,16 +16,13 @@ FastReductionMatcher::FastReductionMatcher(ConditionPtrs conditions,
m_tree(tree){
for (const auto& il : m_tree.leaves()){
auto label = m_conditions[il]->label();
if (label.rfind("leg", 0) != 0) { // startswith "leg"
throw std::runtime_error("Leaf condition " + std::to_string(il) +
"has no leg label");
if (!m_conditions[il]->isFromChainPart()) {
throw std::runtime_error("Tree leaf condition but not from ChainPart");
}
}
}
std::optional<bool>
FastReductionMatcher::match(const HypoJetGroupCIter& groups_b,
const HypoJetGroupCIter& groups_e,
......
......@@ -33,8 +33,10 @@ class ICapacityCheckedCondition: public IConditionMT {
virtual bool multiplicitySatisfied(std::size_t jgMultiplicity,
const Collector&) const = 0;
virtual std::string label() const = 0;
virtual int label() const = 0;
virtual std::string toString() const = 0;
virtual bool isFromChainPart() const = 0;
};
......
......@@ -34,8 +34,8 @@ SingleConditionMatcherMT::match(const HypoJetGroupCIter& jets_b,
if (m_condition->isSatisfied(*i, v)){
// Note that this slightly out-of-date code does not expect
// chains with simple and non-simple scenarios to be present in the
// same chain. The leg label is hard coded here.
jetCollector.addJets((*i).cbegin(), (*i).cend(), "leg000");
// same chain. The chain part ind is hard coded here to be 0.
jetCollector.addJets((*i).cbegin(), (*i).cend(), 0);
return std::make_optional<bool>(true);
}
}
......
......@@ -36,7 +36,8 @@ TrigJetConditionConfig_capacitychecked::getCapacityCheckedCondition() const {
return std::make_unique<CapacityCheckedCondition>(std::move(cc),
m_multiplicity,
m_chainLegLabel);
m_chainPartInd);
}
......
......@@ -36,9 +36,10 @@ public extends<AthAlgTool, ITrigJetCapacityCheckedConditionConfig> {
"no. of occurences of identical condition"};
Gaudi::Property<std::string> m_chainLegLabel {this,
"chainLegLabel",
{""},
Gaudi::Property<std::size_t> m_chainPartInd {this,
"chainPartInd",
{0},
"identifier for chain leg - used to group jets for jet hypo clients "};
......
......@@ -64,7 +64,7 @@ StatusCode
TrigJetHypoToolMT::decide(const xAOD::JetContainer* jets,
const TrigCompositeUtils::DecisionIDContainer& previousDecisionIDs,
std::vector<JetDecision>& jetHypoInputs) const {
if (not TrigCompositeUtils::passed(getId().numeric(), previousDecisionIDs)) {
// This HypoTool's chain is not active -
// we must not check this tool's logic.
......@@ -73,7 +73,13 @@ TrigJetHypoToolMT::decide(const xAOD::JetContainer* jets,
return StatusCode::SUCCESS;
}
std::unique_ptr<ITrigJetHypoInfoCollector> infocollector(nullptr);
if(m_visitDebug){
auto collectorName = name() + std::to_string(m_eventSN->getSN());
infocollector.reset(new DebugInfoCollector(collectorName));
}
HypoJetVector hypoJets(jets->size());
std::transform(jets -> begin(),
......@@ -88,11 +94,7 @@ TrigJetHypoToolMT::decide(const xAOD::JetContainer* jets,
<< "...");
// steady_clock::time_point t = steady_clock::now();
std::unique_ptr<ITrigJetHypoInfoCollector> infocollector(nullptr);
if(m_visitDebug){
auto collectorName = name() + std::to_string(m_eventSN->getSN());
infocollector.reset(new DebugInfoCollector(collectorName));
}
xAODJetCollector jetCollector;
bool pass;
......@@ -103,70 +105,37 @@ TrigJetHypoToolMT::decide(const xAOD::JetContainer* jets,
<< e.what());
return StatusCode::FAILURE;
}
std::size_t decision_count{0};
if (pass) {
if (jetCollector.empty()) {
ATH_MSG_ERROR("HypoTool passed the event for " <<
getId().name() <<
", but did not specify which jets participated");
return StatusCode::FAILURE;
}
// jet hypo inputs:
// pairs of const xAOD::Jet* (first) and mutable Decision* (second)
auto participating_jets = jetCollector.xAODJets();
if (infocollector) {
infocollector->
collect(name(),
"no of xAODJets " + std::to_string(participating_jets.size()));
auto labels = jetCollector.legLabels();
std::stringstream ss;
for(const auto& label : labels){
auto jets = jetCollector.xAODJets(label);
ss << label << " [\n";
for(const auto& j : jets){
ss << static_cast<const void*>(j) << '\n';
}
ss << "]\n";
}
infocollector->collect(name(), ss.str());
}
for (auto& pair : jetHypoInputs) {
auto it = std::find(participating_jets.begin(),
participating_jets.end(),
pair.first);
if (it != participating_jets.end()) {
ATH_MSG_VERBOSE("Passing jet: pt " << (*it)->pt() << ", eta " << (*it)->eta() );
// This jet particpated in passing the event.
// Add this HypoTool's ID to this Decision object.
TrigCompositeUtils::addDecisionID(getId().numeric(), pair.second);
++decision_count;
}
if (!pass) {
if (infocollector){
std::string msg =
"hypo testing done: no of input jets " + std::to_string(jets->size())
+ " no of participating jets " + std::to_string(jetCollector.size())
+ " pass: false ";
infocollector->collect("TrigJetHypoToolMT", msg);
infocollector->write();
}
return StatusCode::SUCCESS;
}
CHECK(checkPassingJets(jetCollector, infocollector));
CHECK(reportPassingJets(jetCollector, jetHypoInputs));
// accumulateTime(steady_clock::now() - t);
std::string msg =
"hypo testing done: no of input jets " + std::to_string(jets->size())
+ " no of particlating jets " + std::to_string(jetCollector.size())
+ " decision count " + std::to_string(decision_count)
+ " pass ";
if (pass) {msg += "true"; } else { msg += "false";}
+ " pass: true";
ATH_MSG_DEBUG(msg);
if (infocollector){
infocollector->collect("TrigJetHypoToolMT", msg);
infocollector->write();
......@@ -174,6 +143,72 @@ TrigJetHypoToolMT::decide(const xAOD::JetContainer* jets,
return StatusCode::SUCCESS;
}
const HLT::Identifier& TrigJetHypoToolMT::getId() const{
return m_decisionId;
}
}
StatusCode
TrigJetHypoToolMT::checkPassingJets(xAODJetCollector& jetCollector,
std::unique_ptr<ITrigJetHypoInfoCollector>& infocollector) const {
if (jetCollector.empty()) {
ATH_MSG_ERROR("HypoTool passed the event for " <<
getId().name() <<
", but did not specify which jets participated");
return StatusCode::FAILURE;
}
// jet hypo inputs:
// pairs of const xAOD::Jet* (first) and mutable Decision* (second)
auto participating_jets = jetCollector.xAODJets();
if (infocollector) {
infocollector->
collect(name(),
"no of xAODJets " + std::to_string(participating_jets.size()));
auto legInds = jetCollector.legInds();
std::stringstream ss;
for(const auto& label : legInds){
auto jets = jetCollector.xAODJets(label);
ss << label << " [\n";
for(const auto& j : jets){
ss << static_cast<const void*>(j) << '\n';
}
ss << "]\n";
}
infocollector->collect(name(), ss.str());
}
return StatusCode::SUCCESS;
}
StatusCode
TrigJetHypoToolMT::reportPassingJets(xAODJetCollector& jetCollector,
std::vector<JetDecision>& jetHypoInputs) const {
auto participating_jets = jetCollector.xAODJets();
for (auto& pair : jetHypoInputs) {
auto it = std::find(participating_jets.begin(),
participating_jets.end(),
pair.first);
if (it == participating_jets.end()) {
// the input jet is not a jet that contributed
// to passing the hypo.
continue;
}
// This jet particpated in passing the event.
// Add this HypoTool's ID to this Decision object.
TrigCompositeUtils::addDecisionID(getId().numeric(), pair.second);
}
return StatusCode::SUCCESS;
}
......@@ -70,6 +70,15 @@ public:
std::unique_ptr<EventSN> m_eventSN;
StatusCode
checkPassingJets(xAODJetCollector&,
std::unique_ptr<ITrigJetHypoInfoCollector>&) const;
StatusCode reportPassingJets(xAODJetCollector&,
std::vector<JetDecision>& jetHypoInputs) const;
};
#endif
......@@ -63,6 +63,10 @@ class TrigJetTLAHypoToolMT: public AthAlgTool{
Gaudi::Property<bool>
m_visitDebug {this, "visit_debug", false, "debug flag"};
Gaudi::Property<std::string> m_chainName {
this, "chain_name", {}, "chain name"};
};
......
......@@ -9,8 +9,8 @@
void xAODJetCollector::addJets(const HypoJetCIter& begin,
const HypoJetCIter& end,
const std::string& label){
auto& jets = m_jets[label];
int chainPartInd){
auto& jets = m_jets[chainPartInd];
jets.insert(jets.end(), begin, end);
}
......@@ -29,14 +29,14 @@ std::vector<const xAOD::Jet*> xAODJetCollector::xAODJets() const {
std::vector<const xAOD::Jet*>
xAODJetCollector::xAODJets(const std::string& label) const {
xAODJetCollector::xAODJets(int chainPartInd) const {
if (m_jets.count(label) == 0){
if (m_jets.count(chainPartInd) == 0){
std::vector<const xAOD::Jet*> empty;
return empty;
}
const auto& jets = m_jets.at(label);
const auto& jets = m_jets.at(chainPartInd);
return xAODJets_(jets.cbegin(), jets.cend());
}
......@@ -54,17 +54,19 @@ HypoJetVector xAODJetCollector::hypoJets() const {
}
HypoJetVector xAODJetCollector::hypoJets(const std::string& label) const {
auto begin = m_jets.at(label).cbegin();
auto end = m_jets.at(label).cend();
HypoJetVector xAODJetCollector::hypoJets(int chainPartInd) const {
auto begin = m_jets.at(chainPartInd).cbegin();
auto end = m_jets.at(chainPartInd).cend();
HypoJetSet js(begin, end);
return HypoJetVector(js.begin(), js.end());
}
void xAODJetCollector::addOneJet(const pHypoJet jet,
const std::string& label){
m_jets[label].push_back(jet);
int chainPartInd){
m_jets[chainPartInd].push_back(jet);
}
......@@ -97,12 +99,12 @@ xAODJetCollector::xAODJets_(const HypoJetVector::const_iterator begin,
}
std::vector<std::string> xAODJetCollector::legLabels() const {
std::vector<std::string> labels;
std::vector<int> xAODJetCollector::legInds() const {
std::vector<int> legInds;
for(auto it = m_jets.begin(); it != m_jets.end(); ++it){
labels.push_back(it->first);
legInds.push_back(it->first);
}
return labels;
return legInds;
}
......@@ -23,26 +23,28 @@ public:
void addJets(const HypoJetCIter& begin,
const HypoJetCIter& end,
const std::string& label="");
int chainPartInd = -1);
std::vector<const xAOD::Jet*> xAODJets() const;
std::vector<const xAOD::Jet*> xAODJets(const std::string& label) const;
std::vector<const xAOD::Jet*> xAODJets(int chainPartInd) const;
HypoJetVector hypoJets() const;
HypoJetVector hypoJets(const std::string& label) const;
HypoJetVector hypoJets(int chainPartInd) const;
void addOneJet(const pHypoJet jet, int ind = -1);
void addOneJet(const pHypoJet jet, const std::string& label="");
std::size_t size() const;
bool empty() const;
std::vector<std::string> legLabels() const;
std::vector<int> legInds() const;
private:
std::map<std::string, HypoJetVector> m_jets;
// store passing jets by chainPart index. this defaults to -1
// only leaf nodes have indices >= 0
std::map<int, HypoJetVector> m_jets;
std::vector<const xAOD::Jet*>
......
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