_ROOT Version: 6.08
Platform: Not Provided
Compiler: Not Provided
I want to write a histogram to a branch of a tree in PyROOT.
// Opens input file
//Get NDim Histo
//Create Output file
tree = ROOT.TTree( ‘tree’, ‘tree’ )
//extract TH1D histo
//Writing as a branch
tree.Branch(“h1”,“TH1D”,hex(id(h1))) // Here I am giving the address, but I am no getting histogrm
Is there anything I am doing wrong?
Could you please help in this?
Thanks in Advance
Can you try with
This should create a branch called
h1 associated with the
h1 histogram, and when you run
tree.Write() it will write an entry in the tree for that branch.
It works. There is a branch in the tree with a lot of information.
I correct myself, I need a single leaf which contains the histogram (h1) inside the tree.
Right Now we have this –
tree->Branch (h1)-> … … several leaves and plenty of information ***but NOT the h1 distribution
I expect —
tree->leaf (h1) ***** No extra Info, just h1 distribution
h1 is a 1D histogram
So you just want to store a single histogram in your file, is that correct?
If that is so, you just need to
# Opens input file
# Get NDim Histo
# Create Output file
# extract TH1D histo
# Write as single object in file
Yes! this does work.
But I want to write as an object inside tree.
I need this-
fileOut -> tree -> h1
What you were suggesting is -
fileOut -> h1
Please note that the tree is (sort of) a table, so if you write the histogram as a branch (column), you will have N copies of that histogram stored in the tree (where N is the number of rows, called entries in the tree).
Thanks for the reply…
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.