QwAnalysis
QwTracking::treenode Class Reference

A treenode contains the bits that make up a tree pattern. More...

#include <treenode.h>

+ Inheritance diagram for QwTracking::treenode:
+ Collaboration diagram for QwTracking::treenode:

Public Member Functions

 treenode (unsigned int size)
 Default constructor. More...
 
 treenode (treenode &node)
 Copy-constructor from object. More...
 
 treenode (treenode *node)
 Copy-constructor from pointer. More...
 
 ~treenode ()
 Destructor. More...
 
void SetNext (treenode *next)
 Set the next node. More...
 
treenodeGetNext () const
 Get the next node. More...
 
treenodenext () const
 Get the next node (non-standard notation) More...
 
unsigned int size () const
 Get size of the bit array. More...
 
void Print (bool recursive=false, int indent=0)
 Print some debugging information. More...
 
- Public Member Functions inherited from QwObjectCounter< treenode >
 QwObjectCounter ()
 Default constructor. More...
 
 QwObjectCounter (const QwObjectCounter &)
 Copy constructor. More...
 
virtual ~QwObjectCounter ()
 Destructor. More...
 

Data Fields

int fMinLevel
 Minimum level at which this node is valid. More...
 
int fMaxLevel
 Maximum level at which this node is valid. More...
 
int * fBit
 Hit pattern, one bin specified per detector layer. More...
 
int fWidth
 Width in bins of the hit pattern. More...
 
int fRef
 Reference of this node when writing to file. More...
 
nodenodefSon [4]
 Each tree has four son nodes. More...
 

Private Attributes

treenodefNext
 Link to the next tree node. More...
 
unsigned int fSize
 

Static Private Attributes

static int fDebug = 0
 Debug level. More...
 

Friends

std::ostream & operator<< (std::ostream &stream, const treenode &tn)
 Output stream operator. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from QwObjectCounter< treenode >
static size_t GetObjectsCreated ()
 Get number of objects ever created. More...
 
static size_t GetObjectsAlive ()
 Get number of objects still alive. More...
 

Detailed Description

A treenode contains the bits that make up a tree pattern.

This is the basic element of the tree search database when it is constructed. Each valid track has a corresponding tree node. The minimum and maximum levels of bin division are stored in the treenode.

The array fBit contains the rank of the bit that is active for this track. For example, a track that goes through (simplified) element 2 in layer 1, element 4 in layer 2, element 5 in layer 3, and element 7 in layer 4 will have the following fBit array: [2,4,6,7]. This example track will have a width of 7 - 2 + 1 = 6 (such that the track [2,2,2,2] has a width of 1).

The treenode also has a pointer to its father and a pointer to its son nodenodes. Each following generation of a treenode will have a higher bit resolution.

Definition at line 63 of file treenode.h.

Constructor & Destructor Documentation

QwTracking::treenode::treenode ( unsigned int  size)

Default constructor.

Default constructor

Parameters
sizeSize of the bit pattern

Definition at line 30 of file treenode.cc.

References fBit, fNext, fSize, fSon, and size().

31 {
32  // Set the size
33  fSize = size;
34  fBit = new int[fSize];
35  for (unsigned int i = 0; i < fSize; i++) fBit[i] = 0;
36 
37  // Initialize pointers
38  fNext = 0;
39  for (int i = 0; i < 4; i++) fSon[i] = 0;
40 }
nodenode * fSon[4]
Each tree has four son nodes.
Definition: treenode.h:95
unsigned int fSize
Definition: treenode.h:114
treenode * fNext
Link to the next tree node.
Definition: treenode.h:100
int * fBit
Hit pattern, one bin specified per detector layer.
Definition: treenode.h:84
unsigned int size() const
Get size of the bit array.
Definition: treenode.h:123

+ Here is the call graph for this function:

QwTracking::treenode::treenode ( treenode node)

Copy-constructor from object.

Copy-constructor from object

Parameters
nodeOriginal tree node

Definition at line 46 of file treenode.cc.

References fBit, fNext, fSize, and fSon.

