LOGO

RestFrames  v1.0.0
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-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 #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 
63  RFBase(const std::string& sname, const std::string& stitle, int key);
64 
65  RFBase();
66 
67  virtual ~RFBase();
68 
69  friend void SetWarningTolerance(int NMAX);
70 
72  virtual void Clear();
73 
75  bool IsEmpty() const;
76 
78  bool operator !() const { return IsEmpty(); }
79 
87 
89  RFKey GetKey() const;
90 
92  std::string GetName() const;
93 
95  std::string GetTitle() const;
96 
98  bool IsSame(const RFKey& key) const;
99 
101  bool IsSame(const RFBase& obj) const;
102 
104  bool operator == (const RFKey& key) const { return IsSame(key); }
105 
107  bool operator == (const RFBase& obj) const { return IsSame(obj); }
108 
110  bool operator != (const RFKey& key) const { return !IsSame(key); }
111 
113  bool operator != (const RFBase& obj) const { return !IsSame(obj); }
114 
116 
118  void Print(LogType type) const;
119 
121  virtual std::string PrintString(LogType type) const;
122 
123  static RFBase& Empty();
124 
125  protected:
126  mutable RFLog m_Log;
127 
128  bool SetBody(bool body) const;
129  bool SetMind(bool mind) const;
130  bool SetSpirit(bool spirit) const;
131 
132  virtual bool IsSoundBody() const;
133  virtual bool IsSoundMind() const;
134  virtual bool IsSoundSpirit() const;
135 
136  void UnSoundBody(const std::string& function) const;
137  void UnSoundMind(const std::string& function) const;
138  void UnSoundSpirit(const std::string& function) const;
139 
141  void AddDependent(RFBase* dep);
142 
143  RFBase* m_This;
144 
145  static const TVector3 m_Empty3Vector;
146  static const TLorentzVector m_Empty4Vector;
147 
148  private:
149  std::string m_Name;
150  std::string m_Title;
151  RFKey m_Key;
152 
153  mutable bool m_Body;
154  mutable bool m_Mind;
155  mutable bool m_Spirit;
156 
157  std::vector<RFBase*> m_Owns;
158 
159  static RFBase m_Empty;
160 
161  static int m_BodyCount;
162  static int m_MindCount;
163  static int m_SpiritCount;
164 
165  static int m_WarningTolerance;
166  };
167 
168  double GetP(double Mp, double Mc1, double Mc2);
169 
170  // adapted from boost/current_function.hpp
171  #if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) || defined(__ghs__)
172  # define RF_FUNCTION __PRETTY_FUNCTION__
173  #elif defined(__DMC__) && (__DMC__ >= 0x810)
174  # define RF_FUNCTION __PRETTY_FUNCTION__
175  #elif defined(__FUNCSIG__)
176  # define RF_FUNCTION __FUNCSIG__
177  #elif (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) || (defined(__IBMCPP__) && (__IBMCPP__ >= 500))
178  # define RF_FUNCTION __FUNCTION__
179  #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550)
180  # define RF_FUNCTION __FUNC__
181  #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
182  # define RF_FUNCTION __func__
183  #elif defined(__cplusplus) && (__cplusplus >= 201103)
184  # define RF_FUNCTION __func__
185  #else
186  # define RF_FUNCTION "(unknown)"
187  #endif
188 
197  void SetWarningTolerance(int NMAX = -1);
198  void TooManyBodies(const RFBase& obj);
199  void TooManyMinds(const RFBase& obj);
200  void TooManySpirits(const RFBase& obj);
201 
202 }
203 
204 #endif
virtual std::string PrintString(LogType type) const
String of information associated with object.
Definition: RFBase.cc:146
Base class for all RestFrame package objects.
Definition: RFBase.hh:53
std::string GetName() const
Returns object name.
Definition: RFBase.cc:104
std::string GetTitle() const
Returns object title.
Definition: RFBase.cc:108
virtual void Clear()
Clears RFBase of all connections to other objects.
Definition: RFBase.cc:71
friend void SetWarningTolerance(int NMAX)
Set the tolerance for number of RestFrames warnings.
Definition: RFBase.cc:223
bool IsEmpty() const
Checks whether this is default (empty) instance of class.
Definition: RFBase.cc:84
RFKey GetKey() const
gets object identification key
Definition: RFBase.cc:100
void AddDependent(RFBase *dep)
pointer to RFBase object owned by this one
Definition: RFBase.cc:88
bool operator==(const RFKey &key) const
Tests whether key is the same as this.
Definition: RFBase.hh:104
bool IsSame(const RFKey &key) const
Tests whether key is the same as this.
Definition: RFBase.cc:92
bool operator!() const
Tests whether key is the same as this.
Definition: RFBase.hh:78
void Print(LogType type) const
Print information associated with object.
Definition: RFBase.cc:141
bool operator!=(const RFKey &key) const
Tests whether key is the same as this.
Definition: RFBase.hh:110