22 #include "TStopwatch.h"
149 double bestSplitValue = 0;
150 int bestSplitVariable = -1;
151 double bestErrorReduction = -1;
157 double candidateErrorReduction = -1;
161 for (
unsigned int i = 0;
i <
events[0].size();
i++) {
167 unsigned int numVars =
events.size();
170 for (
unsigned int variableToCheck = 1; variableToCheck < numVars; variableToCheck++) {
173 double SUMright =
SUM;
177 int nright =
events[variableToCheck].size() - 1;
179 int candidateSplitVariable = variableToCheck;
181 std::vector<Event*>&
v =
events[variableToCheck];
184 for (
unsigned int i = 1;
i <
v.size();
i++) {
188 SUMleft = SUMleft +
v[
i - 1]->data[0];
189 SUMright = SUMright -
v[
i - 1]->data[0];
192 if (
v[
i - 1]->
data[candidateSplitVariable] <
v[
i]->
data[candidateSplitVariable]) {
195 candidateErrorReduction = SUMleft * SUMleft / nleft + SUMright * SUMright / nright -
SUM *
SUM /
numEvents;
199 if (candidateErrorReduction > bestErrorReduction) {
200 bestErrorReduction = candidateErrorReduction;
201 bestSplitValue = (
v[
i - 1]->data[candidateSplitVariable] +
v[
i]->data[candidateSplitVariable]) / 2;
202 bestSplitVariable = candidateSplitVariable;
240 std::cout << std::endl <<
"Listing Events... " << std::endl;
242 for (
unsigned int i = 0;
i <
events.size();
i++) {
243 std::cout << std::endl <<
"Variable " <<
i <<
" vector contents: " << std::endl;
244 for (
unsigned int j = 0;
j <
events[
i].size();
j++) {
286 std::vector<std::vector<Event*> >
l(
events.size());
287 std::vector<std::vector<Event*> >
r(
events.size());
289 for (
unsigned int i = 0;
i <
events.size();
i++) {
290 for (
unsigned int j = 0;
j <
events[
i].size();
j++) {
292 if (
e->data[
sv] < sp)
294 if (
e->data[
sv] > sp)
299 events = std::vector<std::vector<Event*> >();
322 Node* nextNode =
nullptr;
324 if (left ==
nullptr || right ==
nullptr)
327 if (
e->data[
sv] < sp)
329 if (
e->data[
sv] >= sp)