31 ISvcLocator* pSvcLocator )
32 : base_class(name, pSvcLocator),
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)");
56 std::string possibleActions;
58 possibleActions +=
a.first +
" ";
59 declareProperty(
"Actions",
m_actions,
"Operations which need to be done on the navigation"+possibleActions);
71 ATH_MSG_DEBUG(
"TrigNavigationThinningSvc::initialize()" << name() );
73 m_checkToolDeps =
false;
80 return StatusCode::FAILURE;
82 ATH_MSG_INFO (
"Successfully retrieved the TrigDecisionTool!" );
85 ATH_MSG_FATAL (
"Could not retrieve the TrigDecisionTool as it was not specified!" );
86 return StatusCode::FAILURE;
89 ATH_MSG_DEBUG (
"Leaving TrigNavigationThinningSvc::Initialize" );
92 ATH_MSG_ERROR(
"Can't use the features inclusion and exclusion lists at the same time.");
93 return StatusCode::FAILURE;
103 ATH_MSG_FATAL(
"Dropping features is demanded but neither inclusion and exclusion lists are set");
104 return StatusCode::FAILURE;
114 return StatusCode::FAILURE;
117 return StatusCode::SUCCESS;
126 return StatusCode::SUCCESS;
133 std::vector<unsigned int> cuts;
134 std::vector<uint32_t>
temp;
139 ATH_MSG_DEBUG (
"Reloaded the navigation content in TDT (all clients will see reduced navigation content) ..." );
140 return StatusCode::SUCCESS;
145 std::vector<unsigned int> cuts;
148 return StatusCode::SUCCESS;
158 return StatusCode::SUCCESS;
165 return StatusCode::SUCCESS;
180 return StatusCode::SUCCESS;
189 std::set<std::pair<CLID, uint16_t> > toDelete;
190 std::set<std::pair<CLID, uint16_t> > toRetain;
195 if ( holders.empty() ) {
196 ATH_MSG_ERROR(
"The navigation does not contain any features. This is likely a configuration problem.");
197 return StatusCode::FAILURE;
200 for(
auto h : holders ) {
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() );
219 toDelete.insert(std::make_pair(
h->typeClid(),
h->subTypeIndex() ));
220 ATH_MSG_DEBUG(
"will be dropping references associated to: " <<
h->collectionName()<<
"#"<<
h->key() );
226 if ( not toRetain.empty() )
228 if ( not toDelete.empty() )
236 return StatusCode::SUCCESS;
245 return StatusCode::SUCCESS;
254 return StatusCode::SUCCESS;
259 if ( te->getFeatureAccessHelpers().empty() )
262 return StatusCode::SUCCESS;
268 return StatusCode::SUCCESS;
280 return StatusCode::SUCCESS;
287 std::vector<uint32_t>& slimmed_and_serialized)
const {
289 ATH_MSG_DEBUG(name() <<
" is obtaining the TrigNavigationThinningSvc lock in slot " << ctx.slot() <<
" for event " << ctx.eventID().event_number() );
298 ATH_MSG_WARNING (
"Could not get navigation from Trigger Decision Tool" );
300 ATH_MSG_DEBUG(name() <<
" is releasing the TrigNavigationThinningSvc lock");
301 return StatusCode::SUCCESS;
304 State state (ctx, *cnav, slimmed_and_serialized);
308 std::vector<uint32_t> cuts;
313 ATH_MSG_DEBUG(
"Applying action " << action <<
" on the navigation ");
316 auto function = ifunc->second;
317 CHECK( (this->*function)(ctx, state) );
320 ATH_MSG_DEBUG(name() <<
" is releasing the TrigNavigationThinningSvc lock");
321 return StatusCode::SUCCESS;
327 return StatusCode::SUCCESS;
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) {
345 return StatusCode::SUCCESS;
350 bool propagateFeatures)
const {
353 return StatusCode::SUCCESS;
362 if ( propagateFeatures )
371 for(
auto nodeInRoI : sameRoI ) {
383 for(
auto seededByNode: seededBy ) {
401 for(
auto seedsNode: seeds ) {
412 return StatusCode::SUCCESS;
421 const std::set<std::pair<CLID, uint16_t> >& toDelete)
const {
434 ATH_MSG_DEBUG(
"Will remove " << toDelete.size()<<
" feature type/key");
437 for (
auto& fea: te->getFeatureAccessHelpers() ) {
438 if ( toDelete.find( std::make_pair(fea.getCLID(), fea.getIndex().subTypeIndex()) ) != toDelete.end() )
448 return StatusCode::SUCCESS;
453 const std::set<std::pair<CLID, uint16_t> >& toRetain)
const {
454 ATH_MSG_DEBUG(
"Will retain " << toRetain.size()<<
" feature type/key");
457 for (
auto& fea: te->getFeatureAccessHelpers() ) {
458 if ( toRetain.find( std::make_pair(fea.getCLID(), fea.getIndex().subTypeIndex()) ) == toRetain.end() )
462 return StatusCode::SUCCESS;
472 size_t featuresCount = std::count_if(te->getFeatureAccessHelpers().begin(),
473 te->getFeatureAccessHelpers().end(),
476 if( featuresCount == 0 ) {
480 return StatusCode::SUCCESS;
491 return StatusCode::SUCCESS;
493 std::vector<TriggerElement*>::iterator newend =
std::remove( v.begin(), v.end(), te);
494 v.erase(newend, v.end());
496 return StatusCode::SUCCESS;
501 std::vector<std::string> *inclusionList, std::vector<std::string> *exclusionList) {
504 if(inclusionList && inclusionList->size() > 0) {
507 int onExclusionList = 0;
508 for(std::vector< TriggerElement::FeatureAccessHelper >::const_iterator iter =
515 if(exclusionList && std::find(exclusionList->begin(), exclusionList->end(),
533 if(!exclusionList || exclusionList->size() == 0)
536 for(std::vector< TriggerElement::FeatureAccessHelper >::const_iterator iter =
551 std::vector<TriggerElement*> *inclusionList,
552 std::vector<TriggerElement*> *exclusionList) {
565 if(inclusionList && inclusionList->size() > 0) {
568 if(std::find_if(inclusionList->begin(), inclusionList->end(),
572 if(exclusionList && std::find_if(exclusionList->begin(), exclusionList->end(),
582 if(!exclusionList || exclusionList->size() == 0)
586 if(std::find_if(exclusionList->begin(), exclusionList->end(),
600 return StatusCode::SUCCESS;
605 for(
auto ch: children ) {
609 for(
auto& fea: features ) {
613 std::stringstream
ss;
617 ch->getFeatureAccessHelpers().insert(ch->getFeatureAccessHelpers().begin(), fea );
621 return StatusCode::SUCCESS;
671 const std::vector< TriggerElement::FeatureAccessHelper > firstFeatures =
m_RoI->getFeatureAccessHelpers();
672 const std::vector< TriggerElement::FeatureAccessHelper > secondFeatures =
m_RoI->getFeatureAccessHelpers();
674 if(firstFeatures.size() != secondFeatures.size())
677 for(
unsigned int i = 0; i < firstFeatures.size(); i++) {
703 struct IndexRecalculator {
708 size_t getNewIndex(
size_t oldIndex) {
709 if ( oldIndex >= m_indices.size() ) {
712 return m_indices[oldIndex];
715 void expand(
size_t maxIndex ) {
716 const size_t checkedSoFar = m_validIndices.size();
717 m_indices.resize(maxIndex+1, RemovedIdx);
718 m_validIndices.resize(maxIndex+1);
720 for (
size_t toScan = checkedSoFar; toScan <= maxIndex; ++ toScan ) {
721 size_t newIndex = m_dec->index(toScan);
722 m_validIndices[toScan] = newIndex;
725 for (
size_t toScan = checkedSoFar; toScan <= maxIndex; ++toScan ) {
726 m_indices[toScan] = std::count_if(m_validIndices.begin(), m_validIndices.begin()+toScan,
727 [](
const size_t x){ return x != RemovedIdx; } );
732 std::vector<size_t> m_indices = {0};
733 std::vector<size_t> m_validIndices;
734 const SG::ThinningDecisionBase* m_dec;
744 if ( holders.empty() ) {
745 ATH_MSG_ERROR(
"The navigation does not contain any features. This is likely a configuration problem.");
746 return StatusCode::FAILURE;
749 for(
auto holder : holders) {
751 if ( not ipd->
proxy(holder->containerClid(), holder->label() ) ) {
752 ATH_MSG_DEBUG(
"Skipping feature missing in the store: " << holder->label());
755 holder->syncWithSG();
759 ATH_MSG_DEBUG (
"Thinning occured for this container" << *holder <<
", going to ajust the indices" );
768 IndexRecalculator recalculator( dec );
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);
780 idx.updateBeginAndEnd(newBegin, newEnd);
792 return StatusCode::SUCCESS;
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
std::vector< size_t > vec
#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.
Hold thinning decisions for one container.
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
The NavigationCore class, adds on top of the TrigNavStructure the EDM read-only handling.
virtual void reset(bool inFinalize=false)
resets all the navigation, goes to the factory and asks to withdraw all produced objects
virtual bool serialize(std::vector< uint32_t > &output) const
method serizlizes the navigation structure The structure is serrizlized in following order ....
virtual void prepare()
prepapres the navigation for next event
bool deserialize(const std::vector< uint32_t > &input)
std::vector< HolderType * > getAllHolders() const
static bool isInitialNode(const TriggerElement *te)
queries if node is an initial one
std::vector< TriggerElement * > & getAllTEs()
access needed by slimming tools.
static bool isTerminalNode(const TriggerElement *te)
queries if node is terminal (no more TriggerElement are seeded by it)
std::recursive_mutex & getMutex()
static bool isRoINode(const TriggerElement *te)
queries if node is an RoI type one
TrigHolderStructure & getHolderStorage()
the FeatureAccessHelper is a class used to keep track of features attached to this TE.
const ObjectIndex & getIndex() const
index in the external ojects array
class_id_type getCLID() const
Class ID of object.
Helper class for conversion from/to int stored in TE and pair of ints used in Navigation Object point...
sub_index_type subTypeIndex() const
to get collection index
index_type objectsEnd() const
to get object number in th ecollection
index_type objectsBegin() const
to get object number in th ecollection
TriggerElement is the basic ingreedient of the interface between HLT algorithms and the navigation It...
@ seedsRelation
what TEs I am seeding
@ sameRoIRelation
equilateral relation of all TEs rooted in one RoI
@ seededByRelation
what TEs are seeding me
te_id_type getId() const
reset internals.
void setTransient(bool t=true)
const std::vector< TriggerElement * > & getRelated(Relation rel) const
returns reference to the likns to other TriggerElements related by relation r
const std::vector< FeatureAccessHelper > & getFeatureAccessHelpers() const
returns all features which ara attached to this TE
std::map< Relation, std::vector< TriggerElement * > > m_relations
relations holder (features outside)
virtual SG::DataProxy * proxy(const CLID &id, const std::string &key) const =0
Get proxy with given id and key.
Hold thinning decisions for one container.
static const std::size_t RemovedIdx
Flag used to show that an index has been thinned away.
static std::mutex s_mutex
Used to compare pointers of TriggerElements.
TriggerElementFind(const HLT::TriggerElement *te)
const HLT::TriggerElement * m_RoI
bool operator()(const HLT::TriggerElement *te)
std::vector< std::string > m_actions
StatusCode lateFillConfiguration(State &state) const
configures at the first event
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 StatusCode finalize() override
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 ...
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 removeFeaturelessTriggerElements(State &state, HLT::TriggerElement *te=0)
Removes all trigger elements with no features from the navigation structure.
std::string m_chainsRegex
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.
StatusCode removeFeatures(State &state, const std::set< std::pair< CLID, uint16_t > > &doDelete) const
This is a helper function for removeFeatures(HLT::NavigationCore*, ...).
std::vector< std::string > m_featureInclusionList
virtual StatusCode doSlimming(const EventContext &, std::vector< uint32_t > &slimmed_and_serialized) const override
StatusCode retainFeatures(State &state, const std::set< std::pair< CLID, uint16_t > > &toRetain) const
This is a helper function for removeFeatures(HLT::NavigationCore*, ...).
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
virtual StatusCode initialize() override
std::set< std::string > m_featureKeepSet
computed from above
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 removeTriggerElementFromVector(HLT::TriggerElement *te, std::vector< HLT::TriggerElement * > &v) const
Removes all instances of the supplied TriggerElement from the supplied vector.
StatusCode print(const EventContext &ctx, State &state) const
StatusCode propagateFeaturesToChildren(const HLT::TriggerElement *te) const
Propagates the features on given TE to its children.
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
std::set< std::string > m_featureDropSet
computed from above
StatusCode restore(const EventContext &ctx, State &state) const
Restore the original navigation structure.
TrigNavigationThinningSvc(const std::string &name, ISvcLocator *pSvcLocator)
Helper function to get a label for a feature.
Helpers to retrieve the current thinning cache from the event context.
std::string find(const std::string &s)
return a remapped string
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
void expand(bit_t new_nbits)
Expand the container.
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
const SG::ThinningDecisionBase * getThinningDecision(const EventContext &ctx, const std::string &key)
Retrieve the current thinning decision for key.
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.
std::vector< uint32_t > & destinationNavigation
std::vector< uint32_t > originalNavigation
HLT::NavigationCore & navigation
std::set< HLT::te_id_type > tesToProtect