You are a guest. Restricted access. Read more.
SCaVis manual


Reading ROOT files

SCaVis supports reading files created by the ROOT data-analysis program implemented in C++. There are several ways to read ROOT file but the easiest is to use the FileRoot class. You can list all objects inside ROOT files, navigate inside the ROOT files and extract histograms and graphs (TGraph) objects. Below is a simple example showing how to do this:

Code example

  Download for this example is disabled for non-members
 1: from jhplot  import *
 2: from import *
 4: rr = FileRoot("file.root")
 5: print "number of objects=",rr.getNKeys()  # how many objects in the current directory
 6: print "ROOT version=",rr.getVersion()
 7: print rr.toString()          # list all entries in the current directory
 9:"dir1/dir2")           # navigate to a directory inside the ROOT file
10: p1=rr.get("TGraph_example")  # extract TGraph as  P1D Java object
11: h1=rr.get("hpx")             # extract TH1 histogram as H1D Java object
12: h2=rr.get("hpxpy")           # extract TH2D   as H2D Java object
14: c1 = HPlot("Canvas",600,400,2,1)
15: c1.setGTitle("Reading root objects from a file")
16: c1.visible()
17: c1.setAutoRange()
20: c1.draw(p1)
23: c1.setAutoRange()
24: c1.draw(h1)

Note that the method get() returns a ROOT objects. In case TH1 ROOT histograms, it will return H1D histograms ready to plot on SCaVis canvas. In case of TH2 ROOT histograms, it will return H2D SCaVis histogram. It can also create P1D objects by reading TGraph ROOT object.

Reading AIDA files

You can read AIDA objects using the classes FileAida Here is a simile example showing how to read an AIDA file and plot Clouds and histograms:

Code example

  Download for this example is disabled for non-members
 1: from java.awt import Color
 2: from jhplot  import *
 3: from  import *
 5: # location of AIDA file (in /macro/examples/jaida_examples)
 6: a=FileAida( "UsingJAIDAFromJython.aida")
 8: c1d=a.get("Clouds/Cloud 1D")  # retrieve objects
 9: c2d=a.get("Clouds/Cloud 2D")
10: h1=a.get("Histograms/Histogram 1D")
12: hh1=H1D(h1) # Convert Histogrm1D to H1D so we can add some color
13: hh1.setColor(
15: c1 = HPlot("Canvas",600,400,2,1)
16: c1.setGTitle("Reading  AIDA objects from a file")
17: c1.visible(1)
18: c1.setAutoRange()
21: c1.draw(c1d)
22: c1.draw(hh1)
25: c1.setAutoRange()
26: c1.draw(c2d)

The output of this script is shown below.

See the example “” for ROOT-file examples.

Plotting AIDA or ROOT objects using browser

One can open AIDA or ROOT files using HPlotJa browser. In the SCaVis IDE, go to “Tools-HplotJa”. Then, in the HplotJa, create an empty pad (pads), as “Options→Draw pad”. Then, open ROOT or AIDA file as “File-Open data”. You will see a ObjectBrowser. Select any object, such as histograms or cloud. With the mouse (right button), click on the selected object and press “Draw”.

Look at the visual guide how to open a AIDA file (similarly, ROOT file):

STEP 1: (step 1)

STEP 2 : (step 2)

STEP 3: (step3)

STEP 4: (step 4)

ASCII, Gauss, Matlab, Excel data formats

SCaVis can read data (timeseries) in variety of formats, such as ASCII, Gauss, Matlab, Excel. Data can be modified, showed as tables/ One can plot such data and perform a statistical analysis. One can also save such data into files. Read timeseries for detail since this topic is closely related to financial calculations

Third-party IO classes

click here if you want to know more

click here if you want to know more

click here if you want to know more

here are a lot of other Java-based I/O classes designed for storing and retrieving data. A complete description of how to use Java, Jython and SCaVis for scientific analysis is described in the book Scientific data analysis using Jython and Java published by Springer Verlag, London, 2010 (by S.V.Chekanov)

Sergei Chekanov 2010/03/07 17:35

man/io/root_aida.txt · Last modified: 2013/05/31 16:11 (external edit)
CC Attribution-Share Alike 3.0 Unported
Powered by PHP Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 Valid HTML5