BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
Mdcxprobab.cxx
Go to the documentation of this file.
1#include <math.h>
2#include "MdcxReco/Mdcxprobab.h"
3
4extern float Mdcxprobab(int& ndof, float& chisq) {
5
6 //constants
7 static float srtopi = 2.0/sqrt(2.0*M_PI);
8 static float upl = 100.0; //FIXME
9
10 float prob = 0.0;
11 if(ndof <= 0) return prob;
12 if(chisq < 0.0) return prob;
13 if(ndof <= 60) {
14 //full treatment
15 if(chisq > upl) return prob;
16 float sum = exp(-0.5*chisq);
17 float term = sum;
18
19 int m = ndof/2;
20 if(2*m == ndof) {
21 if(m == 1) return sum;
22 for(int i = 2; i <= m; i++) {
23 term = 0.5*term*chisq/(i-1);
24 sum += term;
25 }//(int i=2; i<=m)
26 return sum;
27 //even
28 } else {
29 //odd
30 float srty = sqrt(chisq);
31 float temp = srty/M_SQRT2;
32 prob = erfc(temp);
33 if(ndof == 1) return prob;
34 if(ndof == 3) return (srtopi*srty*sum+prob);
35 m--;
36 for(int i = 1; i <= m; i++) {
37 term = term*chisq/(2*i+1);
38 sum += term;
39 }//(int i=1; i<=m; i++)
40 return (srtopi*srty*sum + prob);
41
42 }//(2*m==ndof)
43
44 } else {
45 //asymtotic Gaussian approx
46 float srty = sqrt(chisq) - sqrt(ndof - 0.5);
47 if(srty < 12.0) prob=0.5*erfc(srty);
48 return prob;
49
50 }//ndof<30
51
52 // cannot reach following line; warning on OSF; so comment it out
53 // return prob;
54}//endof Mdcxprobab
55
EvtComplex exp(const EvtComplex &c)
Definition: EvtComplex.hh:252
float Mdcxprobab(int &ndof, float &chisq)
Definition: Mdcxprobab.cxx:4
#define M_PI
Definition: TConstant.h:4