Logo ROOT   6.08/07
Reference Guide
BinarySearchTreeNode.h
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Classes: Node, NodeID *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Node for the BinarySearch *
12  * *
13  * Authors (alphabetical): *
14  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
15  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
16  * Kai Voss <Kai.Voss@cern.ch> - U. of Victoria, Canada *
17  * *
18  * Copyright (c) 2005: *
19  * CERN, Switzerland *
20  * U. of Victoria, Canada *
21  * MPI-K Heidelberg, Germany *
22  * LAPP, Annecy, France *
23  * *
24  * Redistribution and use in source and binary forms, with or without *
25  * modification, are permitted according to the terms listed in LICENSE *
26  * (http://tmva.sourceforge.net/LICENSE) *
27  **********************************************************************************/
28 
29 #ifndef ROOT_TMVA_BinarySearchTreeNode
30 #define ROOT_TMVA_BinarySearchTreeNode
31 
32 //////////////////////////////////////////////////////////////////////////
33 // //
34 // BinarySearchTreeNode //
35 // //
36 // Node for the BinarySearch Tree //
37 // //
38 //////////////////////////////////////////////////////////////////////////
39 
40 #include <iosfwd>
41 #include <vector>
42 #ifndef ROOT_Rtypes
43 #include "Rtypes.h"
44 #endif
45 
46 #ifndef ROOT_TMVA_Node
47 #include "TMVA/Node.h"
48 #endif
49 
50 namespace TMVA {
51 
52  class Event;
53 
54  // a class used to identify a Node; (needed for recursive reading from text file)
55  // (currently it is NOT UNIQUE... but could eventually made it
56  // a node in the tree structure
57  class BinarySearchTreeNode : public Node {
58 
59  public:
60 
61  // constructor of a node for the search tree
62  BinarySearchTreeNode( const Event* e = NULL, UInt_t signalClass=0 );
63 
64  // constructor of a daughter node as a daughter of 'p'
65  BinarySearchTreeNode( BinarySearchTreeNode* parent, char pos );
66 
67  // copy constructor
69  BinarySearchTreeNode* parent = NULL);
70 
71  // destructor
72  virtual ~BinarySearchTreeNode ();
73 
74  virtual Node* CreateNode() const { return new BinarySearchTreeNode(); }
75 
76  // test event if it decends the tree at this node to the right
77  virtual Bool_t GoesRight( const Event& ) const;
78  // test event if it decends the tree at this node to the left
79 
80  virtual Bool_t GoesLeft ( const Event& ) const;
81  // test event if it is equal to the event that "makes the node" (just for the "search tree"
82 
83  virtual Bool_t EqualsMe ( const Event& ) const;
84 
85  // set index of variable used for discrimination at this node
86  inline void SetSelector( Short_t i) { fSelector = i; }
87  // return index of variable used for discrimination at this node
88  inline Short_t GetSelector() const { return fSelector; }
89 
90  const std::vector<Float_t> & GetEventV() const { return fEventV; }
91  Float_t GetWeight() const { return fWeight; }
92  UInt_t GetClass() const { return fClass; }
93  // Bool_t IsSignal() const { return (fClass == fSignalClass); }
94 
95  const std::vector<Float_t> & GetTargets() const { return fTargets; }
96 
97 
98  // printout of the node
99  virtual void Print( std::ostream& os ) const;
100 
101  // recursive printout of the node and it daughters
102  virtual void PrintRec( std::ostream& os ) const;
103 
104  virtual void AddAttributesToNode(void* node) const;
105  virtual void AddContentToNode(std::stringstream& s) const;
106 
107  private:
108  // Read the data block
109  virtual void ReadAttributes(void* node, UInt_t tmva_Version_Code = TMVA_VERSION_CODE );
110  virtual Bool_t ReadDataRecord( std::istream& is, UInt_t tmva_Version_Code = TMVA_VERSION_CODE );
111  virtual void ReadContent(std::stringstream& s);
112  std::vector<Float_t> fEventV;
113  std::vector<Float_t> fTargets;
114 
117 
118  Short_t fSelector; // index of variable used in node selection (decision tree)
119 
120  ClassDef(BinarySearchTreeNode,0); // Node for the BinarySearchTree
121  };
122 
123 } // namespace TMVA
124 
125 #endif
virtual void PrintRec(std::ostream &os) const
recursively print the node and its daughters (–> print the &#39;tree&#39;)
virtual Bool_t GoesRight(const Event &) const
check if the event fed into the node goes/decends to the right daughter
virtual Bool_t GoesLeft(const Event &) const
check if the event fed into the node goes/decends to the left daughter
#define TMVA_VERSION_CODE
Definition: Version.h:47
float Float_t
Definition: RtypesCore.h:53
std::vector< Float_t > fTargets
bool Bool_t
Definition: RtypesCore.h:59
virtual Bool_t ReadDataRecord(std::istream &is, UInt_t tmva_Version_Code=TMVA_VERSION_CODE)
Read the data block.
#define ClassDef(name, id)
Definition: Rtypes.h:254
std::vector< Float_t > fEventV
virtual void AddContentToNode(std::stringstream &s) const
adding attributes to tree node
virtual ~BinarySearchTreeNode()
node destructor
virtual void ReadAttributes(void *node, UInt_t tmva_Version_Code=TMVA_VERSION_CODE)
read attributes from XML
unsigned int UInt_t
Definition: RtypesCore.h:42
short Short_t
Definition: RtypesCore.h:35
virtual Node * CreateNode() const
virtual void AddAttributesToNode(void *node) const
adding attributes to tree node
virtual Bool_t EqualsMe(const Event &) const
check if the event fed into the node actually equals the event that forms the node (in case of a sear...
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
BinarySearchTreeNode(const Event *e=NULL, UInt_t signalClass=0)
constructor of a node for the search tree
const std::vector< Float_t > & GetEventV() const
Abstract ClassifierFactory template that handles arbitrary types.
virtual void Print(std::ostream &os) const
print the node
#define NULL
Definition: Rtypes.h:82
const Int_t n
Definition: legend1.C:16
virtual void ReadContent(std::stringstream &s)
read events from node
const std::vector< Float_t > & GetTargets() const