LOGO

RestFrames  v1.0.1
RestFrames HEP Event Analysis Software Library
LabFrame.cc
Go to the documentation of this file.
1 // RestFrames: particle physics event analysis library
3 // --------------------------------------------------------------------
4 // Copyright (c) 2014-2015, 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/LabFrame.hh"
33 
34 namespace RestFrames {
35 
37  // LabFrame class
39  template <class T>
40  LabFrame<T>::LabFrame(const std::string& sname,
41  const std::string& stitle)
42  : T(sname, stitle)
43  {
44  T::m_Type = kLabFrame;
45  }
46 
47  template <class T>
48  LabFrame<T>::LabFrame() : T() {}
49 
50 
51  template <class T>
52  LabFrame<T>::~LabFrame() {}
53 
54  template <class T>
55  bool LabFrame<T>::IsSoundBody() const {
56  if(RFBase::IsSoundBody())
57  return true;
58  if(!T::IsSoundBody()){
59  return T::SetBody(false);
60  }
61  int Nchild = T::GetNChildren();
62  if(Nchild != 1){
63  T::m_Log << LogWarning << "Number of LabFrame children != 1: ";
64  T::m_Log << Nchild << LogEnd;
65  return T::SetBody(false);
66  }
67  if(!T::GetParentFrame().IsEmpty()){
68  T::m_Log << LogWarning << "Parent frame of LabFrame is not empty: ";
69  T::m_Log << Log(T::GetParentFrame()) << LogEnd;
70  return T::SetBody(false);
71  }
72  return T::SetBody(true);;
73  }
74 
75  template <class T>
76  void LabFrame<T>::SetChildFrame(RestFrame& frame){
77  T::AddChildFrame(frame);
78  }
79 
80  template <class T>
81  bool LabFrame<T>::InitializeTree() {
82  T::m_Log << LogVerbose;
83  T::m_Log << "Initializing tree skeleton...";
84  T::m_Log << LogEnd;
85 
86  std::vector<RFKey> keys;
87  if(T::IsCircularTree(keys)){
88  T::m_Log << LogWarning;
89  T::m_Log << " Tree is circular in construction";
90  T::m_Log << LogEnd;
91  return false;
92  }
93 
94  if(!T::InitializeTreeRecursive()){
95  T::m_Log << LogWarning;
96  T::m_Log << " Problem with structure of tree";
97  T::m_Log << LogEnd;
98  return false;
99  }
100 
101  T::m_Log << LogVerbose;
102  T::m_Log << "...Done";
103  T::m_Log << LogEnd;
104 
105  return true;
106  }
107 
108  template <class T>
109  TVector3 LabFrame<T>::GetInvisibleMomentum() const {
110  return T::GetInvisibleFourVector().Vect();
111  }
112 
113  template class LabFrame<ReconstructionFrame>;
114  template class LabFrame<GeneratorFrame>;
115 }