ATLAS Offline Software
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 
22 namespace 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 
39 namespace 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 
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 
278  bool propagateDeactivation(const TrigNavStructure* nav);
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 
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,
335  TriggerElement::FeatureVec& features,
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,
344  TriggerElement::FeatureVec& features,
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
HLT::TrigNavStructure::haveAllCommonRoIs
static bool haveAllCommonRoIs(const HLT::TriggerElement *te1, const HLT::TriggerElement *te2)
Definition: TrigNavStructure.cxx:449
HLT::TrigNavStructure::haveDistinctSeed
static bool haveDistinctSeed(const TriggerElement *te1, const TriggerElement *te2)
inversion of haveCommonSeed
Definition: TrigNavStructure.cxx:481
HLT::TrigNavStructure::combine
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)
Definition: TrigNavStructure.cxx:582
HLT::TrigNavStructure::getAll
void getAll(std::vector< TriggerElement * > &output, const bool activeOnly=true) const
The query returning a collection of all TriggerElements.
Definition: TrigNavStructure.cxx:363
HLTNavDetails::FillSize::m_index
size_t m_index
Definition: TrigNavStructure.h:28
HLTNavDetails
Definition: Holder.cxx:118
HLT::TrigNavStructure::getHolderStorage
const TrigHolderStructure & getHolderStorage() const
Definition: TrigNavStructure.h:374
HLT::TrigNavStructure::getAllOfType
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.
Definition: TrigNavStructure.cxx:344
HLT::TrigNavStructure::serialize
virtual bool serialize(std::vector< uint32_t > &) const =0
method serizlizes entire navigation
HLT::TrigNavStructure::label
std::string label(class_id_type clid, const index_or_label_type &sti_or_label) const
Definition: TrigNavStructure.cxx:775
HLT::TrigNavStructure::deserialize
virtual bool deserialize(const std::vector< uint32_t > &)=0
HLT::TrigNavStructure::isRoINode
static bool isRoINode(const TriggerElement *te)
queries if node is an RoI type one
Definition: TrigNavStructure.cxx:507
HLT::TrigNavStructure::s_rmutex
static std::recursive_mutex s_rmutex
Definition: TrigNavStructure.h:385
HLT::TrigNavStructure::printASCIIArt
void printASCIIArt(std::string &str, const TriggerElement *te=0, int offset=0) const
pretty printing of the navigational structure (heavy)
Definition: TrigNavStructure.cxx:152
HLT::TrigHolderStructure
Definition: TrigHolderStructure.h:21
HLT::TriggerElement::FeatureVec
std::vector< FeatureAccessHelper > FeatureVec
Definition: TrigNavStructure/TrigNavStructure/TriggerElement.h:233
HLT::TrigNavStructure::getMutex
std::recursive_mutex & getMutex()
Definition: TrigNavStructure.h:371
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
HLT::TrigNavStructure::isTerminalNode
static bool isTerminalNode(const TriggerElement *te)
queries if node is terminal (no more TriggerElement are seeded by it)
Definition: TrigNavStructure.cxx:517
HLT::TriggerElement::getActiveState
bool getActiveState() const
get state of the TriggerElement
Definition: TrigNavStructure/TrigNavStructure/TriggerElement.h:48
HLT::TrigNavStructure::m_holderstorage
SG::SlotSpecificObj< TrigHolderStructure > m_holderstorage
structure for feature holders (one per processing slot)
Definition: TrigNavStructure.h:383
HLT::TrigNavStructure::getFeatureAccessorsSingleTE
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
Definition: TrigNavStructure.cxx:810
HLT::TrigNavStructure::reset
virtual void reset(bool inFinalize=false)
resets all the navigation, goes to the factory and asks to withdraw all produced objects
Definition: TrigNavStructure.cxx:756
HLT::TrigNavStructure::haveDistinctRoI
static bool haveDistinctRoI(const TriggerElement *te1, const TriggerElement *te2)
inversion of haveCommonRoI
Definition: TrigNavStructure.cxx:444
HLT::TrigNavStructure::getTopologicallySpannedBy
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
Definition: TrigNavStructure.cxx:714
HLT::TrigNavStructure::isTopological
static bool isTopological(const TriggerElement *te)
Definition: TrigNavStructure.h:259
TrigHolderStructure.h
HLT::TrigNavStructure::~TrigNavStructure
virtual ~TrigNavStructure()
Definition: TrigNavStructure.cxx:30
HLT::TrigNavStructure
Definition: TrigNavStructure.h:40
HLTNavDetails::FillSize::~FillSize
~FillSize()
Definition: TrigNavStructure.h:33
HLT::TrigNavStructure::getFeatureAccessors
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
Definition: TrigNavStructure.cxx:842
HLT::TrigNavStructure::getInitialNode
TriggerElement * getInitialNode()
gets initial node, if node is not there then it is created on fly
Definition: TrigNavStructure.cxx:39
HLT::TrigNavStructure::haveCommonSeed
static bool haveCommonSeed(const TriggerElement *te1, const TriggerElement *te2)
checks that there is any common predecessor of two TriggerElements
Definition: TrigNavStructure.cxx:461
HLT::TrigNavStructure::haveCommonRoI
static bool haveCommonRoI(const TriggerElement *te1, const TriggerElement *te2)
does this 2 share RoI
Definition: TrigNavStructure.cxx:416
HLT::TrigNavStructure::getFactory
TriggerElementFactory & getFactory()
Definition: TrigNavStructure.h:369
HLT::TrigNavStructure::getDirectSuccessors
static const std::vector< TriggerElement * > & getDirectSuccessors(const TriggerElement *te)
returns list of direct predecessors (nodes I seed)
Definition: TrigNavStructure.cxx:124
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
HLT::TrigNavStructure::m_factory
SG::SlotSpecificObj< TriggerElementFactory > m_factory
factory of trigger elements (one per processing slot)
Definition: TrigNavStructure.h:382
SG::SlotSpecificObj
Maintain a set of objects, one per slot.
Definition: AthenaKernel/AthenaKernel/SlotSpecificObj.h:70
HLT::TrigNavStructure::deserializeTEs
bool deserializeTEs(std::vector< uint32_t >::const_iterator &start, unsigned int totalSize)
Definition: TrigNavStructure.cxx:264
HLTNavDetails::FillSize
Definition: TrigNavStructure.h:26
HLT::TrigNavStructure::serializeTEs
bool serializeTEs(std::vector< uint32_t > &output) const
method serizlizes the navigation structure
Definition: TrigNavStructure.cxx:217
SlotSpecificObj.h
Dummy implementation of AthenaKernel/SlotSpecificObj.h.
HLT::TrigNavStructure::getDirectPredecessors
static const std::vector< TriggerElement * > & getDirectPredecessors(const TriggerElement *te)
returns list of direct predecessors (nodes seeding me)
Definition: TrigNavStructure.cxx:120
HLT::index_or_label_type
std::variant< sub_index_type, std::string > index_or_label_type
Definition: Trigger/TrigEvent/TrigNavStructure/TrigNavStructure/Types.h:16
HLT
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
Definition: HLTResultReader.h:26
HLTNavDetails::FillSize::m_output
std::vector< uint32_t > & m_output
Definition: TrigNavStructure.h:27
HLT::TriggerElement
TriggerElement is the basic ingreedient of the interface between HLT algorithms and the navigation It...
Definition: TrigNavStructure/TrigNavStructure/TriggerElement.h:27
TriggerElement.h
TriggerElementFactory.h
HLT::TrigNavStructure::ATLAS_THREAD_SAFE
static const TriggerElement *m_unspecifiedTE ATLAS_THREAD_SAFE
Definition: TrigNavStructure.h:377
HLT::TrigNavStructure::subType
sub_index_type subType(class_id_type clid, const index_or_label_type &sti_or_label) const
Definition: TrigNavStructure.cxx:768
HLT::TrigNavStructure::copyAllFeatures
unsigned int copyAllFeatures(const TriggerElement *sourceTE, TriggerElement *destTE)
gets all features from the sourceTE and copies a reference (FeatureAccessHelper) to the destTE
Definition: TrigNavStructure.cxx:736
HLT::TrigNavStructure::getHolderStorage
TrigHolderStructure & getHolderStorage()
Definition: TrigNavStructure.h:370
HLT::BaseHolder
Definition: BaseHolder.h:14
HLT::class_id_type
uint32_t class_id_type
Definition: Trigger/TrigEvent/TrigNavStructure/Root/Types.h:11
HLT::sub_index_type
uint16_t sub_index_type
Definition: Trigger/TrigEvent/TrigNavStructure/Root/Types.h:9
BaseHolder.h
HLT::TrigNavStructure::ATLAS_THREAD_SAFE
static std::string m_unspecifiedLabel ATLAS_THREAD_SAFE
Definition: TrigNavStructure.h:378
HLT::TrigNavStructure::getFeature
TriggerElement::FeatureAccessHelper getFeature(const TriggerElement *te, class_id_type clid, const index_or_label_type &index_or_label) const
typeless feature access metod
Definition: TrigNavStructure.cxx:783
merge.output
output
Definition: merge.py:17
HLT::TrigNavStructure::getFactory
const TriggerElementFactory & getFactory() const
Definition: TrigNavStructure.h:373
HLT::TrigNavStructure::getSuccessor
static const TriggerElement * getSuccessor(const TriggerElement *te, unsigned int id)
returns successor of given type beeing seeded from this TE
Definition: TrigNavStructure.cxx:129
HLT::TriggerElementFactory
The factory of TriggerElements Creation in controlled way.
Definition: TriggerElementFactory.h:28
HLT::TrigNavStructure::getAllRoIThresholdTEs
void getAllRoIThresholdTEs(std::vector< TriggerElement * > &output) const
The query returns a vector of all TriggerElements that represent a LVL1 RoI threshold.
Definition: TrigNavStructure.cxx:328
python.subdetectors.mmg.ids
ids
Definition: mmg.py:8
HLT::TrigNavStructure::addRoINode
TriggerElement * addRoINode(TriggerElement *initial)
gets RoI node (attached to initial)
Definition: TrigNavStructure.cxx:58
HLT::TrigNavStructure::decreasingOrderByTEId
static bool decreasingOrderByTEId(const TriggerElement *te1, const TriggerElement *te2)
Definition: TrigNavStructure.cxx:489
HLT::TrigNavStructure::overlaps
bool overlaps(const TriggerElement *t1, const TriggerElement *t2) const
Check overlap between trigger elements (pointer equality or RoI overlap)
Definition: TrigNavStructure.cxx:707
HLT::TrigNavStructure::isCompatibleTree
static bool isCompatibleTree(const TriggerElement *te1, const TriggerElement *te2)
check compatibility of 2 navigation structures
Definition: TrigNavStructure.cxx:526
HLT::TrigNavStructure::getRoINodes
static const std::vector< TriggerElement * > & getRoINodes(const TriggerElement *somenode)
gets all RoI type nodes seeding indirectly this TriggerElement
Definition: TrigNavStructure.cxx:73
HLT::TrigNavStructure::getFeatureRecursively
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 ...
Definition: TrigNavStructure.cxx:797
HLT::TrigNavStructure::getAllTEs
std::vector< TriggerElement * > & getAllTEs()
access needed by slimming tools.
Definition: TrigNavStructure.cxx:376
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
HLT::TrigNavStructure::isInitialNode
static bool isInitialNode(const TriggerElement *te)
queries if node is an initial one
Definition: TrigNavStructure.cxx:501
HLT::TrigNavStructure::fillSameRoIRelation
void fillSameRoIRelation(TriggerElement *roi, TriggerElement *te)
rebuilds the sameRoIRelation between trigger elements (used internally by deserialize)
Definition: TrigNavStructure.cxx:307
HLT::TriggerElement::FeatureAccessHelper
the FeatureAccessHelper is a class used to keep track of features attached to this TE.
Definition: TrigNavStructure/TrigNavStructure/TriggerElement.h:192
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
HLT::TrigNavStructure::getMutex
std::recursive_mutex & getMutex() const
Definition: TrigNavStructure.h:375
HLT::TrigNavStructure::hasIdFromTheSet
static bool hasIdFromTheSet(const TriggerElement *te, std::vector< unsigned int > ids)
simple helper
Definition: TrigNavStructure.cxx:493
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
python.DecayParser.children
children
Definition: DecayParser.py:32
HLT::TrigNavStructure::countAllOfType
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.
Definition: TrigNavStructure.cxx:390
copySelective.source
string source
Definition: copySelective.py:32
str
Definition: BTagTrackIpAccessor.cxx:11
python.copyTCTOutput.totalSize
totalSize
Definition: copyTCTOutput.py:93
HLT::TrigNavStructure::addNode
TriggerElement * addNode(TriggerElement *seed, unsigned int id)
adds nodes seeded form the one given as an argument,
Definition: TrigNavStructure.cxx:79
HLT::TrigNavStructure::increasingOrderByTEId
static bool increasingOrderByTEId(const TriggerElement *te1, const TriggerElement *te2)
for sorting TriggerElements according to their id
Definition: TrigNavStructure.cxx:485
HLT::TrigNavStructure::addOneLevel
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.
Definition: TrigNavStructure.cxx:610
HLT::TrigNavStructure::isNotActive
static bool isNotActive(const TriggerElement *te)
helper for the STL
Definition: TrigNavStructure.h:257
HLT::TrigNavStructure::propagateDeactivation
bool propagateDeactivation(const TrigNavStructure *nav)
propagates deactivation of TE state This finction should be used after Trigger is rerurn on L2 and th...
Definition: TrigNavStructure.cxx:557
HLT::TrigNavStructure::matchFeature
bool matchFeature(const TriggerElement::FeatureAccessHelper &fea, class_id_type clid, const index_or_label_type &index_or_label) const
Definition: TrigNavStructure.cxx:898
checker_macros.h
Define macros for attributes used to control the static checker.
HLT::TrigNavStructure::getHolder
const BaseHolder * getHolder(const TriggerElement::FeatureAccessHelper &fea) const
Definition: TrigNavStructure.cxx:923
HLTNavDetails::FillSize::FillSize
FillSize(std::vector< uint32_t > &o)
Definition: TrigNavStructure.h:29
HLT::te_id_type
uint32_t te_id_type
Definition: Trigger/TrigEvent/TrigNavStructure/TrigNavStructure/Types.h:11