QwAnalysis
treenode.h
Go to the documentation of this file.
1 /*------------------------------------------------------------------------*//*!
2 
3  \file treenode.h
4  \ingroup QwTracking
5 
6  \author Wolfgang Wander <wwc@hermes.desy.de>
7  \author Burnham Stokes <bestokes@jlab.org>
8  \author Wouter Deconinck <wdconinc@mit.edu>
9 
10  \date 2009-09-04 18:06:23
11 
12  \brief Definition of a treenode which contains the bits that make up a tree pattern
13 
14 *//*-------------------------------------------------------------------------*/
15 
16 #ifndef QWTRACKINGTREENODE_H
17 #define QWTRACKINGTREENODE_H
18 
19 // System headers
20 #include <iostream>
21 
22 // Qweak headers
23 #include "QwLog.h"
24 #include "QwObjectCounter.h"
25 
26 /**
27  * \namespace QwTracking
28  *
29  * \brief Contains tracking-related objects
30  *
31  * The namespace QwTracking contains the classes related to the pattern
32  * recognition algorithm and the tree search. This includes the objects
33  * treenode, nodenode, shorttree, shortnode, and treeregion.
34  *
35  */
36 namespace QwTracking {
37 
38 
39 // Forward declaration due to cyclic dependency
40 class nodenode;
41 
42 /**
43  * \class treenode
44  *
45  * \ingroup QwTracking
46  *
47  * \brief A treenode contains the bits that make up a tree pattern.
48  *
49  * This is the basic element of the tree search database when it is
50  * constructed. Each valid track has a corresponding tree node. The
51  * minimum and maximum levels of bin division are stored in the treenode.
52  *
53  * The array fBit contains the rank of the bit that is active for this track.
54  * For example, a track that goes through (simplified) element 2 in layer 1,
55  * element 4 in layer 2, element 5 in layer 3, and element 7 in layer 4 will
56  * have the following fBit array: [2,4,6,7]. This example track will have a
57  * width of 7 - 2 + 1 = 6 (such that the track [2,2,2,2] has a width of 1).
58  *
59  * The treenode also has a pointer to its father and a pointer to its
60  * son nodenodes. Each following generation of a treenode will have
61  * a higher bit resolution.
62  */
63 class treenode: public QwObjectCounter<treenode> {
64 
65  public:
66 
67  /// \brief Default constructor
68  treenode(unsigned int size);
69  /// \brief Copy-constructor from object
70  treenode(treenode& node);
71  /// \brief Copy-constructor from pointer
72  treenode(treenode* node);
73  /// \brief Destructor
74  ~treenode();
75 
76  public:
77 
78  /// Minimum level at which this node is valid
79  int fMinLevel;
80  /// Maximum level at which this node is valid
81  int fMaxLevel;
82 
83  /// Hit pattern, one bin specified per detector layer
84  int* fBit;
85 
86  /// Width in bins of the hit pattern
87  int fWidth;
88 
89  /// Reference of this node when writing to file
90  int fRef;
91 
92  public: // TODO Too many low-level calls to hide this behind a getter
93 
94  /// Each tree has four son nodes
96 
97  private:
98 
99  /// Link to the next tree node
101 
102  public:
103 
104  /// Set the next node
106  if (next == this) {
107  QwError << "Trying to link next to self" << QwLog::endl; return;
108  }
109  fNext = next;
110  };
111  /// Get the next node
112  treenode* GetNext() const { return fNext; };
113  /// Get the next node (non-standard notation)
114  treenode* next() const { return fNext; };
115 
116  private:
117 
118  unsigned int fSize;
119 
120  public:
121 
122  /// Get size of the bit array
123  unsigned int size() const { return fSize; };
124 
125  private:
126 
127  static int fDebug; ///< Debug level
128 
129  public:
130 
131  /// \brief Print some debugging information
132  void Print(bool recursive = false, int indent = 0);
133  /// \brief Output stream operator
134  friend std::ostream& operator<< (std::ostream& stream, const treenode& tn);
135 
136 }; // class treenode
137 
138 } // namespace QwTracking
139 
140 #endif // QWTRACKINGTREENODE_H
treenode * next() const
Get the next node (non-standard notation)
Definition: treenode.h:114
static int fDebug
Debug level.
Definition: treenode.h:123
Memory management structure to count objects.
void Print(bool recursive=false, int indent=0)
Print some debugging information.
Definition: treenode.cc:104
int fMinLevel
Minimum level at which this node is valid.
Definition: treenode.h:79
int fWidth
Width in bins of the hit pattern.
Definition: treenode.h:87
int fRef
Reference of this node when writing to file.
Definition: treenode.h:90
A logfile class, based on an identical class in the Hermes analyzer.
nodenode * fSon[4]
Each tree has four son nodes.
Definition: treenode.h:95
Memory management class to count object instantiations.
unsigned int fSize
Definition: treenode.h:114
void SetNext(treenode *next)
Set the next node.
Definition: treenode.h:105
treenode * fNext
Link to the next tree node.
Definition: treenode.h:100
treenode * GetNext() const
Get the next node.
Definition: treenode.h:112
int * fBit
Hit pattern, one bin specified per detector layer.
Definition: treenode.h:84
~treenode()
Destructor.
Definition: treenode.cc:87
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
treenode(unsigned int size)
Default constructor.
Definition: treenode.cc:30
int fMaxLevel
Maximum level at which this node is valid.
Definition: treenode.h:81
friend std::ostream & operator<<(std::ostream &stream, const treenode &tn)
Output stream operator.
Definition: treenode.cc:135
unsigned int size() const
Get size of the bit array.
Definition: treenode.h:123
A nodenode is used as a pointer which links treenodes to their siblings.
Definition: nodenode.h:42
A treenode contains the bits that make up a tree pattern.
Definition: treenode.h:63
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40