[Gate-users] Reading root histogram values

Konik, Arda Arda.Konik at umassmed.edu
Tue Jul 19 20:03:11 CEST 2011


Thank you Jon and Ramya for  your responses.
I can now, more easily and accurately read the values.

Arda
On Jul 19, 2011, at 7:52 AM, Jon Moody wrote:

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

Hi Arda,

Inside Root's TBrowser, right-click on say, the Singles tree and
"StartViewer". This opens a TreeViewer with all the leaves. Make sure
the "Scan" box (top right) in the TreeViewer is checked, then
right-click on say, comptVolName and then "Scan". A file called
Singles-scan.dat is created in the working directory that now contains
the data.  (As of now, I don't know how to set the file name inside Root
other than just going back to the working directory and renaming a file
before creating another output file). If the "Scan" box in the
TreeViewer is not checked, then there is a continuous verbose output of
the data on the screen. 

The other option is to have the ascii output enabled in your macro. This
way, you get all the data you need in the Singles and Hits files.

Hope that helps,

Ramya

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

_______________________________________________
Gate-users mailing list
Gate-users at lists.opengatecollaboration.org
http://lists.opengatecollaboration.org/mailman/listinfo/gate-users


Arda Konik
UMASS Medical School
Dept. of Radiology




More information about the Gate-users mailing list