CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Attributes
SeedingNode< DATA > Class Template Reference

#include <SeedingTree.h>

Public Member Functions

const SeedingNode< DATA > * firstChild () const
 
const SeedingNode< DATA > * getChild (unsigned int ichild) const
 
unsigned int getChildIndex () const
 
unsigned int getChildrenSize () const
 
const DATA & getData () const
 
unsigned int getDepth () const
 
unsigned int getIndex () const
 
const SeedingNodegetParent () const
 
bool insert (const std::vector< DATA > &dataList, std::vector< SeedingNode< DATA > * > &allNodes)
 
const SeedingNode< DATA > * next () const
 
void print () const
 
void printRecursive () const
 
 SeedingNode (const DATA &data, std::vector< SeedingNode * > &allNodes, int parentIndex=-1)
 
void sort (std::vector< SeedingNode< DATA > * > &allNodes, unsigned int parentIndex)
 

Protected Attributes

const std::vector< SeedingNode
< DATA > * > & 
_allNodes
 
int _childIndex
 
std::vector< unsigned int > _children
 
const DATA _data
 
unsigned int _depth
 
unsigned int _index
 
int _parentIndex
 

Detailed Description

template<class DATA>
class SeedingNode< DATA >

Definition at line 10 of file SeedingTree.h.

Constructor & Destructor Documentation

template<class DATA>
SeedingNode< DATA >::SeedingNode ( const DATA &  data,
std::vector< SeedingNode< DATA > * > &  allNodes,
int  parentIndex = -1 
)
inline

Definition at line 22 of file SeedingTree.h.

References SeedingNode< DATA >::_childIndex, SeedingNode< DATA >::_children, SeedingNode< DATA >::_depth, SeedingNode< DATA >::_index, and SeedingNode< DATA >::_parentIndex.

22  :
23  _data(data),
24  _allNodes(allNodes),
25  _index(allNodes.size()),
26  _parentIndex(parentIndex)
27  {
28  allNodes.push_back(this);
29 
30  if (_parentIndex>=0)
31  {
32  SeedingNode* parent = allNodes[_parentIndex];
33  _depth=parent->_depth+1;
34  _childIndex=parent->_children.size();
35  parent->_children.push_back(_index);
36 
37  }
38  else
39  {
40  _depth=0;
41  _childIndex=-1;
42  }
43  }
int _childIndex
Definition: SeedingTree.h:17
int _parentIndex
Definition: SeedingTree.h:16
unsigned int _depth
Definition: SeedingTree.h:18
const DATA _data
Definition: SeedingTree.h:13
std::vector< unsigned int > _children
Definition: SeedingTree.h:19
const std::vector< SeedingNode< DATA > * > & _allNodes
Definition: SeedingTree.h:14
unsigned int _index
Definition: SeedingTree.h:15

Member Function Documentation

template<class DATA>
const SeedingNode<DATA>* SeedingNode< DATA >::firstChild ( ) const
inline

Definition at line 98 of file SeedingTree.h.

References SeedingNode< DATA >::_allNodes, and SeedingNode< DATA >::_children.

99  {
100  if (_children.size()>0)
101  {
102  return _allNodes[_children[0]];
103  }
104  return nullptr;
105  }
std::vector< unsigned int > _children
Definition: SeedingTree.h:19
const std::vector< SeedingNode< DATA > * > & _allNodes
Definition: SeedingTree.h:14
template<class DATA>
const SeedingNode<DATA>* SeedingNode< DATA >::getChild ( unsigned int  ichild) const
inline

Definition at line 126 of file SeedingTree.h.

References SeedingNode< DATA >::_allNodes, and SeedingNode< DATA >::_children.

Referenced by SeedFinder::insertHit().

127  {
128  return _allNodes[_children[ichild]];
129  }
std::vector< unsigned int > _children
Definition: SeedingTree.h:19
const std::vector< SeedingNode< DATA > * > & _allNodes
Definition: SeedingTree.h:14
template<class DATA>
unsigned int SeedingNode< DATA >::getChildIndex ( ) const
inline

Definition at line 131 of file SeedingTree.h.

References SeedingNode< DATA >::_childIndex.

