simple-tof-analysis
 All Classes Namespaces Functions Variables Groups Pages
StatUtils.h
1 /*
2  * StatUtils.h
3  *
4  * Created on: Nov 9, 2014
5  * Author: Silvestro di Luise
6  * Silvestro.Di.Luise@cern.ch
7  *
8  */
9 
10 #ifndef STATUTILS_H_
11 #define STATUTILS_H_
12 
13 
14 #include <iostream>
15 #include <limits>
16 #include <cmath>
17 
18 #include <string>
19 #include <TString.h>
20 #include <TGraph.h>
21 #include <TGraphErrors.h>
22 #include <TGraphAsymmErrors.h>
23 
24 #include <TObject.h>
25 #include <TMath.h>
26 #include <TRandom.h>
27 
28 class TH2;
29 class TH1;
30 class TH2F;
31 class TH1F;
32 class TH2Poly;
33 
34 using namespace std;
35 
36 using std::cout;
37 using std::endl;
38 
39 /*
40  *
41  */
42 
43 namespace StatUtils {
44 
45 
46  double Chisquare(double *x, double *p){
47 
48  //p[0] Normaliation, p[1] degree of freedom
49  //const needed to avoid too large value of the normalization param p[0]
50  //i.e.: for p[1]=dof=50 Gamma(50/2)=6e23;
51 
52  double half_mu = 0.5*p[1];
53 
54  double D = pow(2,half_mu) * TMath::Gamma(half_mu);
55 
56  return (1/D)*p[0]*pow(x[0],(half_mu-1))*exp( -0.5*x[0] );
57  }
58 
59  double GetChi2(double x, double n){
60 
61  double half_nu = 0.5*n;
62 
63  double D = pow(2,half_mu) * TMath::Gamma(half_mu);
64 
65  return (1/D)*pow(x,(half_mu-1))*exp( -0.5*x );
66 
67  }
68 
69 };
70 
71 #endif /* STATUTILS_H_ */