ATLAS Offline Software
Loading...
Searching...
No Matches
TrigNavigationThinningSvc Class Reference

The TrigNavigationThinningSvc is an athena tool used to slim the trigger Navigation structure in various ways. More...

#include <TrigNavigationThinningSvc.h>

Inheritance diagram for TrigNavigationThinningSvc:
Collaboration diagram for TrigNavigationThinningSvc:

Classes

struct  State
class  TriggerElementFind
 Used to compare pointers of TriggerElements. More...

Public Member Functions

 TrigNavigationThinningSvc (const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize () override
virtual StatusCode finalize () override
virtual StatusCode doSlimming (const EventContext &, std::vector< uint32_t > &slimmed_and_serialized) const override

Private Types

typedef StatusCode(TrigNavigationThinningSvc::* Action) (State &state) const

Private Member Functions

StatusCode lateFillConfiguration (State &state) const
 configures at the first event
StatusCode drop (State &state) const
 clear the result of the slimming in the doSliming argument (vector<uint32_t>) Makes no sense to combine with other options
StatusCode reload (State &state) const
 Reload the slimmed navigation in TDT so that all clients of current job see the chage.
StatusCode restore (State &state) const
 Restore the original navigation structure.
StatusCode save (State &state) const
 Save the result of the slimming in the doSlimming argument (vector<uint32_t>)
StatusCode print (State &state) const
StatusCode squeeze (State &state) const
 Remove intermediate TEs leaving very flat structure with event node, rois and terminals.
StatusCode dropFeatures (State &state) const
 Removes references to features from the navigation structure.
StatusCode dropRoIs (State &state) const
 Removes RoI nodes, rather aggressive option, should be use as one of last actions as it makes impossible to traverse the tree.
StatusCode dropEmptyRoIs (State &state) const
 Removes RoI nodes, which do not seed anything.
StatusCode dropFeatureless (State &state) const
 Removes TEs which have no features (combine wiht squeeze)
StatusCode dropInactive ()
 Removes TEs which are inactive (rejected by hypothesis)
StatusCode syncThinning (State &state) const
 reset indexes in the after the thinning
StatusCode dropChains (State &state) const
 remove info not related to the specified chains
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 seeded and seeding TEs,.
StatusCode removeGhostTriggerElements (HLT::TriggerElement *te=0)
 Removes all trigger elements with the flag ghost set to true from the navigation structure.
StatusCode removeFeaturelessTriggerElements (State &state, HLT::TriggerElement *te=0)
 Removes all trigger elements with no features from the navigation structure.
StatusCode recursivelyRemoveNodesFromNavigation (HLT::TriggerElement *te)
 Removes the passed te and all children from the navigation structure.
StatusCode removeFeatures (State &state, const std::set< std::pair< CLID, uint16_t > > &doDelete) const
 This is a helper function for removeFeatures(HLT::NavigationCore*, ...).
StatusCode retainFeatures (State &state, const std::set< std::pair< CLID, uint16_t > > &toRetain) const
 This is a helper function for removeFeatures(HLT::NavigationCore*, ...).
StatusCode removeTriggerElementFromVector (HLT::TriggerElement *te, std::vector< HLT::TriggerElement * > &v) const
 Removes all instances of the supplied TriggerElement from the supplied vector.
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 not be.
bool toBeIncluded (State &state, HLT::TriggerElement *te, std::vector< HLT::TriggerElement * > *inclusionList, std::vector< HLT::TriggerElement * > *exclusionList)
StatusCode propagateFeaturesToChildren (const HLT::TriggerElement *te) const
 Propagates the features on given TE to its children.

Private Attributes

ToolHandle< Trig::TrigDecisionToolm_trigDecisionTool
std::vector< std::string > m_featureInclusionList
std::vector< std::string > m_featureExclusionList
std::set< std::string > m_featureKeepSet
 computed from above
std::set< std::string > m_featureDropSet
 computed from above
std::vector< std::string > m_actions
std::map< std::string, Actionm_actionsMap
std::string m_chainsRegex
bool m_report
 TE operations verbosity flag.

Detailed Description

The TrigNavigationThinningSvc is an athena tool used to slim the trigger Navigation structure in various ways.

Author
Ben Smith bcsmi.nosp@m.th@f.nosp@m.as.ha.nosp@m.rvar.nosp@m.d.edu - Harvard University major rework Tomasz Bold

This tool allows users to slim the trigger Navigation structure, which is important when creating derived datasets, as the structure can grow very large (> 30k per event).

There are three main slimming operations that are implemented via this tool:

(a) TriggerElement squeezing: this removes all intermediate trigger elements (those which are not the initial node, an RoI node, or a terminal node)

(b) Feature Removal: this removes all links to the specified features from the trigger elements in the structure. Note that it does not remove the holder from the navigation structure.

(c) Remove the TEs related to certain chains

(d) Complete removal

and few other actions

All operations on the navigation are configured via the Actions property which specifies set of operations (and the order) with which they are executed in the slimming process. The main method to execute is doSlimming - the vector given as an argument is filled whti serialized and slimmed content of the navigation. !!! go back !!! we need to remove holders from slimmed navigation as they are becoming now the biggest

Definition at line 53 of file TrigNavigationThinningSvc.h.

Member Typedef Documentation

◆ Action

typedef StatusCode(TrigNavigationThinningSvc::* TrigNavigationThinningSvc::Action) (State &state) const
private

Definition at line 90 of file TrigNavigationThinningSvc.h.

Constructor & Destructor Documentation

◆ TrigNavigationThinningSvc()

TrigNavigationThinningSvc::TrigNavigationThinningSvc ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 31 of file TrigNavigationThinningSvc.cxx.

33 : base_class(name, pSvcLocator),
34 m_trigDecisionTool("Trig::TrigDecisionTool/TrigDecisionTool")
35{
36 // job option configurable properties
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)");
42
55
56
57 std::string possibleActions;
58 for ( auto a: m_actionsMap )
59 possibleActions += a.first +" ";
60 declareProperty("Actions", m_actions, "Operations which need to be done on the navigation"+possibleActions);
61}
static Double_t a
std::vector< std::string > m_actions
StatusCode syncThinning(State &state) const
reset indexes in the after the thinning
StatusCode save(State &state) const
Save the result of the slimming in the doSlimming argument (vector<uint32_t>)
StatusCode drop(State &state) const
clear the result of the slimming in the doSliming argument (vector<uint32_t>) Makes no sense to combi...
std::map< std::string, Action > m_actionsMap
StatusCode dropRoIs(State &state) const
Removes RoI nodes, rather aggressive option, should be use as one of last actions as it makes impossi...
StatusCode dropChains(State &state) const
remove info not related to the specified chains
std::vector< std::string > m_featureInclusionList
StatusCode dropFeatures(State &state) const
Removes references to features from the navigation structure.
StatusCode reload(State &state) const
Reload the slimmed navigation in TDT so that all clients of current job see the chage.
StatusCode squeeze(State &state) const
Remove intermediate TEs leaving very flat structure with event node, rois and terminals.
StatusCode dropFeatureless(State &state) const
Removes TEs which have no features (combine wiht squeeze)
StatusCode print(State &state) const
bool m_report
TE operations verbosity flag.
StatusCode dropEmptyRoIs(State &state) const
Removes RoI nodes, which do not seed anything.
std::vector< std::string > m_featureExclusionList
ToolHandle< Trig::TrigDecisionTool > m_trigDecisionTool
StatusCode restore(State &state) const
Restore the original navigation structure.

