Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 * *
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 * (see tmva/doc/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 = nullptr, 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 = nullptr);
68
69 // destructor
70 virtual ~BinarySearchTreeNode ();
71
72 virtual Node* CreateNode() const { return new BinarySearchTreeNode(); }
73
74 // test event if it descends the tree at this node to the right
75 virtual Bool_t GoesRight( const Event& ) const;
76 // test event if it descends 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
92 const std::vector<Float_t> & GetTargets() const { return fTargets; }
93
94
95 // printout of the node
96 virtual void Print( std::ostream& os ) const;
97
98 // recursive printout of the node and it daughters
99 virtual void PrintRec( std::ostream& os ) const;
100
101 virtual void AddAttributesToNode(void* node) const;
102 virtual void AddContentToNode(std::stringstream& s) const;
103
104 // Read the data block
105 virtual Bool_t ReadDataRecord( std::istream& is, UInt_t tmva_Version_Code = TMVA_VERSION_CODE );
106 virtual void ReadAttributes(void* node, UInt_t tmva_Version_Code = TMVA_VERSION_CODE );
107 virtual void ReadContent(std::stringstream& s);
108
109 private:
110 std::vector<Float_t> fEventV;
111 std::vector<Float_t> fTargets;
112
115
116 Short_t fSelector; ///< index of variable used in node selection (decision tree)
117
118 ClassDef(BinarySearchTreeNode,0); ///< Node for the BinarySearchTree
119 };
120
121} // namespace TMVA
122
123#endif
#define e(i)
Definition RSha256.hxx:103
bool Bool_t
Definition RtypesCore.h:63
unsigned int UInt_t
Definition RtypesCore.h:46
float Float_t
Definition RtypesCore.h:57
short Short_t
Definition RtypesCore.h:39
#define ClassDef(name, id)
Definition Rtypes.h:337
#define TMVA_VERSION_CODE
Definition Version.h:47
Node for the BinarySearch or Decision Trees.
virtual Bool_t ReadDataRecord(std::istream &is, UInt_t tmva_Version_Code=262657)
Read the data block.
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
Short_t fSelector
index of variable used in node selection (decision tree)
virtual void ReadAttributes(void *node, UInt_t tmva_Version_Code=262657)
read attributes from XML
const std::vector< Float_t > & GetTargets() const
void SetSelector(Short_t i)
set index of variable used for discrimination at this node
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
Short_t GetSelector() const
return index of variable used for discrimination at this node
virtual void AddContentToNode(std::stringstream &s) const
adding attributes to tree node
virtual Node * CreateNode() const
Node for the BinarySearch or Decision Trees.
Definition Node.h:58
const Int_t n
Definition legend1.C:16
create variable transformations