24 const std::string& edgeName)
const
29 return StatusCode::SUCCESS;
36 ATH_MSG_DEBUG(
"Unable to repack '" << edgeName <<
"' of container type xAOD::IParticleContainer for '"
37 << decision->
name() <<
"' node, the link is invalid.");
39 return StatusCode::SUCCESS;
46 const std::string featureStoreGateKey = currentEL.
dataID();
48 if (featureStoreGateKey == exclusionEntry) {
49 ATH_MSG_VERBOSE(
"Will not repack this feature " << currentEL.
index() <<
" from " << currentEL.
dataID() <<
", as this container is on the exclusion list");
50 return StatusCode::SUCCESS;
60 remapped->
setP4( current->p4() );
66 <<
", to index:" << remappedEL.
index() <<
" to key:" << remappedEL.
dataID());
68 return StatusCode::SUCCESS;
80 return StatusCode::SUCCESS;
101 ATH_MSG_WARNING(
"Possible miss-configuration. Cannot repack ROIs in the navigation slimming if they are being dropped");
117 msg() << MSG::INFO <<
"Initialized. Will *not* inspect the following SG Keys: ";
122 return StatusCode::SUCCESS;
136 outputContainers.rois = &outputROIs;
140 outputContainers.particles = &outputParticles;
144 outputContainers.mets = &outputMETs;
148 outputContainers.nav = &outputNavigation;
155 ATH_MSG_ERROR(
"Unable to locate the HLTPassRaw from the primary input navigation collection, size:" << primaryInputHandle->size());
156 return StatusCode::FAILURE;
166 const Decision* applyPassingChainsFilter =
nullptr;
168 applyPassingChainsFilter = terminusNode;
171 ATH_MSG_DEBUG(
"Supplied " <<
m_chainsFilter.size() <<
" chain patterns. This converts to " << chainIDs.size() <<
" DecisionIDs to be preserved.");
172 if (chainIDs.empty()) {
177 ATH_MSG_DEBUG(
"No HLT-chain based filtering of the navigation graph will be performed.");
180 std::set<const Decision*> fullyExploredFrom;
190 ATH_MSG_DEBUG(
"Collated nodes from passing paths, now have " << transientNavGraph.
nodes() <<
" nodes with " << transientNavGraph.
edges() <<
" edges");
201 for (
const Decision* rejectedNode : rejectedNodes) {
212 ATH_MSG_DEBUG(
"Collated nodes from failing paths, now have " << transientNavGraph.
nodes() <<
" nodes with " << transientNavGraph.
edges() <<
" edges");
220 if (
msg().level() <= MSG::VERBOSE) {
227 const size_t nodesBefore = transientNavGraph.
nodes();
228 const size_t edgesBefore = transientNavGraph.
edges();
229 std::vector<const Decision*> thinnedInputNodes = transientNavGraph.
thin();
234 ATH_MSG_DEBUG(
"Trigger navigation graph thinning going from " << nodesBefore <<
" nodes with " << edgesBefore <<
" edges, to "
235 << transientNavGraph.
nodes() <<
" nodes with " << transientNavGraph.
edges() <<
" edges");
237 if (
msg().level() <= MSG::VERBOSE) {
238 ATH_MSG_VERBOSE(
"The navigation graph has been slimmed to the following paths:");
247 Decision* terminusNodeOut =
nullptr;
252 if (expressTerminusNode) {
254 Decision* expressTerminusNodeOut =
nullptr;
262 Decision* prescaleNodeOut =
nullptr;
273 if (L1TBPNode && L1TAVNode) {
285 const std::vector<NavGraphNode*> allNodes = transientNavGraph.
allNodes();
298 ATH_MSG_VERBOSE(
"The output navigation graph looks like this (output terminus node search only, converted back into a NavGraph one final time for printing)");
299 std::set<const Decision*> fullyExploredFromOut;
303 transientNavGraphOut,
304 fullyExploredFromOut,
310 if (
msg().level() <= MSG::DEBUG) {
319 return StatusCode::SUCCESS;
323 if (chain ==
"HLT_id_cosmicid_L1MU11_EMPTY")
return std::vector<size_t>(1,1);
324 return std::vector<size_t>();
329 if (applyPassingChainsFilter) {
337 for (
const std::string& chain : chains) {
340 if (passingChains.size() && passingChains.count( chainID.
numeric() ) == 0) {
341 ATH_MSG_VERBOSE(
"Skipping " << chain <<
" as it didn't pass this event");
344 chainIDs.insert( chainID.
numeric() );
346 ATH_MSG_VERBOSE(
"Including " << chain <<
" and its " << legMultiplicites.size() <<
" legs in the trigger slimming output");
347 if (legMultiplicites.size() == 0) {
349 if (legMultiplicites.size() == 0) {
350 ATH_MSG_ERROR(
"chain " << chainID <<
" has invalid configuration, no multiplicity data.");
351 return StatusCode::FAILURE;
354 if (legMultiplicites.size() > 1) {
357 for (
size_t legNumeral = 0; legNumeral < legMultiplicites.size(); ++legNumeral) {
359 chainIDs.insert( legID.
numeric() );
364 return StatusCode::SUCCESS;
373 if (chains.size() != bits.size()) {
374 ATH_MSG_ERROR(
"Unexpected different sized chains and bits vectors");
375 return StatusCode::FAILURE;
379 for (
size_t i = 0; i < bits.size(); ++i) {
380 if (bits[i] & TrigDefs::EF_prescaled) { prescaledIDs.insert(
HLT::Identifier(chains[i]).numeric() ); }
385 return !chainIDs.contains(
id);
390 return StatusCode::SUCCESS;
401 if (chains.size() != bits.size()) {
402 ATH_MSG_ERROR(
"Unexpected different sized chains and bits vectors");
403 return StatusCode::FAILURE;
407 for (
size_t i = 0; i < bits.size(); ++i) {
408 if (bits[i] & TrigDefs::L1_isPassedBeforePrescale) { TBPIDs.insert(
HLT::Identifier(chains[i]).numeric() ); }
409 if (bits[i] & TrigDefs::L1_isPassedAfterVeto) { TAVIDs.insert(
HLT::Identifier(chains[i]).numeric() ); }
414 ATH_MSG_INFO(
"Created new TAV node at index " << L1TAVNode->
index() <<
" with " << TBPIDs.size() <<
" = " << TAVIDs.size() <<
" decisions\n" << *L1TAVNode );
415 return StatusCode::SUCCESS;
425 const EventContext& ctx)
const
427 IOCacheMap::const_iterator it = cache.find(input);
428 if (it != cache.end()) {
429 *output = it->second;
431 *output =
newDecisionIn(outputContainers.nav->ptr(), input, input->name(), ctx);
435 cache[input] = *output;
437 return StatusCode::SUCCESS;
444 const EventContext& ctx)
const
449 IOCacheMap::const_iterator it = cache.find(inputDecision);
451 outputDecision = it->second;
454 const Decision* inputSeedDecision = seed->node();
455 const Decision* outputSeedDecision =
nullptr;
457 IOCacheMap::const_iterator it = cache.find(inputSeedDecision);
459 outputSeedDecision = it->second;
468 const size_t sensibleUpperBoundOnNLinks = 100;
469 const size_t maxUpperBoundOnNLinks = 500;
471 const bool bad_in = inputNode->
children().size() > sensibleUpperBoundOnNLinks;
473 const bool bad_out = outputDecision->
linkColNames().size() > sensibleUpperBoundOnNLinks;
474 const bool vbad = inputNode->
children().size() > maxUpperBoundOnNLinks or outputDecision->
linkColNames().size() > maxUpperBoundOnNLinks;
476 ATH_MSG_WARNING(
"Saving a Decision object with a very large number of INCOMING graph edges. Number of in-edges: " << inputNode->
children().size());
479 ATH_MSG_WARNING(
"Saving a Decision object with a very large number of OUTGOING graph edges. Number of out-edges: " << outputDecision->
linkColNames().size());
481 if (bad_in or bad_out) {
486 ATH_MSG_ERROR(
"More than " << maxUpperBoundOnNLinks <<
" links, printing an ERROR such that this gets promptly investigated and reduced.");
489 return StatusCode::SUCCESS;
499 output->copyAllLinksFrom( input );
507 const Decision*
const firstParent = (seeds.size() ? *seeds.at(0) :
nullptr);
514 output->copyLinkFrom( firstParent,
roiString() );
518 output->removeObjectLink(toRemove);
519 output->removeObjectCollectionLinks(toRemove);
525 output->removeObjectCollectionLinks(
seedString() );
527 return StatusCode::SUCCESS;
542 if ( chainIDs.size() ) {
544 std::set_intersection(fromInput.begin(), fromInput.end(), chainIDs.begin(), chainIDs.end(),
545 std::inserter(toOutput, toOutput.begin()));
548 toOutput.insert(fromInput.begin(), fromInput.end());
554 return StatusCode::SUCCESS;
558 if (not
msgLvl(MSG::DEBUG))
return;
564 <<
"(pt:" << l.pt() <<
",eta:" << l.eta() <<
",phi:" << l.phi() <<
",m:" << l.m() <<
",e:" << l.e() <<
")"
565 <<
" from:" << link.
dataID());
574 Outputs& outputContainers)
const
601 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Athena::TPCnvVers::Current TrigRoiDescriptor
ServiceHandle< StoreGateSvc > & evtStore()
bool msgLvl(const MSG::Level lvl) const
An algorithm that can be simultaneously executed in multiple threads.
ElementLink implementation for ROOT usage.
const ID_type & dataID() const
Get the key that we reference, as a string.
index_type index() const
Get the index of the element inside of its container.
bool isValid() const
Test to see if the link can be dereferenced.
TrigCompositeUtils::DecisionID numeric() const
numeric ID
size_t index() const
Return the index of this element within its container.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Transient utility class to represent a node in a graph (m_decisionObject), and a vector of edges (m_f...
const std::vector< NavGraphNode * > & children() const
Return a vector of const pointers to the Decision object nodes which are the children of this NavGrap...
const std::vector< NavGraphNode * > & seeds() const
Return a vector of const pointers to the Decision object nodes which this NavGraphNode seeds from.
const Decision * node() const
Return a const pointer to the Decision object node which this NavGraphNode is shadowing.
Structure to hold a transient Directed Acyclic Graph (DAG) structure.
std::vector< NavGraphNode * > allNodes()
Get all nodes.
void printAllPaths(MsgStream &log, MSG::Level msgLevel=MSG::VERBOSE) const
Helper function.
std::vector< const Decision * > thin()
Perform thinning.
HLT chain configuration information.
const std::string & chain_name() const
const std::vector< size_t > & leg_multiplicities() const
std::vector< size_t > lookupHardCodedLegMultiplicities(const std::string &chain) const
Supplemental leg multiplicity information to support MC20.
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_outputRepackedROICollectionKey
Gaudi::Property< std::vector< std::string > > m_edgesToDrop
StatusCode createPresaledGraphNode(Outputs &outputContainers, const TrigCompositeUtils::DecisionIDContainer &chainIDs) const
Creates a new graph node from scratch, populates it with the Chain IDs of all HLT chains which were n...
StatusCode doRepack(TrigCompositeUtils::Decision *decision, SG::WriteHandle< COLLECTION > *writeHandle, const std::string &edgeName) const
Look for an ElementLink<COLLECTION> with the given edge-name in 'decision', if found then make a copy...
Gaudi::Property< bool > m_keepFailedBranches
Gaudi::Property< std::vector< std::string > > m_allOutputContainers
Gaudi::Property< bool > m_repackFeatures
SG::WriteHandleKey< xAOD::TrigCompositeContainer > m_outputCollection
Gaudi::Property< bool > m_applyChainsFilterToSummaryNodes
Gaudi::Property< bool > m_runtimeValidation
StatusCode inputToOutput(const TrigCompositeUtils::Decision *input, TrigCompositeUtils::Decision **output, IOCacheMap &cache, Outputs &outputContainers, const TrigCompositeUtils::DecisionIDContainer &chainIDs, const EventContext &ctx) const
Map a const Decision object from an input collection to its equivalent in the output collection Where...
SG::WriteHandleKey< xAOD::ParticleContainer > m_outputRepackedFeaturesCollectionKey_Particle
SG::WriteHandleKey< xAOD::TrigMissingETContainer > m_outputRepackedFeaturesCollectionKey_MET
StatusCode propagateSeedingRelation(const TrigCompositeUtils::NavGraphNode *inputNode, IOCacheMap &cache, const EventContext &ctx) const
Copy the subset of "seed" links which are present in the inputNode.
void printIParticleRepackingDebug(const TrigCompositeUtils::Decision *output, const std::string &when) const
Print debug information relating to the re-packing of feature links as Particle objects.
StatusCode createL1GraphNodes(Outputs &outputContainers) const
Creates two new graph node from scratch, populates it using the TriggerDecisionTool with the hash of ...
StatusCode propagateDecisionIDs(const TrigCompositeUtils::Decision *input, TrigCompositeUtils::Decision *output, const TrigCompositeUtils::DecisionIDContainer &chainIDs) const
Copy DecisionIDs (passing chains and passing chain-legs) from input to output.
Gaudi::Property< bool > m_repackMET
Gaudi::Property< bool > m_repackROIs
std::set< std::string > m_allOutputContainersSet
Processed form of m_allOutputContainers.
Gaudi::Property< std::vector< std::string > > m_repackFeaturesExclusionList
Gaudi::Property< bool > m_keepOnlyFinalFeatures
StatusCode doRepackCopy(const typename COLLECTION::base_value_type *object, SG::WriteHandle< COLLECTION > *writeHandle) const
Performs the xAOD Copy.
SG::ReadHandleKey< xAOD::TrigCompositeContainer > m_primaryInputCollection
TrigNavSlimmingMTAlg(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode repackLinks(TrigCompositeUtils::Decision *output, Outputs &outputContainers) const
Repacks ElementLinks in the DecisionObject to point to compact output containers written by this alg.
std::map< const TrigCompositeUtils::Decision *, TrigCompositeUtils::Decision * > IOCacheMap
Gaudi::Property< std::vector< std::string > > m_nodesToDrop
virtual StatusCode execute(const EventContext &ctx) const override
Gaudi::Property< bool > m_removeEmptySteps
virtual StatusCode initialize() override
StatusCode fillChainIDs(TrigCompositeUtils::DecisionIDContainer &chainIDs, const TrigCompositeUtils::Decision *applyPassingChainsFilter) const
Convert the ChainsFilter into the set of chain-IDd and chain-leg-IDs which comprises all of the Decis...
Gaudi::Property< bool > m_propagatePrescaledNode
Gaudi::Property< bool > m_propagateL1Nodes
PublicToolHandle< Trig::TrigDecisionTool > m_trigDec
StatusCode propagateLinks(const TrigCompositeUtils::Decision *input, TrigCompositeUtils::Decision *output) const
Copy links (graph edges) from input to output.
Gaudi::Property< std::vector< std::string > > m_chainsFilter
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
utility class to measure time duration in AthenaMT The pattern when it is useful: AlgA tags the begin...
double millisecondsSince() const
double millisecondsDifference(const TrigTimeStamp &other) const
std::vector< unsigned int > isPassedBitsForEach() const
return result of isPassedBits for each chain in the group
std::vector< std::string > getListOfTriggers() const
Class providing the definition of the 4-vector interface.
void setP4(const FourMom_t &vec)
Set the 4-vec.
bool setObjectLink(const std::string &name, const ElementLink< CONTAINER > &link)
Set the link to an object.
const std::vector< std::string > & linkColNames() const
Raw access to the persistent link names.
bool hasObjectLink(const std::string &name, const CLID clid=CLID_NULL) const
Check if a link to an object with a given name and type exists. CLID_NULL to not check type.
ElementLink< CONTAINER > objectLink(const std::string &name) const
Get the link with the requested name.
const std::string & name() const
Get a human-readable name for the object.
SG::WriteHandle< CONT > createAndStoreNoAux(const SG::WriteHandleKey< CONT > &key, const EventContext &ctx)
Creates and right away records the Container CONT with the key.
HLT::Identifier createLegName(const HLT::Identifier &chainIdentifier, size_t counter)
Generate the HLT::Identifier which corresponds to a specific leg of a given chain.
const std::string & summaryPrescaledNodeName()
const std::string & inputMakerNodeName()
xAOD::TrigComposite Decision
const Decision * getNodeByName(const DecisionContainer &container, const std::string &nodeName)
Returns the navigation node with a given name from a collection or nullptr if missing.
void insertDecisionIDs(const Decision *src, Decision *dest)
Appends the decision IDs of src to the dest decision object.
const std::string & roiString()
Decision * newDecisionIn(DecisionContainer *dc, const std::string &name)
Helper method to create a Decision object, place it in the container and return a pointer to it.
SG::WriteHandle< CONT > createAndStoreWithAux(const SG::WriteHandleKey< CONT > &key, const EventContext &ctx)
Creates and right away records the Container CONT with the key.
const std::string & featureString()
const Decision * getExpressTerminusNode(const DecisionContainer &container)
Returns the express-accept navigation node from a collection or nullptr if missing.
std::vector< const Decision * > getRejectedDecisionNodes(const asg::EventStoreType *eventStore, const EventContext &ctx, const std::string &summaryCollectionKey, const DecisionIDContainer &ids, const std::set< std::string > &keysToIgnore)
Query all DecisionCollections in the event store, locate all Decision nodes in the graph where an obj...
std::set< DecisionID > DecisionIDContainer
const Decision * getTerminusNode(SG::ReadHandle< DecisionContainer > &container)
void recursiveFlagForThinning(NavGraph &graph, const bool keepOnlyFinalFeatures, const bool removeEmptySteps, const std::vector< std::string > &nodesToDrop)
Used by trigger navigation thinning.
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.
void recursiveGetDecisionsInternal(const Decision *node, const Decision *comingFrom, NavGraph &navGraph, std::set< const Decision * > &fullyExploredFrom, const DecisionIDContainer &ids, const bool enforceDecisionOnNode)
Used by recursiveGetDecisions.
const std::string & hypoAlgNodeName()
void linkToPrevious(Decision *d, const std::string &previousCollectionKey, size_t previousIndex)
Links to the previous object, location of previous 'seed' decision supplied by hand.
const std::string & initialRoIString()
const std::string & seedString()
const std::string & summaryPassNodeName()
xAOD::TrigCompositeContainer DecisionContainer
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
ElementLink< DecisionContainer > decisionToElementLink(const Decision *d, const EventContext &ctx)
Takes a raw pointer to a Decision and returns an ElementLink to the Decision.
std::size_t erase_if(T_container &container, T_Func pred)
Particle_v1 Particle
Define the latest version of the particle class.
ParticleContainer_v1 ParticleContainer
Define the latest version of the particle class.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.