BinarySearchTreeNode.h

Go to the documentation of this file.
00001 // @(#)root/tmva $Id: BinarySearchTreeNode.h 33928 2010-06-15 16:19:31Z stelzer $    
00002 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss 
00003 
00004 /**********************************************************************************
00005  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
00006  * Package: TMVA                                                                  *
00007  * Classes: Node, NodeID                                                          *
00008  * Web    : http://tmva.sourceforge.net                                           *
00009  *                                                                                *
00010  * Description:                                                                   *
00011  *      Node for the BinarySearch                                                 *
00012  *                                                                                *
00013  * Authors (alphabetical):                                                        *
00014  *      Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland              *
00015  *      Helge Voss      <Helge.Voss@cern.ch>     - MPI-K Heidelberg, Germany      *
00016  *      Kai Voss        <Kai.Voss@cern.ch>       - U. of Victoria, Canada         *
00017  *                                                                                *
00018  * Copyright (c) 2005:                                                            *
00019  *      CERN, Switzerland                                                         * 
00020  *      U. of Victoria, Canada                                                    * 
00021  *      MPI-K Heidelberg, Germany                                                 * 
00022  *      LAPP, Annecy, France                                                      *
00023  *                                                                                *
00024  * Redistribution and use in source and binary forms, with or without             *
00025  * modification, are permitted according to the terms listed in LICENSE           *
00026  * (http://tmva.sourceforge.net/LICENSE)                                          *
00027  **********************************************************************************/
00028 
00029 #ifndef ROOT_TMVA_BinarySearchTreeNode
00030 #define ROOT_TMVA_BinarySearchTreeNode
00031 
00032 //////////////////////////////////////////////////////////////////////////
00033 //                                                                      //
00034 // BinarySearchTreeNode                                                 //
00035 //                                                                      //
00036 // Node for the BinarySearch  Tree                                      //
00037 //                                                                      //
00038 //////////////////////////////////////////////////////////////////////////
00039 
00040 #include <iosfwd>
00041 #include <vector>
00042 #ifndef ROOT_Rtypes
00043 #include "Rtypes.h"
00044 #endif
00045 
00046 #ifndef ROOT_TMVA_Node
00047 #include "TMVA/Node.h"
00048 #endif
00049 
00050 namespace TMVA {
00051 
00052    class Event;
00053 
00054    // a class used to identify a Node; (needed for recursive reading from text file)
00055    // (currently it is NOT UNIQUE... but could eventually made it
00056    // a node in the tree structure
00057    class BinarySearchTreeNode : public Node  {
00058 
00059    public:
00060 
00061       // constructor of a node for the search tree
00062       BinarySearchTreeNode( const Event* e = NULL );
00063 
00064       // constructor of a daughter node as a daughter of 'p'
00065       BinarySearchTreeNode( BinarySearchTreeNode* parent, char pos );
00066 
00067       // copy constructor
00068       BinarySearchTreeNode ( const BinarySearchTreeNode &n, 
00069                              BinarySearchTreeNode* parent = NULL);
00070 
00071       // destructor
00072       virtual ~BinarySearchTreeNode ();
00073 
00074       virtual Node* CreateNode() const { return new BinarySearchTreeNode(); }
00075 
00076       // test event if it decends the tree at this node to the right  
00077       virtual Bool_t GoesRight( const Event& ) const;
00078       // test event if it decends the tree at this node to the left 
00079 
00080       virtual Bool_t GoesLeft ( const Event& ) const;
00081       // test event if it is equal to the event that "makes the node" (just for the "search tree"  
00082 
00083       virtual Bool_t EqualsMe ( const Event& ) const;
00084 
00085       // set index of variable used for discrimination at this node
00086       inline void SetSelector( Short_t i) { fSelector = i; }
00087       // return index of variable used for discrimination at this node 
00088       inline Short_t GetSelector() const { return fSelector; }
00089 
00090       const std::vector<Float_t> & GetEventV() const { return fEventV; }
00091       Float_t                      GetWeight() const { return fWeight; }
00092       Bool_t                       IsSignal()  const { return (fClass == 0); }
00093 
00094       const std::vector<Float_t> & GetTargets() const { return fTargets; }
00095 
00096 
00097       // printout of the node
00098       virtual void Print( std::ostream& os ) const;
00099 
00100       // recursive printout of the node and it daughters 
00101       virtual void PrintRec( std::ostream& os ) const;
00102 
00103       virtual void AddAttributesToNode(void* node) const;
00104       virtual void AddContentToNode(std::stringstream& s) const;
00105 
00106    private: 
00107       // Read the data block
00108       virtual void ReadAttributes(void* node, UInt_t tmva_Version_Code = TMVA_VERSION_CODE );
00109       virtual Bool_t ReadDataRecord( std::istream& is, UInt_t tmva_Version_Code = TMVA_VERSION_CODE );
00110       virtual void ReadContent(std::stringstream& s);
00111       std::vector<Float_t> fEventV;
00112       std::vector<Float_t> fTargets;
00113 
00114       Float_t     fWeight;
00115       // Float_t     fIsSignal;
00116       UInt_t       fClass;
00117 
00118       Short_t     fSelector;       // index of variable used in node selection (decision tree) 
00119 
00120       ClassDef(BinarySearchTreeNode,0) // Node for the BinarySearchTree
00121    };
00122 
00123 } // namespace TMVA
00124 
00125 #endif

Generated on Tue Jul 5 14:27:18 2011 for ROOT_528-00b_version by  doxygen 1.5.1