22 #include "TStopwatch.h" 221 double bestSplitValue = 0;
222 int bestSplitVariable = -1;
223 double bestErrorReduction = -1;
229 double candidateErrorReduction = -1;
233 for(
unsigned int i=0;
i<
events[0].size();
i++)
240 unsigned int numVars =
events.size();
243 for(
unsigned int variableToCheck = 1; variableToCheck < numVars; variableToCheck++)
248 double SUMright =
SUM;
252 int nright =
events[variableToCheck].size()-1;
254 int candidateSplitVariable = variableToCheck;
256 std::vector<Event*>&
v =
events[variableToCheck];
259 for(
unsigned int i=1;
i<v.size();
i++)
264 SUMleft = SUMleft + v[
i-1]->data[0];
265 SUMright = SUMright - v[
i-1]->data[0];
268 if(v[
i-1]->
data[candidateSplitVariable] < v[
i]->
data[candidateSplitVariable])
272 candidateErrorReduction = SUMleft*SUMleft/nleft + SUMright*SUMright/nright - SUM*SUM/
numEvents;
276 if(candidateErrorReduction > bestErrorReduction)
278 bestErrorReduction = candidateErrorReduction;
279 bestSplitValue = (v[
i-1]->data[candidateSplitVariable] + v[
i]->data[candidateSplitVariable])/2;
280 bestSplitVariable = candidateSplitVariable;
320 std::cout << std::endl <<
"Listing Events... " << std::endl;
322 for(
unsigned int i=0;
i <
events.size();
i++)
324 std::cout << std::endl <<
"Variable " <<
i <<
" vector contents: " << std::endl;
325 for(
unsigned int j=0; j <
events[
i].size(); j++)
370 std::vector< std::vector<Event*> >
l(
events.size());
371 std::vector< std::vector<Event*> >
r(
events.size());
373 for(
unsigned int i=0;
i<
events.size();
i++)
375 for(
unsigned int j=0; j<
events[
i].size(); j++)
378 if(e->
data[sv] < sp)
l[
i].push_back(e);
379 if(e->
data[sv] > sp)
r[
i].push_back(e);
383 events = std::vector< std::vector<Event*> >();
407 Node* nextNode =
nullptr;
409 if(left ==
nullptr || right ==
nullptr)
return nullptr;
411 if(e->
data[sv] < sp) nextNode = left;
412 if(e->
data[sv] >= sp) nextNode = right;
void setFitValue(double sFitValue)
Node * getRightDaughter()
void setRightDaughter(Node *sLeftDaughter)
std::vector< std::vector< Event * > > events
void setTotalError(double sTotalError)
Node * filterEventToDaughter(Event *e)
void setErrorReduction(double sErrorReduction)
void setEvents(std::vector< std::vector< Event * > > &sEvents)
std::vector< std::vector< Event * > > & getEvents()
void setAvgError(double sAvgError)
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()
std::vector< double > data
void setSplitValue(double sSplitValue)
void setLeftDaughter(Node *sLeftDaughter)
void theMiracleOfChildBirth()