5 #ifndef MVAUtils_TMVATOMVAUtils_H
6 #define MVAUtils_TMVATOMVAUtils_H
11 #include "TMVA/Reader.h"
12 #include "TMVA/MethodBDT.h"
16 const TMVA::DecisionTreeNode *
node,
23 std::vector<MVAUtils::index_t> right;
26 std::stack<const TMVA::DecisionTreeNode *>
parent;
27 std::stack<MVAUtils::index_t> parentIndex;
35 if (!currNode->GetLeft()) {
37 auto currParent =
parent.top();
38 auto currParentIndex = parentIndex.top();
40 if (currParentIndex >= 0) {
41 right[currParentIndex] =
i + 1 - currParentIndex;
42 currNode = currParent->GetCutType() ? currParent->GetLeft() : currParent->GetRight();
52 currNode = currNode->GetCutType() ? currNode->GetRight() : currNode->GetLeft();
58 std::stack<const TMVA::DecisionTreeNode *>
parent;
64 std::vector<MVAUtils::NodeTMVA> nodes;
67 if (!currNode->GetLeft()){
69 nodes.emplace_back(-1,
71 currNode->GetResponse() : useYesNoLeaf ? currNode->GetNodeType() : currNode->GetPurity(),
73 auto currParent =
parent.top();
76 currNode = currParent->GetCutType() ? currParent->GetLeft() : currParent->GetRight();
85 if (currNode->GetSelector() >max_var) { max_var = currNode->GetSelector(); }
87 nodes.emplace_back(currNode->GetSelector(), currNode->GetCutValue(), right[
i]);
89 currNode = currNode->GetCutType() ? currNode->GetRight() : currNode->GetLeft();
100 auto forest=std::make_unique<MVAUtils::ForestTMVA>();
101 std::vector<TMVA::DecisionTree*>::const_iterator
it;
102 for(
it = bdt->GetForest().begin();
it != bdt->GetForest().end(); ++
it) {
105 if(bdt->GetBoostWeights().size() >
index) {
109 newTree(forest.get(),(*it)->GetRoot(),
weight, isRegression, useYesNoLeaf);
114 std::unique_ptr<MVAUtils::BDT>
convert(TMVA::MethodBDT* bdt,
115 bool isRegression =
true,
116 bool useYesNoLeaf =
false){
118 std::unique_ptr<MVAUtils::IForest> forest=
createForestTMVA(bdt,isRegression,useYesNoLeaf);
119 return std::make_unique<MVAUtils::BDT> (std::move(forest));