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=Gaudi::Hive::currentContext())
 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=Gaudi::Hive::currentContext())
 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=Gaudi::Hive::currentContext())
 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=Gaudi::Hive::currentContext())
 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 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...
 
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=Gaudi::Hive::currentContext())
 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=Gaudi::Hive::currentContext())
 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 51 of file TrigCompositeUtils.h.

◆ sgkey_t

Definition at line 45 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 61 of file TrigCompositeUtilsRoot.cxx.

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

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

805  {
806  Combinations combinations(filter);
807  combinations.reserve(legMultiplicities.size());
808  if (legMultiplicities.size() == 1)
809  combinations.addLeg(legMultiplicities.at(0), features);
810  else
811  for (std::size_t legIdx = 0; legIdx < legMultiplicities.size(); ++legIdx)
812  {
813  // Skip any that will not provide IParticle features
814  if (legMultiplicities[legIdx] == 0)
815  continue;
817  std::vector<LinkInfo<xAOD::IParticleContainer>> legFeatures;
818  for (const LinkInfo<xAOD::IParticleContainer>& info : features)
819  if (passed(legID.numeric(), info.decisions))
820  legFeatures.push_back(info);
821  combinations.addLeg(legMultiplicities.at(legIdx), std::move(legFeatures));
822  }
823  return combinations;
824  }

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

832  {
833  return buildCombinations(chainName, features, legMultiplicities, getFilter(filter));
834  }

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

841  {
842  return buildCombinations(chainName, features, chainInfo->leg_multiplicities(), filter);
843  }

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

850  {
851  return buildCombinations(chainName, features, chainInfo, getFilter(filter));
852  }

◆ comboHypoAlgNodeName()

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

Definition at line 908 of file TrigCompositeUtilsRoot.cxx.

908  {
909  return Decision::s_comboHypoAlgNodeNameString;
910  }

◆ 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 = Gaudi::Hive::currentContext() 
)

Creates and right away records the DecisionContainer with the key.

Returns the WriteHandle. If possible provide the context that comes via an argument to execute otherwise it will default to looking it up which is slower.

Definition at line 30 of file TrigCompositeUtilsRoot.cxx.

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

◆ createAndStore() [2/2]

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

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

Definition at line 39 of file TrigCompositeUtilsRoot.cxx.

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

◆ createAndStoreNoAux()

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

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

Returns the WriteHandle. No Aux store. If possible provide the context that comes via an argument to execute otherwise it will default to looking it up which is slower.

◆ createAndStoreWithAux()

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

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

Returns the WriteHandle. With Aux store. If possible provide the context that comes via an argument to execute otherwise it will default to looking it up which is slower.

◆ createLegName()

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

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

This can be queried for its DecisionID.

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

Definition at line 166 of file TrigCompositeUtilsRoot.cxx.

