LOGO

RestFrames  v1.0.1
RestFrames HEP Event Analysis Software Library
TreePlot.hh
Go to the documentation of this file.
1 // RestFrames: particle physics event analysis library
3 // --------------------------------------------------------------------
4 // Copyright (c) 2014-2016, Christopher Rogan
14 // This file is part of RestFrames.
15 //
16 // RestFrames is free software; you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation; either version 2 of the License, or
19 // (at your option) any later version.
20 //
21 // RestFrames is distributed in the hope that it will be useful,
22 // but WITHOUT ANY WARRANTY; without even the implied warranty of
23 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 // GNU General Public License for more details.
25 //
26 // You should have received a copy of the GNU General Public License
27 // along with RestFrames. If not, see <http://www.gnu.org/licenses/>.
29 
30 #ifndef TreePlot_HH
31 #define TreePlot_HH
32 
33 #include <TCanvas.h>
34 
35 #include "RestFrames/RFPlot.hh"
36 #include "RestFrames/RestFrame.hh"
37 
38 namespace RestFrames {
39 
40  class ReconstructionFrame;
41  class DecayRecoFrame;
42  class Jigsaw;
43  class Group;
44  class State;
45  class TreePlotNode;
46  class TreePlotLink;
47 
48  enum TreeType { kVanillaTree, kFrameTree, kGroupTree };
49 
50  class TreePlot : public RFPlot {
51  public:
52 
57  TreePlot(const std::string& sname, const std::string& stitle);
58  ~TreePlot();
59 
61  virtual void Clear();
62 
66  void SetTree(const RestFrame& frame);
67 
71  void SetTree(const Group& group);
72 
79  void SetTree(const Jigsaw& jigsaw);
80 
84  void AddJigsaw(const Jigsaw& jigsaw);
85 
94  void Draw(const std::string& name = "",
95  const std::string& title = "",
96  bool invert_colors = false,
97  bool invert_node_colors = false);
98 
99  private:
100  TreeType m_Type;
101 
102  int m_Nrow;
103  std::vector<int> m_Ncol;
104  double m_Node_R;
105 
106  bool m_SelfAssembling;
107  std::map<const Jigsaw*,int> m_JigsawColorMap;
108  std::map<FrameType,int> m_FrameColorMap;
109 
110  ConstRestFrameList m_Frames;
111  ConstJigsawList m_Jigsaws;
112  const Group* m_GroupPtr;
113 
114  int m_color_Node_text[4];
115  int m_color_Node_line[4];
116  int m_color_Node_fill[4];
117  int m_color_Default_text;
118  int m_color_Default_line;
119  int m_color_Default_fill;
120  int m_color_Text;
121  int m_color_Bkg;
122  std::vector<int> m_color_Leaf;
123  int m_style_Default;
124  int m_style_Leaf;
125 
126  void ClearTree();
127 
128  void InitTreeGrid();
129 
130  std::string GetStateTitle(const State& state);
131  std::string GetSetTitle(const std::string& set,
132  const std::string& index);
133 
134  void AddFrame(const RestFrame& frame);
135  void FillFrameTree(const RestFrame& frame);
136  void FillFrameTreeMap(int irow, const RestFrame& frame);
137  void FillFrameTreeMap(int irow, const DecayRecoFrame& frame);
138  void FillGroupTree(const Group& group);
139  void FillJigsawTree(const Jigsaw& jigsaw);
140  void FillStateTreeMap(int irow, const State& state);
141  void FillJigsawLink(const Jigsaw& jigsaw);
142 
143  void SetColors(bool invert_bkg_color,
144  bool invert_node_color);
145 
146  std::vector<TreePlotNode*> m_TreeNodes;
147  std::vector<TreePlotLink*> m_TreeLinks;
148  void DrawTreeLinks();
149  void DrawTreeNodes(bool with_rings = false);
150 
151  std::vector<TreePlotLink*> m_LeafLinks;
152  void DrawLeafLinks();
153 
154  void DrawLink(TreePlotLink* linkPtr);
155  void DrawNode(TreePlotNode* nodePtr, bool with_rings = false);
156 
157  void DrawFrameTypeLegend();
158  void DrawTitle(const std::string& title);
159  void DrawJigsawLegend();
160 
161  void ConvertNodeCoordinates(std::vector<TreePlotNode*>& nodesPtr);
162 
163  int GetJigsawPriority(int Nout, int Ndep) const;
164  TCanvas* GetNewCanvas(const std::string& name,
165  const std::string& title);
166  };
167 
168 }
169 
170 #endif
RestFrames::TreePlot::AddJigsaw
void AddJigsaw(const Jigsaw &jigsaw)
Adds a jigsaw to a frame tree and shows how jigsaw could affect the tree.
Definition: TreePlot.cc:170
RestFrames::TreePlot::Draw
void Draw(const std::string &name="", const std::string &title="", bool invert_colors=false, bool invert_node_colors=false)
Draws tree.
Definition: TreePlot.cc:127
RFPlot.hh
RestFrames::TreePlot::Clear
virtual void Clear()
Clears TreePlot from all connections to other objects.
Definition: TreePlot.cc:71
RestFrames::RestFrame
abstract base class for all Frame objects
Definition: RestFrame.hh:45
RestFrames::Group
abstract base class for all Group objects
Definition: Group.hh:46
RestFrames::RFList< const RestFrame >
RestFrames::TreePlotNode
Definition: TreePlotNode.hh:42
RestFrames::TreePlot::SetTree
void SetTree(const RestFrame &frame)
Sets a tree that shows how a frame is connected to its children.
Definition: TreePlot.cc:160
RestFrames::TreePlot
Definition: TreePlot.hh:50
RestFrames::TreePlotLink
Definition: TreePlotLink.hh:40
RestFrames::RFPlot
Abstract base class for all plotting objects.
Definition: RFPlot.hh:41
RestFrames::Jigsaw
abstract base class for all Jigsaw objects
Definition: Jigsaw.hh:44
RestFrames::State
Abstract base class for all State objects.
Definition: State.hh:47
RestFrames::TreePlot::TreePlot
TreePlot(const std::string &sname, const std::string &stitle)
Standard constructor.
Definition: TreePlot.cc:58
RestFrames::DecayRecoFrame
Definition: DecayRecoFrame.hh:43
RestFrame.hh