# Getting drawn histograms from TTree

**URL:** <https://root-forum.cern.ch/t/getting-drawn-histograms-from-ttree/45278>\
**Category:** Newbie\
**Tags:** tree, hist, root\
**Created:** [June 6, 2021, 2:20pm UTC](https://root-forum.cern.ch/t/getting-drawn-histograms-from-ttree/45278 "2021-06-06T14:20:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dario\_Ramirez](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dario_ramirez/32/26397_2.png) [@Dario\_Ramirez](https://root-forum.cern.ch/u/Dario_Ramirez)\
**Post date:** [June 6, 2021, 2:20pm UTC](https://root-forum.cern.ch/t/getting-drawn-histograms-from-ttree/45278/1 "2021-06-06T14:20:53Z")

</div>

_ROOT Version:_ 6.16/00  
_Platform:_ Ubuntu 20.04.2 LTS x64  
_Compiler:_ Not Provided

* * *

Hello,

I am looking for the fastest way to get the built histograms from a TTree.  
I have a TTree that for each entry has a vector. This class T has members: Charge, Channel, … etc.

Each time I want to see Channel Distribution and/or Charge vs ChannelI run this: (after getting the tree from the .root file)

```auto
tree->Draw("StsDigi.fChannel>>h1(2048,0,2048)","")
tree->Draw("StsDigi.fChannel:StsDigi.fChannel>>h2(2048,0,2048,32,0,32)","","colz")

```

This build h0/h1 histograms with the (2048,0,2048)/(2048,0,2048,32,0,32) binning options, looping over all entries of the tree.  
My understanding is that for each entry, a histogram is built base on the vector StsDigi’s members. Then, all the histograms are merged into one. Am I correct?

I want to know how to retrieve them to save these histograms to a new .root file. Moreover, if there is a better way to solve this I will be glad to read it to you.

Thanks in advance,  
Dario

---

<div class="post-metadata">

**Author:** ![berserker](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/berserker/32/17693_2.png) [@berserker](https://root-forum.cern.ch/u/berserker)\
**Post date:** [June 6, 2021, 2:34pm UTC](https://root-forum.cern.ch/t/getting-drawn-histograms-from-ttree/45278/2 "2021-06-06T14:34:11Z")

</div>

[Master](https://root.cern.ch/doc/master/classTTree.html#autotoc_md927)/[v624](https://root.cern.ch/doc/v624/classTTree.html#:~:text=Saving%20the%20result%20of%20Draw%20to%20a%20histogram) documentation
