LOGO

RestFrames  v1.0.0
RestFrames HEP Event Analysis Software Library
State.cc
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 #include "RestFrames/State.hh"
32 #include "RestFrames/RestFrame.hh"
33 
34 namespace RestFrames {
35 
37  // State class
39  int State::m_class_key = 0;
40 
41  // constructor
42  State::State(const std::string& sname,
43  const std::string& stitle)
44  : RFBase(sname, stitle, State::m_class_key++)
45  {
46  m_Log.SetSource("State "+GetName());
47  m_Type = kVanillaState;
48  m_ParentJigsawPtr = nullptr;
49  m_ChildJigsawPtr = nullptr;
50  m_P.SetPxPyPzE(0.,0.,0.,0.);
51  m_Charge = 0;
52  }
53 
54  State::State() : RFBase() {
55  m_Type = kVanillaState;
56  m_Log.SetSource("State "+GetName());
57  }
58 
59  State::~State() {}
60 
61  void State::Clear(){
62  m_ParentJigsawPtr = nullptr;
63  m_ChildJigsawPtr = nullptr;
64  m_P.SetPxPyPzE(0.,0.,0.,0.);
65  m_Frames.Clear();
66  }
67 
68  State& State::Empty(){
69  return VisibleState::Empty();
70  }
71 
72  StateList const& State::EmptyList(){
73  return m_EmptyList;
74  }
75 
77  StateType State::GetType() const {
78  return m_Type;
79  }
80 
82  bool State::IsVisibleState() const {
83  return m_Type == kVisibleState;
84  }
85 
87  bool State::IsInvisibleState() const {
88  return m_Type == kInvisibleState;
89  }
90 
93  return m_Type == kCombinatoricState;
94  }
95 
96  void State::AddFrames(const ConstRestFrameList& frames){
97  int N = frames.GetN();
98  for(int i = 0; i < N; i++)
99  AddFrame(frames[i]);
100  }
101 
102  ConstRestFrameList const& State::GetListFrames() const {
103  return m_Frames;
104  }
105 
106  int State::GetNFrames() const {
107  return m_Frames.GetN();
108  }
109 
110  bool State::IsFrame(const RestFrame& frame) const {
111  if(!frame) return false;
112  if(m_Frames.GetN() != 1) return false;
113  return m_Frames[0] == frame;
114  }
115 
116  bool State::IsFrames(const ConstRestFrameList& frames) const {
117  return m_Frames == frames;
118  }
119 
120  void State::SetParentJigsaw(Jigsaw& jigsaw){
121  if(IsEmpty()) return;
122 
123  if(!jigsaw)
124  m_ParentJigsawPtr = nullptr;
125  else
126  m_ParentJigsawPtr = &jigsaw;
127  }
128 
129  void State::SetChildJigsaw(Jigsaw& jigsaw){
130  if(IsEmpty()) return;
131 
132  if(!jigsaw)
133  m_ChildJigsawPtr = nullptr;
134  else
135  m_ChildJigsawPtr = &jigsaw;
136  }
137 
138  Jigsaw& State::GetParentJigsaw() const {
139  if(m_ParentJigsawPtr)
140  return *m_ParentJigsawPtr;
141  else
142  return Jigsaw::Empty();
143  }
144 
145  Jigsaw& State::GetChildJigsaw() const {
146  if(m_ChildJigsawPtr)
147  return *m_ChildJigsawPtr;
148  else
149  return Jigsaw::Empty();
150  }
151 
152  void State::Boost(const TVector3& B){
153  m_P.Boost(B);
154  }
155 
156  void State::SetFourVector(const TLorentzVector& V){
157  m_P = V;
158  }
159 
160  TLorentzVector State::GetFourVector() const {
161  return m_P;
162  }
163 
164  RFCharge State::GetCharge() const {
165  return m_Charge;
166  }
167 
168  const StateList State::m_EmptyList;
169 
170 }
std::string GetName() const
Returns object name.
Definition: RFBase.cc:104
bool IsCombinatoricState() const
Is this a CombinatoricState? (true/false)
Definition: State.cc:92
bool IsEmpty() const
Checks whether this is default (empty) instance of class.
Definition: RFBase.cc:84
virtual void Clear()
Clears RFBase of all connections to other objects.
Definition: State.cc:61
StateType GetType() const
Returns State (StateType) type.
Definition: State.cc:77
bool IsInvisibleState() const
Is this an InvisibleState? (true/false)
Definition: State.cc:87
abstract base class for all State objects
Definition: State.hh:44
bool IsVisibleState() const
Is this a VisibleState? (true/false)
Definition: State.cc:82