Leaf to Histogram

Nice to meet you

I want to know, if I make the histogram from the leaf of tree as

T->Draw(Form(“leaf>>histo”),Form(“some conditions”));

Can I get do ‘Integral()’ or ‘GetBinContent()’ from this histogram in the code?

example)

T->Draw(Form(“leaf>>histo”),Form(“some conditions”));
int num = histo->Integral();

If it can’t then how could I get the Integral of bincontent?

Cheers
Kyounghyoun

Hi,
yes it is possible if you do something like this:

auto histo = new TH1D("h1","my histogram",100,1,0);
tree->Draw( "leaf >> h1");
int num = histo->Integral();

Note that inside TTree::Draw you must use the histogram name (i.e h1), while when calling TH1::Integral you must use the C++ instance name (i.e histo )

Lorenzo

if you do not need the plot you can do:

tree->Draw( "leaf >> h1", "", "goff");

Now I can get the histogram from the tree

Many Thanks!!

Ciao
Kyounghyoun