ATLAS Offline Software
Loading...
Searching...
No Matches
TrigNavStructure.h
Go to the documentation of this file.
1// Dear emacs, this is -*- c++ -*-
2
3/*
4 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5*/
6
7
8#ifndef TRIGNAVSTRUCTURE_TRIGNAVSTRUCTURE_H
9#define TRIGNAVSTRUCTURE_TRIGNAVSTRUCTURE_H
10
11#include <vector>
12#include <mutex>
13
19
21
22namespace HLTNavDetails {
23 // RAII trick to fill sizes at the exit of the function
24 // at construction the extra word is reserved and the current size remembered
25 // at destruction the current size is filled at the previously reserved index
26 struct FillSize {
27 std::vector<uint32_t>& m_output;
28 size_t m_index;
29 FillSize(std::vector<uint32_t>& o)
30 : m_output(o), m_index(m_output.size()) {
31 m_output.push_back(0);
32 }
34 m_output[m_index] = m_output.size();
35 }
36 };
37}
38
39namespace HLT {
41 public:
42
43 virtual ~TrigNavStructure();
44
48 virtual void reset(bool inFinalize = false);
49
54 const TriggerElement* getInitialNode() const;
55
60
68 static const std::vector<TriggerElement*>& getRoINodes( const TriggerElement* somenode );
69
75 TriggerElement* addNode( TriggerElement* seed, unsigned int id );
76
85 TriggerElement* addNode( std::vector<TriggerElement* >& seeds, unsigned int id, bool ghost=false, bool nofwd=false );
86
92 static const std::vector<TriggerElement*>& getDirectPredecessors( const TriggerElement* te );
93
99 static const std::vector<TriggerElement*>& getDirectSuccessors( const TriggerElement* te );
100
108 static const TriggerElement* getSuccessor( const TriggerElement* te, unsigned int id );
109
115 static bool isInitialNode( const TriggerElement* te );
116
122 static bool isRoINode( const TriggerElement* te );
123
129 static bool isTerminalNode( const TriggerElement* te );
130
131
135 void printASCIIArt( std::string& str, const TriggerElement* te = 0, int offset = 0 ) const;
136
144 bool serializeTEs( std::vector<uint32_t>& output ) const;
145 bool deserializeTEs( std::vector<uint32_t>::const_iterator& start, unsigned int totalSize);
146
154 virtual bool serialize( std::vector<uint32_t>&) const = 0;
155 virtual bool deserialize( const std::vector<uint32_t>&) = 0;
156
165
166
174 const index_or_label_type& index_or_label, const TriggerElement*& sourceTE) const;
175
176
180 void getAllRoIThresholdTEs( std::vector< TriggerElement* >& output ) const;
181
185 void getAll( std::vector< TriggerElement* >& output, const bool activeOnly = true ) const;
186
190 std::vector<TriggerElement*>& getAllTEs();
191
195 const std::vector<TriggerElement*>& getAllTEs() const;
196
201 void getAllOfType( const te_id_type id, std::vector< TriggerElement* >& output, const bool activeOnly = true ) const;
202
203
204
208 unsigned int countAllOfType( const te_id_type id, const bool activeOnly = true ) const;
209
223
224 static bool haveCommonRoI( const TriggerElement* te1, const TriggerElement* te2 );
225
232 static bool haveDistinctRoI(const TriggerElement* te1, const TriggerElement* te2 );
233
234 static bool haveAllCommonRoIs ( const HLT::TriggerElement* te1, const HLT::TriggerElement* te2 );
235
240 static bool haveCommonSeed( const TriggerElement* te1, const TriggerElement* te2 );
241
243 static bool haveDistinctSeed( const TriggerElement* te1, const TriggerElement* te2 );
244
250 static bool increasingOrderByTEId( const TriggerElement* te1, const TriggerElement* te2 );
251 static bool decreasingOrderByTEId( const TriggerElement* te1, const TriggerElement* te2 );
252
254 static bool hasIdFromTheSet( const TriggerElement* te, std::vector<unsigned int> ids );
255
257 static inline bool isNotActive( const TriggerElement* te ) { return !te->getActiveState(); }
258
259 static inline bool isTopological( const TriggerElement* te) { return (getDirectPredecessors(te).size() > 1 ? true : false); }
260
267 static bool isCompatibleTree(const TriggerElement* te1, const TriggerElement* te2 );
268
269
270
279
280
281
292 bool combine(std::vector<unsigned int>& types,
293 std::vector< std::vector<TriggerElement*> >& output,
294 unsigned int maxResults = 1000, bool onlyActive = true);
295
299 bool overlaps(const TriggerElement* t1, const TriggerElement* t2) const;
300
304 bool overlaps(const TriggerElement* t1, const std::vector<TriggerElement*>& teVec) const;
305
306
314 bool getTopologicallySpannedBy( const TriggerElement* te, const std::vector<unsigned int>& types,
315 std::vector<const TriggerElement*>& children, const bool activeOnly = true ) const;
316
323
324 unsigned int copyAllFeatures( const TriggerElement* sourceTE, TriggerElement* destTE);
325
327
328 sub_index_type subType(class_id_type clid, const index_or_label_type& sti_or_label) const;
329 std::string label(class_id_type clid, const index_or_label_type& sti_or_label) const;
330
331
332 virtual bool getFeatureAccessors( const TriggerElement* te, class_id_type clid,
333 const index_or_label_type& index_or_label,
334 bool only_single_feature,
336 bool travel_backward_recursively,
337 const TriggerElement*& source = m_unspecifiedTE,
338 std::string& sourcelabel = m_unspecifiedLabel) const;
339 protected:
340
341 virtual bool getFeatureAccessorsSingleTE( const TriggerElement* te, class_id_type clid,
342 const index_or_label_type& index_or_label,
343 bool only_single_feature,
345 const TriggerElement*& source,
346 std::string& sourcelabel ) const ;
347
348
349 //method to see if feature matches by clid and either index or label
350 bool matchFeature(const TriggerElement::FeatureAccessHelper& fea, class_id_type clid, const index_or_label_type& index_or_label) const;
351
357
361 bool addOneLevel(std::vector< std::vector<TriggerElement*> >& currentCombs,
362 std::vector< std::vector<std::pair<unsigned int, unsigned int> > >& currentIdxs,
363 unsigned int type,
364 std::vector< std::vector<TriggerElement*> >& newCombs,
365 std::vector< std::vector<std::pair<unsigned int, unsigned int> > >& newIdxs,
366 unsigned int maxResults = 1000, bool onlyActive = 1);
367
368
371 std::recursive_mutex& getMutex() { return s_rmutex; }
372
373 const TriggerElementFactory& getFactory() const { return *m_factory; }
375 std::recursive_mutex& getMutex() const { return s_rmutex; }
376
377 static const TriggerElement* m_unspecifiedTE ATLAS_THREAD_SAFE;
378 static std::string m_unspecifiedLabel ATLAS_THREAD_SAFE;
379
380 private:
381
384
385 static std::recursive_mutex s_rmutex;
386
387 };
388} // end of HLT namespace
389
390#endif // TRIGNAVSTRUCTURE_TRIGNAVSTRUCTURE_H
Dummy implementation of AthenaKernel/SlotSpecificObj.h.
static unsigned int totalSize(const MultiDimArray< T, N > &ht)
static const std::vector< std::string > types
Define macros for attributes used to control the static checker.
static bool haveCommonSeed(const TriggerElement *te1, const TriggerElement *te2)
checks that there is any common predecessor of two TriggerElements
unsigned int countAllOfType(const te_id_type id, const bool activeOnly=true) const
The query counting a collection of all TriggerElement of a given type.
bool overlaps(const TriggerElement *t1, const TriggerElement *t2) const
Check overlap between trigger elements (pointer equality or RoI overlap)
static bool isCompatibleTree(const TriggerElement *te1, const TriggerElement *te2)
check compatibility of 2 navigation structures
std::recursive_mutex & getMutex() const
static bool haveDistinctRoI(const TriggerElement *te1, const TriggerElement *te2)
inversion of haveCommonRoI
static bool haveAllCommonRoIs(const HLT::TriggerElement *te1, const HLT::TriggerElement *te2)
bool matchFeature(const TriggerElement::FeatureAccessHelper &fea, class_id_type clid, const index_or_label_type &index_or_label) const
void getAllRoIThresholdTEs(std::vector< TriggerElement * > &output) const
The query returns a vector of all TriggerElements that represent a LVL1 RoI threshold.
SG::SlotSpecificObj< TriggerElementFactory > m_factory
factory of trigger elements (one per processing slot)
static bool isInitialNode(const TriggerElement *te)
queries if node is an initial one
virtual void reset(bool inFinalize=false)
resets all the navigation, goes to the factory and asks to withdraw all produced objects
void printASCIIArt(std::string &str, const TriggerElement *te=0, int offset=0) const
pretty printing of the navigational structure (heavy)
static std::recursive_mutex s_rmutex
TriggerElement::FeatureAccessHelper getFeature(const TriggerElement *te, class_id_type clid, const index_or_label_type &index_or_label) const
typeless feature access metod
bool addOneLevel(std::vector< std::vector< TriggerElement * > > &currentCombs, std::vector< std::vector< std::pair< unsigned int, unsigned int > > > &currentIdxs, unsigned int type, std::vector< std::vector< TriggerElement * > > &newCombs, std::vector< std::vector< std::pair< unsigned int, unsigned int > > > &newIdxs, unsigned int maxResults=1000, bool onlyActive=1)
Helper method for "combine": add one "level" of multiplicity to the results.
bool propagateDeactivation(const TrigNavStructure *nav)
propagates deactivation of TE state This finction should be used after Trigger is rerurn on L2 and th...
sub_index_type subType(class_id_type clid, const index_or_label_type &sti_or_label) const
virtual bool deserialize(const std::vector< uint32_t > &)=0
virtual bool serialize(std::vector< uint32_t > &) const =0
method serizlizes entire navigation
static const TriggerElement * getSuccessor(const TriggerElement *te, unsigned int id)
returns successor of given type beeing seeded from this TE
const BaseHolder * getHolder(const TriggerElement::FeatureAccessHelper &fea) const
bool serializeTEs(std::vector< uint32_t > &output) const
method serizlizes the navigation structure
std::vector< TriggerElement * > & getAllTEs()
access needed by slimming tools.
void getAllOfType(const te_id_type id, std::vector< TriggerElement * > &output, const bool activeOnly=true) const
The query returning a collection of all TriggerElements if name is given.
virtual bool getFeatureAccessors(const TriggerElement *te, class_id_type clid, const index_or_label_type &index_or_label, bool only_single_feature, TriggerElement::FeatureVec &features, bool travel_backward_recursively, const TriggerElement *&source=m_unspecifiedTE, std::string &sourcelabel=m_unspecifiedLabel) const
TriggerElement * addNode(TriggerElement *seed, unsigned int id)
adds nodes seeded form the one given as an argument,
static bool haveCommonRoI(const TriggerElement *te1, const TriggerElement *te2)
does this 2 share RoI
TriggerElement * addRoINode(TriggerElement *initial)
gets RoI node (attached to initial)
void fillSameRoIRelation(TriggerElement *roi, TriggerElement *te)
rebuilds the sameRoIRelation between trigger elements (used internally by deserialize)
bool getTopologicallySpannedBy(const TriggerElement *te, const std::vector< unsigned int > &types, std::vector< const TriggerElement * > &children, const bool activeOnly=true) const
gets the TEs whose predecessors were used to built a given topological TE
bool combine(std::vector< unsigned int > &types, std::vector< std::vector< TriggerElement * > > &output, unsigned int maxResults=1000, bool onlyActive=true)
For Algorithms: return all the possible n-tuples of TE* objects (te0, te1..., ten)
static bool hasIdFromTheSet(const TriggerElement *te, std::vector< unsigned int > ids)
simple helper
SG::SlotSpecificObj< TrigHolderStructure > m_holderstorage
structure for feature holders (one per processing slot)
unsigned int copyAllFeatures(const TriggerElement *sourceTE, TriggerElement *destTE)
gets all features from the sourceTE and copies a reference (FeatureAccessHelper) to the destTE
bool deserializeTEs(std::vector< uint32_t >::const_iterator &start, unsigned int totalSize)
static bool isNotActive(const TriggerElement *te)
helper for the STL
static bool decreasingOrderByTEId(const TriggerElement *te1, const TriggerElement *te2)
void getAll(std::vector< TriggerElement * > &output, const bool activeOnly=true) const
The query returning a collection of all TriggerElements.
static const TriggerElement *m_unspecifiedTE ATLAS_THREAD_SAFE
virtual bool getFeatureAccessorsSingleTE(const TriggerElement *te, class_id_type clid, const index_or_label_type &index_or_label, bool only_single_feature, TriggerElement::FeatureVec &features, const TriggerElement *&source, std::string &sourcelabel) const
TriggerElement * getInitialNode()
gets initial node, if node is not there then it is created on fly
TriggerElementFactory & getFactory()
static bool increasingOrderByTEId(const TriggerElement *te1, const TriggerElement *te2)
for sorting TriggerElements according to their id
static const std::vector< TriggerElement * > & getRoINodes(const TriggerElement *somenode)
gets all RoI type nodes seeding indirectly this TriggerElement
TriggerElement::FeatureAccessHelper getFeatureRecursively(const TriggerElement *startTE, class_id_type clid, const index_or_label_type &index_or_label, const TriggerElement *&sourceTE) const
recursive search for features the function is similar to the above butif th features is not found at ...
const TriggerElementFactory & getFactory() const
static const std::vector< TriggerElement * > & getDirectPredecessors(const TriggerElement *te)
returns list of direct predecessors (nodes seeding me)
static bool haveDistinctSeed(const TriggerElement *te1, const TriggerElement *te2)
inversion of haveCommonSeed
static bool isTerminalNode(const TriggerElement *te)
queries if node is terminal (no more TriggerElement are seeded by it)
static const std::vector< TriggerElement * > & getDirectSuccessors(const TriggerElement *te)
returns list of direct predecessors (nodes I seed)
std::recursive_mutex & getMutex()
const TrigHolderStructure & getHolderStorage() const
static bool isRoINode(const TriggerElement *te)
queries if node is an RoI type one
TrigHolderStructure & getHolderStorage()
static bool isTopological(const TriggerElement *te)
std::string label(class_id_type clid, const index_or_label_type &sti_or_label) const
The factory of TriggerElements Creation in controlled way.
the FeatureAccessHelper is a class used to keep track of features attached to this TE.
TriggerElement is the basic ingreedient of the interface between HLT algorithms and the navigation It...
bool getActiveState() const
get state of the TriggerElement
Maintain a set of objects, one per slot.
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
std::variant< sub_index_type, std::string > index_or_label_type
FillSize(std::vector< uint32_t > &o)
std::vector< uint32_t > & m_output