CMS 3D CMS Logo

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

◆ SeedingNode()

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

Definition at line 21 of file SeedingTree.h.

22  : _data(data), _allNodes(allNodes), _index(allNodes.size()), _parentIndex(parentIndex) {
23  allNodes.push_back(this);
24 
25  if (_parentIndex >= 0) {
26  SeedingNode* parent = allNodes[_parentIndex];
27  _depth = parent->_depth + 1;
28  _childIndex = parent->_children.size();
29  parent->_children.push_back(_index);
30 
31  } else {
32  _depth = 0;
33  _childIndex = -1;
34  }
35  }

References SeedingNode< DATA >::_childIndex, SeedingNode< DATA >::_depth, SeedingNode< DATA >::_index, SeedingNode< DATA >::_parentIndex, and class-composition::parent.

Member Function Documentation

◆ firstChild()

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

Definition at line 74 of file SeedingTree.h.

74  {
75  if (!_children.empty()) {
76  return _allNodes[_children[0]];
77  }
78  return nullptr;
79  }

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

◆ getChild()

template<class DATA>
const SeedingNode<DATA>* SeedingNode< DATA >::getChild ( unsigned int  ichild) const
inline

Definition at line 92 of file SeedingTree.h.

92 { return _allNodes[_children[ichild]]; }

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

Referenced by SeedFinder::insertHit().

◆ getChildIndex()

template<class DATA>
unsigned int SeedingNode< DATA >::getChildIndex ( ) const
inline

Definition at line 94 of file SeedingTree.h.

94 { return _childIndex; }

References SeedingNode< DATA >::_childIndex.

◆ getChildrenSize()

template<class DATA>
unsigned int SeedingNode< DATA >::getChildrenSize ( ) const
inline

Definition at line 90 of file SeedingTree.h.

90 { return _children.size(); }

References SeedingNode< DATA >::_children.

Referenced by SeedFinder::insertHit().

◆ getData()

template<class DATA>
const DATA& SeedingNode< DATA >::getData ( void  ) const
inline

Definition at line 96 of file SeedingTree.h.

96 { return _data; }

References SeedingNode< DATA >::_data.

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

◆ getDepth()

template<class DATA>
unsigned int SeedingNode< DATA >::getDepth ( void  ) const
inline

Definition at line 65 of file SeedingTree.h.

65 { return _depth; }

References SeedingNode< DATA >::_depth.

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

◆ getIndex()

template<class DATA>
unsigned int SeedingNode< DATA >::getIndex ( ) const
inline

Definition at line 81 of file SeedingTree.h.

81 { return _index; }

References SeedingNode< DATA >::_index.

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

◆ getParent()

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

Definition at line 83 of file SeedingTree.h.

83  {
84  if (_parentIndex >= 0) {
85  return _allNodes[_parentIndex];
86  }
87  return nullptr;
88  }

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

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

◆ insert()

template<class DATA>
bool SeedingNode< DATA >::insert ( const std::vector< DATA > &  dataList,
std::vector< SeedingNode< DATA > * > &  allNodes 
)
inline

Definition at line 49 of file SeedingTree.h.

49  {
50  if (_depth + 1 >= dataList.size()) {
51  return false;
52  }
53  for (unsigned int ichild = 0; ichild < _children.size(); ++ichild) {
54  if (allNodes[_children[ichild]]->getData() == dataList[_depth + 1]) {
55  return allNodes[_children[ichild]]->insert(dataList, allNodes);
56  }
57  }
58  SeedingNode<DATA>* node = new SeedingNode<DATA>(dataList[_depth + 1], allNodes, _index);
59  if (node->getDepth() + 1 >= dataList.size()) {
60  return true;
61  }
62  return node->insert(dataList, allNodes);
63  }

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

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

◆ next()

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

Definition at line 67 of file SeedingTree.h.

67  {
68  if (_index + 1 < _allNodes.size()) {
69  return _allNodes[_index + 1];
70  }
71  return nullptr;
72  }

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

◆ print()

template<class DATA>
void SeedingNode< DATA >::print ( void  ) const
inline

Definition at line 98 of file SeedingTree.h.

98  {
99  printf("index=%3i, depth=%2i, childIndex=%2i: ", _index, _depth, _childIndex);
100  for (unsigned int i = 0; i < _depth; ++i) {
101  std::cout << " -- ";
102  }
103  printf("[%s, %s] \r\n", _data.toString().c_str(), _data.toIdString().c_str());
104  }

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

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

◆ printRecursive()

template<class DATA>
void SeedingNode< DATA >::printRecursive ( ) const
inline

Definition at line 105 of file SeedingTree.h.

105  {
106  print();
107  for (unsigned int ichild = 0; ichild < _children.size(); ++ichild) {
108  _allNodes[_children[ichild]]->printRecursive();
109  }
110  }

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

◆ sort()

template<class DATA>
void SeedingNode< DATA >::sort ( std::vector< SeedingNode< DATA > * > &  allNodes,
unsigned int  parentIndex 
)
inline

Definition at line 37 of file SeedingTree.h.

37  {
38  _parentIndex = parentIndex;
39  _index = allNodes.size();
40  if (_parentIndex >= 0) {
41  allNodes[_parentIndex]->_children[_childIndex] = _index;
42  }
43  allNodes.push_back(this);
44  for (unsigned int ichild = 0; ichild < _children.size(); ++ichild) {
45  _allNodes[_children[ichild]]->sort(allNodes, _index);
46  }
47  }

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

