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++) {
293 if (
sv >=
e->data.size())
295 if (
e->data[
sv] < sp)
297 if (
e->data[
sv] > sp)
302 events = std::vector<std::vector<Event*> >();
325 Node* nextNode =
nullptr;
328 if (left ==
nullptr || right ==
nullptr ||
sv >=
e->data.size())
331 if (
e->data[
sv] < sp)
333 if (
e->data[
sv] >= sp)
void setFitValue(double sFitValue)
Node * getRightDaughter()
void setRightDaughter(Node *sLeftDaughter)
void setEvents(std::vector< std::vector< Event *> > &sEvents)
void setTotalError(double sTotalError)
Node * filterEventToDaughter(Event *e)
void setErrorReduction(double sErrorReduction)
std::vector< std::vector< Event * > > & getEvents()
void setAvgError(double sAvgError)
std::vector< std::vector< Event * > > events
void setParent(Node *sParent)
void setName(std::string sName)
void setSplitVariable(int sSplitVar)
char data[epos_bytes_allocation]
void setNumEvents(int sNumEvents)
double getErrorReduction()
void filterEventsToDaughters()
void setSplitValue(double sSplitValue)
void setLeftDaughter(Node *sLeftDaughter)
void theMiracleOfChildBirth()