ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
Tree Class Reference

#include <Tree.h>

Collaboration diagram for Tree:

Public Member Functions

 Tree (const std::vector< std::size_t > &)
 
std::size_t parent (std::size_t) const
 
std::vector< std::size_t > siblings (std::size_t) const
 
std::size_t size () const
 
const std::vector< std::size_t > & leaves () const
 
bool is_leaf (size_t) const
 
bool is_simple () const
 
const std::vector< std::size_t > & firstGeneration () const
 
std::vector< std::size_t >::const_iterator cbegin () const
 
std::vector< std::size_t >::const_iterator cend () const
 
std::size_t depth (std::size_t) const
 

Private Attributes

std::vector< std::size_t > m_parents
 
std::vector< std::vector< std::size_t > > m_children
 
std::vector< std::size_t > m_leaves
 
std::vector< std::size_t > m_firstGeneration
 

Detailed Description

Definition at line 18 of file Tree.h.

Constructor & Destructor Documentation

◆ Tree()

Tree::Tree ( const std::vector< std::size_t > &  parents)

Definition at line 8 of file Tree.cxx.

8  :
10  m_children(m_parents.size(),std::vector<std::size_t>()){
11  auto nParents = parents.size();
12 
13  // do not process node 0 to prevent inifinite loops
14  for(auto i = 1u; i < nParents; ++i){
15  m_children[m_parents[i]].push_back(i);
16  }
17 
18  auto nChildren = m_children.size();
19 
20  for(auto i = 0u; i < nChildren; ++i){
21  if(m_children[i].empty()){
22  m_leaves.push_back(i);
23  }
24  }
25 
26  for(auto i = 0u; i < nParents; ++i){
27  if (i == 0){continue;}
28  // tree numbering (tree[1] corresponds to Conditions[0]
29  if(parents[i] == 0){m_firstGeneration.push_back(i);}
30  }
31 }

Member Function Documentation

◆ cbegin()

std::vector<std::size_t>::const_iterator Tree::cbegin ( ) const
inline

Definition at line 33 of file Tree.h.

33  {
34  return m_parents.cbegin();
35  }

◆ cend()

std::vector<std::size_t>::const_iterator Tree::cend ( ) const
inline

Definition at line 38 of file Tree.h.

38  {
39  return m_parents.cend();
40  }

◆ depth()

std::size_t Tree::depth ( std::size_t  n) const

Definition at line 75 of file Tree.cxx.

75  {
76  std::size_t depth{0u};
77  while (n != 0){
78  n = m_parents[n];
79  ++depth;
80  }
81  return depth;
82 }

◆ firstGeneration()

const std::vector< std::size_t > & Tree::firstGeneration ( ) const

Definition at line 59 of file Tree.cxx.

59  {
60  return m_firstGeneration;
61 }

◆ is_leaf()

bool Tree::is_leaf ( size_t  ) const

Definition at line 52 of file Tree.cxx.

52  {
53  return std::find(m_leaves.begin(),
54  m_leaves.end(),
55  c) != m_leaves.end();
56 }

◆ is_simple()

bool Tree::is_simple ( ) const

Definition at line 64 of file Tree.cxx.

64  {
65  if (m_parents.empty()) {
66  return false;
67  } else {
68  return std::all_of(m_parents.begin(),
69  m_parents.end(),
70  [](const auto& e) {return e == 0;});
71  }
72 }

◆ leaves()

const std::vector< std::size_t > & Tree::leaves ( ) const

Definition at line 48 of file Tree.cxx.

48  {
49  return m_leaves;
50 }

◆ parent()

std::size_t Tree::parent ( std::size_t  k) const

Definition at line 34 of file Tree.cxx.

34  {
35  return m_parents[k];
36 }

◆ siblings()

std::vector< std::size_t > Tree::siblings ( std::size_t  k) const

Definition at line 39 of file Tree.cxx.

39  {
40  return m_children[parent(k)];
41 }

◆ size()

std::size_t Tree::size ( ) const

Definition at line 43 of file Tree.cxx.

43  {
44  return m_parents.size();
45 }

Member Data Documentation

◆ m_children

std::vector<std::vector<std::size_t> > Tree::m_children
private

Definition at line 48 of file Tree.h.

◆ m_firstGeneration

std::vector<std::size_t> Tree::m_firstGeneration
private

Definition at line 50 of file Tree.h.

◆ m_leaves

std::vector<std::size_t> Tree::m_leaves
private

Definition at line 49 of file Tree.h.

◆ m_parents

std::vector<std::size_t> Tree::m_parents
private

Definition at line 47 of file Tree.h.


The documentation for this class was generated from the following files:
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
python.DecayParser.parents
parents
print ("==> buf:",buf)
Definition: DecayParser.py:31
Tree::m_children
std::vector< std::vector< std::size_t > > m_children
Definition: Tree.h:48
empty
bool empty(TH1 *h)
Definition: computils.cxx:295
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
Tree::m_parents
std::vector< std::size_t > m_parents
Definition: Tree.h:47
Tree::depth
std::size_t depth(std::size_t) const
Definition: Tree.cxx:75
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
Tree::parent
std::size_t parent(std::size_t) const
Definition: Tree.cxx:34
Tree::m_leaves
std::vector< std::size_t > m_leaves
Definition: Tree.h:49
Tree::m_firstGeneration
std::vector< std::size_t > m_firstGeneration
Definition: Tree.h:50
python.compressB64.c
def c
Definition: compressB64.py:93
fitman.k
k
Definition: fitman.py:528