Member Data Documentation

◆ _allNodes

template<class DATA>
const std::vector<SeedingNode<DATA>*>& SeedingNode< DATA >::_allNodes
protected

◆ _childIndex

template<class DATA>
int SeedingNode< DATA >::_childIndex
protected

◆ _children

template<class DATA>
std::vector<unsigned int> SeedingNode< DATA >::_children
protected

◆ _data

template<class DATA>
const DATA SeedingNode< DATA >::_data
protected

◆ _depth

template<class DATA>
unsigned int SeedingNode< DATA >::_depth
protected

◆ _index

template<class DATA>
unsigned int SeedingNode< DATA >::_index
protected

Definition at line 14 of file SeedingTree.h.

Referenced by ntupleDataFormat._Object::__getattr__(), python.cmstools.EventTree::__getitem__(), python.cmstools.EventTree::__iter__(), python.cmstools.EventBranch::__readData(), python.cmstools.EventTree::__setBranchIndicies(), ntupleDataFormat.TrackingParticle::_nMatchedSeeds(), ntupleDataFormat._SimHitMatchAdaptor::_nMatchedSimHits(), ntupleDataFormat._TrackingParticleMatchAdaptor::_nMatchedTrackingParticles(), ntupleDataFormat.TrackingParticle::_nMatchedTracks(), html.HtmlReport::addNote(), ntupleDataFormat.TrackingVertex::daughterTrackingParticles(), ntupleDataFormat.TrackingParticle::decayVertices(), ntupleDataFormat._DetIdStrAdaptor::detIdStr(), SeedingNode< DATA >::getIndex(), ntupleDataFormat._Object::index(), python.cmstools.EventTree::index(), ntupleDataFormat.Seed::indexWithinAlgo(), SeedingNode< DATA >::insert(), ntupleDataFormat._Object::isValid(), ntupleDataFormat._DetIdStrAdaptor::layerStr(), ntupleDataFormat.InvalidHit::layerStr(), ntupleDataFormat.TrackingParticle::matchedSeedInfos(), ntupleDataFormat._SimHitMatchAdaptor::matchedSimHitInfos(), ntupleDataFormat.TrackingParticle::matchedTrackInfos(), ntupleDataFormat._TrackingParticleMatchAdaptor::matchedTrackingParticleInfos(), ntupleDataFormat.GluedHit::monoHit(), ntupleDataFormat.TrackingVertex::nDaughterTrackingParticles(), SeedingNode< DATA >::next(), ntupleDataFormat.SimHit::nRecHits(), ntupleDataFormat._HitObject::nseeds(), ntupleDataFormat.GluedHit::nseeds(), ntupleDataFormat.TrackingVertex::nSourceTrackingParticles(), ntupleDataFormat._HitObject::ntracks(), ntupleDataFormat.Vertex::nTracks(), ntupleDataFormat.TrackingParticle::parentVertex(), SeedingNode< DATA >::print(), ntupleDataFormat.SeedMatchInfo::seed(), ntupleDataFormat.Track::seed(), SeedingNode< DATA >::SeedingNode(), ntupleDataFormat._HitObject::seeds(), ntupleDataFormat.GluedHit::seeds(), python.cmstools.EventBranch::setIndex(), ntupleDataFormat.SimHitMatchInfo::simHit(), SeedingNode< DATA >::sort(), ntupleDataFormat.TrackingVertex::sourceTrackingParticles(), ntupleDataFormat.GluedHit::stereoHit(), ntupleDataFormat.Seed::track(), ntupleDataFormat.SimHit::trackingParticle(), ntupleDataFormat._HitObject::tracks(), ntupleDataFormat.Vertex::tracks(), ntupleDataFormat.Track::vertex(), and html.HtmlReport::write().

◆ _parentIndex

template<class DATA>
int SeedingNode< DATA >::_parentIndex
protected
SeedingNode::_childIndex
int _childIndex
Definition: SeedingTree.h:16
mps_fire.i
i
Definition: mps_fire.py:428
gather_cfg.cout
cout
Definition: gather_cfg.py:144
SeedingNode::print
void print() const
Definition: SeedingTree.h:98
SeedingNode::_parentIndex
int _parentIndex
Definition: SeedingTree.h:15
SeedingNode::getDepth
unsigned int getDepth() const
Definition: SeedingTree.h:65
SeedingNode::_children
std::vector< unsigned int > _children
Definition: SeedingTree.h:18
SeedingNode::_allNodes
const std::vector< SeedingNode< DATA > * > & _allNodes
Definition: SeedingTree.h:13
SeedingNode::_depth
unsigned int _depth
Definition: SeedingTree.h:17
SeedingNode::_data
const DATA _data
Definition: SeedingTree.h:12
SeedingNode::insert
bool insert(const std::vector< DATA > &dataList, std::vector< SeedingNode< DATA > * > &allNodes)
Definition: SeedingTree.h:49
SeedingNode::_index
unsigned int _index
Definition: SeedingTree.h:14
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
SeedingNode
Definition: SeedingTree.h:10
class-composition.parent
parent
Definition: class-composition.py:88
SeedingNode::getData
const DATA & getData() const
Definition: SeedingTree.h:96