Member Function Documentation

◆ doSlimming()

StatusCode TrigNavigationThinningSvc::doSlimming ( const EventContext & ctx,
std::vector< uint32_t > & slimmed_and_serialized ) const
overridevirtual

Definition at line 287 of file TrigNavigationThinningSvc.cxx.

288 {
289
290 ATH_MSG_DEBUG(name() << " is obtaining the TrigNavigationThinningSvc lock in slot " << ctx.slot() << " for event " << ctx.eventID().event_number() );
291 std::lock_guard<std::mutex> lock(TrigNavigationThinningSvcMutex::s_mutex);
292
293 // grab the navigation
294 auto navAccess = m_trigDecisionTool->ExperimentalAndExpertMethods();
295 // protected by above lock
296 HLT::NavigationCore *cnav ATLAS_THREAD_SAFE = const_cast<HLT::NavigationCore*>(navAccess.getNavigation());
297
298 if(cnav == 0) {
299 ATH_MSG_WARNING ( "Could not get navigation from Trigger Decision Tool" );
300 ATH_MSG_WARNING ( "Navigation will not be slimmed in this event" );
301 ATH_MSG_DEBUG(name() << " is releasing the TrigNavigationThinningSvc lock");
302 return StatusCode::SUCCESS;
303 }
304
305 State state (ctx, *cnav, slimmed_and_serialized);
307 {
308 state.originalNavigation.clear();
309 std::vector<uint32_t> cuts;
310 cnav->serialize(state.originalNavigation, cuts);
311 }
312
313 for ( auto& action: m_actions ) {
314 ATH_MSG_DEBUG("Applying action " << action << " on the navigation ");
315 auto ifunc = m_actionsMap.find (action);
316 if (ifunc != m_actionsMap.end()) {
317 auto function = ifunc->second;
318 CHECK( (this->*function)(state) );
319 }
320 }
321 ATH_MSG_DEBUG(name() << " is releasing the TrigNavigationThinningSvc lock");
322 return StatusCode::SUCCESS;
323}
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
#define ATLAS_THREAD_SAFE
StatusCode lateFillConfiguration(State &state) const
configures at the first event

◆ drop()

StatusCode TrigNavigationThinningSvc::drop ( State & state) const
private

clear the result of the slimming in the doSliming argument (vector<uint32_t>) Makes no sense to combine with other options

Definition at line 123 of file TrigNavigationThinningSvc.cxx.

124{
125 state.destinationNavigation.clear();
126 ATH_MSG_DEBUG ( "Navigation dropped entirely" );
127 return StatusCode::SUCCESS;
128}

◆ dropChains()

StatusCode TrigNavigationThinningSvc::dropChains ( State & state) const
private

remove info not related to the specified chains

Definition at line 267 of file TrigNavigationThinningSvc.cxx.