132  {
133  return _childIndex;
134  }
int _childIndex
Definition: SeedingTree.h:17
template<class DATA>
unsigned int SeedingNode< DATA >::getChildrenSize ( ) const
inline

Definition at line 121 of file SeedingTree.h.

References SeedingNode< DATA >::_children.

Referenced by SeedFinder::insertHit().

122  {
123  return _children.size();
124  }
std::vector< unsigned int > _children
Definition: SeedingTree.h:19
template<class DATA>
const DATA& SeedingNode< DATA >::getData ( void  ) const
inline

Definition at line 136 of file SeedingTree.h.

References SeedingNode< DATA >::_data.

Referenced by SeedingNode< DATA >::insert(), and SeedFinder::insertHit().

137  {
138  return _data;
139  }
const DATA _data
Definition: SeedingTree.h:13
template<class DATA>
unsigned int SeedingNode< DATA >::getDepth ( void  ) const
inline
template<class DATA>
unsigned int SeedingNode< DATA >::getIndex ( ) const
inline

Definition at line 107 of file SeedingTree.h.

References SeedingNode< DATA >::_index.

Referenced by SeedFinder::insertHit(), SeedFinder::iterateHits(), and TrajectorySeedProducer::passHitTuplesCuts().

108  {
109  return _index;
110  }
unsigned int _index
Definition: SeedingTree.h:15
template<class DATA>
const SeedingNode* SeedingNode< DATA >::getParent ( ) const
inline

Definition at line 112 of file SeedingTree.h.

References SeedingNode< DATA >::_allNodes, and SeedingNode< DATA >::_parentIndex.

Referenced by SeedFinder::insertHit(), SeedFinder::iterateHits(), and TrajectorySeedProducer::passHitTuplesCuts().

113  {
114  if (_parentIndex>=0)
115  {
116  return _allNodes[_parentIndex];
117  }
118  return nullptr;
119  }
int _parentIndex
Definition: SeedingTree.h:16
const std::vector< SeedingNode< DATA > * > & _allNodes
Definition: SeedingTree.h:14
template<class DATA>
bool SeedingNode< DATA >::insert ( const std::vector< DATA > &  dataList,
std::vector< SeedingNode< DATA > * > &  allNodes 
)
inline

Definition at line 60 of file SeedingTree.h.

References SeedingNode< DATA >::_children, SeedingNode< DATA >::_depth, SeedingNode< DATA >::_index, SeedingNode< DATA >::getData(), SeedingNode< DATA >::getDepth(), and SeedingNode< DATA >::insert().

Referenced by BeautifulSoup.PageElement::_invert(), SeedingNode< DATA >::insert(), and SeedingTree< TrackingLayer >::insert().

61  {
62  if (_depth+1>=dataList.size())
63  {
64  //std::cout<<"\tSeedingNode::insert: return"<<std::endl;
65  return false;
66  }
67  for (unsigned int ichild=0; ichild<_children.size();++ichild)
68  {
69  if (allNodes[_children[ichild]]->getData()==dataList[_depth+1])
70  {
71  //std::cout<<"\tSeedingNode::insert: has child "<<dataList[_depth+1].print()<<std::endl;
72  return allNodes[_children[ichild]]->insert(dataList,allNodes);
73  }
74  }
75  //std::cout<<"\tSeedingNode::insert: create child "<<dataList[_depth+1].print()<<std::endl;
76  SeedingNode<DATA>* node = new SeedingNode<DATA>(dataList[_depth+1],allNodes,_index);
77  if (node->getDepth()+1>=dataList.size())
78  {
79  return true;
80  }
81  return node->insert(dataList,allNodes);
82  }
const DATA & getData() const
Definition: SeedingTree.h:136
unsigned int getDepth() const
Definition: SeedingTree.h:84
unsigned int _depth
Definition: SeedingTree.h:18
bool insert(const std::vector< DATA > &dataList, std::vector< SeedingNode< DATA > * > &allNodes)
Definition: SeedingTree.h:60
std::vector< unsigned int > _children
Definition: SeedingTree.h:19
unsigned int _index
Definition: SeedingTree.h:15
template<class DATA>
const SeedingNode<DATA>* SeedingNode< DATA >::next ( void  ) const
inline

