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