Re: Browsing the contents of a file...

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Oct 08 1997 - 08:36:53 MEST


Gordon Watts (Brown University) wrote:
> 
> Hi,
>   I'm just getting started with Root, so perhaps this question is a little
> off. I'm using the NT version, the most recent development version. I
> converted a 3 meg PAW ntuple to a ROOT file. I then wanted to browse the
> contents of the file (basically, I wanted to do a "ntuple/print" on the
> guy). The instructions for the conversion talk about using the TBrowser.
> So, first I created a TFile that pointed to the file, and that worked just
> fine. I then created a browser object and up poped the window just fine. I
> was even able to find the instance of the file object under the global
> varriables section. However, when I clicked on the file object (as when I
> clicked on almost anything else) I got an error saying the "Browse" method
> needs to be over-ridden.
> 
>   What is the proper method to look for the various branchs and trees, etc.
> that are in a file?
> 

Assuming that your ntuple object is called "h1" (converted from Hbook
id=1),
you can do:
  Root > TFile f("myfile.root");
  Root > h1.Print();  // this will get the object h1 in memory and show
its contents

To create a browser object, do
  Root > TBrowser b;  // this will create the browser window
In the browser, you can click on the item "ROOT Files"
then click on "myfile.root", then on "h1".
At this point you should see all your ntuple variables in the right pane
of the browser. To histogram one variable, simply click on the variable
name.
You can also click with the right mouse button on "h1" in the left pane
to execute one of the proposed actions (eg Print) on the ntuple object.

A future version of the browser will include the possibility to browse
your file system (current directory) and automatically connect a Root
file.
Note also that the WindowsNT version does not include all the features
of the Unix version.

If you click on the "Global Variables" item in the browser, you see
the list of all currently defined globals. However, the corresponding
icons in the right pane are all from the class TGlobal with a reference
to the real object (click with the right mouse button to check).
You cannot perform an operation on the referenced object at this level.
This could be implemented.

>   I was able, in the end, to see what was in the file by getting the ntuple
> object, and then invoking the "MakeCode" method on it. BTW, in the
> instructions for doing this (in the HOWTO section of the web pages) you
> have the call written as "MakeCode.C("filename.c");" The ".C" isn't valid
> as far as I can tell.

I have fixed the typo.

> 
>   Finally, I note that ROOT on NT seems to be built with MSVC 4.0. I will
> need to build some libraries and add them to ROOT as sharable (I guess).
> Unfortunately, I've only got access to 5.0. Anyone using this
> configuration: are there any potholes I should know about?
> 
In principle, you should be able to mix DLLs generated with version 4
with your DLLs generated with version 5. (Valery correct me if this is
wrong).
Examples to generate user DLLs linked with ROOT are given in the
root/test/Event example in the distribution kit.

Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:21 MET