19std::ostream&
operator<<( std::ostream&
s,
const std::vector<T>& v)
21 s<<
"[";
for(
auto i:v){
s << i <<
", ";}
s <<
"]";
25std::string TrigNavStructure::m_unspecifiedLabel =
"";
31 for (
auto& factory :
m_factory) factory.reset();
40 std::lock_guard<std::recursive_mutex> lock(
getMutex());
43 if ( factory.
empty() )
49 std::lock_guard<std::recursive_mutex> lock(
getMutex());
52 if ( not factory.
empty() )
59 std::lock_guard<std::recursive_mutex> lock(
getMutex());
80 std::vector<TriggerElement*> list;
81 list.push_back(seednode);
86 std::lock_guard<std::recursive_mutex> lock(
getMutex());
92 std::vector<TriggerElement* >::iterator it;
93 for ( it = seeds.begin(); it != seeds.end(); ++it ) {
111 for ( ; itbegin != itend; ++itbegin ) {
130 if ( te->
getId() ==
id )
132 std::vector<TriggerElement*>::const_iterator it;
155 if ( initialNode == 0 )
158 std::lock_guard<std::recursive_mutex> lock(
getMutex());
165 if ( te == initialNode ) {
167 const std::vector< TriggerElement* >& allTEs = factory.
listOfProduced();
168 std::vector< TriggerElement* >::const_iterator allIt;
169 for (allIt = allTEs.begin(); allIt != allTEs.end(); ++allIt) {
177 for (
int i=0; i < offset; i++ ) {
183 ss <<
"id:" << dec << te->
getId() <<
";"
186 <<
"ptr:" << hex << te <<
";"
189 std::vector<TriggerElement*>::const_iterator seedIt;
209 for ( ; it != itEnd; ++it ) {
218 std::lock_guard<std::recursive_mutex> lock(
getMutex());
223 const std::vector<TriggerElement*>& fullList = factory.
listOfProduced();
224 std::vector<TriggerElement*> all;
225 all.reserve(fullList.size());
227 for(std::vector<TriggerElement*>::const_iterator iter = fullList.begin(); iter != fullList.end(); ++iter) {
228 if(! (*iter)->transient() ) {
229 all.push_back( *iter );
234 output.reserve(10*all.size());
238 output.push_back(all.size());
241 std::map<TriggerElement*, uint16_t> keys;
244 std::vector<TriggerElement*>::const_iterator it;
245 uint16_t indexForTe = 0;
246 for ( it = all.begin(); it != all.end(); ++it ) {
249 (*it)->serialize(output, keys, previous);
251 keys[*it] = indexForTe;
265 std::lock_guard<std::recursive_mutex> lock(
getMutex());
270 std::vector<uint32_t>::const_iterator& inputIt = start;
271 const size_t payloadSize = *inputIt++;
274 std::cerr <<
"size of the navigation payload smaller than the one required to save TEs. " <<
totalSize <<
" < " << payloadSize << std::endl;
279 const unsigned int size = *inputIt++;
281 std::map<uint16_t, TriggerElement* > keys;
283 for (
unsigned int i = 0; i < size; ++i ) {
292 if ( not factory.
empty() ) {
295 std::vector<TriggerElement*>::const_iterator roiTEit;
315 std::vector<TriggerElement*>::const_iterator it;
337 output.push_back( te );
343 std::vector< TriggerElement* >& output,
344 const bool activeOnly)
const {
345 std::lock_guard<std::recursive_mutex> lock(
getMutex());
349 std::back_insert_iterator<std::vector<TriggerElement*> > outputIt( output );
362 std::lock_guard<std::recursive_mutex> lock(
getMutex());
366 std::back_insert_iterator<std::vector<TriggerElement*> > outputIt( output );
375 std::lock_guard<std::recursive_mutex> lock(
getMutex());
382 std::lock_guard<std::recursive_mutex> lock(
getMutex());
389 std::lock_guard<std::recursive_mutex> lock(
getMutex());
415 std::vector<const TriggerElement*> vecRoINodes;
418 vecRoINodes.push_back(te1);
420 std::back_insert_iterator<std::vector<const TriggerElement*> > outputIt( vecRoINodes );
424 vecRoINodes.push_back(te2);
426 std::back_insert_iterator<std::vector<const TriggerElement*> > outputIt( vecRoINodes );
430 sort(vecRoINodes.begin(), vecRoINodes.end());
432 std::vector<const TriggerElement*>::const_iterator it;
433 it = adjacent_find(vecRoINodes.begin(), vecRoINodes.end());
435 if ( it == vecRoINodes.end() )
448 std::vector<TriggerElement*> vecRoINodes1 =
getRoINodes(te1);
449 std::vector<TriggerElement*> vecRoINodes2 =
getRoINodes(te2);
450 sort(vecRoINodes1.begin(), vecRoINodes1.end());
451 sort(vecRoINodes2.begin(), vecRoINodes2.end());
452 return vecRoINodes1 == vecRoINodes2;
460 std::vector<const TriggerElement*> vecRoINodes;
461 std::back_insert_iterator<std::vector<const TriggerElement*> > outputIt( vecRoINodes );
470 sort(vecRoINodes.begin(), vecRoINodes.end());
472 std::vector<const TriggerElement*>::iterator it;
473 it = adjacent_find(vecRoINodes.begin(), vecRoINodes.end());
474 if ( it == vecRoINodes.end() )
492 if (
find(ids.begin(), ids.end(), te->
getId()) != ids.end() )
556 std::lock_guard<std::recursive_mutex> lock(
getMutex());
565 std::vector< TriggerElement* >::const_iterator old = oldFactory.
listOfProduced().begin();
566 std::vector< TriggerElement* >::iterator me = factory.
listOfProduced().begin();
569 (*me)->setActiveState((*old)->getActiveState());
581 std::vector<std::vector<TriggerElement*> >& output,
582 unsigned int maxResults,
bool onlyActive)
587 std::vector< std::vector<TriggerElement*> > input;
588 std::vector< std::vector<std::pair<unsigned int, unsigned int> > > newIdxs;
590 for (std::vector<unsigned int>::iterator
type =
types.begin();
593 std::vector< std::vector<TriggerElement*> > input = output;
594 std::vector< std::vector<std::pair<unsigned int, unsigned int> > > currentIdxs = newIdxs;
601 maxResults, onlyActive))
return false;
609 std::vector< std::vector<std::pair<unsigned int, unsigned int> > >& currentIdxs,
611 std::vector<std::vector<TriggerElement*> >& newCombs,
612 std::vector< std::vector<std::pair<unsigned int, unsigned int> > >& newIdxs,
613 unsigned int maxResults,
bool onlyActive)
616 std::vector<TriggerElement*> newTEs;
619 if (currentCombs.size() == 0) {
622 for (
unsigned int j = 0; j < newTEs.size(); j++) {
624 std::vector<TriggerElement*> cbs;
625 cbs.push_back(newTEs[j]);
626 newCombs.push_back(std::move(cbs));
629 std::vector<std::pair<unsigned int, unsigned int> > ti;
630 ti.emplace_back(
type, j);
631 newIdxs.push_back(std::move(ti));
637 for (
unsigned int i = 0; i < currentCombs.size(); i++) {
640 std::vector<TriggerElement*>& comb = currentCombs[i];
645 std::vector<std::pair<unsigned int, unsigned int> >& ti = currentIdxs[i];
658 for (
unsigned int j = comb.size(); j > 0; j--)
659 if (ti[j - 1].first ==
type) {
660 first = ti[j - 1].second;
667 for (
unsigned int j = first + 1; j < newTEs.size(); j++) {
678 newCombs.push_back(comb);
684 ti.push_back(std::pair<unsigned int, unsigned int>(
type, j));
685 newIdxs.push_back(ti);
689 if (maxResults > 0 && newCombs.size() >= maxResults) {
699 for (std::vector<TriggerElement*>::const_iterator te2 = teVec.begin(); te2 != teVec.end(); ++te2)
700 if (
overlaps(te1, *te2))
return true;
706 if (te1 == te2)
return true;
713 std::vector<const TriggerElement*>& children,
const bool activeOnly )
const {
718 for (
unsigned i = 0 ; i <
types.size(); ++i ) {
725 children.push_back(child);
736 unsigned int n_features = 0;
738 for ( std::vector< TriggerElement::FeatureAccessHelper >::const_iterator it = sourceTE->
getFeatureAccessHelpers().begin();
755 std::lock_guard<std::recursive_mutex> lock(
getMutex());
767 std::lock_guard<std::recursive_mutex> lock(
getMutex());
774 std::lock_guard<std::recursive_mutex> lock(
getMutex());
777 return holderstorage.
getLabel(clid,sti_or_label);
785 bool single =
true;
bool recursively =
false;
788 if(status && !features.empty()){
789 return features.front();
799 bool single =
true;
bool recursively =
true;
800 bool status =
getFeatureAccessors(startTE, clid,index_or_label,single,features,recursively,sourceTE);
802 if(status && !features.empty()){
803 return features.front();
810 bool only_single_feature,
813 std::string& sourcelabel )
const {
821 for (
int it = ( only_single_feature ? size-1 : 0 ); it != (only_single_feature ? -1 : size ); only_single_feature ? it--: it++ ) {
826 sourcelabel =
label(clid,fea.getIndex().subTypeIndex());
828 features.push_back(fea);
832 if ( only_single_feature )
842 bool only_single_feature,
844 bool travel_backward_recursively,
846 std::string& sourcelabel )
const {
856 if ( ! travel_backward_recursively ) {
866 if ( ! features.empty() ) {
871 bool recursion_status =
true;
876 recursion_status = recursion_status &&
getFeatureAccessors( predecessor, clid, index_or_label,
877 only_single_feature, features_in_branch,
878 travel_backward_recursively,
879 source, sourcelabel);
880 features.insert(features.end(), features_in_branch.begin(), features_in_branch.end());
883 if ( only_single_feature && ( features.size() > 1 || recursion_status ==
false) ) {
898 if(fea.
getCLID() != clid)
return false;
900 if(index_or_label.index() == 0){
902 auto index = std::get<sub_index_type>(index_or_label) ;
906 if(index_or_label.index() == 1){
908 auto label = std::get<std::string>(index_or_label);
922 std::lock_guard<std::recursive_mutex> lock(
getMutex());
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
static unsigned int totalSize(const MultiDimArray< T, N > &ht)
static const std::vector< std::string > types
std::string getLabel(class_id_type clid, const index_or_label_type &stiOrLabel) const
HolderType * getHolderForFeature(const TriggerElement::FeatureAccessHelper &fea) const
sub_index_type getSubTypeIndex(class_id_type clid, const index_or_label_type &stiOrLabel) const
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
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 * > > ¤tCombs, std::vector< std::vector< std::pair< unsigned int, unsigned int > > > ¤tIdxs, 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
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
virtual ~TrigNavStructure()
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.
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 ...
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()
static bool isRoINode(const TriggerElement *te)
queries if node is an RoI type one
TrigHolderStructure & getHolderStorage()
std::string label(class_id_type clid, const index_or_label_type &sti_or_label) const
The factory of TriggerElements Creation in controlled way.
const std::vector< TriggerElement * > & listOfProduced() const
TriggerElement * produce(unsigned int id, bool ghost=false, bool nofwd=false)
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.
sub_index_type subTypeIndex() const
to get collection index
TriggerElement is the basic ingreedient of the interface between HLT algorithms and the navigation It...
static unsigned int enquireId(std::vector< uint32_t >::const_iterator &inputIt)
@ 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.
const std::vector< TriggerElement * > & getRelated(Relation rel) const
returns reference to the likns to other TriggerElements related by relation r
bool getActiveState() const
get state of the TriggerElement
bool getErrorState() const
const std::vector< FeatureAccessHelper > & getFeatureAccessHelpers() const
returns all features which ara attached to this TE
void addFeature(class_id_type clid, const ObjectIndex &index, bool forget=false)
add helper for new feature
std::vector< FeatureAccessHelper > FeatureVec
const std::vector< FeatureAccessHelper > & getPreviousFeatures() const
void deserialize(std::vector< uint32_t >::const_iterator &inputIt, const std::map< uint16_t, TriggerElement * > &keys, const TriggerElement *previous)
deserialization
void relate(TriggerElement *te, Relation r)
reates given TE to other TE
std::string find(const std::string &s)
return a remapped string
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
const FeatureContainerInit< FEATURE, CONTAINER > RegisterFeatureContainerTypes< FEATURE, CONTAINER >::s
std::variant< sub_index_type, std::string > index_or_label_type
static const index_type invalid_sub_index
MsgStream & operator<<(MsgStream &m, const Navigation &nav)