58 #ifndef ROOT_TMVA_MsgLogger 61 #ifndef ROOT_TMVA_MethodBase 64 #ifndef ROOT_TMVA_Tools 67 #ifndef ROOT_TMVA_Event 70 #ifndef ROOT_TMVA_BinarySearchTree 87 fStatisticsIsValid(
kFALSE ),
89 fCanNormalize( kFALSE )
91 fNEventsW[0]=fNEventsW[1]=0.;
99 fPeriod ( b.fPeriod ),
101 fStatisticsIsValid(
kFALSE ),
102 fSumOfWeights( b.fSumOfWeights ),
106 Log() <<
kFATAL <<
" Copy constructor not implemented yet " <<
Endl;
114 for(std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator pIt =
fNormalizeTreeTable.begin();
124 std::string
type(
"");
127 bt->
ReadXML( node, tmva_Version_Code );
152 Log() <<
kFATAL <<
"<Insert> event vector length != Periode specified in Binary Tree" <<
Endl 153 <<
"--- event size: " <<
event->GetNVariables() <<
" Periode: " << this->
GetPeriode() <<
Endl 154 <<
"--- and all this when trying filling the "<<
fNNodes+1<<
"th Node" <<
Endl;
207 else Log() <<
kFATAL <<
"<Insert> neither left nor right :)" <<
Endl;
241 Log() <<
kWARNING <<
"you asked for the SumOfWeights, which is not filled yet" 242 <<
" I call CalcStatistics which hopefully fixes things" 256 Log() <<
kWARNING <<
"you asked for the SumOfWeights, which is not filled yet" 257 <<
" I call CalcStatistics which hopefully fixes things" 273 return Fill(events, theType);
287 <<
"You are filling a search three that is not empty.. " 288 <<
" do you know what you are doing?" 291 for (
UInt_t ievt=0; ievt<
n; ievt++) {
293 if (theType == -1 || (
Int_t(events[ievt]->
GetClass()) == theType) ) {
294 this->
Insert( events[ievt] );
307 std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator rightBound,
312 if (leftBound == rightBound)
return;
314 if (actDim ==
fPeriod) actDim = 0;
315 for (std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator i=leftBound; i!=rightBound; i++) {
316 i->first = i->second->GetValue( actDim );
319 std::sort( leftBound, rightBound );
321 std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator leftTemp = leftBound;
322 std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator rightTemp = rightBound;
327 if (rightTemp == leftTemp ) {
331 if (leftTemp == rightTemp) {
336 std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator
mid = leftTemp;
337 std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator midTemp =
mid;
339 if (mid!=leftBound) midTemp--;
341 while (mid != leftBound && mid->second->GetValue( actDim ) == midTemp->second->GetValue( actDim )) {
382 if (n !=
NULL)
delete n;
392 std::vector<const BinarySearchTreeNode*>* events )
402 std::vector<const BinarySearchTreeNode*>* events )
404 if (t==
NULL)
return 0;
411 if (
NULL != events) events->push_back( st );
421 Log() <<
kFATAL <<
"<SearchVolume> selector in Searchvolume " 439 result = ( (*(volume->
fLower))[ivar] <
event[ivar] &&
440 (*(volume->
fUpper))[ivar] >=
event[ivar] );
458 for (
Int_t sb=0; sb<2; sb++) {
467 fMeans[sb][j] = fRMS[sb][j] = fSum[sb][j] = fSumSq[sb][j] = 0;
468 fMin[sb][j] = FLT_MAX;
469 fMax[sb][j] = -FLT_MAX;
473 if (currentNode ==
NULL)
return;
476 const std::vector<Float_t> & evtVec = currentNode->
GetEventV();
497 for (
Int_t sb=0; sb<2; sb++) {
499 if (fNEventsW[sb] == 0) {
fMeans[sb][j] =
fRMS[sb][j] = 0;
continue; }
517 std::queue< std::pair< const BinarySearchTreeNode*, Int_t > > queue;
523 while ( !queue.empty() ) {
524 st = queue.front(); queue.pop();
526 if (count == max_points)
529 if (
InVolume( st.first->GetEventV(), volume )) {
531 if (
NULL != events) events->push_back( st.first );
538 if (d != st.first->GetSelector()) {
539 Log() <<
kFATAL <<
"<SearchVolume> selector in Searchvolume " 540 << d <<
" != " <<
"node "<< st.first->GetSelector() <<
Endl;
543 tl = (*(volume->
fLower))[d] < st.first->GetEventV()[d] && st.first->GetLeft() !=
NULL;
544 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)
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
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)
Double_t GetSumOfWeights(void) const
return the sum of event (node) weights
UInt_t GetPeriode(void) const
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)
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.
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 weigths of events that lie within the given voluem ...
std::vector< Float_t > fRMS[2]