166  {
167  const std::string& name = chainIdentifier.name();
168  if (!isChainId(name)) {
169  throw std::runtime_error("TrigCompositeUtils::createLegName chainIdentifier '"+chainIdentifier.name()+"' does not start 'HLT_'");
170  }
171  if (counter > 999) {
172  throw std::runtime_error("TrigCompositeUtils::createLegName Leg counters above 999 are invalid.");
173  }
174  std::stringstream legStringStream;
175  legStringStream << "leg" << std::setfill('0') << std::setw(3) << counter << "_" << name;
176  return HLT::Identifier( legStringStream.str() );
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 72 of file TrigCompositeUtilsRoot.cxx.

72  {
73  return readOnlyAccessor( *d );
74  }

◆ decisionIDs() [2/3]

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

Extracts DecisionIDs stored in the Decision object.

Definition at line 67 of file TrigCompositeUtilsRoot.cxx.

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

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

76  {
77  return readWriteAccessor( *d );
78  }

◆ decisionToElementLink()

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

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

855  {
856  std::string ret;
857  ret += printerFnc( tc );
858  if ( hasLinkToPrevious(tc) ) {
859  const std::vector<ElementLink<DecisionContainer>> seeds = getLinkToPrevious(tc);
860  for (const ElementLink<DecisionContainer>& seedEL : seeds) {
861  ret += " -> " + dump( *seedEL, printerFnc );
862  }
863  }
864  return ret;
865  }

◆ featureString()

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

Definition at line 884 of file TrigCompositeUtilsRoot.cxx.

884  {
885  return Decision::s_featureString;
886  }

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

896  {
897  return Decision::s_filterNodeNameString;
898  }

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

221  {
222  if ( filter( start ) ) return start;
223 
224  if ( hasLinkToPrevious(start) ) {
225  const std::vector<ElementLink<DecisionContainer>> seeds = getLinkToPrevious(start);
226  for (const ElementLink<DecisionContainer>& seedEL : seeds) {
227  const Decision* result = find( *seedEL, filter );
228  if (result) return result;
229  }
230  }
231 
232  return nullptr;
233  }

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

251  {
252  return getNodeByName(container, summaryPassExpressNodeName());
253  }

◆ getFilter()

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

Get a lambda corresponding to the specified FilterType enum.

Definition at line 69 of file IPartCombItr.cxx.

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

◆ getIDFromLeg()

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

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

This can be queried for its DecisionID.

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

Definition at line 180 of file TrigCompositeUtilsRoot.cxx.

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

◆ getIndexFromLeg() [1/2]

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

Extract the numeric index of a leg identifier.

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

Definition at line 191 of file TrigCompositeUtilsRoot.cxx.

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

◆ getIndexFromLeg() [2/2]

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

Extract the numeric index of a leg identifier.

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

Definition at line 195 of file TrigCompositeUtilsRoot.cxx.

195  {
196  if (isChainId(name)){
197  return 0;
198  } else if (!isLegId(name)) {
199  return -1;
200  }
201  return std::stoi( name.substr(3,3) );
202  }

◆ 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  }

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

255  {
256  const auto it = std::find_if(container.begin(), container.end(), [&nodeName](const Decision* d){return d->name()==nodeName;});
257  if (it==container.end()) {return nullptr;}
258  return *it;
259  }

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

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

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

247  {
248  return getNodeByName(container, summaryPassNodeName());
249  }

◆ getTerminusNode() [2/2]

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

Definition at line 243 of file TrigCompositeUtilsRoot.cxx.

243  {
244  return getTerminusNode(*container);
245  }

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

892  {
893  return Decision::s_hltSeedingNodeNameString;
894  }

◆ hypoAlgNodeName()

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

Definition at line 904 of file TrigCompositeUtilsRoot.cxx.

904  {
905  return Decision::s_hypoAlgNodeNameString;
906  }

◆ initialRecRoIString()

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

Definition at line 872 of file TrigCompositeUtilsRoot.cxx.

872  {
873  return Decision::s_initialRecRoIString;
874  }

◆ initialRoIString()

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

Definition at line 868 of file TrigCompositeUtilsRoot.cxx.

868  {
869  return Decision::s_initialRoIString;
870  }

◆ inputMakerNodeName()

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

Definition at line 900 of file TrigCompositeUtilsRoot.cxx.

900  {
901  return Decision::s_inputMakerNodeNameString;
902  }

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

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

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

