ROOT
git-r3/HEAD
Reference Guide
Loading...
Searching...
No Matches
pdf010_CrystalBall.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_pdf
3
/// \notebook
4
/// Example of CrystalBall Function and its distribution (pdf and cdf)
5
///
6
/// \macro_image
7
/// \macro_code
8
///
9
/// \author Lorenzo Moneta
10
11
void
pdf010_CrystalBall() {
12
13
auto
c1
=
new
TCanvas
();
14
c1
->Divide(1,3);
15
16
// crystal ball function
17
c1
->cd(1);
18
19
auto
f1
=
new
TF1
(
"f1"
,
"crystalball"
,-5,5);
20
f1
->SetParameters(1, 0, 1, 2, 0.5);
21
f1
->SetLineColor(
kRed
);
22
f1
->Draw();
23
// use directly the functionin ROOT::MATH note that the parameters definition is different is (alpha, n sigma, mu)
24
auto
f2 =
new
TF1
(
"f2"
,
"ROOT::Math::crystalball_function(x, 2, 1, 1, 0)"
,-5,5);
25
f2->SetLineColor(
kGreen
);
26
f2->Draw(
"same"
);
27
auto
f3 =
new
TF1
(
"f3"
,
"ROOT::Math::crystalball_function(x, 2, 2, 1, 0)"
,-5,5);
28
f3->SetLineColor(
kBlue
);
29
f3->Draw(
"same"
);
30
31
auto
legend =
new
TLegend
(0.7,0.6,0.9,1.);
32
legend->AddEntry(
f1
,
"N=0.5 alpha=2"
,
"L"
);
33
legend->AddEntry(f2,
"N=1 alpha=2"
,
"L"
);
34
legend->AddEntry(f3,
"N=2 alpha=2"
,
"L"
);
35
legend->Draw();
36
37
c1
->cd(2);
38
auto
pdf1 =
new
TF1
(
"pdf"
,
"crystalballn"
,-5,5);
39
pdf1->SetParameters(2, 0, 1, 2, 3);
40
pdf1->Draw();
41
auto
pdf2 =
new
TF1
(
"pdf"
,
"ROOT::Math::crystalball_pdf(x, 3, 1.01, 1, 0)"
,-5,5);
42
pdf2->SetLineColor(
kBlue
);
43
pdf2->Draw(
"same"
);
44
auto
pdf3 =
new
TF1
(
"pdf"
,
"ROOT::Math::crystalball_pdf(x, 2, 2, 1, 0)"
,-5,5);
45
pdf3->SetLineColor(
kGreen
);
46
pdf3->Draw(
"same"
);
47
48
legend =
new
TLegend
(0.7,0.6,0.9,1.);
49
legend->AddEntry(pdf1,
"N=3 alpha=2"
,
"L"
);
50
legend->AddEntry(pdf2,
"N=1.01 alpha=3"
,
"L"
);
51
legend->AddEntry(pdf3,
"N=2 alpha=3"
,
"L"
);
52
legend->Draw();
53
54
c1
->cd(3);
55
auto
cdf =
new
TF1
(
"cdf"
,
"ROOT::Math::crystalball_cdf(x, 1.2, 2, 1, 0)"
,-5,5);
56
auto
cdfc =
new
TF1
(
"cdfc"
,
"ROOT::Math::crystalball_cdf_c(x, 1.2, 2, 1, 0)"
,-5,5);
57
cdf->SetLineColor(
kRed
-3);
58
cdf->SetMinimum(0.);
59
cdf->SetMaximum(1.);
60
cdf->Draw();
61
cdfc->SetLineColor(
kMagenta
);
62
cdfc->Draw(
"Same"
);
63
64
legend =
new
TLegend
(0.7,0.7,0.9,1.);
65
legend->AddEntry(cdf,
"N=1.2 alpha=2"
,
"L"
);
66
legend->AddEntry(cdfc,
"N=1.2 alpha=2"
,
"L"
);
67
legend->Draw();
68
}
kRed
@ kRed
Definition
Rtypes.h:67
kGreen
@ kGreen
Definition
Rtypes.h:67
kMagenta
@ kMagenta
Definition
Rtypes.h:67
kBlue
@ kBlue
Definition
Rtypes.h:67
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TF1
Definition
TF1.h:182
TLegend
Definition
TLegend.h:23
c1
return c1
Definition
legend1.C:41
f1
TF1 * f1
Definition
legend1.C:11
tutorials
math
pdf
pdf010_CrystalBall.C
ROOTgit-r3/HEAD - Reference Guide Generated on
(GVA Time) using Doxygen 1.16.1