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 83 fStatisticsIsValid(
kFALSE ),
85 fCanNormalize( kFALSE )
87 fNEventsW[0]=fNEventsW[1]=0.;
95 fPeriod ( b.fPeriod ),
97 fStatisticsIsValid(
kFALSE ),
98 fSumOfWeights( b.fSumOfWeights ),
102 Log() <<
kFATAL <<
" Copy constructor not implemented yet " <<
Endl;
110 for(std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator pIt =
fNormalizeTreeTable.begin();
120 std::string
type(
"");
123 bt->
ReadXML( node, tmva_Version_Code );
148 Log() <<
kFATAL <<
"<Insert> event vector length != Periode specified in Binary Tree" <<
Endl 149 <<
"--- event size: " <<
event->GetNVariables() <<
" Periode: " << this->
GetPeriode() <<
Endl 150 <<
"--- and all this when trying filling the "<<
fNNodes+1<<
"th Node" <<
Endl;
203 else Log() <<
kFATAL <<
"<Insert> neither left nor right :)" <<
Endl;
237 Log() <<
kWARNING <<
"you asked for the SumOfWeights, which is not filled yet" 238 <<
" I call CalcStatistics which hopefully fixes things" 252 Log() <<
kWARNING <<
"you asked for the SumOfWeights, which is not filled yet" 253 <<
" I call CalcStatistics which hopefully fixes things" 269 return Fill(events, theType);
283 <<
"You are filling a search three that is not empty.. " 284 <<
" do you know what you are doing?" 287 for (
UInt_t ievt=0; ievt<
n; ievt++) {
289 if (theType == -1 || (
Int_t(events[ievt]->
GetClass()) == theType) ) {
290 this->
Insert( events[ievt] );
303 std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator rightBound,
308 if (leftBound == rightBound)
return;
310 if (actDim ==
fPeriod) actDim = 0;
311 for (std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator i=leftBound; i!=rightBound; i++) {
312 i->first = i->second->GetValue( actDim );
315 std::sort( leftBound, rightBound );
317 std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator leftTemp = leftBound;
318 std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator rightTemp = rightBound;
323 if (rightTemp == leftTemp ) {
327 if (leftTemp == rightTemp) {
332 std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator mid = leftTemp;
333 std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator midTemp = mid;
335 if (mid!=leftBound) midTemp--;
337 while (mid != leftBound && mid->second->GetValue( actDim ) == midTemp->second->GetValue( actDim )) {
378 if (n !=
NULL)
delete n;
388 std::vector<const BinarySearchTreeNode*>* events )
398 std::vector<const BinarySearchTreeNode*>* events )
400 if (t==
NULL)
return 0;
407 if (
NULL != events) events->push_back( st );
417 Log() <<
kFATAL <<
"<SearchVolume> selector in Searchvolume " 435 result = ( (*(volume->
fLower))[ivar] <
event[ivar] &&
436 (*(volume->
fUpper))[ivar] >=
event[ivar] );
454 for (
Int_t sb=0; sb<2; sb++) {
463 fMeans[sb][j] = fRMS[sb][j] = fSum[sb][j] = fSumSq[sb][j] = 0;
464 fMin[sb][j] = FLT_MAX;
465 fMax[sb][j] = -FLT_MAX;
469 if (currentNode ==
NULL)
return;
472 const std::vector<Float_t> & evtVec = currentNode->
GetEventV();
493 for (
Int_t sb=0; sb<2; sb++) {
495 if (fNEventsW[sb] == 0) {
fMeans[sb][j] =
fRMS[sb][j] = 0;
continue; }
513 std::queue< std::pair< const BinarySearchTreeNode*, Int_t > > queue;
519 while ( !queue.empty() ) {
520 st = queue.front(); queue.pop();
522 if (count == max_points)
525 if (
InVolume( st.first->GetEventV(), volume )) {
527 if (
NULL != events) events->push_back( st.first );
534 if (d != st.first->GetSelector()) {
535 Log() <<
kFATAL <<
"<SearchVolume> selector in Searchvolume " 536 << d <<
" != " <<
"node "<< st.first->GetSelector() <<
Endl;
539 tl = (*(volume->
fLower))[d] < st.first->GetEventV()[d] && st.first->GetLeft() !=
NULL;
540 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)
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
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]