ROOT
v6-32
Reference Guide
Loading...
Searching...
No Matches
gtime.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_graphics
3
/// Example of a graph of data moving in time.
4
/// Use the canvas "File/Quit ROOT" to exit from this example
5
///
6
/// \macro_code
7
///
8
/// \author Olivier Couet
9
10
void
gtime()
11
{
12
auto
c1
= (
TCanvas
*)
gROOT
->FindObject(
"c1"
);
13
if
(
c1
)
delete
c1
;
14
15
c1
=
new
TCanvas
(
"c1"
);
16
const
Int_t
ng = 100;
17
const
Int_t
kNMAX
= 10000;
18
std::vector<Double_t>
X
(
kNMAX
), Y(
kNMAX
);
19
Int_t
cursor
=
kNMAX
;
20
Double_t
x
= 0, stepx = 0.1;
21
22
while
(!
gSystem
->ProcessEvents()) {
23
if
(
cursor
+ ng >=
kNMAX
) {
24
cursor
= 0;
25
for
(
Int_t
i
= 0;
i
< ng;
i
++) {
26
X
[
i
] =
x
;
27
Y[
i
] =
TMath::Sin
(
x
);
28
x
+= stepx;
29
}
30
}
else
{
31
X
[
cursor
+ng] =
x
;
32
Y[
cursor
+ng] =
TMath::Sin
(
x
);
33
x
+= stepx;
34
cursor
++;
35
}
36
37
TGraph
*
g
=
new
TGraph
(ng,
X
.data()+
cursor
, Y.data()+
cursor
);
38
g
->SetMarkerStyle(21);
39
g
->SetMarkerColor(
kBlue
);
40
g
->SetLineColor(
kGreen
);
41
g
->SetBit(
kCanDelete
);
// let canvas delete graph when call TCanvas::Clear()
42
43
c1
->Clear();
44
g
->Draw(
"alp"
);
45
c1
->Update();
46
47
gSystem
->Sleep(10);
48
}
49
}
g
#define g(i)
Definition
RSha256.hxx:105
Int_t
int Int_t
Definition
RtypesCore.h:45
Double_t
double Double_t
Definition
RtypesCore.h:59
kGreen
@ kGreen
Definition
Rtypes.h:66
kBlue
@ kBlue
Definition
Rtypes.h:66
X
#define X(type, name)
cursor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t cursor
Definition
TGWin32VirtualXProxy.cxx:160
i
Int_t i
Definition
TGraphAsymmErrors.cxx:1306
kNMAX
const Int_t kNMAX
Definition
THistPainter.cxx:3162
kCanDelete
@ kCanDelete
Definition
TObject.h:364
gROOT
#define gROOT
Definition
TROOT.h:414
gSystem
R__EXTERN TSystem * gSystem
Definition
TSystem.h:566
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TGraph
A TGraph is an object made of two arrays X and Y with npoints each.
Definition
TGraph.h:41
c1
return c1
Definition
legend1.C:41
x
Double_t x[n]
Definition
legend1.C:17
TMath::Sin
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition
TMath.h:588
tutorials
graphics
gtime.C
ROOT v6-32 - Reference Guide Generated on Tue May 19 2026 02:47:09 (GVA Time) using Doxygen 1.13.2