Logo ROOT  
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#include <string>
43#include <sstream>
44#include "Rtypes.h"
45
46#include "TMVA/Node.h"
47
48namespace TMVA {
49
50 class Event;
51
52 // a class used to identify a Node; (needed for recursive reading from text file)
53 // (currently it is NOT UNIQUE... but could eventually made it
54 // a node in the tree structure
55 class BinarySearchTreeNode : public Node {
56
57 public:
58
59 // constructor of a node for the search tree
60 BinarySearchTreeNode( const Event* e = NULL, UInt_t signalClass=0 );
61
62 // constructor of a daughter node as a daughter of 'p'
63 BinarySearchTreeNode( BinarySearchTreeNode* parent, char pos );
64
65 // copy constructor
67 BinarySearchTreeNode* parent = NULL);
68
69 // destructor
70 virtual ~BinarySearchTreeNode ();
71
72 virtual Node* CreateNode() const { return new BinarySearchTreeNode(); }
73
74 // test event if it decends the tree at this node to the right
75 virtual Bool_t GoesRight( const Event& ) const;
76 // test event if it decends the tree at this node to the left
77
78 virtual Bool_t GoesLeft ( const Event& ) const;
79 // test event if it is equal to the event that "makes the node" (just for the "search tree"
80
81 virtual Bool_t EqualsMe ( const Event& ) const;
82
83 // set index of variable used for discrimination at this node
84 inline void SetSelector( Short_t i) { fSelector = i; }
85 // return index of variable used for discrimination at this node
86 inline Short_t GetSelector() const { return fSelector; }
87
88 const std::vector<Float_t> & GetEventV() const { return fEventV; }
89 Float_t GetWeight() const { return fWeight; }
90 UInt_t GetClass() const { return fClass; }
91 // Bool_t IsSignal() const { return (fClass == fSignalClass); }
92
93 const std::vector<Float_t> & GetTargets() const { return fTargets; }
94
95
96 // printout of the node
97 virtual void Print( std::ostream& os ) const;
98
99 // recursive printout of the node and it daughters
100 virtual void PrintRec( std::ostream& os ) const;
101
102 virtual void AddAttributesToNode(void* node) const;
103 virtual void AddContentToNode(std::stringstream& s) const;
104
105 // Read the data block
106 virtual Bool_t ReadDataRecord( std::istream& is, UInt_t tmva_Version_Code = TMVA_VERSION_CODE );
107 virtual void ReadAttributes(void* node, UInt_t tmva_Version_Code = TMVA_VERSION_CODE );
108 virtual void ReadContent(std::stringstream& s);
109
110 private:
111 std::vector<Float_t> fEventV;
112 std::vector<Float_t> fTargets;
113
116
117 Short_t fSelector; // index of variable used in node selection (decision tree)
118
119 ClassDef(BinarySearchTreeNode,0); // Node for the BinarySearchTree
120 };
121
122} // namespace TMVA
123
124#endif
#define e(i)
Definition: RSha256.hxx:103
unsigned int UInt_t
Definition: RtypesCore.h:46
bool Bool_t
Definition: RtypesCore.h:63
short Short_t
Definition: RtypesCore.h:39
float Float_t
Definition: RtypesCore.h:57
#define ClassDef(name, id)
Definition: Rtypes.h:325
#define TMVA_VERSION_CODE
Definition: Version.h:47
Node for the BinarySearch or Decision Trees.
std::vector< Float_t > fTargets
virtual void PrintRec(std::ostream &os) const
recursively print the node and its daughters (--> print the 'tree')
std::vector< Float_t > fEventV
virtual void ReadContent(std::stringstream &s)
read events from node
virtual Bool_t GoesLeft(const Event &) const
check if the event fed into the node goes/descends to the left daughter
virtual ~BinarySearchTreeNode()
node destructor
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...
virtual void Print(std::ostream &os) const
print the node
virtual void AddAttributesToNode(void *node) const
adding attributes to tree node
virtual void ReadAttributes(void *node, UInt_t tmva_Version_Code=TMVA_VERSION_CODE)
read attributes from XML
const std::vector< Float_t > & GetTargets() const
BinarySearchTreeNode(const Event *e=NULL, UInt_t signalClass=0)
constructor of a node for the search tree
const std::vector< Float_t > & GetEventV() const
virtual Bool_t GoesRight(const Event &) const
check if the event fed into the node goes/descends to the right daughter
virtual void AddContentToNode(std::stringstream &s) const
adding attributes to tree node
virtual Node * CreateNode() const
virtual Bool_t ReadDataRecord(std::istream &is, UInt_t tmva_Version_Code=TMVA_VERSION_CODE)
Read the data block.
Node for the BinarySearch or Decision Trees.
Definition: Node.h:58
const Int_t n
Definition: legend1.C:16
static constexpr double s
create variable transformations