[Gate-users] Reading root histogram values
Jon Moody
jbmoody at umich.edu
Tue Jul 19 13:52:51 CEST 2011
The python interface to ROOT is good for this sort of thing, for example:
"""
from ROOT import gROOT, gDirectory, TFile
gROOT.Reset
f = TFile('file.root', 'read')
tree = gDirectory.Get('Singles;1')
nevents = tree.GetEntriesFast()
v1, v2 = 0, 0
for j in range(nevents):
nb = tree.GetEntry(j)
if nb < 0: continue
volname = tree.comptVolName
if volname == 'Vol1':
v1 += 1
elif volname == 'Vol2':
v2 += 1
"""
--
Jon
On 7/18/2011 4:58 PM, Konik, Arda wrote:
> Hi All,
> How can I read the root histogram values ?
> Currently, I just enable the " Event Statusbar " as in the attached screenshot and bring the cursor on the horizontal line to read its y - value at the bottom.
> In this example, the cursor (invisible on this picture) is positioned somewhere on the highlighted tab and the y-value correctly shows y = 56.
> However, this is not practical when there are multiple quantities I need to check as in the case of ComptVolname (i.e., compton scatter values of different SD in the system), especially
> when horizontal lines are very close to y = 0.
>
> How can I read these values without using this graphical method ? I tried to use some root commands but couldn't get what I needed...
> I ll appreciate if you could give a command line example to get the scatter values of , say 2 materials ( Vol1 and Vol2) in ComptVolname.
>
> Thanks,
>
> Arda
>
>
>
>
> _______________________________________________
> Gate-users mailing list
> Gate-users at lists.opengatecollaboration.org
> http://lists.opengatecollaboration.org/mailman/listinfo/gate-users
More information about the Gate-users
mailing list