Loading [MathJax]/extensions/tex2jax.js
 |
ATLAS Offline Software
|
Go to the documentation of this file.
16 #include "GaudiKernel/ThreadLocalContext.h"
32 ISvcLocator* pSvcLocator )
33 : base_class(
name, pSvcLocator),
34 m_trigDecisionTool(
"Trig::TrigDecisionTool/TrigDecisionTool")
37 declareProperty(
"TrigDecisionTool",
m_trigDecisionTool,
"Tool handle to TDT/Navigation.");
38 declareProperty(
"ChainsRegex",
m_chainsRegex=
"",
"Keep only information related to this chains");
39 declareProperty(
"FeatureInclusionList",
m_featureInclusionList,
"This features will be kept. This setting overrules the FeatureExclusionList. Only list of types or type#key pairs are supported.");
40 declareProperty(
"FeatureExclusionList",
m_featureExclusionList,
"This features will be dropeed. It can be specified as * meaning all, or as a list of typenames, or typename#key pairs.");
41 declareProperty(
"ReportOperations",
m_report=
false,
"Additional verbosity flag, when enabled the operations on trigger elements are reported (VERBOSE logging level)");
57 std::string possibleActions;
59 possibleActions +=
a.first +
" ";
60 declareProperty(
"Actions",
m_actions,
"Operations which need to be done on the navigation"+possibleActions);
74 m_checkToolDeps =
false;
81 return StatusCode::FAILURE;
83 ATH_MSG_INFO (
"Successfully retrived the TrigDecisionTool!" );
86 ATH_MSG_FATAL (
"Could not retrive the TrigDecisionTool as it was not specified!" );
87 return StatusCode::FAILURE;
90 ATH_MSG_DEBUG (
"Leaving TrigNavigationThinningSvc::Initialize" );
93 ATH_MSG_ERROR(
"Can't use the features inclusion and exclusion lists at the same time.");
94 return StatusCode::FAILURE;
104 ATH_MSG_FATAL(
"Dropping features is demanded but neither inclusion and exclusion lists are set");
105 return StatusCode::FAILURE;
115 return StatusCode::FAILURE;
118 return StatusCode::SUCCESS;
127 return StatusCode::SUCCESS;
134 std::vector<unsigned int>
cuts;
135 std::vector<uint32_t>
temp;
140 ATH_MSG_DEBUG (
"Reloaded the navigation content in TDT (all clients will see reduced navigation content) ..." );
141 return StatusCode::SUCCESS;
146 std::vector<unsigned int>
cuts;
149 return StatusCode::SUCCESS;
159 return StatusCode::SUCCESS;
166 return StatusCode::SUCCESS;
181 return StatusCode::SUCCESS;
190 std::set<std::pair<CLID, uint16_t> > toDelete;
191 std::set<std::pair<CLID, uint16_t> > toRetain;
196 if ( holders.empty() ) {
197 ATH_MSG_ERROR(
"The navigation does not contain any features. This is likely a configuration problem.");
198 return StatusCode::FAILURE;
201 for(
auto h : holders ) {
212 toRetain.insert(std::make_pair(
h->typeClid(),
h->subTypeIndex() ));
213 ATH_MSG_DEBUG(
"will be keeping references associated to: " <<
h->collectionName()<<
"#"<<
h->key() <<
" clid: " <<
h->typeClid() );
220 toDelete.insert(std::make_pair(
h->typeClid(),
h->subTypeIndex() ));
221 ATH_MSG_DEBUG(
"will be dropping references associated to: " <<
h->collectionName()<<
"#"<<
h->key() );
227 if ( not toRetain.empty() )
229 if ( not toDelete.empty() )
237 return StatusCode::SUCCESS;
246 return StatusCode::SUCCESS;
252 and te->getRelated(TriggerElement::seedsRelation).empty() )
255 return StatusCode::SUCCESS;
260 if ( te->getFeatureAccessHelpers().empty() )
263 return StatusCode::SUCCESS;
269 return StatusCode::SUCCESS;
281 return StatusCode::SUCCESS;
288 std::vector<uint32_t>& slimmed_and_serialized)
const {
290 ATH_MSG_DEBUG(
name() <<
" is obtaining the TrigNavigationThinningSvc lock in slot " << ctx.slot() <<
" for event " << ctx.eventID().event_number() );
299 ATH_MSG_WARNING (
"Could not get navigation from Trigger Decision Tool" );
302 return StatusCode::SUCCESS;
305 State state (ctx, *cnav, slimmed_and_serialized);
309 std::vector<uint32_t>
cuts;
317 auto function = ifunc->second;
318 CHECK( (this->*
function)(state) );
322 return StatusCode::SUCCESS;
328 return StatusCode::SUCCESS;
339 ATH_MSG_DEBUG(
"Will keep information related to this chains" << chainGroup->getListOfTriggers());
340 auto confTEs = chainGroup->getHLTTriggerElements();
341 for (
auto&
vec: confTEs) {
342 for (
auto confTEPtr:
vec) {
346 return StatusCode::SUCCESS;
351 bool propagateFeatures)
const {
354 return StatusCode::SUCCESS;
363 if ( propagateFeatures )
370 const std::vector<TriggerElement*>& sameRoI = te->
getRelated(TriggerElement::sameRoIRelation);
372 for(
auto nodeInRoI : sameRoI ) {
375 std::vector<TriggerElement*>& relations = nodeInRoI->m_relations[ TriggerElement::sameRoIRelation ];
382 std::vector<TriggerElement*> seededBy = te->
m_relations[TriggerElement::seededByRelation];
384 for(
auto seededByNode: seededBy ) {
387 std::vector<TriggerElement*>& relations = seededByNode->m_relations[ TriggerElement::seedsRelation ];
394 seededByNode->relate( te->
m_relations[ TriggerElement::seedsRelation ], TriggerElement::seedsRelation );
400 std::vector<TriggerElement*>& seeds = te->
m_relations[TriggerElement::seedsRelation];
402 for(
auto seedsNode: seeds ) {
405 std::vector<TriggerElement*>& relations = seedsNode->m_relations[ TriggerElement::seededByRelation ];
410 seedsNode->relate( te->
m_relations[ TriggerElement::seededByRelation ], TriggerElement::seededByRelation );
413 return StatusCode::SUCCESS;
422 const std::set<std::pair<CLID, uint16_t> >& toDelete)
const {
435 ATH_MSG_DEBUG(
"Will remove " << toDelete.size()<<
" feature type/key");
438 for (
auto& fea: te->getFeatureAccessHelpers() ) {
439 if ( toDelete.find( std::make_pair(fea.getCLID(), fea.getIndex().subTypeIndex()) ) != toDelete.end() )
449 return StatusCode::SUCCESS;
454 const std::set<std::pair<CLID, uint16_t> >& toRetain)
const {
455 ATH_MSG_DEBUG(
"Will retain " << toRetain.size()<<
" feature type/key");
458 for (
auto& fea: te->getFeatureAccessHelpers() ) {
459 if ( toRetain.find( std::make_pair(fea.getCLID(), fea.getIndex().subTypeIndex()) ) == toRetain.end() )
463 return StatusCode::SUCCESS;
473 size_t featuresCount = std::count_if(te->getFeatureAccessHelpers().begin(),
474 te->getFeatureAccessHelpers().end(),
477 if( featuresCount == 0 ) {
481 return StatusCode::SUCCESS;
492 return StatusCode::SUCCESS;
495 v.erase(newend,
v.end());
497 return StatusCode::SUCCESS;
502 std::vector<std::string> *inclusionList, std::vector<std::string> *exclusionList) {
505 if(inclusionList && inclusionList->size() > 0) {
508 int onExclusionList = 0;
509 for(std::vector< TriggerElement::FeatureAccessHelper >::const_iterator
iter =
516 if(exclusionList &&
std::find(exclusionList->begin(), exclusionList->end(),
534 if(!exclusionList || exclusionList->size() == 0)
537 for(std::vector< TriggerElement::FeatureAccessHelper >::const_iterator
iter =
552 std::vector<TriggerElement*> *inclusionList,
553 std::vector<TriggerElement*> *exclusionList) {
566 if(inclusionList && inclusionList->size() > 0) {
569 if(std::find_if(inclusionList->begin(), inclusionList->end(),
573 if(exclusionList && std::find_if(exclusionList->begin(), exclusionList->end(),
583 if(!exclusionList || exclusionList->size() == 0)
587 if(std::find_if(exclusionList->begin(), exclusionList->end(),
601 return StatusCode::SUCCESS;
603 const std::vector<TriggerElement::FeatureAccessHelper>& features = te->getFeatureAccessHelpers() ;
605 const std::vector<TriggerElement*>
children = te->getRelated(TriggerElement::seedsRelation);
610 for(
auto& fea: features ) {
614 std::stringstream
ss;
618 ch->getFeatureAccessHelpers().insert(
ch->getFeatureAccessHelpers().begin(), fea );
622 return StatusCode::SUCCESS;
637 while( mother->
getRelated(TriggerElement::seededByRelation).size() > 0 ) {
639 mother = m_RoI->
getRelated(TriggerElement::seededByRelation)[0];
654 if(te->
getId() != m_id)
664 while( mother->
getRelated(TriggerElement::seededByRelation).size() > 0 ) {
666 mother = RoI->
getRelated(TriggerElement::seededByRelation)[0];
672 const std::vector< TriggerElement::FeatureAccessHelper > firstFeatures = m_RoI->getFeatureAccessHelpers();
673 const std::vector< TriggerElement::FeatureAccessHelper > secondFeatures = m_RoI->getFeatureAccessHelpers();
675 if(firstFeatures.size() != secondFeatures.size())
678 for(
unsigned int i = 0;
i < firstFeatures.size();
i++) {
704 struct IndexRecalculator {
709 size_t getNewIndex(
size_t oldIndex) {
710 if ( oldIndex >= m_indices.size() ) {
713 return m_indices[oldIndex];
716 void expand(
size_t maxIndex ) {
717 const size_t checkedSoFar = m_validIndices.size();
718 m_indices.resize(maxIndex+1, RemovedIdx);
719 m_validIndices.resize(maxIndex+1);
721 for (
size_t toScan = checkedSoFar; toScan <= maxIndex; ++ toScan ) {
722 size_t newIndex = m_dec->index(toScan);
723 m_validIndices[toScan] = newIndex;
726 for (
size_t toScan = checkedSoFar; toScan <= maxIndex; ++toScan ) {
727 m_indices[toScan] = std::count_if(m_validIndices.begin(), m_validIndices.begin()+toScan,
728 [](
const size_t x){ return x != RemovedIdx; } );
733 std::vector<size_t> m_indices = {0};
734 std::vector<size_t> m_validIndices;
740 const EventContext& ctx = Gaudi::Hive::currentContext();
746 if ( holders.empty() ) {
747 ATH_MSG_ERROR(
"The navigation does not contain any features. This is likely a configuration problem.");
748 return StatusCode::FAILURE;
751 for(
auto holder : holders) {
753 if ( not ipd->
proxy(holder->containerClid(), holder->label() ) ) {
754 ATH_MSG_DEBUG(
"Skipping feature missing in the store: " << holder->label());
757 holder->syncWithSG();
761 ATH_MSG_DEBUG (
"Thinning occured for this container" << *holder <<
", going to ajust the indices" );
770 IndexRecalculator recalculator( dec );
773 for (
auto& fea: te->getFeatureAccessHelpers() ) {
774 if ( fea.getCLID() == holder->typeClid()
775 and fea.getIndex().subTypeIndex() == holder->subTypeIndex() ) {
782 idx.updateBeginAndEnd(newBegin, newEnd);
794 return StatusCode::SUCCESS;
JetConstituentVector::iterator iterator
Helper class for conversion from/to int stored in TE and pair of ints used in Navigation Object point...
std::vector< std::string > m_actions
std::set< HLT::te_id_type > tesToProtect
StatusCode lateFillConfiguration(State &state) const
configures at the first event
virtual SG::DataProxy * proxy(const CLID &id, const std::string &key) const =0
Get proxy with given id and key.
virtual StatusCode doSlimming(const EventContext &, std::vector< uint32_t > &slimmed_and_serialized) const override
std::string find(const std::string &s)
return a remapped string
StatusCode reload(State &state) const
Reload the slimmed navigation in TDT so that all clients of current job see the chage.
static bool isRoINode(const TriggerElement *te)
queries if node is an RoI type one
StatusCode dropFeatureless(State &state) const
Removes TEs which have no features (combine wiht squeeze)
Hold thinning decisions for one container.
virtual StatusCode finalize() override
std::recursive_mutex & getMutex()
StatusCode retainFeatures(State &state, const std::set< std::pair< CLID, uint16_t > > &toRetain) const
This is a helper function for removeFeatures(HLT::NavigationCore*, ...).
bool deserialize(const std::vector< uint32_t > &input)
std::vector< uint32_t > originalNavigation
te_id_type getId() const
reset internals.
class_id_type getCLID() const
Class ID of object.
static bool isTerminalNode(const TriggerElement *te)
queries if node is terminal (no more TriggerElement are seeded by it)
std::vector< size_t > vec
Hold thinning decisions for one container.
#define ATH_MSG_VERBOSE(x)
std::mutex TrigNavigationThinningSvcMutex::s_mutex ATLAS_THREAD_SAFE
StatusCode save(State &state) const
Save the result of the slimming in the doSlimming argument (vector<uint32_t>)
bool toBeIncluded(State &state, HLT::TriggerElement *te, std::vector< std::string > *inclusionList, std::vector< std::string > *exclusionList)
Returns true if the TriggerElement should be included in the navigation tree and false if it should n...
virtual void reset(bool inFinalize=false)
resets all the navigation, goes to the factory and asks to withdraw all produced objects
void setTransient(bool t=true)
std::string m_chainsRegex
TriggerElementFind(const HLT::TriggerElement *te)
virtual void prepare()
prepapres the navigation for next event
const std::vector< TriggerElement * > & getRelated(Relation rel) const
returns reference to the likns to other TriggerElements related by relation r
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
The NavigationCore class, adds on top of the TrigNavStructure the EDM read-only handling.
sub_index_type subTypeIndex() const
to get collection index
index_type objectsBegin() const
to get object number in th ecollection
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
StatusCode print(State &state) const
HLT::NavigationCore & navigation
static std::mutex s_mutex
StatusCode removeFeatures(State &state, const std::set< std::pair< CLID, uint16_t > > &doDelete) const
This is a helper function for removeFeatures(HLT::NavigationCore*, ...).
::StatusCode StatusCode
StatusCode definition for legacy code.
TriggerElement is the basic ingreedient of the interface between HLT algorithms and the navigation It...
std::vector< uint32_t > & destinationNavigation
Helpers to retrieve the current thinning cache from the event context.
StatusCode removeTriggerElement(State &state, HLT::TriggerElement *te, bool propagateFeatures=true) const
Removes the passed trigger element from the navigation structure by removing all references to it in ...
Used to compare pointers of TriggerElements.
TrigHolderStructure & getHolderStorage()
#define CHECK(...)
Evaluate an expression and check for errors.
static const std::size_t RemovedIdx
Flag used to show that an index has been thinned away.
StatusCode dropRoIs(State &state) const
Removes RoI nodes, rather aggressive option, should be use as one of last actions as it makes impossi...
StatusCode syncThinning(State &state) const
reset indexes in the after the thinning
std::map< Relation, std::vector< TriggerElement * > > m_relations
relations holder (features outside)
StatusCode dropFeatures(State &state) const
Removes references to features from the navigation structure.
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
StatusCode squeeze(State &state) const
Remove intermediate TEs leaving very flat structure with event node, rois and terminals.
bool m_report
TE operations verbosity flag.
const SG::ThinningDecisionBase * getThinningDecision(const EventContext &ctx, const std::string &key)
Retrieve the current thinning decision for key.
bool operator()(const HLT::TriggerElement *te)
Helper function to get a label for a feature.
StatusCode removeFeaturelessTriggerElements(State &state, HLT::TriggerElement *te=0)
Removes all trigger elements with no features from the navigation structure.
virtual bool serialize(std::vector< uint32_t > &output) const
method serizlizes the navigation structure The structure is serrizlized in following order ....
StatusCode restore(State &state) const
Restore the original navigation structure.
std::vector< TriggerElement * > & getAllTEs()
access needed by slimming tools.
std::set< std::string > m_featureKeepSet
computed from above
static bool isInitialNode(const TriggerElement *te)
queries if node is an initial one
index_type objectsEnd() const
to get object number in th ecollection
const ObjectIndex & getIndex() const
index in the external ojects array
StatusCode propagateFeaturesToChildren(const HLT::TriggerElement *te) const
Propagates the features on given TE to its children.
the FeatureAccessHelper is a class used to keep track of features attached to this TE.
#define ATH_MSG_WARNING(x)
StatusCode drop(State &state) const
clear the result of the slimming in the doSliming argument (vector<uint32_t>) Makes no sense to combi...
TrigNavigationThinningSvc(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode dropEmptyRoIs(State &state) const
Removes RoI nodes, which do not seed anything.
StatusCode removeTriggerElementFromVector(HLT::TriggerElement *te, std::vector< HLT::TriggerElement * > &v) const
Removes all instances of the supplied TriggerElement from the supplied vector.
const std::vector< FeatureAccessHelper > & getFeatureAccessHelpers() const
returns all features which ara attached to this TE
std::vector< std::string > m_featureExclusionList
std::vector< HolderType * > getAllHolders() const
ToolHandle< Trig::TrigDecisionTool > m_trigDecisionTool
Define macros for attributes used to control the static checker.
virtual StatusCode initialize() override
std::vector< std::string > m_featureInclusionList
std::map< std::string, Action > m_actionsMap
StatusCode dropChains(State &state) const
remove info not related to the specified chains
std::set< std::string > m_featureDropSet
computed from above