DMelt:IO/9 Other file formats
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 jhplot.io.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:
from java.awt import Color from jhplot import * from jhplot.io import * file="Example.root" Web.get("https://datamelt.org/examples/data/"+file) # 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.visible(1) c1.setMarginLeft(90) c1.setRange(0, -4, 4) # set autorange for Y c1.setAutoRange(1,1) h1.setColor(Color.blue) c1.draw(h1) h2.setColor(Color.red) c1.draw(h2) c1.setNameX("Xaxis") c1.setNameY("Yaxis") c1.setName("Canvas title") c1.update() # 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 jhplot.io.FileAida Here is a simile example showing how to read an AIDA file and plot Clouds and histograms:
<jcode lang="python" > dmelt 90533913.py
The output of this script is shown below.
See the example "io_read_root.py" 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.