7 #ifndef LEM_DECISIONTREE_H 8 #define LEM_DECISIONTREE_H 48 double Classify(
const Evt&
evt)
const;
58 static Forest Train(std::vector<Evt>& trainEvts,
60 bool parallel =
false);
68 static Tree* TrainSingle(
const std::vector<Evt>& trainEvts,
73 static TreeNode* TrainSingleTransformed(std::vector<std::list<Evt*> >& sorted,
88 virtual double FOM()
const = 0;
90 virtual double Classify(
const Evt&
e)
const = 0;
92 virtual double NSig()
const = 0;
94 virtual double NBkg()
const = 0;
96 virtual TreeNode* Prune(std::vector<Evt>& evts) = 0;
98 virtual bool IsLeaf()
const = 0;
101 virtual void ToTree(TTree*
tr)
const = 0;
109 : fHead(n), fMatrix(mat) {}
113 double FOM()
const {
return fHead->FOM();}
115 double Classify(
const Evt&
e)
const;
117 void Prune(std::vector<Evt>& evts) {fHead = fHead->Prune(evts);};
133 virtual double FOM()
const;
134 virtual double Classify(
const Evt&
e)
const;
135 virtual double NSig()
const;
136 virtual double NBkg()
const;
138 virtual TreeNode* Prune(std::vector<Evt>& evts);
142 virtual void ToTree(TTree*
tr)
const;
154 virtual double FOM()
const;
155 virtual double Classify(
const Evt&)
const;
157 virtual double NBkg()
const {
return fBkg;}
163 virtual void ToTree(TTree*
tr)
const;
Leaf of a decision tree. No further cuts are made
Tree(TreeNode *n, const TMatrixD &mat)
double FOM() const
Estimated figure of merit of this tree.
A cut dividing events into two samples, maximizing FOM.
void ToTree(TTree *tr) const
Serialize to a TTree. Needs assistance from Forest::ToTree.
double fSig
How many signal events reached this node in training.
double fBkg
How many background events reached this node in training.
std::vector< Tree * > fTrees
A training or trial event for the decision tree.
TMatrixD GetMatrix() const
virtual double NBkg() const
Number of background events below this point in the tree.
void * thread_func(void *a)
int fCutDim
What variable the cut is on.
"Random forest" of decision trees
TreeNode * fRight
Subtrees to descend into based on cut result.
virtual TreeNode * Prune(std::vector< Evt > &)
Abstract base class for tree cuts and leaves.
void Prune(std::vector< Evt > &evts)
virtual double NSig() const
Number of signal events below this point in the tree.
A DecisionTree. Forwards most things to the head TreeNode.
double fCutVal
Where the cut is placed.