85 Log() << kFATAL <<
" Copy constructor not implemented yet " <<
Endl;
93 for(std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator pIt =
fNormalizeTreeTable.begin();
103 std::string type(
"");
106 bt->
ReadXML( node, tmva_Version_Code );
131 Log() << kFATAL <<
"<Insert> event vector length != Periode specified in Binary Tree" <<
Endl
132 <<
"--- event size: " <<
event->GetNVariables() <<
" Periode: " << this->
GetPeriode() <<
Endl
133 <<
"--- and all this when trying filling the "<<
fNNodes+1<<
"th Node" <<
Endl;
186 else Log() << kFATAL <<
"<Insert> neither left nor right :)" <<
Endl;
220 Log() << kWARNING <<
"you asked for the SumOfWeights, which is not filled yet"
221 <<
" I call CalcStatistics which hopefully fixes things"
235 Log() << kWARNING <<
"you asked for the SumOfWeights, which is not filled yet"
236 <<
" I call CalcStatistics which hopefully fixes things"
252 return Fill(events, theType);
265 <<
"You are filling a search three that is not empty.. "
266 <<
" do you know what you are doing?"
269 for (
UInt_t ievt=0; ievt<
n; ievt++) {
271 if (theType == -1 || (
Int_t(events[ievt]->GetClass()) == theType) ) {
272 this->
Insert( events[ievt] );
286 std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator rightBound,
290 if (leftBound == rightBound)
return;
292 if (actDim ==
fPeriod) actDim = 0;
293 for (std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator i=leftBound; i!=rightBound; ++i) {
294 i->first = i->second->GetValue( actDim );
297 std::sort( leftBound, rightBound );
299 std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator leftTemp = leftBound;
300 std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator rightTemp = rightBound;
305 if (rightTemp == leftTemp ) {
309 if (leftTemp == rightTemp) {
314 std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator mid = leftTemp;
315 std::vector< std::pair<Double_t, const TMVA::Event*> >::iterator midTemp = mid;
317 if (mid!=leftBound)--midTemp;
319 while (mid != leftBound && mid->second->GetValue( actDim ) == midTemp->second->GetValue( actDim )) {
360 if (
n != NULL)
delete n;
370 std::vector<const BinarySearchTreeNode*>* events )
380 std::vector<const BinarySearchTreeNode*>* events )
382 if (t==NULL)
return 0;
389 if (NULL != events) events->push_back( st );
399 Log() << kFATAL <<
"<SearchVolume> selector in Searchvolume "
419 result = ( (*(volume->
fLower))[ivar] <
event[ivar] &&
420 (*(volume->
fUpper))[ivar] >=
event[ivar] );
438 for (
Int_t sb=0; sb<2; sb++) {
448 fMin[sb][j] = FLT_MAX;
449 fMax[sb][j] = -FLT_MAX;
453 if (currentNode == NULL)
return;
456 const std::vector<Float_t> & evtVec = currentNode->
GetEventV();
467 fSum[type][j] += val*weight;
468 fSumSq[type][j] += val*val*weight;
469 if (val <
fMin[type][j])
fMin[type][j] = val;
470 if (val >
fMax[type][j])
fMax[type][j] = val;
477 for (
Int_t sb=0; sb<2; sb++) {
497 if (this->
GetRoot() == NULL)
return 0;
499 std::queue< std::pair< const BinarySearchTreeNode*, Int_t > > queue;
505 while ( !queue.empty() ) {
506 st = queue.front(); queue.pop();
508 if (count == max_points)
511 if (
InVolume( st.first->GetEventV(), volume )) {
513 if (NULL != events) events->push_back( st.first );
520 if (
d != st.first->GetSelector()) {
521 Log() << kFATAL <<
"<SearchVolume> selector in Searchvolume "
522 <<
d <<
" != " <<
"node "<< st.first->GetSelector() <<
Endl;
525 tl = (*(volume->
fLower))[
d] < st.first->GetEventV()[
d] && st.first->GetLeft() != NULL;
526 tr = (*(volume->
fUpper))[
d] >= st.first->GetEventV()[
d] && st.first->GetRight() != NULL;
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
float Float_t
Float 4 bytes (float).
Node for the BinarySearch or Decision Trees.
void SetSelector(Short_t i)
set index of variable used for discrimination at this node
Float_t GetWeight() const
const std::vector< Float_t > & GetEventV() const
Short_t GetSelector() const
return index of variable used for discrimination at this node
A simple Binary search tree including a volume search method.
Int_t SearchVolumeWithMaxLimit(TMVA::Volume *, std::vector< const TMVA::BinarySearchTreeNode * > *events=nullptr, Int_t=-1)
recursively walk through the daughter nodes and add up all weights of events that lie within the give...
BinarySearchTreeNode * Search(Event *event) const
search the tree to find the node matching "event"
Double_t SearchVolume(Volume *, std::vector< const TMVA::BinarySearchTreeNode * > *events=nullptr)
search the whole tree and add up all weights of events that lie within the given volume
void CalcStatistics(TMVA::Node *n=nullptr)
calculate basic statistics (mean, rms for each variable)
UInt_t fCurrentDepth
internal variable, counting the depth of the tree during insertion
void Clear(TMVA::Node *n=nullptr)
clear nodes
void SetNormalize(Bool_t norm)
Bool_t InVolume(const std::vector< Float_t > &, Volume *) const
test if the data points are in the given volume
std::vector< Float_t > fMax[2]
RMS for signal and background for each variable.
virtual ~BinarySearchTree(void)
destructor
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"
Double_t fNEventsW[2]
Number of events per class, taking into account event weights.
void NormalizeTree()
Normalisation of tree.
std::vector< Double_t > fSumSq[2]
Squared Sum for signal and background for each variable.
Double_t GetSumOfWeights(void) const
return the sum of event (node) weights
std::vector< Float_t > fMeans[2]
mean for signal and background for each variable
UInt_t fPeriod
periode (number of event variables)
Bool_t fCanNormalize
the tree can be normalised
Double_t fSumOfWeights
Total number of events (weighted) counted during filling should be the same as fNEventsW[0]+fNEventsW...
UInt_t GetPeriode(void) const
std::vector< Double_t > fSum[2]
Sum for signal and background for each variable.
BinarySearchTree(void)
default constructor
Bool_t fStatisticsIsValid
flag if last stat calculation is still valid, set to false if new node is insert
void Insert(const Event *)
insert a new "event" in the binary tree
std::vector< Float_t > fMin[2]
RMS for signal and background for each variable.
std::vector< std::pair< Double_t, const TMVA::Event * > > fNormalizeTreeTable
std::vector< Float_t > fRMS[2]
RMS for signal and background for each variable.
static BinarySearchTree * CreateFromXML(void *node, UInt_t tmva_Version_Code=262657)
re-create a new tree (decision tree or search tree) from XML
BinaryTree(void)
constructor for a yet "empty" tree. Needs to be filled afterwards
UInt_t fNNodes
total number of nodes in the tree (counted)
virtual Node * GetRoot() const
virtual void ReadXML(void *node, UInt_t tmva_Version_Code=262657)
read attributes from XML
UInt_t GetNVariables() const
accessor to the number of variables
Node for the BinarySearch or Decision Trees.
virtual Node * GetLeft() const
virtual void SetRight(Node *r)
virtual Bool_t GoesLeft(const Event &) const =0
virtual void SetLeft(Node *l)
virtual void SetParent(Node *p)
virtual Bool_t GoesRight(const Event &) const =0
virtual Node * GetRight() const
@ kSignal
Never change this number - it is elsewhere assumed to be zero !
Volume for BinarySearchTree.
std::vector< Double_t > * fLower
vector with lower volume dimensions
std::vector< Double_t > * fUpper
vector with upper volume dimensions
MsgLogger & Endl(MsgLogger &ml)
Double_t Sqrt(Double_t x)
Returns the square root of x.