CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Dcxprobab.cc
Go to the documentation of this file.
1 //babar #include "BaBar/BaBar.hh"
2 //babar #include <math.h>
3 //babar #include "DcxReco/Dcxprobab.hh"
4 #include <cmath>
5 #include "RecoTracker/RoadSearchHelixMaker/interface/Dcxprobab.hh"
6 extern float Dcxprobab(int& ndof, float& chisq){
7 
8  //constants
9  static float srtopi=2.0/sqrt(2.0*M_PI);
10  static float upl=100.0;
11 
12  float prob=0.0;
13  if(ndof<=0) {return prob;}
14  if(chisq<0.0) {return prob;}
15  if(ndof<=60) {
16  //full treatment
17  if(chisq>upl) {return prob;}
18  float sum=exp(-0.5*chisq);
19  float term=sum;
20 
21  int m=ndof/2;
22  if(2*m==ndof){
23  if(m==1){return sum;}
24  for(int i=2; i<=m;i++){
25  term=0.5*term*chisq/(i-1);
26  sum+=term;
27  }//(int i=2; i<=m)
28  return sum;
29  //even
30 
31  }else{
32  //odd
33  float srty=sqrt(chisq);
34  float temp=srty/M_SQRT2;
35  prob=erfc(temp);
36  if(ndof==1) {return prob;}
37  if(ndof==3) {return (srtopi*srty*sum+prob);}
38  m=m-1;
39  for(int i=1; i<=m; i++){
40  term=term*chisq/(2*i+1);
41  sum+=term;
42  }//(int i=1; i<=m; i++)
43  return (srtopi*srty*sum+prob);
44 
45  }//(2*m==ndof)
46 
47  }else{
48  //asymtotic Gaussian approx
49  float srty=sqrt(chisq)-sqrt(ndof-0.5);
50  if(srty<12.0) {prob=0.5*erfc(srty);};
51  return prob;
52 
53  }//ndof<30
54 
55  // cannot reach following line; warning on OSF; so comment it out
56  // return prob;
57 }//endof Dcxprobab
int i
Definition: DBlmapReader.cc:9
float Dcxprobab(int &ndof, float &chisq)
Definition: Dcxprobab.cc:6
T sqrt(T t)
Definition: SSEVec.h:46
#define M_PI
Definition: BFit3D.cc:3