ATLAS Offline Software
Classes | Typedefs | Enumerations | Functions
TrigCompositeUtils Namespace Reference

Classes

class  AlgToChainTool
 Provide the reverse mapping: algorithm name to set of chain names. More...
 
class  Combinations
 
class  HasObject
 Prerequisite object usable with. More...
 
class  HasObjectCollection
 Prerequisite object usable with. More...
 
class  IPartCombItr
 
class  KFromNItr
 Iterates over all combinations of k values chosen from a range n. More...
 
struct  LinkInfo
 Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGroup) linked together (for convenience) More...
 
class  NavGraph
 Structure to hold a transient Directed Acyclic Graph (DAG) structure. NavGraph is populated from, and forms a sub-graph over the full Run 3 trigger navigation graph in a single event. Requirements on specific chains, and the specification of allowable graph entry-points are considered in the construction of the NavGraph sub-graph. Once one of these sub-graphs is fully populated to a given specification, it is searched by the feature-retrieval code to find features. More...
 
class  NavGraphNode
 Transient utility class to represent a node in a graph (m_decisionObject), and a vector of edges (m_filteredSeeds) to other nodes which are parents of this node. More...
 
class  ProductItr
 Iterates over all combinations of the provided input iterators. More...
 

Typedefs

typedef xAOD::TrigComposite Decision
 
typedef xAOD::TrigCompositeAuxContainer DecisionAuxContainer
 
typedef xAOD::TrigCompositeContainer DecisionContainer
 
typedef unsigned int DecisionID
 
typedef std::set< DecisionIDDecisionIDContainer
 
using sgkey_t = SG::sgkey_t
 
typedef SG::WriteHandle< DecisionContainerDecisionWriteHandle
 alias types, for readability and to simplify future evolution More...
 

Enumerations

enum  FilterType { FilterType::All, FilterType::UniqueObjects, FilterType::UniqueRoIs, FilterType::UniqueInitialRoIs }
 
enum  ActiveState { UNSET, ACTIVE, INACTIVE }
 Additional information returned by the TrigerDecisionTool's feature retrieval, contained within the LinkInfo. More...
 

Functions

bool uniqueObjects (const std::vector< LinkInfo< xAOD::IParticleContainer >> &links)
 Helper fucntion that returns true if no objects are repeated. More...
 
bool uniqueInitialRoIs (const std::vector< LinkInfo< xAOD::IParticleContainer >> &links)
 Helper function that returns true if no objects share an initial RoI. More...
 
bool uniqueRoIs (const std::vector< LinkInfo< xAOD::IParticleContainer >> &links)
 Helper function that returns true if no objects share a final RoI. More...
 
std::function< bool(const std::vector< LinkInfo< xAOD::IParticleContainer >> &)> getFilter (FilterType filter)
 Get a lambda corresponding to the specified FilterType enum. More...
 
SG::WriteHandle< DecisionContainercreateAndStore (const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
 Creates and right away records the DecisionContainer with the key. More...
 
void createAndStore (SG::WriteHandle< DecisionContainer > &handle)
 Creates and right away records the DecisionContainer using the provided WriteHandle. More...
 
DecisionnewDecisionIn (DecisionContainer *dc, const std::string &name="")
 Helper method to create a Decision object, place it in the container and return a pointer to it. More...
 
DecisionnewDecisionIn (DecisionContainer *dc, const Decision *dOld, const std::string &name, const EventContext &ctx)
 Helper method to create a Decision object, place it in the container and return a pointer to it. More...
 
void addDecisionID (DecisionID id, Decision *d)
 Appends the decision (given as ID) to the decision object. More...
 
void decisionIDs (const Decision *d, DecisionIDContainer &id)
 Extracts DecisionIDs stored in the Decision object. More...
 
const std::vector< DecisionID > & decisionIDs (const Decision *d)
 Another variant of the above method to access DecisionIDs stored in the Decision object, returns const accessor. More...
 
std::vector< DecisionID > & decisionIDs (Decision *d)
 Another variant of the above method to access DecisionIDs stored in the Decision object, returns read/write accessor. More...
 
void insertDecisionIDs (const Decision *src, Decision *dest)
 Appends the decision IDs of src to the dest decision object. More...
 
void insertDecisionIDs (const DecisionIDContainer &src, Decision *dest)
 Appends the decision IDs of src to the dest decision object. More...
 
void uniqueDecisionIDs (Decision *dest)
 Make unique list of decision IDs of dest Decision object. More...
 
bool allFailed (const Decision *d)
 return true if there is no positive decision stored More...
 
bool isAnyIDPassing (const Decision *d, const DecisionIDContainer &required)
 Checks if any of the DecisionIDs passed in arg required is availble in Decision object. More...
 
bool passed (DecisionID id, const DecisionIDContainer &)
 checks if required decision ID is in the set of IDs in the container More...
 
ElementLink< DecisionContainerdecisionToElementLink (const Decision *d, const EventContext &ctx)
 Takes a raw pointer to a Decision and returns an ElementLink to the Decision. More...
 
void linkToPrevious (Decision *d, const std::string &previousCollectionKey, size_t previousIndex)
 Links to the previous object, location of previous 'seed' decision supplied by hand. More...
 
void linkToPrevious (Decision *d, const Decision *dOld, const EventContext &ctx)
 Links to the previous object, 'seed' decision provided explicitly. More...
 
bool hasLinkToPrevious (const Decision *d)
 checks if there is at least one 'seed' link to previous object More...
 
const std::vector< ElementLink< DecisionContainer > > getLinkToPrevious (const Decision *)
 returns links to previous decision object 'seed' More...
 
bool copyLinks (const Decision *src, Decision *dest)
 copy all links from src to dest TC objects More...
 
HLT::Identifier createLegName (const HLT::Identifier &chainIdentifier, size_t counter)
 Generate the HLT::Identifier which corresponds to a specific leg of a given chain. More...
 
HLT::Identifier createLegName (const std::string &name, size_t counter)
 Generate the HLT::Identifier which corresponds to a specific leg of a given chain. More...
 
HLT::Identifier getIDFromLeg (const HLT::Identifier &legIdentifier)
 Generate the HLT::Identifier which corresponds to the chain name from the leg name. More...
 
int32_t getIndexFromLeg (const HLT::Identifier &legIdentifier)
 Extract the numeric index of a leg identifier. More...
 
int32_t getIndexFromLeg (const std::string &name)
 Extract the numeric index of a leg identifier. More...
 
std::pair< std::string, int32_t > getNameAndIndexFromLeg (const std::string &name)
 Extract the name and numeric index of a leg identifier. More...
 
bool isLegId (const HLT::Identifier &legIdentifier)
 Recognise whether the chain ID is a leg ID. More...
 
bool isLegId (const std::string &name)
 Recognise whether the chain ID is a leg ID. More...
 
bool isChainId (const HLT::Identifier &chainIdentifier)
 Recognise whether the HLT identifier corresponds to a whole chain. More...
 
bool isChainId (const std::string &name)
 Recognise whether the HLT identifier corresponds to a whole chain. More...
 
const Decisionfind (const Decision *, const std::function< bool(const Decision *)> &filter)
 traverses Decision object links for another Decision object fulfilling the prerequisite specified by the filter More...
 
const DecisiongetTerminusNode (SG::ReadHandle< DecisionContainer > &container)
 
const DecisiongetTerminusNode (const DecisionContainer &container)
 Returns the terminus navigation node from a collection, assuming that the passed collection contains the terminus node. More...
 
const DecisiongetExpressTerminusNode (const DecisionContainer &container)
 Returns the express-accept navigation node from a collection or nullptr if missing. More...
 
const DecisiongetNodeByName (const DecisionContainer &container, const std::string &nodeName)
 Returns the navigation node with a given name from a collection or nullptr if missing. More...
 
std::vector< const Decision * > getRejectedDecisionNodes ([[maybe_unused]] const asg::EventStoreType *eventStore, const EventContext &ctx, const std::string &summaryCollectionKey, const DecisionIDContainer &ids, const std::set< std::string > &keysToIgnore)
 
void recursiveGetDecisionsInternal (const Decision *node, const Decision *comingFrom, NavGraph &navGraph, std::set< const Decision * > &fullyExploredFrom, const DecisionIDContainer &ids, const bool enforceDecisionOnNode)
 Used by recursiveGetDecisions. More...
 
void recursiveGetDecisions (const Decision *node, NavGraph &navGraph, const DecisionIDContainer &ids={}, const bool enforceDecisionOnStartNode=true)
 Search back in time from "node" and locate all paths back through Decision objects for a given chain. More...
 
void recursiveFlagForThinning (NavGraph &node, const bool keepOnlyFinalFeatures, const bool removeEmptySteps, const std::vector< std::string > &nodesToDrop)
 Used by trigger navigation thinning. More...
 
void recursiveFlagForThinningInternal (NavGraphNode *node, bool modeKeep, std::set< NavGraphNode * > &fullyExploredFrom, const bool keepOnlyFinalFeatures, const bool removeEmptySteps, const std::vector< std::string > &nodesToDrop)
 Used by recursiveFlagForThinning. More...
 
bool typelessFindLinks (const Decision *start, const std::string &linkName, std::vector< sgkey_t > &keyVec, std::vector< uint32_t > &clidVec, std::vector< Decision::index_type > &indexVec, std::vector< const Decision * > &sourceVec, const unsigned int behaviour=TrigDefs::allFeaturesOfType, std::set< const Decision * > *fullyExploredFrom=nullptr)
 search back the TC links for the object of type T linked to the one of TC (recursively) Returns the link data in a typeless way, as raw key, index and CLID values. More...
 
bool typelessFindLinks (const NavGraphNode *start, const std::string &linkName, std::vector< sgkey_t > &key, std::vector< uint32_t > &clid, std::vector< Decision::index_type > &index, std::vector< const Decision * > &sourceVec, const unsigned int behaviour=TrigDefs::allFeaturesOfType, std::set< const Decision * > *fullyExploredFrom=nullptr)
 Version of typelessFindLinks which operates on a sub-graph (entered via the supplied NavGraphNode), rather than the whole navigation graph. More...
 
bool typelessFindLinksCommonLinkCollection (const Decision *start, const std::string &linkName, std::vector< sgkey_t > &keyVec, std::vector< uint32_t > &clidVec, std::vector< Decision::index_type > &indexVec, std::vector< const Decision * > &sourceVec)
 Common functionality shared by both typelessFindLinks interfaces Returns true if at least one link was collected. More...
 
bool typelessFindLink (const Decision *start, const std::string &linkName, sgkey_t &key, uint32_t &clid, Decision::index_type &index, const Decision *&source, const bool suppressMultipleLinksWarning=false)
 Perform a recursive search for ElementLinks of any time and name 'linkName', starting from Decision object 'start' Returns the link data in a typeless way, as raw key, index and CLID values. More...
 
bool typelessFindLink (const NavGraph &subGraph, const std::string &linkName, sgkey_t &key, uint32_t &clid, Decision::index_type &index, const Decision *&source, const bool suppressMultipleLinksWarning=false)
 Version of typelessFindLink which operates on a sub-graph (described by the NavGraph), rather than the whole navigation graph. More...
 
Combinations buildCombinations (const std::string &chainName, const std::vector< LinkInfo< xAOD::IParticleContainer >> &features, const std::vector< std::size_t > &legMultiplicities, const std::function< bool(const std::vector< LinkInfo< xAOD::IParticleContainer >> &)> &filter)
 Produce the combinations for a set of features. More...
 
Combinations buildCombinations (const std::string &chainName, const std::vector< LinkInfo< xAOD::IParticleContainer >> &features, const std::vector< std::size_t > &legMultiplicities, FilterType filter=FilterType::UniqueObjects)
 Produce the combinations for a set of features. More...
 
Combinations buildCombinations (const std::string &chainName, const std::vector< LinkInfo< xAOD::IParticleContainer >> &features, const TrigConf::HLTChain *chainInfo, const std::function< bool(const std::vector< LinkInfo< xAOD::IParticleContainer >> &)> &filter)
 Produce the combinations for a set of features. More...
 
Combinations buildCombinations (const std::string &chainName, const std::vector< LinkInfo< xAOD::IParticleContainer >> &features, const TrigConf::HLTChain *chainInfo, FilterType filter=FilterType::UniqueObjects)
 Produce the combinations for a set of features. More...
 
std::string dump (const Decision *tc, const std::function< std::string(const Decision *)> &printerFnc)
 Prints the Decision object including the linked seeds @warnign expensive call. More...
 
template<class CONT >
SG::WriteHandle< CONT > createAndStoreNoAux (const SG::WriteHandleKey< CONT > &key, const EventContext &ctx)
 Creates and right away records the Container CONT with the key. More...
 
template<class CONT , class AUX >
SG::WriteHandle< CONT > createAndStoreWithAux (const SG::WriteHandleKey< CONT > &key, const EventContext &ctx)
 Creates and right away records the Container CONT with the key. More...
 
template<typename T >
DecisionIDContainer passedDecisionIDs (const Decision *d, const T &required)
 return DecisionIDs in Decision object that match the required ones More...
 
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=std::set< std::string >())
 Query all DecisionCollections in the event store, locate all Decision nodes in the graph where an object failed selection for a given chain. More...
 
