ROOT
git-r3/HEAD
Reference Guide
Loading...
Searching...
No Matches
quantiles.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_math
3
/// \notebook -js
4
/// Demo for quantiles.
5
///
6
/// \macro_image
7
/// \macro_code
8
///
9
/// \authors Rene Brun, Eddy Offermann
10
11
void
quantiles() {
12
const
Int_t
nq = 100;
13
const
Int_t
nshots = 10;
14
Double_t
xq[nq];
// position where to compute the quantiles in [0,1]
15
Double_t
yq[nq];
// array to contain the quantiles
16
for
(
Int_t
i=0;i<nq;i++) xq[i] =
Float_t
(i+1)/nq;
17
18
TGraph
*gr70 =
new
TGraph
(nshots);
19
TGraph
*gr90 =
new
TGraph
(nshots);
20
TGraph
*gr98 =
new
TGraph
(nshots);
21
TH1F
*
h
=
new
TH1F
(
"h"
,
"demo quantiles"
,50,-3,3);
22
23
for
(
Int_t
shot=0;shot<nshots;shot++) {
24
h
->FillRandom(
"gaus"
,50);
25
h
->GetQuantiles(nq,yq,xq);
26
gr70->
SetPoint
(shot,shot+1,yq[70]);
27
gr90->
SetPoint
(shot,shot+1,yq[90]);
28
gr98->
SetPoint
(shot,shot+1,yq[98]);
29
}
30
31
//show the original histogram in the top pad
32
TCanvas
*
c1
=
new
TCanvas
(
"c1"
,
"demo quantiles"
,10,10,600,900);
33
c1
->Divide(1,3);
34
c1
->cd(1);
35
h
->SetFillColor(38);
36
h
->Draw();
37
38
// show the final quantiles in the middle pad
39
c1
->cd(2);
40
gPad
->SetGrid();
41
TGraph
*
gr
=
new
TGraph
(nq,xq,yq);
42
gr
->SetTitle(
"final quantiles"
);
43
gr
->SetMarkerStyle(21);
44
gr
->SetMarkerColor(
kRed
);
45
gr
->SetMarkerSize(0.3);
46
gr
->Draw(
"ap"
);
47
48
// show the evolution of some quantiles in the bottom pad
49
c1
->cd(3);
50
gPad
->DrawFrame(0,0,nshots+1,3.2);
51
gPad
->SetGrid();
52
gr98->
SetMarkerStyle
(22);
53
gr98->
SetMarkerColor
(
kRed
);
54
gr98->
Draw
(
"lp"
);
55
gr90->
SetMarkerStyle
(21);
56
gr90->
SetMarkerColor
(
kBlue
);
57
gr90->
Draw
(
"lp"
);
58
gr70->
SetMarkerStyle
(20);
59
gr70->
SetMarkerColor
(
kMagenta
);
60
gr70->
Draw
(
"lp"
);
61
// add a legend
62
TLegend
*legend =
new
TLegend
(0.85,0.74,0.95,0.95);
63
legend->
SetTextFont
(72);
64
legend->
SetTextSize
(0.05);
65
legend->
AddEntry
(gr98,
" q98"
,
"lp"
);
66
legend->
AddEntry
(gr90,
" q90"
,
"lp"
);
67
legend->
AddEntry
(gr70,
" q70"
,
"lp"
);
68
legend->
Draw
();
69
}
h
#define h(i)
Definition
RSha256.hxx:106
Int_t
int Int_t
Signed integer 4 bytes (int).
Definition
RtypesCore.h:59
Double_t
double Double_t
Double 8 bytes.
Definition
RtypesCore.h:73
Float_t
float Float_t
Float 4 bytes (float).
Definition
RtypesCore.h:71
kRed
@ kRed
Definition
Rtypes.h:67
kMagenta
@ kMagenta
Definition
Rtypes.h:67
kBlue
@ kBlue
Definition
Rtypes.h:67
gPad
#define gPad
Definition
TVirtualPad.h:322
TAttMarker::SetMarkerColor
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition
TAttMarker.h:41
TAttMarker::SetMarkerStyle
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition
TAttMarker.h:43
TAttText::SetTextFont
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition
TAttText.h:52
TAttText::SetTextSize
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition
TAttText.h:53
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TGraph
Definition
TGraph.h:41
TGraph::SetPoint
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
TGraph::Draw
void Draw(Option_t *chopt="") override
Default Draw method for all objects.
TH1F
1-D histogram with a float per channel (see TH1 documentation)
Definition
TH1.h:878
TLegend
Definition
TLegend.h:23
TLegend::AddEntry
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
TLegend::Draw
void Draw(Option_t *option="") override
Draw this box with its current attributes.
c1
return c1
Definition
legend1.C:41
gr
TGraphErrors * gr
Definition
legend1.C:25
tutorials
math
quantiles.C
ROOTgit-r3/HEAD - Reference Guide Generated on
(GVA Time) using Doxygen 1.16.1