2 /* Copyright (C) 2007 Christian Holm Christensen <cholm@nbi.dk>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public License
6 * as published by the Free Software Foundation; either version 2.1 of
7 * the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 #ifndef ALIFMDFLOWEFFICIENCY_H
20 #define ALIFMDFLOWEFFICIENCY_H
23 /** @defgroup z_eff Efficiency calculations
24 @brief Functions to do efficiency calculations based on a
27 /** Namespace for efficency calculations
29 namespace AliFMDFlowEfficiency
33 /** Calculate @f$ \log(\Gamma(z))\ \forall z>0@f$
35 @return @f$ \log(\Gamma(z))@f$ */
36 Double_t LnGamma(Double_t z);
38 /** Continued fraction evaluation by modified Lentz's method
39 used in calculation of incomplete Beta function.
43 @return incomplete Beta function evaluated at x */
44 Double_t BetaCf(Double_t x, Double_t a, Double_t b);
46 /** Calculates the incomplete Beta function @f$ I_x(a,b)@f$;
47 this is the incomplete Beta function divided by the
48 complete Beta function.
52 @return @f$ I_x(a,b)@f$ */
53 Double_t IBetaI(Double_t a, Double_t b, Double_t x);
55 /** Calculates the fraction of the area under the curve
56 @f$ x^k (1-x)^{n-k}@f$ between @f$ x=a@f$ and @f$ x=b@f$
59 @param k Parameter @f$ k@f$
60 @param n Parameter @f$ n@f$
61 @return The fraction under the curve */
62 Double_t BetaAB(Double_t a, Double_t b, Int_t k, Int_t n);
64 /** Integrates the Binomial distribution with parameters @a k and @a
65 n, and determines the upper edge of the integration region,
66 starting at @a low, which contains probability content @a c. If
67 an upper limit is found, the value is returned. If no solution
68 is found, -1 is returned. Check to see if there is any solution
69 by verifying that the integral up to the maximum upper limit (1)
71 @param low Where to start the integration from.
72 @param k @a k parameter of the Binomial distribution.
73 @param n @a N parameter of the Binomial distribution.
74 @param c Wanted confidence limit (defaults to 68% - similar to
75 @f$ 1\sigma@f$ of a Gaussian distribution)
76 @return the upper limit of the confidence interval, or -1 in
78 Double_t SearchUpper(Double_t low, Int_t k, Int_t n, Double_t c=0.683);
80 /** Integrates the Binomial distribution with parameters @a k and @a
81 n, and determines the lower edge of the integration region,
82 ending at @a high, which contains probability content @a c. If
83 a lower limit is found, the value is returned. If no solution
84 is found, -1 is returned. Check to see if there is any solution
85 by verifying that the integral up to the maximum upper limit (1)
87 @param high Where to end the integration at.
88 @param k @a k parameter of the Binomial distribution.
89 @param n @a N parameter of the Binomial distribution.
90 @param c Wanted confidence limit (defaults to 68% - similar to
91 @f$ 1\sigma@f$ of a Gaussian distribution)
92 @return the upper limit of the confidence interval, or -1 in
94 Double_t SearchLower(Double_t high, Int_t k, Int_t n, Double_t c=0.683);
96 /** Numerical equation solver. This includes root finding and
97 minimum finding algorithms. Adapted from Numerical Recipes in
98 C, 2nd edition. Translated to C++ by Marc Paterno
99 @param ax Left side of interval
100 @param bx Middle of interval
101 @param cx Right side of interval
103 @param xmin On return, the value of @f$ x@f$ such that @f$
105 @param k Parameter of the Binomial distribution
106 @param n Parameter of the Binomial distribution
107 @param c Confidence level.
108 @return Minimum of @f$ f = f(x)@f$. */
109 Double_t Brent(Double_t ax, Double_t bx, Double_t cx, Double_t& xmin,
110 Int_t k, Int_t n, Double_t c=.683, Double_t tol=1e-9);
112 /** Return the length of the interval starting at @a l that contains
113 @a c of the @f$ x^k (1-x)^{n-k}@f$ distribution. If there is no
114 sufficient interval starting at @a l, we return 2.0
116 @param k Binomial parameter k
117 @param n Binomial parameter n
118 @param c Condifience level
119 @return Legnth of interval */
120 Double_t Length(Double_t l, Int_t k, Int_t n, Double_t c=0.683);
123 /** Calculate the shortest central confidence interval containing
124 the required probability content @a c. Interval(low) returns the
125 length of the interval starting at low that contains @a c
126 probability. We use Brent's method, except in two special cases:
127 when @a k=0, or when @a k=n
129 @param k Binomial parameter @a k
130 @param n Binomial parameter @a n
131 @param low On return, the lower limit
132 @param high On return, the upper limit
133 @param c Required confidence level (defaults to 68% - similar
134 to @f$ 1\sigma@f$ of a Gaussian distribution)
136 Double_t Interval(Int_t k, Int_t n, Double_t& low, Double_t& high, Double_t c=0.683);