/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/MdcPatRec/ProbTools/ProbTools-00-00-01/src/Consistency.cxx

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: Consistency.cxx,v 1.1.1.1 2005/04/21 01:17:17 zhangy Exp $
00004 //
00005 // Description:
00006 //      Class Consistency; encapsulates statistics
00007 //
00008 //      See header for more info.  This implementation
00009 //      is not complete
00010 //
00011 // Environment:
00012 //      Software developed for the BaBar Detector at the SLAC B-Factory.
00013 //
00014 // Author List:
00015 //      Bob Jacobsen            Original Author
00016 //
00017 // Copyright Information:
00018 //      Copyright (C) 1995      Lawrence Berkeley Laboratory
00019 //
00020 //------------------------------------------------------------------------
00021 //#include "BaBar/BaBar.hh"
00022 
00023 //------------------
00024 // This C Headers --
00025 //------------------
00026 extern "C" {
00027 #include <math.h>
00028 #include <assert.h>
00029 }
00030 
00031 //--------------------
00032 // This C++ Headers --
00033 //--------------------
00034 #include <iostream>
00035 #include <iomanip>
00036 
00037 //-----------------------
00038 // This Class's Header --
00039 //-----------------------
00040 #include "ProbTools/Consistency.h"
00041 using std::endl;
00042 using std::ios;
00043 using std::ostream;
00044 using std::setiosflags;
00045 using std::setprecision;
00046 using std::setw;
00047 
00048 
00049 //              ----------------------------------------
00050 //              -- Public Function Member Definitions --
00051 //              ----------------------------------------
00052 
00053 
00054 Consistency::Consistency() 
00055   : _stat(noMeasure), _value(0), _likelihood(1.), _sign(unknown)
00056 {
00057 }
00058 
00059 Consistency::Consistency(double v, double l)
00060   : _stat(OK), _value(v), _likelihood(l), _sign(unknown)
00061 {
00062 }
00063 
00064 Consistency::Consistency(const Consistency& rhs) 
00065   : _stat(rhs._stat), _value(rhs._value)
00066   , _likelihood(rhs._likelihood), _sign(rhs._sign)
00067 {
00068 }
00069 
00070 // operators
00071 Consistency& 
00072 Consistency::operator=(const Consistency& rhs)
00073 {
00074   if(this != &rhs){
00075     _stat=rhs._stat;
00076     _value=rhs._value;
00077     _likelihood=rhs._likelihood;
00078     _sign=rhs._sign;
00079   }
00080   return *this;
00081 }
00082 
00083 bool
00084 Consistency::operator==(const Consistency& rhs) const
00085 {
00086   bool answer = false;
00087   if (_stat       == rhs._stat &&
00088       _value      == rhs._value &&
00089       _likelihood == rhs._likelihood &&
00090       _sign       == rhs._sign) {
00091     answer = true;
00092   }
00093 
00094   return answer;
00095 }
00096 
00097 bool
00098 Consistency::operator<(const Consistency& rhs) const
00099 {
00100   //
00101   // this is not unique...
00102   //
00103 
00104   bool answer = false;
00105   if (_stat == OK && rhs._stat == OK ) {
00106     //
00107     // Dare to use consistency for comparison. 
00108     // Likelihood may give a different answer
00109     //
00110     if (_value < rhs._value) {
00111       answer = true;
00112     }
00113   } else {
00114     if (rhs._stat == OK) {
00115       answer = true;
00116     }
00117   }
00118 
00119   return answer;
00120 }
00121 
00122 bool
00123 Consistency::operator>(const Consistency& rhs) const
00124 {
00125   // ghm
00126   if( *this==rhs ) return false;
00127   return( ! (*this<rhs) );
00128 }
00129 
00130 
00131 const ConsistencySet* 
00132 Consistency::genealogy() const
00133 {
00134   return 0;
00135 }
00136 
00137 
00138 void
00139 Consistency::print(ostream& os) const
00140 {
00141   os << "Likelihood = ";
00142   os << setiosflags(ios::fixed) << setw(7) << setprecision(4);
00143   os << _likelihood;
00144   os << "\t SignificanceLevel = ";
00145   os << setiosflags(ios::fixed) << setw(7) << setprecision(4);
00146   os << _value;
00147   os << "\t Status ";
00148   switch( status() ) {
00149   case Consistency::OK  :
00150     os << "OK"; 
00151     break;
00152   case  Consistency::noMeasure  :
00153     os << "noMeasure"; 
00154     break;
00155   case  Consistency::underFlow  :
00156     os << "underFlow"; 
00157     break;
00158   case  Consistency::unPhysical  :
00159     os << "unPhysical"; 
00160     break;
00161   default:
00162     os << "unknown";
00163   }
00164   os << endl;
00165 }
00166 
00167 //------------------
00168 // Static methods --
00169 //------------------
00170 
00171 const Consistency&
00172 Consistency::badMeasurement() 
00173 {
00174   static Consistency bad(1.,1.);
00175   bad.setStatus(noMeasure);
00176 
00177   return bad;
00178 }

Generated on Tue Nov 29 23:13:39 2016 for BOSS_7.0.2 by  doxygen 1.4.7