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  public:
17  Tree();
18  Tree(std::vector<std::vector<Event*>>& cEvents);
19  ~Tree();
20 
21  Tree(const Tree& tree);
22  Tree& operator=(const Tree& tree);
23  Tree(Tree&& tree);
24 
25  void setRootNode(Node* sRootNode);
26  Node* getRootNode();
27 
28  void setTerminalNodes(std::list<Node*>& sTNodes);
29  std::list<Node*>& getTerminalNodes();
30 
31  int getNumTerminalNodes();
32 
33  void buildTree(int nodeLimit);
34  void calcError();
35  void filterEvents(std::vector<Event*>& tEvents);
36  void filterEventsRecursive(Node* node);
39 
40  void saveToXML(const char* filename);
41  void saveToXMLRecursive(TXMLEngine* xml, Node* node, XMLNodePointer_t np);
42  void addXMLAttributes(TXMLEngine* xml, Node* node, XMLNodePointer_t np);
43 
44  void loadFromXML(const char* filename);
45  void loadFromXMLRecursive(TXMLEngine* xml, XMLNodePointer_t node, Node* tnode);
49  Node* tnode);
50 
51  void rankVariables(std::vector<double>& v);
52  void rankVariablesRecursive(Node* node, std::vector<double>& v);
53 
54  void getSplitValues(std::vector<std::vector<double>>& v);
55  void getSplitValuesRecursive(Node* node, std::vector<std::vector<double>>& v);
56 
57  double getBoostWeight(void) const { return boostWeight; }
58  void setBoostWeight(double wgt) { boostWeight = wgt; }
59 
60  private:
62  std::list<Node*> terminalNodes;
64  double rmsError;
65  double boostWeight;
66  unsigned xmlVersion; // affects only XML loading part, save uses an old format and looses the boostWeight
67 
68  // this is the main recursive workhorse function that compensates for Nodes being non-copyable
69  Node* copyFrom(const Node* local_root); // no garantees if throws in the process
70  // a dumb DFS tree traversal
71  void findLeafs(Node* local_root, std::list<Node*>& tn);
72  };
73 
74 } // namespace emtf
75 
76 #endif
emtf::Tree::buildTree
void buildTree(int nodeLimit)
Definition: Tree.cc:185
emtf::Tree::addXMLAttributes
void addXMLAttributes(TXMLEngine *xml, Node *node, XMLNodePointer_t np)
Definition: Tree.cc:381
emtf::Tree
Definition: Tree.h:15
emtf::Tree::getNumTerminalNodes
int getNumTerminalNodes()
Definition: Tree.cc:165
emtf::Tree::terminalNodes
std::list< Node * > terminalNodes
Definition: Tree.h:62
emtf::Tree::loadFromCondPayload
void loadFromCondPayload(const L1TMuonEndCapForest::DTree &tree)
Definition: Tree.cc:542
emtf::Tree::boostWeight
double boostWeight
Definition: Tree.h:65
tree
Definition: tree.py:1
np
int np
Definition: AMPTWrapper.h:43
emtf::Tree::getTerminalNodes
std::list< Node * > & getTerminalNodes()
Definition: Tree.cc:161
emtf::Tree::saveToXML
void saveToXML(const char *filename)
Definition: Tree.cc:391
emtf::Tree::setBoostWeight
void setBoostWeight(double wgt)
Definition: Tree.h:58
emtf::Tree::findLeafs
void findLeafs(Node *local_root, std::list< Node * > &tn)
Definition: Tree.cc:124
findQualityFiles.v
v
Definition: findQualityFiles.py:179
emtf::Tree::operator=
Tree & operator=(const Tree &tree)
Definition: Tree.cc:74
emtf::Tree::saveToXMLRecursive
void saveToXMLRecursive(TXMLEngine *xml, Node *node, XMLNodePointer_t np)
Definition: Tree.cc:415
emtf::Event
Definition: Event.h:17
emtf::Tree::filterEventsRecursive
void filterEventsRecursive(Node *node)
Definition: Tree.cc:258
emtf::Tree::getBoostWeight
double getBoostWeight(void) const
Definition: Tree.h:57
emtf
Definition: Event.h:15
emtf::Tree::Tree
Tree()
Definition: Tree.cc:30
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
L1TMuonEndCapForest::DTreeNode
Definition: L1TMuonEndCapForest.h:17
L1TMuonEndCapForest.h
emtf::Tree::setTerminalNodes
void setTerminalNodes(std::list< Node * > &sTNodes)
Definition: Tree.cc:159
emtf::Tree::getRootNode
Node * getRootNode()
Definition: Tree.cc:155
Node.h
emtf::Tree::calcError
void calcError()
Definition: Tree.cc:171
emtf::Tree::rankVariables
void rankVariables(std::vector< double > &v)
Definition: Tree.cc:332
emtf::Tree::rmsError
double rmsError
Definition: Tree.h:64
emtf::Tree::xmlVersion
unsigned xmlVersion
Definition: Tree.h:66
emtf::Tree::loadFromCondPayloadRecursive
void loadFromCondPayloadRecursive(const L1TMuonEndCapForest::DTree &tree, const L1TMuonEndCapForest::DTreeNode &node, Node *tnode)
Definition: Tree.cc:552
L1TMuonEndCapForest::DTree
std::vector< DTreeNode > DTree
Definition: L1TMuonEndCapForest.h:31
emtf::Tree::setRootNode
void setRootNode(Node *sRootNode)
Definition: Tree.cc:153
emtf::Tree::~Tree
~Tree()
Definition: Tree.cc:52
emtf::Tree::loadFromXML
void loadFromXML(const char *filename)
Definition: Tree.cc:437
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
emtf::Tree::filterEventRecursive
Node * filterEventRecursive(Node *node, Event *e)
Definition: Tree.cc:287
emtf::Tree::loadFromXMLRecursive
void loadFromXMLRecursive(TXMLEngine *xml, XMLNodePointer_t node, Node *tnode)
Definition: Tree.cc:475
emtf::Tree::filterEvents
void filterEvents(std::vector< Event * > &tEvents)
Definition: Tree.cc:243
emtf::Tree::copyFrom
Node * copyFrom(const Node *local_root)
Definition: Tree.cc:93
emtf::Tree::filterEvent
Node * filterEvent(Event *e)
Definition: Tree.cc:276
emtf::Node
Definition: Node.h:12
emtf::Tree::getSplitValues
void getSplitValues(std::vector< std::vector< double >> &v)
Definition: Tree.cc:364
emtf::Tree::rootNode
Node * rootNode
Definition: Tree.h:61
emtf::Tree::rankVariablesRecursive
void rankVariablesRecursive(Node *node, std::vector< double > &v)
Definition: Tree.cc:300
emtf::Tree::numTerminalNodes
int numTerminalNodes
Definition: Tree.h:63
emtf::Tree::getSplitValuesRecursive
void getSplitValuesRecursive(Node *node, std::vector< std::vector< double >> &v)
Definition: Tree.cc:336
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37