Go to the documentation of this file.00001 #ifndef __BCMATH__H
00002 #define __BCMATH__H
00003
00023
00024
00025 #define BCMATH_NFACT_ALIMIT 20
00026
00027
00028
00029 #include <vector>
00030
00031 class TH1D;
00032
00033 namespace BCMath
00034 {
00035
00042 double LogGaus(double x, double mean = 0, double sigma = 1, bool norm = false);
00043
00047 double LogPoisson(double x, double par);
00048
00054 double ApproxBinomial(int n, int k, double p);
00055
00062 double LogApproxBinomial(int n, int k, double p);
00063
00071 double LogBinomFactor(int n, int k);
00072
00080 double ApproxLogFact(double x);
00081
00085 double LogNoverK(int n, int k);
00086
00090 double LogFact(int n);
00091
00095 inline int Max(int x, int y)
00096 { return x >= y ? x : y; }
00097
00098 inline int Max(unsigned int x, unsigned int y)
00099 { return x >= y ? x : y; }
00100
00101 inline double Max(double x, double y)
00102 { return x >= y ? x : y; }
00103
00104 inline double Max(float x, float y)
00105 { return x >= y ? x : y; }
00106
00110 inline int Min(int x, int y)
00111 { return x <= y ? x : y; }
00112
00113 inline int Min(unsigned int x, unsigned int y)
00114 { return x <= y ? x : y; }
00115
00116 inline double Min(double x, double y)
00117 { return x <= y ? x : y; }
00118
00119 inline double Min(float x, float y)
00120 { return x <= y ? x : y; }
00121
00125 int Nint(double x);
00126
00130 double rms(int n, const double * a);
00131
00136 double LogBreitWignerNonRel(double x, double mean, double Gamma, bool norm = false);
00137 double LogBreitWignerRel(double x, double mean, double Gamma);
00138
00143 double LogChi2(double x, int n);
00144
00158 double LogVoigtian(double x, double sigma, double gamma);
00159
00164 void RandomChi2(std::vector<double> &randoms, int K);
00165
00166
00176 TH1D* ECDF(const std::vector<double>& data);
00177
00186 std::vector<int> longestRuns(const std::vector<bool>& bitStream);
00187
00199 std::vector<double> longestRunsChi2(const std::vector<double>& yMeasured,
00200 const std::vector<double>& yExpected, const std::vector<double>& sigma);
00201
00215 double longestRunFrequency(unsigned int longestObserved, unsigned int nTrials);
00216
00217
00218 double SplitGaussian(double* x, double* par);
00219
00220
00223 void CacheFactorial(unsigned int n);
00224
00225 }
00226
00227
00228
00229 #endif
00230