Go to the documentation of this file.00001
00002
00003
00004 #include <cmath>
00005 #include "RecoTracker/RoadSearchHelixMaker/interface/Dcxprobab.hh"
00006 extern float Dcxprobab(int& ndof, float& chisq){
00007
00008
00009 static float srtopi=2.0/sqrt(2.0*M_PI);
00010 static float upl=100.0;
00011
00012 float prob=0.0;
00013 if(ndof<=0) {return prob;}
00014 if(chisq<0.0) {return prob;}
00015 if(ndof<=60) {
00016
00017 if(chisq>upl) {return prob;}
00018 float sum=exp(-0.5*chisq);
00019 float term=sum;
00020
00021 int m=ndof/2;
00022 if(2*m==ndof){
00023 if(m==1){return sum;}
00024 for(int i=2; i<=m;i++){
00025 term=0.5*term*chisq/(i-1);
00026 sum+=term;
00027 }
00028 return sum;
00029
00030
00031 }else{
00032
00033 float srty=sqrt(chisq);
00034 float temp=srty/M_SQRT2;
00035 prob=erfc(temp);
00036 if(ndof==1) {return prob;}
00037 if(ndof==3) {return (srtopi*srty*sum+prob);}
00038 m=m-1;
00039 for(int i=1; i<=m; i++){
00040 term=term*chisq/(2*i+1);
00041 sum+=term;
00042 }
00043 return (srtopi*srty*sum+prob);
00044
00045 }
00046
00047 }else{
00048
00049 float srty=sqrt(chisq)-sqrt(ndof-0.5);
00050 if(srty<12.0) {prob=0.5*erfc(srty);};
00051 return prob;
00052
00053 }
00054
00055
00056
00057 }