-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathCrystalBallEfficiency.cxx
88 lines (74 loc) · 2.67 KB
/
CrystalBallEfficiency.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*****************************************************************************
* Project: RooFit *
* *
* This code was autogenerated by RooClassFactory *
*****************************************************************************/
#include "Riostream.h"
#include "CrystalBallEfficiency.h"
#include "RooAbsReal.h"
#include "RooAbsCategory.h"
#include <math.h>
#include "TMath.h"
ClassImp(CrystalBallEfficiency)
CrystalBallEfficiency::CrystalBallEfficiency(const char *name, const char *title,
RooAbsReal& _m,
RooAbsReal& _m0,
RooAbsReal& _sigma,
RooAbsReal& _alpha,
RooAbsReal& _n,
RooAbsReal& _norm) :
RooAbsReal(name,title),
m("m","m",this,_m),
m0("m0","m0",this,_m0),
sigma("sigma","sigma",this,_sigma),
alpha("alpha","alpha",this,_alpha),
n("n","n",this,_n),
norm("norm","norm",this,_norm)
{
}
CrystalBallEfficiency::CrystalBallEfficiency(const CrystalBallEfficiency& other, const char* name) :
RooAbsReal(other,name),
m("m",this,other.m),
m0("m0",this,other.m0),
sigma("sigma",this,other.sigma),
alpha("alpha",this,other.alpha),
n("n",this,other.n),
norm("norm",this,other.norm)
{
}
Double_t CrystalBallEfficiency::evaluate() const
{
double sqrtPiOver2 = std::sqrt(TMath::PiOver2());
double sqrt2 = std::sqrt(2.);
double sig = std::abs(sigma);
double t = (m - m0)/sig * alpha / std::abs(alpha);
double absAlpha = std::abs(alpha/sig);
double a = TMath::Power(n/absAlpha, n) * TMath::Exp(-0.5 * absAlpha * absAlpha);
double b = absAlpha - n/absAlpha;
double arg = absAlpha / sqrt2;
double ApproxErf = 0.;
if (arg > 5.) {
ApproxErf = 1.;
} else if (arg < -5.) {
ApproxErf = -1.;
} else {
ApproxErf = TMath::Erf(arg);
}
double leftArea = (1. + ApproxErf) * sqrtPiOver2;
double rightArea = ( a * 1. / TMath::Power(absAlpha-b, n-1) ) / (n - 1.);
double area = leftArea + rightArea;
if (t <= absAlpha) {
arg = t / sqrt2;
if (arg > 5.) {
ApproxErf = 1.;
} else if (arg < -5.) {
ApproxErf = -1.;
} else {
ApproxErf = TMath::Erf(arg);
}
return norm * (1. + ApproxErf) * sqrtPiOver2 / area;
} else {
return norm * (leftArea + a * (1./TMath::Power(t-b,n-1) - \
1./TMath::Power(absAlpha - b,n-1)) / (1 - n)) / area;
}
}