From 2a53a2eeb7b8bcbd37db584bd21b041bd1c15a6f Mon Sep 17 00:00:00 2001 From: Tim Martin Date: Mon, 22 Jul 2019 14:15:19 +0200 Subject: [PATCH 1/2] add support for nameless features, returns all allowed features. The try-block had migrated away from the piece of code it was there to protect, moved it back. --- .../DecisionHandling/TrigCompositeUtils.icc | 52 ++++++++++++------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/Trigger/TrigSteer/DecisionHandling/DecisionHandling/TrigCompositeUtils.icc b/Trigger/TrigSteer/DecisionHandling/DecisionHandling/TrigCompositeUtils.icc index ab96c641dd8..bcbdf651434 100644 --- a/Trigger/TrigSteer/DecisionHandling/DecisionHandling/TrigCompositeUtils.icc +++ b/Trigger/TrigSteer/DecisionHandling/DecisionHandling/TrigCompositeUtils.icc @@ -98,32 +98,44 @@ namespace TrigCompositeUtils { // For each step along this path, starting at the terminus and working back towards L1 for (const ElementLink& decisionLink : decisionPath) { const Decision* decision = (*decisionLink); - ElementLinkVector featureLinks; - // Slices may have added link collections - if (decision->hasObjectCollectionLinks(featureName, ClassID_traits< CONTAINER >::ID())) { - featureLinks = decision->objectCollectionLinks( featureName ); - } - // Framework specified "feature" is always a single link - if (decision->hasObjectLink(featureName, ClassID_traits< CONTAINER >::ID())) { - featureLinks.push_back( decision->objectLink( featureName ) ); + + std::vector availableLinkNames; + if (featureName == "") { // Look up what named links are available + const std::vector getSingleLinkNames = decision->getObjectNames(); + const std::vector getCollectionLinkNames = decision->getObjectCollectionNames(); + std::copy(getSingleLinkNames.begin(), getSingleLinkNames.end(), std::back_inserter(availableLinkNames)); + std::copy(getCollectionLinkNames.begin(), getCollectionLinkNames.end(), std::back_inserter(availableLinkNames)); + } else { // Just looking for an explicitly named feature + availableLinkNames.push_back( featureName ); } - // This try block protects against ExcCLIDMismatch throws from - // features which do not derive from IParticle, when an IParticle interface is requested. - try { - for (const ElementLink& featureLink : featureLinks) { - if (std::none_of(features.begin(), features.end(), [&](const auto& li) { return li.link == featureLink; } )) { - // Don't duplicate up returned features (may have entries from many chains in the linkVector) - features.push_back( LinkInfo(decision, featureLink) ); + for (const std::string& featureNameToGet : availableLinkNames) { + // This try block protects against ExcCLIDMismatch throws from + // features which do not derive from IParticle, when an IParticle interface is requested. + try { + // Slices may have added link collections + if (decision->hasObjectCollectionLinks(featureNameToGet, ClassID_traits< CONTAINER >::ID())) { + featureLinks = decision->objectCollectionLinks( featureNameToGet ); + } + // Framework specified "feature" is always a single link + if (decision->hasObjectLink(featureNameToGet, ClassID_traits< CONTAINER >::ID())) { + featureLinks.push_back( decision->objectLink( featureNameToGet ) ); } + } catch (SG::ExcCLIDMismatch&) { + // This is in place to catch the exception caused by non-IParticle features when an IParticle interface is requested. + // We're fine to catch this silently and cary on looking at the next Decision object in the graph } - if (featureLinks.size() && oneFeaturePerLeg) { - break; + } + + for (const ElementLink& featureLink : featureLinks) { + if (std::none_of(features.begin(), features.end(), [&](const auto& li) { return li.link == featureLink; } )) { + // Don't duplicate up returned features (may have entries from many chains in the linkVector) + features.push_back( LinkInfo(decision, featureLink) ); } - } catch (SG::ExcCLIDMismatch&) { - // This is in place to catch the exception caused by non-IParticle features when an IParticle interface is requested. - // We're fine to catch this silently and cary on looking at the next Decision object in the graph + } + if (featureLinks.size() && oneFeaturePerLeg) { + break; } } // for (decisionLink : decisionPath) -- GitLab From a5b48a3df9f51ffad1770b8623d4f9ae6318072f Mon Sep 17 00:00:00 2001 From: Tim Martin Date: Tue, 23 Jul 2019 10:35:57 +0200 Subject: [PATCH 2/2] Move to two try-catch blocks. Add missing check in getRejectedDecisionNodes when a specific chain is specified. Stop shadowing var name --- .../DecisionHandling/TrigCompositeUtils.icc | 11 ++++++++--- .../DecisionHandling/src/TrigCompositeUtils.cxx | 5 +++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Trigger/TrigSteer/DecisionHandling/DecisionHandling/TrigCompositeUtils.icc b/Trigger/TrigSteer/DecisionHandling/DecisionHandling/TrigCompositeUtils.icc index bcbdf651434..c3ce889198e 100644 --- a/Trigger/TrigSteer/DecisionHandling/DecisionHandling/TrigCompositeUtils.icc +++ b/Trigger/TrigSteer/DecisionHandling/DecisionHandling/TrigCompositeUtils.icc @@ -116,15 +116,20 @@ namespace TrigCompositeUtils { try { // Slices may have added link collections if (decision->hasObjectCollectionLinks(featureNameToGet, ClassID_traits< CONTAINER >::ID())) { - featureLinks = decision->objectCollectionLinks( featureNameToGet ); + ElementLinkVector collectionLinks = decision->objectCollectionLinks( featureNameToGet ); + std::copy(collectionLinks.begin(), collectionLinks.end(), std::back_inserter(featureLinks)); } + } catch (SG::ExcCLIDMismatch&) { + // This is in place to catch the exception caused by non-IParticle features when an IParticle interface is requested. + // We're fine to catch this silently and cary on looking at the next Decision object in the graph + } + try { // Framework specified "feature" is always a single link if (decision->hasObjectLink(featureNameToGet, ClassID_traits< CONTAINER >::ID())) { featureLinks.push_back( decision->objectLink( featureNameToGet ) ); } } catch (SG::ExcCLIDMismatch&) { - // This is in place to catch the exception caused by non-IParticle features when an IParticle interface is requested. - // We're fine to catch this silently and cary on looking at the next Decision object in the graph + // As above } } diff --git a/Trigger/TrigSteer/DecisionHandling/src/TrigCompositeUtils.cxx b/Trigger/TrigSteer/DecisionHandling/src/TrigCompositeUtils.cxx index 9a0f16234af..0bee034e70e 100644 --- a/Trigger/TrigSteer/DecisionHandling/src/TrigCompositeUtils.cxx +++ b/Trigger/TrigSteer/DecisionHandling/src/TrigCompositeUtils.cxx @@ -218,8 +218,9 @@ namespace TrigCompositeUtils { // I.e. the HypoTool for the chain returned a NEGATIVE decision DecisionIDContainer activeChainsPassedByThisDecision; decisionIDs(d, activeChainsPassedByThisDecision); - for (const DecisionID id : chainsToCheck) { - if (activeChainsPassedByThisDecision.count(id) == 0) { // I was REJECTED + for (const DecisionID checkID : chainsToCheck) { + if (activeChainsPassedByThisDecision.count(checkID) == 0 && // I was REJECTED here ... + activeChainsIntoThisDecision.count(checkID) == 1) { // ... but PASSSED by all my inputs output.push_back(d); break; } -- GitLab