jhplot.io
Class FileRoot

java.lang.Object
  extended by jhplot.io.FileRoot

public class FileRoot
extends Object

Class to read ROOT files. To get directory inside the file, use "cd()" method. You can get any objects inside a ROOT file as using keys as:

key1 = rr.getKey("dir1")
dir1=key1.getObject()
key2=dir1.getKey("dir2")
dir2=key2.getObject()
key3=dir2.getKey("Histogram")
h1d=H1D( key3.getObject() )


Constructor Summary
FileRoot(String file)
          Main constructor to build root file reader.
FileRoot(URL url)
          Open file from URL
 
Method Summary
 hep.io.root.interfaces.TDirectory cd(String dir)
          Navigate to a directory inside the ROOT file.
 void doc()
          Show online documentation.
 Object get(String skey)
          Get object associated with the key name in the current directory.
 H1D getH1D(String skey)
          Get H1D histogram associated with the key name.
 H2D getH2D(String skey)
          Get H2D histogram associated with the key name.
 List getInfo()
          Get the StreamerInfo
 hep.io.root.interfaces.TKey getKey(int i)
          Get a key using its index.
 hep.io.root.interfaces.TKey getKey(String skey)
          Get a key
 ArrayList<String> getKeys()
          Return all keys of the current directory as a list.
 int getNKeys()
          Get number of objects in the current directory of a ROOT file.
 Object getObject(int i)
          Get object associated with the key name in tthe current directory.
 Object getObject(String skey)
          Get object associated with the key name in the current directory.
 P1D getP1D(String skey)
          Get P1D associated with the key name.
 hep.io.root.RootFileReader getReader()
          Returns RootFileReader
 String getTitle()
          Get ROOT title
 int getVersion()
          Get ROOT version
 String toString()
          Return all root objects in form of a string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileRoot

public FileRoot(String file)
Main constructor to build root file reader.

Parameters:
file - Input root file

FileRoot

public FileRoot(URL url)
Open file from URL

Parameters:
url - Input URL file
Method Detail

cd

public hep.io.root.interfaces.TDirectory cd(String dir)
Navigate to a directory inside the ROOT file.

Parameters:
directory - inside the file. Use the standard unix path, i.e. dir1/dir2/dir3

toString

public String toString()
Return all root objects in form of a string. Use cd(dir) to navigate to a specific directory

Overrides:
toString in class Object
Returns:
a string showing all ROOT objects in the current directory

getKeys

public ArrayList<String> getKeys()
Return all keys of the current directory as a list.

Returns:
a list of all keys for the current directory

getVersion

public int getVersion()
Get ROOT version

Returns:
ROOT version

getNKeys

public int getNKeys()
Get number of objects in the current directory of a ROOT file.

Returns:
number of objects

getTitle

public String getTitle()
Get ROOT title

Returns:
ROOT title

getKey

public hep.io.root.interfaces.TKey getKey(int i)
Get a key using its index. Can be called after navigation to a directory using the cd() method.

Parameters:
i - index of this key
Returns:
TKey object.

getInfo

public List getInfo()
Get the StreamerInfo

Parameters:
streamer - info

getKey

public hep.io.root.interfaces.TKey getKey(String skey)
Get a key

Parameters:
skey - key name
Returns:
TKey object.

getReader

public hep.io.root.RootFileReader getReader()
Returns RootFileReader

Returns:
RootFileReader

getH1D

public H1D getH1D(String skey)
Get H1D histogram associated with the key name. It is assumed that this ROOT key keeps histogram (TH1).

Parameters:
skey - key name
Returns:
H1D histogram

getH2D

public H2D getH2D(String skey)
Get H2D histogram associated with the key name. It is assumed that this ROOT key keeps histogram (TH1).

Parameters:
skey - key name
Returns:
H2D histogram

getP1D

public P1D getP1D(String skey)
Get P1D associated with the key name. It corresponds to TGraph in ROOT. It is assumed that this ROOT key keeps histogram (TH1).

Parameters:
skey - key name
Returns:
P1D object representing TGraph inside ROOT file

get

public Object get(String skey)
Get object associated with the key name in the current directory. The mapping is as following:
TGraph will be returned as P1D object
TH1F or TH1D will be returned as H1D object
TH2F or TH2D will be returned as H2D object
other objects will be returned as in hep.io.root.interfaces.

Parameters:
skey - key name
Returns:
Object depending on the key.

getObject

public Object getObject(String skey)
Get object associated with the key name in the current directory.

Parameters:
skey - key name
Returns:
Object

getObject

public Object getObject(int i)
Get object associated with the key name in tthe current directory.

Parameters:
i - key index
Returns:
Object

doc

public void doc()
Show online documentation.



jHepWork 3.1 ©