Subsections

1.6 Plotting ROOT or AIDA data using jHepWork IDE

On can use jHepWork IDE to read data files written in ROOT or AIDA format. You can do this as:

One can find more on how to read ROOT or AIDA files in the Sections :autorefGetting started with jHepWork Java classes3.8 and Section :autorefGetting started with jHepWork Java classes3.5.3.

1.6.1 Jython scripting with jHepWork

jHepWork allows scripting with histograms and other high-level objects with a syntax which is very more elegant and easy to work with. To see this, look at the Jython example below (we use the line starting from # for explanations):

>>> from java.util import Random
>>> from  shplot import *
>>>
>>> c1=hplot("scripting",1,2)     # build a canvas with 2 plots  
>>> h1=h1d("histogram1",200,-5,5) # make histogram 1  
>>> h2=h1d("histogram2",200,-5,5) # make histogram 1 
>>> r=Random()                    # fill histograms  
>>> for i in range(500):
          h1.fill(r.nextGaussian())
          h2.fill(0.2*r.nextGaussian())
>>> h1=h1+h2*2                    # add 2 histograms, second scaled by 2  
>>> c1+h1                         # draw h1 on c1 canvas  
>>> h1=h1*2                       # scale by a factor 2 
>>> c1.cd(1,2)                    # go to the next plot 
>>> h1=h1-h2                      # subtract 2 histograms

This illustrates the simplicity of Jython scripting. It also shows that the most common operators like +, -, *,/ are overloaded. It should be noted that all objects created in the example above are Jython instances which inherit Java classes of jHPlot package.

We will discuss jHepWork scripting in Chapter :autorefJython scripting with jHepWork4 in more details. Below we will discuss a Jython scripting based on Java instances, rather then on Jython ones. Since Java does not allow the operator overloading, it is impossible to use the operators +, -, *,/ when you create Java instances.