 |
ATLAS Offline Software
|
Go to the documentation of this file.
29 auto data = std::make_unique<DecisionContainer>() ;
30 auto aux = std::make_unique<DecisionAuxContainer>() ;
31 data->setStore( aux.get() );
32 handle.
record( std::move(
data ), std::move( aux ) ).ignore();
37 auto data = std::make_unique<DecisionContainer>() ;
38 auto aux = std::make_unique<DecisionAuxContainer>() ;
39 data->setStore( aux.get() );
40 handle.
record( std::move(
data ), std::move( aux ) ).ignore();
46 if ( !
name.empty() ) {
59 std::vector<DecisionID>&
decisions = readWriteAccessor( *
d );
65 const std::vector<DecisionID>&
decisions = readOnlyAccessor( *
d );
70 return readOnlyAccessor( *
d );
74 return readWriteAccessor( *
d );
88 collateIDs.insert(
src.begin(),
src.end() );
92 vdest.reserve(collateIDs.size());
94 vdest.insert( vdest.end(), collateIDs.begin(), collateIDs.end() );
104 const std::vector<DecisionID>&
decisions = readOnlyAccessor( *
d );
118 return idSet.find(
id ) != idSet.end();
121 #if !defined(XAOD_STANDALONE) && !defined(XAOD_ANALYSIS) // Full athena
125 throw std::runtime_error(
"TrigCompositeUtils::convertToElementLink Using convertToElementLink(d) requires that the Decision d is already in a container");
129 #else // Analysis or Standalone
133 throw std::runtime_error(
"TrigCompositeUtils::convertToElementLink Using convertToElementLink(d) requires that the Decision d is already in a container");
141 if (!seed.isValid()) {
142 throw std::runtime_error(
"TrigCompositeUtils::linkToPrevious Invalid Decision Link key or index provided");
153 return d->hasObjectCollectionLinks(
seedString() );
162 return dest->copyAllLinksFrom(
src);
171 throw std::runtime_error(
"TrigCompositeUtils::createLegName chainIdentifier '"+
name+
"' does not start with 'HLT_'");
174 throw std::runtime_error(
"TrigCompositeUtils::createLegName Leg counters above 999 are invalid.");
180 const std::string&
name = legIdentifier.
name();
182 return legIdentifier;
186 throw std::runtime_error(
"TrigCompositeUtils::getIDFromLeg legIdentifier '"+
name+
"' does not start with 'HLT_' or 'leg' ");
199 std::from_chars(
name.data()+3,
name.data()+6,
id);
201 throw std::runtime_error(
"TrigCompositeUtils::getIndexFromLeg legIdentifier '"+
name+
"' does not start with 'HLT_' or 'leg' ");
211 std::from_chars(
name.data()+3,
name.data()+6,
id);
212 return {
name.substr(7),
id};
214 throw std::runtime_error(
"TrigCompositeUtils::getIDFromLeg legIdentifier '"+
name+
"' does not start with 'HLT_' or 'leg' ");
223 return name.starts_with(
"leg");
231 return name.starts_with(
"HLT_");
270 const auto it = std::find_if(container.
begin(), container.
end(), [&nodeName](
const Decision*
d){return d->name()==nodeName;});
271 if (
it==container.
end()) {
return nullptr;}
276 const std::string& summaryCollectionKey,
278 const std::set<std::string>& keysToIgnore) {
283 static const std::vector<std::string> knownDistributedSummaryStores{
290 static const std::vector<std::string> knownCompactSummaryStores{
"HLTNav_Summary_OnlineSlimmed",
291 "HLTNav_Summary_ESDSlimmed",
292 "HLTNav_Summary_AODSlimmed",
293 "HLTNav_Summary_DAODSlimmed",
294 "HLTNav_R2ToR3Summary"
297 std::vector<std::string>
keys;
299 if (
std::find(knownDistributedSummaryStores.cbegin(), knownDistributedSummaryStores.cend(), summaryCollectionKey) != knownDistributedSummaryStores.end() or summaryCollectionKey ==
"") {
303 #ifndef XAOD_STANDALONE
309 throw std::runtime_error(
"Cannot obtain rejected HLT features in AnalysisBase when reading from uncompactified navigation containers, run trigger navigation slimming first if you really need this.");
312 }
else if (
std::find(knownCompactSummaryStores.cbegin(), knownCompactSummaryStores.cend(), summaryCollectionKey) != knownCompactSummaryStores.end()) {
314 keys.push_back(summaryCollectionKey);
318 using namespace msgRejected;
319 ANA_MSG_WARNING(
"getRejectedDecisionNodes has not been told about final collection " << summaryCollectionKey <<
" please update this function. Assuming that it is already compact.");
321 keys.push_back(summaryCollectionKey);
325 std::vector<const Decision*> output;
328 for (
const std::string&
key :
keys) {
330 if ( ! (
key.starts_with(
"HLTNav_") ||
key.starts_with(
"_HLTNav_")) ) {
333 if (keysToIgnore.count(
key) == 1) {
338 throw std::runtime_error(
"Unable to retrieve " +
key +
" from event store.");
346 if (mySeeds.size() == 0) {
350 if (!allSeedsValid) {
351 using namespace msgRejected;
353 <<
"The trigger navigation information is incomplete. Skipping this Decision object.");
358 decisionIDs(*(mySeeds.at(0)), activeChainsIntoThisDecision);
359 if (mySeeds.size() > 1) {
360 for (
size_t i = 1;
i < mySeeds.size(); ++
i) {
366 moreActiveChains.begin(), moreActiveChains.end(),
376 if (
ids.size() == 0) {
377 chainsToCheck = activeChainsIntoThisDecision;
385 for (
const DecisionID checkID : chainsToCheck) {
386 if (activeChainsPassedByThisDecision.find(checkID) == activeChainsPassedByThisDecision.end() &&
387 activeChainsIntoThisDecision.count(checkID) == 1) {
400 std::set<const Decision*>& fullyExploredFrom,
402 const bool enforceDecisionOnNode) {
412 #if TRIGCOMPUTILS_ENABLE_EARLY_EXIT == 1
414 if (fullyExploredFrom.count(
node) == 1) {
424 const Decision* seedDecision = *(seed);
431 fullyExploredFrom.insert(
node);
439 const bool enforceDecisionOnStartNode) {
441 std::set<const Decision*> fullyExploredFrom;
450 const bool keepOnlyFinalFeatures,
451 const bool removeEmptySteps,
452 const std::vector<std::string>& nodesToDrop)
454 std::set<NavGraphNode*> fullyExploredFrom;
463 std::set<NavGraphNode*>& fullyExploredFrom,
464 const bool keepOnlyFinalFeatures,
465 const bool removeEmptySteps,
466 const std::vector<std::string>& nodesToDrop)
471 bool keep = modeKeep;
477 const Decision*
const myFirstParent = (
node->seeds().size() ?
node->seeds().at(0)->
node() :
nullptr);
478 const Decision*
const myFirstChild = (
node->children().size() ?
node->children().at(0)->
node() :
nullptr);
482 if (keepOnlyFinalFeatures) {
498 if (!specialBphysCase && !specialR2toR3Case) {
512 for (
const std::string& toDrop : nodesToDrop) {
513 if (me->
name() == toDrop) {
561 #if TRIGCOMPUTILS_ENABLE_EARLY_EXIT == 1
575 bool allowEarlyExit =
true;
576 if (keepOnlyFinalFeatures) {
577 allowEarlyExit = (modeKeep ==
false);
579 if (allowEarlyExit && fullyExploredFrom.count(seed) == 1) {
589 fullyExploredFrom.insert(
node);
594 const std::string& linkName,
595 std::vector<sgkey_t>& keyVec,
596 std::vector<uint32_t>& clidVec,
597 std::vector<Decision::index_type>& indexVec,
598 std::vector<const Decision*>& sourceVec,
599 const unsigned int behaviour,
600 std::set<const Decision*>* fullyExploredFrom)
602 using namespace msgFindLink;
605 if (keyVec.size() != clidVec.size() or clidVec.size() != indexVec.size()) {
606 ANA_MSG_WARNING(
"In typelessFindLinks, keyVec, clidVec, indexVec must all be the same size. Instead have:"
607 << keyVec.size() <<
", " << clidVec.size() <<
", " << indexVec.size());
615 if (
found && behaviour == TrigDefs::lastFeatureOfType) {
620 #if TRIGCOMPUTILS_ENABLE_EARLY_EXIT == 1
621 if (fullyExploredFrom !=
nullptr) {
624 if (fullyExploredFrom->count(*seed) == 1) {
629 found |=
typelessFindLinks(*seed, linkName, keyVec, clidVec, indexVec, sourceVec, behaviour, fullyExploredFrom);
632 if (fullyExploredFrom !=
nullptr) {
633 fullyExploredFrom->insert(
start);
640 const std::string& linkName,
641 std::vector<sgkey_t>& keyVec,
642 std::vector<uint32_t>& clidVec,
643 std::vector<Decision::index_type>& indexVec,
644 std::vector<const Decision*>& sourceVec,
645 const unsigned int behaviour,
646 std::set<const Decision*>* fullyExploredFrom)
648 using namespace msgFindLink;
651 if (keyVec.size() != clidVec.size() or clidVec.size() != indexVec.size()) {
652 ANA_MSG_WARNING(
"In typelessFindLinks, keyVec, clidVec, indexVec must all be the same size. Instead have:"
653 << keyVec.size() <<
", " << clidVec.size() <<
", " << indexVec.size());
662 if (
found && behaviour == TrigDefs::lastFeatureOfType) {
667 #if TRIGCOMPUTILS_ENABLE_EARLY_EXIT == 1
668 if (fullyExploredFrom !=
nullptr) {
671 const Decision* seed_decisionObject = seed->node();
672 if (fullyExploredFrom->count(seed_decisionObject) == 1) {
677 found |=
typelessFindLinks(seed, linkName, keyVec, clidVec, indexVec, sourceVec, behaviour, fullyExploredFrom);
680 if (fullyExploredFrom !=
nullptr) {
681 fullyExploredFrom->insert(start_decisionObject);
688 const std::string& linkName,
689 std::vector<sgkey_t>& keyVec,
690 std::vector<uint32_t>& clidVec,
691 std::vector<Decision::index_type>& indexVec,
692 std::vector<const Decision*>& sourceVec)
695 std::vector<sgkey_t> tmpKeyVec;
696 std::vector<uint32_t> tmpClidVec;
697 std::vector<Decision::index_type> tmpIndexVec;
698 if (
start->hasObjectCollectionLinks(linkName)) {
699 found =
start->typelessGetObjectCollectionLinks(linkName, tmpKeyVec, tmpClidVec, tmpIndexVec);
701 if (
start->hasObjectLink(linkName)) {
705 found |=
start->typelessGetObjectLink(linkName, tmpKey, tmpClid, tmpIndex);
706 tmpKeyVec.push_back(tmpKey);
707 tmpClidVec.push_back(tmpClid);
708 tmpIndexVec.push_back(tmpIndex);
711 for (
size_t tmpi = 0; tmpi < tmpKeyVec.size(); ++tmpi) {
712 bool alreadyAdded =
false;
713 const uint32_t tmpKey = tmpKeyVec.at(tmpi);
714 const uint32_t tmpClid = tmpClidVec.at(tmpi);
716 for (
size_t veci = 0; veci < keyVec.size(); ++veci) {
718 and clidVec.at(veci) == tmpClid
719 and indexVec.at(veci) == tmpIndex)
726 keyVec.push_back( tmpKey );
727 clidVec.push_back( tmpClid );
728 indexVec.push_back( tmpIndex );
729 sourceVec.push_back(
start );
738 const std::string& linkName,
743 const bool suppressMultipleLinksWarning)
745 using namespace msgFindLink;
752 std::vector<sgkey_t> keyVec;
753 std::vector<uint32_t> clidVec;
754 std::vector<Decision::index_type> indexVec;
755 std::vector<const Decision*> sourceVec;
756 std::set<const xAOD::TrigComposite*> fullyExploredFrom;
758 const bool result =
typelessFindLinks(
start, linkName, keyVec, clidVec, indexVec, sourceVec, TrigDefs::lastFeatureOfType, &fullyExploredFrom);
763 if (keyVec.size() > 1 && !suppressMultipleLinksWarning) {
764 ANA_MSG_WARNING (keyVec.size() <<
" typeless links found for " << linkName
765 <<
" returning the first link, consider using findLinks.");
768 clid = clidVec.at(0);
769 index = indexVec.at(0);
776 const std::string& linkName,
781 const bool suppressMultipleLinksWarning)
783 using namespace msgFindLink;
787 std::vector<sgkey_t> keyVec;
788 std::vector<uint32_t> clidVec;
789 std::vector<Decision::index_type> indexVec;
790 std::vector<const Decision*> sourceVec;
791 std::set<const Decision*> fullyExploredFrom;
795 result |=
typelessFindLinks(finalNode, linkName, keyVec, clidVec, indexVec, sourceVec, TrigDefs::lastFeatureOfType, &fullyExploredFrom);
802 if (keyVec.size() > 1 && !suppressMultipleLinksWarning) {
803 ANA_MSG_WARNING (keyVec.size() <<
" typeless links found for " << linkName
804 <<
" returning the first link, consider using findLinks.");
807 clid = clidVec.at(0);
808 index = indexVec.at(0);
817 const std::vector<std::size_t>& legMultiplicities,
822 if (legMultiplicities.size() == 1)
825 for (std::size_t legIdx = 0; legIdx < legMultiplicities.size(); ++legIdx)
828 if (legMultiplicities[legIdx] == 0)
831 std::vector<LinkInfo<xAOD::IParticleContainer>> legFeatures;
834 legFeatures.push_back(
info);
835 combinations.addLeg(legMultiplicities.at(legIdx), std::move(legFeatures));
844 const std::vector<std::size_t>& legMultiplicities,
871 ret += printerFnc( tc );
875 ret +=
" -> " +
dump( *seedEL, printerFnc );
const std::string & summaryPrescaledNodeName()
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.
const std::string & summaryFilterNodeName()
char data[hepevt_bytes_allocation_ATLAS]
const Decision * find(const Decision *start, const std::function< bool(const Decision *)> &filter)
traverses Decision object links for another Decision object fulfilling the prerequisite specified by ...
xAOD::TrigCompositeContainer DecisionContainer
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
void recursiveGetDecisions(const Decision *start, NavGraph &navGraph, const DecisionIDContainer &ids, const bool enforceDecisionOnStartNode)
Search back in time from "node" and locate all paths back through Decision objects for a given chain.
std::string find(const std::string &s)
return a remapped string
const std::string & summaryPassExpressNodeName()
TrigCompositeUtils::DecisionID numeric() const
numeric ID
const std::string & hltSeedingNodeName()
Helper class to provide type-safe access to aux data.
bool operator()(const Decision *) const
checks if the arg Decision object has link collection of name specified at construction
Decision * newDecisionIn(DecisionContainer *dc, const std::string &name)
Helper method to create a Decision object, place it in the container and return a pointer to it.
const std::vector< NavGraphNode * > & finalNodes() const
Get all final nodes.
const std::string & hypoAlgNodeName()
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
bool hasObjectLink(const std::string &name, const CLID clid=CLID_NULL) const
Check if a link to an object with a given name and type exists. CLID_NULL to not check type.
const OBJECT * object(const std::string &name) const
Get a bare pointer with the requested name.
static const std::string s_featureString
Constant used to identify a feature.
bool typelessFindLinksCommonLinkCollection(const Decision *start, const std::string &linkName, std::vector< sgkey_t > &keyVec, std::vector< uint32_t > &clidVec, std::vector< Decision::index_type > &indexVec, std::vector< const Decision * > &sourceVec)
Common functionality shared by both typelessFindLinks interfaces Returns true if at least one link wa...
void insertDecisionIDs(const Decision *src, Decision *dest)
Appends the decision IDs of src to the dest decision object.
const std::string & comboHypoAlgNodeName()
void addNode(const Decision *node, const Decision *comingFrom=nullptr)
Add a new NavGraphNode which shadows the xAOD Decision object "node" from the full navigation graph.
const std::string & initialRecRoIString()
Helper class to provide constant type-safe access to aux data.
static const std::string s_seedString
Constant used to identify a seed (parent)
bool hasObjectCollectionLinks(const std::string &collectionName, const CLID clid=CLID_NULL) const
Check if links exist to a collection of objects with given name and type. CLID_NULL to not check type...
static const std::string s_initialRoIString
Constant used to identify an initial ROI from L1.
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.
bool const RAWDATA *ch2 const
HLT chain configuration information.
void keys(std::vector< std::string > &vkeys, bool includeAlias=false, bool onlyValid=true) const
provide list of all StoreGate keys associated with an object.
std::pair< std::string, int32_t > getNameAndIndexFromLeg(const std::string &name)
Extract the name and numeric index of a leg identifier.
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.
std::vector< std::string > intersection(std::vector< std::string > &v1, std::vector< std::string > &v2)
const std::vector< size_t > & leg_multiplicities() const
static const std::string s_hypoAlgNodeNameString
Constant used to identify a navigation graph node as being from a Hypo Alg.
bool operator()(const Decision *) const
checks if the arg TC has link of name specified at construction
static const std::string s_summaryPassNodeNameString
Constant used to identify the single terminus graph node the end point of all chains which accept the...
const Decision * getTerminusNode(SG::ReadHandle< DecisionContainer > &container)
The Athena Transient Store API.
static const std::string s_comboHypoAlgNodeNameString
Constant used to identify a navigation graph node as being from a Combo Hypo Alg.
std::vector< const Decision * > getRejectedDecisionNodes(const asg::EventStoreType *eventStore, const std::string &summaryCollectionKey, const DecisionIDContainer &ids, const std::set< std::string > &keysToIgnore)
Query all DecisionCollections in the event store, locate all Decision nodes in the graph where an obj...
const std::string & initialRoIString()
const std::vector< ElementLink< DecisionContainer > > getLinkToPrevious(const Decision *d)
returns links to previous decision object 'seed'
bool typelessFindLinks(const Decision *start, const std::string &linkName, std::vector< sgkey_t > &keyVec, std::vector< uint32_t > &clidVec, std::vector< Decision::index_type > &indexVec, std::vector< const Decision * > &sourceVec, const unsigned int behaviour, std::set< const Decision * > *fullyExploredFrom)
search back the TC links for the object of type T linked to the one of TC (recursively) Returns the l...
const Decision * getExpressTerminusNode(const DecisionContainer &container)
Returns the express-accept navigation node from a collection or nullptr if missing.
static const std::string s_filterNodeNameString
Constant used to identify a navigation graph node as being from a Filter.
Default, invalid implementation of ClassID_traits.
bool copyLinks(const Decision *src, Decision *dest)
copy all links from src to dest TC objects
static const std::string s_summaryFilterNodeNameString
Constant used to identify a navigation graph node as being from a final Filter created by the Decisio...
Structure to hold a transient Directed Acyclic Graph (DAG) structure. NavGraph is populated from,...
Class used to describe composite objects in the HLT.
uint32_t CLID
The Class ID type.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
static const std::string s_hltSeedingNodeNameString
Constant used to identify a navigation graph node as being from the HLTSeeding.
ElementLink implementation for ROOT usage.
const std::string & featureString()
bool isChainId(const HLT::Identifier &chainIdentifier)
Recognise whether the HLT identifier corresponds to a whole chain.
xAOD::TrigComposite Decision
static const std::string s_initialRecRoIString
Constant used to identify an initial HLT ROI derived from L1.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const std::string & summaryPassNodeName()
std::function< bool(const std::vector< LinkInfo< xAOD::IParticleContainer >> &)> getFilter(FilterType filter)
Get a lambda corresponding to the specified FilterType enum.
HLT::Identifier createLegName(const HLT::Identifier &chainIdentifier, size_t counter)
Generate the HLT::Identifier which corresponds to a specific leg of a given chain.
bool hasLinkToPrevious(const Decision *d)
checks if there is at least one 'seed' link to previous object
def combinations(items, n)
const std::string & filterNodeName()
const std::string & name() const
Get a human-readable name for the object.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
void linkToPrevious(Decision *d, const std::string &previousCollectionKey, size_t previousIndex)
Links to the previous object, location of previous 'seed' decision supplied by hand.
const std::string & seedString()
bool isLegId(const HLT::Identifier &legIdentifier)
Recognise whether the chain ID is a leg ID.
int32_t getIndexFromLeg(const HLT::Identifier &legIdentifier)
Extract the numeric index of a leg identifier.
std::set< DecisionID > DecisionIDContainer
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Transient utility class to represent a node in a graph (m_decisionObject), and a vector of edges (m_f...
bool allFailed(const Decision *d)
return true if there is no positive decision stored
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
std::string name() const
reports human redable name
void recursiveFlagForThinning(NavGraph &graph, const bool keepOnlyFinalFeatures, const bool removeEmptySteps, const std::vector< std::string > &nodesToDrop)
Used by trigger navigation thinning.
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.
node(node *n=0, const std::string &d="", TObject *t=0)
const std::string & roiString()
static const std::string s_viewString
Constant used to identify a view.
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.
HLT::Identifier getIDFromLeg(const HLT::Identifier &legIdentifier)
Generate the HLT::Identifier which corresponds to the chain name from the leg name.
static const std::string s_inputMakerNodeNameString
Constant used to identify a navigation graph node as being from a Input Maker.
static const std::string s_summaryPrescaledNodeNameString
Constant used to identify the single prescaled graph node.
void uniqueDecisionIDs(Decision *dest)
Make unique list of decision IDs of dest Decision object.
static const std::string s_summaryPassExpressNodeNameString
Constant used to identify the single express-accept graph node.
Set * set_intersection(Set *set1, Set *set2)
Perform an intersection of two sets.
bool isAnyIDPassing(const Decision *d, const DecisionIDContainer &required)
Checks if any of the DecisionIDs passed in arg required is availble in Decision object.
const std::string & viewString()
constexpr bool sgkeyEqual(const sgkey_t a, const sgkey_t b)
Compare two sgkeys for equality.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
Base class for elements of a container that can have aux data.
const std::string & inputMakerNodeName()
void recursiveGetDecisionsInternal(const Decision *node, const Decision *comingFrom, NavGraph &navGraph, std::set< const Decision * > &fullyExploredFrom, const DecisionIDContainer &ids, const bool enforceDecisionOnNode)
Used by recursiveGetDecisions.
static const std::string s_roiString
Constant used to identify an (explicitly) updated HLT ROI.
ElementLink< DecisionContainer > decisionToElementLink(const Decision *d, const EventContext &ctx)
Takes a raw pointer to a Decision and returns an ElementLink to the Decision.
bool typelessFindLink(const Decision *start, const std::string &linkName, sgkey_t &key, uint32_t &clid, Decision::index_type &index, const Decision *&source, const bool suppressMultipleLinksWarning)
Perform a recursive search for ElementLinks of any time and name 'linkName', starting from Decision o...