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, const EventContext &ctx, std::set< const Decision * > &fullyExploredFrom, const DecisionIDContainer &ids, const bool enforceDecisionOnNode)
 Used by recursiveGetDecisions. More...
 
void recursiveGetDecisions (const Decision *node, NavGraph &navGraph, const EventContext &ctx, 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< uint16_t > &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< uint16_t > &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< uint16_t > &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, uint16_t &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, uint16_t &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/TrigCompositeUtils/TrigCompositeUtils.h.

◆ sgkey_t

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

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

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

834  {
835  return buildCombinations(chainName, features, legMultiplicities, getFilter(filter));
836  }

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

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

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

852  {
853  return buildCombinations(chainName, features, chainInfo, getFilter(filter));
854  }

◆ comboHypoAlgNodeName()

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

Definition at line 910 of file TrigCompositeUtilsRoot.cxx.

910  {
911  return Decision::s_comboHypoAlgNodeNameString;
912  }

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

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

◆ featureString()

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

Definition at line 886 of file TrigCompositeUtilsRoot.cxx.

886  {
887  return Decision::s_featureString;
888  }

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

898  {
899  return Decision::s_filterNodeNameString;
900  }

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

894  {
895  return Decision::s_hltSeedingNodeNameString;
896  }

◆ hypoAlgNodeName()

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

Definition at line 906 of file TrigCompositeUtilsRoot.cxx.

906  {
907  return Decision::s_hypoAlgNodeNameString;
908  }

◆ initialRecRoIString()

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

Definition at line 874 of file TrigCompositeUtilsRoot.cxx.

874  {
875  return Decision::s_initialRecRoIString;
876  }

◆ initialRoIString()

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

Definition at line 870 of file TrigCompositeUtilsRoot.cxx.

870  {
871  return Decision::s_initialRoIString;
872  }

◆ inputMakerNodeName()

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

Definition at line 902 of file TrigCompositeUtilsRoot.cxx.

902  {
903  return Decision::s_inputMakerNodeNameString;
904  }

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

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

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

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

◆ recursiveGetDecisions()

void TrigCompositeUtils::recursiveGetDecisions ( const Decision node,
NavGraph navGraph,
const EventContext &  ctx,
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]ctxThe event context.
[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 423 of file TrigCompositeUtilsRoot.cxx.

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

◆ recursiveGetDecisionsInternal()

void TrigCompositeUtils::recursiveGetDecisionsInternal ( const Decision node,
const Decision comingFrom,
NavGraph navGraph,
const EventContext &  ctx,
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.

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

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

878  {
879  return Decision::s_roiString;
880  }

◆ seedString()

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

Definition at line 890 of file TrigCompositeUtilsRoot.cxx.

890  {
891  return Decision::s_seedString;
892  }

◆ summaryFilterNodeName()

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

Definition at line 914 of file TrigCompositeUtilsRoot.cxx.

914  {
915  return Decision::s_summaryFilterNodeNameString;
916  }

◆ summaryPassExpressNodeName()

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

Definition at line 922 of file TrigCompositeUtilsRoot.cxx.

922  {
923  return Decision::s_summaryPassExpressNodeNameString;
924  }

◆ summaryPassNodeName()

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

Definition at line 918 of file TrigCompositeUtilsRoot.cxx.

918  {
919  return Decision::s_summaryPassNodeNameString;
920  }

◆ summaryPrescaledNodeName()

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

Definition at line 926 of file TrigCompositeUtilsRoot.cxx.

926  {
927  return Decision::s_summaryPrescaledNodeNameString;
928  }

◆ typelessFindLink() [1/2]

bool TrigCompositeUtils::typelessFindLink ( const Decision start,
const std::string &  linkName,
sgkey_t key,
uint32_t &  clid,
uint16_t &  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 725 of file TrigCompositeUtilsRoot.cxx.

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

◆ typelessFindLink() [2/2]

bool TrigCompositeUtils::typelessFindLink ( const NavGraph subGraph,
const std::string &  linkName,
sgkey_t key,
uint32_t &  clid,
uint16_t &  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 763 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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< uint16_t > &  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 581 of file TrigCompositeUtilsRoot.cxx.

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

◆ 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< uint16_t > &  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 627 of file TrigCompositeUtilsRoot.cxx.

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

◆ typelessFindLinksCommonLinkCollection()

bool TrigCompositeUtils::typelessFindLinksCommonLinkCollection ( const Decision start,
const std::string &  linkName,
std::vector< sgkey_t > &  keyVec,
std::vector< uint32_t > &  clidVec,
std::vector< uint16_t > &  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 675 of file TrigCompositeUtilsRoot.cxx.

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

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

882  {
883  return Decision::s_viewString;
884  }
grepfile.info
info
Definition: grepfile.py:38
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
TrigCompositeUtils::recursiveGetDecisionsInternal
void recursiveGetDecisionsInternal(const Decision *node, const Decision *comingFrom, NavGraph &navGraph, const EventContext &ctx, std::set< const Decision * > &fullyExploredFrom, const DecisionIDContainer &ids, const bool enforceDecisionOnNode)
Used by recursiveGetDecisions.
Definition: TrigCompositeUtilsRoot.cxx:383
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:922
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:47
TrigCompositeUtils::hltSeedingNodeName
const std::string & hltSeedingNodeName()
Definition: TrigCompositeUtilsRoot.cxx:894
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:906
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
TrigCompositeUtils::typelessFindLinksCommonLinkCollection
bool typelessFindLinksCommonLinkCollection(const Decision *start, const std::string &linkName, std::vector< sgkey_t > &keyVec, std::vector< uint32_t > &clidVec, std::vector< uint16_t > &indexVec, std::vector< const Decision * > &sourceVec)
Common functionality shared by both typelessFindLinks interfaces Returns true if at least one link wa...
Definition: TrigCompositeUtilsRoot.cxx:675
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
skel.it
it
Definition: skel.GENtoEVGEN.py:424
TrigCompositeUtils::comboHypoAlgNodeName
const std::string & comboHypoAlgNodeName()
Definition: TrigCompositeUtilsRoot.cxx:910
perfmonmt-printer.dest
dest
Definition: perfmonmt-printer.py:189
atn_test_sgProducerConsumerDataPool_jobOptions.end
end
Definition: atn_test_sgProducerConsumerDataPool_jobOptions.py:25
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:449
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
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:847
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
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
lumiFormat.i
int i
Definition: lumiFormat.py:92
TrigCompositeUtils::initialRoIString
const std::string & initialRoIString()
Definition: TrigCompositeUtilsRoot.cxx:870
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
ret
T ret(T t)
Definition: rootspy.cxx:260
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
TrigCompositeUtils::typelessFindLinks
bool typelessFindLinks(const NavGraphNode *start, const std::string &linkName, std::vector< sgkey_t > &keyVec, std::vector< uint32_t > &clidVec, std::vector< uint16_t > &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:627
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:81
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:886
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
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:918
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:890
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
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:857
TrigCompositeUtils::FilterType::UniqueInitialRoIs
@ UniqueInitialRoIs
Do not allow any two objects to share an initial RoI.
ACTIVE
@ ACTIVE
Definition: ZdcID.h:21
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:790
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
TrigConf::HLTChain::leg_multiplicities
const std::vector< size_t > leg_multiplicities() const
Definition: TrigConfHLTData/TrigConfHLTData/HLTChain.h:82
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:902
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
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37