I am using pyROOT, and I find a very strange issue regarding TTree.Project:
my_tree.Project(“my_histo”,“my_var”)
is giving to my an empty histogram (I checked drawing it or printing its content).
Also the making the following command:
my_tree.Draw(“my_var>>my_hist”) is giving to me an empty histogram.
Firstly, I ensure that the variable inside my tree exists, and also that I am using the name of the histogram (my_histo=TH1D(“my_histo”,“my_histo”,40,1,8))
I also tried to implement gROOT.cd(), before the command regarding the TTree (as I saw here: )
Please fill also the fields below. Note that root -b -q will tell you this info, and starting from 6.28/06 upwards, you can call .forum bug from the ROOT prompt to pre-populate a topic.
ROOT Version: Not Provided Platform: Not Provided Compiler: Not Provided
import ROOT as r
r.gROOT.cd()
h = r.TH1D("h","h",40,-4,4)
data = r.TFile.Open("hsimple.root")
t = data.Get("ntuple")
r.gROOT.cd()
t.Project("h","log10(random)")
h.Draw()
So it’s not an issue in these lines of code (tested with ROOT v.6.30/06) (maybe you are doing more, that you didn’t show here?) Check that you are really reading the file and getting the histogram with those exact lines. Try
my_tree.Draw("log10(mc_E)")
instead of Project, or also try my_tree.Draw("mc_E"), and see if you get something.