76 fStatisticsIsValid(
kFALSE ),
78 fCanNormalize( kFALSE )
80 fNEventsW[0]=fNEventsW[1]=0.;
88 fPeriod ( b.fPeriod ),
90 fStatisticsIsValid(
kFALSE ),
91 fSumOfWeights( b.fSumOfWeights ),
95 Log() << kFATAL <<
" Copy constructor not implemented yet " <<
Endl;
103 for(std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator pIt =
fNormalizeTreeTable.begin();
113 std::string
type(
"");
116 bt->
ReadXML( node, tmva_Version_Code );
141 Log() << kFATAL <<
"<Insert> event vector length != Periode specified in Binary Tree" <<
Endl 142 <<
"--- event size: " <<
event->GetNVariables() <<
" Periode: " << this->
GetPeriode() <<
Endl 143 <<
"--- and all this when trying filling the "<<
fNNodes+1<<
"th Node" <<
Endl;
196 else Log() << kFATAL <<
"<Insert> neither left nor right :)" <<
Endl;
230 Log() << kWARNING <<
"you asked for the SumOfWeights, which is not filled yet" 231 <<
" I call CalcStatistics which hopefully fixes things" 245 Log() << kWARNING <<
"you asked for the SumOfWeights, which is not filled yet" 246 <<
" I call CalcStatistics which hopefully fixes things" 262 return Fill(events, theType);
276 <<
"You are filling a search three that is not empty.. " 277 <<
" do you know what you are doing?" 280 for (
UInt_t ievt=0; ievt<
n; ievt++) {
282 if (theType == -1 || (
Int_t(events[ievt]->
GetClass()) == theType) ) {
283 this->
Insert( events[ievt] );
298 std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator rightBound,
302 if (leftBound == rightBound)
return;
304 if (actDim ==
fPeriod) actDim = 0;
305 for (std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator i=leftBound; i!=rightBound; i++) {
306 i->first = i->second->GetValue( actDim );
309 std::sort( leftBound, rightBound );
311 std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator leftTemp = leftBound;
312 std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator rightTemp = rightBound;
317 if (rightTemp == leftTemp ) {
321 if (leftTemp == rightTemp) {
326 std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator
mid = leftTemp;
327 std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator midTemp =
mid;
329 if (mid!=leftBound) midTemp--;
331 while (mid != leftBound && mid->second->GetValue( actDim ) == midTemp->second->GetValue( actDim )) {
372 if (n !=
NULL)
delete n;
382 std::vector<const BinarySearchTreeNode*>* events )
392 std::vector<const BinarySearchTreeNode*>* events )
394 if (t==
NULL)
return 0;
401 if (
NULL != events) events->push_back( st );
411 Log() << kFATAL <<
"<SearchVolume> selector in Searchvolume " 431 result = ( (*(volume->
fLower))[ivar] <
event[ivar] &&
432 (*(volume->
fUpper))[ivar] >=
event[ivar] );
450 for (
Int_t sb=0; sb<2; sb++) {
459 fMeans[sb][j] = fRMS[sb][j] = fSum[sb][j] = fSumSq[sb][j] = 0;
460 fMin[sb][j] = FLT_MAX;
461 fMax[sb][j] = -FLT_MAX;
465 if (currentNode ==
NULL)
return;
468 const std::vector<Float_t> & evtVec = currentNode->
GetEventV();
489 for (
Int_t sb=0; sb<2; sb++) {
491 if (fNEventsW[sb] == 0) {
fMeans[sb][j] =
fRMS[sb][j] = 0;
continue; }
511 std::queue< std::pair< const BinarySearchTreeNode*, Int_t > > queue;
517 while ( !queue.empty() ) {
518 st = queue.front(); queue.pop();
520 if (count == max_points)
523 if (
InVolume( st.first->GetEventV(), volume )) {
525 if (
NULL != events) events->push_back( st.first );
532 if (d != st.first->GetSelector()) {
533 Log() << kFATAL <<
"<SearchVolume> selector in Searchvolume " 534 << d <<
" != " <<
"node "<< st.first->GetSelector() <<
Endl;
537 tl = (*(volume->
fLower))[d] < st.first->GetEventV()[d] && st.first->GetLeft() !=
NULL;
538 tr = (*(volume->
fUpper))[d] >= st.first->GetEventV()[d] && st.first->GetRight() !=
NULL;
Int_t SearchVolumeWithMaxLimit(TMVA::Volume *, std::vector< const TMVA::BinarySearchTreeNode *> *events=0, Int_t=-1)
recursively walk through the daughter nodes and add up all weights of events that lie within the give...
std::vector< Double_t > * fLower
std::vector< Double_t > fSum[2]
BinarySearchTreeNode * Search(Event *event) const
search the tree to find the node matching "event"
std::vector< Float_t > fMax[2]
std::vector< Double_t > fSumSq[2]
MsgLogger & Endl(MsgLogger &ml)
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t mid
virtual ~BinarySearchTree(void)
destructor
Bool_t InVolume(const std::vector< Float_t > &, Volume *) const
test if the data points are in the given volume
Double_t Fill(const std::vector< TMVA::Event *> &events, const std::vector< Int_t > &theVars, Int_t theType=-1)
create the search tree from the event collection using ONLY the variables specified in "theVars" ...
std::vector< Double_t > * fUpper
virtual void SetRight(Node *r)
Node for the BinarySearch or Decision Trees.
Double_t GetSumOfWeights(void) const
return the sum of event (node) weights
UInt_t GetPeriode(void) const
Volume for BinarySearchTree.
void NormalizeTree()
Normalisation of tree.
std::vector< std::pair< Double_t, const TMVA::Event * > > fNormalizeTreeTable
virtual Bool_t GoesLeft(const Event &) const =0
virtual void SetLeft(Node *l)
Base class for BinarySearch and Decision Trees.
virtual Node * GetRight() const
virtual Node * GetLeft() const
void SetSelector(Short_t i)
void Clear(TMVA::Node *n=0)
clear nodes
Float_t GetWeight() const
void CalcStatistics(TMVA::Node *n=0)
calculate basic statistics (mean, rms for each variable)
Bool_t fStatisticsIsValid
BinarySearchTree(void)
default constructor
static BinarySearchTree * CreateFromXML(void *node, UInt_t tmva_Version_Code=TMVA_VERSION_CODE)
re-create a new tree (decision tree or search tree) from XML
void SetNormalize(Bool_t norm)
void Insert(const Event *)
insert a new "event" in the binary tree
virtual void ReadXML(void *node, UInt_t tmva_Version_Code=TMVA_VERSION_CODE)
read attributes from XML
virtual void SetParent(Node *p)
UInt_t GetNVariables() const
accessor to the number of variables
std::vector< Float_t > fMeans[2]
const std::vector< Float_t > & GetEventV() const
Abstract ClassifierFactory template that handles arbitrary types.
Node for the BinarySearch or Decision Trees.
virtual Bool_t GoesRight(const Event &) const =0
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Short_t GetSelector() const
virtual Node * GetRoot() const
Double_t Sqrt(Double_t x)
std::vector< Float_t > fMin[2]
Double_t SearchVolume(Volume *, std::vector< const TMVA::BinarySearchTreeNode *> *events=0)
search the whole tree and add up all weights of events that lie within the given volume ...
std::vector< Float_t > fRMS[2]
A simple Binary search tree including a volume search method.