21 #include "TStopwatch.h"
220 Double_t bestSplitValue = 0;
221 Int_t bestSplitVariable = -1;
222 Double_t bestErrorReduction = -1;
228 Double_t candidateErrorReduction = -1;
232 for(
unsigned int i=0;
i<
events[0].size();
i++)
239 unsigned int numVars =
events.size();
242 for(
unsigned int variableToCheck = 1; variableToCheck < numVars; variableToCheck++)
246 Double_t SUMleft = 0;
247 Double_t SUMright =
SUM;
251 Int_t nright =
events[variableToCheck].size()-1;
253 Int_t candidateSplitVariable = variableToCheck;
255 std::vector<Event*>&
v =
events[variableToCheck];
258 for(
unsigned int i=1;
i<v.size();
i++)
263 SUMleft = SUMleft + v[
i-1]->data[0];
264 SUMright = SUMright - v[
i-1]->data[0];
267 if(v[
i-1]->
data[candidateSplitVariable] < v[
i]->
data[candidateSplitVariable])
271 candidateErrorReduction = SUMleft*SUMleft/nleft + SUMright*SUMright/nright - SUM*SUM/
numEvents;
275 if(candidateErrorReduction > bestErrorReduction)
277 bestErrorReduction = candidateErrorReduction;
278 bestSplitValue = (v[
i-1]->data[candidateSplitVariable] + v[
i]->data[candidateSplitVariable])/2;
279 bestSplitVariable = candidateSplitVariable;
319 std::cout << std::endl <<
"Listing Events... " << std::endl;
321 for(
unsigned int i=0;
i <
events.size();
i++)
323 std::cout << std::endl <<
"Variable " <<
i <<
" vector contents: " << std::endl;
324 for(
unsigned int j=0;
j <
events[
i].size();
j++)
369 std::vector< std::vector<Event*> >
l(
events.size());
370 std::vector< std::vector<Event*> >
r(
events.size());
372 for(
unsigned int i=0;
i<
events.size();
i++)
374 for(
unsigned int j=0;
j<
events[
i].size();
j++)
377 if(e->
data[sv] < sp)
l[
i].push_back(e);
378 if(e->
data[sv] > sp)
r[
i].push_back(e);
382 events = std::vector< std::vector<Event*> >();
408 if(left ==0 || right ==0)
return 0;
410 if(e->
data[sv] < sp) nextNode = left;
411 if(e->
data[sv] > sp) nextNode = right;
Node * getRightDaughter()
std::vector< std::vector< emtf::Event * > > events
void setErrorReduction(Double_t sErrorReduction)
void setEvents(std::vector< std::vector< emtf::Event * > > &sEvents)
void setNumEvents(Int_t sNumEvents)
void setRightDaughter(Node *sLeftDaughter)
void setAvgError(Double_t sAvgError)
Double_t getErrorReduction()
std::vector< Double_t > data
void setFitValue(Double_t sFitValue)
std::vector< std::vector< emtf::Event * > > & getEvents()
void setTotalError(Double_t sTotalError)
void setSplitVariable(Int_t sSplitVar)
void setParent(Node *sParent)
void setName(std::string sName)
char data[epos_bytes_allocation]
void setSplitValue(Double_t sSplitValue)
Node * filterEventToDaughter(emtf::Event *e)
void filterEventsToDaughters()
void setLeftDaughter(Node *sLeftDaughter)
void theMiracleOfChildBirth()