]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/flow/AliFMDFlowEfficiency.h
Added code to do flow analysis.
[u/mrichter/AliRoot.git] / FMD / flow / AliFMDFlowEfficiency.h
1 // -*- mode: C++ -*-
2 #ifndef Efficiency_h
3 #define Efficiency_h
4 #include <Rtypes.h>
5
6 /** @defgroup z_eff Efficiency calculations 
7     @brief Functions to do efficiency calculations based on a
8     Baysian analysis. 
9 */
10 /** Namespace for efficency calculations 
11     @ingroup z_eff */
12 namespace AliFMDFlowEfficiency 
13 {
14   /** @{ 
15       @ingroup z_eff */
16   /** Calculate @f$ \log(\Gamma(z))\ \forall z>0@f$ 
17       @param z Argument. 
18       @return  @f$ \log(\Gamma(z))@f$ */ 
19   Double_t LnGamma(Double_t z);
20   
21   /** Continued fraction evaluation by modified Lentz's method 
22       used in calculation of incomplete  Beta function. 
23       @param x argument. 
24       @param a lower limit
25       @param b upper limit
26       @return incomplete Beta function evaluated at x */ 
27   Double_t BetaCf(Double_t x, Double_t a, Double_t b);
28   
29   /** Calculates the incomplete Beta function @f$ I_x(a,b)@f$;
30       this is the incomplete Beta function divided by the
31       complete Beta function. 
32       @param a Lower bound 
33       @param b Upper bound 
34       @param x Order 
35       @return  @f$ I_x(a,b)@f$ */
36   Double_t IBetaI(Double_t a, Double_t b, Double_t x);
37
38   /** Calculates the fraction of the area under the curve 
39       @f$ x^k (1-x)^{n-k}@f$ between @f$ x=a@f$ and @f$ x=b@f$ 
40       @param a lower limit 
41       @param b upper limit 
42       @param k Parameter @f$ k@f$ 
43       @param n Parameter @f$ n@f$ 
44       @return The fraction under the curve */ 
45   Double_t BetaAB(Double_t a, Double_t b, Int_t k, Int_t n);
46   
47   /** Integrates the Binomial distribution with parameters @a k and @a
48       n, and determines the upper edge of the integration region, 
49       starting at @a low, which contains probability content @a c.  If
50       an upper limit is found, the value is returned. If no solution
51       is found, -1 is returned. Check to see if there is any solution
52       by verifying that the integral up to the maximum upper limit (1)
53       is greater than c 
54       @param low Where to start the integration from. 
55       @param k   @a k parameter of the Binomial distribution. 
56       @param n   @a N parameter of the Binomial distribution. 
57       @param c   Wanted confidence limit (defaults to 68% - similar to
58       @f$ 1\sigma@f$ of a Gaussian distribution)
59       @return the upper limit of the confidence interval, or -1 in
60       case of failure */
61   Double_t SearchUpper(Double_t low, Int_t k, Int_t n, Double_t c=0.683);
62
63   /** Integrates the Binomial distribution with parameters @a k and @a
64       n, and determines the lower edge of the integration region, 
65       ending at @a high, which contains probability content @a c.  If
66       a lower limit is found, the value is returned. If no solution
67       is found, -1 is returned. Check to see if there is any solution
68       by verifying that the integral up to the maximum upper limit (1)
69       is greater than c 
70       @param high Where to end the integration at. 
71       @param k    @a k parameter of the Binomial distribution. 
72       @param n    @a N parameter of the Binomial distribution. 
73       @param c    Wanted confidence limit (defaults to 68% - similar to
74       @f$ 1\sigma@f$ of a Gaussian distribution) 
75       @return the upper limit of the confidence interval, or -1 in
76       case of failure */
77   Double_t SearchLower(Double_t high, Int_t k, Int_t n, Double_t c=0.683);
78
79   /** Numerical equation solver.  This includes root finding and
80       minimum finding algorithms. Adapted from Numerical Recipes in
81       C, 2nd edition. Translated to C++ by Marc Paterno
82       @param ax   Left side of interval 
83       @param bx   Middle of interval 
84       @param cx   Right side of interval 
85       @param tol  Tolerance 
86       @param xmin On return, the value of @f$ x@f$ such that @f$
87       f(x)@f$ i minimal. 
88       @param k    Parameter of the Binomial distribution 
89       @param n    Parameter of the Binomial distribution 
90       @param c    Confidence level. 
91       @return Minimum of @f$ f = f(x)@f$. */
92   Double_t Brent(Double_t ax, Double_t bx, Double_t cx, Double_t& xmin, 
93                Int_t k, Int_t n, Double_t c=.683, Double_t tol=1e-9);
94   
95   /** Return the length of the interval starting at @a l that contains
96       @a c of the @f$ x^k (1-x)^{n-k}@f$ distribution. If there is no
97       sufficient interval starting at @a l, we return 2.0 
98       @param l Lower bound 
99       @param k Binomial parameter k 
100       @param n Binomial parameter n 
101       @param c Condifience level 
102       @return Legnth of interval */
103   Double_t Length(Double_t l, Int_t k, Int_t n, Double_t c=0.683);
104     
105
106   /** Calculate the shortest central confidence interval containing
107       the required probability content @a c. Interval(low) returns the
108       length of the interval starting at low that contains @a c
109       probability. We use Brent's method, except in two special cases:
110       when @a k=0, or when @a k=n 
111       @author Marc Paterno
112       @param k    Binomial parameter @a k 
113       @param n    Binomial parameter @a n 
114       @param low  On return, the lower limit
115       @param high On return, the upper limit 
116       @param c    Required confidence level (defaults to 68% - similar
117       to @f$ 1\sigma@f$ of a Gaussian distribution)
118       @return The mode */ 
119   Double_t Interval(Int_t k, Int_t n, Double_t& low, Double_t& high, Double_t c=0.683);
120   /** @} */
121 }
122
123
124 #endif
125 //
126 // EOF
127 //
128