File indexing completed on 2025-03-23 23:40:23
0001
0002
0003 #ifndef L1Trigger_L1TMuonEndCap_emtf_Tree
0004 #define L1Trigger_L1TMuonEndCap_emtf_Tree
0005
0006 #include <list>
0007 #include <memory>
0008 #include "Node.h"
0009 #include "TXMLEngine.h"
0010 #include "CondFormats/L1TObjects/interface/L1TMuonEndCapForest.h"
0011
0012 namespace emtf {
0013
0014
0015
0016 class Tree {
0017 public:
0018 Tree();
0019 Tree(std::vector<std::vector<Event*>>& cEvents);
0020 ~Tree() = default;
0021
0022 Tree(const Tree& tree);
0023 Tree& operator=(const Tree& tree);
0024 Tree(Tree&& tree) noexcept = default;
0025
0026 void setRootNode(Node* sRootNode);
0027 Node* getRootNode();
0028 const Node* getRootNode() const;
0029
0030 void setTerminalNodes(std::list<Node*>& sTNodes);
0031 std::list<Node*>& getTerminalNodes();
0032
0033 int getNumTerminalNodes();
0034
0035 void buildTree(int nodeLimit);
0036 void calcError();
0037 void filterEvents(std::vector<Event*>& tEvents);
0038 void filterEventsRecursive(Node* node);
0039 Node* filterEvent(Event* e);
0040 Node* filterEventRecursive(Node* node, Event* e);
0041
0042 void saveToXML(const char* filename);
0043 void saveToXMLRecursive(TXMLEngine* xml, Node* node, XMLNodePointer_t np);
0044 void addXMLAttributes(TXMLEngine* xml, Node* node, XMLNodePointer_t np);
0045
0046 void loadFromXML(const char* filename);
0047 void loadFromXMLRecursive(TXMLEngine* xml, XMLNodePointer_t node, Node* tnode);
0048 void loadFromCondPayload(const L1TMuonEndCapForest::DTree& tree);
0049 void loadFromCondPayloadRecursive(const L1TMuonEndCapForest::DTree& tree,
0050 const L1TMuonEndCapForest::DTreeNode& node,
0051 Node* tnode);
0052
0053 void rankVariables(std::vector<double>& v) const;
0054 void rankVariablesRecursive(Node* node, std::vector<double>& v) const;
0055
0056 void getSplitValues(std::vector<std::vector<double>>& v) const;
0057 void getSplitValuesRecursive(Node* node, std::vector<std::vector<double>>& v) const;
0058
0059 double getBoostWeight(void) const { return boostWeight; }
0060 void setBoostWeight(double wgt) { boostWeight = wgt; }
0061
0062 private:
0063 std::unique_ptr<Node> rootNode;
0064 std::list<Node*> terminalNodes;
0065 int numTerminalNodes;
0066 double rmsError;
0067 double boostWeight;
0068 unsigned xmlVersion;
0069
0070
0071 std::unique_ptr<Node> copyFrom(const Node* local_root);
0072
0073 void findLeafs(Node* local_root, std::list<Node*>& tn);
0074 };
0075
0076 }
0077
0078 #endif