# Leaf to Histogram

**URL:** <https://root-forum.cern.ch/t/leaf-to-histogram/40506>\
**Category:** Newbie\
**Created:** [July 18, 2020, 11:27pm UTC](https://root-forum.cern.ch/t/leaf-to-histogram/40506 "2020-07-18T23:27:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kykwon](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/7ab992/32.png) [@kykwon](https://root-forum.cern.ch/u/kykwon)\
**Post date:** [July 18, 2020, 11:27pm UTC](https://root-forum.cern.ch/t/leaf-to-histogram/40506/1 "2020-07-18T23:27:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [July 20, 2020, 2:52pm UTC](https://root-forum.cern.ch/t/leaf-to-histogram/40506/2 "2020-07-20T14:52:47Z")

</div>

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

```auto
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

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [July 21, 2020, 8:01am UTC](https://root-forum.cern.ch/t/leaf-to-histogram/40506/3 "2020-07-21T08:01:30Z")

</div>

if you do not need the plot you can do:

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

```

---

<div class="post-metadata">

**Author:** ![kykwon](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/7ab992/32.png) [@kykwon](https://root-forum.cern.ch/u/kykwon)\
**Post date:** [August 4, 2020, 12:42pm UTC](https://root-forum.cern.ch/t/leaf-to-histogram/40506/4 "2020-08-04T12:42:54Z")

</div>

Now I can get the histogram from the tree

Many Thanks!!

Ciao  
Kyounghyoun
