ROOT
master
Reference Guide
Loading...
Searching...
No Matches
hist060_TH1_Stats.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_hist
3
/// \notebook
4
/// Edit statistics box.
5
///
6
/// This example shows:
7
/// - how to remove a stat element from the stat box
8
/// - how to add a new one
9
///
10
/// \macro_image
11
/// \macro_code
12
///
13
/// \date August 2016
14
/// \author Olivier Couet
15
16
TCanvas
*
hist060_TH1_Stats
()
17
{
18
// Create and plot a test histogram with stats
19
TCanvas
*
se
=
new
TCanvas
;
20
TH1F
*
h
=
new
TH1F
(
"h"
,
"test"
, 100, -3, 3);
21
h
->FillRandom(
"gaus"
, 3000);
22
gStyle
->
SetOptStat
();
23
h
->Draw();
24
se
->Update();
25
26
// Retrieve the stat box
27
TPaveStats
*ps = (
TPaveStats
*)
se
->GetPrimitive(
"stats"
);
28
ps->
SetName
(
"mystats"
);
29
TList
*
listOfLines
= ps->
GetListOfLines
();
30
31
// Remove the RMS line
32
TText
*
tconst
= ps->
GetLineWith
(
"RMS"
);
33
listOfLines
->Remove(
tconst
);
34
35
// Add a new line in the stat box.
36
// Note that "=" is a control character
37
TLatex
*
myt
=
new
TLatex
(0, 0,
"Test = 10"
);
38
myt
->SetTextFont(42);
39
myt
->SetTextSize(0.04);
40
myt
->SetTextColor(
kRed
);
41
listOfLines
->Add(
myt
);
42
43
// the following line is needed to avoid that the automatic redrawing of stats
44
h
->SetStats(0);
45
46
se
->Modified();
47
return
se
;
48
}
h
#define h(i)
Definition
RSha256.hxx:106
kRed
@ kRed
Definition
Rtypes.h:66
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
TH1F
1-D histogram with a float per channel (see TH1 documentation)
Definition
TH1.h:634
TLatex
To draw Mathematical Formula.
Definition
TLatex.h:18
TList
A doubly linked list.
Definition
TList.h:38
TPaveStats
The histogram statistics painter class.
Definition
TPaveStats.h:18
TPaveText::GetListOfLines
virtual TList * GetListOfLines() const
Definition
TPaveText.h:48
TPaveText::GetLineWith
virtual TText * GetLineWith(const char *text) const
Get Pointer to first containing string text in this pavetext.
Definition
TPaveText.cxx:301
TPave::SetName
virtual void SetName(const char *name="")
Definition
TPave.h:79
TStyle::SetOptStat
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
Definition
TStyle.cxx:1640
TText
Base class for several text objects.
Definition
TText.h:22
tutorials
hist
hist060_TH1_Stats.C
ROOT master - Reference Guide Generated on Mon Jan 20 2025 04:13:31 (GVA Time) using Doxygen 1.10.0