Getting drawn histograms from TTree

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)

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

Master/v624 documentation