LOGO

RestFrames  v1.0.1
RestFrames HEP Event Analysis Software Library
Jigsaw.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 Jigsaw_HH
31 #define Jigsaw_HH
32 
33 #include "RestFrames/RFBase.hh"
34 #include "RestFrames/Group.hh"
35 
36 namespace RestFrames {
37 
38  enum JigsawType { kVanillaJigsaw, kInvisibleJigsaw,
39  kCombinatoricJigsaw };
40 
42  // Jigsaw class
44  class Jigsaw : public RFBase {
45  public:
46 
53  Jigsaw(const std::string& sname,
54  const std::string& stitle,
55  int Nchild, int Ndependancy);
56 
58  Jigsaw();
59 
60  virtual ~Jigsaw();
61 
63  virtual void Clear();
64 
68  JigsawType GetType() const { return m_Type; }
69 
73  virtual std::string GetLabel() const { return "Jigsaw"; }
74 
78  virtual std::string PrintString(LogType type) const;
79 
81  bool IsInvisibleJigsaw() const;
82 
84  bool IsCombinatoricJigsaw() const;
85 
95  virtual void SetGroup(Group& group = Group::Empty());
96 
100  virtual Group& GetGroup() const;
101 
105  virtual ConstRestFrameList GetParentFrames() const;
106 
112  virtual ConstRestFrameList const& GetChildFrames(int i) const;
113 
119  virtual ConstRestFrameList const& GetDependancyFrames(int i) const;
120 
124  void RemoveFrame(const RestFrame& frame);
125 
129  void RemoveFrames(const ConstRestFrameList& frames);
130 
134  static Jigsaw& Empty();
135 
136  protected:
137  JigsawType m_Type;
138  virtual bool IsSoundBody() const;
139 
140  virtual bool AnalyzeEvent() = 0;
141 
142  bool CanResolve(const State& state) const;
143  bool CanResolve(const ConstRestFrameList& frames) const;
144  bool DependsOnJigsaw(const Jigsaw& jigsaw) const;
145 
146  virtual bool InitializeTree();
147  virtual bool InitializeAnalysis();
148 
149  virtual bool InitializeDependancyJigsaws();
150  virtual bool InitializeJigsawExecutionList(JigsawList& exec_jigsaws, JigsawList& todo_jigsaws) = 0;
151 
152  void AddChildFrame(const RestFrame& frame, int i = 0);
153  void AddDependancyFrame(const RestFrame& frame, int i = 0);
154 
155  virtual int GetNChildren() const;
156  virtual State& GetChildState(int i) const;
157  virtual StateList const& GetChildStates() const;
158 
159  int GetNDependancyStates() const;
160  virtual StateList const& GetDependancyStates(int i) const;
161 
162  void SetParentState();
163  virtual void SetParentState(State& state);
164  virtual State const& GetParentState() const;
165 
166  virtual State& GetNewChildState() = 0;
167 
168  virtual void FillJigsawDependancies(JigsawList& jigsaws) const;
169  virtual void FillGroupJigsawDependancies(JigsawList& jigsaws) const;
170  virtual void FillGroupJigsawDependants(JigsawList& jigsaws) const;
171 
172  private:
173  Group* m_GroupPtr;
174  State* m_ParentStatePtr;
175 
176  const int m_Nchild;
177  const int m_Ndeps;
178 
179  StateList m_ChildStates;
180  StateListList m_DependancyStates;
181 
182  std::vector<ConstRestFrameList> m_ChildFrames;
183  std::vector<ConstRestFrameList> m_DependancyFrames;
184 
185  JigsawList m_DependancyJigsaws;
186 
187  static int m_class_key;
188 
189  friend class TreePlot;
190  friend class Group;
191  friend class LabRecoFrame;
192  friend class InvisibleJigsaw;
193  friend class CombinatoricJigsaw;
194 
195  };
196 
197 }
198 
199 #endif
RestFrames::Jigsaw::PrintString
virtual std::string PrintString(LogType type) const
Prints string of information associated with Jigsaw.
Definition: Jigsaw.cc:100
RestFrames::Jigsaw::GetType
JigsawType GetType() const
Returns jigsaw (JigsawType) type.
Definition: Jigsaw.hh:68
RestFrames::Jigsaw::SetGroup
virtual void SetGroup(Group &group=Group::Empty())
Sets group (Group) to current jigsaw.
Definition: Jigsaw.cc:109
RestFrames::Jigsaw::GetGroup
virtual Group & GetGroup() const
Returns group (Group) associated with this jigsaw.
Definition: Jigsaw.cc:130
RestFrames::Jigsaw::Jigsaw
Jigsaw()
Empty constructor.
Definition: Jigsaw.cc:61
RestFrames::Group::Empty
static Group & Empty()
Returns empty Group.
Definition: Group.cc:58
RestFrames::Jigsaw::GetDependancyFrames
virtual ConstRestFrameList const & GetDependancyFrames(int i) const
Returns list of frames in which this jigsaw depends on.
Definition: Jigsaw.cc:214
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
Definition: RFList.hh:43
RestFrames::RFBase
Base class for all RestFrame package objects.
Definition: RFBase.hh:53
RestFrames::Jigsaw::GetChildFrames
virtual ConstRestFrameList const & GetChildFrames(int i) const
Returns list of child frames associated with this jigsaw.
Definition: Jigsaw.cc:208
RestFrames::Jigsaw::Clear
virtual void Clear()
Clears Jigsaw of all connections to other objects.
Definition: Jigsaw.cc:74
RestFrames::Jigsaw::IsInvisibleJigsaw
bool IsInvisibleJigsaw() const
Is invisible jigsaw? (true/false)
Definition: Jigsaw.cc:92
RestFrames::LabRecoFrame
Definition: LabRecoFrame.hh:44
RestFrames::Jigsaw::GetLabel
virtual std::string GetLabel() const
Returns name of this Jigsaw.
Definition: Jigsaw.hh:73
RestFrames::LogType
LogType
Type of Log Message.
Definition: RFLog.hh:45
RFBase.hh
RestFrames::CombinatoricJigsaw
Definition: CombinatoricJigsaw.hh:40
RestFrames::Jigsaw::Empty
static Jigsaw & Empty()
Returns empty Jigsaw.
Definition: Jigsaw.cc:70
RestFrames::Jigsaw::GetParentFrames
virtual ConstRestFrameList GetParentFrames() const
Returns list of parent frames associated with this jigsaw.
Definition: Jigsaw.cc:201
RestFrames::TreePlot
Definition: TreePlot.hh:50
RestFrames::Jigsaw::RemoveFrame
void RemoveFrame(const RestFrame &frame)
Removes a frame from this jigsaw.
Definition: Jigsaw.cc:364
RestFrames::Jigsaw
abstract base class for all Jigsaw objects
Definition: Jigsaw.hh:44
RestFrames::InvisibleJigsaw
Definition: InvisibleJigsaw.hh:39
RestFrames::Jigsaw::RemoveFrames
void RemoveFrames(const ConstRestFrameList &frames)
Removes a list of frames from this jigsaw.
Definition: Jigsaw.cc:376
RestFrames::State
Abstract base class for all State objects.
Definition: State.hh:47
RestFrames::Jigsaw::IsCombinatoricJigsaw
bool IsCombinatoricJigsaw() const
Is combinatoric jigsaw? (true/false)
Definition: Jigsaw.cc:96
Group.hh