267 {
268 if ( m_chainsRegex.empty() ) {
269 return StatusCode::SUCCESS;
270 }
271 // now run over the tree and drop alle TEs except RoIs and intial which are not in the TEs to protect
272 for ( auto te: state.navigation.getAllTEs() ) {
273 if ( state.navigation.isInitialNode(te)
274 or state.navigation.isRoINode(te) ) {
275 continue;
276 }
277 if ( state.tesToProtect.find(te->getId()) == state.tesToProtect.end() ) {
278 CHECK( removeTriggerElement(state, te));
279 }
280 }
281 return StatusCode::SUCCESS;
282}
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 ...

◆ dropEmptyRoIs()

StatusCode TrigNavigationThinningSvc::dropEmptyRoIs ( State & state) const
private

Removes RoI nodes, which do not seed anything.

Definition at line 249 of file TrigNavigationThinningSvc.cxx.

249 {
250 for ( auto te: state.navigation.getAllTEs() ) {
251 if ( state.navigation.isRoINode(te)
252 and te->getRelated(TriggerElement::seedsRelation).empty() )
253 CHECK( removeTriggerElement(state, te) );
254 }
255 return StatusCode::SUCCESS;
256}

◆ dropFeatureless()

StatusCode TrigNavigationThinningSvc::dropFeatureless ( State & state) const
private

Removes TEs which have no features (combine wiht squeeze)

Definition at line 258 of file TrigNavigationThinningSvc.cxx.

258 {
259 for ( auto te: state.navigation.getAllTEs() ) {
260 if ( te->getFeatureAccessHelpers().empty() )
261 CHECK( removeTriggerElement(state, te) );
262 }
263 return StatusCode::SUCCESS;
264}

◆ dropFeatures()

StatusCode TrigNavigationThinningSvc::dropFeatures ( State & state) const
private

Removes references to features from the navigation structure.

Features are specified via the inclusion and exclusion lists. If the inclusion list is specified, only elements on that list are included (the exclusion list is ignored). If the inclusion list is NULL or empty, then all elements except those on the exclusion list are included.

Definition at line 185 of file TrigNavigationThinningSvc.cxx.

186{
187 // turn the inclusion and exclusion lists into set of pairs <CLID, SubTypeIndex> of this collections which needs to be dropped
188 // in fact this a bit waste of time that we reclaulate this each time, but, one can imagine slimming events from different runs/configurations
189 // but then we sould have to check some configuration in data (i.e. SMK in the HLTResult, and recompute m_deletedFeatures only if it changes)
190 std::set<std::pair<CLID, uint16_t> > toDelete;
191 std::set<std::pair<CLID, uint16_t> > toRetain;
192
193 std::lock_guard<std::recursive_mutex> lock(state.navigation.getMutex());
194
195 const auto& holders = state.navigation.getHolderStorage().getAllHolders<HLTNavDetails::IHolder>();
196 if ( holders.empty() ) { // to prevent issues as in ATR-25282
197 ATH_MSG_ERROR("The navigation does not contain any features. This is likely a configuration problem.");
198 return StatusCode::FAILURE;
199 }
200
201 for( auto h : holders ) {
202 if(!h) { // check if h is null
203 ATH_MSG_WARNING("holder.second is null pointer; skipping...");
204 continue;
205 }
206 //ATH_MSG_VERBOSE("Checking what to do with "
207 // << h->collectionName()+"#"+h->key());
208 // check if this needs to be kept
209 if ( not m_featureKeepSet.empty() ) {
210 if ( m_featureKeepSet.count(h->collectionName())
211 || m_featureKeepSet.count(h->key()) ) {
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() );
214 }
215 }
216 // check if this needs to be dropped
217 if ( not m_featureDropSet.empty() ) {
218 if ( m_featureDropSet.count(h->collectionName())
219 || m_featureDropSet.count(h->key()) ) {
220 toDelete.insert(std::make_pair(h->typeClid(), h->subTypeIndex() ));
221 ATH_MSG_DEBUG("will be dropping references associated to: " << h->collectionName()<<"#"<<h->key() );
222 }
223 }
224 }
225
226
227 if ( not toRetain.empty() )
228 return retainFeatures(state, toRetain);
229 if ( not toDelete.empty() )
230 return removeFeatures(state, toDelete);
231
232 // now that we've removed them from the tree, we need to remove them from
233 // the navigation structure as well. We do this by finding the holders that
234 // match the deleted labels and removing them.
235 // to be implemented !!!
236
237 return StatusCode::SUCCESS;
238}
#define ATH_MSG_ERROR(x)
StatusCode removeFeatures(State &state, const std::set< std::pair< CLID, uint16_t > > &doDelete) const
This is a helper function for removeFeatures(HLT::NavigationCore*, ...).
StatusCode retainFeatures(State &state, const std::set< std::pair< CLID, uint16_t > > &toRetain) const
This is a helper function for removeFeatures(HLT::NavigationCore*, ...).
std::set< std::string > m_featureKeepSet
computed from above
std::set< std::string > m_featureDropSet
computed from above

◆ dropInactive()

StatusCode TrigNavigationThinningSvc::dropInactive ( )
private

Removes TEs which are inactive (rejected by hypothesis)

◆ dropRoIs()

StatusCode TrigNavigationThinningSvc::dropRoIs ( State & state) const
private

Removes RoI nodes, rather aggressive option, should be use as one of last actions as it makes impossible to traverse the tree.

Nonetheless the tree can be to some extent usable in the analysis i.e. when no TEs traversing is really needed

Definition at line 241 of file TrigNavigationThinningSvc.cxx.

241 {
242 for ( auto te: state.navigation.getAllTEs() ) {
243 if ( state.navigation.isRoINode(te) )
244 CHECK( removeTriggerElement(state, te) );
245 }
246 return StatusCode::SUCCESS;
247}

◆ finalize()

StatusCode TrigNavigationThinningSvc::finalize ( )
overridevirtual

Definition at line 327 of file TrigNavigationThinningSvc.cxx.

327 {
328 return StatusCode::SUCCESS;
329}

◆ initialize()

StatusCode TrigNavigationThinningSvc::initialize ( )
overridevirtual

Definition at line 70 of file TrigNavigationThinningSvc.cxx.

70 {
71
72 ATH_MSG_DEBUG( "TrigNavigationThinningSvc::initialize()" << name() );
73
74 m_checkToolDeps = false;
75
76 // load the required tools
77 if( not m_trigDecisionTool.empty() ) {
78 if ( m_trigDecisionTool.retrieve().isFailure() ) {
79 ATH_MSG_FATAL ( "Unable to retrieve the TrigDecisionTool!" );
80 ATH_MSG_FATAL ( "Please check your job options file" );
81 return StatusCode::FAILURE;
82 }
83 ATH_MSG_INFO ( "Successfully retrieved the TrigDecisionTool!" );
84 }
85 else {
86 ATH_MSG_FATAL ( "Could not retrieve the TrigDecisionTool as it was not specified!" );
87 return StatusCode::FAILURE;
88 }
89
90 ATH_MSG_DEBUG ( "Leaving TrigNavigationThinningSvc::Initialize" );
91 // make sure that the inclusions/exclusions are self consistent i.e. they can not be sued at the same time
92 if ( m_featureExclusionList.size() and m_featureInclusionList.size() ) {
93 ATH_MSG_ERROR( "Can't use the features inclusion and exclusion lists at the same time.");
94 return StatusCode::FAILURE;
95 }
96
99 if ( m_featureKeepSet.size() or m_featureDropSet.size() ) {
100 ATH_MSG_DEBUG("Configured features removeal keep:" << m_featureInclusionList
101 << " drop: " << m_featureExclusionList );
102 } else {
103 if ( find(m_actions.begin(), m_actions.end(), "DropFeatures") != m_actions.end() ) {
104 ATH_MSG_FATAL("Dropping features is demanded but neither inclusion and exclusion lists are set");
105 return StatusCode::FAILURE;
106 }
107 }
108
109
110
111 // verify if all actions are possible
112 for ( auto& action: m_actions) {
113 if ( m_actionsMap.find(action) == m_actionsMap.end()) {
114 ATH_MSG_FATAL("Action not implemented (check for typo) " << action << " possible " << m_actions);
115 return StatusCode::FAILURE;
116 }
117 }
118 return StatusCode::SUCCESS;
119}
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138

◆ lateFillConfiguration()

StatusCode TrigNavigationThinningSvc::lateFillConfiguration ( State & state) const
private

configures at the first event

Definition at line 334 of file TrigNavigationThinningSvc.cxx.

334 {
335 // remember the configured chain names, as they will be useful later
336 // ??? Originally, this was done once and cached in the tool.
337 // If this takes too long, consider storing it in the detector store.
338 auto chainGroup = m_trigDecisionTool->getChainGroup(m_chainsRegex);
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) {
343 state.tesToProtect.insert(confTEPtr->id());
344 }
345 }
346 return StatusCode::SUCCESS;
347}
std::vector< size_t > vec

◆ print()

StatusCode TrigNavigationThinningSvc::print ( State & state) const
private

Definition at line 164 of file TrigNavigationThinningSvc.cxx.

164 {
165 ATH_MSG_DEBUG ( "Navigation printout \n" << state.navigation );
166 return StatusCode::SUCCESS;
167}

◆ propagateFeaturesToChildren()

StatusCode TrigNavigationThinningSvc::propagateFeaturesToChildren ( const HLT::TriggerElement * te) const
private

Propagates the features on given TE to its children.

Definition at line 598 of file TrigNavigationThinningSvc.cxx.

598 {
599
600 if ( not te )
601 return StatusCode::SUCCESS;
602
603 const std::vector<TriggerElement::FeatureAccessHelper>& features = te->getFeatureAccessHelpers() ;
604
605 const std::vector<TriggerElement*> children = te->getRelated(TriggerElement::seedsRelation);
606 for( auto ch: children ) {
607 if ( m_report ) ATH_MSG_VERBOSE("Propagating features to child: " << ch << " " << ch->getId() );
608 // add the parents features to the front of the child features list features list
609 // skip this FEAs which are anyway to be discarded
610 for( auto& fea: features ) {
611 if ( fea.forget() )
612 continue;
613 if ( m_report ){
614 std::stringstream ss;
615 ss << fea;
616 ATH_MSG_VERBOSE("Propagating feature " << ss.str() );
617 }
618 ch->getFeatureAccessHelpers().insert(ch->getFeatureAccessHelpers().begin(), fea );
619 }
620 // te->getFeatureAccessHelpers().insert((*iter)->getFeatureAccessHelpers().begin(), features.begin(), features.end());
621 }
622 return StatusCode::SUCCESS;
623}
#define ATH_MSG_VERBOSE(x)
static Double_t ss

