DMelt:IO/9 Other file formats

From HandWiki
Limitted access. First login to DataMelt if you are a full DataMelt member. Then login to HandWiki as a user.

ROOT/AIDA/Matlab/Excel =
Reading ROOT files

DataMelt supports reading files created by the Software:ROOT implemented in C++. There are several ways to read ROOT file but the easiest is to use the 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:

from java.awt import Color
from jhplot  import *
from  import *


# location of ROOT file
rfr = FileRoot( file )
print "number of histograms=",rfr.getNKeys()
print "ROOT version=",rfr.getVersion()
print "ROOT version=",rfr.getTitle()
print "No of histograms=",rfr.toString()

# get ROOT histograms 
h1 = rfr.getH1D("mainHistogram")
h2 = rfr.getH1D("totalHistogram") 
# create canvas 1x1
c1 = HPlot("Canvas",600,400,1, 1)
c1.setGTitle("Show ROOT histograms from Example.root")

c1.setRange(0, -4, 4)
# set autorange for Y



c1.setName("Canvas title")

# export to some image (png,eps,pdf,jpeg...)
# c1.export(Editor.DocMasterName()+".png");

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

Reading AIDA files

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

<jcode lang="python" > dmelt

The output of this script is shown below.

DMelt example: Reading AIDA file and accessing histograms

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 DataMelt 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".

ASCII, Gauss, Matlab, Excel data formats

DataMelt 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.