LOGO

RestFrames  v1.0.1
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 
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 
69  return VisibleState::Empty();
70  }
71 
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 
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 
121  if(IsEmpty()) return;
122 
123  if(!jigsaw)
124  m_ParentJigsawPtr = nullptr;
125  else
126  m_ParentJigsawPtr = &jigsaw;
127  }
128 
130  if(IsEmpty()) return;
131 
132  if(!jigsaw)
133  m_ChildJigsawPtr = nullptr;
134  else
135  m_ChildJigsawPtr = &jigsaw;
136  }
137 
139  if(m_ParentJigsawPtr)
140  return *m_ParentJigsawPtr;
141  else
142  return Jigsaw::Empty();
143  }
144 
146  if(m_ChildJigsawPtr)
147  return *m_ChildJigsawPtr;
148  else
149  return Jigsaw::Empty();
150  }
151 
152  void State::Boost(const TVector3& B){
153  if(B.Mag() >= 1)
154  return;
155 
156  m_P.Boost(B);
157 
158  SetFourVector(m_P);
159  }
160 
161  void State::SetFourVector(const TLorentzVector& V){
162  m_P.SetVectM(V.Vect(), std::max(0., V.M()));
163  }
164 
165  TLorentzVector State::GetFourVector() const {
166  return m_P;
167  }
168 
170  return m_Charge;
171  }
172 
173  const StateList State::m_EmptyList;
174 
175 }
RestFrames::State::State
State()
Empty constructor.
Definition: State.cc:54
RestFrames::State::GetNFrames
int GetNFrames() const
Returns number of frames (RestFrame) contained in this state.
Definition: State.cc:106
RestFrames::State::IsCombinatoricState
bool IsCombinatoricState() const
Is this a CombinatoricState? (true/false)
Definition: State.cc:92
RestFrames::State::GetType
StateType GetType() const
Returns State (StateType) type.
Definition: State.cc:77
RestFrames::State::EmptyList
static StateList const & EmptyList()
Returns empty StateList.
Definition: State.cc:72
RestFrames::RFCharge
Definition: RFCharge.hh:40
RestFrames::RestFrame
abstract base class for all Frame objects
Definition: RestFrame.hh:45
RestFrames::RFBase::IsEmpty
bool IsEmpty() const
Checks whether this is default (empty) instance of class.
Definition: RFBase.cc:84
RestFrames::State::SetFourVector
virtual void SetFourVector(const TLorentzVector &V)
Sets four-vector of this frame.
Definition: State.cc:161
RestFrames::RFList< State >
RestFrames::RFBase
Base class for all RestFrame package objects.
Definition: RFBase.hh:53
RestFrames::State::GetFourVector
virtual TLorentzVector GetFourVector() const
Returns four vector of this frame.
Definition: State.cc:165
RestFrames::VisibleState::Empty
static VisibleState & Empty()
Returns empty VisibleState.
Definition: VisibleState.cc:53
RestFrames::State::Clear
virtual void Clear()
Clears State of all connections to other objects.
Definition: State.cc:61
RestFrames::RFBase::GetName
std::string GetName() const
Returns object name.
Definition: RFBase.cc:104
RestFrames::State::GetCharge
virtual RFCharge GetCharge() const
Returns charge of this frames.
Definition: State.cc:169
RestFrames::RFLog::SetSource
void SetSource(const std::string &source)
Sets name of instance that is associated with.
Definition: RFLog.cc:182
RestFrames::State::SetChildJigsaw
virtual void SetChildJigsaw(Jigsaw &jigsaw=Jigsaw::Empty())
Sets the child jigsaw (Jigsaw) to jigsaw
Definition: State.cc:129
State.hh
RestFrames::State::GetListFrames
ConstRestFrameList const & GetListFrames() const
Returns list of frames (RestFrame) contained in this state.
Definition: State.cc:102
RestFrames::State::IsFrames
virtual bool IsFrames(const ConstRestFrameList &frames) const
Checks if frames lists of state corresponds frames
Definition: State.cc:116
RestFrames::State::Empty
static State & Empty()
Returns empty state.
Definition: State.cc:68
RestFrames::State::AddFrames
virtual void AddFrames(const ConstRestFrameList &frames)
Adds a list of frames (RestFrame) to this state.
Definition: State.cc:96
VisibleState.hh
RestFrames::Jigsaw::Empty
static Jigsaw & Empty()
Returns empty Jigsaw.
Definition: Jigsaw.cc:70
RestFrames::State::AddFrame
virtual void AddFrame(const RestFrame &frame)=0
Pure virtual function defined in derivatives of State class.
RestFrames::State::SetParentJigsaw
virtual void SetParentJigsaw(Jigsaw &jigsaw=Jigsaw::Empty())
Sets the parent jigsaw (Jigsaw) to jigsaw
Definition: State.cc:120
RestFrames::State::IsVisibleState
bool IsVisibleState() const
Is this a VisibleState? (true/false)
Definition: State.cc:82
RestFrames::State::IsFrame
virtual bool IsFrame(const RestFrame &frame) const
Checks if frame of state corresponds to frame
Definition: State.cc:110
RestFrames::State::IsInvisibleState
bool IsInvisibleState() const
Is this an InvisibleState? (true/false)
Definition: State.cc:87
RestFrames::State::Boost
virtual void Boost(const TVector3 &B)
Boosts to different frame (RestFrame)
Definition: State.cc:152
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::State::GetChildJigsaw
virtual Jigsaw & GetChildJigsaw() const
Returns the child of this jigsaw (Jigsaw)
Definition: State.cc:145
RestFrames::State::GetParentJigsaw
virtual Jigsaw & GetParentJigsaw() const
Returns the parent of this jigsaw (Jigsaw)
Definition: State.cc:138
RestFrame.hh