Hi Philippe hi Wim, Thanks a lot for your replies.
Wim, I know you are working in ATLAS so I will explain my situation more specifically.
I failed to reproduce the “not stable” bit. I found it a few months ago and then I didn’t try to investigate it further and just decided to copy the contents of the trees. However, I still see some inconsistencies. I attatch the file with my trees in. And the following seems to work.
from ROOT import *
f=TFile("MtBjj.test.ntuple.root")
tree=f.Get("ElectronNtuple")
histo=TH2F("histo","", 50,0,50000,50,0,2 )
histo2=TH2F("histo2","", 50,0,50000, 50,0,2)
histo3=TH1F("histo3","", 50,0,50000)
histo4=TH1F("histo4","", 50,0,50000)
histo5=TH1F("histo5","", 5,0,5)
histo6=TH1F("histo6","", 5,0,5)
tree.Draw("(P/E):E>>histo")
tree.Project("histo2", "(P/E):E")
tree.Draw("E>>histo3")
tree.Project("histo4", "E")
tree.Draw("no>>histo5")
tree.Project("histo6", "no")
canv=TCanvas("canv", "", 400,450)
canv.Divide(2,3)
canv.cd(1)
histo.Draw("")
canv.cd(2)
histo2.Draw("")
canv.cd(3)
histo3.Draw("")
canv.cd(4)
histo4.Draw("")
canv.cd(5)
histo5.Draw("")
canv.cd(6)
histo6.Draw("")
canv.SaveAs("test.eps")
Although, this one doesn’t:
from ROOT import *
f=TFile("MtBjj.test.ntuple.root")
tree=f.Get("ElectronNtuple")
histo=TH1F("histo", "", 0,0,5)
tree.Project("histo","no")
canv=TCanvas("canv","", 200,150)
canv.cd(1)
histo.Draw("")
canv.SaveAs("test2.eps")
So why is this? It seems that even in the second one, I have some entries in the histogram but nothing is showing up.
I tried your link too but this does not seem to work on what I have. It is hard for me to see the correspondance with this and my file. Mine is from Athena, I use ntuple service to make this but not sure this is in the right kind of format. Your link seems to explain how to get trees out of a directory, while I want to get hold of the values in the Leaves.
Of course, I would love to do all the things instead of copying which is dreadful. But as I described above, with the method I know, I only get “buffer” which is not good enough since it will be replaced by another tree as soon as I retrieve another leaf.
I have to admit, though, I am not very sure if I am structuring my analysis right. What I decided to do is to get some variables out in the form of ntuple and manipulate them afterwards. This involves things like I want to accept the reconstructed top if there was exactly two light jets of energy bigger than 40GeV and two b-jets with likelihood bigger than 0.6 and the missing Et is bigger than 20GeV and so on and so on. Plus I want to be able to change these cuts as I wish withought running another 10-hour job.
All the functionalities provided with the Draw and Project methods in Trees are attractive, although I couldn’t quite figure out how I can impliment everything I want to do with them.
Methods structured around Trees and Leaves seem very hard to understand for me, I was expecting something like
aTree.GetLeaf("aLeaf").GetValue(1)
But nothing seems to work that way and I am not too sure how these things are designed to be used and I am confused.
Any suggestion is much appreciated. Thank you for your help.
MtBjj.test.ntuple.root (106 KB)