47 {
48  // Copy the node
49  *this = node;
50 
51  // Copy the bit pattern
52  fBit = new int[fSize];
53  for (unsigned int i = 0; i < fSize; i++) fBit[i] = node.fBit[i];
54 
55  // Set the external reference link
56  this->fRef = -1L;
57 
58  // Initialize pointers
59  fNext = 0;
60  for (int i = 0; i < 4; i++) fSon[i] = 0;
61 }
nodenode * fSon[4]
Each tree has four son nodes.
Definition: treenode.h:95
unsigned int fSize
Definition: treenode.h:114
treenode * fNext
Link to the next tree node.
Definition: treenode.h:100
int * fBit
Hit pattern, one bin specified per detector layer.
Definition: treenode.h:84
QwTracking::treenode::treenode ( treenode node)

Copy-constructor from pointer.

Copy-constructor from pointer

Parameters
nodePointer to original tree node

Definition at line 67 of file treenode.cc.

References fBit, fNext, fSize, and fSon.

68 {
69  // Copy the node
70  *this = *node;
71 
72  // Copy the bit pattern
73  fBit = new int[fSize];
74  for (unsigned int i = 0; i < fSize; i++) fBit[i] = node->fBit[i];
75 
76  // Set the external reference link
77  this->fRef = -1L;
78 
79  // Initialize pointers
80  fNext = 0;
81  for (int i = 0; i < 4; i++) fSon[i] = 0;
82 }
nodenode * fSon[4]
Each tree has four son nodes.
Definition: treenode.h:95
unsigned int fSize
Definition: treenode.h:114
treenode * fNext
Link to the next tree node.
Definition: treenode.h:100
int * fBit
Hit pattern, one bin specified per detector layer.
Definition: treenode.h:84
QwTracking::treenode::~treenode ( )

Destructor.

Destructor

Definition at line 87 of file treenode.cc.

References fBit, and fSon.

88 {
89  // Delete the sons
90  for (int i = 0; i < 4; i++)
91  if (fSon[i]) delete fSon[i];
92 
93  // Delete the bit pattern
94  delete[] fBit;
95 }
nodenode * fSon[4]
Each tree has four son nodes.
Definition: treenode.h:95
int * fBit
Hit pattern, one bin specified per detector layer.
Definition: treenode.h:84

Member Function Documentation

treenode* QwTracking::treenode::GetNext ( ) const
inline

Get the next node.

Definition at line 112 of file treenode.h.

References fNext.

Referenced by QwTrackingTree::existent(), QwTrackingTree::PrintHashTable(), and QwTrackingTree::~QwTrackingTree().

112 { return fNext; };
treenode * fNext
Link to the next tree node.
Definition: treenode.h:100

+ Here is the caller graph for this function:

treenode* QwTracking::treenode::next ( ) const
inline

Get the next node (non-standard notation)

Definition at line 114 of file treenode.h.

References fNext.

Referenced by SetNext().

114 { return fNext; };
treenode * fNext
Link to the next tree node.
Definition: treenode.h:100

+ Here is the caller graph for this function:

void QwTracking::treenode::Print ( bool  recursive = false,
int  indent = 0 
)

Print some debugging information.

Print the entire tree (descending all the way down)

Warning
This will produce a lot of screen output!
Parameters
recursiveFlag to enable recursive calls
indentIndentation level (for recursive calls)

Definition at line 104 of file treenode.cc.

References QwLog::endl(), fSon, QwTracking::nodenode::GetTree(), Print(), QwOut, and QwWarning.

Referenced by Print(), and QwTrackingTree::PrintTree().