◆ recursivelyRemoveNodesFromNavigation()

StatusCode TrigNavigationThinningSvc::recursivelyRemoveNodesFromNavigation ( HLT::TriggerElement * te)
private

Removes the passed te and all children from the navigation structure.

◆ reload()

StatusCode TrigNavigationThinningSvc::reload ( State & state) const
private

Reload the slimmed navigation in TDT so that all clients of current job see the chage.

Definition at line 131 of file TrigNavigationThinningSvc.cxx.

132{
133 state.destinationNavigation.clear();
134 std::vector<unsigned int> cuts;
135 std::vector<uint32_t> temp;
136 state.navigation.serialize(temp, cuts);
137 state.navigation.reset();
138 state.navigation.prepare();
139 state.navigation.deserialize(temp);
140 ATH_MSG_DEBUG ( "Reloaded the navigation content in TDT (all clients will see reduced navigation content) ..." );
141 return StatusCode::SUCCESS;
142}

◆ removeFeaturelessTriggerElements()

StatusCode TrigNavigationThinningSvc::removeFeaturelessTriggerElements ( State & state,
HLT::TriggerElement * te = 0 )
private

Removes all trigger elements with no features from the navigation structure.

Definition at line 468 of file TrigNavigationThinningSvc.cxx.

469 {
470 ATH_MSG_DEBUG ( "Running the adjustIndicesAfterThinning" );
471
472 for ( auto te: state.navigation.getAllTEs() ) {
473 size_t featuresCount = std::count_if(te->getFeatureAccessHelpers().begin(),
474 te->getFeatureAccessHelpers().end(),
475 [](const TriggerElement::FeatureAccessHelper& fea){ return fea.forget(); }
476 );
477 if( featuresCount == 0 ) {
478 CHECK( removeTriggerElement( state, te, false ) );
479 }
480 }
481 return StatusCode::SUCCESS;
482}
const std::vector< FeatureAccessHelper > & getFeatureAccessHelpers() const
returns all features which ara attached to this TE

◆ removeFeatures()

StatusCode TrigNavigationThinningSvc::removeFeatures ( State & state,
const std::set< std::pair< CLID, uint16_t > > & doDelete ) const
private

This is a helper function for removeFeatures(HLT::NavigationCore*, ...).

Note that that function should be instead, because it not only removes the features from the tree, but also cleans them up within the navigation structure.

Definition at line 421 of file TrigNavigationThinningSvc.cxx.

422 {
423 // we have the following problem:
424 // (a) features are stored as a vector where order can possibly matter
425 // (b) its very time consuming to delete items from the middle of a vector
426 // (c) a large fraction of elements will not have any features deleted
427 //
428 // To handle this, we're going to build an array that keeps track of
429 // whether an element needs be deleted. If none do, nothing gets changed.
430 // If some do, we build a new vector and copy it over. This prevents
431 // the big time sink from deleting elements in the middle of a vector.
432
433 // another option would be to build a new vector when using inclusion
434 // lists and remove elements when using exclusion lists
435 ATH_MSG_DEBUG("Will remove " << toDelete.size()<< " feature type/key");
436 using namespace HLT;
437 for (auto te: state.navigation.getAllTEs()) {
438 for ( auto& fea: te->getFeatureAccessHelpers() ) {
439 if ( toDelete.find( std::make_pair(fea.getCLID(), fea.getIndex().subTypeIndex()) ) != toDelete.end() )
440 fea.setForget(true); // when we mark this then the serialization of TEs will simpley skip this one, easy, no
441 }
442 }
443 // get back here
444 // get rid of the holders themselves
445 //m_navigation->m_featuresByIndex[ h->typeClid() ].erase( h->subTypeIndex() ); // Erasing an element of the map we're looping over
446 //m_navigation->m_featuresByLabel.at( h->typeClid() ).erase( h->label() ); // Use new C++11 map accessor (does bounds check)
447 // delete holder.second;
448
449 return StatusCode::SUCCESS;
450}

◆ removeGhostTriggerElements()

StatusCode TrigNavigationThinningSvc::removeGhostTriggerElements ( HLT::TriggerElement * te = 0)
private

Removes all trigger elements with the flag ghost set to true from the navigation structure.

◆ removeTriggerElement()

StatusCode TrigNavigationThinningSvc::removeTriggerElement ( State & state,
HLT::TriggerElement * te,
bool propagateFeatures = true ) const
private

Removes the passed trigger element from the navigation structure by removing all references to it in seeded and seeding TEs,.

Parameters
propagateFeaturesdecides if features need to be moved to children TEs

Definition at line 349 of file TrigNavigationThinningSvc.cxx.

