File indexing completed on 2024-04-06 12:32:02
0001 Double_t CrystalBall(Double_t* x, Double_t* par){
0002 double norm = par[0];
0003 double alpha = par[1];
0004 double n = par[2];
0005 double m0 = par[3];
0006 double sigma = par[4];
0007
0008 return norm*evaluate(x[0], m0, sigma, alpha, (int)n);
0009 }
0010
0011 Double_t evaluate(double m, double m0, double sigma, double alpha, int n) {
0012 n = 5;
0013 Double_t t = (m - m0)/sigma;
0014 if ( alpha < 0 ) t = -t;
0015
0016 Double_t absAlpha = fabs((Double_t)alpha);
0017 if ( t >= - absAlpha ) {
0018 return exp(-0.5*t*t);
0019 }
0020 else {
0021 Double_t a = TMath::Power(n/absAlpha,n)*exp(-0.5*absAlpha*absAlpha);
0022 Double_t b = n/absAlpha - absAlpha;
0023
0024 return a/TMath::Power(b - t, n);
0025 }
0026 }
0027
0028