template<class CONTAINER >
void filterLinkVectorByContainerKey (const std::string &containerSGKey, std::vector< ElementLink< CONTAINER >> &vector)
 Removes ElementLinks from the supplied vector if they do not come from the specified collection (sub-string match). More...
 
template<class CONTAINER >
const std::vector< LinkInfo< CONTAINER > > recursiveGetFeaturesOfType (const NavGraph &navGraph, const std::string &containerSGKey="", const unsigned int behaviour=TrigDefs::lastFeatureOfType, const std::string &navElementLinkKey=featureString(), const DecisionIDContainer &chainIDs=DecisionIDContainer())
 Extract features from the supplied linkVector (obtained through recursiveGetDecisions). More...
 
template<class CONTAINER >
void recursiveGetFeaturesOfTypeInternal (std::vector< LinkInfo< CONTAINER > > &features, std::set< const NavGraphNode * > &fullyExploredFrom, const NavGraphNode *navGraphNode, const std::string &containerSGKey, const unsigned int behaviour, const std::string &navElementLinkKey, const DecisionIDContainer &chainIDs)
 Internal implimentation called by recursiveGetFeaturesOfType, and by itself. More...
 
template<typename T >
LinkInfo< T > findLink (const Decision *start, const std::string &linkName, const bool suppressMultipleLinksWarning=false)
 Perform a recursive search for ElementLinks of type T and name 'linkName', starting from Decision object 'start' For the case of multiple links, this function only returns the first one found. More...
 
template<typename T >
void findLinks (const Decision *start, const std::string &linkName, std::vector< LinkInfo< T >> &links, unsigned int behaviour=TrigDefs::allFeaturesOfType, std::set< const xAOD::TrigComposite * > *fullyExploredFrom=nullptr)
 search back the TC links for the object of type T linked to the one of TC (recursively) Populates provided vector with all located links to T of the corresponding linkName. More...
 
template<typename T >
std::vector< LinkInfo< T > > findLinks (const Decision *start, const std::string &linkName, unsigned int behaviour=TrigDefs::allFeaturesOfType)
 search back the TC links for the object of type T linked to the one of TC (recursively) This version returns a vector rather than requiring that one be passed to it. More...
 

Typedef Documentation

◆ Decision

◆ DecisionAuxContainer

Definition at line 20 of file TrigCompositeAuxContainer.h.

◆ DecisionContainer

◆ DecisionID

typedef unsigned int TrigCompositeUtils::DecisionID

Definition at line 27 of file TrigComposite_v1.h.

◆ DecisionIDContainer

Definition at line 28 of file TrigComposite_v1.h.

◆ DecisionWriteHandle

alias types, for readability and to simplify future evolution

Definition at line 49 of file TrigCompositeUtils.h.

◆ sgkey_t

Definition at line 43 of file TrigCompositeUtils.h.

Enumeration Type Documentation

◆ ActiveState

Additional information returned by the TrigerDecisionTool's feature retrieval, contained within the LinkInfo.

Enumerator
UNSET 

Default property of state.

Indicates that the creator of the LinkInfo did not supply this information

ACTIVE 

The link was still active for one-or-more of the HLT Chains requested in the TDT.

INACTIVE 

The link was inactive for all of the HLT Chains requested in the TDT.

I.e. the object was rejected by these chains.

Definition at line 19 of file LinkInfo.h.

19  {
20  UNSET,
21  ACTIVE,
22  INACTIVE
23  };

◆ FilterType

Enumerator
All 

Allow all combinations.

UniqueObjects 

Do not allow any repeated objects.

UniqueRoIs 

Do not allow any two objects to share an RoI.

UniqueInitialRoIs 

Do not allow any two objects to share an initial RoI.

Definition at line 21 of file IPartCombItr.h.

22  {
24  All,
28  UniqueRoIs,
31  };

Function Documentation

◆ addDecisionID()

void TrigCompositeUtils::addDecisionID ( DecisionID  id,
Decision d 
)

Appends the decision (given as ID) to the decision object.

Warning
Performing two decision insertions with the same ID consecutively results in the ID stored only once This helps solving multiple inserts in the combo hypo tools

Definition at line 59 of file TrigCompositeUtilsRoot.cxx.

59  {
60  std::vector<DecisionID>& decisions = readWriteAccessor( *d );
61  if ( decisions.size() == 0 or decisions.back() != id)
62  decisions.push_back( id );
63  }

◆ allFailed()

bool TrigCompositeUtils::allFailed ( const Decision d)

return true if there is no positive decision stored

Definition at line 104 of file TrigCompositeUtilsRoot.cxx.

104  {
105  const std::vector<DecisionID>& decisions = readOnlyAccessor( *d );
106  return decisions.empty();
107  }

◆ buildCombinations() [1/4]

Combinations TrigCompositeUtils::buildCombinations ( const std::string &  chainName,
const std::vector< LinkInfo< xAOD::IParticleContainer >> &  features,
const std::vector< std::size_t > &  legMultiplicities,
const std::function< bool(const std::vector< LinkInfo< xAOD::IParticleContainer >> &)> &  filter 
)

Produce the combinations for a set of features.

Returns a TrigCompositeUtils::Combinations object that generates all valid combinations of features. This is a range object that returns on iterator which creates the combinations on the fly.

Parameters
[in]chainNameThe name of the chain
[in]featuresThe IParticle features of the container
[in]legMultiplicitiesThe multiplicity of each chain leg. If a leg will not produce an IParticle feature its multiplicity should be set to 0
[in]filterA function that returns true for all valid combinations

Definition at line 824 of file TrigCompositeUtilsRoot.cxx.

829  {
830  Combinations combinations(filter);
831  combinations.reserve(legMultiplicities.size());
832  if (legMultiplicities.size() == 1)
833  combinations.addLeg(legMultiplicities.at(0), features);
834  else
835  for (std::size_t legIdx = 0; legIdx < legMultiplicities.size(); ++legIdx)
836  {
837  // Skip any that will not provide IParticle features
838  if (legMultiplicities[legIdx] == 0)
839  continue;
840  HLT::Identifier legID = createLegName(chainName, legIdx);
841  std::vector<LinkInfo<xAOD::IParticleContainer>> legFeatures;
842  for (const LinkInfo<xAOD::IParticleContainer>& info : features) {
843  if (info.decisions->contains(legID.numeric()))
844  legFeatures.push_back(info);
845  }
846  combinations.addLeg(legMultiplicities.at(legIdx), std::move(legFeatures));
847  }
848  return combinations;
849  }

◆ buildCombinations() [2/4]

Combinations TrigCompositeUtils::buildCombinations ( const std::string &  chainName,
const std::vector< LinkInfo< xAOD::IParticleContainer >> &  features,
const std::vector< std::size_t > &  legMultiplicities,
FilterType  filter = FilterType::UniqueObjects 
)

Produce the combinations for a set of features.

Returns a TrigCompositeUtils::Combinations object that generates all valid combinations of features. This is a range object that returns on iterator which creates the combinations on the fly.

Parameters
[in]chainNameThe name of the chain
[in]featuresThe IParticle features of the container
[in]legMultiplicitiesThe multiplicity of each chain leg. If a leg will not produce an IParticle feature its multiplicity should be set to 0
[in]filterA FilterType enum describing how to filter valid combinations

Definition at line 852 of file TrigCompositeUtilsRoot.cxx.

857  {
858  return buildCombinations(chainName, features, legMultiplicities, getFilter(filter));
859  }

◆ buildCombinations() [3/4]

Combinations TrigCompositeUtils::buildCombinations ( const std::string &  chainName,
const std::vector< LinkInfo< xAOD::IParticleContainer >> &  features,
const TrigConf::HLTChain chainInfo,
const std::function< bool(const std::vector< LinkInfo< xAOD::IParticleContainer >> &)> &  filter 
)

Produce the combinations for a set of features.

Returns a TrigCompositeUtils::Combinations object that generates all valid combinations of features. This is a range object that returns on iterator which creates the combinations on the fly.

Note that if any legs of this chain do not have IParticle features this will not generate any combinations.

Parameters
[in]chainNameThe name of the chain
[in]featuresThe IParticle features of the container
[in]chainInfoThe chain info object read from the configuration
[in]filterA function that returns true for all valid combinations

Definition at line 861 of file TrigCompositeUtilsRoot.cxx.

866  {
867  return buildCombinations(chainName, features, chainInfo->leg_multiplicities(), filter);
868  }

◆ buildCombinations() [4/4]

Combinations TrigCompositeUtils::buildCombinations ( const std::string &  chainName,
const std::vector< LinkInfo< xAOD::IParticleContainer >> &  features,
const TrigConf::HLTChain chainInfo,
FilterType  filter = FilterType::UniqueObjects 
)

Produce the combinations for a set of features.

Returns a TrigCompositeUtils::Combinations object that generates all valid combinations of features. This is a range object that returns on iterator which creates the combinations on the fly.

Note that if any legs of this chain do not have IParticle features this will not generate any combinations.

Parameters
[in]chainNameThe name of the chain
[in]featuresThe IParticle features of the container
[in]chainInfoThe chain info object read from the configuration
[in]filterA FilterType enum describing how to filter valid combinations

Definition at line 870 of file TrigCompositeUtilsRoot.cxx.

875  {
876  return buildCombinations(chainName, features, chainInfo, getFilter(filter));
877  }

◆ comboHypoAlgNodeName()

const std::string& TrigCompositeUtils::comboHypoAlgNodeName ( )
inline

Definition at line 427 of file TrigCompositeUtils.h.

427 { return Decision::s_comboHypoAlgNodeNameString; }

◆ copyLinks()

bool TrigCompositeUtils::copyLinks ( const Decision src,
Decision dest 
)

copy all links from src to dest TC objects

Warning
if there are links already in the dest TC, the operation is not performed and false returned @ret true if success

Definition at line 162 of file TrigCompositeUtilsRoot.cxx.

162  {
163  return dest->copyAllLinksFrom(src);
164  }

◆ createAndStore() [1/2]

SG::WriteHandle< DecisionContainer > TrigCompositeUtils::createAndStore ( const SG::WriteHandleKey< DecisionContainer > &  key,
const EventContext &  ctx 
)

Creates and right away records the DecisionContainer with the key.

Returns the WriteHandle.

Definition at line 28 of file TrigCompositeUtilsRoot.cxx.

28  {
30  auto data = std::make_unique<DecisionContainer>() ;
31  auto aux = std::make_unique<DecisionAuxContainer>() ;
32  data->setStore( aux.get() );
33  handle.record( std::move( data ), std::move( aux ) ).ignore();
34  return handle;
35  }

◆ createAndStore() [2/2]

void TrigCompositeUtils::createAndStore ( SG::WriteHandle< DecisionContainer > &  handle)

Creates and right away records the DecisionContainer using the provided WriteHandle.

Definition at line 37 of file TrigCompositeUtilsRoot.cxx.

37  {
38  auto data = std::make_unique<DecisionContainer>() ;
39  auto aux = std::make_unique<DecisionAuxContainer>() ;
40  data->setStore( aux.get() );
41  handle.record( std::move( data ), std::move( aux ) ).ignore();
42  }

