#include "TMVA/BinarySearchTreeNode.h"
#include "Riostream.h"
#include <stdexcept>
#include "TMVA/Event.h"
ClassImp(TMVA::BinarySearchTreeNode)
;
TMVA::BinarySearchTreeNode::BinarySearchTreeNode ( const BinarySearchTreeNode &n,
BinarySearchTreeNode* parent) :
TMVA::Node(n),
fEvent ( n.fEvent==NULL ? NULL : new Event(*(n.fEvent)) ),
fEventOwnership (kTRUE),
fSelector (n.fSelector)
{
this->SetParent( parent );
if (n.GetLeft() == 0 ) this->SetLeft(NULL);
else this->SetLeft( new BinarySearchTreeNode( *((BinarySearchTreeNode*)(n.GetLeft())),this));
if (n.GetRight() == 0 ) this->SetRight(NULL);
else this->SetRight( new BinarySearchTreeNode( *((BinarySearchTreeNode*)(n.GetRight())),this));
}
TMVA::BinarySearchTreeNode::~BinarySearchTreeNode ( void )
{
if (this->GetEventOwnership()) delete fEvent;
}
Bool_t TMVA::BinarySearchTreeNode::GoesRight(const TMVA::Event& e) const {
if (e.GetVal(fSelector) > fEvent->GetVal(fSelector)) return true;
else return false;
}
Bool_t TMVA::BinarySearchTreeNode::GoesLeft(const TMVA::Event& e) const
{
if (e.GetVal(fSelector) <= fEvent->GetVal(fSelector)) return true;
else return false;
}
Bool_t TMVA::BinarySearchTreeNode::EqualsMe(const TMVA::Event& e) const
{
Bool_t result = true;
for (UInt_t i=0; i<fEvent->GetNVars(); i++) {
result&= (e.GetVal(i) == fEvent->GetVal(i));
}
return result;
}
void TMVA::BinarySearchTreeNode::Print(ostream& os) const
{
os << "< *** " <<endl << " node.Data: " << this->GetEvent()
<< "at address " <<long(this->GetEvent()) <<endl;
os << "Selector: " << this->GetSelector() <<endl;
os << "My address is " << long(this) << ", ";
if (this->GetParent() != NULL) os << " parent at addr: " << long(this->GetParent()) ;
if (this->GetLeft() != NULL) os << " left daughter at addr: " << long(this->GetLeft());
if (this->GetRight() != NULL) os << " right daughter at addr: " << long(this->GetRight()) ;
os << " **** > "<< endl;
}
void TMVA::BinarySearchTreeNode::PrintRec(ostream& os ) const
{
os << this->GetDepth() << " " << this->GetPos()
<< " node.Data: " << endl << this->GetEvent() ;
os << this->GetDepth() << " " << this->GetPos()
<< " Selector: " << this->GetSelector() <<endl;
if(this->GetLeft() != NULL)this->GetLeft()->PrintRec(os) ;
if(this->GetRight() != NULL)this->GetRight()->PrintRec(os);
}
void TMVA::BinarySearchTreeNode::ReadRec(istream& is, char &pos, UInt_t &depth,
TMVA::Node* parent )
{
std::string tmp;
Int_t itmp;
if (parent==NULL) {
is >> itmp >> pos ;
this->SetDepth(itmp);
this->SetPos(pos);
} else {
this->SetDepth(depth);
this->SetPos(pos);
}
is >> tmp;
std::cout << kFATAL << " Cannot read revents yet as the constuctor would need "
<< " know about the VariableInfo" << std::endl; exit(1);
this->SetEventOwnership(kTRUE);
Double_t dtmp;
Int_t nvar;
is >> tmp >> tmp >> nvar >> tmp >> tmp >> tmp >> dtmp;
for (int i=0; i<nvar; i++){
is >> dtmp;
}
is >> itmp >> pos >> tmp >> tmp;
this->SetSelector((UInt_t)atoi(tmp.c_str()));
is >> depth >> pos;
if (depth == this->GetDepth()+1){
if (pos=='l') {
this->SetLeft(new TMVA::BinarySearchTreeNode() );
this->GetLeft()->SetParent(this);
this->GetLeft()->ReadRec(is,pos,depth,this);
}
}
if (depth == this->GetDepth()+1){
if (pos=='r') {
this->SetRight(new TMVA::BinarySearchTreeNode());
this->GetRight()->SetParent(this);
this->GetRight()->ReadRec(is,pos,depth,this);
}
}
}
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.