CMS 3D CMS Logo

Tree.h
Go to the documentation of this file.
1 // Tree.h
2 
3 #ifndef L1Trigger_L1TMuonEndCap_emtf_Tree
4 #define L1Trigger_L1TMuonEndCap_emtf_Tree
5 
6 #include <list>
7 #include "Node.h"
8 #include "TXMLEngine.h"
10 
11 namespace emtf {
12 
13 //class Node;
14 
15 class Tree
16 {
17  public:
18  Tree();
19  Tree(std::vector< std::vector<Event*> >& cEvents);
20  ~Tree();
21 
22  Tree(const Tree &tree);
23  Tree& operator=(const Tree &tree);
24  Tree(Tree && tree);
25 
26  void setRootNode(Node *sRootNode);
27  Node* getRootNode();
28 
29  void setTerminalNodes(std::list<Node*>& sTNodes);
30  std::list<Node*>& getTerminalNodes();
31 
32  int getNumTerminalNodes();
33 
34  void buildTree(int nodeLimit);
35  void calcError();
36  void filterEvents(std::vector<Event*>& tEvents);
37  void filterEventsRecursive(Node* node);
39  Node* filterEventRecursive(Node* node, Event* e);
40 
41  void saveToXML(const char* filename);
42  void saveToXMLRecursive(TXMLEngine* xml, Node* node, XMLNodePointer_t np);
43  void addXMLAttributes(TXMLEngine* xml, Node* node, XMLNodePointer_t np);
44 
45  void loadFromXML(const char* filename);
46  void loadFromXMLRecursive(TXMLEngine* xml, XMLNodePointer_t node, Node* tnode);
49 
50  void rankVariables(std::vector<double>& v);
51  void rankVariablesRecursive(Node* node, std::vector<double>& v);
52 
53  void getSplitValues(std::vector<std::vector<double>>& v);
54  void getSplitValuesRecursive(Node* node, std::vector<std::vector<double>>& v);
55 
56  double getBoostWeight(void) const { return boostWeight; }
57  void setBoostWeight(double wgt) { boostWeight = wgt; }
58 
59  private:
61  std::list<Node*> terminalNodes;
63  double rmsError;
64  double boostWeight;
65  unsigned xmlVersion; // affects only XML loading part, save uses an old format and looses the boostWeight
66 
67  // this is the main recursive workhorse function that compensates for Nodes being non-copyable
68  Node* copyFrom(const Node *local_root); // no garantees if throws in the process
69  // a dumb DFS tree traversal
70  void findLeafs(Node *local_root, std::list<Node*> &tn);
71 };
72 
73 } // end of emtf namespace
74 
75 #endif
Node * filterEventRecursive(Node *node, Event *e)
Definition: Tree.cc:310
std::list< Node * > terminalNodes
Definition: Tree.h:61
void buildTree(int nodeLimit)
Definition: Tree.cc:203
void getSplitValues(std::vector< std::vector< double >> &v)
Definition: Tree.cc:396
Tree()
Definition: Tree.cc:29
void loadFromXMLRecursive(TXMLEngine *xml, XMLNodePointer_t node, Node *tnode)
Definition: Tree.cc:516
double rmsError
Definition: Tree.h:63
int getNumTerminalNodes()
Definition: Tree.cc:178
void addXMLAttributes(TXMLEngine *xml, Node *node, XMLNodePointer_t np)
Definition: Tree.cc:417
Node * getRootNode()
Definition: Tree.cc:159
void loadFromCondPayloadRecursive(const L1TMuonEndCapForest::DTree &tree, const L1TMuonEndCapForest::DTreeNode &node, Node *tnode)
Definition: Tree.cc:596
Definition: Event.h:15
Tree & operator=(const Tree &tree)
Definition: Tree.cc:77
void setTerminalNodes(std::list< Node * > &sTNodes)
Definition: Tree.cc:166
void findLeafs(Node *local_root, std::list< Node * > &tn)
Definition: Tree.cc:124
int np
Definition: AMPTWrapper.h:33
void setBoostWeight(double wgt)
Definition: Tree.h:57
void loadFromCondPayload(const L1TMuonEndCapForest::DTree &tree)
Definition: Tree.cc:586
void rankVariables(std::vector< double > &v)
Definition: Tree.cc:358
void rankVariablesRecursive(Node *node, std::vector< double > &v)
Definition: Tree.cc:325
void saveToXMLRecursive(TXMLEngine *xml, Node *node, XMLNodePointer_t np)
Definition: Tree.cc:454
std::vector< DTreeNode > DTree
std::list< Node * > & getTerminalNodes()
Definition: Tree.cc:171
Node * copyFrom(const Node *local_root)
Definition: Tree.cc:95
double getBoostWeight(void) const
Definition: Tree.h:56
void filterEventsRecursive(Node *node)
Definition: Tree.cc:280
int numTerminalNodes
Definition: Tree.h:62
void calcError()
Definition: Tree.cc:187
double boostWeight
Definition: Tree.h:64
Node * filterEvent(Event *e)
Definition: Tree.cc:298
void loadFromXML(const char *filename)
Definition: Tree.cc:476
void saveToXML(const char *filename)
Definition: Tree.cc:428
Node * rootNode
Definition: Tree.h:60
unsigned xmlVersion
Definition: Tree.h:65
Definition: tree.py:1
void filterEvents(std::vector< Event * > &tEvents)
Definition: Tree.cc:264
void setRootNode(Node *sRootNode)
Definition: Tree.cc:154
void getSplitValuesRecursive(Node *node, std::vector< std::vector< double >> &v)
Definition: Tree.cc:366
~Tree()
Definition: Tree.cc:54