◆ createAndStoreNoAux()

template<class CONT >
SG::WriteHandle<CONT> TrigCompositeUtils::createAndStoreNoAux ( const SG::WriteHandleKey< CONT > &  key,
const EventContext &  ctx 
)

Creates and right away records the Container CONT with the key.

Returns the WriteHandle. No Aux store.

◆ createAndStoreWithAux()

template<class CONT , class AUX >
SG::WriteHandle<CONT> TrigCompositeUtils::createAndStoreWithAux ( const SG::WriteHandleKey< CONT > &  key,
const EventContext &  ctx 
)

Creates and right away records the Container CONT with the key.

Returns the WriteHandle. With Aux store.

◆ createLegName() [1/2]

HLT::Identifier TrigCompositeUtils::createLegName ( const HLT::Identifier chainIdentifier,
size_t  counter 
)

Generate the HLT::Identifier which corresponds to a specific leg of a given chain.

This can be queried for its DecisionID.

Parameters
chainIdentifierThe HLT::Identifier corresponding to the chain.
counterThe numeral of the leg.
Returns
HLT::Identifier corresponding to the specified leg. Call .numeric() on this to get the DecisionID.

Definition at line 166 of file TrigCompositeUtilsRoot.cxx.

166  {
167  return createLegName( chainIdentifier.name(), counter );
168  }

◆ createLegName() [2/2]

HLT::Identifier TrigCompositeUtils::createLegName ( const std::string &  name,
size_t  counter 
)

Generate the HLT::Identifier which corresponds to a specific leg of a given chain.

This can be queried for its DecisionID.

Parameters
nameThe chain name.
counterThe numeral of the leg.
Returns
HLT::Identifier corresponding to the specified leg. Call .numeric() on this to get the DecisionID.

Definition at line 170 of file TrigCompositeUtilsRoot.cxx.

170  {
171  if (!isChainId(name)) {
172  throw std::runtime_error("TrigCompositeUtils::createLegName chainIdentifier '"+name+"' does not start with 'HLT_'");
173  }
174  if (counter > 999) {
175  throw std::runtime_error("TrigCompositeUtils::createLegName Leg counters above 999 are invalid.");
176  }
177  return HLT::Identifier( std::format("leg{:0>3d}_{}", counter, name) );
178  }

◆ decisionIDs() [1/3]

const std::vector< DecisionID > & TrigCompositeUtils::decisionIDs ( const Decision d)

Another variant of the above method to access DecisionIDs stored in the Decision object, returns const accessor.

Warning
Operates on the underlying xAOD vector form rather than the DecisionContainer set form

Definition at line 70 of file TrigCompositeUtilsRoot.cxx.

70  {
71  return readOnlyAccessor( *d );
72  }

◆ decisionIDs() [2/3]

void TrigCompositeUtils::decisionIDs ( const Decision d,
DecisionIDContainer destination 
)

Extracts DecisionIDs stored in the Decision object.

Definition at line 65 of file TrigCompositeUtilsRoot.cxx.

65  {
66  const std::vector<DecisionID>& decisions = readOnlyAccessor( *d );
67  destination.insert( decisions.begin(), decisions.end() );
68  }

◆ decisionIDs() [3/3]

std::vector< DecisionID > & TrigCompositeUtils::decisionIDs ( Decision d)

Another variant of the above method to access DecisionIDs stored in the Decision object, returns read/write accessor.

Warning
Operates on the underlying xAOD vector form rather than the DecisionContainer set form

Definition at line 74 of file TrigCompositeUtilsRoot.cxx.

74  {
75  return readWriteAccessor( *d );
76  }

◆ decisionToElementLink()

ElementLink< DecisionContainer > TrigCompositeUtils::decisionToElementLink ( const Decision d,
const EventContext &  ctx 
)

Takes a raw pointer to a Decision and returns an ElementLink to the Decision.

The Decision must already be in a container in SG.

Definition at line 123 of file TrigCompositeUtilsRoot.cxx.

123  {
124  const DecisionContainer* container = dynamic_cast<const DecisionContainer*>( d->container() );
125  if( ! container ) {
126  throw std::runtime_error("TrigCompositeUtils::convertToElementLink Using convertToElementLink(d) requires that the Decision d is already in a container");
127  }
128  return ElementLink<DecisionContainer>(*container, d->index(), ctx);
129  }

◆ dump()

std::string TrigCompositeUtils::dump ( const Decision tc,
const std::function< std::string(const Decision *)> &  printerFnc 
)

Prints the Decision object including the linked seeds @warnign expensive call.

Definition at line 880 of file TrigCompositeUtilsRoot.cxx.

880  {
881  std::string ret;
882  ret += printerFnc( tc );
883  if ( hasLinkToPrevious(tc) ) {
884  const std::vector<ElementLink<DecisionContainer>> seeds = getLinkToPrevious(tc);
885  for (const ElementLink<DecisionContainer>& seedEL : seeds) {
886  ret += " -> " + dump( *seedEL, printerFnc );
887  }
888  }
889  return ret;
890  }

◆ featureString()

const std::string& TrigCompositeUtils::featureString ( )
inline

Definition at line 420 of file TrigCompositeUtils.h.

420 { return Decision::s_featureString; }

◆ filterLinkVectorByContainerKey()

template<class CONTAINER >
void TrigCompositeUtils::filterLinkVectorByContainerKey ( const std::string &  containerSGKey,
std::vector< ElementLink< CONTAINER >> &  vector 
)

Removes ElementLinks from the supplied vector if they do not come from the specified collection (sub-string match).

Parameters
[in]containerSGKeyThe StoreGate key of the collection to match against. Performs sub-string matching. Passing "" performs no filtering.
[in,out]vectorMutable vector of ElementLinks on which to filter.

◆ filterNodeName()

const std::string& TrigCompositeUtils::filterNodeName ( )
inline

Definition at line 424 of file TrigCompositeUtils.h.

424 { return Decision::s_filterNodeNameString; }

◆ find()

const Decision * TrigCompositeUtils::find ( const Decision ,
const std::function< bool(const Decision *)> &  filter 
)

traverses Decision object links for another Decision object fulfilling the prerequisite specified by the filter

Returns
matching Decision object or nullptr

Definition at line 236 of file TrigCompositeUtilsRoot.cxx.

236  {
237  if ( filter( start ) ) return start;
238 
239  if ( hasLinkToPrevious(start) ) {
240  const std::vector<ElementLink<DecisionContainer>> seeds = getLinkToPrevious(start);
241  for (const ElementLink<DecisionContainer>& seedEL : seeds) {
242  const Decision* result = find( *seedEL, filter );
243  if (result) return result;
244  }
245  }
246 
247  return nullptr;
248  }

◆ findLink()

template<typename T >
LinkInfo<T> TrigCompositeUtils::findLink ( const Decision start,
const std::string &  linkName,
const bool  suppressMultipleLinksWarning = false 
)

Perform a recursive search for ElementLinks of type T and name 'linkName', starting from Decision object 'start' For the case of multiple links, this function only returns the first one found.

See also
findLinks
Parameters
[in]startthe Decision Object from where recursive search should begin
[in]linkNamethe name of the ElementLink stored inside one or more DecisionObjects.
[in]suppressMultipleLinksWarningfindLink will print a warning if more than one ElementLink is found, this can be silenced here.
Returns
LinkInfo A wrapper around an ElementLink and the location in the graph

◆ findLinks() [1/2]

template<typename T >
void TrigCompositeUtils::findLinks ( const Decision start,
const std::string &  linkName,
std::vector< LinkInfo< T >> &  links,
unsigned int  behaviour = TrigDefs::allFeaturesOfType,
std::set< const xAOD::TrigComposite * > *  fullyExploredFrom = nullptr 
)

search back the TC links for the object of type T linked to the one of TC (recursively) Populates provided vector with all located links to T of the corresponding linkName.

Parameters
[in]startthe Decision Object from where recursive search should begin
[in]linkNamethe name of the ElementLink stored inside one or more DecisionObjects.
[in,out]linksReference to vector, this will be populated with the found links.
[in]behaviourTrigDefs::allFeaturesOfType to explore all branches of the navigation graph all the way back to the HLTSeeding, or TrigDefs::lastFeatureOfType to exit early from each branch once a link has been located and collected. Optional OR with TrigDefs::fillDecisions to fill the decisions storage in LinkInfo.
[in,out]fullyExploredFromOptional cache used by the recursive algorithm to avoid exploring each node multiple times.

◆ findLinks() [2/2]

template<typename T >
std::vector<LinkInfo<T> > TrigCompositeUtils::findLinks ( const Decision start,
const std::string &  linkName,
unsigned int  behaviour = TrigDefs::allFeaturesOfType 
)

search back the TC links for the object of type T linked to the one of TC (recursively) This version returns a vector rather than requiring that one be passed to it.

Parameters
[in]startthe Decision Object from where recursive search should begin
[in]linkNamethe name of the ElementLink stored inside one or more DecisionObjects.
[in]behaviourTrigDefs::allFeaturesOfType to explore all branches of the navigation graph all the way back to the HLTSeeding, or TrigDefs::lastFeatureOfType to exit early from each branch once a link has been located and collected. Optional OR with TrigDefs::fillDecisions to fill the decisions storage in LinkInfo.
Returns
Vector with the found links.

◆ getExpressTerminusNode()

const Decision * TrigCompositeUtils::getExpressTerminusNode ( const DecisionContainer container)

Returns the express-accept navigation node from a collection or nullptr if missing.

Parameters
[in]containerCollection of navigation nodes
Returns
The express-accept node, or a nullptr if the node is not found

Definition at line 266 of file TrigCompositeUtilsRoot.cxx.

266  {
267  return getNodeByName(container, summaryPassExpressNodeName());
268  }

◆ getFilter()

std::function<bool(const std::vector<LinkInfo<xAOD::IParticleContainer>> &)> TrigCompositeUtils::getFilter ( FilterType  filter)

Get a lambda corresponding to the specified FilterType enum.

Definition at line 69 of file IPartCombItr.cxx.

70  {
71  switch (filter)
72  {
73  case FilterType::All:
74  return [](const std::vector<LinkInfo<xAOD::IParticleContainer>> &) { return true; };
75  case FilterType::UniqueObjects:
76  return uniqueObjects;
77  case FilterType::UniqueRoIs:
78  return uniqueRoIs;
79  default:
80  throw std::runtime_error("Unhandled FilterType enum value!");
81  return {};
82  }
83  }

◆ getIDFromLeg()

HLT::Identifier TrigCompositeUtils::getIDFromLeg ( const HLT::Identifier legIdentifier)

Generate the HLT::Identifier which corresponds to the chain name from the leg name.

This can be queried for its DecisionID.

Parameters
legIdentifierThe HLT::Identifier corresponding to the specific leg.
Returns
HLT::Identifier corresponding to the chain. Call .numeric() on this to get the DecisionID.

Definition at line 180 of file TrigCompositeUtilsRoot.cxx.

180  {
181  const std::string& name = legIdentifier.name();
182  if (isChainId(name)){
183  return legIdentifier;
184  } else if (isLegId(name)){
185  return HLT::Identifier(name.substr(7));
186  } else{
187  throw std::runtime_error("TrigCompositeUtils::getIDFromLeg legIdentifier '"+name+"' does not start with 'HLT_' or 'leg' ");
188  }
189  }

◆ getIndexFromLeg() [1/2]

int32_t TrigCompositeUtils::getIndexFromLeg ( const HLT::Identifier legIdentifier)

Extract the numeric index of a leg identifier.

Parameters
legIdentifierThe HLT::Identifier corresponding to the specific leg.
Returns
Index of the leg, e.g. leg002_HLT_mu50_L1MU20 would return 2. Returns -1 if not a leg identifier or 0 if a chain identifier.

Definition at line 191 of file TrigCompositeUtilsRoot.cxx.

191  {
192  return getIndexFromLeg(legIdentifier.name());
193  }

◆ getIndexFromLeg() [2/2]

int32_t TrigCompositeUtils::getIndexFromLeg ( const std::string &  name)

Extract the numeric index of a leg identifier.

Parameters
nameThe name of the HLT::Identifier corresponding to the specific leg.
Returns
Index of the leg, e.g. leg002_HLT_mu50_L1MU20 would return 2. Returns -1 if not a leg identifier or 0 if a chain identifier.

Definition at line 195 of file TrigCompositeUtilsRoot.cxx.

195  {
196  int32_t id = 0;
197  if (isChainId(name)){
198  // pass
199  } else if (isLegId(name)) {
200  std::from_chars(name.data()+3, name.data()+6, id);
201  } else {
202  throw std::runtime_error("TrigCompositeUtils::getIndexFromLeg legIdentifier '"+name+"' does not start with 'HLT_' or 'leg' ");
203  }
204  return id;
205  }

◆ getLinkToPrevious()

const std::vector< ElementLink< DecisionContainer > > TrigCompositeUtils::getLinkToPrevious ( const Decision d)

returns links to previous decision object 'seed'

Definition at line 157 of file TrigCompositeUtilsRoot.cxx.

157  {
158  return d->objectCollectionLinks<DecisionContainer>( seedString() );
159  }

◆ getNameAndIndexFromLeg()

std::pair< std::string, int32_t > TrigCompositeUtils::getNameAndIndexFromLeg ( const std::string &  name)

Extract the name and numeric index of a leg identifier.

Parameters
nameThe name of the HLT::Identifier corresponding to the specific leg.
Returns
Name and index of the leg, e.g. leg002_HLT_mu50_L1MU20 would return {HLT_mu50_L1MU20, 2}. If not a leg, returns {chainName, 0}. Throws if neither leg nor chain.

Definition at line 207 of file TrigCompositeUtilsRoot.cxx.

207  {
208  int32_t id = 0;
209  if (isChainId(name)) {
210  return {name, id};
211  } else if (isLegId(name)) {
212  std::from_chars(name.data()+3, name.data()+6, id);
213  return {name.substr(7), id};
214  } else {
215  throw std::runtime_error("TrigCompositeUtils::getIDFromLeg legIdentifier '"+name+"' does not start with 'HLT_' or 'leg' ");
216  }
217  }

◆ getNodeByName()

const Decision * TrigCompositeUtils::getNodeByName ( const DecisionContainer container,
const std::string &  nodeName 
)

Returns the navigation node with a given name from a collection or nullptr if missing.

Parameters
[in]containerCollection of navigation nodes
[in]nodeNameThe name of the node to find
Returns
The terminus node, or a nullptr if the node is not found

Definition at line 270 of file TrigCompositeUtilsRoot.cxx.

270  {
271  const auto it = std::find_if(container.begin(), container.end(), [&nodeName](const Decision* d){return d->name()==nodeName;});
272  if (it==container.end()) {return nullptr;}
273  return *it;
274  }

◆ getRejectedDecisionNodes() [1/2]

std::vector<const Decision*> TrigCompositeUtils::getRejectedDecisionNodes ( [[maybe_unused] ] const asg::EventStoreType eventStore,
const EventContext &  ctx,
const std::string &  summaryCollectionKey,
const DecisionIDContainer ids,
const std::set< std::string > &  keysToIgnore 
)

Definition at line 276 of file TrigCompositeUtilsRoot.cxx.

280  {
281 
282  // The following list contains all known summary store identifiers where the graph nodes are spread out over O(100s) or O(1000s)
283  // of different SG collections. This is the raw output from running the trigger online.
284  // When dealing with this, we need to query eventStore->keys in every event to obtain the full set of collections to process.
285  static const std::unordered_set<std::string> knownDistributedSummaryStores{
286  "HLTNav_Summary",
287  "_HLTNav_Summary"
288  };
289 
290  // The following list contains all known summary store identifiers where all nodes from the graph have been compactified / condensed
291  // down into a single container. Here we just have to search this one container.
292  static const std::unordered_set<std::string> knownCompactSummaryStores{"HLTNav_Summary_OnlineSlimmed",
293  "HLTNav_Summary_ESDSlimmed",
294  "HLTNav_Summary_AODSlimmed",
295  "HLTNav_Summary_DAODSlimmed",
296  "HLTNav_R2ToR3Summary"
297  };
298 
299  std::vector<std::string> keys; // The SG keys we will be exploring to find rejected decision nodes
300 
301  if (knownDistributedSummaryStores.contains(summaryCollectionKey) or summaryCollectionKey.empty()) {
302 
303  // If we have a distributed store then we need to query SG to find all keys.
304  // This should be a rare case now that we run compactification "online" (i.e. immediately after the trigger has executed)
305 #ifndef XAOD_STANDALONE
306  // The list of containers we need to read can change on a file-by-file basis (it depends on the SMK)
307  // Hence we query SG for all collections rather than maintain a large and ever changing ReadHandleKeyArray
308  eventStore->keys<DecisionContainer>(keys);
309 #else
310  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.");
311 #endif
312 
313  } else if (knownCompactSummaryStores.contains(summaryCollectionKey)) {
314 
315  keys.push_back(summaryCollectionKey);
316 
317  } else {
318 
319  using namespace msgRejected;
320  ANA_MSG_WARNING("getRejectedDecisionNodes has not been told about final collection " << summaryCollectionKey << " please update this function. Assuming that it is already compact.");
321  // Safest to assume that this is a compact summary store
322  keys.push_back(summaryCollectionKey);
323 
324  }
325 
326  std::vector<const Decision*> output; // The return vector of identified nodes where one of the chains in 'ids' was rejected
327 
328  // ReadHandleKey to be re-used in the loop to avoid repeated CLID lookups
329  SG::ReadHandleKey<DecisionContainer> containerRHKey("temp");
330  if (!containerRHKey.initialize().isSuccess()) {
331  throw std::runtime_error("Cannot initialize ReadHandleKey for DecisionContainer");
332  }
333 
334  // Loop over each DecisionContainer,
335  for (const std::string& key : keys) {
336  // Get and check this container
337  if ( ! (key.starts_with( "HLTNav_") || key.starts_with("_HLTNav_")) ) {
338  continue; // Only concerned about the decision containers which make up the navigation, they have name prefix of HLTNav (or _HLTNav for transient-only mode)
339  }
340  if (keysToIgnore.contains(key)) {
341  continue; // Have been asked to not explore this SG container
342  }
343 
344  // Create ReadHandle for this key
345  containerRHKey = key;
346  auto containerRH = SG::makeHandle(containerRHKey, ctx);
347  if (!containerRH.isValid()) {
348  throw std::runtime_error("Unable to retrieve " + key + " from event store.");
349  }
350 
351  for (const Decision* d : *containerRH) {
352  if ( not (d->name() == hypoAlgNodeName() or d->name() == comboHypoAlgNodeName()) ) {
353  continue; // Only want Decision objects created by HypoAlgs or ComboHypoAlgs
354  }
355  const std::vector<ElementLink<DecisionContainer>> mySeeds = d->objectCollectionLinks<DecisionContainer>(seedString());
356  if (mySeeds.empty()) {
357  continue;
358  }
359  const bool allSeedsValid = std::all_of(mySeeds.begin(), mySeeds.end(), [](const ElementLink<DecisionContainer>& s) { return s.isValid(); });
360  if (!allSeedsValid) {
361  using namespace msgRejected;
362  ANA_MSG_WARNING("A Decision object in " << key << " has invalid seeds. "
363  << "The trigger navigation information is incomplete. Skipping this Decision object.");
364  continue;
365  }
366 
367  DecisionIDContainer activeChainsIntoThisDecision;
368  decisionIDs(*mySeeds[0], activeChainsIntoThisDecision); // Get list of active chains from the first parent
369  if (mySeeds.size() > 1) {
370  for (size_t i = 1; i < mySeeds.size(); ++i) {
371  // If there are more than one parent, we only want to keep the intersection of all of the seeds
372  DecisionIDContainer moreActiveChains;
373  decisionIDs(*mySeeds[i], moreActiveChains);
375  std::set_intersection(activeChainsIntoThisDecision.begin(), activeChainsIntoThisDecision.end(),
376  moreActiveChains.begin(), moreActiveChains.end(),
377  std::inserter(intersection, intersection.begin()));
378  activeChainsIntoThisDecision = std::move(intersection); // Update the output to only be the intersection and continue to any other seeds
379  }
380  }
381  // We now know what chains were active coming into this Decision (d) from ALL seeds
382  // This is the logic required for each HypoTool to have activated and checked if its chain passes
383  // So the size of activeChainsIntoThisDecision corresponds to the number of HypoTools which will have run
384  // What do we care about? A chain, or all chains?
385  DecisionIDContainer chainsToCheck;
386  if (ids.empty()) { // We care about *all* chains
387  chainsToCheck = activeChainsIntoThisDecision;
388  } else { // We care about specified chains
389  chainsToCheck = ids;
390  }
391  // We have found a rejected decision node *iff* a chainID to check is *not* present here
392  // I.e. the HypoTool for the chain returned a NEGATIVE decision
393  DecisionIDContainer activeChainsPassedByThisDecision;
394  decisionIDs(d, activeChainsPassedByThisDecision);
395  for (const DecisionID checkID : chainsToCheck) {
396  if (not activeChainsPassedByThisDecision.contains(checkID) && // I was REJECTED here ...
397  activeChainsIntoThisDecision.contains(checkID)) { // ... but PASSSED by all my inputs
398  output.push_back(d);
399  break;
400  }
401  }
402  }
403  }
404  return output;
405  }

◆ getRejectedDecisionNodes() [2/2]

std::vector<const Decision*> TrigCompositeUtils::getRejectedDecisionNodes ( const asg::EventStoreType eventStore,
const EventContext &  ctx,
const std::string &  summaryCollectionKey,
const DecisionIDContainer ids = {},
const std::set< std::string > &  keysToIgnore = std::set< std::string >() 
)

Query all DecisionCollections in the event store, locate all Decision nodes in the graph where an object failed selection for a given chain.

Parameters
[in]eventStorePointer to event store within current event context
[in]ctxEventContext
[in]summaryCollectionKeyThe primary source of navigation data in the event (i.e the collection which contains the navigation terminus node).
[in]idsIDs 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.
[in]keysToIgnoreSet of SG keys of containers which should not be explored by getRejectedDecisionNodes.
Returns
Vector of Decision nodes whose attached feature failed the trigger chain logic for chain with DecisionID id

◆ getTerminusNode() [1/2]

const Decision * TrigCompositeUtils::getTerminusNode ( const DecisionContainer container)

Returns the terminus navigation node from a collection, assuming that the passed collection contains the terminus node.

Parameters
[in]containerCollection of navigation nodes which contains the terminus node
Returns
The terminus node, or a nullptr if the node is not found

Definition at line 262 of file TrigCompositeUtilsRoot.cxx.

262  {
263  return getNodeByName(container, summaryPassNodeName());
264  }

◆ getTerminusNode() [2/2]

const Decision * TrigCompositeUtils::getTerminusNode ( SG::ReadHandle< DecisionContainer > &  container)

Definition at line 258 of file TrigCompositeUtilsRoot.cxx.

258  {
259  return getTerminusNode(*container);
260  }

◆ hasLinkToPrevious()

bool TrigCompositeUtils::hasLinkToPrevious ( const Decision d)

checks if there is at least one 'seed' link to previous object

Definition at line 153 of file TrigCompositeUtilsRoot.cxx.

153  {
154  return d->hasObjectCollectionLinks( seedString() );
155  }

◆ hltSeedingNodeName()

const std::string& TrigCompositeUtils::hltSeedingNodeName ( )
inline

Definition at line 423 of file TrigCompositeUtils.h.

423 { return Decision::s_hltSeedingNodeNameString; }

◆ hypoAlgNodeName()

const std::string& TrigCompositeUtils::hypoAlgNodeName ( )
inline

Definition at line 426 of file TrigCompositeUtils.h.

426 { return Decision::s_hypoAlgNodeNameString; }

◆ initialRecRoIString()

const std::string& TrigCompositeUtils::initialRecRoIString ( )
inline

Definition at line 417 of file TrigCompositeUtils.h.

417 { return Decision::s_initialRecRoIString; }

◆ initialRoIString()

const std::string& TrigCompositeUtils::initialRoIString ( )
inline

Definition at line 416 of file TrigCompositeUtils.h.

416 { return Decision::s_initialRoIString; }

◆ inputMakerNodeName()

const std::string& TrigCompositeUtils::inputMakerNodeName ( )
inline

Definition at line 425 of file TrigCompositeUtils.h.

425 { return Decision::s_inputMakerNodeNameString; }

◆ insertDecisionIDs() [1/2]

void TrigCompositeUtils::insertDecisionIDs ( const Decision src,
Decision dest 
)

Appends the decision IDs of src to the dest decision object.

Warning
Performing merging of IDs and solving the duples (via set) This helps when making copies of Decision obejcts

Definition at line 78 of file TrigCompositeUtilsRoot.cxx.

78  {
79  DecisionIDContainer srcIds;
80  decisionIDs( src, srcIds ); // Now stored in a set
81  insertDecisionIDs( srcIds, dest);
82  }

◆ insertDecisionIDs() [2/2]

void TrigCompositeUtils::insertDecisionIDs ( const DecisionIDContainer src,
Decision dest 
)

Appends the decision IDs of src to the dest decision object.

Warning
Performing merging of IDs and solving the duples (via set)

Definition at line 84 of file TrigCompositeUtilsRoot.cxx.

84  {
85  DecisionIDContainer collateIDs;
86  // Decision are xAOD objects backed by a std::vector
87  // Here we use a std::set to de-duplicate IDs from src and dest before setting dest
88  decisionIDs( dest, collateIDs ); // Set operation 1. Get from dest
89  collateIDs.insert( src.begin(), src.end() ); // Set operation 2. Get from src
90  std::vector<DecisionID>& vdest = decisionIDs( dest );
91  // Clear and reserve target
92  vdest.clear();
93  vdest.reserve(collateIDs.size());
94  // Copy from set to (ordered) vector
95  vdest.insert( vdest.end(), collateIDs.begin(), collateIDs.end() );
96  }

◆ isAnyIDPassing()

bool TrigCompositeUtils::isAnyIDPassing ( const Decision d,
const DecisionIDContainer required 
)

Checks if any of the DecisionIDs passed in arg required is availble in Decision object.

Definition at line 109 of file TrigCompositeUtilsRoot.cxx.

109  {
110  for ( DecisionID id : readOnlyAccessor( *d ) ) {
111  if ( required.find( id ) != required.end() ) {
112  return true;
113  }
114  }
115  return false;
116  }

◆ isChainId() [1/2]

bool TrigCompositeUtils::isChainId ( const HLT::Identifier chainIdentifier)

Recognise whether the HLT identifier corresponds to a whole chain.

Parameters
chainIdentifierThe HLT::Identifier corresponding to the specific ID.
Returns
True if chain-ID, else false

Definition at line 227 of file TrigCompositeUtilsRoot.cxx.

227  {
228  return isChainId(chainIdentifier.name());
229  }

◆ isChainId() [2/2]

bool TrigCompositeUtils::isChainId ( const std::string &  name)

Recognise whether the HLT identifier corresponds to a whole chain.

Parameters
nameThe name of the HLT::Identifier corresponding to the specific ID.
Returns
True if chain-ID, else false

Definition at line 231 of file TrigCompositeUtilsRoot.cxx.

231  {
232  return name.starts_with("HLT_");
233  }

◆ isLegId() [1/2]

bool TrigCompositeUtils::isLegId ( const HLT::Identifier legIdentifier)

Recognise whether the chain ID is a leg ID.

Parameters
legIdentifierThe HLT::Identifier corresponding to the specific ID.
Returns
True if leg-ID, else false

Definition at line 219 of file TrigCompositeUtilsRoot.cxx.

219  {
220  return isLegId(legIdentifier.name());
221  }

◆ isLegId() [2/2]

bool TrigCompositeUtils::isLegId ( const std::string &  name)

Recognise whether the chain ID is a leg ID.

Parameters
nameThe name of the HLT::Identifier corresponding to the specific ID.
Returns
True if leg-ID, else false

Definition at line 223 of file TrigCompositeUtilsRoot.cxx.

223  {
224  return name.starts_with("leg");
225  }

◆ linkToPrevious() [1/2]

void TrigCompositeUtils::linkToPrevious ( Decision d,
const Decision dOld,
const EventContext &  ctx 
)

Links to the previous object, 'seed' decision provided explicitly.

Definition at line 149 of file TrigCompositeUtilsRoot.cxx.

149  {
150  d->addObjectCollectionLink(seedString(), decisionToElementLink(dOld, ctx));
151  }

◆ linkToPrevious() [2/2]

void TrigCompositeUtils::linkToPrevious ( Decision d,
const std::string &  previousCollectionKey,
size_t  previousIndex 
)

Links to the previous object, location of previous 'seed' decision supplied by hand.

Definition at line 140 of file TrigCompositeUtilsRoot.cxx.

140  {
141  ElementLink<DecisionContainer> seed = ElementLink<DecisionContainer>( previousCollectionKey, previousIndex );
142  if (!seed.isValid()) {
143  throw std::runtime_error("TrigCompositeUtils::linkToPrevious Invalid Decision Link key or index provided");
144  } else {
145  d->addObjectCollectionLink(seedString(), seed);
146  }
147  }

◆ newDecisionIn() [1/2]

Decision * TrigCompositeUtils::newDecisionIn ( DecisionContainer dc,
const Decision dOld,
const std::string &  name,
const EventContext &  ctx 
)

Helper method to create a Decision object, place it in the container and return a pointer to it.

RoI, view and feature links will be copied from the previous to the new decision and a "seed" link made between them

  • the container in which to place the new Decision
  • the previous decision to which the new one should be connected
  • the name is assigned to the TC object Note that the supplied DecisionContainer must have been recorded in the event store.

Definition at line 53 of file TrigCompositeUtilsRoot.cxx.

53  {
54  Decision* dNew = newDecisionIn( dc, name );
55  linkToPrevious(dNew, dOld, ctx); // Sets up link to 'seed' collection, points to dOld
56  return dNew;
57  }

◆ newDecisionIn() [2/2]

Decision * TrigCompositeUtils::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.

This is to make this: auto d = newDecisionIn(output); instead of: auto d = new Decision; output->push_back(d);
If provided, the name is assigned to the TC object Note that the supplied DecisionContainer must have been recorded in the event store.

Definition at line 44 of file TrigCompositeUtilsRoot.cxx.

44  {
45  Decision * x = new Decision;
46  dc->push_back( x );
47  if ( ! name.empty() ) {
48  x->setName( name );
49  }
50  return x;
51  }

◆ passed()

bool TrigCompositeUtils::passed ( DecisionID  id,
const DecisionIDContainer idSet 
)

checks if required decision ID is in the set of IDs in the container

Definition at line 118 of file TrigCompositeUtilsRoot.cxx.

118  {
119  return idSet.find( id ) != idSet.end();
120  }

◆ passedDecisionIDs()

template<typename T >
DecisionIDContainer TrigCompositeUtils::passedDecisionIDs ( const Decision d,
const T &  required 
)

return DecisionIDs in Decision object that match the required ones

  • required is a container of (values convertable to) DecisionIDs

◆ recursiveFlagForThinning()

void TrigCompositeUtils::recursiveFlagForThinning ( NavGraph node,
const bool  keepOnlyFinalFeatures,
const bool  removeEmptySteps,
const std::vector< std::string > &  nodesToDrop 
)

Used by trigger navigation thinning.

Recursive function. Explore all possible paths back through the navigation graph from the given node. Flag nodes as "keep" during the exploration, nodes not flagged as "keep" will be thinned if thin() is called on the NavGraph.

Parameters
[in]keepOnlyFinalFeaturesSet this to true for analysis-level slimming, when only trigger-matching is needed downstream.
[in]nodesToDropOptional list of node names. Nodes whose name matches an entry in this list will never be flagged as "keep".

Definition at line 459 of file TrigCompositeUtilsRoot.cxx.

463  {
464  std::set<NavGraphNode*> fullyExploredFrom;
465  for (NavGraphNode* finalNode : graph.finalNodes()) {
466  recursiveFlagForThinningInternal(finalNode, /*modeKeep*/true, fullyExploredFrom, keepOnlyFinalFeatures, removeEmptySteps, nodesToDrop);
467  }
468  }

◆ recursiveFlagForThinningInternal()

void TrigCompositeUtils::recursiveFlagForThinningInternal ( NavGraphNode node,
bool  modeKeep,
std::set< NavGraphNode * > &  fullyExploredFrom,
const bool  keepOnlyFinalFeatures,
const bool  removeEmptySteps,
const std::vector< std::string > &  nodesToDrop 
)

Used by recursiveFlagForThinning.

See also
recursiveFlagForThinning @paramp[inout] fullyExploredFrom Cache to avoid exploring graph branches more than once

Definition at line 471 of file TrigCompositeUtilsRoot.cxx.

477  {
478 
479  // If modeKeep == true, then by default we are KEEPING the nodes as we walk up the navigation (towards L1),
480  // otherwise by default we are THINNING the nodes
481  bool keep = modeKeep;
482 
483  // The calls to node->node() here are going from the transient NavGraphNode
484  // to the underlying const Decision* from the input collection. Cache these in local stack vars for better readability.
485 
486  const Decision* const me = node->node();
487  const Decision* const myFirstParent = (node->seeds().size() ? node->seeds().at(0)->node() : nullptr);
488  const Decision* const myFirstChild = (node->children().size() ? node->children().at(0)->node() : nullptr);
489 
490  // KEEP Section: The following code blocks may override the modeKeep default by setting keep=True for this node.
491 
492  if (keepOnlyFinalFeatures) {
493  // Check if we have reached the first feature
494  if ( modeKeep == true && (me->hasObjectLink(featureString()) || me->hasObjectLink("subfeature")) ) {
495  // Just to be explicit, we keep this node
496  keep = true;
497 
498  // Special BLS case: The bphysics object is attached exceptionally at the ComboHypo.
499  // We want to keep going up one more level in this case to get the Feature node too (we save the 4-vec of the BPhys and both of the muons/electrons)
500  const bool specialBphysCase = (me->name() == comboHypoAlgNodeName());
501 
502  // Special R2->R3 case: We can get steps with dummy features, these feature links point back to the same node.
503  // First check again the feature, with an addition requirement on the feature CLID. Then check if the feature points back to the node.
504  const bool specialR2toR3Case = (me->hasObjectLink(featureString(), ClassID_traits<DecisionContainer>::ID()) && me->object<Decision>(featureString()) == me);
505 
506  // We change the default behaviour to be modeKeep = false (unless we want to explore up one more level for BLS's special case
507  // or to the next feature for the R2->R3 special case) such that by default we start to NOT flag all the parent nodes to be kept
508  if (!specialBphysCase && !specialR2toR3Case) {
509  modeKeep = false;
510  }
511  }
512  }
513 
514  // We always by default keep the initial node from the HLTSeeding, but this may be overridden below by nodesToDrop
515  if (me->name() == hltSeedingNodeName()) {
516  keep = true;
517  }
518 
519  // DROP Section: The following code blocks may override both the current modeKeep default and the above KEEP section by setting keep=False for this node.
520 
521  // Check also against NodesToDrop
522  for (const std::string& toDrop : nodesToDrop) {
523  if (me->name() == toDrop) {
524  keep = false;
525  break;
526  }
527  }
528 
529  // Check against RemoveEmptySteps
530  // The signature we look for here is a InputMaker node connected directly to a ComboHypo node
531  // The key thing to identify is NO intermediate Hypo node
532  // This structure is created in Steps where some chain legs are running reconstruction, but other legs are idle - either due to
533  // menu alignment, or due to the legs being of different length.
534  // For passed chains, there is little point keeping these CH and IM nodes on the idle legs. So we have the option of slimming them here.
535  // First for the ComboHypo ...
536  if (removeEmptySteps && me->name() == comboHypoAlgNodeName() && myFirstParent && myFirstParent->name() == inputMakerNodeName()) {
537  keep = false;
538  }
539  // ... and also for the InputMaker, with flipped logic.
540  if (removeEmptySteps && me->name() == inputMakerNodeName() && myFirstChild && myFirstChild->name() == comboHypoAlgNodeName()) {
541  keep = false;
542  }
543 
544  // Check against RemoveEmptySteps
545  // Check for the R2->R3 empty step case
546  if (removeEmptySteps
547  && me->name() == hypoAlgNodeName()
548  && me->hasObjectLink(featureString(), ClassID_traits<DecisionContainer>::ID())
549  && me->object<Decision>(featureString()) == me)
550  {
551  keep = false;
552  }
553  // ... and also for the InputMaker
554  if (removeEmptySteps
555  && me->name() == inputMakerNodeName()
556  && myFirstChild
557  && myFirstChild->name() == hypoAlgNodeName()
558  && myFirstChild->hasObjectLink(featureString(), ClassID_traits<DecisionContainer>::ID())
559  && myFirstChild->object<Decision>(featureString()) == myFirstChild)
560  {
561  keep = false;
562  }
563 
564  // APPLICATION Section:
565 
566  if (keep) {
567  node->keep(); // Inform the node that it should NOT be thinned away.
568  }
569 
570  for (NavGraphNode* seed : node->seeds()) {
571 #if TRIGCOMPUTILS_ENABLE_EARLY_EXIT == 1
572  // NOTE: This code block cuts short the recursive graph exploration for any node which has already been fully-explored-from.
573  //
574  // If we are keeping final features, then processing each node exactly once is actually insufficient.
575  // This is because we may reach a node, X, with a feature which is penultimate/generally-non-final for some chain, A,
576  // but then later on we may follow Terminus->SummaryFilter->Hypothesis(X) for some chain, B, where this same
577  // feature from X _is_ the final-feature for chain B. Here we would not process node X again as we have already dealt with it.
578  // But we need to process it again as for chain B, modeKeep==true still and chain B wants to flag the node as keep().
579  //
580  // We only however need to force the exploration while we are in the mode where we are nominally keeping nodes (modeKeep == true).
581  // Once we have switched to dropping nodes by default, we should be OK to once again skip over nodes which we already processed.
582  // The only thing we should be keeping when modeKeep == false is the L1 node, any this is not dependent on path.
583  //
584  // See: ATR-28061
585  bool allowEarlyExit = true;
586  if (keepOnlyFinalFeatures) {
587  allowEarlyExit = (modeKeep == false);
588  }
589  if (allowEarlyExit && fullyExploredFrom.count(seed) == 1) {
590  // We have fully explored this branch
591  continue;
592  }
593 #endif
594  // Recursively call all the way up the graph to the initial nodes from the HLTSeeding
595  recursiveFlagForThinningInternal(seed, modeKeep, fullyExploredFrom, keepOnlyFinalFeatures, removeEmptySteps, nodesToDrop);
596  }
597 
598  // Have fully explored down from this point
599  fullyExploredFrom.insert(node);
600  }

◆ recursiveGetDecisions()

void TrigCompositeUtils::recursiveGetDecisions ( const Decision node,
NavGraph navGraph,
const DecisionIDContainer ids = {},
const bool  enforceDecisionOnStartNode = true 
)

Search back in time from "node" and locate all paths back through Decision objects for a given chain.

Parameters
[in]nodeThe Decision object to start the search from. Typically this will be one of the terminus objects from the HLTNav_Summary.
[in,out]navPathsHolds a sub-graph of the full navigation graph, filtered by DecisionID. An already partially populated graph may be provided as input.
[in]idsOptional DecisionIDContainer of Chains / Chain-Legs to trace through the navigation. If omitted, no chain requirement will be applied.
[in]enforceDecisionOnStartNodeIf the check of DecisionID should be carried out on the start node. enforceDecisionOnStartNode should be true if navigating for a trigger which passed (e.g. starting from HLTPassRaw) enforceDecisionOnStartNode should be false if navigating for a trigger which failed but whose failing start node(s) were recovered via getRejectedDecisionNodes

Definition at line 446 of file TrigCompositeUtilsRoot.cxx.

449  {
450 
451  std::set<const Decision*> fullyExploredFrom;
452  // Note: we do not require navGraph to be an empty graph. We can extend it.
453  recursiveGetDecisionsInternal(start, /*comingFrom*/nullptr, navGraph, fullyExploredFrom, ids, enforceDecisionOnStartNode);
454 
455  return;
456  }

◆ recursiveGetDecisionsInternal()

void TrigCompositeUtils::recursiveGetDecisionsInternal ( const Decision node,
const Decision comingFrom,
NavGraph navGraph,
std::set< const Decision * > &  fullyExploredFrom,
const DecisionIDContainer ids,
const bool  enforceDecisionOnNode 
)

Used by recursiveGetDecisions.

See also
recursiveGetDecisions
Parameters
comingFromThe parent node which has a link in the navigation to this "node" @paramp[inout] fullyExploredFrom Cache to avoid exploring graph branches more than once

Definition at line 407 of file TrigCompositeUtilsRoot.cxx.

412  {
413 
414  // Does this Decision satisfy the chain requirement?
415  if (enforceDecisionOnNode && ids.size() != 0 && !isAnyIDPassing(node, ids)) {
416  return; // Stop propagating down this leg. It does not concern the chain with DecisionID = id
417  }
418 
419  // This Decision object is part of this path through the Navigation
420  navGraph.addNode(node, comingFrom);
421 
422 #if TRIGCOMPUTILS_ENABLE_EARLY_EXIT == 1
423  // Note we have to do this check here (after calling addNode) rather than just before calling recursiveGetDecisionsInternal
424  if (fullyExploredFrom.count(node) == 1) {
425  // We have fully explored this branch
426  return;
427  }
428 #endif
429 
430  // Continue to the path(s) by looking at this Decision object's seed(s)
431  if ( hasLinkToPrevious(node) ) {
432  // Do the recursion
434  const Decision* seedDecision = *(seed); // Dereference ElementLink
435  // Sending true as final parameter for enforceDecisionOnStartNode as we are recursing away from the supplied start node
436  recursiveGetDecisionsInternal(seedDecision, node, navGraph, fullyExploredFrom, ids, /*enforceDecisionOnNode*/ true);
437  }
438  }
439 
440  // Have fully explored down from this point
441  fullyExploredFrom.insert(node);
442 
443  return;
444  }

◆ recursiveGetFeaturesOfType()

template<class CONTAINER >
const std::vector< LinkInfo<CONTAINER> > TrigCompositeUtils::recursiveGetFeaturesOfType ( const NavGraph navGraph,
const std::string &  containerSGKey = "",
const unsigned int  behaviour = TrigDefs::lastFeatureOfType,
const std::string &  navElementLinkKey = featureString(),
const DecisionIDContainer chainIDs = DecisionIDContainer() 
)

Extract features from the supplied linkVector (obtained through recursiveGetDecisions).

Parameters
[in]navPathsSub-graph of the trigger navigation which is to be considered.
[in]behaviourTrigDefs::allFeaturesOfType to explore all branches of the navigation graph all the way back to the HLTSeeding, or TrigDefs::lastFeatureOfType to exit early from each branch once a link has been located and collected. Optional OR with TrigDefs::fillDecisions to fill the decisions storage in LinkInfo.
[in]featureNameOptional name of feature link as saved online. The "feature" link is enforced, others may have been added.
[in]chainsOptional set of Chain IDs which features are being requested for. Used to set the ActiveState of returned LinkInfo objects.
Returns
Typed vector of LinkInfo. Each LinkInfo wraps an ElementLink to a feature and a pointer to the feature's Decision object in the navigation.

◆ recursiveGetFeaturesOfTypeInternal()

template<class CONTAINER >
void TrigCompositeUtils::recursiveGetFeaturesOfTypeInternal ( std::vector< LinkInfo< CONTAINER > > &  features,
std::set< const NavGraphNode * > &  fullyExploredFrom,
const NavGraphNode navGraphNode,
const std::string &  containerSGKey,
const unsigned int  behaviour,
const std::string &  navElementLinkKey,
const DecisionIDContainer chainIDs 
)

Internal implimentation called by recursiveGetFeaturesOfType, and by itself.

See also
recursiveGetFeaturesOfType
Parameters
[in,out]featuresThe untimate return vector. New links are to be appended.
[in,out]fullyExploredFromCache of graph nodes which have been fully explored, and hence don't need exploring again should they show up.
[in]navGraphNodeThe current node in the navGraph which is being explored.

◆ roiString()

const std::string& TrigCompositeUtils::roiString ( )
inline

Definition at line 418 of file TrigCompositeUtils.h.

418 { return Decision::s_roiString; }

◆ seedString()

const std::string& TrigCompositeUtils::seedString ( )
inline

Definition at line 421 of file TrigCompositeUtils.h.

421 { return Decision::s_seedString; }

◆ summaryFilterNodeName()

const std::string& TrigCompositeUtils::summaryFilterNodeName ( )
inline

Definition at line 428 of file TrigCompositeUtils.h.

428 { return Decision::s_summaryFilterNodeNameString; }

◆ summaryPassExpressNodeName()

const std::string& TrigCompositeUtils::summaryPassExpressNodeName ( )
inline

Definition at line 430 of file TrigCompositeUtils.h.

430 { return Decision::s_summaryPassExpressNodeNameString; }

◆ summaryPassNodeName()

const std::string& TrigCompositeUtils::summaryPassNodeName ( )
inline

Definition at line 429 of file TrigCompositeUtils.h.

429 { return Decision::s_summaryPassNodeNameString; }

◆ summaryPrescaledNodeName()

const std::string& TrigCompositeUtils::summaryPrescaledNodeName ( )
inline

Definition at line 431 of file TrigCompositeUtils.h.

431 { return Decision::s_summaryPrescaledNodeNameString; }

◆ typelessFindLink() [1/2]

bool TrigCompositeUtils::typelessFindLink ( const Decision start,
const std::string &  linkName,
sgkey_t key,
uint32_t &  clid,
Decision::index_type index,
const Decision *&  source,
const bool  suppressMultipleLinksWarning = false 
)

Perform a recursive search for ElementLinks of any time and name 'linkName', starting from Decision object 'start' Returns the link data in a typeless way, as raw key, index and CLID values.

These may be reconstituted into a typed ElementLink. For the case of multiple links, this function only returns the first one found.

See also
findLinks
Parameters
[in]startthe Decision Object from where recursive search should begin
[in]linkNamethe name of the ElementLink stored inside one or more DecisionObjects.
[out]keyThe storegate key (hash) of the located link's collection
[out]clidThe class ID of the link's collection
[out]indexThe link's index inside its collection.
[out]sourceThe link's originating Decision object.
[in]suppressMultipleLinksWarningfindLink will print a warning if more than one ElementLink is found, this can be silenced here.
Returns
True if a link was located

Definition at line 747 of file TrigCompositeUtilsRoot.cxx.

754  {
755  using namespace msgFindLink;
756  // We use findLink in cases where there is only one link to be found, or if there are multiple then we
757  // only want the most recent.
758  // Hence we can supply TrigDefs::lastFeatureOfType. /--> parent3(link)
759  // We can still have more then one link found if there is a branch in the navigation. E.g. start --> parent1 --> parent2(link)
760  // If both parent2 and parent3 possessed an admissible ElementLink, then the warning below will trigger, and only one of the
761  // links will be returned (whichever of parent2 or parent3 happened to be the first seed of parent1).
762  std::vector<sgkey_t> keyVec;
763  std::vector<uint32_t> clidVec;
764  std::vector<Decision::index_type> indexVec;
765  std::vector<const Decision*> sourceVec;
766  std::set<const xAOD::TrigComposite*> fullyExploredFrom;
767 
768  const bool result = typelessFindLinks(start, linkName, keyVec, clidVec, indexVec, sourceVec, TrigDefs::lastFeatureOfType, &fullyExploredFrom);
769  if (!result) {
770  return false; // Nothing found
771  }
772 
773  if (keyVec.size() > 1 && !suppressMultipleLinksWarning) {
774  ANA_MSG_WARNING (keyVec.size() << " typeless links found for " << linkName
775  << " returning the first link, consider using findLinks.");
776  }
777  key = keyVec.at(0);
778  clid = clidVec.at(0);
779  index = indexVec.at(0);
780  source = sourceVec.at(0);
781  return true;
782  }

◆ typelessFindLink() [2/2]

bool TrigCompositeUtils::typelessFindLink ( const NavGraph subGraph,
const std::string &  linkName,
sgkey_t key,
uint32_t &  clid,
Decision::index_type index,
const Decision *&  source,
const bool  suppressMultipleLinksWarning = false 
)

Version of typelessFindLink which operates on a sub-graph (described by the NavGraph), rather than the whole navigation graph.

If the supplied NavGraph has more than one entry point, then all will be explored.

Definition at line 785 of file TrigCompositeUtilsRoot.cxx.

792  {
793  using namespace msgFindLink;
794  // Note: This function should be the same as its predecessor, just using a NavGraph to start rather than a Decision*
795  // As a result, it can search from more than one Decision* (the NavGraph may have more than one final node)
796  // but it will still warn if this results in more than one link being located.
797  std::vector<sgkey_t> keyVec;
798  std::vector<uint32_t> clidVec;
799  std::vector<Decision::index_type> indexVec;
800  std::vector<const Decision*> sourceVec;
801  std::set<const Decision*> fullyExploredFrom;
802 
803  bool result = false;
804  for (const NavGraphNode* finalNode : subGraph.finalNodes()) {
805  result |= typelessFindLinks(finalNode, linkName, keyVec, clidVec, indexVec, sourceVec, TrigDefs::lastFeatureOfType, &fullyExploredFrom);
806  }
807 
808  if (!result) {
809  return false; // Nothing found
810  }
811 
812  if (keyVec.size() > 1 && !suppressMultipleLinksWarning) {
813  ANA_MSG_WARNING (keyVec.size() << " typeless links found for " << linkName
814  << " returning the first link, consider using findLinks.");
815  }
816  key = keyVec.at(0);
817  clid = clidVec.at(0);
818  index = indexVec.at(0);
819  source = sourceVec.at(0);
820  return true;
821  }

◆ typelessFindLinks() [1/2]

bool TrigCompositeUtils::typelessFindLinks ( const Decision start,
const std::string &  linkName,
std::vector< sgkey_t > &  keyVec,
std::vector< uint32_t > &  clidVec,
std::vector< Decision::index_type > &  indexVec,
std::vector< const Decision * > &  sourceVec,
const unsigned int  behaviour = TrigDefs::allFeaturesOfType,
std::set< const Decision * > *  fullyExploredFrom = nullptr 
)

search back the TC links for the object of type T linked to the one of TC (recursively) Returns the link data in a typeless way, as raw key, index and CLID values.

These may be reconstituted into a typed ElementLink. Populates provided vectors with all located links of the corresponding linkName.

Parameters
[in]startthe Decision Object from where recursive search should begin
[in]linkNamethe name of the ElementLink stored inside one or more DecisionObjects.
[in,out]keyVecThe return vector of the storegate key (hash) of the located link's collection
[in,out]clidVecThe return vector of the class ID of the link's collection
[in,out]indexVecThe return vector of the link's index inside its collection.
[in,out]sourceVecThe return vector of the link's originating Decision object.
[in]behaviourTrigDefs::allFeaturesOfType to explore all branches of the navigation graph all the way back to the HLTSeeding, or TrigDefs::lastFeatureOfType to exit early from each branch once a link has been located and collected.
[in,out]fullyExploredFromOptional cache used by the recursive algorithm to avoid exploring each node multiple times.

Definition at line 603 of file TrigCompositeUtilsRoot.cxx.

611  {
612  using namespace msgFindLink;
613 
614  // As the append vectors are user-supplied, perform some input validation.
615  if (keyVec.size() != clidVec.size() or clidVec.size() != indexVec.size()) {
616  ANA_MSG_WARNING("In typelessFindLinks, keyVec, clidVec, indexVec must all be the same size. Instead have:"
617  << keyVec.size() << ", " << clidVec.size() << ", " << indexVec.size());
618  return false;
619  }
620 
621  // Locate named links. Both collections of links and individual links are supported.
622  bool found = typelessFindLinksCommonLinkCollection(start, linkName, keyVec, clidVec, indexVec, sourceVec);
623 
624  // Early exit
625  if (found && (behaviour & TrigDefs::lastFeatureOfType)) {
626  return true;
627  }
628  // If not Early Exit, then recurse
630 #if TRIGCOMPUTILS_ENABLE_EARLY_EXIT == 1
631  if (fullyExploredFrom != nullptr) {
632  // We only need to recursively explore back from each node in the graph once.
633  // We can keep a record of nodes which we have already explored, these we can safely skip over.
634  if (fullyExploredFrom->count(*seed) == 1) {
635  continue;
636  }
637  }
638 #endif
639  found |= typelessFindLinks(*seed, linkName, keyVec, clidVec, indexVec, sourceVec, behaviour, fullyExploredFrom);
640  }
641  // Fully explored this node
642  if (fullyExploredFrom != nullptr) {
643  fullyExploredFrom->insert(start);
644  }
645  return found;
646  }

◆ typelessFindLinks() [2/2]

bool TrigCompositeUtils::typelessFindLinks ( const NavGraphNode start,
const std::string &  linkName,
std::vector< sgkey_t > &  keyVec,
std::vector< uint32_t > &  clidVec,
std::vector< Decision::index_type > &  indexVec,
std::vector< const Decision * > &  sourceVec,
const unsigned int  behaviour,
std::set< const Decision * > *  fullyExploredFrom 
)

Version of typelessFindLinks which operates on a sub-graph (entered via the supplied NavGraphNode), rather than the whole navigation graph.

Definition at line 649 of file TrigCompositeUtilsRoot.cxx.

657  {
658  using namespace msgFindLink;
659 
660  // As the append vectors are user-supplied, perform some input validation.
661  if (keyVec.size() != clidVec.size() or clidVec.size() != indexVec.size()) {
662  ANA_MSG_WARNING("In typelessFindLinks, keyVec, clidVec, indexVec must all be the same size. Instead have:"
663  << keyVec.size() << ", " << clidVec.size() << ", " << indexVec.size());
664  return false;
665  }
666 
667  const Decision* start_decisionObject = start->node();
668  // Locate named links. Both collections of links and individual links are supported.
669  bool found = typelessFindLinksCommonLinkCollection(start_decisionObject, linkName, keyVec, clidVec, indexVec, sourceVec);
670 
671  // Early exit
672  if (found && (behaviour & TrigDefs::lastFeatureOfType)) {
673  return true;
674  }
675  // If not Early Exit, then recurse
676  for (const NavGraphNode* seed : start->seeds()) {
677 #if TRIGCOMPUTILS_ENABLE_EARLY_EXIT == 1
678  if (fullyExploredFrom != nullptr) {
679  // We only need to recursively explore back from each node in the graph once.
680  // We can keep a record of nodes which we have already explored, these we can safely skip over.
681  const Decision* seed_decisionObject = seed->node();
682  if (fullyExploredFrom->count(seed_decisionObject) == 1) {
683  continue;
684  }
685  }
686 #endif
687  found |= typelessFindLinks(seed, linkName, keyVec, clidVec, indexVec, sourceVec, behaviour, fullyExploredFrom);
688  }
689  // Fully explored this node
690  if (fullyExploredFrom != nullptr) {
691  fullyExploredFrom->insert(start_decisionObject);
692  }
693  return found;
694  }

◆ typelessFindLinksCommonLinkCollection()

bool TrigCompositeUtils::typelessFindLinksCommonLinkCollection ( const Decision start,
const std::string &  linkName,
std::vector< sgkey_t > &  keyVec,
std::vector< uint32_t > &  clidVec,
std::vector< Decision::index_type > &  indexVec,
std::vector< const Decision * > &  sourceVec 
)

Common functionality shared by both typelessFindLinks interfaces Returns true if at least one link was collected.

Definition at line 697 of file TrigCompositeUtilsRoot.cxx.

703  {
704  bool found = false;
705  std::vector<sgkey_t> tmpKeyVec;
706  std::vector<uint32_t> tmpClidVec;
707  std::vector<Decision::index_type> tmpIndexVec;
708  if (start->hasObjectCollectionLinks(linkName)) {
709  found = start->typelessGetObjectCollectionLinks(linkName, tmpKeyVec, tmpClidVec, tmpIndexVec);
710  }
711  if (start->hasObjectLink(linkName)) {
712  sgkey_t tmpKey{0};
713  uint32_t tmpClid{0};
714  Decision::index_type tmpIndex{0};
715  found |= start->typelessGetObjectLink(linkName, tmpKey, tmpClid, tmpIndex);
716  tmpKeyVec.push_back(tmpKey);
717  tmpClidVec.push_back(tmpClid);
718  tmpIndexVec.push_back(tmpIndex);
719  }
720  // De-duplicate
721  for (size_t tmpi = 0; tmpi < tmpKeyVec.size(); ++tmpi) {
722  bool alreadyAdded = false;
723  const uint32_t tmpKey = tmpKeyVec.at(tmpi);
724  const uint32_t tmpClid = tmpClidVec.at(tmpi);
725  const Decision::index_type tmpIndex = tmpIndexVec.at(tmpi);
726  for (size_t veci = 0; veci < keyVec.size(); ++veci) {
727  if (SG::sgkeyEqual (keyVec.at(veci), tmpKey)
728  and clidVec.at(veci) == tmpClid
729  and indexVec.at(veci) == tmpIndex)
730  {
731  alreadyAdded = true;
732  break;
733  }
734  }
735  if (!alreadyAdded) {
736  keyVec.push_back( tmpKey );
737  clidVec.push_back( tmpClid );
738  indexVec.push_back( tmpIndex );
739  sourceVec.push_back( start );
740  }
741  }
742  return found;
743  }

◆ uniqueDecisionIDs()

void TrigCompositeUtils::uniqueDecisionIDs ( Decision dest)

Make unique list of decision IDs of dest Decision object.

Warning
Use vector->set->vector This helps solving multiple inserts of the Decision obejcts

Definition at line 98 of file TrigCompositeUtilsRoot.cxx.

98  {
99  // Re-use above insertDecisionIDs method.
100  // This implicitly performs de-duplication
101  return insertDecisionIDs(dest, dest);
102  }

◆ uniqueInitialRoIs()

bool TrigCompositeUtils::uniqueInitialRoIs ( const std::vector< LinkInfo< xAOD::IParticleContainer >> &  links)

Helper function that returns true if no objects share an initial RoI.

Definition at line 43 of file IPartCombItr.cxx.

44  {
45  std::set<std::pair<uint32_t, uint32_t>> seen;
46  for (const auto &info : links)
47  {
48  LinkInfo<TrigRoiDescriptorCollection> roi = findLink<TrigRoiDescriptorCollection>(info.source, initialRoIString());
49  if (!seen.insert(std::make_pair(roi.link.persKey(), roi.link.persIndex())).second)
50  // Insert returns false if that item already exists in it
51  return false;
52  }
53  return true;
54  }

◆ uniqueObjects()

bool TrigCompositeUtils::uniqueObjects ( const std::vector< LinkInfo< xAOD::IParticleContainer >> &  links)

Helper fucntion that returns true if no objects are repeated.

Definition at line 34 of file IPartCombItr.cxx.

35  {
36  std::set<const xAOD::IParticle *> seen;
37  for (const auto &info : links)
38  if (!seen.insert(*info.link).second)
39  return false;
40  return true;
41  }

◆ uniqueRoIs()

bool TrigCompositeUtils::uniqueRoIs ( const std::vector< LinkInfo< xAOD::IParticleContainer >> &  links)

Helper function that returns true if no objects share a final RoI.

Definition at line 56 of file IPartCombItr.cxx.

57  {
58  std::set<std::pair<uint32_t, uint32_t>> seen;
59  for (const auto &info : links)
60  {
61  LinkInfo<TrigRoiDescriptorCollection> roi = findLink<TrigRoiDescriptorCollection>(info.source, "roi");
62  if (!seen.insert(std::make_pair(roi.link.persKey(), roi.link.persIndex())).second)
63  // Insert returns false if that item already exists in it
64  return false;
65  }
66  return true;
67  }

◆ viewString()

