96 Double_t totalSquaredError = 0;
100 totalSquaredError += (*it)->getTotalError();
110 Double_t bestNodeErrorReduction = -1;
111 Node* nodeToSplit = 0;
122 if( (*it)->getErrorReduction() > bestNodeErrorReduction )
124 bestNodeErrorReduction = (*it)->getErrorReduction();
132 if(nodeToSplit == 0)
return;
192 if(left == 0 || right == 0)
return;
221 if(nextNode == 0)
return node;
239 if(left==0 || right==0)
return;
279 if(left==0 || right==0)
return;
286 std::cout <<
"ERROR: negative split variable for nonterminal node." << std::endl;
287 std::cout <<
"rankVarRecursive Split Variable = " << sv << std::endl;
309 template <
typename T>
313 std::stringstream
ss;
335 TXMLEngine* xml =
new TXMLEngine();
345 XMLDocPointer_t
xmldoc = xml->NewDoc();
346 xml->DocSetRootElement(xmldoc, root);
349 xml->SaveDoc(xmldoc, c);
352 xml->FreeDoc(xmldoc);
363 if(l==0 || r==0)
return;
366 XMLNodePointer_t left = xml->NewChild(np, 0,
"left");
367 XMLNodePointer_t right = xml->NewChild(np, 0,
"right");
383 TXMLEngine* xml =
new TXMLEngine;
386 XMLDocPointer_t
xmldoc = xml->ParseFile(filename);
394 XMLNodePointer_t mainnode = xml->DocGetRootElement(xmldoc);
400 xml->FreeDoc(xmldoc);
410 XMLAttrPointer_t attr = xml->GetFirstAttr(xnode);
411 std::vector<std::string> splitInfo(3);
412 for(
unsigned int i=0;
i<3;
i++)
414 splitInfo[
i] = xml->GetAttrValue(attr);
415 attr = xml->GetNextAttr(attr);
419 std::stringstream converter;
424 converter << splitInfo[0];
425 converter >> splitVar;
429 converter << splitInfo[1];
430 converter >> splitVal;
434 converter << splitInfo[2];
445 XMLNodePointer_t xleft = xml->GetChild(xnode);
446 XMLNodePointer_t xright = xml->GetNext(xleft);
449 if(xleft == 0 || xright == 0)
return;
Node * filterEvent(Event *e)
void filterEventsRecursive(Node *node)
void rankVariablesRecursive(Node *node, std::vector< Double_t > &v)
void loadFromXML(const char *filename)
void setSplitValue(Double_t sSplitValue)
void setTerminalNodes(std::list< Node * > &sTNodes)
Node * filterEventToDaughter(Event *e)
std::list< Node * > terminalNodes
void buildTree(Int_t nodeLimit)
void saveToXMLRecursive(TXMLEngine *xml, Node *node, XMLNodePointer_t np)
void theMiracleOfChildBirth()
void getSplitValues(std::vector< std::vector< Double_t >> &v)
Node * getRightDaughter()
void getSplitValuesRecursive(Node *node, std::vector< std::vector< Double_t >> &v)
void setRootNode(Node *sRootNode)
void filterEventsToDaughters()
Node * filterEventRecursive(Node *node, Event *e)
std::vector< std::vector< Event * > > & getEvents()
void setEvents(std::vector< std::vector< Event * > > &sEvents)
Double_t getErrorReduction()
void setFitValue(Double_t sFitValue)
std::list< Node * > & getTerminalNodes()
void addXMLAttributes(TXMLEngine *xml, Node *node, XMLNodePointer_t np)
void filterEvents(std::vector< Event * > &tEvents)
void setSplitVariable(Int_t sSplitVar)
void rankVariables(std::vector< Double_t > &v)
edm::TrieNode< PDet > Node
void saveToXML(const char *filename)
std::string numToStr(T num)
void loadFromXMLRecursive(TXMLEngine *xml, XMLNodePointer_t node, Node *tnode)
Int_t getNumTerminalNodes()