21 #include "TStopwatch.h"
218 Double_t bestSplitValue = 0;
219 Int_t bestSplitVariable = -1;
220 Double_t bestErrorReduction = -1;
226 Double_t candidateErrorReduction = -1;
230 for(
unsigned int i=0;
i<
events[0].size();
i++)
237 unsigned int numVars =
events.size();
240 for(
unsigned int variableToCheck = 1; variableToCheck < numVars; variableToCheck++)
244 Double_t SUMleft = 0;
245 Double_t SUMright =
SUM;
249 Int_t nright =
events[variableToCheck].size()-1;
251 Int_t candidateSplitVariable = variableToCheck;
253 std::vector<Event*>&
v =
events[variableToCheck];
256 for(
unsigned int i=1;
i<v.size();
i++)
261 SUMleft = SUMleft + v[
i-1]->data[0];
262 SUMright = SUMright - v[
i-1]->data[0];
265 if(v[
i-1]->
data[candidateSplitVariable] < v[
i]->
data[candidateSplitVariable])
269 candidateErrorReduction = SUMleft*SUMleft/nleft + SUMright*SUMright/nright - SUM*SUM/
numEvents;
273 if(candidateErrorReduction > bestErrorReduction)
275 bestErrorReduction = candidateErrorReduction;
276 bestSplitValue = (v[
i-1]->data[candidateSplitVariable] + v[
i]->data[candidateSplitVariable])/2;
277 bestSplitVariable = candidateSplitVariable;
317 std::cout << std::endl <<
"Listing Events... " << std::endl;
319 for(
unsigned int i=0;
i <
events.size();
i++)
321 std::cout << std::endl <<
"Variable " <<
i <<
" vector contents: " << std::endl;
322 for(
unsigned int j=0;
j <
events[
i].size();
j++)
367 std::vector< std::vector<Event*> >
l(
events.size());
368 std::vector< std::vector<Event*> >
r(
events.size());
370 for(
unsigned int i=0;
i<
events.size();
i++)
372 for(
unsigned int j=0;
j<
events[
i].size();
j++)
375 if(e->
data[sv] < sp)
l[
i].push_back(e);
376 if(e->
data[sv] > sp)
r[
i].push_back(e);
380 events = std::vector< std::vector<Event*> >();
406 if(left ==0 || right ==0)
return 0;
408 if(e->
data[sv] < sp) nextNode = left;
409 if(e->
data[sv] > sp) nextNode = right;
void setLeftDaughter(Node *sLeftDaughter)
void setAvgError(Double_t sAvgError)
void setSplitValue(Double_t sSplitValue)
void setNumEvents(Int_t sNumEvents)
Node * filterEventToDaughter(Event *e)
void setRightDaughter(Node *sLeftDaughter)
void theMiracleOfChildBirth()
Node * getRightDaughter()
void setName(std::string sName)
void filterEventsToDaughters()
std::vector< std::vector< Event * > > & getEvents()
std::vector< std::vector< Event * > > events
void setEvents(std::vector< std::vector< Event * > > &sEvents)
Double_t getErrorReduction()
void setParent(Node *sParent)
void setFitValue(Double_t sFitValue)
char data[epos_bytes_allocation]
void setTotalError(Double_t sTotalError)
void setSplitVariable(Int_t sSplitVar)
std::vector< Double_t > data
void setErrorReduction(Double_t sErrorReduction)