Definition at line 89 of file SeedingTree.h.

References SeedingNode< DATA >::_allNodes, and SeedingNode< DATA >::_index.

Referenced by BeautifulSoup.PageElement::_invert().

90  {
91  if (_index+1<_allNodes.size())
92  {
93  return _allNodes[_index+1];
94  }
95  return nullptr;
96  }
const std::vector< SeedingNode< DATA > * > & _allNodes
Definition: SeedingTree.h:14
unsigned int _index
Definition: SeedingTree.h:15
template<class DATA>
void SeedingNode< DATA >::print ( void  ) const
inline

Definition at line 141 of file SeedingTree.h.

References SeedingNode< DATA >::_childIndex, SeedingNode< DATA >::_data, SeedingNode< DATA >::_depth, SeedingNode< DATA >::_index, gather_cfg::cout, and i.

Referenced by SeedingNode< DATA >::printRecursive().

142  {
143 
144  printf("index=%3i, depth=%2i, childIndex=%2i: ",_index,_depth,_childIndex);
145  for (unsigned int i=0;i<_depth;++i)
146  {
147  std::cout<<" -- ";
148  }
149  printf("[%s, %s] \r\n",_data.toString().c_str(),_data.toIdString().c_str());
150 
151  }
int i
Definition: DBlmapReader.cc:9
int _childIndex
Definition: SeedingTree.h:17
unsigned int _depth
Definition: SeedingTree.h:18
const DATA _data
Definition: SeedingTree.h:13
tuple cout
Definition: gather_cfg.py:145
unsigned int _index
Definition: SeedingTree.h:15
template<class DATA>
void SeedingNode< DATA >::printRecursive ( ) const
inline

Definition at line 152 of file SeedingTree.h.

References SeedingNode< DATA >::_allNodes, SeedingNode< DATA >::_children, and SeedingNode< DATA >::print().

153  {
154  print();
155  for (unsigned int ichild=0; ichild<_children.size(); ++ichild)
156  {
157  _allNodes[_children[ichild]]->printRecursive();
158  }
159  }
std::vector< unsigned int > _children
Definition: SeedingTree.h:19
void print() const
Definition: SeedingTree.h:141
const std::vector< SeedingNode< DATA > * > & _allNodes
Definition: SeedingTree.h:14
template<class DATA>
void SeedingNode< DATA >::sort ( std::vector< SeedingNode< DATA > * > &  allNodes,
unsigned int  parentIndex 
)
inline

Definition at line 45 of file SeedingTree.h.

References SeedingNode< DATA >::_allNodes, SeedingNode< DATA >::_childIndex, SeedingNode< DATA >::_children, SeedingNode< DATA >::_index, and SeedingNode< DATA >::_parentIndex.

46  {
47  _parentIndex=parentIndex;
48  _index=allNodes.size();
49  if (_parentIndex>=0)
50  {
51  allNodes[_parentIndex]->_children[_childIndex]=_index;
52  }
53  allNodes.push_back(this);
54  for (unsigned int ichild=0; ichild<_children.size();++ichild)
55  {
56  _allNodes[_children[ichild]]->sort(allNodes,_index);
57  }
58  }
int _childIndex
Definition: SeedingTree.h:17
int _parentIndex
Definition: SeedingTree.h:16
std::vector< unsigned int > _children
Definition: SeedingTree.h:19
const std::vector< SeedingNode< DATA > * > & _allNodes
Definition: SeedingTree.h:14
unsigned int _index
Definition: SeedingTree.h:15

Member Data Documentation

template<class DATA>
const std::vector<SeedingNode<DATA>*>& SeedingNode< DATA >::_allNodes
protected
template<class DATA>
int SeedingNode< DATA >::_childIndex
protected
template<class DATA>
std::vector<unsigned int> SeedingNode< DATA >::_children
protected
template<class DATA>
const DATA SeedingNode< DATA >::_data
protected
template<class DATA>
unsigned int SeedingNode< DATA >::_depth
protected
template<class DATA>
unsigned int SeedingNode< DATA >::_index
protected
template<class DATA>
int SeedingNode< DATA >::_parentIndex
protected