ROOT
v6-32
Reference Guide
Loading...
Searching...
No Matches
hsumanim.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_image
3
/// \notebook
4
/// This script is a slightly modified version of hsum.C.
5
///
6
/// Uncomment the two `c1->Print(...);` lines in order to produce
7
/// an animated gif file. The option "++" makes an infinite animation.
8
/// The animated file `hsumanim.gif` can be visualized within a web browser
9
///
10
/// \macro_image
11
/// \macro_code
12
///
13
/// \authors Rene Brun, Valeriy Onuchin
14
15
void
hsumanim() {
16
auto
c1
=
new
TCanvas
(
"c1"
,
"The HSUM example"
,200,10,600,400);
17
c1
->SetGrid();
18
19
gBenchmark
->Start(
"hsum"
);
20
21
// Create some histograms.
22
auto
total
=
new
TH1F
(
"total"
,
"This is the total distribution"
,100,-4,4);
23
auto
main
=
new
TH1F
(
"main"
,
"Main contributor"
,100,-4,4);
24
auto
s1
=
new
TH1F
(
"s1"
,
"This is the first signal"
,100,-4,4);
25
auto
s2 =
new
TH1F
(
"s2"
,
"This is the second signal"
,100,-4,4);
26
total
->Sumw2();
// this makes sure that the sum of squares of weights will be stored
27
total
->SetMarkerStyle(21);
28
total
->SetMarkerSize(0.7);
29
main
->SetFillColor(16);
30
s1
->SetFillColor(42);
31
s2->SetFillColor(46);
32
TSlider
*slider = 0;
33
gSystem
->Unlink(
"hsumanim.gif"
);
// delete old file
34
35
// Fill histograms randomly
36
gRandom
->SetSeed();
37
const
Int_t
kUPDATE
= 500;
38
Float_t
xs1, xs2, xmain;
39
Int_t
gifcnt = 0;
40
for
(
Int_t
i
=0;
i
<10000;
i
++) {
41
xmain =
gRandom
->Gaus(-1,1.5);
42
xs1 =
gRandom
->Gaus(-0.5,0.5);
43
xs2 =
gRandom
->Landau(1,0.15);
44
main
->Fill(xmain);
45
s1
->Fill(xs1,0.3);
46
s2->Fill(xs2,0.2);
47
total
->Fill(xmain);
48
total
->Fill(xs1,0.3);
49
total
->Fill(xs2,0.2);
50
if
(
i
&& (
i
%
kUPDATE
) == 0) {
51
if
(
i
==
kUPDATE
) {
52
total
->Draw(
"e1p"
);
53
main
->Draw(
"same"
);
54
s1
->Draw(
"same"
);
55
s2->Draw(
"same"
);
56
c1
->Update();
57
slider =
new
TSlider
(
"slider"
,
"test"
,4.2,0,4.6,
total
->GetMaximum(),38);
58
slider->
SetFillColor
(46);
59
}
60
if
(slider) slider->
SetRange
(0,
Float_t
(
i
)/10000.);
61
c1
->Modified();
62
c1
->Update();
63
if
(
gROOT
->IsBatch()) {
64
// c1->Print("hsumanim.gif+");
65
printf(
"i = %d\n"
,
i
);
66
}
else
{
67
if
(
gSystem
->ProcessEvents())
68
break
;
69
}
70
}
71
}
72
slider->
SetRange
(0,1);
73
total
->Draw(
"sameaxis"
);
// to redraw axis hidden by the fill area
74
c1
->Modified();
75
// c1->Print("hsumanim.gif++")
76
77
gBenchmark
->Show(
"hsum"
);
78
}
s1
#define s1(x)
Definition
RSha256.hxx:91
Int_t
int Int_t
Definition
RtypesCore.h:45
Float_t
float Float_t
Definition
RtypesCore.h:57
gBenchmark
R__EXTERN TBenchmark * gBenchmark
Definition
TBenchmark.h:59
kUPDATE
@ kUPDATE
Definition
TFitParametersDialog.cxx:46
total
static unsigned int total
Definition
TGWin32ProxyDefs.h:40
i
Int_t i
Definition
TGraphAsymmErrors.cxx:1306
gROOT
#define gROOT
Definition
TROOT.h:414
gRandom
R__EXTERN TRandom * gRandom
Definition
TRandom.h:62
gSystem
R__EXTERN TSystem * gSystem
Definition
TSystem.h:566
main
int main(int argc, char *argv[])
Definition
cef_main.cxx:54
TAttFill::SetFillColor
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition
TAttFill.h:37
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TH1F
1-D histogram with a float per channel (see TH1 documentation)
Definition
TH1.h:621
TSlider
A specialized TPad including a TSliderBox object.
Definition
TSlider.h:17
TSlider::SetRange
virtual void SetRange(Double_t xmin=0, Double_t xmax=1)
Set Slider range in [0,1].
Definition
TSlider.cxx:183
c1
return c1
Definition
legend1.C:41
tutorials
image
hsumanim.C
ROOT v6-32 - Reference Guide Generated on Tue May 19 2026 02:47:09 (GVA Time) using Doxygen 1.13.2