LOGO

RestFrames  v1.0.1
RestFrames HEP Event Analysis Software Library
RFBase.hh
Go to the documentation of this file.
1 // RestFrames: particle physics event analysis library
3 // --------------------------------------------------------------------
4 // Copyright (c) 2014-2018, 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 RFBase_HH
31 #define RFBase_HH
32 
33 #include <iostream>
34 #include <string>
35 #include <algorithm>
36 #include <TVector3.h>
37 #include <TLorentzVector.h>
38 
39 #include "RestFrames/RFKey.hh"
40 #include "RestFrames/RFLog.hh"
41 #include "RestFrames/RFList.hh"
42 
43 namespace RestFrames {
44 
45  static const double RF_tol = 1e-6;
46 
53  class RFBase {
54 
55  public:
56 
64  RFBase(const std::string& sname, const std::string& stitle, int key);
65 
67  RFBase();
68 
69  virtual ~RFBase();
70 
77  friend void SetWarningTolerance(int NMAX);
78 
80  virtual void Clear();
81 
83  bool IsEmpty() const;
84 
86  bool operator !() const { return IsEmpty(); }
87 
95 
97  RFKey GetKey() const;
98 
100  std::string GetName() const;
101 
103  std::string GetTitle() const;
104 
106  bool IsSame(const RFKey& key) const;
107 
109  bool IsSame(const RFBase& obj) const;
110 
112  bool operator == (const RFKey& key) const { return IsSame(key); }
113 
115  bool operator == (const RFBase& obj) const { return IsSame(obj); }
116 
118  bool operator != (const RFKey& key) const { return !IsSame(key); }
119 
121  bool operator != (const RFBase& obj) const { return !IsSame(obj); }
122 
124 
126  void Print(LogType type) const;
127 
129  virtual std::string PrintString(LogType type) const;
130 
134  static RFBase& Empty();
135 
136  protected:
137  mutable RFLog m_Log;
138 
139  bool SetBody(bool body) const;
140  bool SetMind(bool mind) const;
141  bool SetSpirit(bool spirit) const;
142 
143  virtual bool IsSoundBody() const;
144  virtual bool IsSoundMind() const;
145  virtual bool IsSoundSpirit() const;
146 
147  void UnSoundBody(const std::string& function) const;
148  void UnSoundMind(const std::string& function) const;
149  void UnSoundSpirit(const std::string& function) const;
150 
152  void AddDependent(RFBase* dep);
153 
154  RFBase* m_This;
155 
156  static const TVector3 m_Empty3Vector;
157  static const TLorentzVector m_Empty4Vector;
158 
159  private:
160  std::string m_Name;
161  std::string m_Title;
162  RFKey m_Key;
163 
164  mutable bool m_Body;
165  mutable bool m_Mind;
166  mutable bool m_Spirit;
167 
168  std::vector<RFBase*> m_Owns;
169 
170  static RFBase m_Empty;
171 
172  static int m_BodyCount;
173  static int m_MindCount;
174  static int m_SpiritCount;
175 
176  static int m_WarningTolerance;
177  };
178 
179  double GetP(double Mp, double Mc1, double Mc2);
180 
181  // adapted from boost/current_function.hpp
182  #if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) || defined(__ghs__)
183  # define RF_FUNCTION __PRETTY_FUNCTION__
184  #elif defined(__DMC__) && (__DMC__ >= 0x810)
185  # define RF_FUNCTION __PRETTY_FUNCTION__
186  #elif defined(__FUNCSIG__)
187  # define RF_FUNCTION __FUNCSIG__
188  #elif (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) || (defined(__IBMCPP__) && (__IBMCPP__ >= 500))
189  # define RF_FUNCTION __FUNCTION__
190  #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550)
191  # define RF_FUNCTION __FUNC__
192  #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
193  # define RF_FUNCTION __func__
194  #elif defined(__cplusplus) && (__cplusplus >= 201103)
195  # define RF_FUNCTION __func__
196  #else
197  # define RF_FUNCTION "(unknown)"
198  #endif
199 
208  void SetWarningTolerance(int NMAX = -1);
209  void TooManyBodies(const RFBase& obj);
210  void TooManyMinds(const RFBase& obj);
211  void TooManySpirits(const RFBase& obj);
212 
213 }
214 
215 #endif
RestFrames::RFBase::Empty
static RFBase & Empty()
Returns empty RFBase.
Definition: RFBase.cc:80
RestFrames::RFBase::IsEmpty
bool IsEmpty() const
Checks whether this is default (empty) instance of class.
Definition: RFBase.cc:84
RestFrames::RFBase::IsSame
bool IsSame(const RFKey &key) const
Tests whether key is the same as this.
Definition: RFBase.cc:92
RestFrames::RFBase
Base class for all RestFrame package objects.
Definition: RFBase.hh:53
RestFrames::RFBase::GetKey
RFKey GetKey() const
gets object identification key
Definition: RFBase.cc:100
RestFrames::RFBase::Print
void Print(LogType type) const
Print information associated with object.
Definition: RFBase.cc:141
RestFrames::LogType
LogType
Type of Log Message.
Definition: RFLog.hh:45
RestFrames::RFBase::GetName
std::string GetName() const
Returns object name.
Definition: RFBase.cc:104
RFLog.hh
RestFrames::RFLog
Definition: RFLog.hh:51
RFKey.hh
RestFrames::RFBase::GetTitle
std::string GetTitle() const
Returns object title.
Definition: RFBase.cc:108
RestFrames::RFBase::Clear
virtual void Clear()
Clears RFBase of all connections to other objects.
Definition: RFBase.cc:71
RFList.hh
RestFrames::RFBase::operator!
bool operator!() const
Tests whether key is the same as this.
Definition: RFBase.hh:86
RestFrames::RFKey
Definition: RFKey.hh:38
RestFrames::RFBase::SetWarningTolerance
friend void SetWarningTolerance(int NMAX)
Sets the tolerance for the number of RestFrames warnings.
Definition: RFBase.cc:223
RestFrames::RFBase::AddDependent
void AddDependent(RFBase *dep)
pointer to RFBase object owned by this one
Definition: RFBase.cc:88
RestFrames::RFBase::operator!=
bool operator!=(const RFKey &key) const
Tests whether key is the same as this.
Definition: RFBase.hh:118
RestFrames::RFBase::operator==
bool operator==(const RFKey &key) const
Tests whether key is the same as this.
Definition: RFBase.hh:112
RestFrames::RFBase::PrintString
virtual std::string PrintString(LogType type) const
String of information associated with object.
Definition: RFBase.cc:146
RestFrames::RFBase::RFBase
RFBase()
Empty constructor.
Definition: RFBase.cc:41