56 TMVA::BinarySearchTreeNode::BinarySearchTreeNode( const Event* e,
UInt_t )
58 fEventV ( std::vector<
Float_t>() ),
59 fTargets ( std::vector<Float_t>() ),
65 for (
UInt_t ivar=0; ivar<e->GetNVariables(); ivar++) fEventV.push_back(e->GetValue(ivar));
66 for (std::vector<Float_t>::const_iterator it = e->GetTargets().begin(); it < e->GetTargets().end(); it++ ) {
67 fTargets.push_back( (*it) );
76 TMVA::
Node(parent,pos),
77 fEventV ( std::vector<
Float_t>() ),
78 fTargets ( std::vector<
Float_t>() ),
92 fEventV ( n.fEventV ),
93 fTargets ( n.fTargets ),
94 fWeight ( n.fWeight ),
96 fSelector( n.fSelector )
119 if (e.
GetValue(fSelector) > GetEventV()[fSelector])
return true;
128 if (e.
GetValue(fSelector) <= GetEventV()[fSelector])
return true;
139 for (
UInt_t i=0; i<GetEventV().size(); i++) {
140 result&= (e.
GetValue(i) == GetEventV()[i]);
150 os <<
"< *** " << std::endl <<
" node.Data: ";
151 std::vector<Float_t>::const_iterator it=fEventV.begin();
152 os << fEventV.size() <<
" vars: ";
153 for (;it!=fEventV.end(); it++) os <<
" " << std::setw(10) << *it;
154 os <<
" EvtWeight " << std::setw(10) << fWeight;
155 os << std::setw(10) <<
"Class: " <<
GetClass() << std::endl;
157 os <<
"Selector: " << this->GetSelector() <<std::endl;
158 os <<
"My address is " << long(
this) <<
", ";
159 if (this->GetParent() !=
NULL) os <<
" parent at addr: " << long(this->GetParent()) ;
160 if (this->GetLeft() !=
NULL) os <<
" left daughter at addr: " << long(this->GetLeft());
161 if (this->GetRight() !=
NULL) os <<
" right daughter at addr: " << long(this->GetRight()) ;
163 os <<
" **** > "<< std::endl;
171 os << this->GetDepth() <<
" " << this->GetPos() <<
" " << this->GetSelector()
172 <<
" data: " << std::endl;
173 std::vector<Float_t>::const_iterator it=fEventV.begin();
174 os << fEventV.size() <<
" vars: ";
175 for (;it!=fEventV.end(); it++) os <<
" " << std::setw(10) << *it;
176 os <<
" EvtWeight " << std::setw(10) << fWeight;
177 os << std::setw(10) <<
"Class: " <<
GetClass() << std::endl;
179 if (this->GetLeft() !=
NULL)this->GetLeft()->PrintRec(os) ;
180 if (this->GetRight() !=
NULL)this->GetRight()->PrintRec(os);
190 UInt_t depth, selIdx, nvar;
197 if ( itmp==-1 ) {
return kFALSE; }
201 this->SetDepth(depth);
203 this->SetSelector(selIdx);
209 for (
UInt_t ivar=0; ivar<nvar; ivar++) {
210 is >> evtValFloat; fEventV.push_back(evtValFloat);
212 is >> tmp >> fWeight;
214 fClass = (sigbkgd==
"S" || sigbkgd==
"Signal")?0:1;
228 if (sb==
"Signal" || sb==
"0")
235 fEventV.resize(nvars);
256 std::ios_base::fmtflags ff = s.flags();
258 for (
UInt_t i=0; i<fEventV.size(); i++) s << std::scientific <<
" " << fEventV[i];
259 for (
UInt_t i=0; i<fTargets.size(); i++) s << std::scientific <<
" " << fTargets[i];
268 for (
UInt_t i=0; i<fEventV.size(); i++){
272 while (s >> temp) fTargets.push_back(temp);
virtual Bool_t GoesRight(const Event &) const
check if the event fed into the node goes/decends to the right daughter
virtual void SetRight(Node *r)
virtual void SetLeft(Node *l)
virtual Bool_t ReadDataRecord(std::istream &is, UInt_t tmva_Version_Code=TMVA_VERSION_CODE)
Read the data block.
virtual void PrintRec(std::ostream &os) const
recursively print the node and its daughters (–> print the 'tree')
TClass * fClass
pointer to the foreign object
virtual ~BinarySearchTreeNode()
node destructor
virtual void ReadAttributes(void *node, UInt_t tmva_Version_Code=TMVA_VERSION_CODE)
read attributes from XML
virtual void AddAttributesToNode(void *node) const
adding attributes to tree node
Double_t GetWeight(Double_t x) const
virtual void SetParent(Node *p)
virtual void AddContentToNode(std::stringstream &s) const
adding attributes to tree node
virtual Bool_t GoesLeft(const Event &) const
check if the event fed into the node goes/decends to the left daughter
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
virtual Node * GetRight() const
BinarySearchTreeNode(const Event *e=NULL, UInt_t signalClass=0)
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 ReadContent(std::stringstream &s)
read events from node
virtual Node * GetLeft() const
ClassImp(TMVA::BinarySearchTreeNode) TMVA
constructor of a node for the search tree