ROOT
Version v6.34
master
v6.32
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
Reference Guide
►
ROOT
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
th2polyBoxes.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_hist
3
/// \notebook
4
/// This tutorial illustrates how to create an histogram with polygonal
5
/// bins (TH2Poly). The bins are boxes.
6
///
7
/// \macro_image
8
/// \macro_code
9
///
10
/// \author Olivier Couet
11
12
TCanvas
*
th2polyBoxes
() {
13
TCanvas
*
ch2p2
=
new
TCanvas
(
"ch2p2"
,
"ch2p2"
,600,400);
14
gStyle
->
SetPalette
(57);
15
TH2Poly
*
h2p
=
new
TH2Poly
();
16
h2p
->SetName(
"Boxes"
);
17
h2p
->SetTitle(
"Boxes"
);
18
19
Int_t
i,
j
;
20
Int_t
nx
= 40;
21
Int_t
ny
= 40;
22
Double_t
xval1
,
yval1
,
xval2
,
yval2
;
23
Double_t
dx
=0.2,
dy
=0.1;
24
xval1
= 0.;
25
xval2
=
dx
;
26
27
for
(i = 0; i<
nx
; i++) {
28
yval1
= 0.;
29
yval2
=
dy
;
30
for
(
j
= 0;
j
<
ny
;
j
++) {
31
h2p
->AddBin(
xval1
,
yval1
,
xval2
,
yval2
);
32
yval1
=
yval2
;
33
yval2
=
yval2
+
yval2
*
dy
;
34
}
35
xval1
=
xval2
;
36
xval2
=
xval2
+
xval2
*
dx
;
37
}
38
39
TRandom
ran
;
40
for
(i = 0; i<300000; i++) {
41
h2p
->Fill(50*
ran
.Gaus(2.,1),
ran
.Gaus(2.,1));
42
}
43
44
h2p
->Draw(
"COLZ"
);
45
return
ch2p2
;
46
}
Int_t
int Int_t
Definition
RtypesCore.h:45
Double_t
double Double_t
Definition
RtypesCore.h:59
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
gStyle
R__EXTERN TStyle * gStyle
Definition
TStyle.h:436
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TH2Poly
2D Histogram with Polygonal Bins
Definition
TH2Poly.h:66
TRandom
This is the base class for the ROOT Random number generators.
Definition
TRandom.h:27
TStyle::SetPalette
void SetPalette(Int_t ncolors=kBird, Int_t *colors=nullptr, Float_t alpha=1.)
See TColor::SetPalette.
Definition
TStyle.cxx:1888
tutorials
hist
th2polyBoxes.C
ROOT v6-34 - Reference Guide Generated on Sun Mar 30 2025 16:27:33 (GVA Time) using Doxygen 1.10.0