LOGO

RestFrames  v1.0.0
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  TreePlot(const std::string& sname, const std::string& stitle);
53  ~TreePlot();
54 
55  virtual void Clear();
56 
57  void SetTree(const RestFrame& frame);
58  void SetTree(const Group& group);
59  void SetTree(const Jigsaw& jigsaw);
60 
61  void AddJigsaw(const Jigsaw& jigsaw);
62 
63  void Draw(const std::string& name = "",
64  const std::string& title = "",
65  bool invert_colors = false,
66  bool invert_node_colors = false);
67 
68  private:
69  TreeType m_Type;
70 
71  int m_Nrow;
72  std::vector<int> m_Ncol;
73  double m_Node_R;
74 
75  bool m_SelfAssembling;
76  std::map<const Jigsaw*,int> m_JigsawColorMap;
77  std::map<FrameType,int> m_FrameColorMap;
78 
79  ConstRestFrameList m_Frames;
80  ConstJigsawList m_Jigsaws;
81  const Group* m_GroupPtr;
82 
83  int m_color_Node_text[4];
84  int m_color_Node_line[4];
85  int m_color_Node_fill[4];
86  int m_color_Default_text;
87  int m_color_Default_line;
88  int m_color_Default_fill;
89  int m_color_Text;
90  int m_color_Bkg;
91  std::vector<int> m_color_Leaf;
92  int m_style_Default;
93  int m_style_Leaf;
94 
95  void ClearTree();
96 
97  void InitTreeGrid();
98 
99  std::string GetStateTitle(const State& state);
100  std::string GetSetTitle(const std::string& set,
101  const std::string& index);
102 
103  void AddFrame(const RestFrame& frame);
104  void FillFrameTree(const RestFrame& frame);
105  void FillFrameTreeMap(int irow, const RestFrame& frame);
106  void FillFrameTreeMap(int irow, const DecayRecoFrame& frame);
107  void FillGroupTree(const Group& group);
108  void FillJigsawTree(const Jigsaw& jigsaw);
109  void FillStateTreeMap(int irow, const State& state);
110  void FillJigsawLink(const Jigsaw& jigsaw);
111 
112  void SetColors(bool invert_bkg_color,
113  bool invert_node_color);
114 
115  std::vector<TreePlotNode*> m_TreeNodes;
116  std::vector<TreePlotLink*> m_TreeLinks;
117  void DrawTreeLinks();
118  void DrawTreeNodes(bool with_rings = false);
119 
120  std::vector<TreePlotLink*> m_LeafLinks;
121  void DrawLeafLinks();
122 
123  void DrawLink(TreePlotLink* linkPtr);
124  void DrawNode(TreePlotNode* nodePtr, bool with_rings = false);
125 
126  void DrawFrameTypeLegend();
127  void DrawTitle(const std::string& title);
128  void DrawJigsawLegend();
129 
130  void ConvertNodeCoordinates(std::vector<TreePlotNode*>& nodesPtr);
131 
132  int GetJigsawPriority(int Nout, int Ndep) const;
133  TCanvas* GetNewCanvas(const std::string& name,
134  const std::string& title);
135  };
136 
137 }
138 
139 #endif
abstract base class for all Jigsaw objects
Definition: Jigsaw.hh:44
abstract base class for all Group objects
Definition: Group.hh:46
abstract base class for all Frame objects
abstract base class for all State objects
Definition: State.hh:44
virtual void Clear()
Clears RFBase of all connections to other objects.
Definition: TreePlot.cc:71