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) (const EventContext &ctx, State &state) const

Private Member Functions

StatusCode lateFillConfiguration (State &state) const
 configures at the first event
StatusCode drop (const EventContext &ctx, 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 (const EventContext &ctx, State &state) const
 Reload the slimmed navigation in TDT so that all clients of current job see the chage.
StatusCode restore (const EventContext &ctx, State &state) const
 Restore the original navigation structure.
StatusCode save (const EventContext &ctx, State &state) const
 Save the result of the slimming in the doSlimming argument (vector<uint32_t>).
StatusCode print (const EventContext &ctx, State &state) const
StatusCode squeeze (const EventContext &ctx, State &state) const
 Remove intermediate TEs leaving very flat structure with event node, rois and terminals.
StatusCode dropFeatures (const EventContext &ctx, State &state) const
 Removes references to features from the navigation structure.
StatusCode dropRoIs (const EventContext &ctx, 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 (const EventContext &ctx, State &state) const
 Removes RoI nodes, which do not seed anything.
StatusCode dropFeatureless (const EventContext &ctx, State &state) const
 Removes TEs which have no features (combine wiht squeeze).
StatusCode dropInactive ()
 Removes TEs which are inactive (rejected by hypothesis).
StatusCode syncThinning (const EventContext &ctx, State &state) const
 reset indexes in the after the thinning
StatusCode dropChains (const EventContext &ctx, 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) (const EventContext &ctx, 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 30 of file TrigNavigationThinningSvc.cxx.

32 : base_class(name, pSvcLocator),
33 m_trigDecisionTool("Trig::TrigDecisionTool/TrigDecisionTool")
34{
35 // job option configurable properties
36 declareProperty("TrigDecisionTool", m_trigDecisionTool, "Tool handle to TDT/Navigation.");
37 declareProperty("ChainsRegex", m_chainsRegex="", "Keep only information related to this chains");
38 declareProperty("FeatureInclusionList", m_featureInclusionList, "This features will be kept. This setting overrules the FeatureExclusionList. Only list of types or type#key pairs are supported.");
39 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.");
40 declareProperty("ReportOperations", m_report=false, "Additional verbosity flag, when enabled the operations on trigger elements are reported (VERBOSE logging level)");
41
54
55
56 std::string possibleActions;
57 for ( auto a: m_actionsMap )
58 possibleActions += a.first +" ";
59 declareProperty("Actions", m_actions, "Operations which need to be done on the navigation"+possibleActions);
60}
static Double_t a
std::vector< std::string > m_actions
std::map< std::string, Action > m_actionsMap
StatusCode dropFeatureless(const EventContext &ctx, State &state) const
Removes TEs which have no features (combine wiht squeeze).
StatusCode save(const EventContext &ctx, State &state) const
Save the result of the slimming in the doSlimming argument (vector<uint32_t>).
StatusCode dropFeatures(const EventContext &ctx, State &state) const
Removes references to features from the navigation structure.
std::vector< std::string > m_featureInclusionList
StatusCode dropEmptyRoIs(const EventContext &ctx, State &state) const
Removes RoI nodes, which do not seed anything.
StatusCode syncThinning(const EventContext &ctx, State &state) const
reset indexes in the after the thinning
StatusCode dropRoIs(const EventContext &ctx, State &state) const
Removes RoI nodes, rather aggressive option, should be use as one of last actions as it makes impossi...
StatusCode squeeze(const EventContext &ctx, State &state) const
Remove intermediate TEs leaving very flat structure with event node, rois and terminals.
StatusCode reload(const EventContext &ctx, State &state) const
Reload the slimmed navigation in TDT so that all clients of current job see the chage.
StatusCode drop(const EventContext &ctx, State &state) const
clear the result of the slimming in the doSliming argument (vector<uint32_t>) Makes no sense to combi...
StatusCode print(const EventContext &ctx, State &state) const
bool m_report
TE operations verbosity flag.
StatusCode dropChains(const EventContext &ctx, State &state) const
remove info not related to the specified chains
std::vector< std::string > m_featureExclusionList
ToolHandle< Trig::TrigDecisionTool > m_trigDecisionTool
StatusCode restore(const EventContext &ctx, 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 286 of file TrigNavigationThinningSvc.cxx.

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

◆ drop()

StatusCode TrigNavigationThinningSvc::drop ( const EventContext & ctx,
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 122 of file TrigNavigationThinningSvc.cxx.

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

◆ dropChains()

StatusCode TrigNavigationThinningSvc::dropChains ( const EventContext & ctx,
State & state ) const
private

remove info not related to the specified chains

Definition at line 266 of file TrigNavigationThinningSvc.cxx.

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

Removes RoI nodes, which do not seed anything.

Definition at line 248 of file TrigNavigationThinningSvc.cxx.

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

◆ dropFeatureless()

StatusCode TrigNavigationThinningSvc::dropFeatureless ( const EventContext & ctx,
State & state ) const
private

Removes TEs which have no features (combine wiht squeeze).

Definition at line 257 of file TrigNavigationThinningSvc.cxx.

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

◆ dropFeatures()

StatusCode TrigNavigationThinningSvc::dropFeatures ( const EventContext & ctx,
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 184 of file TrigNavigationThinningSvc.cxx.

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

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

◆ finalize()

StatusCode TrigNavigationThinningSvc::finalize ( )
overridevirtual

Definition at line 326 of file TrigNavigationThinningSvc.cxx.

326 {
327 return StatusCode::SUCCESS;
328}

◆ initialize()

StatusCode TrigNavigationThinningSvc::initialize ( )
overridevirtual

Definition at line 69 of file TrigNavigationThinningSvc.cxx.

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

◆ lateFillConfiguration()

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

configures at the first event

Definition at line 333 of file TrigNavigationThinningSvc.cxx.

333 {
334 // remember the configured chain names, as they will be useful later
335 // ??? Originally, this was done once and cached in the tool.
336 // If this takes too long, consider storing it in the detector store.
337 auto chainGroup = m_trigDecisionTool->getChainGroup(m_chainsRegex);
338 ATH_MSG_DEBUG("Will keep information related to this chains" << chainGroup->getListOfTriggers());
339 auto confTEs = chainGroup->getHLTTriggerElements();
340 for ( auto& vec: confTEs) {
341 for ( auto confTEPtr: vec) {
342 state.tesToProtect.insert(confTEPtr->id());
343 }
344 }
345 return StatusCode::SUCCESS;
346}
std::vector< size_t > vec

◆ print()

StatusCode TrigNavigationThinningSvc::print ( const EventContext & ctx,
State & state ) const
private

Definition at line 163 of file TrigNavigationThinningSvc.cxx.

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

◆ propagateFeaturesToChildren()

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

Propagates the features on given TE to its children.

Definition at line 597 of file TrigNavigationThinningSvc.cxx.

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

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

Definition at line 130 of file TrigNavigationThinningSvc.cxx.

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

◆ 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 467 of file TrigNavigationThinningSvc.cxx.

468 {
469 ATH_MSG_DEBUG ( "Running the adjustIndicesAfterThinning" );
470
471 for ( auto te: state.navigation.getAllTEs() ) {
472 size_t featuresCount = std::count_if(te->getFeatureAccessHelpers().begin(),
473 te->getFeatureAccessHelpers().end(),
474 [](const TriggerElement::FeatureAccessHelper& fea){ return fea.forget(); }
475 );
476 if( featuresCount == 0 ) {
477 CHECK( removeTriggerElement( state, te, false ) );
478 }
479 }
480 return StatusCode::SUCCESS;
481}
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 420 of file TrigNavigationThinningSvc.cxx.

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

◆ 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 348 of file TrigNavigationThinningSvc.cxx.

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

488 {
489
490 if( v.empty())
491 return StatusCode::SUCCESS;
492
493 std::vector<TriggerElement*>::iterator newend = std::remove( v.begin(), v.end(), te);
494 v.erase(newend, v.end());
495
496 return StatusCode::SUCCESS;
497}
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 ( const EventContext & ctx,
State & state ) const
private

Restore the original navigation structure.

Definition at line 152 of file TrigNavigationThinningSvc.cxx.

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

◆ 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 452 of file TrigNavigationThinningSvc.cxx.

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

◆ save()

StatusCode TrigNavigationThinningSvc::save ( const EventContext & ctx,
State & state ) const
private

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

Definition at line 144 of file TrigNavigationThinningSvc.cxx.

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

◆ squeeze()

StatusCode TrigNavigationThinningSvc::squeeze ( const EventContext & ctx,
State & state ) const
private

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

Definition at line 168 of file TrigNavigationThinningSvc.cxx.

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

◆ syncThinning()

StatusCode TrigNavigationThinningSvc::syncThinning ( const EventContext & ctx,
State & state ) const
private

reset indexes in the after the thinning

Definition at line 738 of file TrigNavigationThinningSvc.cxx.

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

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

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

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: