BOSS 7.0.8
BESIII Offline Software System
Loading...
Searching...
No Matches
ChisqConsistency Class Reference

#include <ChisqConsistency.h>

+ Inheritance diagram for ChisqConsistency:

Public Member Functions

 ChisqConsistency ()
 
 ChisqConsistency (double chisq, double nDof)
 
 ChisqConsistency (unsigned nDof, double consistency)
 
 ChisqConsistency (const ChisqConsistency &)
 
ChisqConsistencyoperator= (const ChisqConsistency &)
 
virtual ~ChisqConsistency ()
 
const double & chisqValue () const
 
const double & nDOF () const
 
- Public Member Functions inherited from Consistency
 Consistency ()
 
 Consistency (double consistency, double likelihood=0.)
 
 Consistency (const Consistency &rhs)
 
virtual ~Consistency ()
 
Consistencyoperator= (const Consistency &rhs)
 
bool operator== (const Consistency &rhs) const
 
bool operator< (const Consistency &rhs) const
 
bool operator> (const Consistency &rhs) const
 
double significanceLevel () const
 
double likelihood () const
 
double consistency () const
 
ConsistentStatus status () const
 
void setStatus (ConsistentStatus s)
 
ConsistentSign sign () const
 
void setSign (ConsistentSign s)
 
virtual const ConsistencySet * genealogy () const
 
virtual void print (std::ostream &) const
 

Protected Attributes

double _chisq
 
double _nDof
 
- Protected Attributes inherited from Consistency
ConsistentStatus _stat
 
ConsistentSign _sign
 
double _value
 
double _likelihood
 

Additional Inherited Members

- Public Types inherited from Consistency
enum  ConsistentStatus { OK =0 , noMeasure , underFlow , unPhysical }
 
enum  ConsistentSign { left =-1 , unknown =0 , right =1 }
 
- Static Public Member Functions inherited from Consistency
static const ConsistencybadMeasurement ()
 

Detailed Description

Definition at line 27 of file ChisqConsistency.h.

Constructor & Destructor Documentation

◆ ChisqConsistency() [1/4]

ChisqConsistency::ChisqConsistency ( )

Definition at line 38 of file ChisqConsistency.cxx.

38 :
39 _chisq(-1.0), _nDof(0)
40{}

◆ ChisqConsistency() [2/4]

ChisqConsistency::ChisqConsistency ( double  chisq,
double  nDof 
)

Definition at line 42 of file ChisqConsistency.cxx.

42 :
43 _chisq(chisq), _nDof(nDof)
44{
45 double z2 = 0.5*_chisq;
46 double n2 = 0.5*_nDof;
47
48 if (n2<=0 || z2<0) {
49 std::cout << "ErrMsg(warning)" << " Got unphysical values: chisq = " << chisq
50 << " #dof = " << nDof << std::endl;
51 _value=0;
54 return;
55 }
57
58// given that n2>0 && z2>=0, gammq will NOT abort
60
61 if (_chisq==0) {
62 _likelihood=1;
63 } else {
64 double loglike=(n2-1)*log(z2)-z2-NumRecipes::gammln(n2);
65 if ( loglike < DBL_MIN_EXP ) {
66 _likelihood = 0;
68 } else {
69 _likelihood = 0.5*exp(loglike);
70 }
71 }
72}
EvtComplex exp(const EvtComplex &c)
Definition: EvtComplex.hh:252
int n2
Definition: SD0Tag.cxx:55
void setStatus(ConsistentStatus s)
Definition: Consistency.h:107
double _value
Definition: Consistency.h:134
double _likelihood
Definition: Consistency.h:135
static double gammq(double a, double x)
Definition: NumRecipes.cxx:72
static double gammln(double x)
Definition: NumRecipes.cxx:40

◆ ChisqConsistency() [3/4]

ChisqConsistency::ChisqConsistency ( unsigned  nDof,
double  consistency 
)

Definition at line 76 of file ChisqConsistency.cxx.

76 :
77 _nDof(nDof)
78{
79 if(prob >= 0.0|| prob <= 1.0 || nDof < 0)
80 _value = prob;
81 else {
82 std::cout << "ErrMsg(warning)" << " Got unphysical values: prob = " << prob
83 << " #dof = " << nDof << std::endl;
84 _value=0;
87 return;
88 }
90 if(prob != 1.0){
91// use the cernlib function to get chisq. Note the funny convention on prob!!
92 float value = 1.0-float(_value);
93 int ndof = nDof;
94 if(value < 1.0)
95 _chisq = chisin_(value,ndof);
96 else
97 _chisq = log(double(FLT_MAX));
98// use the same algorithm as above to get loglikelihood
99 double z2 = 0.5*_chisq;
100 double n2 = 0.5*_nDof;
101 if (_chisq==0) {
102 _likelihood=1;
103 } else {
104 double loglike=(n2-1)*log(z2)-z2-NumRecipes::gammln(n2);
105 if ( loglike < DBL_MIN_EXP ) {
106 _likelihood = 0;
108 } else {
109 _likelihood = 0.5*exp(loglike);
110 }
111 }
112 }
113}
float chisin_(const float &, const int &)

◆ ChisqConsistency() [4/4]

ChisqConsistency::ChisqConsistency ( const ChisqConsistency other)

Definition at line 116 of file ChisqConsistency.cxx.

116 :
117 Consistency(other), _chisq(other._chisq), _nDof(other._nDof)
118{}
Index other(Index i, Index j)
Definition: EvtCyclic3.cc:118

◆ ~ChisqConsistency()

virtual ChisqConsistency::~ChisqConsistency ( )
inlinevirtual

Definition at line 44 of file ChisqConsistency.h.

44{}

Member Function Documentation

◆ chisqValue()

const double & ChisqConsistency::chisqValue ( ) const
inline

Definition at line 46 of file ChisqConsistency.h.

46{ return _chisq; }

◆ nDOF()

const double & ChisqConsistency::nDOF ( ) const
inline

Definition at line 47 of file ChisqConsistency.h.

47{ return _nDof; }

◆ operator=()

ChisqConsistency & ChisqConsistency::operator= ( const ChisqConsistency other)

Definition at line 121 of file ChisqConsistency.cxx.

121 {
122 if(this != &other){
124 _chisq = other._chisq;
125 _nDof = other._nDof;
126 }
127 return *this;
128}
Consistency & operator=(const Consistency &rhs)
Definition: Consistency.cxx:72

Member Data Documentation

◆ _chisq

double ChisqConsistency::_chisq
protected

Definition at line 50 of file ChisqConsistency.h.

Referenced by ChisqConsistency(), chisqValue(), and operator=().

◆ _nDof

double ChisqConsistency::_nDof
protected

Definition at line 51 of file ChisqConsistency.h.

Referenced by ChisqConsistency(), nDOF(), and operator=().


The documentation for this class was generated from the following files: