QwAnalysis
QwTracking::shorttree Class Reference

Similar to a treenode. More...

#include <shorttree.h>

+ Inheritance diagram for QwTracking::shorttree:
+ Collaboration diagram for QwTracking::shorttree:

Public Member Functions

 shorttree (unsigned int size=fDefaultSize)
 Default constructor. More...
 
 ~shorttree ()
 Destructor. 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< shorttree >
 QwObjectCounter ()
 Default constructor. More...
 
 QwObjectCounter (const QwObjectCounter &)
 Copy constructor. More...
 
virtual ~QwObjectCounter ()
 Destructor. More...
 

Static Public Member Functions

static void SetDefaultSize (unsigned int size)
 Set the default size for short trees. More...
 
- Static Public Member Functions inherited from QwObjectCounter< shorttree >
static size_t GetObjectsCreated ()
 Get number of objects ever created. More...
 
static size_t GetObjectsAlive ()
 Get number of objects still alive. More...
 

Data Fields

int fMinLevel
 Minimum 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...
 
shortnodeson [4]
 Each tree has four son nodes. More...
 

Private Attributes

unsigned int fSize
 

Static Private Attributes

static unsigned int fDefaultSize = MAX_LAYERS
 Default size. More...
 
static int fDebug = 0
 Debug level. More...
 

Friends

std::ostream & operator<< (std::ostream &stream, const shorttree &st)
 Output stream operator. More...
 

Detailed Description

Similar to a treenode.

A shorttree is basically the same as a treenode. It contains the minimum level of bin division where the bit pattern is valid, the bit pattern in the array fBit, and the width of the pattern.

The difference with the treenode is that there is only a link fSon to the son nodes, no link to the next shorttree. This is because a shorttree is read from file and reconstructing that linkage information is expensive, and not necessary.

Definition at line 44 of file shorttree.h.

Constructor & Destructor Documentation

QwTracking::shorttree::shorttree ( unsigned int  size = fDefaultSize)

Default constructor.

Default constructor, initializes the son pointer to null

Parameters
sizeSize of the bit pattern

Definition at line 37 of file shorttree.cc.

References fBit, fSize, size(), and son.

38 {
39  // Set the size
40  fSize = size;
41  fBit = new int[fSize];
42  for (unsigned int i = 0; i < fSize; i++) fBit[i] = 0;
43 
44  // Initialize pointers
45  for (int i = 0; i < 4; i++)
46  son[i] = 0;
47 }
unsigned int size() const
Get size of the bit array.
Definition: shorttree.h:81
int * fBit
Hit pattern, one bin specified per detector layer.
Definition: shorttree.h:64
unsigned int fSize
Definition: shorttree.h:76
shortnode * son[4]
Each tree has four son nodes.
Definition: shorttree.h:72

+ Here is the call graph for this function:

QwTracking::shorttree::~shorttree ( )

Destructor.

Destructor deletes the memory occupied by the sons

Definition at line 52 of file shorttree.cc.

References fBit.

53 {
54  // Delete the bit pattern
55  delete[] fBit;
56 }
int * fBit
Hit pattern, one bin specified per detector layer.
Definition: shorttree.h:64

Member Function Documentation

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

Print some debugging information.

Print some debugging information

Definition at line 61 of file shorttree.cc.

References QwLog::endl(), fBit, fMinLevel, fSize, QwTracking::shortnode::Print(), QwOut, and son.

Referenced by QwTrackingTreeSearch::_SearchTreeLines(), QwTracking::shortnode::Print(), QwTrackingTreeRegion::PrintNodes(), and QwTrackingTreeRegion::PrintTrees().

62 {
63  // Print this node
64  std::string indentation;
65  for (int i = 0; i < indent; i++) indentation += " ";
66  QwOut << this << ": " << *this << QwLog::endl;
67  // Bit pattern
68  for (unsigned int i = 0; i < fSize; i++) {
69  QwOut << indentation;
70  for (int j = 0; j < (1 << (fMinLevel + 1)); j++) {
71  if (j == fBit[i]) QwOut << "|";
72  else QwOut << ".";
73  }
74  QwOut << QwLog::endl;
75  }
76 
77  // Descend to the sons of this node
78  for (int i = 0; recursive && i < 4; i++) {
79  shortnode* node = this->son[i];
80  if (node) {
81  QwOut << indentation << "son " << i << ": ";
82  node->Print(recursive,indent+1);
83  }
84  }
85 }
int * fBit
Hit pattern, one bin specified per detector layer.
Definition: shorttree.h:64
#define QwOut
Predefined log drain for explicit output.
Definition: QwLog.h:35
unsigned int fSize
Definition: shorttree.h:76
int fMinLevel
Minimum level at which this node is valid.
Definition: shorttree.h:61
shortnode * son[4]
Each tree has four son nodes.
Definition: shorttree.h:72
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void QwTracking::shorttree::SetDefaultSize ( unsigned int  size)
inlinestatic

Set the default size for short trees.

Definition at line 49 of file shorttree.h.

References fDefaultSize, and size().

49  {
51  }
unsigned int size() const
Get size of the bit array.
Definition: shorttree.h:81
static unsigned int fDefaultSize
Default size.
Definition: shorttree.h:81

+ Here is the call graph for this function:

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

Get size of the bit array.

Definition at line 81 of file shorttree.h.

References fSize.

Referenced by SetDefaultSize(), and shorttree().

81 { return fSize; };
unsigned int fSize
Definition: shorttree.h:76

+ Here is the caller graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  stream,
const shorttree st 
)
friend

Output stream operator.

Stream some info about the short tree

Parameters
streamStream as lhs of the operator
stShort tree as rhs of the operator
Returns
Stream as result of the operator

Definition at line 93 of file shorttree.cc.

94 {
95  stream << "(" << st.fMinLevel << "," << "*" << ") ";
96  for (unsigned int i = 0; i < st.fSize; i++)
97  stream << st.fBit[i] << ",";
98  stream << " width = " << st.fWidth;
99  return stream;
100 }

Field Documentation

int* QwTracking::shorttree::fBit

Hit pattern, one bin specified per detector layer.

Definition at line 64 of file shorttree.h.

Referenced by QwTrackingTreeSearch::_SearchTreeLines(), QwTracking::operator<<(), Print(), shorttree(), and ~shorttree().

int QwTracking::shorttree::fDebug = 0
staticprivate

Debug level.

Definition at line 87 of file shorttree.h.

unsigned int QwTracking::shorttree::fDefaultSize = MAX_LAYERS
staticprivate

Default size.

Definition at line 81 of file shorttree.h.

Referenced by SetDefaultSize().

int QwTracking::shorttree::fMinLevel

Minimum level at which this node is valid.

Definition at line 61 of file shorttree.h.

Referenced by QwTrackingTreeSearch::_SearchTreeLines(), QwTracking::operator<<(), and Print().

unsigned int QwTracking::shorttree::fSize
private

Definition at line 76 of file shorttree.h.

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

int QwTracking::shorttree::fWidth

Width in bins of the hit pattern.

Definition at line 67 of file shorttree.h.

Referenced by QwTracking::operator<<().

shortnode* QwTracking::shorttree::son[4]

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