351 {
352 // refuse to remove the initial node
353 if(state.navigation.isInitialNode(te)) {
354 return StatusCode::SUCCESS;
355 }
356 if ( m_report ) ATH_MSG_VERBOSE("Removing TE of ID: " << te->getId() );
357
358 // mark the element as transient to prevent it from being serialized
359 te->setTransient();
360
361
362 // propagate the features to its children
363 if ( propagateFeatures )
365
366
367
368 if ( m_report ) ATH_MSG_VERBOSE("Removeing TE of ID: " << te->getId() << " removing same RoI relations" );
369 // for those in the same RoI, we need only remove the relationship from ones who are related
370 const std::vector<TriggerElement*>& sameRoI = te->getRelated(TriggerElement::sameRoIRelation);
371
372 for( auto nodeInRoI : sameRoI ) {
373 if ( m_report ) ATH_MSG_VERBOSE("Removeing TE of ID: " << te->getId() << " bypassing same RoI relation " );
374 // get the relations, and remove the ones that point to te
375 std::vector<TriggerElement*>& relations = nodeInRoI->m_relations[ TriggerElement::sameRoIRelation ];
376 CHECK( removeTriggerElementFromVector (te, relations) );
377 }
378
379 // for those who te is seededBy, we need to remove the seeds relation, and propagate it down
380 // (if te is not terminal)
381
382 std::vector<TriggerElement*> seededBy = te->m_relations[TriggerElement::seededByRelation];
383
384 for(auto seededByNode: seededBy ) {
385
386 // get the relations and remove the ones that point to te
387 std::vector<TriggerElement*>& relations = seededByNode->m_relations[ TriggerElement::seedsRelation ];
388 CHECK( removeTriggerElementFromVector (te, relations) );
389
390
391
392 // now add all the nodes te seeds onto the node we just removed the seeds relation from
393 if(!state.navigation.isTerminalNode(te))
395 }
396
397 // for those who te seeds, we need to remove the seededBy relation, and propagate it up
398 // (if te is not the inital node - hey, you never know!)
399
400 std::vector<TriggerElement*>& seeds = te->m_relations[TriggerElement::seedsRelation];
401
402 for( auto seedsNode: seeds ) {
403
404 // get the relations and remove the ones that point to te
405 std::vector<TriggerElement*>& relations = seedsNode->m_relations[ TriggerElement::seededByRelation ];
406 CHECK ( removeTriggerElementFromVector(te, relations) );
407
408 // now add all the nodes te seeds onto the node we just removed the seeds relation from
409 if(!state.navigation.isInitialNode(te))
411 }
412
413 return StatusCode::SUCCESS;
414}
@ sameRoIRelation
equilateral relation of all TEs rooted in one RoI
const std::vector< TriggerElement * > & getRelated(Relation rel) const
returns reference to the likns to other TriggerElements related by relation r
std::map< Relation, std::vector< TriggerElement * > > m_relations
relations holder (features outside)
StatusCode removeTriggerElementFromVector(HLT::TriggerElement *te, std::vector< HLT::TriggerElement * > &v) const
Removes all instances of the supplied TriggerElement from the supplied vector.
StatusCode propagateFeaturesToChildren(const HLT::TriggerElement *te) const
Propagates the features on given TE to its children.

◆ removeTriggerElementFromVector()

StatusCode TrigNavigationThinningSvc::removeTriggerElementFromVector ( HLT::TriggerElement * te,
std::vector< HLT::TriggerElement * > & v ) const
private

Removes all instances of the supplied TriggerElement from the supplied vector.

Returns the number of elements removed.

Definition at line 489 of file TrigNavigationThinningSvc.cxx.

489 {
490
491 if( v.empty())
492 return StatusCode::SUCCESS;
493
494 std::vector<TriggerElement*>::iterator newend = std::remove( v.begin(), v.end(), te);
495 v.erase(newend, v.end());
496
497 return StatusCode::SUCCESS;
498}
DataModel_detail::iterator< DVL > remove(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, const T &value)
Specialization of remove for DataVector/List.

◆ restore()

StatusCode TrigNavigationThinningSvc::restore ( State & state) const
private

Restore the original navigation structure.

Definition at line 153 of file TrigNavigationThinningSvc.cxx.

154{
155 state.navigation.reset();
156 state.navigation.prepare();
157 state.navigation.deserialize(state.originalNavigation);
158 ATH_MSG_DEBUG ( "Restored the original navigation" );
159 return StatusCode::SUCCESS;
160}

◆ retainFeatures()

StatusCode TrigNavigationThinningSvc::retainFeatures ( State & state,
const std::set< std::pair< CLID, uint16_t > > & toRetain ) const
private

This is a helper function for removeFeatures(HLT::NavigationCore*, ...).

Either this or the above is caled depending which of the sets is smaller

Warning
this is a bit more agresive as it cleans up the navigation from transient objects

Definition at line 453 of file TrigNavigationThinningSvc.cxx.

454 {
455 ATH_MSG_DEBUG("Will retain " << toRetain.size()<< " feature type/key");
456 using namespace HLT;
457 for (auto te: state.navigation.getAllTEs()) {
458 for ( auto& fea: te->getFeatureAccessHelpers() ) {
459 if ( toRetain.find( std::make_pair(fea.getCLID(), fea.getIndex().subTypeIndex()) ) == toRetain.end() )
460 fea.setForget(true); // when we mark this then the serialization of TEs will simpley skip this one, easy, no
461 }
462 }
463 return StatusCode::SUCCESS;
464
465}

◆ save()

StatusCode TrigNavigationThinningSvc::save ( State & state) const
private

Save the result of the slimming in the doSlimming argument (vector<uint32_t>)

Definition at line 145 of file TrigNavigationThinningSvc.cxx.

