Commit 19a5c453 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

Merge branch 'feature_ret_collection_filtering' into 'master'

[ATR-24398][ATR-24452] Update the way that rejected trigger navigation nodes are located

See merge request !48195
parents 22f02a5f 7e73088b
......@@ -107,7 +107,7 @@ std::vector< TrigCompositeUtils::LinkInfo<CONTAINER> > Trig::ChainGroup::feature
// Obtain navigation routes for objects which fail
if (condition == TrigDefs::includeFailedDecisions) {
std::vector<const TrigCompositeUtils::Decision*> rejectedDecisionNodes =
TrigCompositeUtils::getRejectedDecisionNodes(eventStore, thisChainIDs);
TrigCompositeUtils::getRejectedDecisionNodes(eventStore, HLTSummaryKeyIn.key(), thisChainIDs);
ATH_MSG_DEBUG("Chain " << chainID << " has " << rejectedDecisionNodes.size()
<< " dangling nodes in the graph from objects which were rejected.");
......
......@@ -84,9 +84,10 @@ StatusCode TrigNavSlimmingMTAlg::execute(const EventContext& ctx) const {
// These branches do not connect to the terminusNode, so we have to go hunting them explicitly.
// We need to pass in the evtStore as these nodes can be spread out over numerous collections.
// Like with the terminus node, we can restrict this search to only nodes which were rejected by certain chains.
// We also want to restrict the search to exclue the output collections of any other TrigNavSlimminMTAlg instances.\\s
// We also want to restrict the search to exclue the output collections of any other TrigNavSlimminMTAlg instances
// and let the function know what the primary input collecion is - from the name of this we can tell if we need to search one or many containers.
if (m_keepFailedBranches) {
std::vector<const Decision*> rejectedNodes = TrigCompositeUtils::getRejectedDecisionNodes(&*evtStore(), chainIDs, m_allOutputContainersSet);
std::vector<const Decision*> rejectedNodes = TrigCompositeUtils::getRejectedDecisionNodes(&*evtStore(), m_primaryInputCollection.key(), chainIDs, m_allOutputContainersSet);
for (const Decision* rejectedNode : rejectedNodes) {
// We do *not* enfoce that a member of chainIDs must be present in the starting node (rejectedNode)
// specifically because we know that at least one of chainIDs was _rejected_ here, but is active in the rejected
......
......@@ -237,30 +237,52 @@ namespace TrigCompositeUtils {
}
std::vector<const Decision*> getRejectedDecisionNodes(asg::EventStoreType* eventStore,
const std::string& summaryCollectionKey,
const DecisionIDContainer& ids,
const std::set<std::string>& keysToIgnore) {
std::vector<const Decision*> output;
// The list of containers we need to read can change on a file-by-file basis (it depends on the SMK)
// Hence we query SG for all collections rather than maintain a large and ever changing ReadHandleKeyArray
// The following list contains all known summary store identifiers where the graph nodes are spread out over O(100s) or O(1000s)
// of different SG collections. This is the raw output from running the trigger online.
// When dealing with this, we need to query eventStore->keys in every event to obtain the full set of collections to process.
static const std::vector<std::string> knownDistributedSummaryStores{"HLTNav_Summary"};
static std::vector<std::string> keys ATLAS_THREAD_SAFE;
static std::mutex keysMutex;
// TODO TODO TODO NEED TO REPLACE THIS WITH A STANDALONE-FRIENDLY VERSION
// The following list contains all known summary store identifiers where all nodes from the graph have been compactified / condensed
// down into a single container. Here we just have to search this one container.
static const std::vector<std::string> knownCompactSummaryStores{"HLTNav_Summary_OnlineSlimmed",
"HLTNav_Summary_ESDSlimmed",
"HLTNav_Summary_AODSlimmed",
"HLTNav_Summary_DAODSlimmed"};
std::vector<std::string> keys; // The SG keys we will be exploring to find rejected decision nodes
if (std::find(knownDistributedSummaryStores.cbegin(), knownDistributedSummaryStores.cend(), summaryCollectionKey) != knownDistributedSummaryStores.end() or summaryCollectionKey == "") {
// If we have a distributed store then we need to query SG to find all keys.
// This should be a rare case now that we run compactification "online" (i.e. immediately after the trigger has executed)
#ifndef XAOD_STANDALONE
{
std::lock_guard<std::mutex> lock(keysMutex);
if (keys.size() == 0) {
// In theory this can change from file to file,
// the use case for this function is monitoring, and this is typically over a single run.
eventStore->keys(static_cast<CLID>( ClassID_traits< DecisionContainer >::ID() ), keys);
}
}
// The list of containers we need to read can change on a file-by-file basis (it depends on the SMK)
// Hence we query SG for all collections rather than maintain a large and ever changing ReadHandleKeyArray
eventStore->keys(static_cast<CLID>( ClassID_traits< DecisionContainer >::ID() ), keys);
#else
eventStore->event(); // Avoid unused warning
throw std::runtime_error("Cannot yet obtain rejected HLT features in AnalysisBase");
eventStore->event(); // Avoid unused warning
throw std::runtime_error("Cannot obtain rejected HLT features in AnalysisBase when reading from uncompactified navigation containers, run trigger navigation slimming first if you really need this.");
#endif
} else if (std::find(knownCompactSummaryStores.cbegin(), knownCompactSummaryStores.cend(), summaryCollectionKey) != knownCompactSummaryStores.end()) {
keys.push_back(summaryCollectionKey);
} else {
using namespace msgRejected;
ANA_MSG_WARNING("getRejectedDecisionNodes has not been told about final collection " << summaryCollectionKey << " please update this function. Assuming that it is already compact.");
// Safest to assume that this is a compact summary store
keys.push_back(summaryCollectionKey);
}
std::vector<const Decision*> output; // The return vector of identified nodes where one of the chains in 'ids' was rejected
// Loop over each DecisionContainer,
for (const std::string& key : keys) {
// Get and check this container
......@@ -311,7 +333,7 @@ namespace TrigCompositeUtils {
DecisionIDContainer chainsToCheck;
if (ids.size() == 0) { // We care about *all* chains
chainsToCheck = activeChainsIntoThisDecision;
} else { // We care about sepcified chains
} else { // We care about specified chains
chainsToCheck = ids;
}
// We have found a rejected decision node *iff* a chainID to check is *not* present here
......
......@@ -276,7 +276,7 @@ namespace TrigCompositeUtils {
/**
* @brief Returns the terminus navigation node from a collection, assuming that the passed collection contains the termninus node
* @brief Returns the terminus navigation node from a collection, assuming that the passed collection contains the terminus node
* @param[in] Collection of navigation nodes which contains the terminus node
* @return The terminus node, or a nullptr if the node is not found
**/
......@@ -286,11 +286,13 @@ namespace TrigCompositeUtils {
/**
* @brief Query all DecisionCollections in the event store, locate all Decision nodes in the graph where an object failed selection for a given chain.
* @param[in] eventStore Pointer to event store within current event context
* @param[in] summaryCollectionKey The primary source of navigation data in the event (i.e the collection which contains the navigation terminus node).
* @param[in] ids IDs of chain (if multi-leg chain, include all legs) to located failed decision nodes for. Passing an empty set returns all decision nodes which failed at least one chain.
* @param[in] keysToIgnore Set of SG keys of containers which should not be explored by getRejectedDecisionNodes.
* @return Vector of Decision nodes whose attached feature failed the trigger chain logic for chain with DecisionID id
**/
std::vector<const Decision*> getRejectedDecisionNodes(asg::EventStoreType* eventStore,
const std::string& summaryCollectionKey,
const DecisionIDContainer& ids = {},
const std::set<std::string>& keysToIgnore = std::set<std::string>());
......
......@@ -56,7 +56,7 @@ int main ATLAS_NOT_THREAD_SAFE () {
const EventContext& ctx1 = Gaudi::Hive::currentContext();
log << "Current context: " << ctx1 << endmsg;
SG::WriteHandleKey<DecisionContainer> decisionContainerKey("HLTNav_DC");
SG::WriteHandleKey<DecisionContainer> decisionContainerKey("HLTNav_Summary_OnlineSlimmed"); // We have a single collection, so we use the same name as the online compactified collection
SG::WriteHandleKey<xAOD::ElectronContainer> electronContainerKey("MyElectronContainer");
SG::WriteHandleKey<xAOD::MuonContainer> muonContainerKey("MyMuonContainer");
......@@ -382,11 +382,11 @@ int main ATLAS_NOT_THREAD_SAFE () {
std::cout << " ---------- Now Include Failing Features " << std::endl;
std::vector<const Decision*> extraStart_HLT_mufast_chain = getRejectedDecisionNodes(pSG, {HLT_mufast_chain});
std::vector<const Decision*> extraStart_HLT_mu_chain = getRejectedDecisionNodes(pSG, {HLT_mu_chain});
std::vector<const Decision*> extraStart_HLT_mu_em_chain = getRejectedDecisionNodes(pSG, {HLT_mu_em_chain});
std::vector<const Decision*> extraStart_HLT_em_chain = getRejectedDecisionNodes(pSG, {HLT_em_chain});
std::vector<const Decision*> extraStart_HLT_all = getRejectedDecisionNodes(pSG, {});
std::vector<const Decision*> extraStart_HLT_mufast_chain = getRejectedDecisionNodes(pSG, decisionContainerKey.key(), {HLT_mufast_chain});
std::vector<const Decision*> extraStart_HLT_mu_chain = getRejectedDecisionNodes(pSG, decisionContainerKey.key(), {HLT_mu_chain});
std::vector<const Decision*> extraStart_HLT_mu_em_chain = getRejectedDecisionNodes(pSG, decisionContainerKey.key(), {HLT_mu_em_chain});
std::vector<const Decision*> extraStart_HLT_em_chain = getRejectedDecisionNodes(pSG, decisionContainerKey.key(), {HLT_em_chain});
std::vector<const Decision*> extraStart_HLT_all = getRejectedDecisionNodes(pSG, decisionContainerKey.key(), {});
for (const Decision* d : extraStart_HLT_mufast_chain) {
recursiveGetDecisions(d, graph_HLT_mufast_chain, {HLT_mufast_chain}, false);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment