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 (const asg::EventStoreType *eventStore, 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...
 
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...
 
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 bool lastFeatureOfType=true, 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 bool lastFeatureOfType, 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 18 of file LinkInfo.h.

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

◆ 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 58 of file TrigCompositeUtilsRoot.cxx.

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

◆ allFailed()

bool TrigCompositeUtils::allFailed ( const Decision d)

return true if there is no positive decision stored

Definition at line 103 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 814 of file TrigCompositeUtilsRoot.cxx.

819  {
820  Combinations combinations(filter);
821  combinations.reserve(legMultiplicities.size());
822  if (legMultiplicities.size() == 1)
823  combinations.addLeg(legMultiplicities.at(0), features);
824  else
825  for (std::size_t legIdx = 0; legIdx < legMultiplicities.size(); ++legIdx)
826  {
827  // Skip any that will not provide IParticle features
828  if (legMultiplicities[legIdx] == 0)
829  continue;
830  HLT::Identifier legID = createLegName(chainName, legIdx);
831  std::vector<LinkInfo<xAOD::IParticleContainer>> legFeatures;
832  for (const LinkInfo<xAOD::IParticleContainer>& info : features)
833  if (passed(legID.numeric(), info.decisions))
834  legFeatures.push_back(info);
835  combinations.addLeg(legMultiplicities.at(legIdx), std::move(legFeatures));
836  }
837  return combinations;
838  }

◆ 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 841 of file TrigCompositeUtilsRoot.cxx.

846  {
847  return buildCombinations(chainName, features, legMultiplicities, getFilter(filter));
848  }

◆ 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 850 of file TrigCompositeUtilsRoot.cxx.

855  {
856  return buildCombinations(chainName, features, chainInfo->leg_multiplicities(), filter);
857  }

◆ 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 859 of file TrigCompositeUtilsRoot.cxx.

864  {
865  return buildCombinations(chainName, features, chainInfo, getFilter(filter));
866  }

◆ comboHypoAlgNodeName()

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

Definition at line 922 of file TrigCompositeUtilsRoot.cxx.

922  {
923  return Decision::s_comboHypoAlgNodeNameString;
924  }

◆ 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 161 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 27 of file TrigCompositeUtilsRoot.cxx.

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

◆ createAndStore() [2/2]

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

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

Definition at line 36 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 165 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 169 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 69 of file TrigCompositeUtilsRoot.cxx.

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

◆ decisionIDs() [2/3]

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

Extracts DecisionIDs stored in the Decision object.

Definition at line 64 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 73 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 122 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 869 of file TrigCompositeUtilsRoot.cxx.

869  {
870  std::string ret;
871  ret += printerFnc( tc );
872  if ( hasLinkToPrevious(tc) ) {
873  const std::vector<ElementLink<DecisionContainer>> seeds = getLinkToPrevious(tc);
874  for (const ElementLink<DecisionContainer>& seedEL : seeds) {
875  ret += " -> " + dump( *seedEL, printerFnc );
876  }
877  }
878  return ret;
879  }

◆ featureString()

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

Definition at line 898 of file TrigCompositeUtilsRoot.cxx.

898  {
899  return Decision::s_featureString;
900  }

◆ 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 ( )

Definition at line 910 of file TrigCompositeUtilsRoot.cxx.

910  {
911  return Decision::s_filterNodeNameString;
912  }

◆ 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 235 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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.
[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.
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 265 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 179 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 190 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 194 of file TrigCompositeUtilsRoot.cxx.

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

◆ getLinkToPrevious()

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

returns links to previous decision object 'seed'

Definition at line 156 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 206 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 269 of file TrigCompositeUtilsRoot.cxx.

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

◆ getRejectedDecisionNodes()

std::vector< const Decision * > TrigCompositeUtils::getRejectedDecisionNodes ( const asg::EventStoreType eventStore,
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]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

Definition at line 275 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 261 of file TrigCompositeUtilsRoot.cxx.

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

◆ getTerminusNode() [2/2]

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

Definition at line 257 of file TrigCompositeUtilsRoot.cxx.

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

◆ hasLinkToPrevious()

bool TrigCompositeUtils::hasLinkToPrevious ( const Decision d)

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

Definition at line 152 of file TrigCompositeUtilsRoot.cxx.

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

◆ hltSeedingNodeName()

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

Definition at line 906 of file TrigCompositeUtilsRoot.cxx.

906  {
907  return Decision::s_hltSeedingNodeNameString;
908  }

◆ hypoAlgNodeName()

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

Definition at line 918 of file TrigCompositeUtilsRoot.cxx.

918  {
919  return Decision::s_hypoAlgNodeNameString;
920  }

◆ initialRecRoIString()

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

Definition at line 886 of file TrigCompositeUtilsRoot.cxx.

886  {
887  return Decision::s_initialRecRoIString;
888  }

◆ initialRoIString()

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

Definition at line 882 of file TrigCompositeUtilsRoot.cxx.

882  {
883  return Decision::s_initialRoIString;
884  }

◆ inputMakerNodeName()

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

Definition at line 914 of file TrigCompositeUtilsRoot.cxx.

914  {
915  return Decision::s_inputMakerNodeNameString;
916  }

◆ 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 77 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 83 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 108 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 226 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 230 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 218 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 222 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 148 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 139 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 52 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 43 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 117 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 449 of file TrigCompositeUtilsRoot.cxx.

453  {
454  std::set<NavGraphNode*> fullyExploredFrom;
455  for (NavGraphNode* finalNode : graph.finalNodes()) {
456  recursiveFlagForThinningInternal(finalNode, /*modeKeep*/true, fullyExploredFrom, keepOnlyFinalFeatures, removeEmptySteps, nodesToDrop);
457  }
458  }

◆ 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 461 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 436 of file TrigCompositeUtilsRoot.cxx.

439  {
440 
441  std::set<const Decision*> fullyExploredFrom;
442  // Note: we do not require navGraph to be an empty graph. We can extend it.
443  recursiveGetDecisionsInternal(start, /*comingFrom*/nullptr, navGraph, fullyExploredFrom, ids, enforceDecisionOnStartNode);
444 
445  return;
446  }

◆ 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 397 of file TrigCompositeUtilsRoot.cxx.

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

◆ recursiveGetFeaturesOfType()

template<class CONTAINER >
const std::vector< LinkInfo<CONTAINER> > TrigCompositeUtils::recursiveGetFeaturesOfType ( const NavGraph navGraph,
const std::string &  containerSGKey = "",
const bool  lastFeatureOfType = true,
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]lastFeatureOfTypeTrue for TrigDefs::lastFeatureOfType. stops at the first feature (of the correct type) found per path through the navigation.
[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 bool  lastFeatureOfType,
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 ( )

Definition at line 890 of file TrigCompositeUtilsRoot.cxx.

890  {
891  return Decision::s_roiString;
892  }

◆ seedString()

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

Definition at line 902 of file TrigCompositeUtilsRoot.cxx.

902  {
903  return Decision::s_seedString;
904  }

◆ summaryFilterNodeName()

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

Definition at line 926 of file TrigCompositeUtilsRoot.cxx.

926  {
927  return Decision::s_summaryFilterNodeNameString;
928  }

◆ summaryPassExpressNodeName()

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

Definition at line 934 of file TrigCompositeUtilsRoot.cxx.

934  {
935  return Decision::s_summaryPassExpressNodeNameString;
936  }

◆ summaryPassNodeName()

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

Definition at line 930 of file TrigCompositeUtilsRoot.cxx.

930  {
931  return Decision::s_summaryPassNodeNameString;
932  }

◆ summaryPrescaledNodeName()

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

Definition at line 938 of file TrigCompositeUtilsRoot.cxx.

938  {
939  return Decision::s_summaryPrescaledNodeNameString;
940  }

◆ 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 737 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 775 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 593 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 639 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 687 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 97 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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 ( )

Definition at line 894 of file TrigCompositeUtilsRoot.cxx.

894  {
895  return Decision::s_viewString;
896  }
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:61
TrigCompositeUtils::UNSET
@ UNSET
Default property of state.
Definition: LinkInfo.h:19
TrigCompositeUtils::DecisionContainer
xAOD::TrigCompositeContainer DecisionContainer
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigCompositeContainer.h:21
vtune_athena.format
format
Definition: vtune_athena.py:14
TrigCompositeUtils::passed
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
Definition: TrigCompositeUtilsRoot.cxx:117
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.
TrigCompositeUtils::summaryPassExpressNodeName
const std::string & summaryPassExpressNodeName()
Definition: TrigCompositeUtilsRoot.cxx:934
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:41
TrigCompositeUtils::hltSeedingNodeName
const std::string & hltSeedingNodeName()
Definition: TrigCompositeUtilsRoot.cxx:906
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
WriteCellNoiseToCool.src
src
Definition: WriteCellNoiseToCool.py:513
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
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::hypoAlgNodeName
const std::string & hypoAlgNodeName()
Definition: TrigCompositeUtilsRoot.cxx:918
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:261
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:13
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:687
TrigCompositeUtils::comboHypoAlgNodeName
const std::string & comboHypoAlgNodeName()
Definition: TrigCompositeUtilsRoot.cxx:922
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:461
StoreGateSvc::keys
void keys(std::vector< std::string > &vkeys, bool includeAlias=false, bool onlyValid=true) const
provide list of all StoreGate keys associated with an object.
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:222
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:52
TrigCompositeUtils::insertDecisionIDs
void insertDecisionIDs(const DecisionIDContainer &src, Decision *dest)
Appends the decision IDs of src to the dest decision object.
Definition: TrigCompositeUtilsRoot.cxx:83
covarianceTool.filter
filter
Definition: covarianceTool.py:514
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:859
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:639
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrigCompositeUtils::initialRoIString
const std::string & initialRoIString()
Definition: TrigCompositeUtilsRoot.cxx:882
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:156
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
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
HLT::Identifier
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:19
xAOD::decisions
decisions
Definition: TrigComposite_v1.cxx:101
perfmonmt-printer.required
required
Definition: perfmonmt-printer.py:184
merge.output
output
Definition: merge.py:16
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtilsRoot.cxx:898
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
TrigCompositeUtils::summaryPassNodeName
const std::string & summaryPassNodeName()
Definition: TrigCompositeUtilsRoot.cxx:930
SG::sgkey_t
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition: CxxUtils/CxxUtils/sgkey_t.h:32
TrigCompositeUtils::hasLinkToPrevious
bool hasLinkToPrevious(const Decision *d)
checks if there is at least one 'seed' link to previous object
Definition: TrigCompositeUtilsRoot.cxx:152
python.combo.combinations
def combinations(items, n)
Definition: combo.py:85
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:169
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
TrigCompositeUtils::seedString
const std::string & seedString()
Definition: TrigCompositeUtilsRoot.cxx:902
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:73
TrigCompositeUtils::LinkInfo
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...
Definition: LinkInfo.h:28
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.
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:869
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:269
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:108
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::inputMakerNodeName
const std::string & inputMakerNodeName()
Definition: TrigCompositeUtilsRoot.cxx:914
TrigCompositeUtils::isChainId
bool isChainId(const std::string &name)
Recognise whether the HLT identifier corresponds to a whole chain.
Definition: TrigCompositeUtilsRoot.cxx:230
TrigCompositeUtils::getIndexFromLeg
int32_t getIndexFromLeg(const std::string &name)
Extract the numeric index of a leg identifier.
Definition: TrigCompositeUtilsRoot.cxx:194
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:397
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:122
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:148