QwAnalysis
QwTrackingTreeRegion.cc
Go to the documentation of this file.
1 /**
2  * \file QwTrackingTreeRegion.cc
3  * \ingroup QwTracking
4  *
5  * \author Burnham Stokes <bestokes@jlab.org>
6  * \author Wouter Deconinck <wdconinc@jlab.org>
7  * \date 2009-09-04 18:06:23
8  *
9  * \brief Implementation of the container for the pattern databases for each detector region.
10  *
11  * It is useful to separate the pattern database into multiple detector regions
12  * to reduce the extent by which a set of hits are compared to a pattern.
13  * For instance, there are two databases for the region 3 set of detectors.
14  * One for the 'upper' and one for the 'lower' detector sets. Track segments
15  * in the area downstream of the QTOR magnet are approximated by straight lines.
16  * Only the VDC is designed to measure track positions, so these two databases
17  * designed to contain patterns which ressemble tracks passing through the VDC.
18  *
19  */
20 
21 #include "QwTrackingTreeRegion.h"
22 
23 // Qweak headers
24 #include "QwLog.h"
25 #include "shortnode.h"
26 #include "shorttree.h"
27 
28 /**
29  * Destructor
30  */
32 {
33  // Debug information
34  QwDebug << "Deleting QwTrackingTreeRegion: " << this << QwLog::endl;
35 
36  // First, delete the nodes by going through the list of trees and following
37  // implicitly the linked list of next pointers without branching out through
38  // the tree pointers
39  QwDebug << "Deleting linked lists of node objects..." << QwLog::endl;
40  for (int i = 0; i < fNode.GetNumberOfTrees(); i++)
41  for (int j = 0; j < 4; j++)
42  if (fNode.GetTree(i)->son[j]) {
43  delete fNode.GetTree(i)->son[j];
44  fNode.GetTree(i)->son[j] = 0;
45  }
46 
47  // Then delete the remaining flat list of trees
48  QwDebug << "Deleting flat list of tree objects..." << QwLog::endl;
49  delete[] fNode.GetTree();
50 
51  // Report memory statistics
52  if (shortnode::GetObjectsAlive() > 0 || shorttree::GetObjectsAlive() > 0) {
53  QwVerbose << "Memory occupied by tree objects (should be a single shortnode when all trees cleared):" << QwLog::endl;
54  QwVerbose << "- allocated shortnode objects: " << shortnode::GetObjectsAlive() << QwLog::endl;
55  QwVerbose << "- allocated shorttree objects: " << shorttree::GetObjectsAlive() << QwLog::endl;
56  }
57 }
58 
59 
60 /**
61  * Print the list of trees
62  */
64 {
65  QwOut << "Trees:" << QwLog::endl;
66  for (int i = 0; i < 1 /* fNode.GetNumberOfTrees() */; i++) {
67  QwOut << "tree " << i << ": ";
68  fNode.GetTree(i)->Print(true,1);
69  }
70 }
71 
72 
73 /**
74  * Print the list of nodes
75  */
77 {
78  QwOut << "Nodes:" << QwLog::endl;
79  for (int i = 0; i < fNode.GetNumberOfTrees(); i++) {
80  QwOut << "tree " << i << ":" << QwLog::endl;
81  fNode.GetTree(i)->Print(false,1);
82  for (int j = 0; j < 4; j++) {
83  shortnode* node = fNode.GetTree(i)->son[j];
84  if (node) QwOut << " son " << j << ":" << QwLog::endl;
85  while (node) {
86  QwOut << " tree ";
87  node->GetTree(0)->Print(false,2);
88  node = node->GetNext();
89  } // loop over linked list of nodes
90  } // loop over the four sons
91  } // loop over list of trees
92 }
#define QwOut
Predefined log drain for explicit output.
Definition: QwLog.h:35
void PrintTrees() const
Print the list of trees.
void Print(bool recursive=false, int indent=0)
Print some debugging information.
Definition: shorttree.cc:61
void PrintNodes() const
Print the list of nodes.
#define QwVerbose
Predefined log drain for verbose messages.
Definition: QwLog.h:55
#define QwDebug
Predefined log drain for debugging output.
Definition: QwLog.h:60
int GetNumberOfTrees() const
Get the number of trees.
Definition: shortnode.h:81
A logfile class, based on an identical class in the Hermes analyzer.
shortnode * son[4]
Each tree has four son nodes.
Definition: shorttree.h:72
virtual ~QwTrackingTreeRegion()
Destructor.
shorttree * GetTree(int i=0) const
Get the tree.
Definition: shortnode.cc:54
Definition of a shortnode, the short version of a nodenode.
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
shortnode * GetNext() const
Get the next node.
Definition: shortnode.h:69
Similar to a nodenode.
Definition: shortnode.h:38
shortnode fNode
Top node of this tree region.