**********************************************************************************/
#include <algorithm>
#include "Riostream.h"
#include "TMVA/DecisionTreeNode.h"
#include "TMVA/BinarySearchTree.h"
#include "TMVA/Tools.h"
using std::string;
ClassImp(TMVA::DecisionTreeNode)
TMVA::DecisionTreeNode::DecisionTreeNode(TMVA::Event* e)
: TMVA::Node(e)
{
fCutValue=0;
fCutType= kTRUE;
fSoverSB=-1;
fSeparationIndex=-1;
fSeparationGain=-1;
fNEvents = -1;
fNodeType=-99;
}
TMVA::DecisionTreeNode::DecisionTreeNode(TMVA::Node* p)
: TMVA::Node(p)
{
fCutValue=0;
fCutType= kTRUE;
fSoverSB=-1;
fSeparationIndex=-1;
fSeparationGain=-1;
fNEvents = -1;
fNodeType=-99;
}
Bool_t TMVA::DecisionTreeNode::GoesRight(const TMVA::Event * e) const
{
Bool_t result;
result = (e->GetData(this->GetSelector()) > this->GetCutValue() );
if (fCutType == kTRUE) return result;
else return !result;
}
Bool_t TMVA::DecisionTreeNode::GoesLeft(const TMVA::Event * e) const
{
if (!this->GoesRight(e)) return kTRUE;
else return kFALSE;
}
void TMVA::DecisionTreeNode::PrintRec(ostream& os, const Int_t Depth, const string pos ) const
{
os << Depth << " " << pos << " ivar: " << this->GetSelector()
<< " cut: " << this->GetCutValue()
<< " cType: " << this->GetCutType()
<< " pur: " << this->GetSoverSB()
<< " sepI: " << this->GetSeparationIndex()
<< " sepG: " << this->GetSeparationGain()
<< " nEv: " << this->GetNEvents()
<< " nType: " << this->GetNodeType()<<endl;
if(this->GetLeft() != NULL)this->GetLeft()->PrintRec(os,Depth+1,"l") ;
if(this->GetRight() != NULL)this->GetRight()->PrintRec(os,Depth+1,"r");
}
TMVA::NodeID TMVA::DecisionTreeNode::ReadRec(ifstream& is, TMVA::NodeID nodeID, TMVA::Node* Parent )
{
string tmp;
Double_t dtmp1, dtmp2, dtmp3, dtmp4, dtmp5, dtmp6;
Int_t itmp, itmp1, itmp2;
string pos;
TMVA::NodeID nextNodeID;
if (Parent==NULL) {
is >> itmp >> pos ;
nodeID.SetDepth(itmp);
nodeID.SetPos(pos);
}
is >> tmp >> itmp1 >> tmp >> dtmp1 >> tmp >> dtmp2 >> tmp >> dtmp3
>> tmp >> dtmp4 >> tmp >> dtmp5 >> tmp >> dtmp6
>> tmp >> itmp2;
this->SetSelector(itmp1);
this->SetCutValue(dtmp1);
this->SetCutType(dtmp2);
this->SetSoverSB(dtmp3);
this->SetSeparationIndex(dtmp4);
this->SetSeparationGain(dtmp5);
this->SetNEvents(dtmp6);
this->SetNodeType(itmp2);
is >> itmp >> pos ;
nextNodeID.SetDepth(itmp);
nextNodeID.SetPos(pos);
if (nextNodeID.GetDepth() == nodeID.GetDepth()+1){
if (nextNodeID.GetPos()=="l") {
this->SetLeft(new TMVA::DecisionTreeNode());
this->GetLeft()->SetParent(this);
nextNodeID = this->GetLeft()->ReadRec(is,nextNodeID,this);
}
}
if (nextNodeID.GetDepth() == nodeID.GetDepth()+1){
if (nextNodeID.GetPos()=="r") {
this->SetRight(new TMVA::DecisionTreeNode());
this->GetRight()->SetParent(this);
nextNodeID = this->GetRight()->ReadRec(is,nextNodeID,this);
}
}
return nextNodeID;
}
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.