ROOT
git-r3/HEAD
Reference Guide
Loading...
Searching...
No Matches
hist057_TExec_th1.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_hist
3
/// Echo object at mouse position.
4
/// Example of macro called when a pad is redrawn
5
/// one must create a TExec object in the following way
6
/// ~~~{.cpp}
7
/// gPad->AddExec("ex1", ".x hist057_TExec_th1.C");
8
/// ~~~
9
/// this macro prints the bin number and the bin content when one clicks
10
/// on the histogram contour of any histogram in a pad
11
///
12
/// \macro_code
13
///
14
/// \date November 2022
15
/// \authors Rene Brun, Sergey Linev
16
17
void
hist057_TExec_th1()
18
{
19
if
(!
gPad
) {
20
Error
(
"hist057_TExec_th1"
,
"gPad is null, you are not supposed to run this macro"
);
21
return
;
22
}
23
24
Int_t
event
=
gPad
->GetEvent();
25
int
px =
gPad
->GetEventX();
26
TObject
*select =
gPad->GetSelected();
27
28
if
(select && select->InheritsFrom(
TH1::Class())) {
29
TH1
*
h
= (
TH1
*)select;
30
Float_t
xx =
gPad
->AbsPixeltoX(px);
31
Float_t
x
=
gPad
->PadtoX(xx);
32
Int_t
binx =
h
->GetXaxis()->FindBin(
x
);
33
printf(
"event=%d, hist:%s, bin=%d, content=%f\n"
, event,
h
->GetName(), binx,
h
->GetBinContent(binx));
34
}
35
}
h
#define h(i)
Definition
RSha256.hxx:106
Int_t
int Int_t
Signed integer 4 bytes (int).
Definition
RtypesCore.h:59
Float_t
float Float_t
Float 4 bytes (float).
Definition
RtypesCore.h:71
Error
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
gPad
#define gPad
Definition
TVirtualPad.h:322
TH1
TH1 is the base class of all histogram classes in ROOT.
Definition
TH1.h:109
TH1::Class
static TClass * Class()
TObject
Mother of all ROOT objects.
Definition
TObject.h:42
x
Double_t x[n]
Definition
legend1.C:17
df101_h1Analysis.select
select(rdf)
Definition
df101_h1Analysis.py:37
tutorials
hist
hist057_TExec_th1.C
ROOTgit-r3/HEAD - Reference Guide Generated on
(GVA Time) using Doxygen 1.16.1