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
hist2image.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_image
3
/// \notebook
4
/// Create an image from a 2-D histogram and manipulate it.
5
///
6
/// \image html image_hist2image.png
7
/// \macro_code
8
///
9
/// \author Valeriy Onuchin
10
11
#include <
TAttImage.h
>
12
13
void
hist2image
()
14
{
15
16
TCanvas
*
canv
=
new
TCanvas
(
"image"
,
"xygaus + xygaus(5) + xylandau(10)"
);
17
canv
->ToggleEventStatus();
18
canv
->SetRightMargin(0.2);
19
canv
->SetLeftMargin(0.01);
20
canv
->SetTopMargin(0.01);
21
canv
->SetBottomMargin(0.01);
22
23
// histogram as image (hist taken from draw2dopt.C)
24
TImage
*
img
=
TImage::Create
();
25
26
TF2
*f2 =
new
TF2
(
"f2"
,
"(xygaus + xygaus(5) + xylandau(10))"
,-4,4,-4,4);
27
Double_t
params[] = {130,-1.4,1.8,1.5,1, 150,2,0.5,-2,0.5, 3600,-2,0.7,-3,0.3};
28
f2->
SetParameters
(params);
29
TH2D
*
h2
=
new
TH2D
(
"h2"
,
"xygaus + xygaus(5) + xylandau(10)"
,100,-4,4,100,-4,4);
30
h2
->FillRandom(
"f2"
,40000);
31
img
->SetImage((
const
Double_t
*)
h2
->GetArray(),
h2
->GetNbinsX() + 2,
32
h2
->GetNbinsY() + 2,
gHistImagePalette
);
33
img
->Draw();
34
img
->StartPaletteEditor();
35
}
Double_t
double Double_t
Definition
RtypesCore.h:59
TAttImage.h
gHistImagePalette
R__EXTERN TImagePalette * gHistImagePalette
Definition
TAttImage.h:109
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TF1::SetParameters
virtual void SetParameters(const Double_t *params)
Definition
TF1.h:677
TF2
A 2-Dim function with parameters.
Definition
TF2.h:29
TH2D
2-D histogram with a double per channel (see TH1 documentation)
Definition
TH2.h:357
TImage
An abstract interface to image processing library.
Definition
TImage.h:29
TImage::Create
static TImage * Create()
Create an image.
Definition
TImage.cxx:35
TMVA_SOFIE_GNN_Parser.h2
h2
Definition
TMVA_SOFIE_GNN_Parser.py:188
tutorials
image
hist2image.C
ROOT v6-34 - Reference Guide Generated on Mon Mar 31 2025 06:04:14 (GVA Time) using Doxygen 1.10.0