Getting Bin content from 3D histogram in python


I am new to root. I would like to know how to get bin contents of a TH3 from a root file in python. I was able to get the bin contents in ROOT but is there a way to do the same thing in python?

Thanks in advance.

_ROOT Version: 6.18/04

I guess the same method calls should be available in both languages.

how to load the histogram in python?

I did
import ROOT

what should i do next?

Sorry for my ignorance. I am very new to both root and python.

What did you do in ROOT (i.e. C++)?

In the ROOT, I did

TFile *f = new TFile("[filename]")
TH3D *h3 = new TH3D(“h3”,“prob”, nbinx, xmin, xmax, nbiny, ymin, ymax, nbinz, zmin, zmax)

file = ROOT.TFile.Open("[filename]")
h3 = file.Get("hist")
print h3.GetBinContent(h3.FindFixBin(some_x_value, some_y_value, some_z_value))

it works. thank you very much.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.