21 #include "TStopwatch.h"
217 Double_t bestSplitValue = 0;
218 Int_t bestSplitVariable = -1;
219 Double_t bestErrorReduction = 0;
225 Double_t candidateErrorReduction = 0;
229 for(
unsigned int i=0;
i<
events[0].size();
i++)
236 unsigned int numVars =
events.size();
239 for(
unsigned int variableToCheck = 1; variableToCheck < numVars; variableToCheck++)
242 Double_t SUMleft = 0;
243 Double_t SUMright =
SUM;
247 Int_t nright =
events[variableToCheck].size()-1;
249 Int_t candidateSplitVariable = variableToCheck;
251 std::vector<Event*>&
v =
events[variableToCheck];
254 for(
unsigned int i=1;
i<v.size();
i++)
259 SUMleft = SUMleft + v[
i-1]->data[0];
260 SUMright = SUMright - v[
i-1]->data[0];
263 if(v[
i-1]->
data[candidateSplitVariable] < v[
i]->
data[candidateSplitVariable])
267 candidateErrorReduction = SUMleft*SUMleft/nleft + SUMright*SUMright/nright - SUM*SUM/
numEvents;
271 if(candidateErrorReduction > bestErrorReduction)
273 bestErrorReduction = candidateErrorReduction;
274 bestSplitValue = (v[
i-1]->data[candidateSplitVariable] + v[
i]->data[candidateSplitVariable])/2;
275 bestSplitVariable = candidateSplitVariable;
314 std::cout << std::endl <<
"Listing Events... " << std::endl;
316 for(
unsigned int i=0;
i <
events.size();
i++)
318 std::cout << std::endl <<
"Variable " <<
i <<
" vector contents: " << std::endl;
319 for(
unsigned int j=0;
j <
events[
i].size();
j++)
364 std::vector< std::vector<Event*> >
l(
events.size());
365 std::vector< std::vector<Event*> >
r(
events.size());
367 for(
unsigned int i=0;
i<
events.size();
i++)
369 for(
unsigned int j=0;
j<
events[
i].size();
j++)
372 if(e->
data[sv] < sp)
l[
i].push_back(e);
373 if(e->
data[sv] > sp)
r[
i].push_back(e);
377 events = std::vector< std::vector<Event*> >();
void setLeftDaughter(Node *sLeftDaughter)
void setAvgError(Double_t sAvgError)
void setSplitValue(Double_t sSplitValue)
void setNumEvents(Int_t sNumEvents)
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)
void setTotalError(Double_t sTotalError)
void setSplitVariable(Int_t sSplitVar)
std::vector< Double_t > data
void setErrorReduction(Double_t sErrorReduction)