const std::string& TrigCompositeUtils::viewString ( )
inline

Definition at line 419 of file TrigCompositeUtils.h.

419 { return Decision::s_viewString; }
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtils.h:420
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
get_generator_info.result
result
Definition: get_generator_info.py:21
TrigCompositeUtils::uniqueRoIs
bool uniqueRoIs(const std::vector< LinkInfo< xAOD::IParticleContainer >> &links)
Helper function that returns true if no objects share a final RoI.
Definition: IPartCombItr.cxx:56
TrigCompositeUtils::DecisionID
unsigned int DecisionID
Definition: TrigComposite_v1.h:27
TrigCompositeUtils::LinkInfo::link
ElementLink< T > link
Link to the feature.
Definition: LinkInfo.h:59
TrigCompositeUtils::UNSET
@ UNSET
Default property of state.
Definition: LinkInfo.h:20
TrigCompositeUtils::DecisionContainer
xAOD::TrigCompositeContainer DecisionContainer
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigCompositeContainer.h:21
vtune_athena.format
format
Definition: vtune_athena.py:14
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
TrigCompositeUtils::FilterType::UniqueRoIs
@ UniqueRoIs
Do not allow any two objects to share an RoI.
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:41
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
WriteCellNoiseToCool.src
src
Definition: WriteCellNoiseToCool.py:513
index
Definition: index.py:1
TrigCompositeUtils::uniqueObjects
bool uniqueObjects(const std::vector< LinkInfo< xAOD::IParticleContainer >> &links)
Helper fucntion that returns true if no objects are repeated.
Definition: IPartCombItr.cxx:34
hist_file_dump.d
d
Definition: hist_file_dump.py:142
TrigCompositeUtils::FilterType::UniqueObjects
@ UniqueObjects
Do not allow any repeated objects.
TrigCompositeUtils::summaryPassExpressNodeName
const std::string & summaryPassExpressNodeName()
Definition: TrigCompositeUtils.h:430
TrigCompositeUtils::getTerminusNode
const Decision * getTerminusNode(const DecisionContainer &container)
Returns the terminus navigation node from a collection, assuming that the passed collection contains ...
Definition: TrigCompositeUtilsRoot.cxx:262
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:13
TrigCompositeUtils::summaryPassNodeName
const std::string & summaryPassNodeName()
Definition: TrigCompositeUtils.h:429
skel.it
it
Definition: skel.GENtoEVGEN.py:407
TrigCompositeUtils::typelessFindLinksCommonLinkCollection
bool typelessFindLinksCommonLinkCollection(const Decision *start, const std::string &linkName, std::vector< sgkey_t > &keyVec, std::vector< uint32_t > &clidVec, std::vector< Decision::index_type > &indexVec, std::vector< const Decision * > &sourceVec)
Common functionality shared by both typelessFindLinks interfaces Returns true if at least one link wa...
Definition: TrigCompositeUtilsRoot.cxx:697
TrigCompositeUtils::comboHypoAlgNodeName
const std::string & comboHypoAlgNodeName()
Definition: TrigCompositeUtils.h:427
perfmonmt-printer.dest
dest
Definition: perfmonmt-printer.py:189
TrigCompositeUtils::recursiveFlagForThinningInternal
void recursiveFlagForThinningInternal(NavGraphNode *node, bool modeKeep, std::set< NavGraphNode * > &fullyExploredFrom, const bool keepOnlyFinalFeatures, const bool removeEmptySteps, const std::vector< std::string > &nodesToDrop)
Used by recursiveFlagForThinning.
Definition: TrigCompositeUtilsRoot.cxx:471
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
x
#define x
intersection
std::vector< std::string > intersection(std::vector< std::string > &v1, std::vector< std::string > &v2)
Definition: compareFlatTrees.cxx:25
TrigCompositeUtils::isLegId
bool isLegId(const std::string &name)
Recognise whether the chain ID is a leg ID.
Definition: TrigCompositeUtilsRoot.cxx:223
TrigConf::HLTChain::leg_multiplicities
const std::vector< size_t > & leg_multiplicities() const
Definition: TrigConfHLTData/TrigConfHLTData/HLTChain.h:83
TrigCompositeUtils::newDecisionIn
Decision * newDecisionIn(DecisionContainer *dc, const Decision *dOld, const std::string &name, const EventContext &ctx)
Helper method to create a Decision object, place it in the container and return a pointer to it.
Definition: TrigCompositeUtilsRoot.cxx:53
TrigCompositeUtils::insertDecisionIDs
void insertDecisionIDs(const DecisionIDContainer &src, Decision *dest)
Appends the decision IDs of src to the dest decision object.
Definition: TrigCompositeUtilsRoot.cxx:84
covarianceTool.filter
filter
Definition: covarianceTool.py:514
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:274
TrigCompositeUtils::buildCombinations
Combinations buildCombinations(const std::string &chainName, const std::vector< LinkInfo< xAOD::IParticleContainer >> &features, const TrigConf::HLTChain *chainInfo, FilterType filter)
Produce the combinations for a set of features.
Definition: TrigCompositeUtilsRoot.cxx:870
Generate_dsid_ranseed.seed
seed
Definition: Generate_dsid_ranseed.py:10
TrigCompositeUtils::typelessFindLinks
bool typelessFindLinks(const NavGraphNode *start, const std::string &linkName, std::vector< sgkey_t > &keyVec, std::vector< uint32_t > &clidVec, std::vector< Decision::index_type > &indexVec, std::vector< const Decision * > &sourceVec, const unsigned int behaviour, std::set< const Decision * > *fullyExploredFrom)
Version of typelessFindLinks which operates on a sub-graph (entered via the supplied NavGraphNode),...
Definition: TrigCompositeUtilsRoot.cxx:649
lumiFormat.i
int i
Definition: lumiFormat.py:85
ReadCalibFromCool.keep
keep
Definition: ReadCalibFromCool.py:85
TrigCompositeUtils::getLinkToPrevious
const std::vector< ElementLink< DecisionContainer > > getLinkToPrevious(const Decision *d)
returns links to previous decision object 'seed'
Definition: TrigCompositeUtilsRoot.cxx:157
DMTest::links
links
Definition: CLinks_v1.cxx:22
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:37
ANA_MSG_WARNING
#define ANA_MSG_WARNING(xmsg)
Macro printing warning messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:292
TrigCompositeUtils::initialRoIString
const std::string & initialRoIString()
Definition: TrigCompositeUtils.h:416
HLT::Identifier
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:19
TrigCompositeUtils::hltSeedingNodeName
const std::string & hltSeedingNodeName()
Definition: TrigCompositeUtils.h:423
xAOD::decisions
decisions
Definition: TrigComposite_v1.cxx:101
perfmonmt-printer.required
required
Definition: perfmonmt-printer.py:184
merge.output
output
Definition: merge.py:16
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:239
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
python.subdetectors.mmg.ids
ids
Definition: mmg.py:8
TrigCompositeUtils::Decision
xAOD::TrigComposite Decision
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:20
checkTriggerxAOD.found
found
Definition: checkTriggerxAOD.py:328
SG::sgkey_t
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition: CxxUtils/CxxUtils/sgkey_t.h:32
TrigCompositeUtils::seedString
const std::string & seedString()
Definition: TrigCompositeUtils.h:421
TrigCompositeUtils::hasLinkToPrevious
bool hasLinkToPrevious(const Decision *d)
checks if there is at least one 'seed' link to previous object
Definition: TrigCompositeUtilsRoot.cxx:153
python.combo.combinations
def combinations(items, n)
Definition: combo.py:84
TrigCompositeUtils::createLegName
HLT::Identifier createLegName(const std::string &name, size_t counter)
Generate the HLT::Identifier which corresponds to a specific leg of a given chain.
Definition: TrigCompositeUtilsRoot.cxx:170
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
TrigCompositeUtils::decisionIDs
std::vector< DecisionID > & decisionIDs(Decision *d)
Another variant of the above method to access DecisionIDs stored in the Decision object,...
Definition: TrigCompositeUtilsRoot.cxx:74
TrigCompositeUtils::LinkInfo
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...
Definition: LinkInfo.h:29
TrigCompositeUtils::DecisionIDContainer
std::set< DecisionID > DecisionIDContainer
Definition: TrigComposite_v1.h:28
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
TrigCompositeUtils::hypoAlgNodeName
const std::string & hypoAlgNodeName()
Definition: TrigCompositeUtils.h:426
python.TriggerAPI.TriggerAPISession.chainName
chainName
Definition: TriggerAPISession.py:426
HLT::Identifier::name
std::string name() const
reports human redable name
Definition: HLTIdentifier.cxx:12
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
TrigCompositeUtils::dump
std::string dump(const Decision *tc, const std::function< std::string(const Decision *)> &printerFnc)
Prints the Decision object including the linked seeds @warnign expensive call.
Definition: TrigCompositeUtilsRoot.cxx:880
node::node
node(node *n=0, const std::string &d="", TObject *t=0)
Definition: node.h:29
TrigCompositeUtils::FilterType::UniqueInitialRoIs
@ UniqueInitialRoIs
Do not allow any two objects to share an initial RoI.
ACTIVE
@ ACTIVE
Definition: ZdcID.h:21
ClassID_traits::ID
static CLID ID()
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:44
copySelective.source
string source
Definition: copySelective.py:31
TrigCompositeUtils::getNodeByName
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.
Definition: TrigCompositeUtilsRoot.cxx:270
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:801
test_pyathena.counter
counter
Definition: test_pyathena.py:15
set_intersection
Set * set_intersection(Set *set1, Set *set2)
Perform an intersection of two sets.
getFilter
TrackFilter * getFilter(const std::string &refname, int pdgId, TrackFilter *foff, TrackFilter *fmu, TrackFilter *ftruth)
This is awful code, passing in lots of filter pointers just so that they can be assigned neatly ?...
Definition: rmain.cxx:404
INACTIVE
@ INACTIVE
Definition: ZdcID.h:21
TrigCompositeUtils::isAnyIDPassing
bool isAnyIDPassing(const Decision *d, const DecisionIDContainer &required)
Checks if any of the DecisionIDs passed in arg required is availble in Decision object.
Definition: TrigCompositeUtilsRoot.cxx:109
TrigCompositeUtils::inputMakerNodeName
const std::string & inputMakerNodeName()
Definition: TrigCompositeUtils.h:425
python.ParticleTypeUtil.info
def info
Definition: ParticleTypeUtil.py:87
SG::sgkeyEqual
constexpr bool sgkeyEqual(const sgkey_t a, const sgkey_t b)
Compare two sgkeys for equality.
Definition: CxxUtils/CxxUtils/sgkey_t.h:39
node
Definition: node.h:21
PUClassification.All
All
Definition: PUClassification.py:17
TrigCompositeUtils::isChainId
bool isChainId(const std::string &name)
Recognise whether the HLT identifier corresponds to a whole chain.
Definition: TrigCompositeUtilsRoot.cxx:231
TrigCompositeUtils::getIndexFromLeg
int32_t getIndexFromLeg(const std::string &name)
Extract the numeric index of a leg identifier.
Definition: TrigCompositeUtilsRoot.cxx:195
TrigCompositeUtils::recursiveGetDecisionsInternal
void recursiveGetDecisionsInternal(const Decision *node, const Decision *comingFrom, NavGraph &navGraph, std::set< const Decision * > &fullyExploredFrom, const DecisionIDContainer &ids, const bool enforceDecisionOnNode)
Used by recursiveGetDecisions.
Definition: TrigCompositeUtilsRoot.cxx:407
TrigCompositeUtils::decisionToElementLink
ElementLink< DecisionContainer > decisionToElementLink(const Decision *d, const EventContext &ctx)
Takes a raw pointer to a Decision and returns an ElementLink to the Decision.
Definition: TrigCompositeUtilsRoot.cxx:123
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
index_type
unsigned int index_type
Definition: FPGATrackSimSGToRawHitsTool.h:37
TrigCompositeUtils::linkToPrevious
void linkToPrevious(Decision *d, const Decision *dOld, const EventContext &ctx)
Links to the previous object, 'seed' decision provided explicitly.
Definition: TrigCompositeUtilsRoot.cxx:149