00001
00002
00003 #ifndef TRIGNAVSTRUCTURE_TRIGNAVSTRUCTURE_H
00004 #define TRIGNAVSTRUCTURE_TRIGNAVSTRUCTURE_H
00005
00006 #include <vector>
00007
00008 #include "TrigNavStructure/TriggerElement.h"
00009 #include "TrigNavStructure/TriggerElementFactory.h"
00010 #include "TrigNavStructure/BaseHolder.h"
00011
00012 #include "TrigNavStructure/TrigHolderStructure.h"
00013
00014 namespace HLTNavDetails {
00015
00016
00017
00018 struct FillSize {
00019 std::vector<uint32_t>& m_output;
00020 size_t m_index;
00021 FillSize(std::vector<uint32_t>& o)
00022 : m_output(o), m_index(m_output.size()) {
00023 m_output.push_back(0);
00024 }
00025 ~FillSize() {
00026 m_output[m_index] = m_output.size();
00027 }
00028 };
00029 }
00030
00031 namespace HLT {
00032 class TrigNavStructure {
00033 public:
00034
00035 virtual ~TrigNavStructure();
00036
00040 virtual void reset();
00041
00045 TriggerElement* getInitialNode();
00046 const TriggerElement* getInitialNode() const;
00047
00051 TriggerElement* addRoINode( TriggerElement* initial );
00052
00060 static const std::vector<TriggerElement*>& getRoINodes( const TriggerElement* somenode );
00061
00067 TriggerElement* addNode( TriggerElement* seed, unsigned int id );
00068
00077 TriggerElement* addNode( std::vector<TriggerElement* >& seeds, unsigned int id, bool ghost=false, bool nofwd=false );
00078
00084 static const std::vector<TriggerElement*>& getDirectPredecessors( const TriggerElement* te );
00085
00091 static const std::vector<TriggerElement*>& getDirectSuccessors( const TriggerElement* te );
00092
00100 static const TriggerElement* getSuccessor( const TriggerElement* te, unsigned int id );
00101
00107 static bool isInitialNode( const TriggerElement* te );
00108
00114 static bool isRoINode( const TriggerElement* te );
00115
00121 static bool isTerminalNode( const TriggerElement* te );
00122
00123
00127 void printASCIIArt( std::string& str, const TriggerElement* te = 0, int offset = 0 ) const;
00128
00136 bool serializeTEs( std::vector<uint32_t>& output ) const;
00137 bool deserializeTEs( std::vector<uint32_t>::const_iterator& start, unsigned int totalSize);
00138
00146 virtual bool serialize( std::vector<uint32_t>&) const = 0;
00147 virtual bool deserialize( const std::vector<uint32_t>&) = 0;
00148
00156 TriggerElement::FeatureAccessHelper getFeature(const TriggerElement* te, class_id_type clid, const index_or_label_type& index_or_label) const;
00157
00158
00165 TriggerElement::FeatureAccessHelper getFeatureRecursively(const TriggerElement* startTE, class_id_type clid,
00166 const index_or_label_type& index_or_label, const TriggerElement*& sourceTE) const;
00167
00168
00172 void getAllRoIThresholdTEs( std::vector< TriggerElement* >& output ) const;
00173
00177 void getAll( std::vector< TriggerElement* >& output, const bool activeOnly = true ) const;
00178
00182 std::vector<TriggerElement*>& getAllTEs() { return m_factory.listOfProduced(); }
00183
00188 void getAllOfType( const te_id_type id, std::vector< TriggerElement* >& output, const bool activeOnly = true ) const;
00189
00190
00191
00195 unsigned int countAllOfType( const te_id_type id, const bool activeOnly = true ) const;
00196
00211 static bool haveCommonRoI( const TriggerElement* te1, const TriggerElement* te2 );
00212
00219 static bool haveDistinctRoI(const TriggerElement* te1, const TriggerElement* te2 );
00220
00221 static bool haveAllCommonRoIs ( const HLT::TriggerElement* te1, const HLT::TriggerElement* te2 );
00222
00227 static bool haveCommonSeed( const TriggerElement* te1, const TriggerElement* te2 );
00228
00230 static bool haveDistinctSeed( const TriggerElement* te1, const TriggerElement* te2 );
00231
00237 static bool increasingOrderByTEId( const TriggerElement* te1, const TriggerElement* te2 );
00238 static bool decreasingOrderByTEId( const TriggerElement* te1, const TriggerElement* te2 );
00239
00241 static bool hasIdFromTheSet( const TriggerElement* te, std::vector<unsigned int> ids );
00242
00244 static inline bool isNotActive( const TriggerElement* te ) { return !te->getActiveState(); }
00245
00246 static inline bool isTopological( const TriggerElement* te) { return (getDirectPredecessors(te).size() > 1 ? true : false); }
00247
00254 static bool isCompatibleTree(const TriggerElement* te1, const TriggerElement* te2 );
00255
00256
00257
00265 bool propagateDeactivation(const TrigNavStructure* nav);
00266
00267
00268
00279 bool combine(std::vector<unsigned int>& types,
00280 std::vector< std::vector<TriggerElement*> >& output,
00281 unsigned int maxResults = 1000, bool onlyActive = true);
00282
00286 bool overlaps(const TriggerElement* t1, const TriggerElement* t2) const;
00287
00291 bool overlaps(const TriggerElement* t1, const std::vector<TriggerElement*>& teVec) const;
00292
00293
00301 bool getTopologicallySpannedBy( const TriggerElement* te, const std::vector<unsigned int>& types,
00302 std::vector<TriggerElement*>& children, const bool activeOnly = true ) const;
00303
00311 unsigned int copyAllFeatures( const TriggerElement* sourceTE, TriggerElement* destTE);
00312
00313 const BaseHolder* getHolder(const TriggerElement::FeatureAccessHelper& fea) const;
00314
00315 sub_index_type subType(class_id_type clid, const index_or_label_type& sti_or_label) const;
00316 std::string label(class_id_type clid, const index_or_label_type& sti_or_label) const;
00317
00318
00319 virtual bool getFeatureAccessors( const TriggerElement* te, class_id_type clid,
00320 const index_or_label_type& index_or_label,
00321 bool only_single_feature,
00322 TriggerElement::FeatureVec& features,
00323 bool with_cache_recording,
00324 bool travel_backward_recursively,
00325 const TriggerElement*& source = m_unspecifiedTE,
00326 std::string& sourcelabel = m_unspecifiedLabel) const;
00327 protected:
00328
00329 virtual bool getFeatureAccessorsSingleTE( const TriggerElement* te, class_id_type clid,
00330 const index_or_label_type& index_or_label,
00331 bool only_single_feature,
00332 TriggerElement::FeatureVec& features,
00333 bool with_cache_recording,
00334 const TriggerElement*& source,
00335 std::string& sourcelabel ) const ;
00336
00337
00338
00339 bool matchFeature(const TriggerElement::FeatureAccessHelper& fea, class_id_type clid, const index_or_label_type& index_or_label) const;
00340
00345 void fillSameRoIRelation ( TriggerElement* roi, TriggerElement* te );
00346
00350 bool addOneLevel(std::vector< std::vector<TriggerElement*> >& currentCombs,
00351 std::vector< std::vector<std::pair<unsigned int, unsigned int> > >& currentIdxs,
00352 unsigned int type,
00353 std::vector< std::vector<TriggerElement*> >& newCombs,
00354 std::vector< std::vector<std::pair<unsigned int, unsigned int> > >& newIdxs,
00355 unsigned int maxResults = 1000, bool onlyActive = 1);
00356
00357
00358
00359 TriggerElementFactory m_factory;
00360 TrigHolderStructure m_holderstorage;
00361 static const TriggerElement* m_unspecifiedTE;
00362 static std::string m_unspecifiedLabel;
00363
00364
00365 };
00366 }
00367
00368 #endif // TRIGNAVSTRUCTURE_TRIGNAVSTRUCTURE_H