86  {
87  DecisionIDContainer collateIDs;
88  // Decision are xAOD objects backed by a std::vector
89  // Here we use a std::set to de-duplicate IDs from src and dest before setting dest
90  decisionIDs( dest, collateIDs ); // Set operation 1. Get from dest
91  collateIDs.insert( src.begin(), src.end() ); // Set operation 2. Get from src
92  decisionIDs( dest ).clear(); // Clear target
93  // Copy from set to (ordered) vector
94  decisionIDs( dest ).insert( decisionIDs(dest).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 212 of file TrigCompositeUtilsRoot.cxx.

212  {
213  return isChainId(chainIdentifier.name());
214  }

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

216  {
217  return (name.rfind("HLT_", 0) != std::string::npos);
218  }

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

204  {
205  return isLegId(legIdentifier.name());
206  }

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

208  {
209  return (name.rfind("leg", 0) != std::string::npos);
210  }

◆ 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 = Gaudi::Hive::currentContext() 
)

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

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

◆ 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. If possible provide the context that comes via an argument to execute otherwise it will default to looking it up which is slower.

Definition at line 46 of file TrigCompositeUtilsRoot.cxx.

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

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

439  {
440  std::set<NavGraphNode*> fullyExploredFrom;
441  for (NavGraphNode* finalNode : graph.finalNodes()) {
442  recursiveFlagForThinningInternal(finalNode, /*modeKeep*/true, fullyExploredFrom, keepOnlyFinalFeatures, removeEmptySteps, nodesToDrop);
443  }
444  }

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

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

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

425  {
426 
427  std::set<const Decision*> fullyExploredFrom;
428  // Note: we do not require navGraph to be an empty graph. We can extend it.
429  recursiveGetDecisionsInternal(start, /*comingFrom*/nullptr, navGraph, fullyExploredFrom, ids, enforceDecisionOnStartNode);
430 
431  return;
432  }

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

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

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

876  {
877  return Decision::s_roiString;
878  }

◆ seedString()

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

Definition at line 888 of file TrigCompositeUtilsRoot.cxx.

888  {
889  return Decision::s_seedString;
890  }

◆ summaryFilterNodeName()

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

Definition at line 912 of file TrigCompositeUtilsRoot.cxx.

912  {
913  return Decision::s_summaryFilterNodeNameString;
914  }

◆ summaryPassExpressNodeName()

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

Definition at line 920 of file TrigCompositeUtilsRoot.cxx.

920  {
921  return Decision::s_summaryPassExpressNodeNameString;
922  }

◆ summaryPassNodeName()

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

Definition at line 916 of file TrigCompositeUtilsRoot.cxx.

916  {
917  return Decision::s_summaryPassNodeNameString;
918  }

◆ summaryPrescaledNodeName()

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

Definition at line 924 of file TrigCompositeUtilsRoot.cxx.

924  {
925  return Decision::s_summaryPrescaledNodeNameString;
926  }

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

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

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

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

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

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

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

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

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

679  {
680  bool found = false;
681  std::vector<sgkey_t> tmpKeyVec;
682  std::vector<uint32_t> tmpClidVec;
683  std::vector<Decision::index_type> tmpIndexVec;
684  if (start->hasObjectCollectionLinks(linkName)) {
685  found = start->typelessGetObjectCollectionLinks(linkName, tmpKeyVec, tmpClidVec, tmpIndexVec);
686  }
687  if (start->hasObjectLink(linkName)) {
688  sgkey_t tmpKey{0};
689  uint32_t tmpClid{0};
690  Decision::index_type tmpIndex{0};
691  found |= start->typelessGetObjectLink(linkName, tmpKey, tmpClid, tmpIndex);
692  tmpKeyVec.push_back(tmpKey);
693  tmpClidVec.push_back(tmpClid);
694  tmpIndexVec.push_back(tmpIndex);
695  }
696  // De-duplicate
697  for (size_t tmpi = 0; tmpi < tmpKeyVec.size(); ++tmpi) {
698  bool alreadyAdded = false;
699  const uint32_t tmpKey = tmpKeyVec.at(tmpi);
700  const uint32_t tmpClid = tmpClidVec.at(tmpi);
701  const Decision::index_type tmpIndex = tmpIndexVec.at(tmpi);
702  for (size_t veci = 0; veci < keyVec.size(); ++veci) {
703  if (SG::sgkeyEqual (keyVec.at(veci), tmpKey)
704  and clidVec.at(veci) == tmpClid
705  and indexVec.at(veci) == tmpIndex)
706  {
707  alreadyAdded = true;
708  break;
709  }
710  }
711  if (!alreadyAdded) {
712  keyVec.push_back( tmpKey );
713  clidVec.push_back( tmpClid );
714  indexVec.push_back( tmpIndex );
715  sourceVec.push_back( start );
716  }
717  }
718  return found;
719  }

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

880  {
881  return Decision::s_viewString;
882  }
grepfile.info
info
Definition: grepfile.py:38
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
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
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:920
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:47
TrigCompositeUtils::hltSeedingNodeName
const std::string & hltSeedingNodeName()
Definition: TrigCompositeUtilsRoot.cxx:892
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:70
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:137
TrigCompositeUtils::FilterType::UniqueObjects
@ UniqueObjects
Do not allow any repeated objects.
TrigCompositeUtils::hypoAlgNodeName
const std::string & hypoAlgNodeName()
Definition: TrigCompositeUtilsRoot.cxx:904
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:247
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
skel.it
it
Definition: skel.GENtoEVGEN.py:396
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:673
TrigCompositeUtils::comboHypoAlgNodeName
const std::string & comboHypoAlgNodeName()
Definition: TrigCompositeUtilsRoot.cxx:908
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:447
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:208
TrigConf::HLTChain::leg_multiplicities
const std::vector< size_t > & leg_multiplicities() const
Definition: TrigConfHLTData/TrigConfHLTData/HLTChain.h:82
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
TrigCompositeUtils::insertDecisionIDs
void insertDecisionIDs(const DecisionIDContainer &src, Decision *dest)
Appends the decision IDs of src to the dest decision object.
Definition: TrigCompositeUtilsRoot.cxx:86
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:845
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
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:625
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrigCompositeUtils::initialRoIString
const std::string & initialRoIString()
Definition: TrigCompositeUtilsRoot.cxx:868
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
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:55
DMTest::links
links
Definition: CLinks_v1.cxx:22
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
ANA_MSG_WARNING
#define ANA_MSG_WARNING(xmsg)
Macro printing warning messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:292
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
node::node
node()
Definition: memory_hooks-stdcmalloc.h:76
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
HLT::Identifier
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:20
xAOD::decisions
decisions
Definition: TrigComposite_v1.cxx:101
perfmonmt-printer.required
required
Definition: perfmonmt-printer.py:184
merge.output
output
Definition: merge.py:17
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtilsRoot.cxx:884
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
python.subdetectors.mmg.ids
ids
Definition: mmg.py:8
TrigCompositeUtils::Decision
xAOD::TrigComposite Decision
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:20
TrigCompositeUtils::summaryPassNodeName
const std::string & summaryPassNodeName()
Definition: TrigCompositeUtilsRoot.cxx:916
SG::sgkey_t
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition: CxxUtils/CxxUtils/sgkey_t.h:32
TrigCompositeUtils::createLegName
HLT::Identifier createLegName(const HLT::Identifier &chainIdentifier, size_t counter)
Generate the HLT::Identifier which corresponds to a specific leg of a given chain.
Definition: TrigCompositeUtilsRoot.cxx:166
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
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
TrigCompositeUtils::seedString
const std::string & seedString()
Definition: TrigCompositeUtilsRoot.cxx:888
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:76
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.
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101
python.TriggerAPI.TriggerAPISession.chainName
chainName
Definition: TriggerAPISession.py:426
HLT::Identifier::name
std::string name() const
reports human redable name if it is enabled or, empty string
Definition: HLTIdentifier.cxx:14
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:855
TrigCompositeUtils::FilterType::UniqueInitialRoIs
@ UniqueInitialRoIs
Do not allow any two objects to share an initial RoI.
ACTIVE
@ ACTIVE
Definition: ZdcID.h:21
copySelective.source
string source
Definition: copySelective.py:32
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:255
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
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:403
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
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
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: memory_hooks-stdcmalloc.h:74
PUClassification.All
All
Definition: PUClassification.py:17
TrigCompositeUtils::inputMakerNodeName
const std::string & inputMakerNodeName()
Definition: TrigCompositeUtilsRoot.cxx:900
TrigCompositeUtils::isChainId
bool isChainId(const std::string &name)
Recognise whether the HLT identifier corresponds to a whole chain.
Definition: TrigCompositeUtilsRoot.cxx:216
TrigCompositeUtils::getIndexFromLeg
int32_t getIndexFromLeg(const std::string &name)
Extract the numeric index of a leg identifier.
Definition: TrigCompositeUtilsRoot.cxx:195
TrigCompositeUtils::recursiveGetDecisionsInternal
void recursiveGetDecisionsInternal(const Decision *node, const Decision *comingFrom, NavGraph &navGraph, std::set< const Decision * > &fullyExploredFrom, const DecisionIDContainer &ids, const bool enforceDecisionOnNode)
Used by recursiveGetDecisions.
Definition: TrigCompositeUtilsRoot.cxx:383
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
index_type
unsigned int index_type
Definition: FPGATrackSimSGToRawHitsTool.h:37