145 {
146 std::vector<unsigned int> cuts;
147 state.navigation.serialize(state.destinationNavigation, cuts);
148 ATH_MSG_DEBUG ( "Saved the slimmed navigation" );
149 return StatusCode::SUCCESS;
150}

◆ squeeze()

StatusCode TrigNavigationThinningSvc::squeeze ( State & state) const
private

Remove intermediate TEs leaving very flat structure with event node, rois and terminals.

Definition at line 169 of file TrigNavigationThinningSvc.cxx.

169 {
170 for ( auto te: state.navigation.getAllTEs() ) {
171 if ( state.navigation.isInitialNode(te)
172 or state.navigation.isRoINode(te)
173 or state.navigation.isTerminalNode(te)
174 or state.tesToProtect.find(te->getId()) != state.tesToProtect.end())
175 continue;
176 // if ( te->getId() == 4032407525 ) m_report = true;
177 CHECK( removeTriggerElement(state, te) );
178 // m_report = false;
179 }
180
181 return StatusCode::SUCCESS;
182}

◆ syncThinning()

StatusCode TrigNavigationThinningSvc::syncThinning ( State & state) const
private

reset indexes in the after the thinning

Definition at line 739 of file TrigNavigationThinningSvc.cxx.

739 {
740 const EventContext& ctx = Gaudi::Hive::currentContext();
741 ATH_MSG_DEBUG ( "Running the syncThinning" );
742
743 std::lock_guard<std::recursive_mutex> lock(state.navigation.getMutex());
744
745 const auto& holders = state.navigation.getHolderStorage().getAllHolders<HLTNavDetails::IHolder>();
746 if ( holders.empty() ) { // to prevent issues as in ATR-25282
747 ATH_MSG_ERROR("The navigation does not contain any features. This is likely a configuration problem.");
748 return StatusCode::FAILURE;
749 }
750
751 for(auto holder : holders) {
752 const IProxyDict* ipd = Atlas::getExtendedEventContext(ctx).proxy();
753 if ( not ipd->proxy(holder->containerClid(), holder->label() ) ) {
754 ATH_MSG_DEBUG("Skipping feature missing in the store: " << holder->label());
755 continue;
756 }
757 holder->syncWithSG();
758 const SG::ThinningDecisionBase* dec =
759 SG::getThinningDecision (ctx, holder->label());
760 if ( dec ) {
761 ATH_MSG_DEBUG ( "Thinning occured for this container" << *holder <<", going to ajust the indices" );
762 // ThinningDecisionBase::index method returns the valid new index for unslimmed object and an invalid index ThinningDecisionBase::RemovedIndex for the ones that were removed
763 // The way to calulate new indexes for the ranges describing ROIs (X,Y) is to count the number valid indexes from X to 0 and from Y to 0
764 // This would be quite inefficient so we need to make a vector wiht new indexes
765 // this vector in the end will be of size equal to the original collection and at position X will have new values.
766 // Hoever the difficulty is that we are not able to obtain the size of the collection and we need to build this vector as we meet the indexs during
767 // the scan of TEs.
768 // Since this is quite tricky code it is outsourced to a helper class IndexRecalculator.
769
770 IndexRecalculator recalculator( dec );
771 // now we need to go over the TEs
772 for ( const auto& te: state.navigation.getAllTEs() ) {
773 for ( auto& fea: te->getFeatureAccessHelpers() ) {
774 if ( fea.getCLID() == holder->typeClid()
775 and fea.getIndex().subTypeIndex() == holder->subTypeIndex() ) {
776 uint32_t begin = fea.getIndex().objectsBegin();
777 uint32_t end = fea.getIndex().objectsEnd();
778 uint32_t newEnd = recalculator.getNewIndex(end);
779 uint32_t newBegin = recalculator.getNewIndex(begin);
780
781 HLT::TriggerElement::ObjectIndex& idx ATLAS_THREAD_SAFE = const_cast<HLT::TriggerElement::ObjectIndex&>(fea.getIndex());
782 idx.updateBeginAndEnd(newBegin, newEnd);
783 //ATH_MSG_DEBUG( "Indices changed to " << newBegin << " " << newEnd);
784
785 }
786 }
787 }
788
789 } // if thinning occures
790 else {
791 // ATH_MSG_DEBUG("Thinning did not occure on the " << * holder );
792 }
793 } // holder loop
794 return StatusCode::SUCCESS;
795}
virtual SG::DataProxy * proxy(const CLID &id, const std::string &key) const =0
Get proxy with given id and key.
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
const SG::ThinningDecisionBase * getThinningDecision(const EventContext &ctx, const std::string &key)
Retrieve the current thinning decision for key.
setEventNumber uint32_t

◆ toBeIncluded() [1/2]

bool TrigNavigationThinningSvc::toBeIncluded ( State & state,
HLT::TriggerElement * te,
std::vector< HLT::TriggerElement * > * inclusionList,
std::vector< HLT::TriggerElement * > * exclusionList )
private

Definition at line 550 of file TrigNavigationThinningSvc.cxx.

553 {
554
555 if(!te)
556 return false;
557
558 // this function never allows inital nodes or RoI nodes to be removed
559 if( state.navigation.isInitialNode(te) || state.navigation.isRoINode(te) )
560 return true;
561
562 // if the inclusion list exists, then we use that
563 // If its on the inclusion list, its kept for sure
564 // If its on the exclusion list, its only kept if
565 // its not on the inclusion list.
566 if(inclusionList && inclusionList->size() > 0) {
567
568 // check if the element is in the list
569 if(std::find_if(inclusionList->begin(), inclusionList->end(),
570 TriggerElementFind(te)) != inclusionList->end())
571 return true;
572 // now, check if its in the exclusion list
573 if(exclusionList && std::find_if(exclusionList->begin(), exclusionList->end(),
574 TriggerElementFind(te)) != exclusionList->end())
575 return false;
576 // if its on neither list, keep it
577 return true;
578 }
579
580 // if we get here, then there's no inclusionList, so we need to use the exclusion list
581
582 // check if it exists - if it doesn't, pass everything
583 if(!exclusionList || exclusionList->size() == 0)
584 return true;
585
586 // check if the te belongs to the exclusion list
587 if(std::find_if(exclusionList->begin(), exclusionList->end(),
588 TriggerElementFind(te)) != exclusionList->end()) {
589 return false;
590 }
591
592 // if we've made it here, its passed the exclusion list and so should be included
593 return true;
594
595}
Used to compare pointers of TriggerElements.

◆ toBeIncluded() [2/2]

bool TrigNavigationThinningSvc::toBeIncluded ( State & state,
HLT::TriggerElement * te,
std::vector< std::string > * inclusionList,
std::vector< std::string > * exclusionList )
private

Returns true if the TriggerElement should be included in the navigation tree and false if it should not be.

Definition at line 500 of file TrigNavigationThinningSvc.cxx.

502 {
503
504 // if the inclusion list exists, then we use that
505 if(inclusionList && inclusionList->size() > 0) {
506
507 // check if the trigger element has a feature that is included in the list
508 int onExclusionList = 0;
509 for(std::vector< TriggerElement::FeatureAccessHelper >::const_iterator iter =
510 te->getFeatureAccessHelpers().begin();
511 iter != te->getFeatureAccessHelpers().end(); ++iter) {
512 // grab the label and check if it was found in the inclusion list
513 if(std::find(inclusionList->begin(), inclusionList->end(), SlimmingHelper::getLabel(state.navigation, *iter )) != inclusionList->end())
514 return true;
515 // now find if its in the exclusion list
516 if(exclusionList && std::find(exclusionList->begin(), exclusionList->end(),
517 SlimmingHelper::getLabel( state.navigation, *iter )) != exclusionList->end())
518 onExclusionList = 1;
519 }
520
521 // if it has a feature on the exclusion list, and none on the inclusion list,
522 // it should be excluded
523 if(onExclusionList)
524 return false;
525
526 // we've gone through the feature list, and nothing was on the exclusion list,
527 // so we should keep it
528 return true;
529 }
530
531 // if we get here, then there's no inclusionList, so we need to use the exclusion list
532
533 // check if it exists - if it doesn't, pass everything
534 if(!exclusionList || exclusionList->size() == 0)
535 return true;
536
537 for(std::vector< TriggerElement::FeatureAccessHelper >::const_iterator iter =
538 te->getFeatureAccessHelpers().begin();
539 iter != te->getFeatureAccessHelpers().end(); ++iter) {
540 // grab the label and check if it was found in the exclusion list
541 if(std::find(exclusionList->begin(), exclusionList->end(), SlimmingHelper::getLabel(state.navigation, *iter )) != exclusionList->end())
542 return false;
543 }
544
545 // if we've made it here, its passed the exclusion list and so should be included
546 return true;
547
548}

Member Data Documentation

◆ m_actions

std::vector<std::string> TrigNavigationThinningSvc::m_actions
private

Definition at line 89 of file TrigNavigationThinningSvc.h.

◆ m_actionsMap

std::map<std::string, Action> TrigNavigationThinningSvc::m_actionsMap
private

Definition at line 91 of file TrigNavigationThinningSvc.h.

◆ m_chainsRegex

std::string TrigNavigationThinningSvc::m_chainsRegex
private

Definition at line 92 of file TrigNavigationThinningSvc.h.

◆ m_featureDropSet

std::set<std::string> TrigNavigationThinningSvc::m_featureDropSet
private

computed from above

Definition at line 71 of file TrigNavigationThinningSvc.h.

◆ m_featureExclusionList

std::vector<std::string> TrigNavigationThinningSvc::m_featureExclusionList
private

Definition at line 69 of file TrigNavigationThinningSvc.h.

◆ m_featureInclusionList

std::vector<std::string> TrigNavigationThinningSvc::m_featureInclusionList
private

Definition at line 68 of file TrigNavigationThinningSvc.h.

◆ m_featureKeepSet

std::set<std::string> TrigNavigationThinningSvc::m_featureKeepSet
private

computed from above

Definition at line 70 of file TrigNavigationThinningSvc.h.

◆ m_report

bool TrigNavigationThinningSvc::m_report
private

TE operations verbosity flag.

Definition at line 95 of file TrigNavigationThinningSvc.h.

◆ m_trigDecisionTool

ToolHandle<Trig::TrigDecisionTool> TrigNavigationThinningSvc::m_trigDecisionTool
private

Definition at line 66 of file TrigNavigationThinningSvc.h.


The documentation for this class was generated from the following files: