LOGO

RestFrames  v1.0.0
RestFrames HEP Event Analysis Software Library
VisibleState.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 
32 #include "RestFrames/Jigsaw.hh"
33 
34 namespace RestFrames {
35 
36  VisibleState::VisibleState(const std::string& sname,
37  const std::string& stitle)
38  : State(sname, stitle)
39  {
40  m_Type = kVisibleState;
41  m_FramePtr = nullptr;
42  }
43 
44  VisibleState::VisibleState() : State() {}
45 
46  VisibleState::~VisibleState() {}
47 
49  m_FramePtr = nullptr;
50  State::Clear();
51  }
52 
53  VisibleState& VisibleState::Empty(){
54  return VisibleState::m_Empty;
55  }
56 
57  void VisibleState::AddFrame(const RestFrame& frame){
58  if(IsEmpty()) return;
59 
60  if(!frame) return;
61  if(!frame.IsVisibleFrame() || !frame.IsRecoFrame()) return;
62  m_FramePtr = static_cast<const VisibleRecoFrame*>(&frame);
63  m_Frames.Clear();
64  m_Frames += frame;
65  }
66 
67  bool VisibleState::IsFrame(const RestFrame& frame) const {
68  if(!frame) return false;
69  if(!m_FramePtr) return false;
70  return *m_FramePtr == frame;
71  }
72 
73  bool VisibleState::IsFrames(const ConstRestFrameList& frames) const {
74  return IsFrame(frames[0]);
75  }
76 
77  RestFrame const& VisibleState::GetFrame() const {
78  if(m_FramePtr)
79  return *m_FramePtr;
80  else
81  return RestFrame::Empty();
82  }
83 
84  void VisibleState::SetLabFrameFourVector(){
85  if(!m_FramePtr) return;
86  SetFourVector(m_FramePtr->GetLabFrameFourVector());
87  SetCharge(m_FramePtr->GetCharge());
88  }
89 
90  void VisibleState::SetCharge(const RFCharge& charge){
91  m_Charge = charge;
92  }
93 
94  void VisibleState::SetCharge(int charge){
95  m_Charge = charge;
96  }
97 
98  void VisibleState::SetCharge(int charge_num, int charge_den){
99  m_Charge = RFCharge(charge_num, charge_den);
100  }
101 
102  VisibleState VisibleState::m_Empty;
103 }
virtual void Clear()
Clears RFBase of all connections to other objects.
Definition: VisibleState.cc:48
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