105 {
106  // Print this node
107  std::string indentation;
108  for (int i = 0; i < indent; i++) indentation += " ";
109  QwOut << indentation << this << ": " << *this << QwLog::endl;
110 
111  // Bail out if too deep (probably in a loop)
112  if (indent > 50) {
113  QwWarning << "Tree is too deep to print, probably a self-reference somewhere" << QwLog::endl;
114  return;
115  }
116 
117  // Descend to the sons of this node
118  for (int i = 0; recursive && i < 4; i++) {
119  nodenode* node = this->fSon[i];
120  if (node) {
121  treenode* tree = node->GetTree();
122  if (tree)
123  tree->Print(recursive,indent+1);
124  } // if (node)
125 
126  } // loop over sons
127 }
#define QwOut
Predefined log drain for explicit output.
Definition: QwLog.h:35
nodenode * fSon[4]
Each tree has four son nodes.
Definition: treenode.h:95
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
treenode(unsigned int size)
Default constructor.
Definition: treenode.cc:30
#define QwWarning
Predefined log drain for warnings.
Definition: QwLog.h:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwTracking::treenode::SetNext ( treenode next)
inline

Set the next node.

Definition at line 105 of file treenode.h.

References QwLog::endl(), fNext, next(), and QwError.

Referenced by QwTrackingTree::_inittree(), and QwTrackingTree::marklin().

105  {
106  if (next == this) {
107  QwError << "Trying to link next to self" << QwLog::endl; return;
108  }
109  fNext = next;
110  };
treenode * next() const
Get the next node (non-standard notation)
Definition: treenode.h:114
treenode * fNext
Link to the next tree node.
Definition: treenode.h:100
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int QwTracking::treenode::size ( ) const
inline

Get size of the bit array.

Definition at line 123 of file treenode.h.

References fSize.

Referenced by QwTrackingTree::QwTrackingTree(), and treenode().

123 { return fSize; };
unsigned int fSize
Definition: treenode.h:114

+ Here is the caller graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  stream,
const treenode tn 
)
friend

Output stream operator.

Stream summary info about the tree node

Parameters
streamStream as lhs of the operator
tnTree node as rhs of the operator
Returns
Stream as result of the operator

Definition at line 135 of file treenode.cc.

136 {
137  stream << "(" << tn.fMinLevel << "," << tn.fMaxLevel << ") ";
138  for (unsigned int i = 0; i < tn.fSize; i++)
139  stream << tn.fBit[i] << ",";
140  stream << " width = " << tn.fWidth << ",";
141  stream << " ref = " << tn.fRef;
142  return stream;
143 }

Field Documentation

int* QwTracking::treenode::fBit
int QwTracking::treenode::fDebug = 0
staticprivate

Debug level.

Definition at line 123 of file treenode.h.

int QwTracking::treenode::fMaxLevel

Maximum level at which this node is valid.

Definition at line 81 of file treenode.h.

Referenced by QwTrackingTree::marklin(), QwTracking::operator<<(), and QwTrackingTree::QwTrackingTree().

int QwTracking::treenode::fMinLevel

Minimum level at which this node is valid.

Definition at line 79 of file treenode.h.

Referenced by QwTrackingTree::_writetree(), QwTrackingTree::marklin(), QwTracking::operator<<(), and QwTrackingTree::QwTrackingTree().

treenode* QwTracking::treenode::fNext
private

Link to the next tree node.

Definition at line 100 of file treenode.h.

Referenced by GetNext(), next(), SetNext(), and treenode().

int QwTracking::treenode::fRef

Reference of this node when writing to file.

Definition at line 90 of file treenode.h.

Referenced by QwTrackingTree::_writetree(), QwTracking::operator<<(), and QwTrackingTree::QwTrackingTree().

unsigned int QwTracking::treenode::fSize
private

Definition at line 114 of file treenode.h.

Referenced by QwTracking::operator<<(), size(), and treenode().

nodenode* QwTracking::treenode::fSon[4]

Each tree has four son nodes.

Definition at line 95 of file treenode.h.

Referenced by QwTrackingTree::_writetree(), QwTrackingTree::marklin(), Print(), treenode(), and ~treenode().

int QwTracking::treenode::fWidth

Width in bins of the hit pattern.

Definition at line 87 of file treenode.h.

Referenced by QwTrackingTree::_writetree(), QwTrackingTree::marklin(), QwTracking::operator<<(), and QwTrackingTree::QwTrackingTree().


The documentation for this class was generated from the following files: