#ifndef ROOT_TMVA_CCTreeWrapper
#define ROOT_TMVA_CCTreeWrapper
#ifndef ROOT_TMVA_Event
#include "TMVA/Event.h"
#endif
#ifndef ROOT_TMVA_SeparationBase
#include "TMVA/SeparationBase.h"
#endif
#ifndef ROOT_TMVA_DecisionTree
#include "TMVA/DecisionTree.h"
#endif
#ifndef ROOT_TMVA_DataSet
#include "TMVA/DataSet.h"
#endif
namespace TMVA {
class CCTreeWrapper {
public:
typedef std::vector<Event*> EventList;
class CCTreeNode : virtual public Node {
public:
CCTreeNode( DecisionTreeNode* n = NULL );
virtual ~CCTreeNode( );
virtual Node* CreateNode() const { return new CCTreeNode(); }
inline void SetNLeafDaughters( Int_t N ) { fNLeafDaughters = (N > 0 ? N : 0); }
inline Int_t GetNLeafDaughters() const { return fNLeafDaughters; }
inline void SetNodeResubstitutionEstimate( Double_t R ) { fNodeResubstitutionEstimate = (R >= 0 ? R : 0.0); }
inline Double_t GetNodeResubstitutionEstimate( ) const { return fNodeResubstitutionEstimate; }
inline void SetResubstitutionEstimate( Double_t R ) { fResubstitutionEstimate = (R >= 0 ? R : 0.0); }
inline Double_t GetResubstitutionEstimate( ) const { return fResubstitutionEstimate; }
inline void SetAlphaC( Double_t alpha ) { fAlphaC = alpha; }
inline Double_t GetAlphaC( ) const { return fAlphaC; }
inline void SetMinAlphaC( Double_t alpha ) { fMinAlphaC = alpha; }
inline Double_t GetMinAlphaC( ) const { return fMinAlphaC; }
inline DecisionTreeNode* GetDTNode( ) const { return fDTNode; }
inline CCTreeNode* GetLeftDaughter( ) { return dynamic_cast<CCTreeNode*>(GetLeft()); }
inline CCTreeNode* GetRightDaughter( ) { return dynamic_cast<CCTreeNode*>(GetRight()); }
inline CCTreeNode* GetMother( ) { return dynamic_cast<CCTreeNode*>(GetParent()); }
virtual void Print( ostream& os ) const;
virtual void PrintRec ( ostream& os ) const;
virtual void AddAttributesToNode(void* node) const;
virtual void AddContentToNode(std::stringstream& s) const;
inline virtual Bool_t GoesRight( const Event& e ) const { return (GetDTNode() != NULL ?
GetDTNode()->GoesRight(e) : false); }
inline virtual Bool_t GoesLeft ( const Event& e ) const { return (GetDTNode() != NULL ?
GetDTNode()->GoesLeft(e) : false); }
private:
virtual void ReadAttributes(void* node);
virtual Bool_t ReadDataRecord( std::istream& in );
virtual void ReadContent(std::stringstream& s);
Int_t fNLeafDaughters;
Double_t fNodeResubstitutionEstimate;
Double_t fResubstitutionEstimate;
Double_t fAlphaC;
Double_t fMinAlphaC;
DecisionTreeNode* fDTNode;
};
CCTreeWrapper( DecisionTree* T, SeparationBase* qualityIndex );
~CCTreeWrapper( );
Double_t CheckEvent( const TMVA::Event & e, Bool_t useYesNoLeaf = false );
Double_t TestTreeQuality( const EventList* validationSample );
Double_t TestTreeQuality( const DataSet* validationSample );
void PruneNode( CCTreeNode* t );
void InitTree( CCTreeNode* t );
CCTreeNode* GetRoot() { return fRoot; }
private:
SeparationBase* fQualityIndex;
DecisionTree* fDTParent;
CCTreeNode* fRoot;
};
}
#endif